Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
|
|
@ -0,0 +1,18 @@
|
|||
def wheels: [
|
||||
{
|
||||
"A": [1, 2, 3]
|
||||
},
|
||||
{
|
||||
"A": [1, "B", 2],
|
||||
"B": [3, 4]
|
||||
},
|
||||
{
|
||||
"A": [1, "D", "D"],
|
||||
"D": [6, 7, 8]
|
||||
},
|
||||
{
|
||||
"A": [1, "B", "C"],
|
||||
"B": [3, 4],
|
||||
"C": [5, "B"]
|
||||
}
|
||||
];
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
# read($wheel)
|
||||
# where $wheel is the wheel to be read (a string)
|
||||
# Input: a set of wheels
|
||||
# Output: an object such that .value is the next value,
|
||||
# and .state is the updated state of the set of wheels
|
||||
def read($wheel):
|
||||
|
||||
# Input: an array
|
||||
# Output: the rotated array
|
||||
def rotate: .[1:] + [.[0]];
|
||||
|
||||
.[$wheel][0] as $value
|
||||
| (.[$wheel] |= rotate) as $state
|
||||
| if ($value | type) == "number"
|
||||
then {$value, $state}
|
||||
else $state | read($value)
|
||||
end;
|
||||
|
||||
# Read wheel $wheel $n times
|
||||
def multiread($wheel; $n):
|
||||
if $n <= 0 then empty
|
||||
else read($wheel)
|
||||
| .value, (.state | multiread($wheel; $n - 1))
|
||||
end;
|
||||
|
||||
def printWheels:
|
||||
keys[] as $k
|
||||
| "\($k): \(.[$k])";
|
||||
|
||||
# Spin each group $n times
|
||||
def spin($n):
|
||||
wheels[]
|
||||
| "The number wheel group:",
|
||||
printWheels,
|
||||
"generates",
|
||||
([ multiread("A"; $n) ] | join(" ") + " ..."),
|
||||
"";
|
||||
|
||||
spin(20)
|
||||
Loading…
Add table
Add a link
Reference in a new issue