diff --git a/bin/format-array.rb b/bin/format-array.rb index 3679694de8..af4ba90765 100644 --- a/bin/format-array.rb +++ b/bin/format-array.rb @@ -48,6 +48,10 @@ 'array' => :multi_line_deep, 'expected' => :multi_line, }, + 'flower-field' => { + 'garden' => :multi_line_unless_single, + 'expected' => :multi_line_unless_single, + }, 'forth' => { 'instructions' => :multi_line_unless_single, }, diff --git a/exercises/flower-field/canonical-data.json b/exercises/flower-field/canonical-data.json new file mode 100644 index 0000000000..b9e538c7ef --- /dev/null +++ b/exercises/flower-field/canonical-data.json @@ -0,0 +1,201 @@ +{ + "exercise": "flower-field", + "comments": [ + "The expected outputs are represented as arrays of strings to", + "improve readability in this JSON file.", + "Your track may choose whether to present the input as a single", + "string (concatenating all the lines) or as the list." + ], + "cases": [ + { + "uuid": "237ff487-467a-47e1-9b01-8a891844f86c", + "description": "no rows", + "property": "annotate", + "input": { + "garden": [] + }, + "expected": [] + }, + { + "uuid": "4b4134ec-e20f-439c-a295-664c38950ba1", + "description": "no columns", + "property": "annotate", + "input": { + "garden": [""] + }, + "expected": [""] + }, + { + "uuid": "d774d054-bbad-4867-88ae-069cbd1c4f92", + "description": "no flowers", + "property": "annotate", + "input": { + "garden": [ + " ", + " ", + " " + ] + }, + "expected": [ + " ", + " ", + " " + ] + }, + { + "uuid": "225176a0-725e-43cd-aa13-9dced501f16e", + "description": "garden full of flowers", + "property": "annotate", + "input": { + "garden": [ + "***", + "***", + "***" + ] + }, + "expected": [ + "***", + "***", + "***" + ] + }, + { + "uuid": "3f345495-f1a5-4132-8411-74bd7ca08c49", + "description": "flower surrounded by spaces", + "property": "annotate", + "input": { + "garden": [ + " ", + " * ", + " " + ] + }, + "expected": [ + "111", + "1*1", + "111" + ] + }, + { + "uuid": "6cb04070-4199-4ef7-a6fa-92f68c660fca", + "description": "space surrounded by flowers", + "property": "annotate", + "input": { + "garden": [ + "***", + "* *", + "***" + ] + }, + "expected": [ + "***", + "*8*", + "***" + ] + }, + { + "uuid": "272d2306-9f62-44fe-8ab5-6b0f43a26338", + "description": "horizontal line", + "property": "annotate", + "input": { + "garden": [" * * "] + }, + "expected": ["1*2*1"] + }, + { + "uuid": "c6f0a4b2-58d0-4bf6-ad8d-ccf4144f1f8e", + "description": "horizontal line, flowers at edges", + "property": "annotate", + "input": { + "garden": ["* *"] + }, + "expected": ["*1 1*"] + }, + { + "uuid": "a54e84b7-3b25-44a8-b8cf-1753c8bb4cf5", + "description": "vertical line", + "property": "annotate", + "input": { + "garden": [ + " ", + "*", + " ", + "*", + " " + ] + }, + "expected": [ + "1", + "*", + "2", + "*", + "1" + ] + }, + { + "uuid": "b40f42f5-dec5-4abc-b167-3f08195189c1", + "description": "vertical line, flowers at edges", + "property": "annotate", + "input": { + "garden": [ + "*", + " ", + " ", + " ", + "*" + ] + }, + "expected": [ + "*", + "1", + " ", + "1", + "*" + ] + }, + { + "uuid": "58674965-7b42-4818-b930-0215062d543c", + "description": "cross", + "property": "annotate", + "input": { + "garden": [ + " * ", + " * ", + "*****", + " * ", + " * " + ] + }, + "expected": [ + " 2*2 ", + "25*52", + "*****", + "25*52", + " 2*2 " + ] + }, + { + "uuid": "dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8", + "description": "large garden", + "property": "annotate", + "input": { + "garden": [ + " * * ", + " * ", + " * ", + " * *", + " * * ", + " " + ] + }, + "expected": [ + "1*22*1", + "12*322", + " 123*2", + "112*4*", + "1*22*2", + "111111" + ] + } + ] +} diff --git a/exercises/flower-field/instructions.md b/exercises/flower-field/instructions.md new file mode 100644 index 0000000000..bbdae0c2cb --- /dev/null +++ b/exercises/flower-field/instructions.md @@ -0,0 +1,26 @@ +# Instructions + +Your task is to add flower counts to empty squares in a completed Flower Field garden. +The garden itself is a rectangle board composed of squares that are either empty (`' '`) or a flower (`'*'`). + +For each empty square, count the number of flowers adjacent to it (horizontally, vertically, diagonally). +If the empty square has no adjacent flowers, leave it empty. +Otherwise replace it with the count of adjacent flowers. + +For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen): + +```text +·*·*· +··*·· +··*·· +····· +``` + +Which your code should transform into this: + +```text +1*3*1 +13*31 +·2*2· +·111· +``` diff --git a/exercises/flower-field/introduction.md b/exercises/flower-field/introduction.md new file mode 100644 index 0000000000..af9b615361 --- /dev/null +++ b/exercises/flower-field/introduction.md @@ -0,0 +1,7 @@ +# Introduction + +[Flower Field][history] is a compassionate reimagining of the popular game Minesweeper. +The object of the game is to find all the flowers in the garden using numeric hints that indicate how many flowers are directly adjacent (horizontally, vertically, diagonally) to a square. +"Flower Field" shipped in regional versions of Microsoft Windows in Italy, Germany, South Korea, Japan and Taiwan. + +[history]: https://web.archive.org/web/20020409051321fw_/http://rcm.usr.dsi.unimi.it/rcmweb/fnm/ diff --git a/exercises/flower-field/metadata.toml b/exercises/flower-field/metadata.toml new file mode 100644 index 0000000000..61ced447f2 --- /dev/null +++ b/exercises/flower-field/metadata.toml @@ -0,0 +1,4 @@ +title = "Flower Field" +blurb = "Mark all the flowers in a garden." +deep_dive_youtube_id = "dLT2h2hODhs" +deep_dive_blurb = "We explore nested for loops, clever use of min/max to simplify bounds checking, functional pipelines and using two-dimensional matrices." diff --git a/exercises/minesweeper/.deprecated b/exercises/minesweeper/.deprecated new file mode 100644 index 0000000000..61cb2d5013 --- /dev/null +++ b/exercises/minesweeper/.deprecated @@ -0,0 +1,3 @@ +**NOTE: This exercise has been deprecated** +Your track should implement "flower-field" instead. +https://forum.exercism.org/t/suggestion-deprecate-minesweeper-for-flower-field/17967