Created
July 23, 2011 16:34
-
-
Save dtinth/1101614 to your computer and use it in GitHub Desktop.
HLP Hackathon: Final Round
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
hcf = (a, b, c, d) -> | |
return hcf hcf(a,b), hcf(c,d) if c? and d? | |
return hcf b, a if b > a | |
return hcf b, a % b if b > 0 | |
return a | |
data = [ | |
hcf 447369380069, 466032068393, 485107268193, 496917524923 | |
hcf 6519505243, 7386277141, 8580293573, 9418028861 | |
hcf 43537239727, 378745650149, 559929527, 111868166383 | |
hcf 31047749359, 115066113349, 1195514881, 65017327535897 | |
hcf 3352, 5028, 8380, 2808976 | |
hcf 4075797, 5366031, 5440611, 2300793 | |
] | |
console.log eval(data.join('^')).toString(2) |
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 <stdio.h> | |
struct x { | |
unsigned char r; | |
unsigned char g; | |
unsigned char b; | |
unsigned char a; | |
}; | |
int main() { | |
unsigned long pixel[4], opixel; | |
FILE *fp[4], *fp2; | |
fp[0] = fopen("input1.raw", "rb"); | |
fp[1] = fopen("input2.raw", "rb"); | |
fp[2] = fopen("input3.raw", "rb"); | |
fp[3] = fopen("input4.raw", "rb"); | |
fp2 = fopen("output.raw", "wb"); | |
while(!feof(fp[0])) { | |
fread(&pixel[0], sizeof(pixel[0]), 1, fp[0]); | |
fread(&pixel[1], sizeof(pixel[1]), 1, fp[1]); | |
fread(&pixel[2], sizeof(pixel[2]), 1, fp[2]); | |
fread(&pixel[3], sizeof(pixel[3]), 1, fp[3]); | |
if (pixel[0] == pixel[1] && pixel[1] == pixel[2] && pixel[2] == pixel[3]) { | |
opixel = 0xFFFFFFFF; | |
} else { | |
opixel = 0xFF0000FF; | |
puts("black"); | |
} | |
fwrite(&opixel, sizeof(opixel), 1, fp2); | |
} | |
printf("%d", sizeof(pixel[0])); | |
} |
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
long long int ways[17][17]; | |
int main() { | |
char *map = "1111111101111011111110111111111111111111111111111011111111110111111111011101010111111111111110010111110110111111111111111110101110111101111111100111111111111111111111011111111111111101111111011111110111111111111010011111111111011011011111011011011111111011110111111111111110111111111111101"; | |
int i, j; | |
for (i = 0; i < 17; i ++) { | |
for (j = 0; j < 17; j ++) { | |
if (*(map++) == '1') { | |
ways[i][j] = -1; | |
} else { | |
ways[i][j] = 0; | |
} | |
} | |
} | |
ways[16][16] = 1; | |
int dia, co, right, down; | |
for (dia = 0; dia < 17; dia ++) { | |
for (co = 0; co <= dia; co ++) { | |
i = 16 - co; | |
j = 16 - dia + co; | |
if (ways[i][j] == -1) { | |
right = j == 16 ? 0 : ways[i][j + 1]; | |
down = i == 16 ? 0 : ways[i + 1][j]; | |
ways[i][j] = right + down; | |
} | |
} | |
} | |
for (dia = 0; dia < 17; dia ++) { | |
for (co = 0; co <= (16 - dia); co ++) { | |
i = 16 - dia - co; | |
j = co; | |
printf("%d %d\n", i, j); | |
if (ways[i][j] == -1) { | |
right = j == 16 ? 0 : ways[i][j + 1]; | |
down = i == 16 ? 0 : ways[i + 1][j]; | |
ways[i][j] = right + down; | |
} | |
} | |
} | |
for (i = 0; i < 17; i ++) { | |
for (j = 0; j < 17; j ++) { | |
printf("%3lld ", ways[i][j]); | |
} | |
printf("\n"); | |
} | |
// answer is the number in the top left corner! | |
} |
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
<?php | |
$im = imagecreatefrompng('6.png'); | |
$stat = array(); | |
function trace($x, $y, $no, $clr, $uid) { | |
global $im, $data, $sx, $sy; | |
global $stat; | |
if (isset($data[$x . ':' . $y])) return; | |
$color = imagecolorsforindex($im, imagecolorat($im, $x, $y)); | |
if ($clr != $color) return; | |
$data[$x . ':' . $y] = $no; | |
if (!isset($stat[$uid])) $stat[$uid] = 0; | |
$stat[$uid] ++; | |
if ($x + 1 < $sx) trace($x + 1, $y, $no + 1, $clr, $uid); | |
if ($x - 1 >= 0) trace($x - 1, $y, $no + 1, $clr, $uid); | |
if ($y + 1 < $sy) trace($x, $y + 1, $no + 1, $clr, $uid); | |
if ($y - 1 >= 0) trace($x, $y - 1, $no + 1, $clr, $uid); | |
} | |
$sx = imagesx($im); | |
$sy = imagesy($im); | |
$data = array(); | |
for ($x = 0; $x < $sx; $x ++) { | |
for ($y = 0; $y < $sy; $y ++) { | |
trace($x, $y, 1, imagecolorsforindex($im, imagecolorat($im, $x, $y)), $y * $sx + $x); | |
} | |
} | |
$d = 0; | |
foreach ($stat as $v) { | |
if ($v >= 1) $d++; | |
} | |
echo "$d (" . sqrt($d) . ", " . base_convert((int)sqrt($d), 10, 2) . ")\n"; |
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
data = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_' | |
z = 9124569914 | |
while z > 0 | |
console.log data[z % data.length] | |
z = Math.floor z / data.length |
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
wtf = (eval "0x#{x}" for x in '4c 9a 59 3a 35 89 91 24 5a 9a 5d 3a 35 29 95 2b 53 8c 35 ba 94 ca d5 2d 4d ae 59 92 45 6a d1 21 4c 9a 59'.split(' ')) | |
x = "" | |
for c, i in wtf | |
for j in [0...i] | |
wtf[i] = (wtf[i] >> 1) + 128 * (wtf[i] % 2) | |
x += String.fromCharCode 25 - (wtf[i] - 65) + 65 | |
console.log x |
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
num = [7, 13, 41, 35, 36] | |
for A in num | |
for a in ['+', '*'] | |
for B in num | |
if B != A then for b in ['+', '-', '*'] | |
for C in num | |
if C != B and C != A then for c in ['+', '-', '*'] | |
for D in num | |
if D != C and D != B and D != A then for d in ['+', '-', '*'] | |
for E in num | |
if E != D and E != C and E != B and E != A | |
expr = A + a + B + b + C + c + D + d + E | |
if (eval expr) in num | |
console.log (eval expr).toString(2) |
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
Use GIMP! | |
http://imgur.com/DMCD1 |
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
Availability Table | |
No. EZ NM HD MX MB | |
1 7 13 | |
2 2 6 m1 | |
3 6 m1 | |
4 10 13 | |
5 8 m3 | |
6 8 m3 | |
7 7 | |
8 11 | |
9 3 | |
10 13 m3 | |
11 9 | |
12 11 m3 | |
13 10 13 | |
14 5 m2 | |
15 m1 | |
16 4 | |
17 9 | |
18 13 m3 | |
19 11 m3 | |
20 1 | |
21 12 m2 | |
22 12 m2 | |
23 12 m2 | |
24 13 m3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
เฮ้ยยยยยยยยยยยย
เฉลยข้อ 9!!!!!