Permalink
Browse files

Write ccc 2012 Junior problem 4

  • Loading branch information...
1 parent 0e50a1d commit 44993fbca824032b10e538755d864279cef89cc5 @neilparikh committed Nov 23, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 ccc/2012/j4.rb
View
@@ -0,0 +1,17 @@
+# all test cases passed
+
+k = gets.to_i
+word = gets.chomp
+final = []
+letters = [*'A'..'Z']
+
+word.split('').each_with_index do |c, i|
+ s = k + (i+1) * 3
+ a = letters.index(c) - s
+ while a < 0
+ a = 26 + a
+ end
+ final << letters[a]
+end
+
+puts final.join

0 comments on commit 44993fb

Please sign in to comment.