Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I have got the same approach but I divided every action in a different line. This way more readable for me. I failed to make a sandwich like you did, still need to train.
It is good to have everything in one line. Saves code space. Good job.
This is a good solution!
In my opnion it is easier to read,
if the arguement from map is extracted in a function
and the methode calls are in seperate lines.
Thanks for the example case, I think I misread the if/else logic the first time round. Much appreciated!
This is for this case
Test.expect(![1,1].sameStructureAs([[2,2],2]), "[1,1] not same as [[2,2],2]");
without the else your solution returns true
This comment is hidden because it contains spoiler information about the solution
hi, could someone help explain the line:
c = n.to_s.split('').each.with_index.inject(0){ |s, (v, i)|
s + v.to_i ** (p + i)
}
I understand that this sums the series as required in the problem description, but am unsure how the behaviour of .with_index works with .inject(0) {|s,(v,i)| ... } to create the sum. From my searches on stackoverflow, my guess is that with_index creates a key-value hash that corresponds with (v, i), and interacts with the inject enumerator? Appreciate if someone could clarify on this please.