-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
226 additions
and
26 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
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,90 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
def getBaseForNumber = \n. | ||
if (n == 0) { | ||
"guanine"; | ||
} { | ||
if (n == 1) { | ||
"cytosine"; | ||
} { | ||
if (n == 2) { | ||
"adenine"; | ||
} { | ||
"thymine"; | ||
}; | ||
}; | ||
}; | ||
end; | ||
|
||
def getNumberForBase = \n. | ||
if (n == "guanine") { | ||
0; | ||
} { | ||
if (n == "cytosine") { | ||
1; | ||
} { | ||
if (n == "adenine") { | ||
2; | ||
} { | ||
if (n == "thymine") { | ||
3; | ||
} {-1}; | ||
}; | ||
}; | ||
}; | ||
end; | ||
|
||
def getComplementNumber = \n. | ||
if (n == 0) { | ||
1; | ||
} { | ||
if (n == 1) { | ||
0; | ||
} { | ||
if (n == 2) { | ||
3; | ||
} { | ||
2; | ||
}; | ||
}; | ||
}; | ||
end; | ||
|
||
def waitUntilHere = \remainingCount. | ||
if (remainingCount > 0) { | ||
maybeItemHere <- scan down; | ||
case maybeItemHere (\_. | ||
watch down; | ||
wait 1000; | ||
waitUntilHere remainingCount; | ||
) (\itemHere. | ||
|
||
maybeItemAbove <- scan left; | ||
case maybeItemAbove (\_. fail "Expected an item here.") (\itemAbove. | ||
let num = getNumberForBase itemAbove in | ||
if (num >= 0) { | ||
let complementNum = getComplementNumber num in | ||
let complementItem = getBaseForNumber complementNum in | ||
if (complementItem == itemHere) { | ||
move; | ||
waitUntilHere $ remainingCount - 1; | ||
} { | ||
create "pixel (R)"; | ||
} | ||
} { | ||
fail "Expected nonnegative item index." | ||
} | ||
); | ||
); | ||
} { | ||
log "Finished verifying top row"; | ||
create "pixel (G)"; | ||
}; | ||
|
||
end; | ||
|
||
def go = | ||
instant $ waitUntilHere 32; | ||
end; | ||
|
||
go; |
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
Oops, something went wrong.