by qesa · 9y ago · 0 comments
With the reverse thrown in to switch the key/value around we get the correct answer
q) 1#desc sum each group (!/) reverse (" II";"\t")0:`:1gram
2006| 22569013
or k) {(&x=|/x)#x}@+/'=:!/|(" II";"\t")0:`:1gram
(,2006i)!,22569013i
Works the same for the simple example k)e: 4 5 8 9 6!"ABBCA"
k){(&x=|/x)#x}@+/'=:e
(,"B")!,13No comments yet.