Skip to content

Commit

Permalink
Merge pull request JuliaLang#121 from exercism/0.7-compat
Browse files Browse the repository at this point in the history
Upgrade exercises to work in v0.7/v1.0
  • Loading branch information
SaschaMann authored Aug 9, 2018
2 parents 4c8153f + 671eed2 commit 418577b
Show file tree
Hide file tree
Showing 98 changed files with 294 additions and 97 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: julia

os:
- osx
- linux

julia:
- 0.7
- 1.0
- nightly
- 0.6

matrix:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia v0.7-alpha
julia v1.0
5 changes: 5 additions & 0 deletions config/exercise_readme.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
{{ . }}
{{ end }}

## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
6 changes: 3 additions & 3 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
To install Julia on your system follow the instructions on the [Julia Language Downloads page](http://julialang.org/downloads/).

[JuliaPro](http://juliacomputing.com/products/juliapro.html) includes the latest stable version of Julia, the Juno IDE, a debugger, a Jupyter notebook environment and many of the most popular Julia packages. It is a convenient way to install everything you will need to get started.
[JuliaPro](http://juliacomputing.com/products/juliapro.html) includes the latest stable version of Julia, the Juno IDE, a debugger, a Jupyter notebook environment and many of the most popular Julia packages. It is a convenient way to install everything you will need to get started. Please note that JuliaPro may contain outdated versions of packages or the language itself as it focuses on providing a stable installation.

For a local installation, it is recommended to use [Juno](http://junolab.org/). It's an IDE based on Atom and offers a powerful text editor as well as additional features for developing in Julia. Just follow the instructions on their website.
For a local installation, there are multiple IDEs/editor plugins available. The most popular ones are [Juno](http://junolab.org/) and the [VS Code extension](https://github.com/JuliaEditorSupport/julia-vscode). Just follow the instructions on their websites.

A simple way to get started with Julia without the need of a local installation is [JuliaBox](http://junolab.org/), which is an online IDE based on Jupyter notebooks. You just access it from your browser, login and you can start solving exercises.
A simple way to get started with Julia without the need of a local installation is [JuliaBox](https://juliabox.com/), which is an online IDE based on Jupyter notebooks. You just access it from your browser, login and you can start solving exercises.
5 changes: 5 additions & 0 deletions exercises/anagram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ Given `"listen"` and a list of candidates like `"enlists" "google"
Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/anagram/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("anagram.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/atbash-cipher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ things based on word boundaries.
Wikipedia [http://en.wikipedia.org/wiki/Atbash](http://en.wikipedia.org/wiki/Atbash)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
4 changes: 2 additions & 2 deletions exercises/atbash-cipher/example.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cipher(input::AbstractString) = map(x->isalpha(x)?Char(219-Int(x)):x, lowercase(filter(isalnum, input)))
encode(input::AbstractString) = join(matchall(r"(.{1,5})", cipher(input)), ' ')
cipher(input::AbstractString) = map(x->isletter(x) ? Char(219-Int(x)) : x, lowercase(filter(c -> isletter(c) || isnumeric(c), input)))
encode(input::AbstractString) = join(collect((m.match for m = eachmatch(r"(.{1,5})", cipher(input)))), ' ')
decode(input::AbstractString) = cipher(input)

2 changes: 1 addition & 1 deletion exercises/atbash-cipher/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("atbash-cipher.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/bob/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ Bob's conversational partner is a purist when it comes to written communication
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=06](http://pine.fm/LearnToProgram/?Chapter=06)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
6 changes: 3 additions & 3 deletions exercises/bob/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ issilence(stimulus::AbstractString) = isempty(stimulus)
isquestion(stimulus::AbstractString) = endswith(stimulus, '?')

function isshouting(stimulus::AbstractString)
all(isupper, stimulus) && return true
!any(isalpha, stimulus) && return false
all(isuppercase, stimulus) && return true
!any(isletter, stimulus) && return false

for c in stimulus
# ignore all non-letter chars
if isalpha(c) && !isupper(c)
if isletter(c) && !isuppercase(c)
return false
end
end
Expand Down
2 changes: 1 addition & 1 deletion exercises/bob/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("bob.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/collatz-conjecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ Resulting in 9 steps. So for input n = 12, the return value would be 9.
An unsolved problem in mathematics named after mathematician Lothar Collatz [https://en.wikipedia.org/wiki/3x_%2B_1_problem](https://en.wikipedia.org/wiki/3x_%2B_1_problem)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/collatz-conjecture/example.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function collatz(n::Integer)
n <= 0 && throw(DomainError())
n <= 0 && throw(DomainError("n must be strictly positive"))
iseven(n) ? div(n, 2) : 3n + 1
end

Expand Down
2 changes: 1 addition & 1 deletion exercises/collatz-conjecture/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("collatz-conjecture.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/complex-numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ Implement `jm` analogous to `im` so that `1 + 1jm == ComplexNumber(1, 1)`.
Wikipedia [https://en.wikipedia.org/wiki/Complex_number](https://en.wikipedia.org/wiki/Complex_number)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
4 changes: 2 additions & 2 deletions exercises/complex-numbers/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("complex-numbers.jl")

Expand Down Expand Up @@ -62,7 +62,7 @@ end
@testset "Complex exponential" begin
@test_skip exp(ComplexNumber(0, π)) ComplexNumber(-1, 0)
@test_skip exp(ComplexNumber(0, 0)) == ComplexNumber(1, 0)
@test_skip exp(ComplexNumber(1, 0)) ComplexNumber(e, 0)
@test_skip exp(ComplexNumber(1, 0)) ComplexNumber(, 0)
end

# Bonus B
Expand Down
5 changes: 5 additions & 0 deletions exercises/custom-set/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ Certain methods have a unicode operator equivalent. E.g. `intersect(CustomSet([1



## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
12 changes: 8 additions & 4 deletions exercises/custom-set/example.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base: AbstractSet, isempty, length, in, issubset, start, next, done,
import Base: AbstractSet, isempty, length, in, issubset, iterate,
push!, ==, copy, intersect!, intersect, union!, union

struct CustomSet{T} <: AbstractSet{T}
Expand All @@ -13,9 +13,13 @@ copy(s::CustomSet) = CustomSet(copy(s.elements))
push!(s::CustomSet, element) = push!(s.elements, element)

# Iterator protocol
start(::CustomSet) = 1
next(s::CustomSet, state) = s.elements[state], state + 1
done(s::CustomSet, state) = state > length(s)
function iterate(s::CustomSet, state=1)
if state > length(s)
return nothing
end

s.elements[state], state + 1
end

function disjoint(s1::CustomSet, s2::CustomSet)
for element in s1
Expand Down
2 changes: 1 addition & 1 deletion exercises/custom-set/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("custom-set.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/difference-of-squares/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ natural numbers is 3025 - 385 = 2640.
Problem 6 at Project Euler [http://projecteuler.net/problem=6](http://projecteuler.net/problem=6)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/difference-of-squares/example.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This uses reduce instead of sum because sum can't handle empty collections properly.
# There is no universal zero-element, so it has to be specified manually and cannot
# be determined automatically. Otherwise, n=0 will cause an error.
sum_of_squares(n::Int) = reduce(+, 0, i^2 for i in 1:n)
sum_of_squares(n::Int) = reduce(+, i^2 for i in 1:n; init=0)

# However, sum{T<:Real}(r::Range{T}) can handle "empty" ranges.
square_of_sum(n::Int) = sum(1:n)^2
Expand Down
2 changes: 1 addition & 1 deletion exercises/difference-of-squares/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("difference-of-squares.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/etl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ game while being scored at 4 in the Hawaiian-language version.
The Jumpstart Lab team [http://jumpstartlab.com](http://jumpstartlab.com)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/etl/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("etl.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/gigasecond/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ A gigasecond is 10^9 (1,000,000,000) seconds.
Chapter 9 in Chris Pine's online Learn to Program tutorial. [http://pine.fm/LearnToProgram/?Chapter=09](http://pine.fm/LearnToProgram/?Chapter=09)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 2 additions & 0 deletions exercises/gigasecond/example.jl
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
using Dates

add_gigasecond(date::DateTime) = date + Dates.Second(10^9)
3 changes: 2 additions & 1 deletion exercises/gigasecond/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Base.Test
using Test
using Dates

include("gigasecond.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/grains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ experiment make the code better? Worse? Did you learn anything from it?
JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
5 changes: 0 additions & 5 deletions exercises/grains/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,3 @@ function check_square_input(square)
square < 0 && throw(DomainError(square, "Negative square input is invalid."))
square > 64 && throw(DomainError(square, "Square input greater than 64 is invalid."))
end

if VERSION < v"0.7" # backwards compatibility
Base.DomainError(val) = DomainError()
Base.DomainError(val, msg) = DomainError()
end
2 changes: 1 addition & 1 deletion exercises/grains/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("grains.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/hamming/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ exception vs returning a special value) may differ between languages.
The Calculating Point Mutations problem at Rosalind [http://rosalind.info/problems/hamm/](http://rosalind.info/problems/hamm/)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/hamming/example.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function distance(s1::AbstractString, s2::AbstractString)
length(s1) != length(s2) && throw(ArgumentError("Sequences must have the same length"))
reduce(+, 0, a != b for (a, b) in zip(s1, s2))
reduce(+, a != b for (a, b) in zip(s1, s2); init=0)
end
2 changes: 1 addition & 1 deletion exercises/hamming/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("hamming.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ If everything goes well, you will be ready to fetch your first real exercise.
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/hello-world/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("hello-world.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/isbn-verifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@ Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (represen
Converting a string into a number and some basic processing utilizing a relatable real world example. [https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation](https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
4 changes: 2 additions & 2 deletions exercises/isbn-verifier/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ end
struct ISBN <: AbstractString
s::AbstractString

ISBN(s) = verify(s) ? new(replace(s, "-", "")) : throw(ArgumentError("invalid ISBN string: $s"))
ISBN(s) = verify(s) ? new(replace(s, "-" => "")) : throw(ArgumentError("invalid ISBN string: $s"))
end

string(s::ISBN) = s.s

function verify(s::AbstractString)
s = replace(s, "-", "")
s = replace(s, "-" => "")
chars = split(s, "")

length(chars) == 10 || return false
Expand Down
2 changes: 1 addition & 1 deletion exercises/isbn-verifier/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("isbn-verifier.jl")

Expand Down
5 changes: 5 additions & 0 deletions exercises/isogram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ The word *isograms*, however, is not an isogram, because the s repeats.
Wikipedia [https://en.wikipedia.org/wiki/Isogram](https://en.wikipedia.org/wiki/Isogram)


## Version compatibility
Julia 1.0 and 0.7 are the only supported Julia versions on Exercism.
For the most part, the test suites and solutions should be compatible to 0.6, but you will have to change `using Test` back to `using Base.Test` in the `runtests.jl` file.
Note that 0.7 and 1.0 are almost identical, except for deprecation warnings, which have all been removed in 1.0.

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
2 changes: 1 addition & 1 deletion exercises/isogram/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function isisogram(s::AbstractString)
chars = Char[]

for c in s
isalpha(c) || continue
isletter(c) || continue
c chars ? push!(chars, c) : return false
end

Expand Down
2 changes: 1 addition & 1 deletion exercises/isogram/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Base.Test
using Test

include("isogram.jl")

Expand Down
Loading

0 comments on commit 418577b

Please sign in to comment.