Created
April 1, 2014 03:47
-
-
Save mavant/9907358 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defn line->ints [line] | |
map | |
fn [l] | |
Integer/parseInt l | |
split line #"\s+" | |
defn solutions->outputs [solutions] | |
map | |
fn [n s] | |
str "Case #" | |
inc n | |
": " s " " | |
range | |
count solutions | |
solutions | |
let [ filename "A-large-practice" outfile | |
str filename ".out" | |
infile | |
str filename ".in" | |
write | |
fn [outs] | |
with-open [wrt | |
writer outfile | |
doseq [o outs] | |
.write wrt o | |
inputs | |
split-lines | |
slurp infile | |
[firstline & lines] inputs [L D N] | |
line->ints firstline | |
words | |
take D lines | |
cases | |
map casestring->pattern | |
drop D lines | |
wordmatches | |
fn [pattern] | |
map # | |
re-matches pattern % | |
words | |
nummatches | |
fn [pattern] | |
count | |
remove nil? | |
wordmatches pattern | |
solutions | |
map nummatches cases | |
outputs | |
solutions->outputs solutions | |
write outputs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment