From f5db67ea15508a1241e27a7248406c3a9ababc2d Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:54:30 +0200 Subject: [PATCH 1/3] revise instructions --- exercises/flatten-array/description.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/exercises/flatten-array/description.md b/exercises/flatten-array/description.md index 6b88385494..3bf5fd0efc 100644 --- a/exercises/flatten-array/description.md +++ b/exercises/flatten-array/description.md @@ -1,11 +1,16 @@ # Description -Take a nested list and return a single flattened list with all values except nil/null. +Take a nested array of any depth and return a fully flattened array. -The challenge is to take an arbitrarily-deep nested list-like structure and produce a flattened structure without any nil/null values. +Note that some language tracks may include null-like values in the input array, and the way these values are represented varies by track. +Such values should be excluded from the flattened array. -For example: +Additionally, input arrays may have data of different types, depending on the track. -input: [1,[2,3,null,4],[null],5] +Check the test suite for details. -output: [1,2,3,4,5] +## Example + +input: `[1,[2,6,null],[[null,[4]],5]]` + +output: `[1,2,6,4,5]` From d5509de9252af69d1bb448285645354aae271689 Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Thu, 27 Feb 2025 01:27:50 +0200 Subject: [PATCH 2/3] replace references to lists with arrays in test descriptions --- exercises/flatten-array/canonical-data.json | 107 ++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/exercises/flatten-array/canonical-data.json b/exercises/flatten-array/canonical-data.json index 7b24b5d6a7..20560ecba6 100644 --- a/exercises/flatten-array/canonical-data.json +++ b/exercises/flatten-array/canonical-data.json @@ -183,6 +183,23 @@ 3 ] }, + { + "uuid": "bc72da10-5f55-4ada-baf3-50e4da02ec8e", + "reimplements": "c6cf26de-8ccd-4410-84bd-b9efd88fd2bc", + "description": "consecutive null values at the front of the array are omitted from the final result", + "comments": ["Replaces references to lists with arrays in description."], + "property": "flatten", + "input": { + "array": [ + null, + null, + 3 + ] + }, + "expected": [ + 3 + ] + }, { "uuid": "382c5242-587e-4577-b8ce-a5fb51e385a1", "description": "consecutive null values in the middle of the list are omitted from the final result", @@ -200,6 +217,25 @@ 4 ] }, + { + "uuid": "6991836d-0d9b-4703-80a0-3f1f23eb5981", + "reimplements": "382c5242-587e-4577-b8ce-a5fb51e385a1", + "description": "consecutive null values in the middle of the array are omitted from the final result", + "comments": ["Replaces references to lists with arrays in description."], + "property": "flatten", + "input": { + "array": [ + 1, + null, + null, + 4 + ] + }, + "expected": [ + 1, + 4 + ] + }, { "uuid": "ef1d4790-1b1e-4939-a179-51ace0829dbd", "description": "6 level nest list with null values", @@ -239,6 +275,47 @@ -2 ] }, + { + "uuid": "dc90a09c-5376-449c-a7b3-c2d20d540069", + "reimplements": "ef1d4790-1b1e-4939-a179-51ace0829dbd", + "description": "6 level nested array with null values", + "comments": ["Replaces references to lists with arrays in description."], + "property": "flatten", + "input": { + "array": [ + 0, + 2, + [ + [ + 2, + 3 + ], + 8, + [ + [ + 100 + ] + ], + null, + [ + [ + null + ] + ] + ], + -2 + ] + }, + "expected": [ + 0, + 2, + 2, + 3, + 8, + 100, + -2 + ] + }, { "uuid": "85721643-705a-4150-93ab-7ae398e2942d", "description": "all values in nested list are null", @@ -266,6 +343,36 @@ ] }, "expected": [] + }, + { + "uuid": "51f5d9af-8f7f-4fb5-a156-69e8282cb275", + "reimplements": "85721643-705a-4150-93ab-7ae398e2942d", + "description": "all values in nested array are null", + "comments": ["Replaces references to lists with arrays in description."], + "property": "flatten", + "input": { + "array": [ + null, + [ + [ + [ + null + ] + ] + ], + null, + null, + [ + [ + null, + null + ], + null + ], + null + ] + }, + "expected": [] } ] } From 1fab5f3282c8f749a4a4e3c1ebb9c4b2fbcd570f Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Fri, 28 Feb 2025 20:03:57 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Isaac Good --- exercises/flatten-array/description.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/flatten-array/description.md b/exercises/flatten-array/description.md index 3bf5fd0efc..7601e7a9e9 100644 --- a/exercises/flatten-array/description.md +++ b/exercises/flatten-array/description.md @@ -5,12 +5,12 @@ Take a nested array of any depth and return a fully flattened array. Note that some language tracks may include null-like values in the input array, and the way these values are represented varies by track. Such values should be excluded from the flattened array. -Additionally, input arrays may have data of different types, depending on the track. +Additionally, the input may be of a different data type and contain different types, depending on the track. Check the test suite for details. ## Example -input: `[1,[2,6,null],[[null,[4]],5]]` +input: `[1, [2, 6, null], [[null, [4]], 5]]` -output: `[1,2,6,4,5]` +output: `[1, 2, 6, 4, 5]`