Probably won't get an explanatory blog post on this one today, and need to catch up to finish/submit yesterday's, but here's my Clojure solution for Day 5 (see gist.github.com/ballpointcarrot/7e...
(nsaoc.aoc5)(defnpolymer-drop[[c1c2]](cond(=c1c2)false(or(nil?c1)(nil?c2))false(=(Character/toLowerCasec1)(Character/toLowerCasec2))true:elsefalse))(defnshrink[input](loop[shrunk[]chars-to-test(take2input)left(drop2input)](cond(and(empty?left)(every?nil?chars-to-test))(applystrshrunk)(nil?(firstchars-to-test))(recurshrunk[(lastchars-to-test)(firstleft)](restleft))(polymer-dropchars-to-test)(if(empty?shrunk)(recurshrunk(take2left)(drop2left))(recur(popshrunk)[(lastshrunk)(firstleft)](restleft))):else(recur(conjshrunk(firstchars-to-test))[(lastchars-to-test)(firstleft)](restleft)))))(defnremove-char"Remove all instances of a character (case-insensitive)
from a string"[stringchr](applystr(remove#(or(=%(Character/toUpperCasechr))(=%(Character/toLowerCasechr)))string)))(defnchar-range[startend](mapchar(range(intstart)(inc(intend)))))(defnfind-shortest-polymer[input-string](applymin(pmap#(->input-string(remove-char%)(shrink)(count))(char-range\a\z))))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Probably won't get an explanatory blog post on this one today, and need to catch up to finish/submit yesterday's, but here's my Clojure solution for Day 5 (see gist.github.com/ballpointcarrot/7e...