Code Monkey home page Code Monkey logo

elixir's Introduction

Exercism Elixir Track

GitHub branch checks state GitHub contributors GitHub commit activity

Exercism Exercises in Elixir

Setup

The exercises currently target Elixir versions from 1.11 to 1.16 and Erlang/OTP versions from 21 to 26. Detailed installation instructions can be found at https://elixir-lang.org/install.html. We recommend using the asdf version manager to manage multiple Elixir versions.

Testing


It is recommended to test BEFORE submitting a PR. It will test your submission, ensure that the repository builds as a whole, and help guard against unintentional, unrelated changes.


Test Exercises

To test all of the exercises against their example solution, you can run bin/test_exercises.sh:

$ ./bin/test_exercises.sh
Testing: accumulate Pass
Testing: acronym Pass
...
Testing: zipper Pass
--------------------------------------------------------------------------------
93/93 tests passed.

This will take some time.

To only test some exercises, run:

$ ./bin/test_exercises.sh word-count zebra-puzzle
Testing: word-count Pass
Testing: zebra-puzzle Pass
--------------------------------------------------------------------------------
2/2 tests passed.

Dialyzer

To run dialyzer on all exercises, run ./bin/dialyzer_check.sh. It might take a really long time the first time you run it. It will also be run for you by Github Actions as part of the PR check.

Code and document formatting

To check formatting of all exercises and all documents, run ./bin/check_formatting.sh. It will also be run for you by Github Actions as part of the PR check.

Track linting

configlet is an Exercism-wide tool for working with tracks. You can download it by running:

$ ./bin/fetch-configlet

Run its lint command to verify if all exercises have all the necessary files and if config files are correct:

$ ./bin/configlet lint

The `exercises.practice.slug` value is `transpose πŸ™‚`, but it must be a lowercase and kebab-case string:
/Users/angelika/Documents/exercism/elixir/config.json

Configlet detected at least one problem.
For more information on resolving the problems, please see the documentation:
https://github.com/exercism/docs/blob/main/building/configlet/lint.md

Contributing Guide

If you want to help maintain the Elixir track, take a look at HELLO.md. You will find there an introduction to all the possible ways you can help us.

If you want to contribute to this repository specifically, please see CONTRIBUTING.md.

elixir's People

Contributors

andrewtimberlake avatar angelikatyborska avatar antoine-duchenet avatar bernardoamc avatar br1ght0ne avatar cohen-carlisle avatar dalexj avatar dependabot[bot] avatar devonestes avatar doggettck avatar ee7 avatar elasticdog avatar erikschierboom avatar exercism-bot avatar fireproofsocks avatar henrik avatar jiegillet avatar jimmbraddock avatar jwarwick avatar kytrinyx avatar lauramcastro avatar lpil avatar martinsvalin avatar neenjaw avatar parkerl avatar petehuang avatar pminten avatar robphoenix avatar rubysolo avatar teapane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elixir's Issues

Bob is inconsistent with other languages

Posted by @meantime in exercism.io:

The instructions for the Bob assignment say:

He answers 'Whoa, chill out!' if you yell at him.
However, some of the language test cases check for "Woah" (note that the 'h' has moved to the end)

The difference exists in Objective-C, PERL5, OCaml, Elixir, and Clojure

Add helpful information to the SETUP.md

The contents of the SETUP.md file gets included in
the README.md that gets delivered when a user runs the exercism fetch
command from their terminal.

At the very minimum, it should contain a link to the relevant
language-specific documentation on
help.exercism.io.

It would also be useful to explain in a generic way how to run the tests.
Remember that this file will be included with all the problems, so it gets
confusing if we refer to specific problems or files.

Some languages have very particular needs in terms of the solution: nested
directories, specific files, etc. If this is the case here, then it would be
useful to explain what is expected.


Thanks, @tejasbubane for suggesting that we add this documentation everywhere.
See exercism.io#2198.

Palindrome instruction unclear

