Skip to content

Commit 91dcb79

Browse files
committed
Add flower-field & deprecate minesweeper
1 parent 5e937bc commit 91dcb79

File tree

9 files changed

+383
-3
lines changed

9 files changed

+383
-3
lines changed

config.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,9 +1580,9 @@
15801580
]
15811581
},
15821582
{
1583-
"slug": "minesweeper",
1584-
"name": "Minesweeper",
1585-
"uuid": "3bf049f8-7283-4370-aa0c-e10e99d9ef80",
1583+
"slug": "flower-field",
1584+
"name": "Flower Field",
1585+
"uuid": "c1900113-f4b2-4a04-a40e-89036e8aba9c",
15861586
"practices": [],
15871587
"prerequisites": [],
15881588
"difficulty": 4,
@@ -1594,6 +1594,16 @@
15941594
"transforming"
15951595
]
15961596
},
1597+
{
1598+
"slug": "minesweeper",
1599+
"name": "Minesweeper",
1600+
"uuid": "3bf049f8-7283-4370-aa0c-e10e99d9ef80",
1601+
"practices": [],
1602+
"prerequisites": [],
1603+
"difficulty": 4,
1604+
"topics": [],
1605+
"status": "deprecated"
1606+
},
15971607
{
15981608
"slug": "queen-attack",
15991609
"name": "Queen Attack",
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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"authors": [
3+
"norbs57"
4+
],
5+
"contributors": [
6+
"alebaffa",
7+
"bitfield",
8+
"dvrkps",
9+
"ekingery",
10+
"ferhatelmas",
11+
"hilary",
12+
"kahgoh",
13+
"kytrinyx",
14+
"leenipper",
15+
"petertseng",
16+
"robphoenix",
17+
"sebito91",
18+
"tleen"
19+
],
20+
"files": {
21+
"solution": [
22+
"flower_field.go"
23+
],
24+
"test": [
25+
"flower_field_test.go"
26+
],
27+
"example": [
28+
".meta/example.go"
29+
]
30+
},
31+
"blurb": "Mark all the flowers in a garden."
32+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package flowerfield
2+
3+
func Annotate(b []string) []string {
4+
result := make([]string, len(b))
5+
dirX := []int{}
6+
dirY := []int{}
7+
for i := -1; i <= 1; i++ {
8+
for j := -1; j <= 1; j++ {
9+
if i != 0 || j != 0 {
10+
dirX = append(dirX, i)
11+
dirY = append(dirY, j)
12+
}
13+
}
14+
}
15+
inGrid := func(i, j int) bool {
16+
return i >= 0 && j >= 0 && i < len(b) && j < len(b[0])
17+
}
18+
countForSquare := func(i, j int) int {
19+
result := 0
20+
for k := range dirX {
21+
i1, j1 := i+dirX[k], j+dirY[k]
22+
if inGrid(i1, j1) && b[i1][j1] == '*' {
23+
result++
24+
}
25+
}
26+
return result
27+
}
28+
for i, row := range b {
29+
resultRow := make([]rune, len(b[i]))
30+
for j, c := range row {
31+
if row[j] == '*' {
32+
resultRow[j] = c
33+
} else {
34+
count := countForSquare(i, j)
35+
if count == 0 {
36+
resultRow[j] = ' '
37+
} else {
38+
resultRow[j] = rune('0' + count)
39+
}
40+
}
41+
}
42+
result[i] = string(resultRow)
43+
}
44+
return result
45+
}
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"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package flowerfield
2+
3+
// Annotate returns an annotated board
4+
func Annotate(board []string) []string {
5+
panic("Please implement the Annotate function")
6+
}

0 commit comments

Comments
 (0)