Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions strings/tfcctf2023-MAYDAY/solve-Ezraieel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Author: TheyCallMeEzraieel(Mohammad)
#include <iostream>
#include <string>
#include <sstream>
#include <map>

int main() {
std::string encoded = "Whiskey Hotel Four Tango Dash Alpha Romeo Three Dash Yankee Oscar Uniform Dash Sierra One November Kilo India November Golf Dash Four Bravo Zero Uniform Seven"; //Stores encoded message
std::string decoded; //The decoded message will store into this var
std::map<std::string, char> dict{{"One", '1'}, {"Two", '2'}, {"Three", '3'}, {"Four", '4'}, {"Five", '5'}, {"Six", '6'}, {"Seven", '7'}, {"Eight", '8'}, {"Nine", '9'}, {"Zero", '0'}, {"Dash", '-'}}; //A simple dictionary for numbers and dash character
std::istringstream ss(encoded); //Assign a stringstream of the encoded message
std::string word; //Stores each words with shift right operator
while(ss>>word){
if (dict.find(word) != dict.end()){ //If the word exist in dict
decoded += dict[word];
} else { //If not
decoded += word[0]; //Stores the first character of the word
}
}
std::cout<<decoded; //And prints the decoded message
}