September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,14 +1,20 @@
|
|||
defmodule Maximum do
|
||||
def triangle_path(text) do
|
||||
String.split(text, "\n", trim: true)
|
||||
|> Enum.map(fn line -> String.split(line) |> Enum.map(&String.to_integer(&1)) end)
|
||||
text
|
||||
|> String.split("\n", trim: true)
|
||||
|> Enum.map(fn line ->
|
||||
line
|
||||
|> String.split()
|
||||
|> Enum.map(&String.to_integer(&1))
|
||||
end)
|
||||
|> Enum.reduce([], fn x,total ->
|
||||
Enum.chunk([0]++total++[0], 2, 1)
|
||||
[0]++total++[0]
|
||||
|> Enum.chunk_every( 2, 1)
|
||||
|> Enum.map(&Enum.max(&1))
|
||||
|> Enum.zip(x)
|
||||
|> Enum.map(fn{a,b} -> a+b end)
|
||||
end)
|
||||
|> Enum.max
|
||||
|> Enum.max()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue