fork download
  1. h = {1 => 'st', 2 => 'nd', 3 => 'rd'}.tap {|h| h.default = 'th'}
  2. f = -> n {(11..13).include?(n % 100) ? h.default : h[n % 10]}
  3. p [1, 23, 12].map {|n| [n, n.to_s + f.(n)]}
  4.  
Success #stdin #stdout 0s 6444KB
stdin
Standard input is empty
stdout
[[1, "1st"], [23, "23rd"], [12, "12th"]]