Skip to content

Commit

Permalink
Moved resources into indicative subdirectories. (#146)
Browse files Browse the repository at this point in the history
* Moved resources into indicative subdirectories.
* Fixed references to resources in solutions.
* Fixed references to resources in tests.
  • Loading branch information
tfpf authored Mar 21, 2024
1 parent 1444db2 commit 8ac6051
Show file tree
Hide file tree
Showing 25 changed files with 15 additions and 15 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/solutions/coded_triangle_numbers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::utils;

pub fn solve() -> i64 {
let words = std::fs::read_to_string("res/coded_triangle_numbers.txt").unwrap();
let words = std::fs::read_to_string("res/solutions/coded_triangle_numbers.txt").unwrap();
let result = words
.split(',')
.filter_map(|s| {
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/largest_exponential.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::BufRead;

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/largest_exponential.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/largest_exponential.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let result = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/largest_product_in_a_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn find_largest(
}

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/largest_product_in_a_grid.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/largest_product_in_a_grid.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let grid: Vec<Vec<i32>> = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/maximum_path_sum_i.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::BufRead;

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/maximum_path_sum_i.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/maximum_path_sum_i.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let mut triangle: Vec<Vec<i32>> = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/maximum_path_sum_ii.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::BufRead;

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/maximum_path_sum_ii.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/maximum_path_sum_ii.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let mut triangle: Vec<Vec<i32>> = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/names_scores.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub fn solve() -> i64 {
let names = std::fs::read_to_string("res/names_scores.txt").unwrap();
let names = std::fs::read_to_string("res/solutions/names_scores.txt").unwrap();
let mut names: Vec<&str> = names.split(',').map(|s| &s[1..s.len() - 1]).collect();
names.sort();
let result: usize = names
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/path_sum_two_ways.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::BufRead;

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/path_sum_two_ways.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/path_sum_two_ways.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let mut matrix: Vec<Vec<i32>> = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/poker_hands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::utils;
use std::io::BufRead;

pub fn solve() -> i64 {
let fhandle = std::fs::File::open("res/poker_hands.txt").unwrap();
let fhandle = std::fs::File::open("res/solutions/poker_hands.txt").unwrap();
let reader = std::io::BufReader::new(fhandle);
let result = reader
.lines()
Expand Down
2 changes: 1 addition & 1 deletion src/solutions/xor_decryption.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub fn solve() -> i64 {
let cipher_bytes = std::fs::read_to_string("res/xor_decryption.txt")
let cipher_bytes = std::fs::read_to_string("res/solutions/xor_decryption.txt")
.unwrap()
.split(',')
.map(|s| s.parse().unwrap())
Expand Down
12 changes: 6 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ mod tests {

#[test]
fn is_prime_large_test() {
for line in lines("res/is_prime_large_test.txt") {
for line in lines("res/tests/is_prime_large_test.txt") {
let mut num_primality = line.split_ascii_whitespace();
let num = num_primality.next().unwrap().parse().unwrap();
let primality = num_primality.next().unwrap().parse().unwrap();
Expand All @@ -1322,7 +1322,7 @@ mod tests {

#[test]
fn gcd_test() {
for line in lines("res/gcd_test.txt") {
for line in lines("res/tests/gcd_test.txt") {
let [a, b, g]: [i64; 3] = line
.split_ascii_whitespace()
.map(|s| s.parse().unwrap())
Expand All @@ -1345,7 +1345,7 @@ mod tests {

#[test]
fn long_arithmetic_test() {
for line in lines("res/long_arithmetic_test.txt") {
for line in lines("res/tests/long_arithmetic_test.txt") {
let mut expression = line.split_ascii_whitespace();

// The first operation is always exponentiation. Hard-code it.
Expand Down Expand Up @@ -1374,7 +1374,7 @@ mod tests {

#[test]
fn long_factorial_test() {
for line in lines("res/long_factorial_test.txt") {
for line in lines("res/tests/long_factorial_test.txt") {
let mut num_factorial = line.split_ascii_whitespace();
let num = num_factorial.next().unwrap().parse().unwrap();
let factorial = utils::Long::new(num_factorial.next().unwrap());
Expand All @@ -1384,7 +1384,7 @@ mod tests {

#[test]
fn long_multiplication_test() {
for line in lines("res/long_multiplication_test.txt") {
for line in lines("res/tests/long_multiplication_test.txt") {
let mut mmp = line.split_ascii_whitespace();
let multiplicand = utils::Long::new(mmp.next().unwrap());
let multiplier = mmp.next().unwrap().parse::<u32>().unwrap();
Expand Down Expand Up @@ -1415,7 +1415,7 @@ mod tests {

#[test]
fn continued_fraction_test() {
for line in lines("res/continued_fraction_test.txt") {
for line in lines("res/tests/continued_fraction_test.txt") {
let mut num_terms = line.split_ascii_whitespace();
let num = num_terms.next().unwrap().parse().unwrap();
let terms = num_terms.next().unwrap().split(',').map(|s| s.parse().unwrap());
Expand Down

0 comments on commit 8ac6051

Please sign in to comment.