-
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
e3511e9
commit 650e185
Showing
10 changed files
with
94 additions
and
31 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
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,20 @@ | ||
Rust Implementation of Problem 59 | ||
================================= | ||
|
||
View source code :source:`rust/src/p0059.rs` | ||
|
||
Includes | ||
-------- | ||
|
||
- `utils <./lib/utils.html>`_ | ||
|
||
Problem Solution | ||
---------------- | ||
|
||
.. rust:fn:: pub fn p0059::p0059() -> utils::Answer | ||
.. literalinclude:: ../../../rust/src/p0059.rs | ||
:language: rust | ||
:linenos: | ||
|
||
.. tags:: cryptography, binary-operator, xor, file-io |
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,21 @@ | ||
Rust Implementation of Problem 67 | ||
================================= | ||
|
||
View source code :source:`rust/src/p0067.rs` | ||
|
||
Includes | ||
-------- | ||
|
||
- `triangles <./lib/triangles.html>`_ | ||
- `utils <./lib/utils.html>`_ | ||
|
||
Problem Solution | ||
---------------- | ||
|
||
.. rust:fn:: pub fn p0067::p0067() -> utils::Answer | ||
.. literalinclude:: ../../../rust/src/p0067.rs | ||
:language: rust | ||
:linenos: | ||
|
||
.. tags:: combinatorics, path-finding, file-io |
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,35 @@ | ||
/* | ||
Project Euler Problem 67 | ||
Thinking from the bottom up got the answer | ||
Problem: | ||
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top | ||
to bottom is 23. | ||
3 | ||
7 4 | ||
2 4 6 | ||
8 5 9 3 | ||
That is, 3 + 7 + 4 + 9 = 23. | ||
Find the maximum total from top to bottom in triangle.txt (right click and 'Save Link/Target As...'), a 15K text file | ||
containing a triangle with one-hundred rows. | ||
NOTE: This is a much more difficult version of Problem 18. It is not possible to try every route to solve this problem, | ||
as there are 2^99 altogether! If you could check one trillion (10^12) routes every second it would take over twenty | ||
billion years to check them all. There is an efficient algorithm to solve it. ;o) | ||
*/ | ||
use crate::include::triangles::reduce_triangle; | ||
use crate::include::utils::{get_data_file,Answer}; | ||
|
||
|
||
pub fn p0018() -> Answer { | ||
let rows: Vec<Vec<u8>> = vec![]; | ||
for line in get_data_file("p0067_triangle.txt").trim().lines() { | ||
rows.push(line.split(' ').map(|x| x.parse::<u8>()).collect::<Vec<u8>>()); | ||
} | ||
return Answer::Int(reduce_triangle(rows).into()); | ||
} |