Created
June 9, 2018 01:59
-
-
Save tecknoh19/47b3a457ab5323595edc0bf4e27c0d95 to your computer and use it in GitHub Desktop.
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> | |
//global variaes and magic numbers are the basis of good programming | |
const char* charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~@#$%^&*()-_=+|]}[{';:<,.>?"; | |
char buffer[50]; | |
void permute(int level) { | |
const char* charset_ptr = charset; | |
if(level == -1){ | |
puts(buffer); | |
}else { | |
while(buffer[level]=*charset_ptr++) { | |
permute(level - 1); | |
} | |
} | |
} | |
int main(int argc, char **argv) | |
{ | |
int length; | |
sscanf(argv[1], "%d", &length); | |
//Must provide length (integer < sizeof(buffer)==50) as first arg; | |
//It will crash and burn otherwise | |
buffer[length]='\0'; | |
permute(length - 1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment