Compare commits
No commits in common. '7c3e9def0070ed1b30b296301d9eb64018a83194' and '5c4a0134396597e9a3837fb1693d7219b109300a' have entirely different histories.
7c3e9def00
...
5c4a013439
@ -1,25 +0,0 @@
|
|||||||
1972667147 405592018
|
|
||||||
1450194064 27782252
|
|
||||||
348350443 61862174
|
|
||||||
3911195009 181169206
|
|
||||||
626861593 138786487
|
|
||||||
2886966111 275299008
|
|
||||||
825403564 478003391
|
|
||||||
514585599 6102091
|
|
||||||
2526020300 15491453
|
|
||||||
3211013652 546191739
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TO LOW:
|
|
||||||
6335758
|
|
||||||
|
|
||||||
|
|
||||||
New lowest location: 852082781 - from seed: 348350443 (VALID)
|
|
||||||
New lowest location: 624704155 - from seed: 368099087 (VALID)
|
|
||||||
New lowest location: 462405710 - from seed: 421798005 (INVALID!)
|
|
||||||
New lowest location: 123535056 - from seed: 1211303880 (VALID) -- INCORRECT
|
|
||||||
New lowest location: 122300259 - from seed: 1537339145 (INVALID!)
|
|
||||||
New lowest location: 102613526 - from seed: 2301593560 (VALID) -- ????
|
|
||||||
New lowest location: 44948412 - from seed: 2488220507 (INVALID!)
|
|
||||||
New lowest location: 6335758 - from seed: 2837209310 (INVALID!) -- INCORRECT
|
|
||||||
@ -1 +0,0 @@
|
|||||||
/target
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Debug executable 'day_1'",
|
|
||||||
"cargo": {
|
|
||||||
"args": [
|
|
||||||
"build",
|
|
||||||
"--bin=day_1",
|
|
||||||
"--package=day_1"
|
|
||||||
],
|
|
||||||
"filter": {
|
|
||||||
"name": "day_1",
|
|
||||||
"kind": "bin"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "lldb",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "Debug unit tests in executable 'day_1'",
|
|
||||||
"cargo": {
|
|
||||||
"args": [
|
|
||||||
"test",
|
|
||||||
"--no-run",
|
|
||||||
"--bin=day_1",
|
|
||||||
"--package=day_1"
|
|
||||||
],
|
|
||||||
"filter": {
|
|
||||||
"name": "day_1",
|
|
||||||
"kind": "bin"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
version = 3
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "day_6"
|
|
||||||
version = "0.1.0"
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "day_6"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
use std::{env, fs, path::Path};
|
|
||||||
|
|
||||||
fn main()
|
|
||||||
{
|
|
||||||
// let out_dir = env::var("OUT_DIR").unwrap();
|
|
||||||
// let cwd = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
||||||
// println!("CWD: {}\n", cwd);
|
|
||||||
// let data_dir = cwd + "\\data";
|
|
||||||
// let data_path = Path::new(&data_dir);
|
|
||||||
// println!("Data path: {}", data_path.to_string_lossy());
|
|
||||||
|
|
||||||
// let data_path = Path::new("data/test_input");
|
|
||||||
|
|
||||||
let out_path = format!("target/{}", &env::var("PROFILE").unwrap());
|
|
||||||
let out_path = Path::new(&out_path);
|
|
||||||
//let out_path = Path::new(&out_dir).join(&env::var("PROFILE").unwrap());
|
|
||||||
let out_path_data = out_path.join(Path::new("data"));
|
|
||||||
|
|
||||||
if !out_path_data.exists()
|
|
||||||
{
|
|
||||||
fs::create_dir(&out_path_data).expect(&format!("Could not create data directory at: {}", out_path_data.to_string_lossy()));
|
|
||||||
}
|
|
||||||
|
|
||||||
for file in fs::read_dir("data").unwrap()
|
|
||||||
{
|
|
||||||
let file = file.unwrap();
|
|
||||||
let dest = out_path.join(file.path());
|
|
||||||
fs::copy(file.path(), &dest).expect(&format!("Could not copy file {} to {}", file.path().to_string_lossy(), dest.to_string_lossy()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
Time: 47 84 74 67
|
|
||||||
Distance: 207 1394 1209 1014
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
Time: 7 15 30
|
|
||||||
Distance: 9 40 200
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
use std::{io::prelude::*, fs::File, path::Path, io };
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
struct Race
|
|
||||||
{
|
|
||||||
time: i32,
|
|
||||||
record_dist: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main()
|
|
||||||
{
|
|
||||||
let input = load_data("data/test_input");
|
|
||||||
|
|
||||||
let races = parse_input(&input);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
// LOAD AND PARSE INPUT
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
fn parse_input(input: &str) -> Vec<Race>
|
|
||||||
{
|
|
||||||
|
|
||||||
let mut times: Vec<i32> = Vec::new();
|
|
||||||
let mut record_dists: Vec<i32> = Vec::new();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vec::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load_data(file_name: &str) -> String
|
|
||||||
{
|
|
||||||
let mut file = match File::open(Path::new(file_name))
|
|
||||||
{
|
|
||||||
Ok(file) => file,
|
|
||||||
Err(why) => panic!("Could not open file {}: {}", Path::new(file_name).display(), why),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut s = String::new();
|
|
||||||
let file_contents = match file.read_to_string(&mut s)
|
|
||||||
{
|
|
||||||
Err(why) => panic!("couldn't read {}: {}", Path::new(file_name).display(), why),
|
|
||||||
Ok(_) => s,
|
|
||||||
};
|
|
||||||
|
|
||||||
return normalize_line_endings(&file_contents);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn normalize_line_endings(data: &str) -> String
|
|
||||||
{
|
|
||||||
let mut data: Vec<u8> = data.as_bytes().into();
|
|
||||||
|
|
||||||
let mut idx = 0;
|
|
||||||
while idx < data.len()
|
|
||||||
{
|
|
||||||
if data[idx as usize] == b'\r'
|
|
||||||
{
|
|
||||||
data.remove(idx as usize);
|
|
||||||
idx -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
idx += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
String::from_utf8(data).expect("normalize_line_endings - FAILED: string was not valid utf_8")
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue