Extended Straddling Checkerboard: Difference between revisions
Content added Content deleted
(→{{header|jq}}: more idiomatic version of decode) |
|||
Line 118: | Line 118: | ||
def decode: |
def decode: |
||
. |
{s: .} + checkerboard |
||
| |
| .ewords["FSL"] as $fsl |
||
| checkerboard |
|||
| .res = "" |
| .res = "" |
||
| .figs = false |
| .figs = false |
||
| . |
| until (.s == ""; |
||
.s[0:1] as $c |
|||
$s[.i:.i+1] as $c |
|||
| .ix = -1 |
| .ix = -1 |
||
| if .figs |
| if .figs |
||
then if |
then if (.s | startswith($fsl) | not) |
||
then .res += $c |
then .res += $c |
||
else .figs = false |
else .figs = false |
||
end |
end |
||
| . |
| .s |= .[2:] |
||
else .ix = (drow1|index($c)) |
else .ix = (drow1|index($c)) |
||
| if .ix and .ix >= 0 |
| if .ix and .ix >= 0 |
||
then .res += .dmap[drow1[.ix:.ix+1]] |
then .res += .dmap[drow1[.ix:.ix+1]] |
||
| . |
| .s |= .[1:] |
||
elif $c == "6" |
elif $c == "6" |
||
then .res += "CODE" + |
then .res += "CODE" + .s[1:4] |
||
| . |
| .s |= .[4:] |
||
elif $c == "7" or $c == "8" |
elif $c == "7" or $c == "8" |
||
then |
then .s[1:2] as $d |
||
| .res += .dmap[$c + $d] |
| .res += .dmap[$c + $d] |
||
| . |
| .s |= .[2:] |
||
elif $c == "9" |
elif $c == "9" |
||
then |
then .s[1:2] as $d |
||
| if $d == "0" |
| if $d == "0" |
||
then .res += " " |
then .res += " " |
||
Line 154: | Line 152: | ||
else .res += .dwords[$c + $d] |
else .res += .dwords[$c + $d] |
||
end |
end |
||
| . |
| .s |= .[2:] |
||
end |
end |
||
end ) |
end ) |