Skip to content

Instantly share code, notes, and snippets.

@maehrm
Last active August 29, 2015 14:14
Show Gist options
  • Save maehrm/b9be81fb97b1222e815b to your computer and use it in GitHub Desktop.
Save maehrm/b9be81fb97b1222e815b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# coding: utf-8
# 『有限と微笑のパン』で塙理生哉が西之園萌絵に出題する問題
# (1) この5文字(A E H R T)でできるすべての文字列は? => 120
# (2) アルファベットに並べると、地球は何番目? => 28
# (3) 55番目は? => ?
alphabets = %w(A E H R T)
# (1)
alphabets.permutation.size # => 120
# (2)
alphabets.permutation.sort.map(&:join).find_index('EARTH')+1 # => 28
# (3)
alphabets.permutation.sort.map(&:join)[55-1] # => "HEART"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment