Last active
August 29, 2015 14:05
-
-
Save aycabta/0796b4b7462b825bc367 to your computer and use it in GitHub Desktop.
Simple Hydra
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
dim A(∞) | |
B=9 | |
for C=0 to 9 | |
for D=0 to B | |
A(D)=D | |
next | |
for E=B to 0 step -1 | |
B=B*B | |
for F=0 to E | |
if A(E-F)<A(E) or A(E)=0 then | |
G=F | |
F=E | |
end if | |
next | |
for H=1 to B*G | |
A(E)=A(E-G) | |
E=E+1 | |
next | |
next | |
next | |
print B |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <limits.h> | |
void realloc_int(int **p, size_t *p_size, size_t new_size) { | |
int *new_p; | |
if (new_size >= *p_size) { | |
new_p = realloc(*p, sizeof(int) * (*p_size) * 2); | |
if (new_p == NULL) { | |
printf("Reallocation failed\n"); | |
exit(-1); | |
} | |
*p = new_p; | |
*p_size = (*p_size) * 2; | |
} | |
} | |
int main(void) { | |
int *a; | |
size_t a_size = 2; | |
a = malloc(sizeof(int) * a_size); | |
if (a == NULL) { | |
printf("Allocation failed\n"); | |
exit(-1); | |
} | |
int b = 9; | |
int c; | |
for (c = 0; c <= 9; c++) { | |
int d; | |
for (d = 0; d <= b; d++) { | |
realloc_int(&a, &a_size, d); | |
a[d] = d; | |
} | |
int e; | |
for (e = b; e >= 0; e--) { | |
b = b * b; | |
int g; | |
int f; | |
for (f = 0; f <= e; f++) { | |
if (a[e-f] < a[e] || a[e] == 0) { | |
g = f; | |
f = e; | |
} | |
} | |
int h; | |
for (h = 1; h <= b * g; h++) { | |
realloc_int(&a, &a_size, e); | |
a[e] = a[e-g]; | |
e++; | |
} | |
} | |
} | |
printf("%d\n", b); | |
return 0; | |
} | |
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
a = [] | |
b = 9 | |
c = 0 | |
while c <= 9 | |
c += 1 | |
d = 0 | |
while d < b | |
d += 1 | |
a[d] = d | |
end | |
e = b | |
while e >= 0 | |
e -= 1 | |
b = b * b | |
g = nil | |
f = 0 | |
while f <= e | |
f += 1 | |
if a[e-f] < a[e] or a[e] == 0 | |
g = f | |
f = e | |
end | |
end | |
h = 1 | |
while h <= b * g | |
h += 1 | |
a[e] = a[e-g] | |
e += 1 | |
end | |
end | |
end | |
puts b |
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 <stdlib.h> | |
int main(void) { | |
int *a = malloc(9), b = 9, c, d, e, g, f; | |
for (c = 0; c <= 9; c++) { | |
for (d = 0; d <= b; d++) a[d] = d; | |
for (e = b; e--;) { | |
b = b * b; | |
for (f = 0; f <= e; f++) if (a[e-f] < a[e] || !a[e]) g = f, f = e; | |
a = realloc(a, e+b*g); | |
for (d = b * g; --d;) a[e] = a[e-g], e++; | |
} | |
} | |
return b; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment