Jump to content
BrainDen.com - Brain Teasers
  • 0


superprismatic
 Share

Question

A certain 10-letter word having the

second and fifth letters the same is

treated as follows: the first two

letters are multiplied together

(using the values A=1, B=2, ...,

Y=25, Z=0); then the next two letters

are similarly multiplied together and

the two products added (mod 26).

The sum is reconverted into a letter

using the same correspondence. The

same operations are performed on

letters 2 to 5 producing another

letter. This is continued until the

seventh letter is produced from the

last four letters of the word. The

letters so generated are, in order,

FPSLMMZ. What is the word?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Really confused how did you get this answer?

Run this python script in a folder with a text file in it called wordlist.txt which is a list of English words (that contains the correct word).

I think that formatting gets messed up, so I will use a ~ sign for indentation rather than just a space.

#!/usr/bin/python

def translate(s):

~st = '';

~for k in range(len(s)-3):

~~p = ord(s[k]);

~~if p < 97:

~~~a = (p-64) % 26;

~~else:

~~~a = (p-96) % 26;

~~p = ord(s[k+1]);

~~if p < 97:

~~~b = (p-64) % 26;

~~else:

~~~b = (p-96) % 26;

~~p = ord(s[k+2]);

~~if p < 97:

~~~c = (p-64) % 26;

~~else:

~~~c = (p-96) % 26;

~~p = ord(s[k+3]);

~~if p < 97:

~~~d = (p-64) % 26;

~~else:

~~~d = (p-96) % 26;

~~ch = (a*b+c*d) % 26;

~~if ch == 0:

~~~ch += 26;

~~ch = chr(ch+64);

~~st += ch;

~if st == 'FPSLMMZ':

~~print s, st;

x = open('wordlist.txt').read()

import re;

z = re.findall('[^a-zA-Z]([A-Za-z]([A-Za-z])[A-Za-z]{2}\\2[A-Za-z]{5})[^a-zA-Z]',x);

for k in z:

~translate(k[0]);

Link to comment
Share on other sites

  • 0

Run this python script in a folder with a text file in it called wordlist.txt which is a list of English words (that contains the correct word).

I think that formatting gets messed up, so I will use a ~ sign for indentation rather than just a space.

#!/usr/bin/python

def translate(s):

~st = '';

~for k in range(len(s)-3):

~~p = ord(s[k]);

~~if p < 97:

~~~a = (p-64) % 26;

~~else:

~~~a = (p-96) % 26;

~~p = ord(s[k+1]);

~~if p < 97:

~~~b = (p-64) % 26;

~~else:

~~~b = (p-96) % 26;

~~p = ord(s[k+2]);

~~if p < 97:

~~~c = (p-64) % 26;

~~else:

~~~c = (p-96) % 26;

~~p = ord(s[k+3]);

~~if p < 97:

~~~d = (p-64) % 26;

~~else:

~~~d = (p-96) % 26;

~~ch = (a*b+c*d) % 26;

~~if ch == 0:

~~~ch += 26;

~~ch = chr(ch+64);

~~st += ch;

~if st == 'FPSLMMZ':

~~print s, st;

x = open('wordlist.txt').read()

import re;

z = re.findall('[^a-zA-Z]([A-Za-z]([A-Za-z])[A-Za-z]{2}\\2[A-Za-z]{5})[^a-zA-Z]',x);

for k in z:

~translate(k[0]);

ok still confused but it looks impressive

Link to comment
Share on other sites

  • 0

ok still confused but it looks impressive

Look up "regular expressions". It is a way of searching through text for a particular pattern.

The string:

'[^a-zA-Z]([A-Za-z]([A-Za-z])[A-Za-z]{2}\\2[A-Za-z]{5})[^a-zA-Z]'

basically tells the program to look for a 10 letter word with the second and fifth characters being the same.

[^a-zA-Z] means a non-letter (the ^ symbol means none of the following)

[A-Za-z] means a capital or non-capital letter

adding parentheses around it makes it so you can reference it later

which is what the \\2 does. It means look for whatever letter was matched in the second pair of parentheses encountered.

the {2} and the {5} mean look for the previous thing 2 times or 5 times.

Once the computer has found all the potential matches, you just need to perform the translation described in the post on each word and see if any match up with

the encoded answer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...