*************************************************** * - Implement a Fibonacci Butt Sort.† * * - Don't forget the surrounding b and i tags! * * - Spaces and newlines must be skipped. * * - Any frequently-used language may be used. * * - Output markup is either BBCode or SEXPcode. * * - Lowest bytesize wins. * ***************************************************
†A Fibonacci Buttsort is an operation that can be performed on a string which outputs the string with alternating underline and overline tags, starting with underline. The resulting string is also bold and italicised. Whitespace characters are skipped.
SICP -> SICP HAX ANUS -> HAXANUS
Name:
Anonymous2018-01-05 12:32
import itertools;a=itertools.cycle('{u }{o }');b="{b {i ";c="b+=";d="next(a);" for x in input(): if x.isspace():b+=x else:exec((c+d)*3+c+'x;'+c+d) print(b)
this is kinda meh solution, definitely can be golfed harder. also, it relies on a bug in /prague/'s sexpcode parser. can you spot it?
CL-USER> (format t "{b.i ~{~{{~[~;u~;o~] ~a}~}~}}" (loop for x across (read-line) and i from 0 for m = (or (position x '(#\Space #\Newline #\Tab)) (1+ (mod i 2))) collect `(,m ,x)))