Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
[QUIZ] Happy Numbers (#93)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Éric DUMINIL, post: 4525558"] Hi! I'd just like to post my isHappy? method: class Integer def isHappy? return to_s.split(//).collect{|digit| digit.to_i**2}.inject{|sum, n| sum + n }.isHappy? while self!=1 true rescue false end end puts 115485454654987986246476765451256546545241654555555555555555555555555555555555554125665146454122345444487.isHappy? true This method may return false negative (if happiness>maximum stack level), though I doubt no one will ever find one! Thanks for the quiz, Eric [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
[QUIZ] Happy Numbers (#93)
Top