Skip to content

Conversation

@Galaxylaughing
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall nice work, you hit the learning goals here. Well done.

# Space Complexity - O(log n)
def super_digit(n)

puts "super_digit("+n.to_s+")"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest leaving these out when you submit an answer.

Suggested change
puts "super_digit("+n.to_s+")"

else
sum = 0
while ((n / 10.0) > 0)
puts " while"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
puts " while"

return new_solution
end

solutions = [last_solution, new_solution]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

# because the while loop to create the concatenated number
# and the while loop adding the digits of the number are not nested.
# Space Complexity - O(log k * n)
def refined_super_digit(n, k)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the brute-force solution here. Can you think of a better way to do this with dynamic programming?

# you only keep the last two solutions, so the solutions array does not grow,
# but you're still effectiving the stack by adding recursive calls
# Hint, you may want a recursive helper method
def fibonacci(n)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants