4 kyu
Nesting Structure Comparison
9,680 of 23,806nklein
Description:
Complete the function/method (depending on the language) to return true
/True
when its argument is an array that has the same nesting structures and same corresponding length of nested arrays as the first array.
For example:
// should return true
[ 1, 1, 1 ].sameStructureAs( [ 2, 2, 2 ] );
[ 1, [ 1, 1 ] ].sameStructureAs( [ 2, [ 2, 2 ] ] );
// should return false
[ 1, [ 1, 1 ] ].sameStructureAs( [ [ 2, 2 ], 2 ] );
[ 1, [ 1, 1 ] ].sameStructureAs( [ [ 2 ], 2 ] );
// should return true
[ [ [ ], [ ] ] ].sameStructureAs( [ [ [ ], [ ] ] ] );
// should return false
[ [ [ ], [ ] ] ].sameStructureAs( [ [ 1, 1 ] ] );
For your convenience, there is already a function 'isArray(o)' declared and defined that returns true if its argument is an array, false otherwise.
Arrays
Algorithms
Similar Kata:
Stats:
Created | Aug 9, 2013 |
Published | Aug 9, 2013 |
Warriors Trained | 66505 |
Total Skips | 16244 |
Total Code Submissions | 242418 |
Total Times Completed | 23806 |
JavaScript Completions | 9680 |
Python Completions | 12456 |
Ruby Completions | 1031 |
PHP Completions | 821 |
Total Stars | 1287 |
% of votes with a positive feedback rating | 87% of 2197 |
Total "Very Satisfied" Votes | 1735 |
Total "Somewhat Satisfied" Votes | 364 |
Total "Not Satisfied" Votes | 98 |