Skip to content

Instantly share code, notes, and snippets.

@tfwright

tfwright/1.exs Secret

Created December 7, 2022 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfwright/1fa3cadf09601172a2c668cc105a1e93 to your computer and use it in GitHub Desktop.
Save tfwright/1fa3cadf09601172a2c668cc105a1e93 to your computer and use it in GitHub Desktop.
System.argv()
|> File.stream!([], 1)
|> Stream.with_index()
|> Enum.reduce_while([], fn {char, idx}, last_4 ->
last_4 =
last_4
|> Enum.concat([char])
|> Enum.slice(-4, 4)
if last_4 |> Enum.uniq() |> Enum.count() == 4 do
{:halt, idx + 1}
else
{:cont, last_4}
end
end)
|> IO.inspect
System.argv()
|> File.stream!([], 1)
|> Stream.with_index()
|> Enum.reduce_while([], fn {char, idx}, last_14 ->
last_14 =
last_14
|> Enum.concat([char])
|> Enum.slice(-14, 14)
if last_14 |> Enum.uniq() |> Enum.count() == 14 do
{:halt, idx + 1}
else
{:cont, last_14}
end
end)
|> IO.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment