-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d3d015
commit 5bcaebf
Showing
19 changed files
with
152 additions
and
26 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Licensed under the MIT License. | ||
|
||
*.sh text eol=lf |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Licensed under the MIT License. | ||
|
||
a.out | ||
*.exe | ||
*.o | ||
|
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Licensed under the MIT License. | ||
|
||
# Maximum Path Sum II | ||
|
||
./../id0018.o 67 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed under the MIT License. | ||
|
||
// Magic 5-gon Ring | ||
|
||
#include <math.h> | ||
#include "../lib/euler.h" | ||
#include "../lib/permutation_iterator.h" | ||
|
||
int main(void) | ||
{ | ||
long long max = 0; | ||
long long r[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; | ||
struct List l; | ||
struct PermutationIterator it; | ||
clock_t start = clock(); | ||
|
||
list_from_array(&l, r, 10); | ||
|
||
for (permutation_begin(&it, &l); !it.end; permutation_next(&it)) | ||
{ | ||
if (r[0] > r[3] || r[0] > r[5] || r[0] > r[7] || r[0] > r[9] || | ||
(r[3] != 10 && r[5] != 10 && r[7] != 10 && r[9] != 10)) | ||
{ | ||
continue; | ||
} | ||
|
||
int sum = r[0] + r[1] + r[2]; | ||
|
||
if (r[2] + r[3] + r[4] != sum || r[4] + r[5] + r[6] != sum || | ||
r[6] + r[7] + r[8] != sum || r[8] + r[9] + r[1] != sum) | ||
{ | ||
continue; | ||
} | ||
|
||
long long value = math_concat(r[0], r[1]); | ||
|
||
value = math_concat(value, r[2]); | ||
|
||
value = math_concat(value, r[3]); | ||
value = math_concat(value, r[2]); | ||
value = math_concat(value, r[4]); | ||
|
||
value = math_concat(value, r[5]); | ||
value = math_concat(value, r[4]); | ||
value = math_concat(value, r[6]); | ||
|
||
value = math_concat(value, r[7]); | ||
value = math_concat(value, r[6]); | ||
value = math_concat(value, r[8]); | ||
|
||
value = math_concat(value, r[9]); | ||
value = math_concat(value, r[8]); | ||
value = math_concat(value, r[1]); | ||
|
||
if (value > max) | ||
{ | ||
max = value; | ||
} | ||
} | ||
|
||
return euler_submit(68, max, start); | ||
} |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Licensed under the MIT License. | ||
|
||
# Magic 5-gon Ring | ||
|
||
from itertools import permutations | ||
from time import time | ||
|
||
maxString = "" | ||
start = time() | ||
|
||
for l in permutations([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]): | ||
if l[0] > l[3] or l[0] > l[5] or l[0] > l[7] or l[0] > l[9]: continue | ||
if l[3] != 10 and l[5] != 10 and l[7] != 10 and l[9] != 10: continue | ||
|
||
sum = l[0] + l[1] + l[2] | ||
|
||
if l[2] + l[3] + l[4] != sum or l[4] + l[5] + l[6] != sum: continue | ||
if l[6] + l[7] + l[8] != sum or l[8] + l[9] + l[1] != sum: continue | ||
|
||
string = "".join(map(str, [ | ||
l[0], l[1], l[2], | ||
l[3], l[2], l[4], | ||
l[5], l[4], l[6], | ||
l[7], l[6], l[8], | ||
l[9], l[8], l[1] | ||
])) | ||
|
||
if string > maxString: | ||
maxString = string | ||
|
||
print(f"0068{maxString:>64} {time() - start:.6f}") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,5 +55,3 @@ for i in {0060..0066}; | |
do | ||
./../id${i}.o | ||
done | ||
|
||
cat ./../data/id0067.txt | ./../id0018.o 67 |
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
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