The palindrome instruction in the README seems to fall short compares to instructions from other exercises I've seen so far.

  1. The description of palindrome product could use a few more examples. It should also clarify that there may be more than 1 solution to the product like with 9 => [[1, 9], [3, 3]], and that all single digits were considered palindrome products. Perhaps a link to the wiki page would be good?
  2. The expected resulting format wasn't given. I had figured out after reading the test suite that it was doing Dict.keys on my results.
  3. The test was not obvious either. The first test was looking at the last element in my result checking that I had return palindrome value for 9 but the need the format I should return so that somehow I ended up with key 9 being the last element wasn't obvious.

Just wanted to drop a note in case someone else agrees and it's worthwhile. I could probably do it sometimes in the future when I'm not too busy too.

Thanks!

Verify that nothing links to help.exercism.io

The old help site was deprecated in December 2015. We now have content that is displayed on the main exercism.io website, under each individual language on http://exercism.io/languages.

The content itself is maintained along with the language track itself, under the docs/ directory.

We decided on this approach since the maintainers of each individual language track are in the best position to review documentation about the language itself or the language track on Exercism.

Please verify that nothing in docs/ refers to the help.exercism.io site. It should instead point to http://exercism.io/languages/:track_id (at the moment the various tabs are not linkable, unfortunately, we may need to reorganize the pages in order to fix that).

Also, some language tracks reference help.exercism.io in the SETUP.md file, which gets included into the README of every single exercise in the track.

We may also have referenced non-track-specific content that lived on help.exercism.io. This content has probably been migrated to the Contributing Guide of the x-common repository. If it has not been migrated, it would be a great help if you opened an issue in x-common so that we can remedy the situation. If possible, please link to the old article in the deprecated help repository.

If nothing in this repository references help.exercism.io, then this can safely be closed.

Running doctest's

Would it be possible to run doctest's along the regular ones, but when exercises are pulled from exercism.io? (as opposed to working with mix within this project)

Currently, the mix setup from the root of this project isn't added to exercism's elixir folder, and executing e.g. elixir phone_number_test.exs executes only the ones in the test file.

The only workaround I have for now is:

  • compile the main module, e.g. elixirc phone_number.exs
  • add doctest Phone beneath use ExUnit.Case, async: true in test file
    Then, running elixir phone_number_test.exs runs the doctest as well.

The only problem with this is that one needs to execute the compile step for every change to the main module. I guess this could be made into a small script, e.g run_tests.sh.

elixirc main_module.exs && elixir test_module.exs

Since I'm new to Elixir, I don't know if this would work in all cases (Windows, ...?). What do you think? P.S. I'd be glad to PR this if above suggestion is on the right track.

Related issues: #23
Less, but still related issues: #96, #47

typespecs and dialyzer

I really like the typespecs which are provided with the module skeletons.

But sometimes they don't get updated in the example and/or the skelleton when tests are updated to expect new types, also I do often forget to update them when I catch for the newest version of the tests.

Is there an easy and hassle free way to actually do a check against the specs without wrapping everything into a mix-project?

And if so, could this be used in CI also?

Can we mention it in the README as a part of running the tests?

forth.exs template custom errors stubbed incorrectly

the def exception functions seem like they should be def message functions, which is the function used in the example

I dont know a ton on the working of defining custom errors in elixir so I cant give much more information.

Meetup - 5th Monday

There is an interesting edge case in the meetup problem:
some months have five Mondays.

March of 2015 has five Mondays (the fifth being March 30th), whereas
February of 2015 does not, and so should produce an error.


Thanks, @JKesMc9tqIQe9M for pointing out the edge case.
See exercism.io#2142.

Fail the build on trailing whitespace?

There's one exercise (OCR numbers) where trailing whitespace is necessary for the test data, but (a) I don't know if that exercise is implemented, and (b) maybe we could put the actual test data in external files with a different file extension.

If we make sure not to screw up any exercises, though, we could fail the build if there's trailing whitespace by sticking this in the travis file.

- "! git grep ' $' -- \\*.exs"

"point-mutations" is deprecated in favor of hamming

This happened a while back, and it was for really weird legacy reasons.

I've since fixed the underlying issues that caused the problem, but for consistency
it would be nice to rename point-mutation to hamming, so that all the tracks are using
the same exercise name.

Once the problem has been renamed, I can run a script on the website to point people's
existing point-mutations solutions to the new hamming exercise so that they'll be able
to review solutions to hamming, and people who solve the new hamming exercise can see
all the old ones.

[binary-search]: Current implementation is much less efficient than a linear search

The conclusion in the subject is from a very brief look at the code.

In general, you can't search a linked list, in a way that is more efficient than a linear search, due to its nature.

To access the element in the middle, you have to iterate the first half of the list completely, while dooing this recursively, you might even read over the searched element multiple times.

Also when splitting the list you do again fly over the first half (even doing a copy when the element is there!)

I already had a similar discussion in a project which aims on implementing some prominent CS datastructures and algorithms over it, perhaps you want to take a read at sashaafm/exads#14 and then deprecate/remove this exercise from this track.

Clarification of README in sublist problem

Given that there is a set progression of exercises there is some tendency in the users to almost "inherit" guidance from previous exercises if the current exercise appears to be an expansion of the previous.

For example, the previous exercise "list-ops" had the explicit instruction:
"Implement a series of basic list operations, without using existing functions."

When the next exercise is another list operations (specifically, sublist) there is some confusion as to whether there is an expectation for the users to write all methods from first principles or use the built-in list operators.

[custom-set] example and test suite diverge

The tests do check for Inspect as foolows:

  test "inspect" do
    assert inspect(CustomSet.new) == "%CustomSet{list: []}"
    assert inspect(CustomSet.new([1,3,2])) == "%CustomSet{list: [1, 2, 3]}"
    assert inspect(CustomSet.new(["A",:b,?C])) == "%CustomSet{list: [67, :b, \"A\"]}"
  end

While the example implementation does implement Inspect as follows:

  def inspect(s, opts) do
    concat ["#<CustomSet ", to_doc(CustomSet.to_list(s), opts), ">"]
  end

Before commit 9222be9 the example and the test matched.

Changes to Custom Set tests

We recently rewrote the test suite for Custom Set. Since this track implements Custom Set, please take a look at the new custom_set.json file and see if your track should update its implementation or tests.

The new test suite reorders tests so that students can get to green quickly. It also reduces the number of tests so that students can focus on solving the interesting edge cases.

More details on this change are available in the pull request

Make Hamming conform to official definition

From issue exercism/exercism#1867

Wikipedia says the Hamming distance is not defined for strings of different length.

I am not saying the problems cannot be different, but for such a well-defined concept it would make sense to stick to one definition, especially when the READMEs provide so little information about what is expected from the implementation.

Let's clean this up so that we're using the official definition.

Change use of Dict to Map per Elixir 1.2 soft deprecation

Per the 1.2 changelog https://github.com/elixir-lang/elixir/blob/v1.2.0/CHANGELOG.md

atbash-cipher/example.exs
28:    Dict.get(@key, character, character)

etl/etl.exs
10:  @spec transform(Dict.t) :: map()

etl/example.exs
12:      |> Dict.to_list

forth/example.exs
98:          do_eval(%{s | defs: Dict.put(s.defs, w, ws), input: r})

minesweeper/example.exs
34:        Dict.update(acc, c1, 1, &(&1+1))

nucleotide-count/dna.exs
29:  @spec histogram([char]) :: Dict.t

