Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
Some of them are simply old puzzles revisited, like the paired paintings and the Dartboard.
gcc main.c; ./a.out
#include <stdio.h>
#include <string.h>
#define ANSW_LEN 12
#define TESTS_COUNT 4
const char alphabet[] = "BGYORP";
const int l_alpha = 6;
// count differing positions in two ANSW_LEN-long char arrays
int count_diffs_fast(const char *s1, const char *s2) {
int diff = 0;
for (int i = 0; i < ANSW_LEN; i++) {
if (s1 != s2) diff++;
}
return diff;
}
// return 1 iff each letter in `alphabet` appears exactly twice in s[0..ANSW_LEN-1]
int check_exactly_two(const char *s) {
int counts[l_alpha];
memset(counts, 0, sizeof counts);
for (int i = 0; i < ANSW_LEN; i++) {
for (int j = 0; j < l_alpha; j++) {
if (s == alphabet[j]) {
counts[j]++;
break;
}
}
}
for (int j = 0; j < l_alpha; j++) {
if (counts[j] != 2) return 0;
}
return 1;
}
// runs all checks on candidate ans[]
int passes(const char *ans, const char tests_answers[TESTS_COUNT][ANSW_LEN]) {
if (!check_exactly_two(ans)) return 0;
if (count_diffs_fast(ans, tests_answers[0]) != 2) return 0;
if (count_diffs_fast(ans, tests_answers[1]) != 3) return 0;
if (count_diffs_fast(ans, tests_answers[2]) != 2) return 0;
if (count_diffs_fast(ans, tests_answers[3]) != 10) return 0;
return 1;
}
int main(void) {
// test strings as plain char arrays
const char test_strs[TESTS_COUNT][ANSW_LEN] = {
"ORYBOYRGGPBP",
"ORYBGYRPGOYP",
"ORBBPYRRGOBP",
" RR R R R "
};
char ans[ANSW_LEN];
int digits[ANSW_LEN] = {0};
// initialize ans[] = all alphabet[0]
for (int i = 0; i < ANSW_LEN; i++) {
ans = alphabet[0];
}
// compute total combinations = 6^12
long long search_space = 1;
for (int i = 0; i < ANSW_LEN; i++) {
search_space *= l_alpha;
}
for (long long iter = 0; iter < search_space; iter++) {
if (passes(ans, test_strs)) {
printf("FOUND: ");
for (int k = 0; k < ANSW_LEN; k++) {
putchar(ans[k]);
}
putchar('\n');
break;
}
// increment base-6 counter in digits[], update ans[] lazily
for (int pos = ANSW_LEN - 1; pos >= 0; pos--) {
if (++digits[pos] < l_alpha) {
ans[pos] = alphabet[digits[pos]];
break;
}
// carry
digits[pos] = 0;
ans[pos] = alphabet[0];
}
}
return 0;
}[/spoiler]
~~ edit ~~
oh, and the order of the string it spits out is:
Pumpkin, Flyer Cart, Frag with peaks, Pond, Flag with hour glass, Bananas, Fire hydrant, Lizard, Broccoli, Flag with heart, Marker/tube/rocket thing, Grapes.