Post History
AWK, 80 bytes {split("I V X L C D M 1 5 10 50 100 500 1000",d);for(;d[++i]!=$1;);print d[i+7]} Try it online! A quick map function. 'split' breaks the string into array elements. Find the stri...
Answer
#2: Post edited
- # [AWK], 80 bytes
{split("I V X L C D M 1 5 10 50 100 500 1000",d)for(;d[++i]!=$1;);print d[i+7]}- [Try it online!][TIO-lwf2zcw2]
- [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
- [TIO-lwf2zcw2]: https://tio.run/##SyzP/v@/urggJ7NEQ8lTIUwhQsFHwVnBRcFXwVDBVMHQQMHUAEiCKDBtoKSTosmVll@kYZ0Sra2dGatoq2JorWldUJSZV6KQEp2pbR5b@/8/AA "AWK – Try It Online"
- A quick map function. 'split' breaks the string into array elements. Find the string, and we know the Arabic numbers are always seven spots -> down the array from its Latin variant.
- # [AWK], 80 bytes
- {split("I V X L C D M 1 5 10 50 100 500 1000",d);for(;d[++i]!=$1;);print d[i+7]}
- [Try it online!][TIO-lwf2zcw2]
- [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html
- [TIO-lwf2zcw2]: https://tio.run/##SyzP/v@/urggJ7NEQ8lTIUwhQsFHwVnBRcFXwVDBVMHQQMHUAEiCKDBtoKSTosmVll@kYZ0Sra2dGatoq2JorWldUJSZV6KQEp2pbR5b@/8/AA "AWK – Try It Online"
- A quick map function. 'split' breaks the string into array elements. Find the string, and we know the Arabic numbers are always seven spots -> down the array from its Latin variant.
#1: Initial revision
# [AWK], 80 bytes {split("I V X L C D M 1 5 10 50 100 500 1000",d) for(;d[++i]!=$1;);print d[i+7]} [Try it online!][TIO-lwf2zcw2] [AWK]: https://www.gnu.org/software/gawk/manual/gawk.html [TIO-lwf2zcw2]: https://tio.run/##SyzP/v@/urggJ7NEQ8lTIUwhQsFHwVnBRcFXwVDBVMHQQMHUAEiCKDBtoKSTosmVll@kYZ0Sra2dGatoq2JorWldUJSZV6KQEp2pbR5b@/8/AA "AWK – Try It Online" A quick map function. 'split' breaks the string into array elements. Find the string, and we know the Arabic numbers are always seven spots -> down the array from its Latin variant.