-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathChapter1.purs
80 lines (75 loc) · 2.83 KB
/
Chapter1.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module Levels.Chapter1 where
import Prelude
import Data.List (List(..), reverse, snoc, filter, (:))
import Data.Maybe (Maybe(..))
import Helper (fromArray, (:->), (:>))
import ListHelper (contains)
import Transformer (clearEmpty, mapReject, replaceMultiple)
import Types (Chapter, Cube(..), Difficulty(..))
chapter1 :: Chapter
chapter1 = {
name: "Chapter 1",
transformers: fromArray [
"mapYtoYR" :> {
name: "map {Yellow}↦[{Red}{Yellow}]",
function: replaceMultiple Yellow (Yellow : Red : Nil)
},
"mapCtoRC" :> {
name: "map {Cyan}↦[{Cyan}{Red}]",
function: replaceMultiple Cyan (Red : Cyan : Nil)
},
"rejectY" :> {
name: "map (reject {Yellow})",
function: mapReject Yellow
},
"rejectC" :> {
name: "map (reject {Cyan})",
function: mapReject Cyan
},
"filterContainsR" :> {
name: "filter (contains {Red})",
function: filter (contains Red) >>> clearEmpty
},
"stackR" :> {
name: "map (stack {Red})",
function: map (_ `snoc` Red)
},
"mapReverse" :> {
name: "map reverse",
function: map reverse
}
],
levels: fromArray [
"1.1" :-> {
name: "Mercury",
help: Just """There are some new types of functions in this chapter. We will
introduce them when they are needed. Note that you can always
skip levels and come back later.""",
difficulty: Easy,
initial: [[Red, Red], [Red, Yellow], [Cyan, Yellow], [Cyan, Cyan]],
target: [[Red, Red, Red], [Red, Yellow, Red], [Red, Yellow, Red], [Red, Red, Red]]
},
"1.2" :-> {
name: "Venus",
help: Just """The function `filterContainsR` removes columns without a red cube.""",
difficulty: Medium,
initial: [[Red, Red], [Red, Yellow], [Cyan, Yellow], [Cyan, Cyan]],
target: [[Red, Red], [Red, Red]]
},
"1.3" :-> {
name: "Earth",
help: Just """You can flip each column vertically with `mapReverse`.""",
difficulty: Easy,
initial: [[Cyan, Cyan, Yellow], [Cyan, Red], [Cyan, Red], [Cyan, Cyan, Yellow]],
target: [[Red, Cyan, Cyan], [Red, Cyan], [Red, Cyan], [Red, Cyan, Cyan]]
},
"1.4" :-> {
name: "Mars",
help: Just """In case you were wondering: the level names <s>have a rather deep
philosophical meaning</s> are chosen randomly.""",
difficulty: Medium,
initial: [[Red, Red], [Red, Yellow], [Cyan, Yellow], [Cyan, Cyan]],
target: [[Red, Red], [Red, Red], [Red, Red], [Red, Red]]
}
]
}