Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

###Ruby, (削除) 104 (削除ここまで)(削除) 92 (削除ここまで) 91 characters###

Ruby, (削除) 104 (削除ここまで)(削除) 92 (削除ここまで) 91 characters

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

###Ruby, (削除) 104 (削除ここまで)(削除) 92 (削除ここまで) 91 characters###

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

Ruby, (削除) 104 (削除ここまで)(削除) 92 (削除ここまで) 91 characters

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

added 13 characters in body
Source Link
David Herrmann
  • 1.6k
  • 10
  • 14

###Ruby, (削除) 104 (削除ここまで) 92(削除) 92 (削除ここまで) 91 characters###

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

###Ruby, (削除) 104 (削除ここまで) 92 characters###

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

###Ruby, (削除) 104 (削除ここまで) (削除) 92 (削除ここまで) 91 characters###

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

added syntax highlighting
Source Link
David Herrmann
  • 1.6k
  • 10
  • 14

###Ruby, 104(削除) 104 (削除ここまで) 92 characters###

def f(s)m=("a".."z").to_a;l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m.join, l.sort.transpose[1].join)end

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'', l.sort.transpose[1]*'')}

Online Version Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

###Ruby, 104 characters###

def f(s)m=("a".."z").to_a;l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m.join, l.sort.transpose[1].join)end

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

###Ruby, (削除) 104 (削除ここまで) 92 characters###

Saved quite a few characters thanks to @Chron

f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'', l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.

In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

added 3 characters in body
Source Link
David Herrmann
  • 1.6k
  • 10
  • 14
Loading
added 173 characters in body
Source Link
David Herrmann
  • 1.6k
  • 10
  • 14
Loading
Source Link
David Herrmann
  • 1.6k
  • 10
  • 14
Loading

AltStyle によって変換されたページ (->オリジナル) /