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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char* argv[]) { | |
int layers = 16; // Default value | |
if (argc > 1) { // Optional layers input | |
layers = atoi(argv[1]); | |
if (layers < 1) { |
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
################################################### | |
## DECODE CAESAR CIPHER USING CHI-SQUARED VALUES ## | |
## COPYRIGHT (C) 2018 HENRY FRANKS ## | |
################################################### | |
phrase = "AOLJHLZHYJPWOLYPZVULZMAOLLHYSPLZARUVDUHUKZPTWSLZAJPWOLYZPAPZHAFWLVMZBIZAPABAPVUJPWOLYPUDOPJOLHJOSLAALYPUAOLWSHPUALEAPZZOPMALKHJLYAHPUUBTILYVMWSHJLZKVDUAOLHSWOHILA" # Phrase to decode | |
expected = [13.2345, 2.4138, 4.5036, 6.885, 19.602, 3.6126, 3.2724, 9.8658, 11.2914, 0.243, 1.2474, 6.5286, 3.9042, 10.935, 12.1662, 3.1226, 0.162, 9.7038, 10.2546, 14.6772, 4.4712, 1.5876, 3.8232, 0.243, 3.1914, 0.1134] # Expected frequencies for 162 letters | |
observed = [18, 3, 0, 3, 1, 1, 0, 12, 3, 8, 3, 22, 4, 0, 12, 17, 0, 1, 6, 2, 11, 7, 8, 0, 8, 12] # Observed letter frequencies |
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
box_width=$(tput cols) | |
function create_line() { | |
input_width=$(($(echo "$*" | wc -c) - 1)) | |
if [ $# -lt 1 ]; then | |
input_width=0 | |
fi | |
half_width=$(($(($box_width - $input_width)) / 2)) | |
for i in `seq 1 $half_width`; do | |
echo -n '-' |