Skip to content

Commit eebe29f

Browse files
flower-field replaces minesweeper
1 parent 594515b commit eebe29f

File tree

11 files changed

+288
-44
lines changed

11 files changed

+288
-44
lines changed

config.json

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,60 +42,60 @@
4242
"slug": "lucians-luscious-lasagna",
4343
"name": "Lucian's Luscious Lasagna",
4444
"uuid": "3aa220cb-606f-45c5-9b7a-4bce0e4eb20d",
45-
"prerequisites": [],
46-
"status": "beta",
4745
"concepts": [
4846
"basics"
49-
]
47+
],
48+
"prerequisites": [],
49+
"status": "beta"
5050
},
5151
{
5252
"slug": "temperature",
5353
"name": "Temperature",
5454
"uuid": "6ed15adb-f022-4bbd-bbb3-22845deabc91",
55+
"concepts": [
56+
"numbers"
57+
],
5558
"prerequisites": [
5659
"basics"
5760
],
58-
"status": "beta",
59-
"concepts": [
60-
"numbers"
61-
]
61+
"status": "beta"
6262
},
6363
{
6464
"slug": "pacman-rules",
6565
"name": "Pac-Man Rules",
6666
"uuid": "9050f8c3-9976-4c4d-93e7-c9c549b1c524",
67+
"concepts": [
68+
"booleans"
69+
],
6770
"prerequisites": [
6871
"basics"
6972
],
70-
"status": "wip",
71-
"concepts": [
72-
"booleans"
73-
]
73+
"status": "wip"
7474
},
7575
{
7676
"slug": "guessing-game",
7777
"name": "Guessing Game",
7878
"uuid": "fb9868eb-ce4f-4e6b-aa0d-b47d3451070f",
79+
"concepts": [
80+
"pattern-matching-literals"
81+
],
7982
"prerequisites": [
8083
"numbers"
8184
],
82-
"status": "beta",
83-
"concepts": [
84-
"pattern-matching-literals"
85-
]
85+
"status": "beta"
8686
},
8787
{
8888
"slug": "valentines-day",
8989
"name": "Valentines Day",
9090
"uuid": "537d8df3-0b12-4dbe-aa86-65ae79c4de0e",
91+
"concepts": [
92+
"algebraic-data-types"
93+
],
9194
"prerequisites": [
9295
"pattern-matching-literals",
9396
"numbers"
9497
],
95-
"status": "beta",
96-
"concepts": [
97-
"algebraic-data-types"
98-
]
98+
"status": "beta"
9999
}
100100
],
101101
"practice": [
@@ -297,8 +297,7 @@
297297
"uuid": "dde7cf64-7e3b-4e5c-8a65-5d639fa8a307",
298298
"practices": [],
299299
"prerequisites": [],
300-
"difficulty": 5,
301-
"topics": []
300+
"difficulty": 5
302301
},
303302
{
304303
"slug": "luhn",
@@ -325,23 +324,30 @@
325324
"number_theory"
326325
]
327326
},
327+
{
328+
"slug": "flower-field",
329+
"name": "Flower Field",
330+
"uuid": "1eff202c-ef0c-43d2-9077-7837914bc8b0",
331+
"practices": [],
332+
"prerequisites": [],
333+
"difficulty": 7
334+
},
328335
{
329336
"slug": "minesweeper",
330337
"name": "Minesweeper",
331338
"uuid": "821f2081-dfc2-40c6-8e12-2907daa04416",
332339
"practices": [],
333340
"prerequisites": [],
334341
"difficulty": 7,
335-
"topics": []
342+
"status": "deprecated"
336343
},
337344
{
338345
"slug": "game-of-life",
339346
"name": "Game of Life",
340347
"uuid": "eb221634-15c6-463c-8268-54a3c3aa0c66",
341348
"practices": [],
342349
"prerequisites": [],
343-
"difficulty": 7,
344-
"topics": []
350+
"difficulty": 7
345351
},
346352
{
347353
"slug": "perfect-numbers",
@@ -496,8 +502,7 @@
496502
"uuid": "00b6c83b-e652-4f71-a094-b3034f77fd7b",
497503
"practices": [],
498504
"prerequisites": [],
499-
"difficulty": 4,
500-
"topics": []
505+
"difficulty": 4
501506
},
502507
{
503508
"slug": "food-chain",
@@ -868,8 +873,7 @@
868873
"uuid": "01401d15-6667-4f94-bcd2-ec5a70df1cc6",
869874
"practices": [],
870875
"prerequisites": [],
871-
"difficulty": 4,
872-
"topics": []
876+
"difficulty": 4
873877
},
874878
{
875879
"slug": "sieve",
@@ -926,8 +930,7 @@
926930
"uuid": "78971281-153d-4bdc-8f90-4b7eded2b201",
927931
"practices": [],
928932
"prerequisites": [],
929-
"difficulty": 8,
930-
"topics": []
933+
"difficulty": 8
931934
},
932935
{
933936
"slug": "pov",
@@ -1042,8 +1045,7 @@
10421045
"uuid": "f49d76f7-f826-4b6a-a514-47af7e84144a",
10431046
"practices": [],
10441047
"prerequisites": [],
1045-
"difficulty": 6,
1046-
"topics": []
1048+
"difficulty": 6
10471049
},
10481050
{
10491051
"slug": "sgf-parsing",
@@ -1097,8 +1099,7 @@
10971099
"uuid": "7157a846-5846-47a4-97c2-daad7f763512",
10981100
"practices": [],
10991101
"prerequisites": [],
1100-
"difficulty": 3,
1101-
"topics": []
1102+
"difficulty": 3
11021103
},
11031104
{
11041105
"slug": "roman-numerals",
@@ -1302,7 +1303,6 @@
13021303
"practices": [],
13031304
"prerequisites": [],
13041305
"difficulty": 1,
1305-
"topics": null,
13061306
"status": "deprecated"
13071307
},
13081308
{
@@ -1312,7 +1312,6 @@
13121312
"practices": [],
13131313
"prerequisites": [],
13141314
"difficulty": 1,
1315-
"topics": null,
13161315
"status": "deprecated"
13171316
},
13181317
{
@@ -1322,7 +1321,6 @@
13221321
"practices": [],
13231322
"prerequisites": [],
13241323
"difficulty": 1,
1325-
"topics": null,
13261324
"status": "deprecated"
13271325
},
13281326
{
@@ -1332,7 +1330,6 @@
13321330
"practices": [],
13331331
"prerequisites": [],
13341332
"difficulty": 1,
1335-
"topics": null,
13361333
"status": "deprecated"
13371334
},
13381335
{
@@ -1342,7 +1339,6 @@
13421339
"practices": [],
13431340
"prerequisites": [],
13441341
"difficulty": 1,
1345-
"topics": null,
13461342
"status": "deprecated"
13471343
},
13481344
{
@@ -1443,15 +1439,15 @@
14431439
}
14441440
],
14451441
"tags": [
1442+
"execution_mode/compiled",
14461443
"paradigm/declarative",
14471444
"paradigm/functional",
1448-
"typing/static",
1449-
"typing/strong",
1450-
"execution_mode/compiled",
1451-
"platform/windows",
1452-
"platform/mac",
14531445
"platform/linux",
1446+
"platform/mac",
1447+
"platform/windows",
14541448
"runtime/standalone_executable",
1449+
"typing/static",
1450+
"typing/strong",
14551451
"used_for/backends",
14561452
"used_for/financial_systems"
14571453
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Instructions
2+
3+
Your task is to add flower counts to empty squares in a completed Flower Field garden.
4+
The garden itself is a rectangle board composed of squares that are either empty (`' '`) or a flower (`'*'`).
5+
6+
For each empty square, count the number of flowers adjacent to it (horizontally, vertically, diagonally).
7+
If the empty square has no adjacent flowers, leave it empty.
8+
Otherwise replace it with the count of adjacent flowers.
9+
10+
For example, you may receive a 5 x 4 board like this (empty spaces are represented here with the '·' character for display on screen):
11+
12+
```text
13+
·*·*·
14+
··*··
15+
··*··
16+
·····
17+
```
18+
19+
Which your code should transform into this:
20+
21+
```text
22+
1*3*1
23+
13*31
24+
·2*2·
25+
·111·
26+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
[Flower Field][history] is a compassionate reimagining of the popular game Minesweeper.
4+
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.
5+
"Flower Field" shipped in regional versions of Microsoft Windows in Italy, Germany, South Korea, Japan and Taiwan.
6+
7+
[history]: https://web.archive.org/web/20020409051321fw_/http://rcm.usr.dsi.unimi.it/rcmweb/fnm/
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"authors": [
3+
"etrepum"
4+
],
5+
"contributors": [
6+
"ffflorian",
7+
"iHiD",
8+
"keiravillekode",
9+
"kytrinyx",
10+
"lpalma",
11+
"petertseng",
12+
"ppartarr",
13+
"rbasso",
14+
"sshine",
15+
"tejasbubane"
16+
],
17+
"files": {
18+
"solution": [
19+
"src/FlowerField.hs",
20+
"package.yaml"
21+
],
22+
"test": [
23+
"test/Tests.hs"
24+
],
25+
"example": [
26+
".meta/examples/success-standard/src/FlowerField.hs"
27+
],
28+
"invalidator": [
29+
"stack.yaml"
30+
]
31+
},
32+
"blurb": "Mark all the flowers in a garden."
33+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: flower-field
2+
3+
dependencies:
4+
- base
5+
6+
library:
7+
exposed-modules: FlowerField
8+
source-dirs: src
9+
10+
tests:
11+
test:
12+
main: Tests.hs
13+
source-dirs: test
14+
dependencies:
15+
- flower-field
16+
- hspec
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module FlowerField (annotate) where
2+
3+
import Data.Char (intToDigit)
4+
import Data.Maybe (mapMaybe)
5+
6+
annotate :: [String] -> [String]
7+
annotate xss = [[ fixTile x (i, j)
8+
| (j, x ) <- zip [0..] xs ]
9+
| (i, xs) <- zip [0..] xss ]
10+
where
11+
12+
flowers = length . filter (== '*') . mapMaybe (`lookup` tiles) . neighbors
13+
14+
fixTile ' ' position = case flowers position of
15+
0 -> ' '
16+
x -> intToDigit x
17+
fixTile x _ = x
18+
19+
neighbors (i, j) = [ (i - 1, j - 1), (i - 1, j), (i - 1, j + 1)
20+
, (i , j - 1), (i , j + 1)
21+
, (i + 1, j - 1), (i + 1, j), (i + 1, j + 1) ]
22+
23+
tiles = [ ((i, j), x)
24+
| (i, xs) <- zip [0 :: Int ..] xss
25+
, (j, x ) <- zip [0 :: Int ..] xs ]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
11+
12+
[237ff487-467a-47e1-9b01-8a891844f86c]
13+
description = "no rows"
14+
15+
[4b4134ec-e20f-439c-a295-664c38950ba1]
16+
description = "no columns"
17+
18+
[d774d054-bbad-4867-88ae-069cbd1c4f92]
19+
description = "no flowers"
20+
21+
[225176a0-725e-43cd-aa13-9dced501f16e]
22+
description = "garden full of flowers"
23+
24+
[3f345495-f1a5-4132-8411-74bd7ca08c49]
25+
description = "flower surrounded by spaces"
26+
27+
[6cb04070-4199-4ef7-a6fa-92f68c660fca]
28+
description = "space surrounded by flowers"
29+
30+
[272d2306-9f62-44fe-8ab5-6b0f43a26338]
31+
description = "horizontal line"
32+
33+
[c6f0a4b2-58d0-4bf6-ad8d-ccf4144f1f8e]
34+
description = "horizontal line, flowers at edges"
35+
36+
[a54e84b7-3b25-44a8-b8cf-1753c8bb4cf5]
37+
description = "vertical line"
38+
39+
[b40f42f5-dec5-4abc-b167-3f08195189c1]
40+
description = "vertical line, flowers at edges"
41+
42+
[58674965-7b42-4818-b930-0215062d543c]
43+
description = "cross"
44+
45+
[dd9d4ca8-9e68-4f78-a677-a2a70fd7a7b8]
46+
description = "large garden"

0 commit comments

Comments
 (0)