Message decipher

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 26 ) 7x + 2\pmod{26} . 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).


The answer is 124.

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.

4 solutions

David Holcer
Mar 15, 2015
1
2
3
4
5
6
7
8
summ=0
strr='FKHHCGCXHD'.lower() # sets string to encoded message.
for i in strr: # each letter of string.
    num = ord(i)-96 #numeric value of each letter
    for j in range(1,27): # iterates through letter values to check for...
        if ((7*j+2)%26)==num: # a number (letter) that matches the equation for each letter of encoded message.
            summ+=j # adds found number (letter) to total summ. 
print summ

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
Spy Mabana
Nov 28, 2014

Simple algorithm in c++

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
int main() {
    char txt[] = "fkhhcgcxhd"; //the input code
    int sum = 0;
    for(int i = 0; i < 10; i++) {
        int d = txt[i] - 'a' + 1; // get the value of the letter
        //(i.e.): f - 'a' + 1 = 6 + 1 = 7. F = 7
        for(int j = 1; j <= 26; j++) {
            if(((7 * j) + 2) % 26 == d) { // find the original letter
                sum += j; // add to sum
                break; // go to next letter if already found
            }
        }
    }
    cout << "Sum is: " << sum << endl;
}

Sum is 124 \boxed{124} .

Aditya Raut
Oct 5, 2014

First of all, the easy way is to list out all the transforms,

Original Letter Original Number x 7 x + 2 ( m o d 26 ) Final Letter A 1 9 I B 2 16 P C 3 23 W D 4 4 D E 5 11 K F 6 18 R G 7 25 Y H 8 6 F I 9 13 M J 10 20 T K 11 1 A L 12 8 H M 13 15 O N 14 22 V O 15 3 C P 16 10 J Q 17 17 Q R 18 24 X S 19 5 E T 20 12 L U 21 19 S V 22 0 Z W 23 7 G X 24 14 N Y 25 21 U Z 26 2 B \begin{array}{|c|c||c|c|} \text{Original Letter} & \text{Original Number x} & 7x+2 \pmod{26} & \text{Final Letter} \\ \hline A& 1& 9 & I\\ \hline\\ B&2& 16&P\\ \hline\\ C&3& 23&W\\ \hline\\ D&4& 4&D\\ \hline\\ E&5& 11&K\\ \hline\\ F&6& 18&R\\ \hline\\ G&7& 25&Y\\ \hline\\ H&8& 6&F\\ \hline\\ I&9&13&M\\ \hline\\ J&10& 20&T\\ \hline\\ K&11&1&A\\ \hline\\ L&12& 8&H\\ \hline\\ M&13& 15&O\\ \hline\\ N&14& 22&V\\ \hline\\ O&15& 3&C\\ \hline\\ P&16& 10&J\\ \hline\\ Q&17& 17&Q\\ \hline\\ R&18& 24&X\\ \hline\\ S&19& 5&E\\ \hline\\ T&20& 12&L\\ \hline\\ U&21& 19&S\\ \hline\\ V&22& 0&Z\\ \hline\\ W&23& 7&G\\ \hline\\ X&24& 14&N\\ \hline\\ Y&25& 21&U\\ \hline\\ Z&26& 2&B\\ \end{array}

Thus, the code "FKHHCGCXHD" is actually "HELLOWORLD" and has it's sum as 8 + 5 + 12 + 12 + 15 + 23 + 15 + 18 + 12 + 4 = 124 8+5+12+12+15+23+15+18+12+4= \boxed{124}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...