Created
September 16, 2016 21:45
-
-
Save huntwelch/23d3e3111573b41510ff3385578a0494 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <iostream> | |
| #include <fstream> | |
| #include <stdio.h> | |
| char first( std::string word ) | |
| { | |
| return word[0]; | |
| } | |
| std::string rest( std::string word ) | |
| { | |
| return word.substr(1, word.length()-1); | |
| } | |
| int main ( int argc, char *argv[] ) | |
| { | |
| std::string word = argv[1]; | |
| char letter = first(word); | |
| std::string follow = rest(word); | |
| std::ifstream file("/usr/share/dict/words"); | |
| if( !file.is_open() ) return 0; | |
| std::string arry[235885]; | |
| for( int i=0; i<235885; ++i ) { | |
| file >> arry[i]; | |
| } | |
| std::string checkword; | |
| std::string spoon_1; | |
| std::string spoon_2; | |
| char fetter; | |
| std::string lollow; | |
| bool exists; | |
| for( int i=0; i<235885; ++i ) { | |
| checkword = arry[i]; | |
| if( checkword.length() == 1 ) continue; | |
| fetter = first(checkword); | |
| if( fetter == letter ) continue; | |
| if( isupper(fetter) ) continue; | |
| lollow = rest(checkword); | |
| spoon_1 = fetter + follow; | |
| spoon_2 = letter + lollow; | |
| exists = std::find(std::begin(arry), std::end(arry), spoon_1) != std::end(arry); | |
| if( !exists ) continue; | |
| exists = std::find(std::begin(arry), std::end(arry), spoon_2) != std::end(arry); | |
| if( !exists ) continue; | |
| std::cout << spoon_1 << ' ' << spoon_2 + '\n'; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment