tangled
alpha
login
or
join now
hauleth.dev
/
advent-of-code
3
fork
atom
this repo has no description
3
fork
atom
overview
issues
pulls
pipelines
chore: cleanup 11.2022
hauleth.dev
3 years ago
85f5d0ae
c6fcc17c
+3
-11
1 changed file
expand all
collapse all
unified
split
2022
day11.livemd
+3
-11
2022/day11.livemd
···
206
207
def run(%__MODULE__{} = mb, rounds, calming) do
208
1..rounds
209
-
|> Enum.reduce(mb, fn r, mb ->
210
# IO.inspect(r, label: :round)
211
round(mb, calming)
212
end)
···
214
|> Enum.map(& &1.passes)
215
|> Enum.sort(:desc)
216
|> Enum.take(2)
217
-
|> Enum.reduce(&*/2)
218
end
219
220
defp round(%__MODULE__{} = mb, calming) do
···
239
<!-- livebook:{"output":true} -->
240
241
```
242
-
warning: variable "r" is unused (if the variable is not meant to be used, prefix it with an underscore)
243
-
2022/day11.livemd#cell:wtmu5fny2ud5f5f6xet6khgysonm2y3n:17: MonkeyBusiness.run/3
244
-
245
-
```
246
-
247
-
<!-- livebook:{"output":true} -->
248
-
249
-
```
250
-
{:module, MonkeyBusiness, <<70, 79, 82, 49, 0, 0, 21, ...>>, {:lcm, 2}}
251
```
252
253
## Task 1
···
206
207
def run(%__MODULE__{} = mb, rounds, calming) do
208
1..rounds
209
+
|> Enum.reduce(mb, fn _, mb ->
210
# IO.inspect(r, label: :round)
211
round(mb, calming)
212
end)
···
214
|> Enum.map(& &1.passes)
215
|> Enum.sort(:desc)
216
|> Enum.take(2)
217
+
|> Enum.product()
218
end
219
220
defp round(%__MODULE__{} = mb, calming) do
···
239
<!-- livebook:{"output":true} -->
240
241
```
242
+
{:module, MonkeyBusiness, <<70, 79, 82, 49, 0, 0, 20, ...>>, {:lcm, 2}}
0
0
0
0
0
0
0
0
243
```
244
245
## Task 1