Created
May 24, 2014 10:19
-
-
Save andrusha/ac1608a8aa146b2b9510 to your computer and use it in GitHub Desktop.
Fez game language decypherer
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
$alphabet = | |
{ | |
11 => ?i, | |
12 => ?c, | |
13 => ?u, | |
14 => ?o, | |
21 => ?t, | |
22 => ?n, | |
23 => ?h, | |
24 => ?b, | |
31 => ?q, | |
32 => ?e, | |
33 => ?k, | |
34 => ?z, | |
41 => ?s, | |
42 => ?a, | |
43 => ?g, | |
44 => ?m, | |
51 => ?y, | |
52 => ?r, | |
53 => ?l, | |
54 => ?f, | |
61 => ?w, | |
62 => ?j, | |
63 => ?d, | |
64 => ?p, | |
} | |
messages = [ | |
[ | |
[22, 11, 12, 32], [21, 14], | |
[44, 32, 32, 21], [51, 14, 13] | |
], | |
[ | |
[11], [21, 23, 11, 22, 33], [11, 21], [11, 41], | |
[22, 11, 12, 32], [21, 14], [23, 42, 13, 32], | |
[42], [13, 11, 41, 11, 21, 14, 52], | |
[54, 14, 52], [14, 22, 12, 32] | |
], | |
[ | |
[23, 14, 61], [63, 14], | |
[51, 14, 13], [63, 14] | |
], | |
[ | |
[61, 23, 42, 21], [11, 41], | |
[61, 52, 14, 22, 43], [61, 11, 21, 23], | |
[51, 14, 13, 52], [23, 32, 42, 63] | |
], | |
[ | |
[23, 42], [23, 42], [23, 42], | |
[12, 23, 32, 12, 33], [14, 13, 21], [44, 52], | |
[52, 32, 12, 21, 42, 22, 43, 53, 32], [23, 32, 42, 63], | |
[14, 13, 32, 52], [21, 23, 32, 52, 32] | |
], | |
[ | |
[61, 23, 32, 52, 32], [61, 11, 63], [51, 14, 13], | |
[12, 14, 44, 32], [54, 52, 14, 44] | |
], | |
[ | |
[23, 32, 52, 52, 14], | |
[12, 42, 22], [51, 14, 13], | |
[13, 22, 63, 32, 52, 41, 21, 42, 22, 63], | |
[42, 22, 51], [14, 54], [21, 23, 11, 41] | |
], | |
[ | |
[63, 23, 32, 52, 32], [63, 11, 63], | |
[51, 14, 13], [43, 32, 21], | |
[21, 23, 42, 21], [23, 42, 21] | |
], | |
[ | |
[41, 14], [21, 23, 11, 41], [11, 41], [62, 13, 41, 21], [42], | |
[52, 14, 13, 21, 11, 22, 32], [64, 52, 14, 12, 32, 63, 13, 52, 32], | |
[24, 13, 21], [11], [63, 14], [22, 32, 32, 63], | |
[41, 14, 44, 32, 14, 22, 32], [23, 32, 52, 32], [62, 13, 41, 21], | |
[11, 22], [12, 42, 41, 32], [41, 14, 44, 32, 21, 23, 11, 22, 43], | |
[43, 14, 32, 41], [61, 52, 14, 22, 43] | |
], | |
[ | |
[11, 54], [41, 14, 44, 32, 21, 23, 11, 22, 43], [63, 14, 32, 41], | |
[43, 14], [61, 52, 14, 22, 43], [51, 14, 13], [42, 52, 32], | |
[43, 14, 11, 22, 43], [21, 14], [23, 42, 13, 32], [21, 14], | |
[12, 53, 32, 42, 22], [13, 64], [21, 23, 32], [44, 32, 41, 41] | |
], | |
[ | |
[14, 23], [61, 32, 53, 53], [51, 13, 13], [42, 52, 32], | |
[23, 32, 52, 32], [22, 14, 61], [44, 11, 43, 23, 21], [42, 41], | |
[61, 32, 53, 53], [61, 14], [21, 23, 11, 41], [21, 23, 11, 22, 43], | |
[64, 52, 32, 64, 42, 52, 32], [21, 14], [23, 32, 13, 32], | |
[51, 14, 13, 52], [44, 11, 22, 63], [24, 53, 14, 61, 22] | |
], | |
[ | |
[42, 53, 53], [52, 11, 43, 23, 21], | |
[61, 32, 53, 12, 14, 44, 32], [21, 14], [21, 23, 32], | |
[12, 53, 13, 24], [32, 22, 62, 14, 51], [51, 14, 13, 52], | |
[54, 52, 32, 32], [23, 42, 21] | |
], | |
[ | |
[11], [33, 11, 22, 63], [14, 54], [21, 23, 14, 13, 43, 23, 21], | |
[44, 42, 51, 24, 32], [21, 23, 11, 41], [61, 14, 13, 43, 23, 21], | |
[22, 14, 21], [61, 14, 52, 31], [24, 32, 12, 42, 13, 41, 32], | |
[14, 54], [51, 14, 13, 52], [61, 32, 11, 52, 61], [23, 32, 42, 63], | |
[23, 13, 21], [32, 13, 32, 52, 51, 21, 23, 11, 22, 43], [53, 14, 14, 31, 41], | |
[42, 14, 31], [54, 52, 14, 44], [14, 13, 32, 52], [23, 32, 52, 32] | |
], | |
[ | |
[21, 23, 42, 22, 31, 41], [54, 14, 52], [21, 23, 32], [23, 42, 22, 63], | |
[51, 14, 13], [12, 42, 22], [43, 14], [23, 14, 44, 32], | |
[22, 14, 61], [11, 21], [61, 42, 41], [13, 32, 52, 51], [22, 11, 12, 32], | |
[21, 14], [44, 32, 32, 21], [51, 14, 13] | |
] | |
] | |
def decypher_word(word) | |
word.map do |letter| | |
$alphabet[letter] || '_' | |
end | |
end | |
puts '--------' | |
wordcount = Hash.new(0) | |
lettercount = Hash.new(0) | |
messages.each do |words| | |
words.each do |word| | |
wordcount[word] += 1 | |
word.each do |letter| | |
lettercount[letter] += 1 | |
end | |
end | |
end | |
wordcount.to_a.sort_by(&:last).each do |k, v| | |
puts "#{v}: #{k}" | |
end | |
puts '--------' | |
lettercount.to_a.sort_by(&:last).each do |k, v| | |
puts "#{v}: #{k}" | |
end | |
puts '--------' | |
messages.each do |words| | |
p words.map(&method(:decypher_word)).map(&:join).join(' ') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symbols encoding:
Symbol id is XY, where: X - row number (symbol type); Y - column number (symbol orientation).