Skip to content

Leaves - Sabrina#31

Open
Galaxylaughing wants to merge 7 commits intoAda-C12:masterfrom
Galaxylaughing:master
Open

Leaves - Sabrina#31
Galaxylaughing wants to merge 7 commits intoAda-C12:masterfrom
Galaxylaughing:master

Conversation

@Galaxylaughing
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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.

Comment thread lib/super_digit.rb Outdated
# Space Complexity - O(log n)
def super_digit(n)

puts "super_digit("+n.to_s+")"
Copy link
Copy Markdown

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+")"

Comment thread lib/super_digit.rb Outdated
else
sum = 0
while ((n / 10.0) > 0)
puts " while"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
puts " while"

Comment thread lib/fibonacci.rb
return new_solution
end

solutions = [last_solution, new_solution]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/super_digit.rb
# 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)
Copy link
Copy Markdown

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?

Comment thread lib/fibonacci.rb
# 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)
Copy link
Copy Markdown

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