diff --git a/config.json b/config.json
index 9d5eb72..c21a6db 100644
--- a/config.json
+++ b/config.json
@@ -8,9 +8,6 @@
"representer": false,
"analyzer": false
},
- "test_runner": {
- "average_run_time": 9
- },
"blurb": "ABAP is a high level programming language created by SAP",
"version": 3,
"online_editor": {
@@ -18,13 +15,18 @@
"indent_size": 2,
"highlightjs_language": "abap"
},
+ "test_runner": {
+ "average_run_time": 9
+ },
"exercises": {
"concept": [
{
"slug": "lasagna",
"name": "Lucian's Luscious Lasagna",
"uuid": "0bb8f970-fe74-41f2-8ae6-2d771d87b607",
- "concepts": ["basics"],
+ "concepts": [
+ "basics"
+ ],
"prerequisites": [],
"status": "wip"
}
@@ -181,7 +183,10 @@
"practices": [],
"prerequisites": [],
"difficulty": 2,
- "topics": ["parsing", "transforming"]
+ "topics": [
+ "parsing",
+ "transforming"
+ ]
},
{
"slug": "raindrops",
@@ -223,13 +228,22 @@
"prerequisites": [],
"difficulty": 2
},
+ {
+ "slug": "flower-field",
+ "name": "Flower Field",
+ "uuid": "6e096ef1-5502-446f-b32c-65c3e4a8166b",
+ "practices": [],
+ "prerequisites": [],
+ "difficulty": 5
+ },
{
"slug": "minesweeper",
"name": "Minesweeper",
"uuid": "c8f6abc0-41a4-4104-8050-2df35f0d469a",
"practices": [],
"prerequisites": [],
- "difficulty": 5
+ "difficulty": 5,
+ "status": "deprecated"
},
{
"slug": "word-count",
@@ -238,7 +252,12 @@
"practices": [],
"prerequisites": [],
"difficulty": 1,
- "topics": ["loops", "lists", "regular_expressions", "strings"]
+ "topics": [
+ "loops",
+ "lists",
+ "regular_expressions",
+ "strings"
+ ]
},
{
"slug": "beer-song",
@@ -247,7 +266,11 @@
"practices": [],
"prerequisites": [],
"difficulty": 5,
- "topics": ["conditionals", "loops", "strings"]
+ "topics": [
+ "conditionals",
+ "loops",
+ "strings"
+ ]
},
{
"slug": "darts",
@@ -380,43 +403,43 @@
],
"key_features": [
{
- "icon": "evolving",
"title": "Evolving",
- "content": "ABAP is a modern and constantly evolving language supported by SAP."
+ "content": "ABAP is a modern and constantly evolving language supported by SAP.",
+ "icon": "evolving"
},
{
- "icon": "fun",
"title": "Fun",
- "content": "Always a new or old feature to discover."
+ "content": "Always a new or old feature to discover.",
+ "icon": "fun"
},
{
- "icon": "easy",
"title": "Easy",
- "content": "Statements are easily readable and understandable."
+ "content": "Statements are easily readable and understandable.",
+ "icon": "easy"
},
{
- "icon": "productive",
"title": "Productive",
- "content": "Easily create data structures and interact with database contents."
+ "content": "Easily create data structures and interact with database contents.",
+ "icon": "productive"
},
{
- "icon": "statically-typed",
"title": "Typed",
- "content": "Static types linked to database schemas."
+ "content": "Static types linked to database schemas.",
+ "icon": "statically-typed"
},
{
- "icon": "stable",
"title": "Reliability",
- "content": "Stable functionality to run the core of the worlds largest businesses."
+ "content": "Stable functionality to run the core of the worlds largest businesses.",
+ "icon": "stable"
}
],
"tags": [
+ "execution_mode/compiled",
"paradigm/object_oriented",
"paradigm/procedural",
+ "runtime/language_specific",
"typing/static",
"typing/strong",
- "execution_mode/compiled",
- "runtime/language_specific",
"used_for/backends",
"used_for/financial_systems"
]
diff --git a/exercises/practice/flower-field/.docs/instructions.md b/exercises/practice/flower-field/.docs/instructions.md
new file mode 100644
index 0000000..bbdae0c
--- /dev/null
+++ b/exercises/practice/flower-field/.docs/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/practice/flower-field/.docs/introduction.md b/exercises/practice/flower-field/.docs/introduction.md
new file mode 100644
index 0000000..af9b615
--- /dev/null
+++ b/exercises/practice/flower-field/.docs/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/practice/flower-field/.meta/config.json b/exercises/practice/flower-field/.meta/config.json
new file mode 100644
index 0000000..8ade38f
--- /dev/null
+++ b/exercises/practice/flower-field/.meta/config.json
@@ -0,0 +1,20 @@
+{
+ "authors": [
+ "mbtools"
+ ],
+ "contributors": [
+ "BNAndras"
+ ],
+ "files": {
+ "solution": [
+ "zcl_flower_field.clas.abap"
+ ],
+ "test": [
+ "zcl_flower_field.clas.testclasses.abap"
+ ],
+ "example": [
+ ".meta/zcl_flower_field.clas.abap"
+ ]
+ },
+ "blurb": "Mark all the flowers in a garden."
+}
diff --git a/exercises/practice/flower-field/.meta/tests.toml b/exercises/practice/flower-field/.meta/tests.toml
new file mode 100644
index 0000000..c2b24fd
--- /dev/null
+++ b/exercises/practice/flower-field/.meta/tests.toml
@@ -0,0 +1,46 @@
+# This is an auto-generated file.
+#
+# Regenerating this file via `configlet sync` will:
+# - Recreate every `description` key/value pair
+# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
+# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
+# - Preserve any other key/value pair
+#
+# As user-added comments (using the # character) will be removed when this file
+# is regenerated, comments can be added via a `comment` key.
+
+[237ff487-467a-47e1-9b01-8a891844f86c]
+description = "no rows"
+
+[4b4134ec-e20f-439c-a295-664c38950ba1]
+description = "no columns"
+
+[d774d054-bbad-4867-88ae-069cbd1c4f92]
+description = "no flowers"
+
+[225176a0-725e-43cd-aa13-9dced501f16e]
+description = "garden full of flowers"
+
+[3f345495-f1a5-4132-8411-74bd7ca08c49]
+description = "flower surrounded by spaces"
+
+[6cb04070-4199-4ef7-a6fa-92f68c660fca]
+description = "space surrounded by flowers"
+
+[272d2306-9f62-44fe-8ab5-6b0f43a26338]
+description = "horizontal line"
+
+[c6f0a4b2-58d0-4bf6-ad8d-ccf4144f1f8e]
+description = "horizontal line, flowers at edges"
+
+[a54e84b7-3b25-44a8-b8cf-1753c8bb4cf5]
+description = "vertical line"
+
+[b40f42f5-dec5-4abc-b167-3f08195189c1]
+description = "vertical line, flowers at edges"
+
+[58674965-7b42-4818-b930-0215062d543c]
+description = "cross"
+
+[dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8]
+description = "large garden"
diff --git a/exercises/practice/flower-field/.meta/zcl_flower_field.clas.abap b/exercises/practice/flower-field/.meta/zcl_flower_field.clas.abap
new file mode 100644
index 0000000..977996a
--- /dev/null
+++ b/exercises/practice/flower-field/.meta/zcl_flower_field.clas.abap
@@ -0,0 +1,87 @@
+CLASS zcl_flower_field DEFINITION PUBLIC FINAL CREATE PUBLIC.
+
+ PUBLIC SECTION.
+
+ METHODS annotate
+ IMPORTING
+ !input TYPE string_table
+ RETURNING
+ VALUE(result) TYPE string_table.
+
+ENDCLASS.
+
+
+
+CLASS zcl_flower_field IMPLEMENTATION.
+ METHOD annotate.
+
+ DATA n TYPE n LENGTH 1.
+ DATA res TYPE string.
+
+ CONCATENATE LINES OF input INTO DATA(field) RESPECTING BLANKS.
+ DATA(count) = strlen( field ).
+ DATA(rows) = lines( input ).
+ DATA(cols) = count DIV rows.
+
+ DO rows TIMES.
+ DATA(row) = sy-index - 1.
+ DO cols TIMES.
+ DATA(col) = sy-index - 1.
+ n = 0.
+ DO 9 TIMES.
+ CASE sy-index.
+ WHEN 1.
+ DATA(r) = row.
+ DATA(c) = col.
+ WHEN 2.
+ r = row.
+ c = col + 1.
+ WHEN 3.
+ r = row.
+ c = col - 1.
+ WHEN 4.
+ r = row + 1.
+ c = col.
+ WHEN 5.
+ r = row + 1.
+ c = col + 1.
+ WHEN 6.
+ r = row + 1.
+ c = col - 1.
+ WHEN 7.
+ r = row - 1.
+ c = col.
+ WHEN 8.
+ r = row - 1.
+ c = col + 1.
+ WHEN 9.
+ r = row - 1.
+ c = col - 1.
+ ENDCASE.
+ IF r BETWEEN 0 AND rows - 1 AND c BETWEEN 0 AND cols - 1.
+ IF substring( val = field off = r * cols + c len = 1 ) = `*`.
+ IF r = row AND c = col.
+ n = 9.
+ EXIT.
+ ELSE.
+ n = n + 1.
+ ENDIF.
+ ENDIF.
+ ENDIF.
+ ENDDO.
+ IF n = 0.
+ res = res && ` `.
+ ELSEIF n = 9.
+ res = res && `*`.
+ ELSE.
+ res = res && n.
+ ENDIF.
+ ENDDO.
+ ENDDO.
+
+ DO rows TIMES.
+ INSERT substring( val = res off = ( sy-index - 1 ) * cols len = cols ) INTO TABLE result.
+ ENDDO.
+
+ ENDMETHOD.
+ENDCLASS.
diff --git a/exercises/practice/flower-field/package.devc.xml b/exercises/practice/flower-field/package.devc.xml
new file mode 100644
index 0000000..6a1ff55
--- /dev/null
+++ b/exercises/practice/flower-field/package.devc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+ Exercism: Flower Field
+
+
+
+
diff --git a/exercises/practice/flower-field/zcl_flower_field.clas.abap b/exercises/practice/flower-field/zcl_flower_field.clas.abap
new file mode 100644
index 0000000..2d00cbb
--- /dev/null
+++ b/exercises/practice/flower-field/zcl_flower_field.clas.abap
@@ -0,0 +1,19 @@
+CLASS zcl_flower_field DEFINITION PUBLIC FINAL CREATE PUBLIC.
+
+ PUBLIC SECTION.
+
+ METHODS annotate
+ IMPORTING
+ !input TYPE string_table
+ RETURNING
+ VALUE(result) TYPE string_table.
+
+ENDCLASS.
+
+CLASS zcl_flower_field IMPLEMENTATION.
+
+ METHOD annotate.
+ " add solution here
+ ENDMETHOD.
+
+ENDCLASS.
diff --git a/exercises/practice/flower-field/zcl_flower_field.clas.testclasses.abap b/exercises/practice/flower-field/zcl_flower_field.clas.testclasses.abap
new file mode 100644
index 0000000..f5896de
--- /dev/null
+++ b/exercises/practice/flower-field/zcl_flower_field.clas.testclasses.abap
@@ -0,0 +1,192 @@
+CLASS ltc_test DEFINITION FINAL FOR TESTING
+ DURATION SHORT
+ RISK LEVEL HARMLESS.
+
+ PRIVATE SECTION.
+
+ DATA cut TYPE REF TO zcl_flower_field.
+
+ METHODS setup.
+ METHODS assert_that IMPORTING input TYPE string_table
+ output TYPE string_table.
+
+ METHODS no_rows FOR TESTING RAISING cx_static_check.
+ METHODS no_columns FOR TESTING RAISING cx_static_check.
+ METHODS no_flowers FOR TESTING RAISING cx_static_check.
+ METHODS garden_full_of_flowers FOR TESTING RAISING cx_static_check.
+ METHODS flower_surrounded_by_spaces FOR TESTING RAISING cx_static_check.
+ METHODS space_surrounded_by_flowers FOR TESTING RAISING cx_static_check.
+ METHODS horizontal_line FOR TESTING RAISING cx_static_check.
+ METHODS horizontal_line_flowers_at_end FOR TESTING RAISING cx_static_check.
+ METHODS vertical_line FOR TESTING RAISING cx_static_check.
+ METHODS vertical_line_flowers_at_end FOR TESTING RAISING cx_static_check.
+ METHODS cross FOR TESTING RAISING cx_static_check.
+ METHODS large_garden FOR TESTING RAISING cx_static_check.
+
+ENDCLASS.
+
+
+CLASS ltc_test IMPLEMENTATION.
+
+ METHOD setup.
+ cut = NEW zcl_flower_field( ).
+ ENDMETHOD.
+
+
+ METHOD no_rows.
+ assert_that(
+ input = VALUE #( )
+ output = VALUE #( ) ).
+ ENDMETHOD.
+
+
+ METHOD no_columns.
+ assert_that(
+ input = VALUE #( ( ) )
+ output = VALUE #( ( ) ) ).
+ ENDMETHOD.
+
+
+ METHOD no_flowers.
+ assert_that(
+ input = VALUE #(
+ ( ` ` )
+ ( ` ` )
+ ( ` ` ) )
+ output = VALUE #(
+ ( ` ` )
+ ( ` ` )
+ ( ` ` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD garden_full_of_flowers.
+ assert_that(
+ input = VALUE #(
+ ( `***` )
+ ( `***` )
+ ( `***` ) )
+ output = VALUE #(
+ ( `***` )
+ ( `***` )
+ ( `***` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD flower_surrounded_by_spaces.
+ assert_that(
+ input = VALUE #(
+ ( ` ` )
+ ( ` * ` )
+ ( ` ` ) )
+ output = VALUE #(
+ ( `111` )
+ ( `1*1` )
+ ( `111` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD space_surrounded_by_flowers.
+ assert_that(
+ input = VALUE #(
+ ( `***` )
+ ( `* *` )
+ ( `***` ) )
+ output = VALUE #(
+ ( `***` )
+ ( `*8*` )
+ ( `***` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD horizontal_line.
+ assert_that(
+ input = VALUE #( ( ` * * ` ) )
+ output = VALUE #( ( `1*2*1` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD horizontal_line_flowers_at_end.
+ assert_that(
+ input = VALUE #( ( `* *` ) )
+ output = VALUE #( ( `*1 1*` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD vertical_line.
+ assert_that(
+ input = VALUE #(
+ ( ` ` )
+ ( `*` )
+ ( ` ` )
+ ( `*` )
+ ( ` ` ) )
+ output = VALUE #(
+ ( `1` )
+ ( `*` )
+ ( `2` )
+ ( `*` )
+ ( `1` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD vertical_line_flowers_at_end.
+ assert_that(
+ input = VALUE #(
+ ( `*` )
+ ( ` ` )
+ ( ` ` )
+ ( ` ` )
+ ( `*` ) )
+ output = VALUE #(
+ ( `*` )
+ ( `1` )
+ ( ` ` )
+ ( `1` )
+ ( `*` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD cross.
+ assert_that(
+ input = VALUE #(
+ ( ` * ` )
+ ( ` * ` )
+ ( `*****` )
+ ( ` * ` )
+ ( ` * ` ) )
+ output = VALUE #(
+ ( ` 2*2 ` )
+ ( `25*52` )
+ ( `*****` )
+ ( `25*52` )
+ ( ` 2*2 ` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD large_garden.
+ assert_that(
+ input = VALUE #(
+ ( ` * * ` )
+ ( ` * ` )
+ ( ` * ` )
+ ( ` * *` )
+ ( ` * * ` )
+ ( ` ` ) )
+ output = VALUE #(
+ ( `1*22*1` )
+ ( `12*322` )
+ ( ` 123*2` )
+ ( `112*4*` )
+ ( `1*22*2` )
+ ( `111111` ) ) ).
+ ENDMETHOD.
+
+
+ METHOD assert_that.
+ DATA(act) = cut->annotate( input ).
+ cl_abap_unit_assert=>assert_equals( act = act
+ exp = output ).
+ ENDMETHOD.
+
+ENDCLASS.
diff --git a/exercises/practice/flower-field/zcl_flower_field.clas.xml b/exercises/practice/flower-field/zcl_flower_field.clas.xml
new file mode 100644
index 0000000..2a1de53
--- /dev/null
+++ b/exercises/practice/flower-field/zcl_flower_field.clas.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+ ZCL_FLOWER_FIELD
+ E
+ Exercism: Flower Field
+ 1
+ X
+ X
+ X
+ X
+
+
+
+