Oh, yes, so did I:
require'convert'
knothash=:3 :0
(0,0,i.256) knothash y
:
pos=. 0{x
skip=. 1{x
list=. 2}.x
for_len.y do.
inds=.(#list)|pos+i.len
list=. (|.inds{list) inds} list
pos=. (#list)|pos+len+skip
skip=. skip+1
end.
pos,skip,list
)
xor=:22 b.
denseknot=:3 :0
asc=.(a.i.y),17, 31, 73, 47, 23
sparse=. 2}.knothash&asc^:64]0 0,i.256
,hfd _16 xor/\ sparse
)
knothash takes numeric arguments, denseknot takes literal arguments
My original implementation of knothash just had (list) as an argument,
but I changed it for part 2.
FYI,
--
Raul
On Mon, Dec 11, 2017 at 8:07 AM, David Lambert <[email protected]> wrote:
> I took advantage of j's residue definition for negative values. My verb
> rewrites the list keeping the "current position pointer" at the head,
> thereby losing track of the front of the list.
>
> (list tally) | negative sum of all advancements
>
> computes the front of the list.
>
>
> parta=: $:&256 : (4 :0) NB. LENGTHS parta N
> list=. i.y
> skip=. 0
> for_length. x do.
> list=. (length + skip) |. length (|.@:{.)`(i.@:[)`]} list
> skip=. >: skip
> echo length ; skip ; list
> end.
> i=.+/(,i.@:#)x
> list ; i ; ((#list) | -i) ; */ (0 1 + ((#list) | -i)){,~list
> )
>
> On 12/11/2017 07:00 AM, [email protected] wrote:
>>
>> From: Jimmy Gauvin<[email protected]>
>> To:[email protected]
>> Subject: [Jprogramming] AOC 10 - explicit to tacit
>> Message-ID:
>>
>> <caelwgoeukwzemzv6rq4bne5jb4ujduyhtjtmydawzkfwbai...@mail.gmail.com>
>> Content-Type: text/plain; charset="UTF-8"
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm