Last active
August 24, 2020 21:46
-
-
Save Konstantinusz/29bab03eb6c4286dc05761f6897b8271 to your computer and use it in GitHub Desktop.
2005-ös érettségi - Vigenére
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
H=("ÖÜÓŐÚŰÁÉÍ".split(//).zip("OUOOUUAEI".split(//))).to_h | |
t=('A'..'Z').to_a | |
tt={} | |
tt.merge!({t[0]=>t.zip(t).to_h}) | |
for p in 0..t.size-2 do | |
tt.merge!({t[p+1]=>t.zip(t[p+1..-1]+t[0..p]).to_h}) | |
end | |
kodolatlan="EZAPROBASZOVEGAMITKODOLUNK" #STDIN.readline.chomp | |
kodolatlan=kodolatlan.gsub(" ","").upcase.split(//).map{|c| H[c]==nil ? c : H[c] }.join | |
kodszo="auto" #STDIN.readline.chomp | |
kodszo=kodszo.gsub(" ","").upcase.split(//).map{|c| H[c]==nil ? c : H[c] }.join | |
puts kodszo | |
kodolt=kodolatlan.split(//).collect.with_index.map{|c,i| | |
tt[kodszo[i % kodszo.size]][c] | |
}.join | |
puts kodolt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment