At your communication center, you intercept a message transmit by your ennemy. This message is : FKHHCGCXHD. Also, one of spy (hopefully) find the encryption formula used by your ennemy : 7 x + 2 ( m o d 2 6 ) . X variable is the rank of the letter in the alphabet (starting at A = 1). What is the sum of all the letters of original message ?
(example for the word "he" the sum is 8 + 5 = 13).
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Solution in Ruby. Created a hash with keys corresponding to '((i * 7) + 2) mod 26' (the encrypted character) and values corresponding to i (the original alphabetic character).
letters = {}
for i in (1..26)
letters[((i * 7) + 2) % 26] = i # 0 equals to z here.
end
cipher = [6,11,8,8,3,7,3,24,8,4] # numeric positions for the FKHHCGCXHD letters.
message = []
cipher.each { |l| message.push(letters[l]) }
# message == [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] : HELLOWORLD
s = 0
message.each { |n| s += n }
# s == 124
Simple algorithm in c++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Sum is 1 2 4 .
First of all, the easy way is to list out all the transforms,
Original Letter A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Original Number x 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 7 x + 2 ( m o d 2 6 ) 9 1 6 2 3 4 1 1 1 8 2 5 6 1 3 2 0 1 8 1 5 2 2 3 1 0 1 7 2 4 5 1 2 1 9 0 7 1 4 2 1 2 Final Letter I P W D K R Y F M T A H O V C J Q X E L S Z G N U B
Thus, the code "FKHHCGCXHD" is actually "HELLOWORLD" and has it's sum as 8 + 5 + 1 2 + 1 2 + 1 5 + 2 3 + 1 5 + 1 8 + 1 2 + 4 = 1 2 4
Problem Loading...
Note Loading...
Set Loading...