69 lines
11 KiB
Text
69 lines
11 KiB
Text
|
#seq = [91, 17, 64, 45, 8, 13, 47, 19, 52, 68, 63, 76, 82, 44, 28, 56, 37, 2, 78, 48, 32, 58, 72, 53, 9, 85, 77, 89, 36, 22, 49, 86, 51, 99, 6, 92, 80, 87, 7, 25, 31, 66, 84, 4, 98, 67, 46, 61, 59, 79, 0, 3, 38, 27, 23, 95, 20, 35, 14, 30, 26, 33, 42, 93, 12, 57, 11, 54, 50, 75, 90, 41, 88, 96, 40, 81, 24, 94, 18, 39, 70, 34, 21, 55, 5, 29, 71, 83, 1, 60, 74, 69, 10, 62, 43, 73, 97, 65, 15, 16]
|
||
|
|
||
|
$boards <- [83, 40, 67, 98, 4, 50, 74, 31, 30, 3, 75, 64, 79, 61, 5, 12, 59, 26, 25, 72, 36, 33, 18, 54, 10, 68, 56, 28, 57, 12, 78, 66, 20, 85, 51, 35, 23, 7, 99, 44, 86, 37, 8, 45, 49, 40, 77, 32, 6, 88, 75, 15, 20, 79, 8, 81, 69, 54, 33, 28, 9, 53, 48, 95, 27, 65, 84, 40, 71, 36, 13, 31, 6, 68, 29, 94, 6, 30, 16, 74, 91, 47, 66, 31, 90, 14, 56, 45, 55, 20, 58, 70, 27, 46, 73, 77, 67, 97, 51, 54, 60, 12, 49, 80, 52, 15, 27, 85, 82, 48, 21, 76, 83, 55, 54, 8, 5, 4, 38, 47, 73, 2, 86, 44, 99, 64, 60, 6, 38, 37, 3, 69, 21, 24, 11, 36, 88, 16, 55, 41, 78, 7, 81, 95, 91, 27, 34, 92, 39, 30, 38, 57, 20, 68, 49, 21, 18, 69, 97, 60, 34, 92, 0, 59, 62, 10, 43, 93, 87, 64, 53, 35, 94, 76, 61, 48, 74, 58, 13, 54, 57, 18, 37, 92, 78, 89, 10, 25, 97, 43, 38, 99, 64, 6, 66, 21, 83, 29, 93, 95, 94, 37, 98, 87, 51, 50, 65, 77, 83, 95, 68, 4, 91, 53, 32, 56, 26, 15, 2, 80, 20, 55, 58, 81, 33, 73, 32, 66, 38, 89, 18, 79, 40, 78, 55, 26, 63, 93, 60, 98, 42, 65, 96, 47, 57, 45, 75, 72, 23, 35, 64, 28, 21, 80, 27, 93, 58, 71, 67, 11, 61, 20, 74, 13, 90, 76, 35, 46, 94, 40, 92, 2, 4, 85, 69, 22, 70, 87, 31, 61, 74, 78, 58, 4, 90, 63, 28, 24, 35, 84, 59, 8, 89, 88, 47, 17, 48, 80, 33, 32, 57, 7, 30, 39, 19, 1, 13, 41, 15, 50, 44, 72, 2, 5, 70, 34, 93, 60, 80, 69, 49, 14, 25, 10, 33, 45, 41, 77, 89, 27, 68, 99, 11, 32, 95, 15, 4, 72, 98, 52, 53, 28, 14, 75, 44, 57, 9, 62, 92, 69, 7, 21, 2, 73, 40, 52, 60, 57, 53, 65, 63, 86, 36, 82, 44, 14, 28, 39, 12, 80, 66, 64, 91, 50, 51, 82, 5, 38, 41, 95, 70, 52, 11, 21, 51, 81, 20, 0, 14, 83, 57, 36, 60, 59, 42, 77, 13, 85, 32, 63, 91, 40, 42, 3, 50, 22, 24, 81, 31, 93, 9, 79, 82, 43, 89, 6, 77, 76, 26, 37, 29, 8, 53, 23, 4, 7, 78, 32, 44, 74, 29, 3, 84, 38, 79, 58, 41, 87, 88, 30, 68, 19, 72, 81, 47, 15, 63, 52, 6, 26, 20, 41, 92, 84, 25, 9, 4, 96, 85, 66, 49, 15, 50, 89, 19, 48, 45, 82, 86, 60, 29, 18, 53, 47, 16, 75, 39, 45, 31, 73, 91, 86, 69, 94, 66, 28, 61, 17, 20, 0, 88, 21, 89, 41, 37, 35, 2, 10, 18, 82, 80, 23, 4, 73, 93, 89, 8, 20, 12, 45, 74, 99, 58, 90, 67, 50, 85, 35, 88, 55, 18, 65, 42, 47, 48, 16, 38, 65, 64, 25, 20, 74, 37, 15, 82, 23, 76, 97, 48, 53, 60, 93, 85, 1, 35, 77, 10, 59, 2, 58, 11, 9, 57, 40, 46, 35, 88, 29, 52, 17, 30, 2, 7, 6, 0, 13, 63, 44, 68, 59, 83, 98, 5, 50, 65, 82, 40, 2, 14, 50, 7, 31, 91, 19, 11, 51, 42, 56, 44, 6, 66, 74, 22, 95, 64, 63, 1, 17, 86, 24, 18, 19, 66, 63, 80, 65, 23, 74, 22, 85, 5, 7, 37, 75, 51, 38, 58, 68, 83, 32, 40, 29, 31, 15, 43, 37, 54, 13, 77, 31, 57, 96, 28, 87, 95, 10, 11, 19, 49, 45, 12, 21, 79, 56, 24, 34, 64, 84, 69, 17, 6, 33, 48, 61, 0, 85, 34, 7, 84, 37, 25, 46, 59, 76, 82, 18, 62, 20, 44, 2, 12, 78, 60, 56, 99, 95, 6, 1, 39, 2, 46, 34, 28, 64, 22, 48, 23, 89, 56, 55, 44, 81, 82, 43, 74, 65, 31, 94, 49, 91, 69, 42, 27, 52, 54, 79, 60, 62, 83, 38, 5, 21, 56, 48, 99, 51, 40, 15, 7, 24, 92, 10, 66, 64, 88, 99, 18, 22, 52, 81, 21, 42, 13, 71, 59, 91, 38, 68, 10, 25, 54, 19, 76, 60, 24, 41, 92, 2, 3, 64, 76, 5, 25, 55, 84, 70, 15, 89, 67, 68, 34, 86, 11, 4, 6, 9, 23, 43, 41, 52, 58, 10, 88, 38, 0, 83, 91, 85, 81, 86, 5, 10, 89, 6, 48, 45, 77, 2, 9, 90, 74, 8, 57, 75, 67, 73, 30, 49, 96, 15, 66, 13, 82, 89, 20, 5, 67, 94, 64, 0, 58, 73, 4, 62, 49, 59, 28, 75, 79, 44, 54, 71, 57, 33, 36, 23, 36, 29, 80, 30, 51, 91, 77, 2, 84, 78, 90, 15, 21, 75, 28, 93, 22, 55, 16, 67, 50, 58, 60, 68, 82, 80, 37, 91, 7, 54, 81, 85, 25, 24, 33, 36, 89, 30, 56, 83, 95, 99, 48, 10, 4, 44, 1, 55, 79, 9, 13, 53, 20, 26, 7, 31, 49, 84, 58, 51, 91, 90, 68, 55, 19, 38, 23, 81, 33, 34, 99, 85, 37, 54, 44, 66, 81, 78, 15, 31, 14, 48, 65, 0, 26, 10, 20, 4, 41, 77, 68, 95, 34, 73, 74, 12, 36, 3, 60, 6, 24, 78, 58, 36, 30, 51, 75, 13, 40, 17, 1, 3, 42, 59, 64, 20, 4, 18, 79, 37, 61, 84, 63, 7, 41, 83, 1, 75, 18, 14, 56, 67, 32, 22, 69, 80, 46, 84, 49, 72, 21, 9, 10, 35, 4, 37, 28, 40, 12, 56, 80, 47, 17, 70, 12, 22, 77, 81, 11, 61, 30, 58, 60, 71, 52, 0, 25, 86, 65, 59, 28, 79, 20, 26, 70, 75, 81, 18, 67, 2, 85, 73, 8, 17, 74, 3, 34, 92, 30, 51, 72, 84, 56, 45, 37, 90, 31, 97, 78, 2, 73, 71, 43, 69, 6, 54, 89, 57, 93, 81, 0, 39, 25, 90, 79, 27, 92, 29, 15, 45, 76, 87, 11
|
||
|
|
||
|
@score_board(bidx) {
|
||
|
$sum <- 0
|
||
|
~ (#r, 5) {
|
||
|
#ridx = (bidx + ((r - 1) * 5))
|
||
|
~ (#c, 5) {
|
||
|
#fidx = (ridx + (c - 1))
|
||
|
? (boards[fidx] > 0) {
|
||
|
sum <- (sum + boards[fidx])
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
<< sum
|
||
|
}
|
||
|
|
||
|
@play_board(bidx, num) {
|
||
|
$sum <- _
|
||
|
~ (#r, 5) {
|
||
|
? (sum = _) {
|
||
|
#ridx = (bidx + ((r - 1) * 5))
|
||
|
$rowscore <- 0
|
||
|
~ (#c, 5) {
|
||
|
#fidx = (ridx + (c - 1))
|
||
|
? (boards[fidx] = num) {
|
||
|
boards[fidx] <- -1
|
||
|
}
|
||
|
rowscore <- (rowscore + boards[fidx])
|
||
|
}
|
||
|
? (rowscore = -5) {
|
||
|
sum <- score_board(bidx)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
~ (#c, 5) {
|
||
|
? (sum = _) {
|
||
|
#cidx = (bidx + (c - 1))
|
||
|
$colscore <- 0
|
||
|
~ (#r, 5) {
|
||
|
#fidx = (cidx + ((r - 1) * 5))
|
||
|
colscore <- (colscore + boards[fidx])
|
||
|
}
|
||
|
? (colscore = -5) {
|
||
|
sum <- score_board(bidx)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
<< sum
|
||
|
}
|
||
|
|
||
|
$winner <- _
|
||
|
~~ (#num, seq) {
|
||
|
~ (#b, 100) {
|
||
|
? (winner = _) {
|
||
|
#bidx = (1 + ((b - 1) * (5 * 5)))
|
||
|
? (boards[bidx] = -2) {} . {
|
||
|
#res = play_board(bidx, num)
|
||
|
? (res = _) {} . {
|
||
|
winner <- (res * num)
|
||
|
boards[bidx] <- -2
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
<: `Answer: {winner}`
|