Created
July 14, 2013 16:13
-
-
Save AlbertVeli/5994777 to your computer and use it in GitHub Desktop.
Solver for puzzle found in showcase at Tekniska Museet.
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
/* https://twitter.com/albertveli/status/356432567106408449/photo/1 */ | |
#include <stdio.h> | |
void print_rot(char *str, int rot) | |
{ | |
char c; | |
while (*str) { | |
c = *str; | |
if (c >= 'A' && c <= 'Z') { | |
/* Rotate A-Z */ | |
printf("%c", ((c - 'A' + rot) % 26) + 'A'); | |
} else { | |
/* Output the rest without modification */ | |
printf("%c", c); | |
} | |
str++; | |
} | |
printf("\n"); | |
} | |
int main(void) | |
{ | |
char *str = "\"NYY TYäQWR HGNA RTRA Eå FRANCFFVYY V EBGZBF äE RAQNFG XBAFGYNQ TYäQWR\". FNQRF NI ERNYVFGRA GBEFGRA NEAR RUERAZNEX V NAQREFGBECRG. PVGNGRG XBZ GERINAQR SEåA RYVN V AVNA."; | |
int i; | |
/* Output all combinations, only 26 so the correct one is easy to spot. */ | |
for (i = 0; i < 26; i++) { | |
print_rot(str, i); | |
} | |
return 0; | |
} | |
/** | |
* Local Variables: | |
* mode: c | |
* indent-tabs-mode: nil | |
* c-basic-offset: 3 | |
* End: | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment