Skip to main content
Commonmark migration
Source Link

Brachylog, 8 bytes

ọtᵒtᵍhth

Try it online!

###Explanation

Explanation

Example input: 495902

ọ          Occurences:    [[4,1],[9,2],[5,1],[0,1],[2,1]]
 tᵒ        Order by tail: [[0,1],[2,1],[4,1],[5,1],[9,2]]
   tᵍ      Group by tail: [[[0,1],[2,1],[4,1],[5,1]],[[9,2]]]
     h     Head:          [[0,1],[2,1],[4,1],[5,1]]
      t    Tail:          [5,1]
       h   Head:          5

Brachylog, 8 bytes

ọtᵒtᵍhth

Try it online!

###Explanation

Example input: 495902

ọ          Occurences:    [[4,1],[9,2],[5,1],[0,1],[2,1]]
 tᵒ        Order by tail: [[0,1],[2,1],[4,1],[5,1],[9,2]]
   tᵍ      Group by tail: [[[0,1],[2,1],[4,1],[5,1]],[[9,2]]]
     h     Head:          [[0,1],[2,1],[4,1],[5,1]]
      t    Tail:          [5,1]
       h   Head:          5

Brachylog, 8 bytes

ọtᵒtᵍhth

Try it online!

Explanation

Example input: 495902

ọ          Occurences:    [[4,1],[9,2],[5,1],[0,1],[2,1]]
 tᵒ        Order by tail: [[0,1],[2,1],[4,1],[5,1],[9,2]]
   tᵍ      Group by tail: [[[0,1],[2,1],[4,1],[5,1]],[[9,2]]]
     h     Head:          [[0,1],[2,1],[4,1],[5,1]]
      t    Tail:          [5,1]
       h   Head:          5
Source Link
Fatalize
  • 39.3k
  • 5
  • 70
  • 162

Brachylog, 8 bytes

ọtᵒtᵍhth

Try it online!

###Explanation

Example input: 495902

ọ          Occurences:    [[4,1],[9,2],[5,1],[0,1],[2,1]]
 tᵒ        Order by tail: [[0,1],[2,1],[4,1],[5,1],[9,2]]
   tᵍ      Group by tail: [[[0,1],[2,1],[4,1],[5,1]],[[9,2]]]
     h     Head:          [[0,1],[2,1],[4,1],[5,1]]
      t    Tail:          [5,1]
       h   Head:          5