summaryrefslogtreecommitdiffstats
path: root/2015/rs
diff options
context:
space:
mode:
Diffstat (limited to '2015/rs')
-rw-r--r--2015/rs/code/eight/src/main.rs6
-rw-r--r--2015/rs/code/four/src/main.rs12
-rw-r--r--2015/rs/code/nine/src/main.rs3
3 files changed, 10 insertions, 11 deletions
diff --git a/2015/rs/code/eight/src/main.rs b/2015/rs/code/eight/src/main.rs
index b51f436..6917a54 100644
--- a/2015/rs/code/eight/src/main.rs
+++ b/2015/rs/code/eight/src/main.rs
@@ -5,7 +5,7 @@ enum ParseState {
Verbatim,
Esc,
Hex1,
- Hex2(u32)
+ Hex2
}
fn main() {
@@ -25,8 +25,8 @@ fn main() {
(ParseState::Esc, 'x') => { state = ParseState::Hex1; },
(ParseState::Esc, c) => { buf.push(c); state = ParseState::Verbatim; },
- (ParseState::Hex1, c) => { state = ParseState::Hex2(c.to_digit(16).unwrap() * 16); },
- (ParseState::Hex2(n), c) => { buf.push(/*char::from_u32(n + c.to_digit(16).unwrap()).unwrap()*/'?'); state = ParseState::Verbatim; },
+ (ParseState::Hex1, _) => { state = ParseState::Hex2; },
+ (ParseState::Hex2, _) => { buf.push('?'); state = ParseState::Verbatim; },
}
}
(s, buf)
diff --git a/2015/rs/code/four/src/main.rs b/2015/rs/code/four/src/main.rs
index 177ddc5..0888816 100644
--- a/2015/rs/code/four/src/main.rs
+++ b/2015/rs/code/four/src/main.rs
@@ -9,16 +9,16 @@ fn main() {
buf.extend_from_slice(INPUT);
for i in 0.. {
- if i % 1000 == 0 { print!("{i}\r"); std::io::stdout().flush(); }
+ if i % 1000 == 0 { print!("{i}\r"); let _ = std::io::stdout().flush(); }
let mut hasher = Md5::new();
- write!(&mut buf, "{i}");
+ let _ = write!(&mut buf, "{i}");
hasher.update(buf.as_slice());
let hash = hasher.finalize();
if hash.starts_with(&[0, 0]) && hash[2] < 16 {
let mut hexhash = String::with_capacity(32);
for digit in hash {
- write!(&mut hexhash, "{digit:02x}");
+ let _ = write!(&mut hexhash, "{digit:02x}");
}
println!("Got 5 digit hash: {hexhash}, at {i}");
break;
@@ -27,16 +27,16 @@ fn main() {
}
for i in 0.. {
- if i % 1000 == 0 { print!("{i}\r"); std::io::stdout().flush(); }
+ if i % 1000 == 0 { print!("{i}\r"); let _ = std::io::stdout().flush(); }
let mut hasher = Md5::new();
- write!(&mut buf, "{i}");
+ let _ = write!(&mut buf, "{i}");
hasher.update(buf.as_slice());
let hash = hasher.finalize();
if hash.starts_with(&[0, 0, 0]) {
let mut hexhash = String::with_capacity(32);
for digit in hash {
- write!(&mut hexhash, "{digit:02x}");
+ let _ = write!(&mut hexhash, "{digit:02x}");
}
println!("Got 6 digit hash: {hexhash}, at {i}");
break;
diff --git a/2015/rs/code/nine/src/main.rs b/2015/rs/code/nine/src/main.rs
index 46116e0..408b66a 100644
--- a/2015/rs/code/nine/src/main.rs
+++ b/2015/rs/code/nine/src/main.rs
@@ -1,7 +1,6 @@
#![feature(iter_next_chunk)]
-use std::collections::{HashSet, HashMap};
-use std::io::Write;
+use std::collections::HashMap;
static INPUT: &'static str = include_str!("input.txt");