And mine: # part 1 Presents=. do each ('x'&cut);._2 freads'/tmp/input.txt' sa=: 3 : '(l*w) + (2*l*w) + (2*w*h) + 2*h*l [ ''l w h''=. /:~y' +/ sa"1 Presents
# part 2 ribbon=. +/@:+:@:}:@:(/:~)@:> vol=. */@:> +/ (vol + ribbon)"1 Presents Ryan On 3 Dec 2015, at 13:54, Ric Sherlock wrote: > Here's mine: > > require 'tables/csv stats' > parcels=: _99 ". > 'x' readdsv jpath '~temp/aoc_day2_inp.txt' > > NB. Part 1 > +/ (<./ + [: +/ +:)"1 */"1 (0 1 , 1 2 ,: 0 2) {"_ 1 parcels > > NB. or... > getFaceSides=: (2 comb 3) {"_ 1 ] > calcFaceArea=: */"1@:getFaceSides > calcPaper=: (<./ + +/@:+:)"1 > calcTotalPaper=: +/@:calcPaper@calcFaceArea > > calcTotalPaper parcels > > NB. Part 2 > +/ (*/"1 + ([: <./"1 [: (+/@:+:)"1 (2 comb 3)&{"_ 1)) parcels > > NB. or ... > volume=: */"1 > perimeters=: (+/@:+:)"1@getFaceSides > calcRibbonLength=: (volume + <./"1@:perimeters) > calcTotalRibbonLength=: +/@calcRibbonLength > echo calcTotalRibbonLength parcels > > > > On Thu, Dec 3, 2015 at 3:36 PM, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > >> outfix is quite forgettable, but this is much more elegant than what I >> did. >> >> >> 1 */\. 2 3 4 >> 12 8 6 >> >> >> >> ----- Original Message ----- >> From: Joe Bogner <joebog...@gmail.com> >> To: programm...@jsoftware.com >> Sent: Wednesday, December 2, 2015 8:54 PM >> Subject: Re: [Jprogramming] advent of code - day 2 >> >> Pascal's #2 is the answer to part 2 of the question. Both of his >> answers match mine and yours matches my part one. >> >> Pascal - looks similar to mine, albeit compressed in a single line, >> which is close to the original problem description >> >> Henry - I haven't figured the logic of yours out yet at a quick >> glance, I will need to look closer >> >> Thank you both for sharing >> >> >> On Wed, Dec 2, 2015 at 8:40 PM, Henry Rich <henryhr...@gmail.com> wrote: >>> The 2 versions give different results. >>> >>> Mine: >>> >>> i =. ".;._1@('x'&,);._2 wd 'clippaste' >>> >>> +/ (/:~@(1&(*/\.))"1 i) +/ . * 3 2 2 >>> >>> >>> Henry Rich >>> >>> >>> >>> >>> On 12/2/2015 8:19 PM, 'Pascal Jasmin' via Programming wrote: >>>> >>>> was wondering what took 7 lines, but its style >>>> >>>> 1: with input parsing >>>> >>>> +/ +/ (<./, 2&*)"1 */every@:(0 2&{ ; 1 2&{ ; 0 1&{)"1 ". > cutLF 'x ' >>>> rplc~ wdclippaste '' >>>> >>>> 2: >>>> >>>> +/ +/@(*/ , +:@(2 {. /:~))("1) ". > cutLF 'x ' rplc~ wdclippaste '' >>>> >>>> >>>> >>>> ----- Original Message ----- >>>> From: Joe Bogner <joebog...@gmail.com> >>>> To: programm...@jsoftware.com >>>> Sent: Wednesday, December 2, 2015 7:37 PM >>>> Subject: [Jprogramming] advent of code - day 2 >>>> >>>> building upon: >>>> http://jsoftware.com/pipermail/programming/2015-December/043407.html, >>>> but starting a new thread since the other one started to go in a >>>> different direction. >>>> >>>> http://adventofcode.com/day/2 >>>> >>>> Here's my solution: >>>> https://github.com/joebo/lang-lab/blob/master/j/advent2015/day2.ijs >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >> >> >> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>> >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm