diff --git a/src/euler54/src/main.rs b/src/euler54/src/main.rs index 2953938..1afdfe7 100644 --- a/src/euler54/src/main.rs +++ b/src/euler54/src/main.rs @@ -1,5 +1,4 @@ #![allow(dead_code, unused_imports)] - use std::{ cmp::max, collections::{HashMap, HashSet}, @@ -73,6 +72,22 @@ enum Value { Ace, } +const VALUES: [Value; 13] = [ + Value::Two, + Value::Three, + Value::Four, + Value::Five, + Value::Six, + Value::Seven, + Value::Eight, + Value::Nine, + Value::Ten, + Value::Jack, + Value::Queen, + Value::King, + Value::Ace, +]; + impl Value { fn from_char(c: char) -> Self { match c { @@ -185,7 +200,7 @@ impl CardTrait for Cards { } fn have_consecutive_values(&self) -> bool { - self[0].value + 1 + VALUES. } }