Skip to content

Commit db44c23

Browse files
committed
update some exercises
1 parent 72384b9 commit db44c23

35 files changed

+420
-93
lines changed

diffie-hellman/.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

diffie-hellman/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
diffie_hellman-*.tar
24+

diffie-hellman/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ particularly for enormous integers, but you might need :binary to decode it.
5454
Execute the tests with:
5555

5656
```bash
57-
$ elixir diffie_hellman_test.exs
57+
$ mix test
5858
```
5959

6060
### Pending tests

diffie-hellman/hints/hints.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
For generating random numbers, Erlang's `:rand.uniform` or `Enum.random` are
2+
good places to start.
3+
4+
`:math.pow |> round` can be used to find the power of a number, and `rem` for
5+
the modulus.
6+
7+
Neither of those works particularly well (or quickly) for very large integers.
8+
Cryptography generally makes use of numbers larger than 1024 bits. Erlang's
9+
:crypto module has a useful function for finding the modulus of a power,
10+
particularly for enormous integers, but you might need :binary to decode it.

diffie-hellman/mix.exs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
defmodule DiffieHellman.MixProject do
2+
use Mix.Project
3+
4+
def project do
5+
[
6+
app: :diffie_hellman,
7+
version: "0.1.0",
8+
# elixir: "~> 1.8",
9+
start_permanent: Mix.env() == :prod,
10+
deps: deps()
11+
]
12+
end
13+
14+
# Run "mix help compile.app" to learn about applications.
15+
def application do
16+
[
17+
extra_applications: [:logger, :crypto]
18+
]
19+
end
20+
21+
# Run "mix help deps" to learn about dependencies.
22+
defp deps do
23+
[
24+
# {:dep_from_hexpm, "~> 0.3.0"},
25+
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
26+
]
27+
end
28+
end

diffie-hellman/diffie_hellman_test.exs renamed to diffie-hellman/test/diffie_hellman_test.exs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
2-
Code.load_file("diffie_hellman.exs", __DIR__)
3-
end
4-
5-
ExUnit.start()
6-
ExUnit.configure(trace: true)
7-
81
defmodule DiffieHellmanTest do
92
use ExUnit.Case
103

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ExUnit.start()
2+
ExUnit.configure(exclude: :pending, trace: true)

gigasecond/.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

gigasecond/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Ignore .fetch files in case you like to edit your project deps locally.
14+
/.fetch
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
gigasecond-*.tar
24+

0 commit comments

Comments
 (0)