The "each each" could be replaced by the more generic L:, giving

validIds (((alpha i. ]) { alpha |.~ [) L: 0)"0 '-' cut each validCodes

but this loses the nice data structure correspondence and needs an
extra rank-zero specification (which comes for free with "each").


Alternatively, how about moving the '-' transformation into the decoding 
section:

validIds ((('-' , alpha) i. ]) { ' ' , alpha |.~ [) each validCodes

┌────────────────────────────────────┬────────────────────────────────┐
│rampaging projectile rabbit training│onsumer grade flower acquisition│
└────────────────────────────────────┴────────────────────────────────┘

--
David

Joe Bogner <[email protected]> writes:

> I'm back to working on Advent of Code. I'm on day 4, a bit late I know.
>
> I have "each each" in my solution which doesn't feel right to me.
>
> Here's a reproducible case:
>
> validCodes =:
> ('mvhkvbdib-kmjezxodgz-mvwwdo-omvdidib';'zydfxpc-rclop-qwzhpc-lnbftdtetzy')
> validIds=: 837 171
> alpha =: 'abcdefghijklmnopqrstuvwxyz'
>
> validIds ((alpha i. ]) { alpha |.~ [) each each '-' cut each validCodes
>
>
> ┌──────────────────────────────────────┬──────────────────────────────────┐
> │┌─────────┬──────────┬──────┬────────┐│┌───────┬─────┬──────┬───────────┐│
> ││rampaging│projectile│rabbit│training│││onsumer│grade│flower│acquisition││
> │└─────────┴──────────┴──────┴────────┘│└───────┴─────┴──────┴───────────┘│
> └──────────────────────────────────────┴──────────────────────────────────┘
>
> Does the "each each" feel out of place? If so, how would it be eliminated?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to