I got stumped on a trivial part of today's challenge - the multi-level sort.

... " the checksum is the five most common letters in the encrypted
name, in order, with ties broken by alphabetization..."

It didn't even occur to me to sort the secondary (alphabetical) and
then the primary way (by frequency). I later peeked at Pascal's and
Henry's answer

I attempted concatenating the rank of the frequency and the letter

NB. http://code.jsoftware.com/wiki/JPhrases/RankClass
ranking=: >:@i.~\:~

/:~ (~. ([ ,~ ":@])"0 ranking@:(#/.~) ) 'aaaaabbbzyx'
1a
2b
3x
3y
3z

This worked reasonably well

But got completely messed up on this

/:~ (~. ([ ,~ ":@])"0 ranking@:(#/.~) ) 'zekvierkzferctyftfcrkvivtvzmzex'
10m
10x
10y
1e
1v
1z
4f
4k
4r
4t
8c
8i When it was as simple as this:

([: (~. \: #/.~) /:~) 'zekvierkzferctyftfcrkvivtvzmzex'
evzfkrtcimxy

 ((~. \: #/.~) @: /:~) 'aaaaabbbzyx'
abxyz

Thanks for sharing your solutions. I keep learning new things

Joe
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to