Skip to main content
shortened and fixed bytecount
Source Link
jpjacobs
  • 3.5k
  • 19
  • 17

J 48 Bytes#41 35 Bytes

(u:65+i.26)&([\:[:#[#/.~[~@,((e.~#])toupper))

Demo:

i=: 'This is a test to see whether this is still working'
(u:65+i.26)&([\:[:#[#/.~[~@,((e.~#])toupper)) i
STIEHLORWAGKNBCDFJMPQUVXYZ

Explanation:

(u:65+i.26) & ( [ \: [: #/.~  [ ~@, ((e.~#]) toupper) )
ABCDE...          |      |      |   |      uppercase the right argument
                  |      |      |   \copy from right only member from left
                  |      |      \append the left argument
                  |      \ Afterwards Count apperances of each letter
                  \ Sort the left according to the appearances

The key is to append the left array, such that all letters are available, and already in order. A funny consequence of using a noun as third tine to the fork is that it works as verb as well as as phrase.

J 48 Bytes#

(u:65+i.26)&([\:[:#/.~[,((e.~#])toupper))

Demo:

i=: 'This is a test to see whether this is still working'
(u:65+i.26)&([\:[:#/.~[,((e.~#])toupper)) i
STIEHLORWAGKNBCDFJMPQUVXYZ

Explanation:

(u:65+i.26) & ( [ \: [: #/.~  [ , ((e.~#]) toupper) )
ABCDE...          |      |      |   |      uppercase the right argument
                  |      |      |   \copy from right only member from left
                  |      |      \append the left argument
                  |      \ Count apperances of each letter
                  \ Sort the left according to the appearances

The key is to append the left array, such that all letters are available, and already in order.

J 41 35 Bytes

(u:65+i.26)([\:[#/.~@,e.~#])toupper

Demo:

i=: 'This is a test to see whether this is still working'
(u:65+i.26)([\:[#/.~@,e.~#])toupper i
STIEHLORWAGKNBCDFJMPQUVXYZ

Explanation:

(u:65+i.26) & ( [ \: [ #/.~@,e.~#]) toupper) )
ABCDE...          |    |    |   |      uppercase the right argument
                  |    |    |   \copy from right only member from left
                  |    |     \append the left argument
                  |    \ Afterwards Count apperances of each letter
                  \ Sort the left according to the appearances

The key is to append the left array, such that all letters are available, and already in order. A funny consequence of using a noun as third tine to the fork is that it works as verb as well as as phrase.

Source Link
jpjacobs
  • 3.5k
  • 19
  • 17

J 48 Bytes#

(u:65+i.26)&([\:[:#/.~[,((e.~#])toupper))

Demo:

i=: 'This is a test to see whether this is still working'
(u:65+i.26)&([\:[:#/.~[,((e.~#])toupper)) i
STIEHLORWAGKNBCDFJMPQUVXYZ

Explanation:

(u:65+i.26) & ( [ \: [: #/.~  [ , ((e.~#]) toupper) )
ABCDE...          |      |      |   |      uppercase the right argument
                  |      |      |   \copy from right only member from left
                  |      |      \append the left argument
                  |      \ Count apperances of each letter
                  \ Sort the left according to the appearances

The key is to append the left array, such that all letters are available, and already in order.