palindrome-products/example.exs
22:    Dict.update(dict, product,

palindrome-products/palindrome_products_test.exs
16:    assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 9
23:    assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 9009
30:    assert (palindromes |> Dict.keys |> Enum.sort |> hd) == 121
37:    assert (palindromes |> Dict.keys |> Enum.sort |> List.last) == 906609
44:    assert (palindromes |> Dict.keys |> Enum.sort |> hd) == 10201

parallel-letter-frequency/example.exs
33:    |> Enum.reduce(%{}, fn c, acc -> Dict.update(acc, c, 1, &(&1+1)) end)
38:      Dict.merge(acc, d, fn _, a, b -> a+b end)

parallel-letter-frequency/frequency.exs
9:  @spec frequency([String.t], pos_integer) :: Dict.t

test/test_helper.exs
6:|> Dict.get("problems")

word-count/example.exs
21:    Dict.update(counts, word, 1, &(&1 + 1))

Add test case for Prime Factors

Consider add one more test case for Prime Factors

test "10000000055" do
  assert PrimeFactors.factors_for(10000000055) == [5, 2000000011]
end

With my first iteration, it took 44189.1ms to pass this test. So need to tweak the solution to get this test pass in a decent time. I think it would serve a good test case to make your solution more optimized.

Updated tests for the Custom Set problem

In order to reduce the amount of code required to pass incremental tests (assuming that users pass tests starting from the top), the order of the tests was modified slightly.

Since this track implements Custom Set, please take a look at the new custom-set.json file and see if your track should update its tests.

If you do need to update your tests, please refer to this issue in your PR. That helps us see which tracks still need to update their tests.

If your track is already up to date, go ahead and close this issue.

More details on this change are available in exercism/problem-specifications#257.

Implement Elixir exercises

Copied from exercism/exercism#156 /cc @rubysolo @pminten

This is a placeholder issue for keeping track of porting assignments to Elixir, or noting why they may not be applicable.

  • bob
  • word-count
  • anagram
  • beer-song
  • nucleotide-count
  • rna-transcription
  • point-mutations
  • phone-number
  • grade-school
  • leap
  • etl
  • meetup
  • space-age
  • grains
  • gigasecond
  • triangle
  • scrabble-score
  • roman-numerals
  • binary
  • prime-factors
  • raindrops
  • allergies
  • strain
  • atbash-cipher
  • accumulate
  • nth-prime
  • palindrome-products
  • sum-of-multiples
  • bank-account
  • minesweeper
  • parallel-letter-frequency
  • zipper
  • sieve
  • pythagorean-triplet
  • difference-of-squares
  • largest-series-product
  • queen-attack
  • saddle-points
  • ocr-numbers
  • pascals-triangle
  • say
  • crypto-square
  • trinary
  • simple-cipher
  • octal
  • luhn
  • pig-latin
  • series
  • secret-handshake
  • linked-list
  • wordy
  • hexadecimal
  • kindergarden-garden
  • binary-search-tree
  • matrix
  • robot (robot-movement has no example, robot-pivots has no example)

not applicable

  • robot-name (Elixir is immutable)

Bob has only one test per default?

I find it a bit strange to have only one test for bob which is running when you run the tests. And the exercise can be completed with the default case of the condition.

Is this on purpose?

scrabble-score: replace 'multibillionaire' with 'oxyphenbutazone'

The word multibillionaire is too long for the scrabble board. Oxyphenbutazone, on the other hand, is legal.

Please verify that there is no test for multibillionaire in the scrabble-score in this track. If the word is included in the test data, then it should be replaced with oxyphenbutazone. Remember to check the case (if the original is uppercase, then the replacement also should be).

If multibillionaire isn't used, then this issue can safely be closed.

See exercism/problem-specifications#86

rna-transcription: don't transcribe both ways

I can't remember the history of this, but we ended up with a weird non-biological thing in the RNA transcription exercise, where some test suites also have tests for transcribing from RNA back to DNA. This makes no sense.

If this track does have tests for the reverse transcription, we should remove them, and also simplify the reference solution to match.

If this track doesn't have any tests for RNA->DNA transcription, then this issue can be closed.

See exercism/problem-specifications#148

triangle: incorrect test in some tracks

Please check if there's a test that states that a triangle with sides 2, 4, 2 is invalid. The triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side. If this doesn't affect this track, go ahead and just close the issue.

Grade school exercise will not properly sort grades beyond :grade_9

I'm afraid we've swapped on bug for another. Using atoms for the grade levels has the unfortunate side effect that sorting is done like a string rather than a number. That means :grade_11 will come before :grade_2. See parkerl@ce61f42

This fails:

1) test sort school by grade and by student name (SchoolTest)
     grade_school_test.exs:55
     Assertion with == failed
     code: expected == actual
     lhs:  [grade_3: ["Kyle"], grade_4: ["Bart", "Christopher", "Jennifer"], grade_6: ["Kareem"], grade_11: ["John"]]
     rhs:  [grade_11: ["John"], grade_3: ["Kyle"], grade_4: ["Bart", "Christopher", "Jennifer"], grade_6: ["Kareem"]]
     stacktrace:
       grade_school_test.exs:72

My thought would be to revert to the original implementation but have sort return a list of two tuples with the grade and names, [{1, ["John"]}]. This would leave most of the original exercise intact and only change the api of the function with the bug.

I'm sorry I was too slow to get this review prepared before the PR was merged. My bad.

\cc @bordeltabernacle

gigasecond: use times (not dates) for inputs and outputs

A duration of a gigasecond should be measured in seconds, not
days.

The gigasecond problem has been implemented in a number of languages,
and this issue has been generated for each of these language tracks.
This may already be fixed in this track, if so, please make a note of it
and close the issue.

There has been some discussion about whether or not gigaseconds should
take daylight savings time into account, and the conclusion was "no", since
not all locations observe daylight savings time.

Move exercises to subdirectory

The problems api (x-api) now supports having exercises collected in a subdirectory
named exercises.

That is to say that instead of having a mix of bin, docs, and individual exercises,
we can have bin, docs, and exercises in the root of the repository, and all
the exercises collected in a subdirectory.

In other words, instead of this:

x{TRACK_ID}/
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ bin
β”‚Β Β  └── fetch-configlet
β”œβ”€β”€ bowling
β”‚Β Β  β”œβ”€β”€ bowling_test.ext
β”‚Β Β  └── example.ext
β”œβ”€β”€ clock
β”‚Β Β  β”œβ”€β”€ clock_test.ext
β”‚Β Β  └── example.ext
β”œβ”€β”€ config.json
└── docs
β”‚Β Β  β”œβ”€β”€ ABOUT.md
β”‚Β Β  └── img
... etc

we can have something like this:

x{TRACK_ID}/
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ bin
β”‚Β Β  └── fetch-configlet
β”œβ”€β”€ config.json
β”œβ”€β”€ docs
β”‚Β Β  β”œβ”€β”€ ABOUT.md
β”‚Β Β  └── img
β”œβ”€β”€ exercises
β”‚Β Β  β”œβ”€β”€ bowling
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ bowling_test.ext
β”‚Β Β  β”‚Β Β  └── example.ext
β”‚Β Β  └── clock
β”‚Β Β      β”œβ”€β”€ clock_test.ext
β”‚Β Β      └── example.ext
... etc

This has already been deployed to production, so it's safe to make this change whenever you have time.

Update the Elixir track to target version 1.2

We should update our target version to Elixir 1.2.

  • Update CI
  • Fix test failures
  • Update documentation
  • Clean up pipe warnings
#We are getting quite a few of these in the examples after the 1.2 upgrade

warning: you are piping into a function call without parentheses, which may be ambiguous. Please wrap the function you are piping into in parentheses. For example:

    foo 1 |> bar 2 |> baz 3

Should be written as:

    foo(1) |> bar(2) |> baz(3)

binary: improve tests for invalid numbers

We should have separate tests for:

  • alphabetic characters at the beginning of a valid binary number
  • alphabetic characters at the end of a valid binary number
  • alphabetic characters in the middle of an otherwise valid binary number
  • invalid digits (e.g. 2)

If the test suite for binary has test cases that cover these edge cases, this issue can safely be closed.

See exercism/problem-specifications#95

Change use of Set and HashSet to MapSet per the Elixir 1.2 changelog

Per https://github.com/elixir-lang/elixir/blob/v1.2.0/CHANGELOG.md

allergies/allergies_test.exs
77:    set = Enum.into(list, HashSet.new)
79:      |> Enum.into(HashSet.new)
80:      |> Set.equal?(set)
82:           "Expected a set with: #{inspect to_contain} got #{inspect set |> Set.to_list}"

custom-set/custom_set.exs
1:defmodule CustomSet do
2:  # This lets the compiler check that all Set callback functions have been
4:  @behaviour Set

