Hacker News new | past | comments | ask | show | jobs | submit login

I got a few steps further after lots of experimentation with ngn/k and the extra hints further downthread:

https://gist.github.com/vidarh/3cd1e200458758f3d58c88add0581...

The big caveat being it clicked too late that 1) "encode" is not "change base and format", but "for each element in this array, apply the module to the entire other array, and pass the quotient forward", and 2) encode returns a list of columns of the remainders rather than rows (the output format really does not make this clear...).

So you can turn a list of seconds into hour, minute, seconds with e.g.: (24 60 60)\(86399 0 60), but what you get out is [hour, minute, second] where hour, minute, second each are arrays.

If you want them in the kind of format that doesn't break the minds of non-array-thinking people like us because the order actually matches the input, you'd then transpose them by prepending "+", because why not overload unary plus to change the structure of the data?

   +(24 60 60)\(86399 0 60)
Returns (23 59 59 0 0 0 0 1 0)

Or [[23,59,59], [0,0,0], [0,1,0]] in a saner output format that makes it clear to casuals like me which structure is contained in what.

Now, if you then want to also flatten them, you prepend ",/"

I feel much better now. Until the next time I spend hours figuring out a single line of k.




Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: