Substitute Teacher
-
- Posts: 8
- Joined: Sat Nov 01, 2008 2:49 pm
If you wanted to write a program to solve monoalphabetic substitution ciphers for you, then try using the churn algorith (http://web.mac.com/mikejcowan/Ciphers/C ... rithm.html) and a tetragraph. As to which programming language to use, it is up to you.
P.S. Tetragraphs are very hard to find, but there are some out there.
P.S. Tetragraphs are very hard to find, but there are some out there.
There is no spoon.
-
- Posts: 49
- Joined: Fri Jul 02, 2010 9:34 pm
- Location: Egypt
- Contact:
Since i didn't have any idea of cryptography till today and im not an native english speaker, it wasn't an easy task. Took me good 2 hours to finish this one, but i had fun
I made a little page to help me keep track of my substitutions:
Right now it's also accessible at http://web-werker.de/tmp/chifre.php
It's not realy good, just scramped something together, it still helped me on some ROT* chiffred ones
(**EDIT: added a input field to the online version **)
I made a little page to help me keep track of my substitutions:
Right now it's also accessible at http://web-werker.de/tmp/chifre.php
It's not realy good, just scramped something together, it still helped me on some ROT* chiffred ones
(**EDIT: added a input field to the online version **)
Code: Select all
<script src="jquery.min.1.4.3.js"></script>
<script>
$(document).ready( function() {
$('.up').click( function(event) {
var parent = $(this).parent();
var clss = $(parent).find("span").attr("class");
change_chars(clss, 1);
return false;
});
$('.down').click( function(event) {
var parent = $(this).parent();
var clss = $(parent).find("span").attr("class");
change_chars(clss, -1);
return false;
});
function change_chars(cls, number) {
var obj = $("." + cls);
// 65 = A
// 90 == Z
//console.log("obj " + obj);
var char = obj.html();
if(char > 90 || char < 65) return false;
//console.log("char " + char);
var char_code = char.charCodeAt(0) + number;
if(char_code > 90) char_code = 65;
else if(char_code < 65) char_code = 90;
obj.html(String.fromCharCode(char_code));
$('span').css("background", "#ccc");
obj.css("background", "#999");
}
function move_all(number) {
var cls_array = new Array("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");
for( var i = 0 ; i < 26 ; i+= 1) {
change_chars(cls_array[i], number);
}
}
$('#all_u').append("<a href='#'>all up</a>");
$('#all_d').append("<a href='#'>all down</a>");
$('#all_u a').click(function() { move_all(1) });
$('#all_d a').click(function() { move_all(-1) });
$('span').click(function() {
var cls = $(this).attr("class");
$("." + cls).css("background", "#999");
});
});
</script>
<style>
* { outline: none; }
body { padding: 0; margin: 0; padding-top: 5px; background: #8181F7; background: #6B8E23; }
td { text-align: center; }
span { display: block; background: #ccc; width: 20px; font-size: 20px; }
.hl { background: border: 1px solid red; }
a { display: block; text-decoration: none; background: #000; color: #fff; }
a.up { font-weight: bold; }
table { margin: 10px 0 10px 120px;}
tr { vertical-align: middle;}
#all_u a, #all_d a { padding: 10px 0; text-align: center; }
</style>
<?php
$coded = "ISS NVVK DIPXYWA PIT AVSUY QIAOP PWZEHVNWIEDZ. CDYT ZVM LOTK HDY AVSMHOVT HV HDOA HYFH, ZVM COSS QY IQSY HV NYH HDY ITACYW, CDOPD OA IKMGQWIHY";
echo "<div id='all_u'></div>";
echo "<table><tr>";
for($i = 0; $i < strlen($coded); $i++) {
if($coded[$i] != " ") {
$up = ($coded[$i] != ',' && $coded[$i] != '.') ? "<a class='up' href='#'>^</a>" : "";
$down = ($coded[$i] != ',' && $coded[$i] != '.') ? "<a class='down' href='#'>v</a>" : "";
echo "
<td>
$up
<span class='$coded[$i]'>$coded[$i]</span>
$down
</td>";
}
else {
if($r_count > 3) {
echo "</tr></table><table><tr>";
$r_count = 1;
} else {
echo "<td> | </td>";
}
$r_count++;
}
}
echo "</tr></table>";
echo "<div id='all_d'></div>";
?>
-
- Posts: 8
- Joined: Tue Aug 16, 2011 12:35 pm
Another possible approach is to exploit very long word. The ciphertext PWZEHVNWIEDZ would suggest that this word has exactly three distinct duplicate characters at position 2 & 8, 3 & 12 and 4 & 10 and nothing else. The quick search on my laptop gave this:
Among them only cryptography, manipulation, panification, sanification, tachygraphic are possible, and you know what is appropriate for this context.
Code: Select all
$ grep -E '^.(.)(.)(.)...\1.\3.\2$' /usr/share/dict/words
archimorphic
cryptography
fictionistic
interconnect
intervenient
manipulation
minimifidian
panification
sanification
semiquietism
tachygraphic
tangantangan
When your brain is very much used to the structure of your mother tongue, you can hardly get into this riddle. Furthermore this kind of riddles is rather uncommon in German speaking cultures. I found this challenge was hardly possible to solve without the help of a computer and online ressources.
I had Python (very rapid and simple, 60 script lines) analyze the distribution of letters and two- and three-letter combinations. Then I started programming a Java App (110 code lines by now) to perform the substitution and added more and more visual support (AWT) until I managed to solve the riddle easily. I started with the 2-letter and 3-letter combinations in accordance with lists from puzzle-solvers' web sites from English-speaking quiz aficionados.
tired now
Smee
I had Python (very rapid and simple, 60 script lines) analyze the distribution of letters and two- and three-letter combinations. Then I started programming a Java App (110 code lines by now) to perform the substitution and added more and more visual support (AWT) until I managed to solve the riddle easily. I started with the 2-letter and 3-letter combinations in accordance with lists from puzzle-solvers' web sites from English-speaking quiz aficionados.
tired now
Smee
I just used an automatic solver
LAZY
http://www.purplehell.com/riddletools/a ... togram.htm
http://www.blisstonia.com/software/WebD ... /index.php
LAZY
http://www.purplehell.com/riddletools/a ... togram.htm
http://www.blisstonia.com/software/WebD ... /index.php
just another solution
This was way harder than expected though my solution is a bit of an overkill. Yet a good question is why does it have more than 2,500 solvers.
I solved it by writing a C++ program which searches every possibility for the last word in an dictionary and submits the good ones on the site. Of course, I used some pruning while generating the words (to have at least 2 vowels, etc.). Here's the code:
I solved it by writing a C++ program which searches every possibility for the last word in an dictionary and submits the good ones on the site. Of course, I used some pruning while generating the words (to have at least 2 vowels, etc.). Here's the code:
Code: Select all
#include <set>
#include <vector>
#include <cstdio>
#include <string>
#include <fstream>
#include <cstring>
#include <algorithm>
using namespace std;
string str = "IKMGQWIHY";
int id[32];
set<string> dict;
int main() {
ifstream fin("part-of-speech.txt");
string str;
while (fin >> str) {
for (int i=0; i < (int) str.size(); ++i)
if (str[i] >= 'A' && str[i] <= 'Z')
str[i] += 32;
dict.insert(str);
}
printf("read total %d entries\n", (int)dict.size());
FILE *out = fopen("res", "w");
for (int mask=1220700; mask < (1 << 26); ++mask) {
if (__builtin_popcount(mask) != 8) continue;
if (mask % 100 == 0) printf("%d ", mask); // progress
vector<char> cur; cur.clear();
int am = 0;
for (int i=0; i < 26; ++i)
if (mask & (1 << i)) {
cur.push_back(i+'a');
if (i == 0 || i == 4 || i == 8 || i == 15 || i == 21) // vowels
am ++;
}
if (am < 2) continue;
do {
string now; now.clear();
for (int i=0; i < 6; ++i)
now += cur[i];
now += cur[0];
now += cur[6];
now += cur[7];
if (dict.find(now) != dict.end()) {
//printf("found %s\n", now.c_str());
//fprintf(out, "found %s\n", now.c_str());
string ans = "firefox http://www.hacker.org/challenge/chal.php?answer=" + now + "\\&id=21\\&go=Submit";
system(ans.c_str());
system("sleep 30");
}
} while (next_permutation(cur.begin(), cur.end()));
}
fin.close();
return 0;
}
-
- Posts: 3
- Joined: Tue Jun 04, 2013 3:13 pm
this was a hard one
After several tries I startetd guessing character for character and build up a dictionary.
To do this I wrote this little groovy script which showed me the ciphertext and under it the plaintext as far as conversion from dictonary was possible. All other characters where shown as '.'
I started filling my dictionary with o -> I and A->S, because I guessed, the word 'OA' near the end could be the english word 'IS'.
From that point on, it became easier and easier.
To do this I wrote this little groovy script which showed me the ciphertext and under it the plaintext as far as conversion from dictonary was possible. All other characters where shown as '.'
I started filling my dictionary with o -> I and A->S, because I guessed, the word 'OA' near the end could be the english word 'IS'.
From that point on, it became easier and easier.
Code: Select all
def cipher = 'ISS NVVK DIPXYWA PIT AVSUY QIAOP PWZEHVNWIEDZ. CDYT ZVM LOTK HDY AVSMHOVT HV HDOA HYFH, ZVM COSS QY IQSY HV NYH HDY ITACYW, CDOPD OA IKMGQWIHY.'
def dic = [
' ': ' ',
'O': 'I',
'A': 'S',
'H': 'T',
'D': 'H',
'Y': 'E',
'I': 'A',
'T': 'N',
'C': 'W',
'W': 'R',
'P': 'C',
'N': 'G',
'V': 'O',
'X': 'K',
'K': 'D',
'Q': 'B',
'S': 'L',
'U': 'V',
'Z': 'Y',
'E': 'P',
'M': 'U',
'L': 'F',
'F': 'X',
]
println cipher
for(index in 0..<cipher.size()) {
print dic[cipher[index]]?:'.'
}
-
- Posts: 3
- Joined: Wed Feb 04, 2015 2:06 am
Re: Substitute Teacher
I just looked for the word "answer"Andr3w wrote:how did you solve the challenge ?
I don't think that its solvable manually like I tried first time ...
did you wrote own scripts ?
if yes in which language ? and could you post it eventually ? i would be really interested in how to solve such a program