custom-set/custom_set_test.exs
10:defmodule CustomSetTest do
13:  # Tip: to make your set work with the Set module be sure that your set value
14:  # is a tuple with as first element `CustomSet`. A record with tag `CustomSet`
19:    assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 2), CustomSet.new([1,3]))
20:    assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 4), CustomSet.new([1,2,3]))
21:    assert Set.equal?(Set.delete(CustomSet.new([3,2,1]), 2.0), CustomSet.new([1,2,3]))
26:    assert Set.equal?(
27:      Set.difference(CustomSet.new([1,2,3]), CustomSet.new([2,4])),
28:      CustomSet.new([1,3]))
29:    assert Set.equal?(
30:      Set.difference(CustomSet.new([1,2.0,3]), CustomSet.new([2,4])),
31:      CustomSet.new([1,2.0,3]))
36:    assert Set.disjoint?(CustomSet.new([1,2]), CustomSet.new([3,4]))
37:    refute Set.disjoint?(CustomSet.new([1,2]), CustomSet.new([2,3]))
38:    assert Set.disjoint?(CustomSet.new([1.0,2.0]), CustomSet.new([2,3]))
39:    assert Set.disjoint?(CustomSet.new, CustomSet.new)
44:    assert Set.equal?(Set.empty(CustomSet.new([1,2])), CustomSet.new)
45:    assert Set.equal?(Set.empty(CustomSet.new), CustomSet.new)
50:    assert Set.equal?(
51:      Set.intersection(CustomSet.new([:a, :b, :c]), CustomSet.new([:a, :c, :d])),
52:      CustomSet.new([:a, :c]))
53:    assert Set.equal?(
54:      Set.intersection(CustomSet.new([1, 2, 3]), CustomSet.new([1.0, 2.0, 3])),
55:      CustomSet.new([3]))
60:    assert Set.member?(CustomSet.new([1,2,3]), 2)
61:    assert Set.member?(CustomSet.new(1..3), 2)
62:    refute Set.member?(CustomSet.new(1..3), 2.0)
63:    refute Set.member?(CustomSet.new(1..3), 4)
68:    assert Set.equal?(
69:      Set.put(CustomSet.new([1,2,4]), 3),
70:      CustomSet.new([1,2,3,4]))
71:    assert Set.equal?(
72:      Set.put(CustomSet.new([1,2,3]), 3),
73:      CustomSet.new([1,2,3]))
74:    assert Set.equal?(
75:      Set.put(CustomSet.new([1,2,3]), 3.0),
76:      CustomSet.new([1,2,3,3.0]))
81:    assert Set.size(CustomSet.new) == 0
82:    assert Set.size(CustomSet.new([1,2,3])) == 3
83:    assert Set.size(CustomSet.new([1,2,3,2])) == 3
88:    assert Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([1,2,3]))
89:    assert Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([4,1,2,3]))
90:    refute Set.subset?(CustomSet.new([1,2,3]), CustomSet.new([4,1,3]))
91:    refute Set.subset?(CustomSet.new([1,2,3.0]), CustomSet.new([1,2,3,4]))
92:    assert Set.subset?(CustomSet.new, CustomSet.new([4,1,3]))
93:    assert Set.subset?(CustomSet.new, CustomSet.new)
98:    assert Enum.sort(Set.to_list(CustomSet.new)) == []
99:    assert Enum.sort(Set.to_list(CustomSet.new([3,1,2]))) == [1,2,3]
100:    assert Enum.sort(Set.to_list(CustomSet.new([3,1,2,1]))) == [1,2,3]
105:    assert Set.equal?(
106:      CustomSet.union(CustomSet.new([1,3]), CustomSet.new([2])),
107:      CustomSet.new([3,2,1]))
108:    assert Set.equal?(
109:      CustomSet.union(CustomSet.new([1,3]), CustomSet.new([2,3.0])),
110:      CustomSet.new([3.0,3,2,1]))
111:    assert Set.equal?(
112:      CustomSet.union(CustomSet.new([1,3]), CustomSet.new),
113:      CustomSet.new([3,1]))
114:    assert Set.equal?(
115:      CustomSet.union(CustomSet.new, CustomSet.new([2])),
116:      CustomSet.new([2]))
117:    assert Set.equal?(
118:      CustomSet.union(CustomSet.new, CustomSet.new),
119:      CustomSet.new([]))
124:    assert inspect(CustomSet.new) == "%CustomSet{list: []}"
125:    assert inspect(CustomSet.new([1,3,2])) == "%CustomSet{list: [1, 2, 3]}"
128:    assert inspect(CustomSet.new(["A",:b,?C])) == "%CustomSet{list: [67, :b, \"A\"]}"

