Last active
August 29, 2015 14:14
-
-
Save maehrm/b9be81fb97b1222e815b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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