Finished
11def flatten(iterable):
2 pass
2 result = []
3
4 # Edge Case: Handle None input
5 if iterable is None:
6 return result
7
8 # Edge Case: Handle empty input
9 if not iterable:
10 return result
11
12 for item in iterable:
13 # Edge Case: Skip None values
14 if item is None:
15 continue
16 # Edge Case: Handle nested lists
17 if isinstance(item, list):
18 result.extend(flatten(item))
19 else:
20 result.append(item)
21
22 return result
23# Handled Edge Cases: None input, empty input, None values in array, nested lists of any depth
Test NameStatus
test_5_level_nesting
Pass
test_6_level_nested_array_with_null_values
Pass
test_6_level_nesting
Pass
test_all_values_in_nested_array_are_null
Pass
test_consecutive_null_values_at_the_front_of_the_array_are_omitted_from_the_final_result
Pass
test_consecutive_null_values_in_the_middle_of_the_array_are_omitted_from_the_final_result
Pass
test_empty
Pass
test_flattens_a_nested_array
Pass
test_flattens_array_with_just_integers_present
Pass
test_no_nesting
Pass
test_null_values_are_omitted_from_the_final_result
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.