[accumulate]: typespec vs. example implementation

According to the typespec given in the exercise-stub, I'd expect Accumulate.accumulate %{foo: :bar}, &(&1) beeing a valid call of the function, but such is not caovered by the tests, as well as the example implementation does as well only handle lists.

So either the @spec is wrong and should be changed towards a more proper @spec accumulate(list, (any -> any)) :: list or the example is wrong and another clause should be added (def accumulate(anything), fun) when not is_list(anything), do: anything |> Enum.into([]) |> accumulate(fun)) as well as some tests that do test some other Enumable.ts that are not lists.

`up` function not tested in zipper exercism

Zipper.up is never used in the zipper_text.exs but the stub for it in the example is still there. I can write a couple tests for it and send those in, unless somebody else wants to that knows more about the exercises than me

Elixir track difficulty curve of early exercises.

I'm currently making my way through the elixir track slowly, but some of the exercises (so far, as a newcomer) seem to occur later or earlier than I would expect.

A couple of examples:

Exercise 5: The list-ops exercise, using core language features to re-implement reduce, append, filter, count, concat, and map occurs before:
Exercise 12: Accumulate (Given a list and a function, apply the function to each list item and replace it with the function's return value.)

Exercise 10: Nucleotide-count (Counting occurrences of a character in a character list, raising exceptions based on invalid arguments, creating histogram of preset characters), occurs before
Exercise 11: rna-transcription (simple letter substitution).

I didn't see any open (or closed) issues about this, so thought I'd throw this out there for discussion. Thanks!

Accumulate's recursive function does not actually test recursive mapping

The test here:
https://github.com/exercism/xelixir/blob/master/exercises/accumulate/accumulate_test.exs#L35

Looks like its attempting to check that the accumulate/2 function will continue mapping if it encounters a list as one of the items in the list. This however is not true since the 2nd level of lists is just created in the anonymous function.

The test IMO should be more like:

chars = ~w(a b c)
nums  = ~w(1 2 3)
list = for c <- chars, num <- nums, do: c <> num
expected = [["A1", "A2", "A3"], ["B1", "B2", "B3"], ["C1", "C2", "C3"]]
assert Accumulate.accumulate(chars, &String.upcase/1) == expected

@JEG2 I belive you submitted this exercism

Delete configlet binaries from history?

I made a really stupid choice a while back to commit the cross-compiled
binaries for configlet (the tool that sanity-checks the config.json
against the implemented problems) into the repository itself.

Those binaries are HUGE, and every time they change the entire 4 or 5 megs get
recommitted. This means that cloning the repository takes a ridiculously long
time.

I've added a script that can be run on travis to grab the latest release from
the configlet repository (bin/fetch-configlet), and travis is set up to run
this now instead of using the committed binary.

I would really like to thoroughly delete the binaries from the entire git
history, but this will break all the existing clones and forks.

The commands I would run are:

# ensure this happens on an up-to-date master
git checkout master && git fetch origin && git reset --hard origin/master

# delete from history
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch bin/configlet-*' --prune-empty

# clean up
rm -rf .git/refs/original/
git reflog expire --all
git gc --aggressive --prune

# push up the new master, force override existing master branch
git push -fu origin master

If we do this everyone who has a fork will need to make sure that their master
is reset to the new upstream master:

git checkout master
git fetch upstream master
git reset --hard upstream/master
git push -fu origin master

We can at-mention (@) all the contributors and everyone who has a fork here in this
issue if we decide to do it.

The important question though, is: Is it worth doing?

Do you have any other suggestions of how to make sure this doesn't confuse people and break their
repository if we do proceed with this change?

Verify "Largest Series Product" exercise implementation

There was some confusion in this exercise due to the ambiguous use of the term consecutive in the README. This could be taken to mean contiguous, as in consecutive by position, or as in consecutive numerically. The the README has been fixed (exercism/problem-specifications#200).

Please verify that the exercise is implemented in this track correctly (that it finds series of contiguous numbers, not series of numbers that follow each other consecutively).

If it helps, the canonical inputs/outputs for the exercise can be found here:
https://github.com/exercism/x-common/blob/master/largest-series-product.json

If everything is fine, go ahead and just close this issue. If there's something to be done, then please describe the steps needed in order to close the issue.

HashDict.new doesn't take arguments

While doing the word-count exercise I noticed that all of the tests would fail with a ** (UndefinedFunctionError) undefined function: HashDict.new/1 message. I supposed this worked at some point. My Elixir version is 0.13.2.

My solution was to change every HashDict.new [{"foo", 1}] type line to Enum.into [{"foo", 1}], HashDict.new and then tests would run for the exercise. I'm new to Elixir so I don't know if there's a better way of setting up the test expectations.

Copy track icon into language track repository

Right now all of the icons used for the language tracks (which can be seen at http://exercism.io/languages) are stored in the exercism/exercism.io repository in public/img/tracks/. It would make a lot more sense to keep these images along with all of the other language-specific stuff in each individual language track repository.

There's a pull request that is adding support for serving up the track icon from the x-api, which deals with language-specific stuff.

In order to support this change, each track will need to

In other words, at the end of it you should have the following file:

./img/icon.png

See exercism/exercism#2925 for more details.

How to set up a local dev environment

See issue exercism/exercism#2092 for an overview of operation welcome contributors.


Provide instructions on how to contribute patches to the exercism test suites
and examples: dependencies, running the tests, what gets tested on Travis-CI,
etc.

The contributing document
in the x-api repository describes how all the language tracks are put
together, as well as details about the common metadata, and high-level
information about contributing to existing problems, or adding new problems.

The README here should be language-specific, and can point to the contributing
guide for more context.

From the OpenHatch guide:

Here are common elements of setting up a development environment you’ll want your guide to address:

Preparing their computer
Make sure they’re familiar with their operating system’s tools, such as the terminal/command prompt. You can do this by linking to a tutorial and asking contributors to make sure they understand it. There are usually great tutorials already out there - OpenHatch’s command line tutorial can be found here.
If contributors need to set up a virtual environment, access a virtual machine, or download a specific development kit, give them instructions on how to do so.
List any dependencies needed to run your project, and how to install them. If there are good installation guides for those dependencies, link to them.

Downloading the source
Give detailed instructions on how to download the source of the project, including common missteps or obstacles.

How to view/test changes
Give instructions on how to view and test the changes they’ve made. This may vary depending on what they’ve changed, but do your best to cover common changes. This can be as simple as viewing an html document in a browser, but may be more complicated.

Installation will often differ depending on the operating system of the contributor. You will probably need to create separate instructions in various parts of your guide for Windows, Mac and Linux users. If you only want to support development on a single operating system, make sure that is clear to users, ideally in the top-level documentation.

Pass explicit list of multiples in "Sum of Multiples" exercise rather than defaulting to 3 and 5

Hello, as part of exercism/problem-specifications#198 we'd like to make the sum of multiples exercise less confusing. Currently, the README specifies that if no multiples are given it should default to 3 and 5.

We'd like to remove this default, so that a list of multiples will always be specified by the caller. This makes the behavior explicit, avoiding surprising behavior and simplifying the problem.

Please make sure this track's tests for the sum-of-multiples problem do not expect such a default. Any tests that want to test behavior for multiples of [3, 5] should explicitly pass [3, 5] as the list of multiples.

After all tracks have completed this change, then exercism/problem-specifications#209 can be merged to remove the defaults from the README.

The reason we'd like this change to happen before changing the README is that it was very confusing for students to figure out the default behavior. It wasn't clear from simply looking at the tests that the default should be 3 and 5, as seen in exercism/exercism#2654, so some had to resort to looking at the example solutions (which aren't served by exercism fetch, so they have to find it on GitHub). It was added to the README to fix this confusion, but now we'd like to be explicit so we can remove the default line from the README.

You can find the common test data at https://github.com/exercism/x-common/blob/master/sum-of-multiples.json, in case that is helpful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.