Substitute Teacher

Discussion of challenges you have already solved
lordzerum
Posts: 2
Joined: Tue Sep 29, 2009 10:50 pm

Post by lordzerum »

I use Crank as auxiliar tool, but the hard work I made by hand.

As zac, I search for 'answer' word, and so on.

Challenges like this is so hard for me. English isn´t my maternal language. This affect the intuition to perceive the underlying text. :(
samuelandjw
Posts: 8
Joined: Sat Nov 01, 2008 2:49 pm

Post by samuelandjw »

i did it manually. it was so hard for me. i wonder why there are so solvers...
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

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.
There is no spoon.
Aghamemnon
Posts: 49
Joined: Fri Jul 02, 2010 9:34 pm
Location: Egypt
Contact:

just google it

Post by Aghamemnon »

try to google it and you'll find the answer :wink: :wink:
:twisted: Devilish Angel Aghamemnon :twisted:
Grevas
Posts: 10
Joined: Sat Oct 16, 2010 3:47 pm

Post by Grevas »

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 :roll:
(**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>";
?>
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

Just write a script that uses the churn algorithm and tetragraphs for frequency analysis. That'll solve it in under a second.
There is no spoon.
lifthrasiir
Posts: 8
Joined: Tue Aug 16, 2011 12:35 pm

Post by lifthrasiir »

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:

Code: Select all

$ grep -E '^.(.)(.)(.)...\1.\3.\2$' /usr/share/dict/words 
archimorphic
cryptography
fictionistic
interconnect
intervenient
manipulation
minimifidian
panification
sanification
semiquietism
tachygraphic
tangantangan
Among them only cryptography, manipulation, panification, sanification, tachygraphic are possible, and you know what is appropriate for this context.
Mad Mike
Posts: 11
Joined: Tue Jun 21, 2011 4:38 pm

Post by Mad Mike »

Using a website to assist me I scanned the text for a word with the length matching "solution".
That were enough known letters to find the rest.

And then guessing with the four remaining ones.
chown -R us ./base
Smee80
Posts: 2
Joined: Mon Oct 24, 2011 7:14 pm

Post by Smee80 »

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
Injust
Posts: 1
Joined: Tue Jun 26, 2012 9:29 pm

Post by Injust »

yourMom
Posts: 6
Joined: Sat Dec 18, 2010 9:58 pm
Location: Sofia

just another solution

Post by yourMom »

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:

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;
}
Limberneck
Posts: 3
Joined: Tue Jun 04, 2013 3:13 pm

Post by Limberneck »

I just figured the word "answer" would be there, so I looked for words that were 6 letters long, and there was only one, and from then on it's pretty straight forward.
User avatar
Grusewolf
Posts: 16
Joined: Sun May 29, 2011 7:58 pm
Location: Munich

this was a hard one

Post by Grusewolf »

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.

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]]?:'.'
}
polocatfan
Posts: 3
Joined: Wed Feb 04, 2015 2:06 am

Re: Substitute Teacher

Post by polocatfan »

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
I just looked for the word "answer"
Post Reply