Input: A four-letter ASCII string Output: The phrase ``αorced αndendation αf αode'', with the alphae replaced with the consecutive letters from the input, shifted to uppercase. ╔═══════════════════════════════════════════════ ║Example 1: sicp -> Sorced Indendation Cf Pode ║Example 2: SUSS -> Sorced Undendation Sf Sode ╚═══════════════════════════════════════════════
Your entry has to be a
source code
of a complete program that takes the input on stdin and outputs the string to stdout. Shortest program wins.
using System;public class P {static void Main() {var l=Console.ReadLine().ToUpper();Console.Write($"{l[0]}orced {l[1]}ndendation {l[2]}f {l[3]}ode");}}
One way I see to reduce the bytesize is compressing the string to output. Can we use some kind of a custom encoding? It's terribly wasteful in raw ASCII.
(destructuring-bind(a b c d)(coerce(string-upcase(read))'list)(format t"~Aorced ~Andentation ~Af ~Aode"a b c d))
Name:
Anonymous2017-10-23 15:54
>>31 looking for other lisps in which it could be more terse. clojure's deconstructing bind available in a normal let expression and working natively on strings sounds like a good start but the uppercasing ruins it (although it still beats CL): (let[[f i o c](clojure.string/upper-case(read-line))](print(format"%sorced %sndentation %sf %sode"f i o c)))
I'm gonna fuck around with scheme dialects now
Name:
Anonymous2017-10-23 16:45
>>32 so for this dubspost I went with Racket, which I think is the most usable sort-of- Scheme.
the natural way of destructuring in racket would be through match-let: (match-let([(list f i o c)(string->list(string-upcase(read-line)))])(printf"~aorced ~andentation ~af ~aode"f i o c))
...but abusing match gives us better results. would be better than Clojure if you could natively destructure strings (well, maybe you can; I think it's possible but I may be wrong).
(match(string->list(string-upcase(read-line)))[(list f i o c)(printf"~aorced ~andentation ~af ~aode"f i o c)])
>>36 nice. will need to try that in DOSbox or FreeDOS. what compilers handle that format? I guess they shouldn't be hard to find as it's basically just machine code, right?
Name:
Anonymous2017-10-24 6:45
>>30,33 actually, converting string to list makes it possible to use apply. this makes the CL version much shorter: (apply #'format t"~aorced ~andentation ~af ~aode"(coerce(string-upcase(read))'list))
racket version also gets better, but not that much better: (apply format "~aorced ~andentation ~af ~aode" (string->list(string-upcase(read-line))))