From 1dbc0052ca3d79533842d26474d3ab6ead91dce3 Mon Sep 17 00:00:00 2001 From: "Dr. Matthias Ratajczak" Date: Wed, 17 Aug 2022 21:09:35 +0200 Subject: [PATCH] add more code for 54 (WIP) --- src/euler54/src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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. } }