om: Henry Rich
To: programm...@jsoftware.com
Sent: Wednesday, December 16, 2015 5:53 PM
Subject: Re: [Jprogramming] advent 16
My version:
clue =: ([^:(__ e. ]) __&".)&.>@;:;._2 wd 'clippaste'
names =: {."1 clue
clueval =: 1 {::"1 clue
NB. Get list of boxes, ea
My version:
clue =: ([^:(__ e. ]) __&".)&.>@;:;._2 wd 'clippaste'
names =: {."1 clue
clueval =: 1 {::"1 clue
NB. Get list of boxes, each containg a list of att:value
db =: <@:(2&}.)@(([^:(__ e. ]) __&".)&.>@;:);._2 ',' -.~ (#~ [: -.
(LF,LF)&E.) wd'clippaste'
NB. Create list of values for e
adventofcode/day/16
My solution is posted at
http://forums.devshed.com/programming-languages/972280-reversed-post2964093.html#post2964093
It may be slightly simpler than the others on this thread. Observing
that the machine output matched the memories, the essence of my solution
is an E. table.
=. x label_. (#~ (((< a) -.@e. ]) +. +./@( _2 ((b u
1&{::) *. a -: 0&{::)\ ] ))@}."1) y')
( ( ('&' ,~"1 '()'(strbracket lr)"1 maybenum leaf f) ,"1 (' F)' ,~"1 '( '
strbracket"1 0 '=<=>==><
I changed those keys to numbers... and cheated a bit with < and >
t=: ;: > cutLF (':,',CR)-.~ fread {:ARGV NB.
|Sue|440|pomeranians|1|samoyeds|9|children|4|
c=: ;: 'children cats samoyeds pomeranians akitas vizslas goldfish trees
cars perfumes' NB. categories
a=: ".@>@{: + (100 * c i. {.) NB. ana
mine:
part1 was straightforward - find key/value from the input in the
ticker. If all 3 key/values from the row match the ticker, then it's a
matching row
part2 was a bit trickier - I added on the operator to the input (e.g.
<5 for goldfish) then found the matching row in the ticker and
evaluated
This one took a while, whew.
load'regex'
Defaults=:', ', ': _',~ ': _, 'joinstring <;._2 [ 0 : 0
children
cats
perfumes
samoyeds
pomeranians
akitas
vizslas
goldfish
trees
cars
)
NB. part 1
parse=: deb L:0@:(':'&cut each)@:(','&cut)
Input0=: ('^Sue \d+: ';'') rxrplc fread'16.txt'
Input=: deb L:0