This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Traducao de Potigol para Scala usando http://github.com/potigol/potigol2scala | |
| fizz(numero: Inteiro) | |
| se numero mod 3 == 0 então | |
| "fizz" | |
| senão | |
| "{numero}" | |
| fim | |
| fim | |
| buzz(numero: Inteiro) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Advent1 do | |
| defp process(value, []), do: value | |
| defp process(value, [head | tail]) do | |
| process(value + String.to_integer(head), tail) | |
| end | |
| def do_it(filename) do | |
| {:ok, file} = File.read(filename) | |
| process(0, String.split(file, "\n")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Day1 do | |
| # This is a refactored version of José Valim's code available at https://gist.github.com/josevalim/ea4bf4fb5a009d33ff37f406e25c4749#file-part2-exs | |
| def make_file_stream(filename) do | |
| File.stream!(filename, [], :line) | |
| end | |
| def map_stream_to_integers(file_stream) do | |
| Stream.map(file_stream, fn line -> | |
| {integer, _leftover} = Integer.parse(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Day2 do | |
| def create_map([], map) do | |
| map | |
| end | |
| def create_map([head | tail], map) do | |
| create_map(tail, Map.update(map, head, 1, fn x -> x + 1 end)) | |
| end | |
| def process_string(string) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| youtube-dl https://www.twitch.tv/videos/343661380 --max-downloads 5 --continue --rate-limit 200k |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ohvflkatysoimjxbunazgwcdpr | |
| ohoflkctysmiqjxbufezgwcdpr | |
| ohvflkatysciqwxfunezgwcdpr | |
| fhvflyatysmiqjxbunazgwcdpr | |
| ohvhlkatysmiqjxbunhzgwcdxr | |
| ohvflbatykmiqjxbunezgscdpr | |
| ohvflkatasaiqjxbbnezgwcdpr | |
| ohvflkatyymiqjxrunetgwcdpr | |
| ohvflkatbsmiqhxbunezgwcdpw | |
| oheflkytysmiqjxbuntzgwcdpr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env escript | |
| % Run in shell with | |
| % escript university.erl | |
| -module(university). | |
| -export([average/2, average/3, professor_annual_salary/3, main/1]). | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Run in shell with | |
| # elixir university.exs | |
| defmodule University do | |
| def average(p1, p2), do: (p1 + p2) / 2 | |
| def average(p1, p2, p3), do: (p1 + p2 + p3) / 3 | |
| defp professor_base_salary(:adjunct, "US$"), do: 20000 | |
| defp professor_base_salary(:adjunct, "R$"), do: 30000 |