Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ challenge #-1/12

Name: Anonymous 2021-03-15 11:30

Write a program to count the frequencies of unique words from standard input, then print them out with their frequencies, ordered most frequent first, then ordered ASCIIbetically ascending. For example, given this input:

Hax my anus anus anus
hax the planet and anus

The program should print the following:

anus 4
hax 2
and 1
my 1
planet 1
the 1


ASCII input and output since unicode was a mistake. Shortest bytecount wins. Good luck.

Name: Anonymous 2021-03-15 20:03

Some rusty bash after >5 years of not having used Linux...

tr 'A-Z ' 'a-z\n' | sort | uniq -c | sort -k1rn,1 -k2,2 | awk '{ print $2 " " $1}'

I'm not happy with the
awk
part, I had to google it like a pajeet. I'm sure that it's possible with
cut
, but I could not get it to work in the free (as in free beer) online emulator I was using.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List