File tree 2 files changed +12
-7
lines changed
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 110
110
| 19 | [ Not Enough Minerals] ( https://adventofcode.com/2022/day/19 ) | [ Source] ( src/year2022/day19.rs ) | 407 |
111
111
| 20 | [ Grove Positioning System] ( https://adventofcode.com/2022/day/20 ) | [ Source] ( src/year2022/day20.rs ) | 5067 |
112
112
| 21 | [ Monkey Math] ( https://adventofcode.com/2022/day/21 ) | [ Source] ( src/year2022/day21.rs ) | 61 |
113
- | 22 | [ Monkey Map] ( https://adventofcode.com/2022/day/22 ) | [ Source] ( src/year2022/day22.rs ) | 132 |
113
+ | 22 | [ Monkey Map] ( https://adventofcode.com/2022/day/22 ) | [ Source] ( src/year2022/day22.rs ) | 55 |
114
114
| 23 | [ Unstable Diffusion] ( https://adventofcode.com/2022/day/23 ) | [ Source] ( src/year2022/day23.rs ) | 2017 |
115
115
| 24 | [ Blizzard Basin] ( https://adventofcode.com/2022/day/24 ) | [ Source] ( src/year2022/day24.rs ) | 80 |
116
116
| 25 | [ Full of Hot Air] ( https://adventofcode.com/2022/day/25 ) | [ Source] ( src/year2022/day25.rs ) | 3 |
Original file line number Diff line number Diff line change @@ -208,14 +208,19 @@ fn parse_grid(input: &str) -> Grid {
208
208
209
209
fn parse_moves ( input : & str ) -> Vec < Move > {
210
210
let mut moves = Vec :: new ( ) ;
211
+ let mut numbers = input. iter_unsigned ( ) ;
212
+ let mut letters = input. bytes ( ) . filter ( u8:: is_ascii_uppercase) ;
211
213
212
- for token in input. replace ( 'L' , " L " ) . replace ( 'R' , " R " ) . trim ( ) . split ( ' ' ) {
213
- let next = match token {
214
- "L" => Move :: Left ,
215
- "R" => Move :: Right ,
216
- n => Move :: Forward ( n. unsigned ( ) ) ,
214
+ loop {
215
+ let Some ( n) = numbers. next ( ) else {
216
+ break ;
217
217
} ;
218
- moves. push ( next) ;
218
+ moves. push ( Move :: Forward ( n) ) ;
219
+
220
+ let Some ( d) = letters. next ( ) else {
221
+ break ;
222
+ } ;
223
+ moves. push ( if d == b'L' { Move :: Left } else { Move :: Right } ) ;
219
224
}
220
225
221
226
moves
You can’t perform that action at this time.
0 commit comments