Record of experiments, readings, links, videos and other things that I find on the long road. Registro de experimentos, lecturas, links, vídeos y otras cosas que voy encontrando en el largo camino.
That's a neat little test. I had a go before comparing yours with mine: (as-> text $ (frequencies $) (sort-by val $) (reverse $) (map first $) (apply str $) (clojure.string/replace $ #"_.+" ""))Six of one, half dozen the other I guess. ;-)
My variation:(def input "epqiiqwdiwgyka_vsqtsu.....(->> input frequencies (sort-by val) (map key) reverse (apply str) (re-find #"[^_]+"))And with Bash:grep -o . input|sort|uniq -c|sort -nr|awk '{printf $2}'|grep -oP "[^_]+"|head -1
This comment has been removed by the author.
The reverse operation can be done away with:(def input "epqiiqwdiwgyka_vsqtsu.....(->> inputfrequencies(sort-by #(-' (val %)))(map key)(apply str)(re-find #"[^_]+"))
That's a neat little test. I had a go before comparing yours with mine:
ReplyDelete(as-> text $
(frequencies $)
(sort-by val $)
(reverse $)
(map first $)
(apply str $)
(clojure.string/replace $ #"_.+" ""))
Six of one, half dozen the other I guess. ;-)
My variation:
ReplyDelete(def input "epqiiqwdiwgyka_vsqtsu.....
(->> input
frequencies
(sort-by val)
(map key)
reverse
(apply str)
(re-find #"[^_]+"))
And with Bash:
grep -o . input|sort|uniq -c|sort -nr|awk '{printf $2}'|grep -oP "[^_]+"|head -1
This comment has been removed by the author.
ReplyDeleteThe reverse operation can be done away with:
ReplyDelete(def input "epqiiqwdiwgyka_vsqtsu.....
(->> input
frequencies
(sort-by #(-' (val %)))
(map key)
(apply str)
(re-find #"[^_]+"))