Skip to content

Conversation

@aphunk
Copy link

@aphunk aphunk commented Oct 13, 2019

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.

Nice work, you fully applied dynamic programming to these solutions. Well done!

## Wave 1 Newman-Conway Sequence

[Newman-Conway sequence](https://archive.lib.msu.edu/crcmath/math/math/n/n078.htm) is the one which generates the following integer sequence. 1 1 2 2 3 4 4 4 5 6 7 7….. and follows below recursive formula.
[Newman-Conway sequence](https://archive.lib.msu.edu/crcmath/math/math/n/n078.htm) is the one which generates the following integer sequence. 1 1 2 2 3 4 4 4 5 6 7 7….. and follows the below recursive formula.

Choose a reason for hiding this comment

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

😃

# Space Complexity: ?
# Time complexity: O(n) where n is the size of the input
# Space Complexity: O(n) where n is the size of the input (space needed for storing each char)
def newman_conway(num)

Choose a reason for hiding this comment

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

👍

Comment on lines +8 to +17
result = []
num.times do |i|
if i < 2
result << 1
else
last_char = result[i - 1]
result[i] = result[last_char - 1] + result[i - last_char]
end
end
return result.join(" ")

Choose a reason for hiding this comment

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

Very elegant solution!

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