I hereby claim:
- I am joseph-lozano on github.
- I am jetpackjoe (https://keybase.io/jetpackjoe) on keybase.
- I have a public key whose fingerprint is A806 77F7 C40B 1039 9695 29D0 C954 1E5B B4ED B32C
To claim this, I am signing this object:
require 'pry' | |
# Extend Integers for prime number methods | |
class Integer < Numeric | |
def prime? | |
2.upto((self**0.5).to_i) { |n| return false if self % n == 0 } | |
true | |
end | |
def next_prime | |
next_prime = self + 1 |
I hereby claim:
To claim this, I am signing this object:
def flatten(arr, output = []) | |
raise "Input must be array. Usage: flatten(arr)" unless arr.class == Array | |
arr.each do |el| | |
if el.class == Array | |
flatten(el, output) | |
else | |
output << el | |
end | |
end | |
output |
defmodule Flatten do | |
@spec flatten(List.t()) :: List.t() | |
def flatten([]), do: [] | |
def flatten([head | tail]) when is_list(head), do: flatten(head) ++ flatten(tail) | |
def flatten([head | tail]), do: [head | flatten(tail)] | |
def flatten(_), do: raise("argument must be a list") | |
end | |
ExUnit.start() |
# Setup build image | |
FROM elixir:1.10.4-alpine AS builder | |
# Install build dependencies | |
RUN apk update && \ | |
apk add --no-cache \ | |
bash \ | |
build-base \ | |
curl \ | |
git \ |
defmodule MontyHall do | |
defstruct [:doors, :hidden] | |
def play(door_count) do | |
game = new(door_count) | |
pick = :crypto.rand_uniform(1, door_count + 1) | |
with_revealed_doors = first_move(game, pick) | |
{action, new_pick} = | |
case Enum.random([:switch, :dont]) do |