Jump to content

Extended Straddling Checkerboard: Difference between revisions

Changed task description (as discussed in Talk Page) and amended the Wren entry accordingly.
(→‎{{header|Phix}}: moot point tweaks)
(Changed task description (as discussed in Talk Page) and amended the Wren entry accordingly.)
Line 5:
Implement encoding and decoding of a message using the extended straddling checkerboard, CT-37w, as described in the reference below.
 
You may switch the codes for F/L (99) and SUPP (98) to help differentiate the code for '9' from that of '999' and, soif weyou woulddo that, then havedigits F/Lonly (98)needed andto SUPPbe doubled rather than tripled. So we would then have (99)the asfollowing followscheckerboard:
<pre>
A E I N O T CODE
Line 20:
 
0 1 2 3 4 5 6 7 8 9
00 11 22 33 44 55 66 77 i88 = i + 399
000 111 222 333 444 555 666 777 888 999
</pre>
 
Line 410:
=={{header|Wren}}==
{{libheader|Wren-str}}
For consistency with the Python example, this uses the CT-37w checkerboard with F/L changed to 98 and SUPP to 99.
<syntaxhighlight lang="wren">import "./str" for Str
 
Line 457 ⟶ 456:
if (efigs.contains(c)) {
if (figs) {
add = add + c * 32
} else {
figs = true
add = add + fsl + c * 32
}
} else {
Line 494 ⟶ 493:
if (s[i..i+1] != fsl) {
res = res + c
i = i + 3
} else {
figs = false
i = i + 2
}
i = i + 2
} else if ((ix = drow1.indexOf(c)) >= 0) {
res = res + dmap[drow1[ix]]
Line 539 ⟶ 537:
 
Encoded:
0727923909290884848290949190629190979073848257518290982200000098909990549075819070889098119890790827175
072792390929088484829094919062919097907384825751829098222000000000989099905490758190708890981119890790827175
 
Decoded:
9,492

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.