We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Lego Blocks
- Discussions
Lego Blocks
Lego Blocks
Sort by
recency
|
86 Discussions
|
Please Login in order to post a comment
I was so ready to give up on this Even with @dusanki solution, I didn't understand why the maths works.
It was only when I found on the internet an explanation with pictures that it all clicked.
I will probably implement it now. Just for closure. But I feel like Hackerrank has stolen a part of my life 😛
so what kind of education do you need to be able solve this? i've been in IT 18 years and i don't think i could've ever solved this without internet assistance
I don't know who needs to hears this, but as a 8 YoE software engineer, this took me an entire weekend to solve ^^'.
A little spoiler-free tip I wish I had:
Having some difficult with a valid JavaScript version. The values that are failing are when combinations get over MOD (10^9 +7) Has anybody got a JavaScript version working or can spot the error in this code? Thanks
*(legoBlocks(8,10) on my code is giving 634608018.
Hacker rank is giving 634597424*
}
This question wrinkled my brain until I looked at Willis42's code. Here's some extra annotation in case it helps.
def legoBlocks(n, m): # the ways to build a line of m from 0 up to 4 using legobricks from 1-4 # this takes the prev sums and adds one more way to it each time permutations = [0, 1, 2, 4, 8] mod = 10**9+7 # just keeps our numbers from getting too large - wraps if so