From: Lee Daekeun Date: 2013-04-15T13:29:04+09:00 Subject: Re: simple lambda question --047d7bd74ac43deec304da5eb1c5 Content-Type: text/plain; charset=ISO-8859-1 Like this? 100.times.select{|a| a*a>1000}.map{|a| [a, (a*a).to_s]}.select{|a| a[1][0]==a[1][1] and a[1][2]==a[1][3]} 2013/4/15 Hyun Oh K. > hello, I am newbie for ruby. > these days i am forcusing learning about ruby languages. > and I wonder and hope ruby will be simply answer below quiz just one > line. > below is python code. > > Python 2.3.4 (#1, Nov 10 2004, 13:08:40) [C] on sunos5 > Type "help", "copyright", "credits" or "license" for more information. > >>> > >>> a=0 > >>> while a*a < 10000: > ... if a*a > 1000: > ... s = str(a*a) > ... if s[0]==s[1] and s[2]==s[3]: > ... print a, a*a > ... a = a+1 > ... > 88 7744 > >>> > > quiz is about number. > and ruby have lambda func. so I hope easly solution make. > anybody wellknown ruby user, help and solve above quiz. > Thank you~! > > -- > Posted via http://www.ruby-forum.com/. > > -- Daekeun Lee Department of Computer Science Korea Advanced Institute of Science and Technology (KAIST) +82 10-4012-4809 zmsquf99@gmail.com http://www.facebook.com/daekeun.lee @zmsquf99 --047d7bd74ac43deec304da5eb1c5 Content-Type: text/html; charset=ISO-8859-1
Like this?

100.times.select{|a| a*a>1000}.map{|a| [a, (a*a).to_s]}.select{|a| a[1][0]==a[1][1] and a[1][2]==a[1][3]}


2013/4/15 Hyun Oh K. <lists@ruby-forum.com>
hello, I am newbie for ruby.
these days i am forcusing learning about ruby languages.
and I wonder and hope ruby will be simply answer below quiz just one
line.
below is python code.

Python 2.3.4 (#1, Nov 10 2004, 13:08:40) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> a=0
>>> while a*a < 10000:
... if a*a > 1000:
... s = str(a*a)
... if s[0]==s[1] and s[2]==s[3]:
... print a, a*a
... a = a+1
...
88 7744
>>>

quiz is about number.
and ruby have lambda func. so I hope easly solution make.
anybody wellknown ruby user, help and solve above quiz.
Thank you~!

--
Posted via http://www.ruby-forum.com/.




--
Daekeun Lee

Department of Computer Science
Korea Advanced Institute of Science and Technology (KAIST)
+82 10-4012-4809
zmsquf99@gmail.com

http://www.facebook.com/daekeun.lee
@zmsquf99
--047d7bd74ac43deec304da5eb1c5--