From eb1493cd47c28fd6cecb2f8a805751fa77c3216d Mon Sep 17 00:00:00 2001 From: Peter Byfield Date: Tue, 26 Dec 2023 09:20:13 +0100 Subject: [PATCH] 2023 day 22 part 1 --- 2023/rust/aoc/src/day22/input | 1430 ++++++++++++++++++++++++++++++++ 2023/rust/aoc/src/day22/mod.rs | 137 +++ 2023/rust/aoc/src/day22/sample | 7 + 2023/rust/aoc/src/lib.rs | 1 + 4 files changed, 1575 insertions(+) create mode 100644 2023/rust/aoc/src/day22/input create mode 100644 2023/rust/aoc/src/day22/mod.rs create mode 100644 2023/rust/aoc/src/day22/sample diff --git a/2023/rust/aoc/src/day22/input b/2023/rust/aoc/src/day22/input new file mode 100644 index 0000000..bea79d1 --- /dev/null +++ b/2023/rust/aoc/src/day22/input @@ -0,0 +1,1430 @@ +0,6,296~2,6,296 +0,3,10~1,3,10 +6,9,288~8,9,288 +1,2,302~3,2,302 +6,0,71~6,2,71 +8,8,31~8,8,33 +7,4,53~7,4,54 +6,7,223~8,7,223 +5,2,15~7,2,15 +4,5,4~4,7,4 +6,0,238~7,0,238 +0,2,176~0,4,176 +4,3,253~4,3,255 +0,5,82~0,7,82 +6,0,5~6,3,5 +1,3,48~1,5,48 +1,2,293~2,2,293 +1,8,201~3,8,201 +5,2,37~8,2,37 +2,6,204~2,8,204 +9,0,65~9,1,65 +0,6,75~0,8,75 +6,3,191~6,4,191 +0,3,102~0,5,102 +4,2,23~4,5,23 +2,5,250~2,7,250 +4,9,134~4,9,136 +2,5,244~2,7,244 +1,4,73~3,4,73 +9,7,192~9,7,194 +2,5,276~5,5,276 +3,0,11~5,0,11 +1,4,122~1,8,122 +7,2,83~9,2,83 +5,7,179~5,8,179 +2,1,2~2,2,2 +2,0,109~4,0,109 +0,2,174~0,4,174 +2,8,217~2,8,219 +5,4,52~7,4,52 +4,5,196~4,5,198 +1,2,297~1,4,297 +5,7,256~7,7,256 +2,0,13~2,2,13 +0,7,289~0,8,289 +1,6,154~1,6,156 +2,0,146~4,0,146 +8,3,37~9,3,37 +4,9,148~6,9,148 +2,3,266~2,5,266 +9,2,46~9,5,46 +3,6,319~3,8,319 +0,1,154~0,4,154 +4,4,10~6,4,10 +5,3,105~8,3,105 +4,7,164~5,7,164 +0,1,31~0,4,31 +5,9,5~6,9,5 +8,8,2~8,8,4 +4,2,177~4,3,177 +2,8,193~2,9,193 +5,7,157~8,7,157 +6,1,125~6,1,127 +1,1,5~3,1,5 +1,6,181~1,7,181 +8,2,36~8,3,36 +7,4,12~7,7,12 +7,6,185~7,8,185 +2,4,212~2,6,212 +8,8,128~8,9,128 +0,9,285~3,9,285 +8,5,124~8,7,124 +6,6,181~6,8,181 +6,1,54~6,4,54 +7,2,11~7,4,11 +3,8,203~6,8,203 +7,6,138~7,6,141 +7,0,4~9,0,4 +5,2,264~7,2,264 +5,9,112~6,9,112 +0,5,185~2,5,185 +0,9,237~3,9,237 +0,5,45~0,8,45 +0,9,80~0,9,82 +5,2,170~8,2,170 +0,2,136~0,4,136 +2,1,194~2,4,194 +0,7,264~0,7,266 +9,5,122~9,8,122 +1,4,32~2,4,32 +3,5,155~6,5,155 +0,1,12~2,1,12 +3,6,312~3,8,312 +6,3,98~6,3,98 +7,2,317~9,2,317 +1,7,301~1,9,301 +8,2,241~9,2,241 +6,3,22~6,6,22 +6,6,40~6,8,40 +2,8,191~4,8,191 +2,9,191~4,9,191 +3,1,270~3,2,270 +0,2,65~0,4,65 +2,2,225~4,2,225 +7,1,263~9,1,263 +0,5,18~0,5,20 +4,6,246~4,9,246 +7,3,216~9,3,216 +6,9,167~7,9,167 +4,8,211~7,8,211 +1,3,265~1,5,265 +9,7,150~9,9,150 +2,0,48~2,2,48 +2,3,90~4,3,90 +4,3,213~7,3,213 +6,6,105~6,9,105 +2,2,25~3,2,25 +7,1,154~9,1,154 +7,4,314~7,5,314 +4,4,60~4,4,62 +0,1,71~2,1,71 +6,0,156~8,0,156 +7,1,130~7,2,130 +1,0,79~1,3,79 +8,0,151~8,0,153 +6,1,223~6,4,223 +6,4,98~6,5,98 +3,1,283~3,4,283 +4,2,161~4,4,161 +7,5,155~7,7,155 +6,6,171~6,7,171 +6,6,34~9,6,34 +0,4,23~2,4,23 +3,1,221~5,1,221 +6,3,299~8,3,299 +1,2,57~2,2,57 +4,6,225~4,8,225 +4,7,113~7,7,113 +2,2,62~2,5,62 +9,2,148~9,4,148 +7,3,266~8,3,266 +7,4,14~9,4,14 +9,1,304~9,3,304 +5,6,240~5,8,240 +1,6,226~2,6,226 +7,3,130~7,5,130 +0,3,281~3,3,281 +9,1,25~9,4,25 +5,2,55~5,4,55 +3,5,35~3,7,35 +6,2,96~6,4,96 +8,5,3~8,5,3 +1,0,112~1,1,112 +3,8,316~3,8,316 +2,8,43~3,8,43 +7,2,189~7,3,189 +8,5,116~8,7,116 +1,3,124~1,6,124 +7,8,188~9,8,188 +3,6,303~3,9,303 +5,7,275~7,7,275 +8,6,7~9,6,7 +9,3,39~9,5,39 +6,6,3~8,6,3 +5,6,303~5,9,303 +3,5,124~3,6,124 +2,3,72~4,3,72 +3,7,175~3,9,175 +3,8,196~4,8,196 +0,8,72~2,8,72 +7,1,161~7,3,161 +9,0,153~9,2,153 +4,3,241~4,6,241 +1,1,282~1,3,282 +6,7,320~9,7,320 +7,3,187~7,5,187 +9,7,205~9,8,205 +3,0,196~5,0,196 +6,9,290~7,9,290 +7,6,292~9,6,292 +4,4,282~4,6,282 +9,4,82~9,7,82 +6,2,219~6,3,219 +7,5,285~9,5,285 +7,1,12~7,3,12 +2,2,153~4,2,153 +3,7,63~3,7,65 +6,3,214~6,3,217 +6,8,206~6,8,207 +0,6,198~1,6,198 +9,1,177~9,3,177 +8,8,270~8,8,272 +7,3,81~9,3,81 +2,5,240~2,8,240 +2,4,25~2,4,27 +9,0,67~9,1,67 +0,5,15~3,5,15 +2,3,261~2,3,261 +3,0,293~3,2,293 +6,7,183~7,7,183 +1,2,9~1,2,12 +0,5,55~0,8,55 +7,0,296~7,1,296 +6,2,137~6,3,137 +9,1,58~9,4,58 +4,4,270~5,4,270 +0,3,246~3,3,246 +8,4,61~8,4,63 +2,7,192~4,7,192 +4,1,45~6,1,45 +0,7,42~0,9,42 +1,4,21~3,4,21 +1,4,206~3,4,206 +6,5,96~6,8,96 +8,2,148~8,5,148 +0,1,299~0,4,299 +6,5,99~6,7,99 +4,5,194~4,6,194 +0,1,126~3,1,126 +3,7,61~3,9,61 +7,1,278~7,4,278 +2,2,123~4,2,123 +8,2,109~8,3,109 +9,0,95~9,2,95 +7,3,258~7,5,258 +5,3,83~5,4,83 +1,4,67~3,4,67 +0,3,297~0,4,297 +4,5,158~4,5,161 +8,8,155~8,8,157 +6,5,186~6,5,186 +9,7,49~9,8,49 +5,0,168~8,0,168 +2,5,201~5,5,201 +6,6,200~8,6,200 +0,7,136~2,7,136 +1,3,27~1,3,30 +3,0,174~3,3,174 +1,3,260~4,3,260 +2,8,46~5,8,46 +9,4,135~9,5,135 +7,4,67~7,7,67 +9,4,32~9,6,32 +0,7,286~0,9,286 +0,2,264~0,4,264 +6,5,140~8,5,140 +2,0,301~2,3,301 +2,6,309~2,8,309 +0,5,103~3,5,103 +2,3,248~2,4,248 +0,5,268~2,5,268 +2,0,305~4,0,305 +4,7,318~4,9,318 +1,7,80~1,9,80 +0,8,291~0,9,291 +2,8,317~5,8,317 +4,0,61~4,2,61 +0,0,157~0,3,157 +5,0,297~5,2,297 +2,3,100~4,3,100 +0,7,142~3,7,142 +7,3,60~7,6,60 +5,4,303~7,4,303 +9,3,299~9,6,299 +0,2,139~1,2,139 +3,5,95~3,7,95 +4,4,173~5,4,173 +1,0,309~1,0,311 +5,0,8~8,0,8 +5,6,160~5,8,160 +3,5,168~5,5,168 +6,2,44~6,4,44 +0,0,290~3,0,290 +6,3,102~6,6,102 +7,0,78~7,3,78 +8,2,111~8,3,111 +1,4,207~1,7,207 +8,1,258~8,4,258 +2,1,124~2,3,124 +4,9,8~7,9,8 +6,7,179~8,7,179 +1,6,78~1,8,78 +1,3,212~4,3,212 +6,7,41~8,7,41 +0,5,186~2,5,186 +0,9,182~2,9,182 +1,0,289~1,3,289 +3,5,62~3,5,64 +2,0,193~4,0,193 +6,2,172~8,2,172 +5,5,307~8,5,307 +3,2,94~3,4,94 +4,3,8~6,3,8 +0,8,146~1,8,146 +0,6,305~2,6,305 +1,0,103~4,0,103 +0,7,296~3,7,296 +4,4,178~4,5,178 +6,1,161~6,5,161 +8,2,283~8,4,283 +5,6,210~5,6,211 +0,6,188~3,6,188 +2,1,55~5,1,55 +3,5,297~3,7,297 +1,2,6~1,4,6 +4,1,117~4,3,117 +0,3,175~0,4,175 +7,1,59~9,1,59 +7,6,295~7,6,296 +3,2,213~3,5,213 +5,1,119~6,1,119 +7,4,197~7,6,197 +3,1,291~6,1,291 +4,7,302~6,7,302 +6,9,63~8,9,63 +2,6,281~2,8,281 +6,5,25~6,5,27 +5,1,235~5,3,235 +1,3,126~3,3,126 +3,6,59~3,8,59 +5,3,237~5,6,237 +4,6,135~5,6,135 +3,7,216~5,7,216 +9,4,22~9,6,22 +2,6,69~2,7,69 +3,7,229~3,7,231 +2,7,303~2,7,304 +4,4,116~4,6,116 +1,4,144~1,6,144 +1,6,52~1,8,52 +4,4,77~5,4,77 +6,0,280~6,2,280 +9,2,199~9,2,200 +4,1,43~4,2,43 +9,3,2~9,5,2 +3,6,143~3,9,143 +2,3,148~4,3,148 +4,2,236~8,2,236 +7,0,185~7,3,185 +8,2,61~8,3,61 +6,3,261~6,4,261 +4,3,219~4,6,219 +4,3,150~4,3,152 +9,5,202~9,7,202 +2,0,158~2,2,158 +5,2,62~5,2,64 +7,2,127~7,5,127 +4,5,324~4,6,324 +7,3,217~7,5,217 +7,7,261~7,9,261 +5,3,160~6,3,160 +2,1,104~2,3,104 +5,6,47~7,6,47 +8,3,4~8,4,4 +9,0,175~9,1,175 +4,4,190~6,4,190 +9,3,42~9,3,44 +1,2,75~1,4,75 +3,2,311~3,5,311 +7,4,280~8,4,280 +8,5,263~9,5,263 +1,2,46~4,2,46 +4,5,6~4,5,8 +9,9,159~9,9,162 +6,9,15~8,9,15 +1,6,179~4,6,179 +5,5,183~5,6,183 +3,8,47~3,9,47 +1,5,45~1,7,45 +0,9,44~1,9,44 +3,8,53~3,8,54 +0,3,259~1,3,259 +8,0,9~9,0,9 +4,1,99~7,1,99 +0,8,298~3,8,298 +3,2,137~5,2,137 +6,2,87~6,4,87 +2,6,7~5,6,7 +2,1,49~2,2,49 +0,7,26~1,7,26 +0,6,54~1,6,54 +1,3,283~2,3,283 +2,5,71~2,8,71 +9,3,146~9,5,146 +2,4,215~2,4,217 +6,6,119~6,7,119 +1,2,221~1,3,221 +2,2,247~4,2,247 +4,1,73~6,1,73 +7,1,194~9,1,194 +6,5,41~6,5,43 +5,2,177~8,2,177 +0,0,28~0,2,28 +7,3,312~7,5,312 +7,8,265~9,8,265 +6,3,268~6,5,268 +3,4,321~3,6,321 +6,6,98~6,9,98 +4,2,6~4,4,6 +1,7,152~2,7,152 +1,5,281~3,5,281 +7,0,176~7,1,176 +1,4,17~1,6,17 +9,6,88~9,8,88 +4,2,89~4,4,89 +5,0,148~5,1,148 +4,3,75~4,3,75 +8,7,84~9,7,84 +6,5,8~6,6,8 +8,0,179~9,0,179 +3,0,14~3,1,14 +4,4,78~5,4,78 +4,1,122~6,1,122 +7,0,129~7,2,129 +3,9,17~6,9,17 +4,1,157~4,4,157 +0,5,306~0,7,306 +6,3,256~9,3,256 +9,5,180~9,7,180 +2,1,57~2,1,59 +3,2,147~3,4,147 +0,4,284~0,6,284 +8,1,60~8,4,60 +7,2,160~7,5,160 +8,3,298~9,3,298 +7,6,283~9,6,283 +6,4,42~9,4,42 +0,1,82~1,1,82 +5,2,45~5,5,45 +6,4,143~7,4,143 +7,3,260~7,3,262 +0,6,216~2,6,216 +1,6,290~2,6,290 +7,9,265~7,9,268 +3,1,53~5,1,53 +1,4,105~1,6,105 +2,1,70~2,3,70 +2,3,45~2,5,45 +1,6,210~1,6,213 +6,3,230~6,5,230 +0,1,302~0,1,304 +5,0,52~5,0,53 +8,3,204~9,3,204 +0,5,13~3,5,13 +7,9,194~9,9,194 +6,2,2~6,4,2 +5,0,44~5,3,44 +3,6,189~3,9,189 +3,2,183~3,2,183 +4,4,271~6,4,271 +5,5,250~5,5,252 +0,1,84~0,1,86 +4,0,12~6,0,12 +2,4,299~5,4,299 +7,7,87~9,7,87 +2,0,196~2,0,197 +8,2,17~8,4,17 +3,3,243~6,3,243 +5,9,165~8,9,165 +2,3,263~2,5,263 +4,4,228~6,4,228 +8,8,64~8,9,64 +5,5,10~5,6,10 +1,5,102~1,7,102 +8,6,154~8,9,154 +5,3,138~5,4,138 +9,6,116~9,8,116 +4,5,154~7,5,154 +4,3,273~6,3,273 +3,8,123~6,8,123 +2,5,21~2,8,21 +5,5,5~8,5,5 +4,3,239~5,3,239 +1,5,160~3,5,160 +8,0,150~8,2,150 +9,6,191~9,8,191 +4,2,248~4,3,248 +8,2,86~8,2,87 +3,1,218~5,1,218 +8,8,199~9,8,199 +9,4,261~9,7,261 +0,4,294~3,4,294 +9,3,102~9,4,102 +1,1,76~1,4,76 +9,4,193~9,6,193 +6,3,314~6,5,314 +3,6,176~3,9,176 +2,7,124~5,7,124 +6,4,29~6,6,29 +1,3,9~2,3,9 +6,5,304~8,5,304 +3,2,87~5,2,87 +0,5,172~2,5,172 +4,2,120~7,2,120 +2,0,28~2,3,28 +3,3,19~4,3,19 +2,9,9~4,9,9 +1,8,39~4,8,39 +3,3,204~3,6,204 +5,7,182~5,8,182 +4,8,247~6,8,247 +5,3,7~5,5,7 +0,5,105~0,7,105 +2,8,291~2,9,291 +1,2,250~3,2,250 +3,5,157~3,6,157 +9,1,165~9,4,165 +6,6,274~6,8,274 +0,5,249~3,5,249 +2,4,7~4,4,7 +4,1,295~6,1,295 +2,2,198~3,2,198 +6,8,8~8,8,8 +2,9,145~2,9,145 +6,6,133~6,8,133 +5,0,25~8,0,25 +0,5,109~0,7,109 +6,6,136~6,8,136 +1,2,135~1,5,135 +6,1,293~9,1,293 +8,6,159~8,6,160 +8,8,122~8,8,125 +7,4,37~7,4,39 +5,3,75~5,4,75 +2,8,132~2,8,132 +6,3,140~9,3,140 +7,7,38~7,9,38 +1,0,292~1,2,292 +7,0,88~9,0,88 +2,5,246~4,5,246 +9,9,40~9,9,44 +0,6,74~0,8,74 +3,0,132~6,0,132 +8,8,29~9,8,29 +7,7,166~9,7,166 +3,2,274~3,4,274 +7,2,269~7,3,269 +2,3,168~6,3,168 +9,5,149~9,7,149 +7,9,155~9,9,155 +9,6,3~9,6,6 +3,1,272~6,1,272 +7,5,161~7,5,164 +6,7,258~9,7,258 +9,5,25~9,7,25 +4,0,186~4,3,186 +1,1,156~1,4,156 +1,9,305~3,9,305 +3,6,208~3,6,210 +2,4,34~2,4,37 +3,6,142~6,6,142 +8,4,151~8,6,151 +3,6,314~3,9,314 +7,2,145~7,3,145 +5,4,132~8,4,132 +7,1,190~7,1,192 +7,2,268~9,2,268 +0,3,159~1,3,159 +6,7,284~8,7,284 +4,3,250~4,5,250 +6,0,133~6,0,135 +2,2,154~2,2,156 +7,4,28~9,4,28 +1,0,142~5,0,142 +4,2,140~4,2,144 +4,5,257~5,5,257 +8,6,123~8,7,123 +1,2,24~3,2,24 +4,5,310~7,5,310 +0,6,259~2,6,259 +4,7,261~6,7,261 +3,8,70~5,8,70 +6,5,311~6,8,311 +3,2,301~5,2,301 +4,6,92~7,6,92 +0,7,148~0,9,148 +4,0,47~6,0,47 +5,6,207~5,8,207 +6,6,208~7,6,208 +1,4,59~2,4,59 +2,2,97~3,2,97 +8,6,43~8,6,44 +7,2,89~8,2,89 +5,5,40~7,5,40 +1,6,151~1,7,151 +7,3,139~7,5,139 +9,1,88~9,1,91 +6,3,289~9,3,289 +7,4,56~9,4,56 +6,4,41~9,4,41 +7,7,306~8,7,306 +6,6,120~9,6,120 +1,3,145~1,5,145 +8,5,110~8,8,110 +5,0,147~5,2,147 +7,4,64~7,6,64 +7,9,39~9,9,39 +3,6,206~6,6,206 +1,5,282~1,5,286 +0,6,108~0,7,108 +0,5,27~0,7,27 +0,4,298~0,5,298 +7,5,142~9,5,142 +1,5,279~4,5,279 +7,4,93~8,4,93 +1,3,264~3,3,264 +5,4,251~5,4,253 +8,9,124~9,9,124 +4,5,321~7,5,321 +9,4,83~9,4,84 +6,4,168~6,6,168 +0,1,215~1,1,215 +6,1,17~6,3,17 +4,6,23~7,6,23 +9,4,96~9,5,96 +3,7,161~6,7,161 +3,4,59~3,5,59 +4,9,67~6,9,67 +3,2,160~6,2,160 +5,9,108~7,9,108 +4,8,248~7,8,248 +4,6,292~4,8,292 +9,3,59~9,3,62 +3,9,57~4,9,57 +4,2,259~7,2,259 +0,5,140~0,6,140 +7,1,144~7,3,144 +7,6,46~7,6,46 +4,6,180~6,6,180 +5,1,47~5,1,50 +9,1,85~9,3,85 +4,0,292~4,2,292 +6,2,100~6,2,103 +1,1,246~3,1,246 +4,1,184~6,1,184 +2,9,196~5,9,196 +1,3,152~1,3,152 +2,4,149~4,4,149 +4,4,273~4,6,273 +3,2,16~5,2,16 +7,8,233~7,9,233 +2,7,24~5,7,24 +3,3,93~3,5,93 +5,7,12~5,8,12 +6,2,257~8,2,257 +4,0,162~4,2,162 +4,3,224~6,3,224 +3,9,138~5,9,138 +6,4,45~9,4,45 +3,3,277~4,3,277 +3,6,66~3,8,66 +8,1,183~8,3,183 +9,6,52~9,8,52 +3,8,170~4,8,170 +0,0,111~4,0,111 +1,8,139~1,9,139 +6,3,126~6,5,126 +2,5,143~4,5,143 +6,1,187~6,4,187 +5,2,3~5,3,3 +5,8,128~5,8,130 +7,6,280~7,8,280 +4,1,140~6,1,140 +7,6,299~7,6,301 +6,2,167~6,2,169 +0,9,222~2,9,222 +0,4,3~1,4,3 +3,9,199~5,9,199 +4,2,266~4,4,266 +8,3,310~8,5,310 +6,8,186~6,9,186 +7,8,171~9,8,171 +2,4,139~4,4,139 +7,0,314~7,3,314 +5,3,71~5,4,71 +6,8,1~6,9,1 +7,4,267~7,7,267 +2,0,9~2,0,11 +9,0,180~9,0,182 +2,3,171~3,3,171 +1,6,65~2,6,65 +1,6,138~1,8,138 +4,3,3~4,5,3 +5,1,186~5,2,186 +1,1,216~5,1,216 +4,9,128~7,9,128 +5,7,97~5,8,97 +2,7,290~4,7,290 +6,1,33~6,4,33 +8,4,79~9,4,79 +4,5,74~7,5,74 +8,0,197~8,1,197 +6,9,117~9,9,117 +7,0,214~7,3,214 +9,2,196~9,5,196 +0,7,201~0,8,201 +3,6,8~3,9,8 +7,5,158~9,5,158 +5,7,282~5,8,282 +2,9,50~4,9,50 +1,6,219~1,8,219 +5,8,148~7,8,148 +5,1,67~5,2,67 +0,7,137~0,8,137 +7,7,145~7,9,145 +2,3,10~2,3,12 +3,3,178~5,3,178 +1,5,153~2,5,153 +5,8,132~5,9,132 +2,2,237~3,2,237 +5,2,304~5,3,304 +2,0,243~4,0,243 +0,1,244~2,1,244 +3,0,148~4,0,148 +1,3,100~1,5,100 +5,4,110~5,7,110 +4,5,145~4,5,145 +6,3,142~7,3,142 +6,9,42~8,9,42 +0,6,267~3,6,267 +8,0,47~8,3,47 +5,7,178~8,7,178 +5,9,175~5,9,177 +4,5,184~7,5,184 +2,3,181~3,3,181 +4,0,102~4,2,102 +7,5,151~7,5,153 +6,0,138~8,0,138 +6,2,284~6,2,286 +5,8,302~8,8,302 +1,7,194~3,7,194 +3,6,302~5,6,302 +3,6,226~3,8,226 +5,9,74~8,9,74 +3,3,296~3,6,296 +1,3,69~2,3,69 +1,8,243~4,8,243 +3,2,63~3,3,63 +0,5,138~3,5,138 +6,9,109~7,9,109 +3,8,291~6,8,291 +3,7,129~3,9,129 +6,6,299~6,8,299 +4,6,114~4,8,114 +0,0,170~0,2,170 +0,2,26~2,2,26 +1,3,78~1,4,78 +9,6,172~9,8,172 +5,0,214~5,2,214 +4,5,280~7,5,280 +9,3,103~9,3,105 +0,7,46~0,9,46 +4,3,202~4,5,202 +0,3,220~0,6,220 +8,7,190~8,9,190 +6,4,164~9,4,164 +6,9,235~8,9,235 +8,8,120~8,9,120 +6,3,221~6,5,221 +0,0,106~2,0,106 +6,3,171~8,3,171 +5,3,226~5,6,226 +9,5,267~9,7,267 +8,4,198~8,5,198 +0,3,99~3,3,99 +2,5,277~2,8,277 +1,7,262~4,7,262 +3,9,140~5,9,140 +2,8,23~2,9,23 +7,2,66~7,5,66 +9,1,106~9,3,106 +5,6,250~7,6,250 +7,2,322~7,5,322 +1,6,268~1,8,268 +8,4,208~8,7,208 +7,4,57~9,4,57 +6,4,253~6,7,253 +7,9,264~9,9,264 +2,5,136~4,5,136 +3,6,186~3,8,186 +8,4,202~8,5,202 +7,5,43~7,7,43 +1,2,263~1,4,263 +9,6,28~9,8,28 +4,4,111~6,4,111 +4,9,144~5,9,144 +7,4,264~8,4,264 +0,9,2~0,9,2 +4,2,270~4,3,270 +2,6,253~2,6,256 +8,4,134~9,4,134 +6,2,319~7,2,319 +5,3,24~9,3,24 +5,3,302~6,3,302 +4,7,151~6,7,151 +3,1,58~4,1,58 +2,2,161~3,2,161 +6,3,259~6,4,259 +5,4,36~7,4,36 +0,1,219~1,1,219 +0,0,158~0,2,158 +7,9,10~8,9,10 +8,2,284~8,5,284 +3,2,211~5,2,211 +0,0,140~2,0,140 +7,5,62~8,5,62 +1,4,208~1,5,208 +2,3,14~2,3,16 +0,2,1~0,3,1 +7,5,201~9,5,201 +1,5,213~2,5,213 +4,4,314~4,4,316 +1,5,254~4,5,254 +8,3,2~8,5,2 +2,9,282~2,9,284 +9,3,99~9,4,99 +5,7,173~6,7,173 +1,3,31~3,3,31 +4,8,173~4,9,173 +3,5,20~3,5,23 +3,7,265~3,8,265 +7,5,132~7,8,132 +4,8,74~5,8,74 +4,6,144~4,6,146 +9,6,293~9,9,293 +5,8,231~5,9,231 +9,8,46~9,9,46 +3,4,138~4,4,138 +2,9,85~2,9,86 +4,1,296~4,3,296 +2,7,121~4,7,121 +7,1,298~7,3,298 +5,7,65~5,9,65 +3,3,285~3,3,288 +6,9,192~9,9,192 +5,5,134~5,7,134 +2,9,234~5,9,234 +2,3,276~4,3,276 +2,4,182~2,7,182 +5,3,227~8,3,227 +4,7,166~6,7,166 +3,6,199~3,8,199 +2,3,95~3,3,95 +2,7,83~2,9,83 +6,5,132~6,6,132 +6,6,218~6,7,218 +6,4,91~6,4,92 +7,7,211~9,7,211 +7,1,216~7,1,216 +2,9,131~3,9,131 +5,3,157~6,3,157 +4,8,184~6,8,184 +5,3,249~5,5,249 +3,4,152~4,4,152 +7,0,123~7,3,123 +1,1,102~1,3,102 +3,0,209~3,3,209 +6,2,254~6,4,254 +7,0,40~7,3,40 +2,3,102~2,4,102 +4,3,163~5,3,163 +1,8,302~2,8,302 +6,7,201~8,7,201 +0,2,133~2,2,133 +5,2,285~5,3,285 +1,1,234~1,4,234 +7,0,295~7,2,295 +9,2,272~9,2,275 +6,7,197~8,7,197 +4,5,221~4,8,221 +7,0,188~7,2,188 +3,3,25~3,5,25 +0,2,143~0,2,143 +4,3,226~4,5,226 +1,3,255~1,3,256 +1,3,148~1,6,148 +6,0,228~6,3,228 +6,6,41~8,6,41 +6,7,117~8,7,117 +3,8,116~5,8,116 +6,6,50~7,6,50 +1,3,81~1,5,81 +4,4,167~7,4,167 +4,8,11~6,8,11 +4,8,228~6,8,228 +9,7,158~9,9,158 +4,8,78~6,8,78 +4,4,24~4,4,27 +4,1,246~6,1,246 +4,5,133~6,5,133 +0,6,231~1,6,231 +3,5,123~3,6,123 +6,1,231~6,1,232 +0,5,50~2,5,50 +8,0,260~8,1,260 +4,8,56~6,8,56 +6,0,45~8,0,45 +5,8,319~8,8,319 +0,6,77~3,6,77 +6,3,272~6,5,272 +7,8,277~9,8,277 +9,1,180~9,2,180 +5,9,114~6,9,114 +8,8,275~8,9,275 +4,9,287~7,9,287 +3,0,72~6,0,72 +6,9,123~8,9,123 +0,8,129~2,8,129 +5,9,68~7,9,68 +6,1,182~9,1,182 +7,4,141~9,4,141 +6,6,165~6,8,165 +7,7,295~8,7,295 +6,8,230~8,8,230 +5,9,22~5,9,26 +2,8,146~4,8,146 +6,4,40~8,4,40 +3,4,267~6,4,267 +5,6,108~8,6,108 +8,5,144~8,8,144 +7,7,164~7,9,164 +1,6,1~1,8,1 +2,2,178~3,2,178 +9,5,208~9,8,208 +3,5,180~3,8,180 +0,7,183~0,9,183 +7,4,23~8,4,23 +2,8,295~3,8,295 +0,2,194~0,5,194 +2,7,32~4,7,32 +4,8,4~4,8,7 +7,2,87~7,5,87 +7,3,263~7,4,263 +5,4,279~5,7,279 +2,0,6~2,2,6 +0,1,248~0,3,248 +6,3,174~8,3,174 +8,8,232~8,8,232 +4,7,5~5,7,5 +2,7,1~4,7,1 +6,5,254~7,5,254 +9,5,318~9,7,318 +2,1,67~2,3,67 +2,1,213~2,3,213 +9,3,288~9,6,288 +7,8,113~9,8,113 +0,5,25~2,5,25 +1,0,175~3,0,175 +5,9,55~8,9,55 +9,2,147~9,5,147 +4,1,274~4,4,274 +7,3,137~7,6,137 +1,6,202~1,6,204 +9,3,52~9,5,52 +8,1,269~8,3,269 +1,1,214~1,2,214 +7,1,92~7,3,92 +4,1,244~4,3,244 +3,2,228~4,2,228 +7,8,190~7,8,193 +7,1,28~7,3,28 +7,5,287~7,6,287 +6,1,233~6,1,234 +7,5,174~7,8,174 +5,7,33~7,7,33 +1,1,286~1,3,286 +4,7,169~4,9,169 +6,3,165~6,5,165 +9,3,179~9,5,179 +3,4,135~5,4,135 +5,5,96~5,7,96 +5,5,227~5,8,227 +6,5,138~7,5,138 +0,3,189~0,5,189 +5,8,212~7,8,212 +4,3,176~4,5,176 +2,5,298~3,5,298 +1,9,82~4,9,82 +1,7,132~3,7,132 +6,4,74~7,4,74 +4,2,155~6,2,155 +5,6,219~5,7,219 +5,0,145~7,0,145 +4,7,141~4,9,141 +2,7,65~2,9,65 +1,3,71~1,4,71 +0,0,137~0,3,137 +6,5,111~8,5,111 +0,6,195~4,6,195 +3,1,7~3,3,7 +8,7,286~8,9,286 +5,0,40~5,3,40 +3,6,255~6,6,255 +4,8,126~4,8,127 +8,8,75~8,9,75 +9,4,225~9,5,225 +4,7,129~4,7,130 +0,6,79~0,9,79 +1,3,24~1,5,24 +2,9,172~5,9,172 +4,1,118~6,1,118 +5,1,149~7,1,149 +8,2,291~8,4,291 +6,8,73~6,9,73 +8,4,173~8,5,173 +2,4,29~2,6,29 +8,4,171~8,6,171 +7,5,145~9,5,145 +8,4,176~8,6,176 +4,6,193~4,8,193 +3,2,151~3,4,151 +4,5,72~4,6,72 +4,8,1~4,8,3 +9,1,31~9,4,31 +7,8,303~7,8,306 +5,4,70~8,4,70 +5,3,246~5,6,246 +4,3,311~4,5,311 +2,4,243~4,4,243 +6,9,285~6,9,286 +1,2,252~1,5,252 +1,7,284~4,7,284 +2,3,206~4,3,206 +9,3,301~9,4,301 +1,6,287~1,9,287 +9,6,114~9,9,114 +4,7,266~7,7,266 +5,6,313~6,6,313 +5,3,247~8,3,247 +6,6,212~6,6,215 +6,3,75~8,3,75 +3,5,140~3,7,140 +2,3,151~2,5,151 +6,8,210~6,9,210 +6,9,168~6,9,170 +5,2,81~7,2,81 +8,0,177~9,0,177 +2,3,174~2,3,175 +0,7,292~0,7,294 +2,1,286~4,1,286 +0,2,177~0,3,177 +9,2,38~9,4,38 +2,6,242~2,6,243 +5,3,177~6,3,177 +3,5,38~3,5,40 +0,0,29~1,0,29 +5,0,150~5,0,151 +1,9,179~3,9,179 +7,8,234~7,8,235 +3,5,238~4,5,238 +2,6,224~2,8,224 +9,1,270~9,3,270 +0,6,199~0,8,199 +6,8,268~8,8,268 +1,6,85~1,8,85 +0,1,211~4,1,211 +8,9,17~9,9,17 +8,2,26~9,2,26 +8,8,20~8,8,23 +2,2,300~2,4,300 +2,0,16~2,0,17 +8,4,156~8,6,156 +3,0,129~3,1,129 +3,4,18~3,5,18 +4,6,69~4,8,69 +5,3,274~5,3,275 +5,9,235~5,9,238 +2,1,7~2,1,9 +7,3,293~8,3,293 +2,3,98~2,5,98 +6,5,31~8,5,31 +9,1,320~9,3,320 +2,6,301~2,8,301 +3,0,235~6,0,235 +6,4,38~6,6,38 +1,2,180~3,2,180 +0,3,61~3,3,61 +0,5,111~0,7,111 +6,9,3~9,9,3 +8,5,35~9,5,35 +8,5,265~9,5,265 +3,3,215~3,4,215 +0,3,4~0,3,7 +6,1,97~6,2,97 +7,3,316~8,3,316 +6,4,302~6,6,302 +3,7,126~5,7,126 +2,2,189~5,2,189 +2,6,190~2,8,190 +3,8,294~5,8,294 +9,2,183~9,3,183 +6,6,135~7,6,135 +2,0,161~4,0,161 +4,7,50~5,7,50 +9,1,296~9,4,296 +2,2,267~4,2,267 +6,0,297~8,0,297 +2,6,215~2,9,215 +6,9,283~6,9,283 +2,5,10~2,7,10 +0,2,232~3,2,232 +9,4,10~9,7,10 +0,7,145~0,8,145 +4,2,232~5,2,232 +7,2,27~7,5,27 +6,4,48~6,4,51 +7,6,144~7,8,144 +7,7,36~9,7,36 +6,6,223~6,6,224 +4,0,197~7,0,197 +6,7,36~6,9,36 +6,5,105~6,5,106 +2,4,2~4,4,2 +0,7,209~1,7,209 +7,9,129~9,9,129 +1,4,264~1,6,264 +9,8,194~9,8,196 +1,1,303~2,1,303 +9,4,223~9,6,223 +4,0,244~4,0,246 +0,3,282~0,5,282 +5,0,275~5,2,275 +0,2,130~0,4,130 +7,1,276~7,3,276 +1,7,225~1,8,225 +0,4,261~0,7,261 +9,5,41~9,5,44 +5,3,287~5,3,289 +6,8,312~8,8,312 +2,5,43~3,5,43 +8,5,65~8,5,66 +1,0,306~1,0,307 +2,2,195~2,3,195 +3,7,263~5,7,263 +2,0,192~2,2,192 +9,2,269~9,4,269 +6,2,265~9,2,265 +4,9,11~6,9,11 +5,2,286~5,2,288 +6,6,58~6,9,58 +5,4,165~5,7,165 +2,7,138~2,9,138 +5,2,134~5,4,134 +5,6,57~5,8,57 +1,8,290~1,9,290 +2,1,287~2,1,287 +5,1,68~7,1,68 +5,1,237~5,2,237 +6,0,165~6,2,165 +4,2,222~4,3,222 +1,0,181~1,2,181 +8,1,29~8,3,29 +3,1,21~3,3,21 +5,0,171~5,0,174 +7,2,73~7,4,73 +1,3,207~4,3,207 +8,3,77~8,4,77 +9,2,32~9,2,32 +1,2,217~1,2,218 +3,5,146~3,7,146 +3,5,309~3,7,309 +5,7,149~7,7,149 +6,6,210~7,6,210 +2,6,134~2,8,134 +7,1,61~7,2,61 +5,6,317~9,6,317 +5,7,47~5,8,47 +0,4,153~3,4,153 +1,3,280~1,6,280 +9,0,1~9,2,1 +2,2,230~5,2,230 +0,9,186~0,9,190 +9,5,54~9,5,56 +3,1,239~3,4,239 +4,7,71~6,7,71 +9,4,220~9,6,220 +0,8,82~0,8,84 +1,7,317~4,7,317 +6,0,65~6,1,65 +1,6,20~2,6,20 +3,6,257~5,6,257 +3,3,218~3,3,219 +8,0,175~8,2,175 +0,1,80~2,1,80 +3,5,216~5,5,216 +8,6,286~8,6,289 +8,0,196~8,1,196 +7,6,211~7,6,214 +1,3,150~1,5,150 +5,1,305~5,2,305 +3,1,194~4,1,194 +0,0,142~0,2,142 +7,4,90~7,4,92 +4,3,125~7,3,125 +1,6,104~1,6,104 +9,7,294~9,8,294 +0,0,173~0,3,173 +4,5,129~6,5,129 +6,3,106~7,3,106 +5,0,278~8,0,278 +0,5,81~0,7,81 +7,1,132~9,1,132 +8,2,151~9,2,151 +9,1,185~9,4,185 +9,6,125~9,6,128 +5,6,248~5,6,249 +3,1,176~3,2,176 +5,3,72~5,5,72 +3,5,205~3,5,207 +5,4,170~8,4,170 +6,9,234~9,9,234 +0,0,261~0,3,261 +2,5,196~2,7,196 +3,1,212~5,1,212 +6,2,8~8,2,8 +2,5,169~5,5,169 +6,2,240~9,2,240 +4,7,7~6,7,7 +1,0,247~1,1,247 +3,1,67~3,2,67 +8,5,18~8,8,18 +4,2,20~4,5,20 +2,8,41~4,8,41 +6,6,281~6,9,281 +2,0,241~2,2,241 +8,7,13~8,9,13 +9,0,87~9,2,87 +2,4,3~2,7,3 +1,9,132~4,9,132 +2,1,24~4,1,24 +5,6,270~7,6,270 +5,8,296~7,8,296 +2,2,239~2,5,239 +8,8,305~8,8,308 +0,0,192~0,4,192 +9,3,258~9,5,258 +6,0,173~9,0,173 +6,6,221~9,6,221 +0,8,119~3,8,119 +2,5,30~2,7,30 +2,3,158~4,3,158 +9,4,60~9,4,63 +4,9,110~6,9,110 +2,6,316~6,6,316 +7,6,276~9,6,276 +2,7,27~2,7,29 +5,6,51~5,7,51 +4,0,113~5,0,113 +0,4,68~0,4,70 +2,0,50~5,0,50 +8,3,206~8,4,206 +6,1,62~9,1,62 +4,2,114~4,4,114 +6,0,95~6,2,95 +5,9,62~5,9,63 +6,7,188~7,7,188 +5,3,166~5,4,166 +2,9,198~4,9,198 +0,1,26~2,1,26 +2,0,211~4,0,211 +3,2,271~6,2,271 +1,0,304~4,0,304 +4,9,147~7,9,147 +5,0,41~6,0,41 +6,2,163~6,4,163 +7,5,195~9,5,195 +6,6,53~6,9,53 +0,9,239~3,9,239 +1,0,3~1,0,3 +1,7,307~3,7,307 +0,4,302~1,4,302 +0,1,167~0,2,167 +0,6,219~0,9,219 +0,3,180~2,3,180 +7,6,264~7,8,264 +0,5,252~0,6,252 +5,2,30~7,2,30 +9,0,94~9,1,94 +2,4,209~2,7,209 +1,0,283~1,2,283 +3,3,156~5,3,156 +4,3,318~4,6,318 +4,6,93~4,7,93 +0,9,317~3,9,317 +0,0,194~3,0,194 +7,7,198~8,7,198 +0,0,8~2,0,8 +0,3,182~2,3,182 +1,7,23~2,7,23 +3,3,152~3,3,154 +8,1,106~8,3,106 +4,2,156~6,2,156 +9,1,176~9,2,176 +9,7,86~9,9,86 +1,7,82~2,7,82 +7,0,170~9,0,170 +4,8,42~5,8,42 +1,4,62~1,5,62 +0,1,128~0,3,128 +1,4,142~4,4,142 +5,9,19~7,9,19 +7,3,230~9,3,230 +1,3,175~1,5,175 +5,8,271~6,8,271 +9,9,152~9,9,154 +3,6,120~3,8,120 +6,3,90~6,6,90 +2,3,251~4,3,251 +1,8,50~3,8,50 +1,4,196~1,7,196 +4,8,12~4,8,15 +1,2,95~3,2,95 +2,3,257~4,3,257 +8,1,270~8,4,270 +2,8,284~3,8,284 +5,8,162~7,8,162 +2,3,303~2,6,303 +5,1,25~5,3,25 +7,2,49~8,2,49 +4,0,23~5,0,23 +3,1,41~5,1,41 +2,0,249~4,0,249 +1,1,137~4,1,137 +0,6,159~2,6,159 +2,1,56~2,2,56 +4,2,283~6,2,283 +7,5,148~7,7,148 +3,1,66~3,4,66 +8,3,33~9,3,33 +6,0,234~8,0,234 +0,4,202~0,6,202 +6,6,31~6,9,31 +8,4,113~8,6,113 +1,6,199~1,6,199 +1,8,278~2,8,278 +6,2,93~6,4,93 +9,6,196~9,6,199 +3,1,192~3,2,192 +2,6,5~3,6,5 +1,5,76~4,5,76 +8,3,149~8,3,151 +4,8,38~6,8,38 +4,7,287~4,8,287 +1,4,104~2,4,104 +3,8,75~6,8,75 +2,5,63~2,8,63 +9,1,195~9,1,197 +0,4,183~3,4,183 +4,4,283~6,4,283 +7,6,294~7,7,294 +3,2,145~5,2,145 +6,5,257~6,6,257 +9,2,4~9,3,4 +4,1,289~5,1,289 +5,5,172~7,5,172 +3,7,27~3,9,27 +4,5,213~4,8,213 +5,8,168~7,8,168 +3,0,231~6,0,231 +4,9,61~7,9,61 +7,8,7~8,8,7 +4,7,59~4,8,59 +5,9,44~6,9,44 +1,6,185~3,6,185 +6,4,20~9,4,20 +3,4,301~3,6,301 +0,8,288~3,8,288 +4,1,192~4,3,192 +7,5,219~9,5,219 +9,2,203~9,4,203 +2,4,293~2,6,293 +1,1,136~1,3,136 +6,4,47~7,4,47 +8,0,84~8,2,84 +1,6,228~1,6,228 +4,8,124~6,8,124 +8,3,159~8,5,159 +4,2,85~7,2,85 +5,1,262~5,2,262 +4,7,195~6,7,195 +2,7,68~4,7,68 +4,0,22~4,3,22 +6,8,276~6,8,278 +0,8,41~1,8,41 +8,1,108~8,1,108 +0,7,43~2,7,43 +8,2,15~8,5,15 +1,9,307~3,9,307 +5,6,188~7,6,188 +1,4,61~1,5,61 +8,6,303~8,8,303 +0,2,164~2,2,164 +5,7,186~5,9,186 +1,2,233~1,5,233 +8,3,73~8,4,73 +4,8,80~4,8,80 +3,2,235~3,5,235 +0,2,64~2,2,64 +2,7,225~3,7,225 +1,7,223~4,7,223 +3,4,284~3,4,287 +7,4,175~7,7,175 +8,1,109~8,1,111 +1,2,58~1,4,58 +5,3,78~5,3,80 +3,4,58~5,4,58 +5,8,72~8,8,72 +9,6,53~9,7,53 +5,2,273~7,2,273 +6,7,221~7,7,221 +4,2,298~4,2,299 +9,1,243~9,2,243 +2,7,127~2,8,127 +8,0,235~8,0,235 +0,1,212~0,3,212 +6,0,43~6,2,43 +5,2,56~5,2,59 +2,7,144~2,9,144 +7,4,50~9,4,50 +5,5,93~9,5,93 +7,5,273~7,8,273 +3,7,56~3,9,56 +5,7,127~5,9,127 +5,2,238~6,2,238 +2,3,17~3,3,17 +5,2,136~6,2,136 +4,3,261~4,3,264 +2,8,279~2,9,279 +2,0,145~2,2,145 +5,6,111~5,7,111 \ No newline at end of file diff --git a/2023/rust/aoc/src/day22/mod.rs b/2023/rust/aoc/src/day22/mod.rs new file mode 100644 index 0000000..e922c54 --- /dev/null +++ b/2023/rust/aoc/src/day22/mod.rs @@ -0,0 +1,137 @@ +use anyhow::Result; +use itertools::Itertools; +use slotmap::{DefaultKey, SecondaryMap, SlotMap}; +use std::{ + collections::{HashMap, HashSet}, + fs, + path::Path, + usize, +}; + +pub fn part1(input_path: &Path) -> Result { + let input = fs::read_to_string(input_path)?; + let tree = build_tree(&input); + Ok(tree + .bricks + .keys() + .filter(|k| can_disintegrate(&tree, &k)) + .count() as i64) +} + +pub fn part2(input_path: &Path) -> Result { + let input = fs::read_to_string(input_path)?; + let _ = input; + Ok(42) +} + +#[derive(Debug)] +struct Tree { + bricks: SlotMap, + supports: SecondaryMap>, + supported_by: SecondaryMap>, +} + +fn build_tree(input: &str) -> Tree { + let mut bricks_to_drop = input + .lines() + .map(|line| { + let mut it = line.split('~'); + let start = it + .next() + .unwrap() + .split(',') + .map(|s| s.parse::().unwrap()) + .collect::>(); + let end = it + .next() + .unwrap() + .split(',') + .map(|s| s.parse::().unwrap()) + .collect::>(); + [[start[0], end[0]], [start[1], end[1]], [start[2], end[2]]] + }) + .sorted_by_key(|b| b[2][0]) + .collect::>(); + + let mut bricks = SlotMap::new(); + let mut supports = SecondaryMap::new(); + let mut supported_by = SecondaryMap::new(); + + let mut heights: HashMap = HashMap::new(); + while let Some(brick_to_drop) = bricks_to_drop.pop() { + let brick = ( + brick_to_drop[0], + brick_to_drop[1], + brick_to_drop[2][1] - brick_to_drop[2][0] + 1, + ); + let brick_key = bricks.insert(brick.clone()); + + let mut supported_by_keys = vec![]; + let mut supported_at_height = 0usize; + for (other_brick_key, other_brick_height) in heights.iter() { + let other_brick = bricks.get(*other_brick_key).unwrap(); + if overlaps(brick.0, other_brick.0) && overlaps(brick.1, other_brick.1) { + if *other_brick_height > supported_at_height { + supported_by_keys = vec![*other_brick_key]; + supported_at_height = *other_brick_height; + } else if *other_brick_height == supported_at_height { + supported_by_keys.push(*other_brick_key) + } + } + } + + for key in supported_by_keys.iter() { + supports + .entry(*key) + .unwrap() + .or_insert(HashSet::new()) + .insert(brick_key); + } + supported_by.insert( + brick_key, + supported_by_keys.into_iter().collect::>(), + ); + heights.insert(brick_key, supported_at_height + brick.2); + } + + Tree { + bricks, + supports, + supported_by, + } +} + +fn overlaps(a: [usize; 2], b: [usize; 2]) -> bool { + a[0] <= b[1] && b[0] <= a[1] +} + +fn can_disintegrate(tree: &Tree, brick_key: &DefaultKey) -> bool { + match &tree.supports.get(*brick_key) { + Some(supported) => supported.iter().all(|k| tree.supported_by[*k].len() > 1), + None => true, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn test_part1() { + let input_path = Path::new("./src/day22/sample"); + assert_eq!(part1(input_path).unwrap(), 5); + + let input_path = Path::new("./src/day22/input"); + assert_eq!(part1(input_path).unwrap(), 42); + } + + #[test] + fn test_part2() { + let input_path = Path::new("./src/day22/sample"); + assert_eq!(part2(input_path).unwrap(), 42); + + let input_path = Path::new("./src/day22/input"); + assert_eq!(part2(input_path).unwrap(), 42); + } +} diff --git a/2023/rust/aoc/src/day22/sample b/2023/rust/aoc/src/day22/sample new file mode 100644 index 0000000..158a407 --- /dev/null +++ b/2023/rust/aoc/src/day22/sample @@ -0,0 +1,7 @@ +1,0,1~1,2,1 +0,0,2~2,0,2 +0,2,3~2,2,3 +0,0,4~0,2,4 +2,0,5~2,2,5 +0,1,6~2,1,6 +1,1,8~1,1,9 \ No newline at end of file diff --git a/2023/rust/aoc/src/lib.rs b/2023/rust/aoc/src/lib.rs index 530577a..8a98cb4 100644 --- a/2023/rust/aoc/src/lib.rs +++ b/2023/rust/aoc/src/lib.rs @@ -18,4 +18,5 @@ pub mod day17; pub mod day18; pub mod day19; pub mod day20; +pub mod day22; mod utils;