• Sign Up
    Time to claim your honor
  • Training
  • Practice
    Complete challenging Kata to earn honor and ranks. Re-train to hone technique
  • Freestyle Sparring
    Take turns remixing and refactoring others code through Kumite
  • Community
  • Leaderboards
    Achieve honor and move up the global leaderboards
  • Chat
    Join our Discord server and chat with your fellow code warriors
  • Discussions
    View our Github Discussions board to discuss general Codewars topics
  • About
  • Docs
    Learn about all of the different aspects of Codewars
  • Blog
    Read the latest news from Codewars and the community
  • Log In
  • Sign Up
chesterl Avatar
Name:Unknown
Clan:CodeCore
Skills:ruby, javascript
Member Since:Mar 2015
Last Seen:Jun 2024
Profiles:
Following:174
Followers:174
Allies:174
View Profile Badges
  • Stats
  • Kata
  • Collections
  • Kumite
  • Social
  • Discourse
  • Conversations (10)
  • Replies
  • Authored
  • Needs Resolution
  • Custom User Avatar
    • badswimmer
    • commented on "Jenny's secret message" ruby solution
    • 8 years ago

    Totally agreed.

  • Custom User Avatar
    • chesterl
    • commented on "Return to Sanity" kata
    • 10 years ago

    Agreed. No idea what is being asked

  • Custom User Avatar
    • Abbe
    • commented on "Musical Pitch Classes" ruby solution
    • 10 years ago

    Well, the two possible values are -1 and 11:

    -1 - (-1) = 0   =  0 * 12
    -1 - (11) = -12 = -1 * 12
    

    In ruby, the result always have the same sign as the second operand (12 in this case) so it must be 11.

    The resulting sign when doing modulus between negative numbers varies between different programming languages. There is a table in the right margin here that shows the chaos: http://en.wikipedia.org/wiki/Modulo_operation#Remainder_calculation_for_the_modulo_operation.

  • Custom User Avatar
    • chesterl
    • commented on "Enumerable Magic #5- True for Just One?" ruby solution
    • 10 years ago

    I agree that this isn't really solving it, though it is an acceptable solution. Afterall since he gave you the link, it's not hard to realize that there is a method that will perform the task for you. That being said, you get more out of it as a beginner trying to solve it and knowing that there is a shortcut for it.

  • Custom User Avatar
    • chesterl
    • commented on "Musical Pitch Classes" ruby solution
    • 10 years ago

    While the code is compact, I think the chained ternary is hard to read

  • Custom User Avatar
    • chesterl
    • commented on "Musical Pitch Classes" ruby solution
    • 10 years ago

    why does -1 % 12 equal 11?

  • Custom User Avatar
    • chesterl
    • commented on "N-th Fibonacci" ruby solution
    • 10 years ago

    Thanks!
    I also found this useful for anyone newer

    https://www.youtube.com/watch?v=zg-ddPbzcKM

  • Custom User Avatar
    • colbydauph
    • commented on "N-th Fibonacci" ruby solution
    • 10 years ago

    This is an example of recursion. The concept is present in many programming languages, and mathematics in general.

    The equation for a single fibonacci number is dependent on the two previous fibonacci numbers (for all but n == 1 && n == 2). These are determined by either:

    • Calling the fibonacci method again from within the fibonacci method itself (which may in turn call itself many more times, until it hits a seed value).
    • Hitting an n value that acts as a seed. These seed values are required to prevent infinite recursion, and are implemented as the following lines in this solution:
    return 0 if n == 1
    return 1 if n == 2
    

    For a ruby specific explanation of recursion, check out this StackOverflow Post.

    For a more broad, mathematical explanation (including fibonacci numbers) see the wiki article on Recurrence relations.

  • Custom User Avatar
    • chesterl
    • commented on "N-th Fibonacci" ruby solution
    • 10 years ago

    Can someone explain how this works?
    Newer to ruby and don't understand this method with a method call...?

    nth_fibonacci(n-1)+nth_fibonacci(n-2)

  • Custom User Avatar
    • chesterl
    • commented on "Good vs Evil" kata
    • 11 years ago

    My last test is also failing but the original tie in the original 3 tests is fine

  • © 2025 Codewars
  • About
  • API
  • Blog
  • Privacy
  • Terms
  • Code of Conduct
  • Contact

Confirm

  • Cancel
  • Confirm

Collect: undefined

Loading collection data...