-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queues - Erica Case - Recursion tracing #16
base: master
Are you sure you want to change the base?
Conversation
else | ||
return s[0] + mystery5(s[1..-1]) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
return "" | ||
end | ||
return s[(s.length - 1)] + mystery6(s[0...(s.length-1)]) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code looks like Java code ;)
else | ||
return (n%10) * n / n.abs + mystery2(n/10) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it may work - but is a little hard to follow. Here's another solution that's perhaps more readable.
def mystery2(n)
if n < 0
return -1 * mystery2(-n)
elsif n < 10
return n
else
return (n%10) + mystery2(n/10)
end
end
Nice work! |
Recursion Tracing
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions