-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forging paths through different mediums
- Loading branch information
Showing
5 changed files
with
1,203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
chess_horse.yaml | ||
bridge-building.yaml | ||
teleport.yaml | ||
2048.yaml | ||
word-search.yaml | ||
|
62 changes: 62 additions & 0 deletions
62
data/scenarios/Challenges/_bridge-building/flower-ring-check.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
|
||
def isItemInDirection = \direction. \item. | ||
x <- scan direction; | ||
return $ case x (\_. false) (\y. y == item); | ||
end; | ||
|
||
def isFlankedByItem = \item. | ||
hasLeft <- isItemInDirection left item; | ||
hasRight <- isItemInDirection right item; | ||
return $ hasLeft && hasRight; | ||
end; | ||
|
||
def flowersInCardinalDirections = \item. \n. | ||
if (n > 0) { | ||
x <- isItemInDirection forward item; | ||
if x { | ||
turn left; | ||
flowersInCardinalDirections item $ n - 1; | ||
} { | ||
return false; | ||
}; | ||
} { | ||
return true; | ||
} | ||
end; | ||
|
||
def flowersAround = \item. | ||
hasCardinals <- flowersInCardinalDirections item 4; | ||
if hasCardinals { | ||
move; | ||
isFlanked1 <- isFlankedByItem item; | ||
turn back; | ||
move; | ||
if isFlanked1 { | ||
move; | ||
isFlanked2 <- isFlankedByItem item; | ||
turn back; | ||
move; | ||
return isFlanked2; | ||
} { | ||
return false; | ||
} | ||
} { | ||
return false; | ||
} | ||
end; | ||
|
||
// loop until condition is met | ||
def waitUntilSurrounded = | ||
isSurrounded <- flowersAround "flower"; | ||
if isSurrounded {} { | ||
wait 2; | ||
waitUntilSurrounded; | ||
} | ||
end; | ||
|
||
waitUntilSurrounded; | ||
|
||
_t <- swap "painted plate"; | ||
selfdestruct; |
Oops, something went wrong.