https://github.com/yll0rd/nesting-structure-comparison-exercise
https://github.com/yll0rd/nesting-structure-comparison-exercise
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yll0rd/nesting-structure-comparison-exercise
- Owner: yll0rd
- Created: 2023-01-15T06:00:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-15T09:35:46.000Z (over 3 years ago)
- Last Synced: 2025-04-14T14:58:03.614Z (about 1 year ago)
- Language: Python
- Size: 1.95 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nesting-Structure-Comparison-exercise
A function/method that returns 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**
same_structure_as([ 1, 1, 1 ], [ 2, 2, 2 ] )
same_structure_as([ 1, [ 1, 1 ] ], [ 2, [ 2, 2 ] ] )
**should return False**
same_structure_as([ 1, [ 1, 1 ] ], [ [ 2, 2 ], 2 ] )
same_structure_as([ 1, [ 1, 1 ] ], [ [ 2 ], 2 ] )
**should return True**
same_structure_as([ [ [ ], [ ] ] ], [ [ [ ], [ ] ] ] )
**should return False**
same_structure_as([ [ [ ], [ ] ] ], [ [ 1, 1 ] ] )
The exercise is on [Codewars](https://www.codewars.com/kata/520446778469526ec0000001/train/python)