pub fn place_marble(&mut self, number: usize) -> usize {
        if number % 23 == 0 {
            let mut removed_marble = self
                .marbles
                .left_of(self.current_marble)
                .expect("Marble 1 place to left does not exist");
            for n in 2..=7 {
                removed_marble = self
                    .marbles
                    .left_of(removed_marble)
                    .unwrap_or_else(|| panic!("Marble {} places to left does not exist", n));
            }

            self.current_marble = self
                .marbles
                .right_of(removed_marble)
                .expect("Next current marble does not exist");
            self.marbles.remove(removed_marble);

            number + removed_marble
        } else {
            let marble_to_right = self
                .marbles
                .right_of(self.current_marble)
                .expect("Marble to right of current does not exist");
            self.marbles.insert_after(marble_to_right, number);
            self.current_marble = number;

            0
        }
    }
/// Places a marble in the circle and returns the resulting score.
Places a marble in the circle and returns the resulting score.
Places a marble in the circle and returns the resulting score .
pub fn place_marble(&mut self, number: usize) -> usize {
        if number % 23 == 0 {
            let mut removed_marble = self
                .marbles
                .left_of(self.current_marble)
                .expect("Marble 1 place to left does not exist");
            for n in 2..=7 {
                removed_marble = self
                    .marbles
                    .left_of(removed_marble)
                    .unwrap_or_else(|| panic!("Marble {} places to left does not exist", n));
            }
            self.current_marble = self
                .marbles
                .right_of(removed_marble)
                .expect("Next current marble does not exist");
            self.marbles.remove(removed_marble);
            number + removed_marble
        } else {
            let marble_to_right = self
                .marbles
                .right_of(self.current_marble)
                .expect("Marble to right of current does not exist");
            self.marbles.insert_after(marble_to_right, number);
            self.current_marble = number;
            0
        }
    }
pub fn place_marble ( & mut self , number : usize ) -> usize { if number % 23 == 0 { let mut removed_marble = self . marbles . left_of ( self . current_marble ) . expect ( " " ) ; for n in 2 ..= 7 { removed_marble = self . marbles . left_of ( removed_marble ) . unwrap_or_else ( | | panic ! ( " " n ) ) ; } self . current_marble = self . marbles . right_of ( removed_marble ) . expect ( " " ) ; self . marbles . remove ( removed_marble ) ; number + removed_marble } else { let marble_to_right = self . marbles . right_of ( self . current_marble ) . expect ( " " ) ; self . marbles . insert_after ( marble_to_right , number ) ; self . current_marble = number ; 0 } }
Places a marble in the circle and returns the resulting score.
Places a marble in the circle and returns the resulting score .
&mut self
number
usize
&mut self
number
usize