Compare commits
2 commits
d54bddde27
...
ebc5fe5425
Author | SHA1 | Date | |
---|---|---|---|
Antoine Martin | ebc5fe5425 | ||
Antoine Martin | e8a36de2b4 |
|
@ -71,8 +71,6 @@ impl CupCircle {
|
||||||
// keep subtracting one until it finds a cup that wasn't just picked up. If at any point in
|
// keep subtracting one until it finds a cup that wasn't just picked up. If at any point in
|
||||||
// this process the value goes below the lowest value on any cup's label, it wraps around to
|
// this process the value goes below the lowest value on any cup's label, it wraps around to
|
||||||
// the highest value on any cup's label instead.
|
// the highest value on any cup's label instead.
|
||||||
//
|
|
||||||
// TODO: use std::cmp::Ord::clamp when stabilized (Rust 1.50)
|
|
||||||
let mut destination = if current > 1 { current - 1 } else { self.max() };
|
let mut destination = if current > 1 { current - 1 } else { self.max() };
|
||||||
while removed_cups.contains(&destination) {
|
while removed_cups.contains(&destination) {
|
||||||
destination = if destination > 1 {
|
destination = if destination > 1 {
|
||||||
|
@ -193,8 +191,6 @@ impl FastCupCircle {
|
||||||
// keep subtracting one until it finds a cup that wasn't just picked up. If at any point in
|
// keep subtracting one until it finds a cup that wasn't just picked up. If at any point in
|
||||||
// this process the value goes below the lowest value on any cup's label, it wraps around to
|
// this process the value goes below the lowest value on any cup's label, it wraps around to
|
||||||
// the highest value on any cup's label instead.
|
// the highest value on any cup's label instead.
|
||||||
//
|
|
||||||
// TODO: use std::cmp::Ord::clamp when stabilized (Rust 1.50)
|
|
||||||
let mut destination = if self.current > 1 {
|
let mut destination = if self.current > 1 {
|
||||||
self.current - 1
|
self.current - 1
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -69,10 +69,7 @@ impl std::str::FromStr for Command {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
let mut split = s.split(' ');
|
let (word, number) = s.split_once(' ').context("couldn't split command")?;
|
||||||
|
|
||||||
let word = split.next().context("couldn't find word in command")?;
|
|
||||||
let number = split.next().context("couldn't find number in command")?;
|
|
||||||
|
|
||||||
let number = number.parse()?;
|
let number = number.parse()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue