back again this year,
http://adventofcode.com/2016
--
For information about J forums see http://www.jsoftware.com/forums.htm
I've started a wiki page for it so we don't have to go back and add
them later. Feel free to edit/add
http://code.jsoftware.com/wiki/Essays/Advent_Of_Code_2016
My solution to the first problem is pretty bad (works though). I
intend to add another solution that's in a more functional style
On Thu
I added an alternate solution to problem 1, part 1 -
http://code.jsoftware.com/wiki/Essays/Advent_Of_Code_2016#Imperative_Style_.28cleanup.29
If I had the time, I would think about how to reformulate it so I
could use / to reduce the input to a single solution. I recall using
that pattern last yea
I posted an alternate solution,
a =. wdclippaste '' NB. input from clipboard
O =: 4 2 $ _1 0 0 1 1 0 0 _1
f =: 4 : 0
a =. 4 | x ({.@] + _1 1 {~ 'R' = {.@[) {: y
y , a , (}. {: y) + x (".@}.@[ * O {~ ]) a
)
+&|/ }. {: > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a f each/ (,: 0 0
0) (, <
Nice, that sounds like what i had in mind. I get a domain error though:
a =. 'R2, R2, R2'
O =: 4 2 $ _1 0 0 1 1 0 0 _1
f =: 4 : 0
a =. 4 | x ({.@] + _1 1 {~ 'R' = {.@[) {: y
y , a , (}. {: y) + x (".@}.@[ * O {~ ]) a
)
+&|/ }. {: > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a f each/
(,:
looks like I double pasted? all one line.
+&| /}. {: > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut 'R2, R2, R2'
or
+&| /}. {: > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a
- Original Message -
From: Joe Bogner
To: programm...@jsoftware.com
Sent: Thursday, December 1, 2016
My solution for day 1, using complex notation for X Y.
NB. in contains the input
d =: */\ 0j1 * 'R L' i. in #~ 'RL' e. ~ in NB. get directions for each move
st =: ". in -. 'RL' NB. step lengths
NB. get the manhattan distance (+/@:+. of all steps after each other, i.e.
their sum
]r =: +/ | +. +/ d
Dictionary says:
2!:1 y Spawn. (Unix only.) Like 2!:0, but yields '' without waiting
for the host to finish. Any output is ignored. For example, 2!:1 can be used to
invoke a text-editor.
But I tested on Linux and Mac, 2!:1 on both still waits for the process to
finish.
---
I think the documentation is correct, I think this is an
implementation bug/limitation. J addons and base library append
an & to y as workaround.
Чт, 01 дек 2016, Xiao-Yong Jin написал(а):
> Dictionary says:
>
>2!:1 y Spawn. (Unix only.) Like 2!:0, but yields '' without waiting
> for the
Here's how I'd approach the computational part of this problem:
L=: + 0j1&*
R=: + 0j_1&*
+/+. 2 R 3 L 0
5
+/+. 2 R 2 R 2 R 0
2
+/+. 5 R 5 L 5 R 3 R 0
18
Thanks,
--
Raul
On Thu, Dec 1, 2016 at 6:09 PM, Jan-Pieter Jacobs
wrote:
> My solution for day 1, using complex notation for
10 matches
Mail list logo