-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit from when i was 12 :)
- Loading branch information
0 parents
commit 38319bc
Showing
19 changed files
with
788 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
*.sln merge=union | ||
*.csproj merge=union | ||
*.vbproj merge=union | ||
*.fsproj merge=union | ||
*.dbproj merge=union | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
################# | ||
## Eclipse | ||
################# | ||
|
||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath | ||
|
||
|
||
################# | ||
## Visual Studio | ||
################# | ||
|
||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Rr]elease/ | ||
*_i.c | ||
*_p.c | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.vspscc | ||
.builds | ||
*.dotCover | ||
|
||
## TODO: If you have NuGet Package Restore enabled, uncomment this | ||
#packages/ | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper* | ||
|
||
# Installshield output folder | ||
[Ee]xpress | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish | ||
|
||
# Others | ||
[Bb]in | ||
[Oo]bj | ||
sql | ||
TestResults | ||
*.Cache | ||
ClientBin | ||
stylecop.* | ||
~$* | ||
*.dbmdl | ||
Generated_Code #added for RIA/Silverlight projects | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
|
||
|
||
|
||
############ | ||
## Windows | ||
############ | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
|
||
############# | ||
## Python | ||
############# | ||
|
||
*.py[co] | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
|
||
#Translations | ||
*.mo | ||
|
||
#Mr Developer | ||
.mr.developer.cfg | ||
|
||
# Mac crap | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Codebreaker", "Codebreaker\Codebreaker.vcxproj", "{78AC1119-2530-420D-9D6F-DADBCD206585}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{78AC1119-2530-420D-9D6F-DADBCD206585}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{78AC1119-2530-420D-9D6F-DADBCD206585}.Debug|Win32.Build.0 = Debug|Win32 | ||
{78AC1119-2530-420D-9D6F-DADBCD206585}.Release|Win32.ActiveCfg = Release|Win32 | ||
{78AC1119-2530-420D-9D6F-DADBCD206585}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Codebreaker.cpp : Defines the entry point for the console application. | ||
// | ||
|
||
#include "stdafx.h" | ||
#include "Freq.h" | ||
#include "Grader.h" | ||
#include "Guess.h" | ||
|
||
std::list<CFreq::freq_pair> decoder (istream *stm, int char_to_try,char *letters); | ||
std::list<CFreq::freq_pair> decoder (list<string> cypher, int char_to_try, char* letters); | ||
|
||
string one_letter_words[] = { "a", "i" }; | ||
string common_two_letter_words[] = { "of", "to", "in", "it", "is", "he", "by", "or", "as", "at", "an", "so" }; | ||
string common_three_letter_words[] = { "the", "and", "for", "are", "but", "all", "not" }; | ||
string common_four_letter_words[] = { "that", "with", "from", "have", "this", "they" }; | ||
|
||
int _tmain(int argc, _TCHAR* argv[]) | ||
{ | ||
static char rantop8[] = {'t','a','e','i','n','o','s','r'}; | ||
static char common_letters[] = { 'e', 't', 'a', 'o', 'n', 'i', 's', 'r', 'h', 'l', 'd', 'c', 'u', 'p', 'f', 'm', 'w', 'y', 'b', 'g', 'v', 'k', 'q', 'x', 'j', 'z' }; | ||
std::list<CFreq::freq_pair> modelist; | ||
istream *stm; | ||
list<CFreq::freq_pair>::iterator it; | ||
string filename; | ||
|
||
if (argc <= 1) | ||
{ | ||
cout<< "Please type in cyphertext\n\n"; | ||
stm = &cin; | ||
} | ||
else | ||
{ | ||
filename = argv[1]; | ||
stm = new fstream (filename, ios::in); | ||
} | ||
|
||
// Try our first guess using the most common letters in English | ||
modelist = decoder(stm,8, common_letters); | ||
cout << modelist << endl; | ||
|
||
modelist = decoder(stm,8, rantop8); | ||
cout << modelist << endl; | ||
return 0; | ||
} | ||
|
||
std::list<CFreq::freq_pair> decoder (istream *stm, int char_to_try, char* letters) | ||
{ | ||
std::list<CFreq::freq_pair> modelist; | ||
string word; | ||
list<string> cypher; | ||
do | ||
{ | ||
*stm >> word; | ||
cypher.push_back (word); | ||
} | ||
while ( stm->eof() != 1); | ||
modelist = decoder (cypher, char_to_try, letters); | ||
return modelist; | ||
|
||
} | ||
std::list<CFreq::freq_pair> decoder (list<string> cypher, int char_to_try, char* letters) | ||
{ | ||
std::list<CFreq::freq_pair> modelist; | ||
|
||
// Starting to add an if statement to check if the cyper list is empty. Got interrupted | ||
if (*cypher != >1 | ||
modelist = CFreq::compute_freq (cypher); | ||
std::list<CFreq::freq_pair>::iterator mlit = modelist.begin (); | ||
list<CGuess> guess; | ||
|
||
CFreq::freq_pair cur_freq_letter = (*mlit); | ||
mlit++; | ||
|
||
for( list<string>::iterator it = cypher.begin(); it != cypher.end(); it++ ) | ||
{ | ||
string word = (*it); | ||
|
||
string first_guess = CGuess::substitute( word, cur_freq_letter.first, letters[0] ); | ||
guess.push_back( CGuess( word, first_guess )); | ||
} | ||
|
||
|
||
for (int i = 1; i < char_to_try; i++) | ||
{ | ||
cur_freq_letter = *mlit; // first time through loop, copy 2nd modelist item and | ||
mlit++; // point to 3rd | ||
|
||
|
||
for( list<CGuess>::iterator it = guess.begin(); it != guess.end(); it++ ) | ||
{ | ||
it->substitute (cur_freq_letter.first ,letters [i]); | ||
|
||
} | ||
} | ||
|
||
cout << guess << endl; | ||
|
||
return modelist; | ||
} |
Oops, something went wrong.