trackler 2.2.1.9 → 2.2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/CONTRIBUTING.md +1 -1
- data/problem-specifications/TOPICS.txt +1 -0
- data/tracks/coffeescript/config/maintainers.json +15 -0
- data/tracks/coldfusion/config/maintainers.json +6 -0
- data/tracks/coq/config/maintainers.json +15 -0
- data/tracks/cpp/config/maintainers.json +25 -0
- data/tracks/delphi/config.json +1 -0
- data/tracks/delphi/config/maintainers.json +1 -1
- data/tracks/delphi/docs/SNIPPET.txt +14 -0
- data/tracks/ecmascript/config.json +711 -300
- data/tracks/elisp/config/maintainers.json +15 -0
- data/tracks/elm/config/maintainers.json +25 -0
- data/tracks/erlang/exercises/triangle/test/triangle_tests.erl +3 -3
- data/tracks/fortran/config/maintainers.json +15 -0
- data/tracks/go/config.json +3 -1
- data/tracks/go/config/maintainers.json +3 -1
- data/tracks/go/docs/ABOUT.md +3 -3
- data/tracks/groovy/config.json +1 -3
- data/tracks/groovy/config/maintainers.json +15 -0
- data/tracks/groovy/exercises/grains/Grains.groovy +9 -0
- data/tracks/groovy/exercises/grains/GrainsSpec.groovy +43 -0
- data/tracks/groovy/exercises/grains/README.md +1 -1
- data/tracks/groovy/exercises/word-count/Phrase.groovy +10 -0
- data/tracks/groovy/exercises/word-count/PhraseSpec.groovy +47 -0
- data/tracks/groovy/exercises/word-count/README.md +1 -1
- data/tracks/haxe/config/maintainers.json +6 -0
- data/tracks/idris/config/maintainers.json +15 -0
- data/tracks/java/CONTRIBUTING.md +1 -1
- data/tracks/java/exercises/series/src/example/java/Series.java +7 -9
- data/tracks/julia/config.json +12 -0
- data/tracks/julia/config/exercise_readme.go.tmpl +2 -0
- data/tracks/julia/exercises/anagram/README.md +1 -0
- data/tracks/julia/exercises/atbash-cipher/README.md +1 -0
- data/tracks/julia/exercises/bob/README.md +1 -0
- data/tracks/julia/exercises/collatz-conjecture/README.md +34 -0
- data/tracks/julia/exercises/collatz-conjecture/collatz-conjecture.jl +0 -0
- data/tracks/julia/exercises/collatz-conjecture/example.jl +14 -0
- data/tracks/julia/exercises/collatz-conjecture/runtests.jl +11 -0
- data/tracks/julia/exercises/complex-numbers/README.md +1 -0
- data/tracks/julia/exercises/custom-set/README.md +1 -0
- data/tracks/julia/exercises/difference-of-squares/README.md +1 -0
- data/tracks/julia/exercises/etl/README.md +1 -0
- data/tracks/julia/exercises/gigasecond/README.md +1 -0
- data/tracks/julia/exercises/hamming/README.md +1 -0
- data/tracks/julia/exercises/hello-world/README.md +1 -0
- data/tracks/julia/exercises/isogram/README.md +1 -0
- data/tracks/julia/exercises/leap/README.md +1 -0
- data/tracks/julia/exercises/luhn/README.md +1 -0
- data/tracks/julia/exercises/nucleotide-count/README.md +1 -0
- data/tracks/julia/exercises/pangram/README.md +1 -0
- data/tracks/julia/exercises/pascals-triangle/README.md +1 -0
- data/tracks/julia/exercises/raindrops/README.md +1 -0
- data/tracks/julia/exercises/rna-transcription/README.md +1 -0
- data/tracks/julia/exercises/robot-name/README.md +1 -0
- data/tracks/julia/exercises/roman-numerals/README.md +1 -0
- data/tracks/julia/exercises/rotational-cipher/README.md +1 -0
- data/tracks/julia/exercises/scrabble-score/README.md +1 -0
- data/tracks/julia/exercises/secret-handshake/README.md +1 -0
- data/tracks/julia/exercises/sieve/README.md +1 -0
- data/tracks/julia/exercises/transpose/README.md +1 -0
- data/tracks/julia/exercises/trinary/README.md +1 -0
- data/tracks/julia/exercises/word-count/README.md +1 -0
- data/tracks/lisp/.travis.yml +1 -1
- data/tracks/lisp/config/maintainers.json +5 -5
- data/tracks/mips/config.json +22 -22
- data/tracks/mips/config/maintainers.json +15 -0
- data/tracks/nim/config/maintainers.json +15 -0
- data/tracks/php/config/maintainers.json +35 -0
- data/tracks/plsql/config/maintainers.json +15 -0
- data/tracks/powershell/config/maintainers.json +25 -0
- data/tracks/prolog/config/maintainers.json +15 -0
- data/tracks/python/config/maintainers.json +25 -0
- data/tracks/racket/config/maintainers.json +35 -0
- data/tracks/scheme/config/maintainers.json +25 -0
- data/tracks/sml/config.json +1 -1
- data/tracks/sml/exercises/accumulate/{test_accumulate.sml → test.sml} +0 -0
- data/tracks/sml/exercises/allergies/{test_allergies.sml → test.sml} +0 -0
- data/tracks/sml/exercises/anagram/{test_anagram.sml → test.sml} +0 -0
- data/tracks/sml/exercises/binary/{test_binary.sml → test.sml} +0 -0
- data/tracks/sml/exercises/flatten-array/{test_flatten_array.sml → test.sml} +0 -0
- data/tracks/sml/exercises/hamming/{test_hamming.sml → test.sml} +0 -0
- data/tracks/sml/exercises/nth-prime/{test_nth_prime.sml → test.sml} +0 -0
- data/tracks/sml/exercises/raindrops/{test_raindrops.sml → test.sml} +0 -0
- data/tracks/vbnet/config/maintainers.json +15 -0
- metadata +39 -12
- data/tracks/groovy/exercises/grains/GrainsTest.groovy +0 -45
- data/tracks/groovy/exercises/word-count/PhraseTest.groovy +0 -69
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maintainers": [
|
|
3
|
+
{
|
|
4
|
+
"github_username": "yurrriq",
|
|
5
|
+
"show_on_website": false,
|
|
6
|
+
"alumnus": false,
|
|
7
|
+
"name": null,
|
|
8
|
+
"bio": null,
|
|
9
|
+
"link_text": null,
|
|
10
|
+
"link_url": null,
|
|
11
|
+
"avatar_url": null
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maintainers": [
|
|
3
|
+
{
|
|
4
|
+
"github_username": "tgecho",
|
|
5
|
+
"show_on_website": false,
|
|
6
|
+
"alumnus": false,
|
|
7
|
+
"name": null,
|
|
8
|
+
"bio": null,
|
|
9
|
+
"link_text": null,
|
|
10
|
+
"link_url": null,
|
|
11
|
+
"avatar_url": null
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"github_username": "bewatts",
|
|
15
|
+
"show_on_website": false,
|
|
16
|
+
"alumnus": false,
|
|
17
|
+
"name": null,
|
|
18
|
+
"bio": null,
|
|
19
|
+
"link_text": null,
|
|
20
|
+
"link_url": null,
|
|
21
|
+
"avatar_url": null
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
|
|
25
|
+
}
|
|
@@ -43,14 +43,14 @@ triangles_with_negative_sides_are_illegal_test() ->
|
|
|
43
43
|
?assertMatch({error, "all side lengths must be positive"},
|
|
44
44
|
?TESTED_MODULE:kind(3, 4, -5)).
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
triangles_violating_triangle_inequality_are_illegal_test() ->
|
|
47
47
|
?assertMatch({error, "side lengths violate triangle inequality"},
|
|
48
48
|
?TESTED_MODULE:kind(1, 1, 3)).
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
triangles_violating_triangle_inequality_are_illegal_2_test() ->
|
|
51
51
|
?assertMatch({error, "side lengths violate triangle inequality"},
|
|
52
52
|
?TESTED_MODULE:kind(2, 4, 2)).
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
triangles_violating_triangle_inequality_are_illegal_3_test() ->
|
|
55
55
|
?assertMatch({error, "side lengths violate triangle inequality"},
|
|
56
56
|
?TESTED_MODULE:kind(7, 3, 2)).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maintainers": [
|
|
3
|
+
{
|
|
4
|
+
"github_username": "sentientmonkey",
|
|
5
|
+
"show_on_website": false,
|
|
6
|
+
"alumnus": false,
|
|
7
|
+
"name": null,
|
|
8
|
+
"bio": null,
|
|
9
|
+
"link_text": null,
|
|
10
|
+
"link_url": null,
|
|
11
|
+
"avatar_url": null
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
|
|
15
|
+
}
|
data/tracks/go/config.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"language": "Go",
|
|
3
3
|
"active": true,
|
|
4
|
+
"blurb": "Go is a compiled, open source programming language with a small, consistent syntax, a powerful standard library, and fantastic tooling. It's a great fit for web backends and command-line tools.",
|
|
4
5
|
"ignore_pattern": "example(?!.*test)",
|
|
5
6
|
"foregone": [
|
|
6
7
|
"space-age",
|
|
@@ -328,6 +329,7 @@
|
|
|
328
329
|
"unlocked_by": null,
|
|
329
330
|
"difficulty": 3,
|
|
330
331
|
"topics": [
|
|
332
|
+
"Cryptography",
|
|
331
333
|
"Filtering",
|
|
332
334
|
"Strings",
|
|
333
335
|
"Text Formatting",
|
|
@@ -822,8 +824,8 @@
|
|
|
822
824
|
"difficulty": 3,
|
|
823
825
|
"topics": [
|
|
824
826
|
"Algorithms",
|
|
827
|
+
"Cryptography",
|
|
825
828
|
"Interfaces",
|
|
826
|
-
"Security",
|
|
827
829
|
"Strings",
|
|
828
830
|
"Transforming"
|
|
829
831
|
]
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"github_username": "kytrinyx",
|
|
15
|
-
"alumnus": true
|
|
15
|
+
"alumnus": true,
|
|
16
|
+
"name": "Katrina Owen",
|
|
17
|
+
"bio": "I love Go for its simplicity and consistency. I also appreciate how hard the Go project is working to make the ecosystem welcoming to newcomers. I no longer maintain the Go track, but still maintain the Go tooling on Exercism."
|
|
16
18
|
},
|
|
17
19
|
{
|
|
18
20
|
"github_username": "petertseng",
|
data/tracks/go/docs/ABOUT.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
Fans of Go (called *gophers*) describe Go as having the expressiveness of dynamic languages like Python or Ruby, with the performance of compiled languages like C or C++.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The language is open source, and was started by engineers at Google. It's written using a C-style syntax, has statically typed variables, manages memory using garbage collection, and is compiled into stand-alone executables.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Go is noted for the [concurrent programming features](https://golang.org/doc/effective_go.html#concurrency) built into the language core, the networking packages in the standard library ([such as a web server](https://golang.org/pkg/net/http/)), fast compilation and execution speed. Its simple, minimalistic and consistent language design make for a delightful experience, while the abundant and thoughtful tooling addresses traditional problems such as [consistent formatting](https://godoc.org/github.com/golang/go/src/cmd/gofmt) and [documentation](http://godoc.org/golang.org/x/tools/cmd/godoc).
|
|
6
6
|
|
|
7
7
|
The home page for Go is [golang.org](https://golang.org/), and there is an excellent interactive tutorial at [tour.golang.org](https://tour.golang.org/).
|
data/tracks/groovy/config.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maintainers": [
|
|
3
|
+
{
|
|
4
|
+
"github_username": "Dispader",
|
|
5
|
+
"show_on_website": false,
|
|
6
|
+
"alumnus": false,
|
|
7
|
+
"name": null,
|
|
8
|
+
"bio": null,
|
|
9
|
+
"link_text": null,
|
|
10
|
+
"link_url": null,
|
|
11
|
+
"avatar_url": null
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
|
2
|
+
import spock.lang.*
|
|
3
|
+
|
|
4
|
+
class GrainsSpec extends Specification {
|
|
5
|
+
|
|
6
|
+
@Shared
|
|
7
|
+
def grains = new Grains()
|
|
8
|
+
|
|
9
|
+
def 'square of 1' () {
|
|
10
|
+
expect: 1 == grains.square(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
def 'square of 2' () {
|
|
14
|
+
expect: 2 == grains.square(2)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def 'square of 3' () {
|
|
18
|
+
expect: 4 == grains.square(3)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def 'square of 4' () {
|
|
23
|
+
expect: 8 == grains.square(4)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def 'square of 16' () {
|
|
27
|
+
expect: 32768 == grains.square(16)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// GROOVY-7129
|
|
31
|
+
def 'square of 32' () {
|
|
32
|
+
expect: 2147483648 == grains.square(32)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def 'square of 64' () {
|
|
36
|
+
expect: 9223372036854775808 == grains.square(64)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def 'test total' () {
|
|
40
|
+
expect:
|
|
41
|
+
18446744073709551615 == grains.total()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -33,7 +33,7 @@ For installation and learning resources, refer to the
|
|
|
33
33
|
Run the tests by executing the test script.
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
-
$ groovy ./
|
|
36
|
+
$ groovy ./GrainsSpec.groovy
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@Grab('org.spockframework:spock-core:1.0-groovy-2.4')
|
|
2
|
+
import spock.lang.*
|
|
3
|
+
|
|
4
|
+
class PhraseSpec extends Specification {
|
|
5
|
+
|
|
6
|
+
def 'count one word' () {
|
|
7
|
+
expect: ["word":1] == new Phrase("word").wordCount()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
def 'count one of each' () {
|
|
11
|
+
expect: ["one":1,"of":1,"each":1] == new Phrase("one of each").wordCount()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def 'count multiple occurrences' () {
|
|
15
|
+
def phrase = new Phrase("one fish two fish red fish blue fish")
|
|
16
|
+
expect: ["one":1,"fish":4,"two":1,"red":1,"blue":1] == phrase.wordCount()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def 'count everything only once' () {
|
|
20
|
+
def phrase = new Phrase("all the kings horses and all the kings men")
|
|
21
|
+
// call wordCount 2x to verify
|
|
22
|
+
phrase.wordCount()
|
|
23
|
+
expect: ["all":2,"the":2,"kings":2,"horses":1,"and":1,"men":1] == phrase.wordCount()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def 'ignore punctuation' () {
|
|
27
|
+
def phrase = new Phrase('car : carpet as java : javascript!!&@$%^&')
|
|
28
|
+
expect: ["car":1,"carpet":1,"as":1,"java":1,"javascript":1] == phrase.wordCount()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def 'handle no spaces' () {
|
|
32
|
+
expect: ["one":1,"two":1,"three":1] == new Phrase("one,two,three").wordCount()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def 'include numbers' () {
|
|
36
|
+
expect: ["testing":2,"1":1,"2":1] == new Phrase("testing, 1, 2 testing").wordCount()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def 'normalize case' () {
|
|
40
|
+
expect: ["go":3] == new Phrase("go Go GO").wordCount()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def 'handle apostrophes' () {
|
|
44
|
+
def phrase = new Phrase("First: don't laugh. Then: don't cry.")
|
|
45
|
+
expect: ["first":1,"don't":2,"laugh":1,"then":1,"cry":1] == phrase.wordCount()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -18,7 +18,7 @@ For installation and learning resources, refer to the
|
|
|
18
18
|
Run the tests by executing the test script.
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
$ groovy ./
|
|
21
|
+
$ groovy ./PhraseSpec.groovy
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maintainers": [
|
|
3
|
+
{
|
|
4
|
+
"github_username": "yurrriq",
|
|
5
|
+
"show_on_website": false,
|
|
6
|
+
"alumnus": false,
|
|
7
|
+
"name": null,
|
|
8
|
+
"bio": null,
|
|
9
|
+
"link_text": null,
|
|
10
|
+
"link_url": null,
|
|
11
|
+
"avatar_url": null
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
|
|
15
|
+
}
|
data/tracks/java/CONTRIBUTING.md
CHANGED
|
@@ -37,7 +37,7 @@ To submit a fix for an existing exercise or port an exercise to Java with the le
|
|
|
37
37
|
|
|
38
38
|
1. **Ensure you have the basic Java tooling installed:** JDK 1.8+, an editor and Gradle 2.x.
|
|
39
39
|
|
|
40
|
-
(see [exercism.io: Installing Java](http://exercism.io/languages/java/
|
|
40
|
+
(see [exercism.io: Installing Java](http://exercism.io/languages/java/installation))
|
|
41
41
|
- **Setup a branch on a fork of [exercism/java](https://github.com/exercism/java) on your computer.**
|
|
42
42
|
|
|
43
43
|
See [GitHub Help: Forking](https://help.github.com/articles/fork-a-repo/). Use those instructions (in conjunction with the [Git Basics doc](https://github.com/exercism/docs/blob/master/contributing/git-basics.md)) to:
|
|
@@ -4,21 +4,19 @@ import java.util.Arrays;
|
|
|
4
4
|
import java.util.List;
|
|
5
5
|
import java.util.stream.Collectors;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class Series {
|
|
8
8
|
|
|
9
9
|
private final int digitsSize;
|
|
10
10
|
private List<Integer> digits;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
this.digits = Arrays
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.map(digit -> Integer.parseInt(digit))
|
|
17
|
-
.collect(Collectors.toList());
|
|
12
|
+
Series(String string) {
|
|
13
|
+
this.digits = Arrays.stream(string.split(""))
|
|
14
|
+
.map(Integer::parseInt)
|
|
15
|
+
.collect(Collectors.toList());
|
|
18
16
|
this.digitsSize = this.digits.size();
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
List<List<Integer>> slices(int num) {
|
|
22
20
|
if (num > this.digitsSize) {
|
|
23
21
|
throw new IllegalArgumentException("Slice size is too big.");
|
|
24
22
|
}
|
|
@@ -32,7 +30,7 @@ public class Series {
|
|
|
32
30
|
return result;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
List<Integer> getDigits() {
|
|
36
34
|
return digits;
|
|
37
35
|
}
|
|
38
36
|
|
data/tracks/julia/config.json
CHANGED
|
@@ -218,6 +218,18 @@
|
|
|
218
218
|
"sorting"
|
|
219
219
|
]
|
|
220
220
|
},
|
|
221
|
+
{
|
|
222
|
+
"uuid": "43f1dc63-0412-9a80-49ba-b620f4bbfccac2731e4",
|
|
223
|
+
"slug": "collatz-conjecture",
|
|
224
|
+
"core": false,
|
|
225
|
+
"unlocked_by": null,
|
|
226
|
+
"difficulty": 2,
|
|
227
|
+
"topics": [
|
|
228
|
+
"mathematics",
|
|
229
|
+
"control-flow (exceptions)",
|
|
230
|
+
"control-flow (if-else statements)"
|
|
231
|
+
]
|
|
232
|
+
},
|
|
221
233
|
{
|
|
222
234
|
"uuid": "9474a13b-09c1-4e4d-90e3-1a14fde5eb62",
|
|
223
235
|
"slug": "bob",
|
|
@@ -9,5 +9,6 @@ Given `"listen"` and a list of candidates like `"enlists" "google"
|
|
|
9
9
|
|
|
10
10
|
Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup)
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
## Submitting Incomplete Solutions
|
|
13
14
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -30,5 +30,6 @@ things based on word boundaries.
|
|
|
30
30
|
|
|
31
31
|
Wikipedia [http://en.wikipedia.org/wiki/Atbash](http://en.wikipedia.org/wiki/Atbash)
|
|
32
32
|
|
|
33
|
+
|
|
33
34
|
## Submitting Incomplete Solutions
|
|
34
35
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -14,5 +14,6 @@ He answers 'Whatever.' to anything else.
|
|
|
14
14
|
|
|
15
15
|
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)
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
## Submitting Incomplete Solutions
|
|
18
19
|
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Collatz Conjecture
|
|
2
|
+
|
|
3
|
+
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
|
|
4
|
+
|
|
5
|
+
Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is
|
|
6
|
+
odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely.
|
|
7
|
+
The conjecture states that no matter which number you start with, you will
|
|
8
|
+
always reach 1 eventually.
|
|
9
|
+
|
|
10
|
+
Given a number n, return the number of steps required to reach 1.
|
|
11
|
+
|
|
12
|
+
## Examples
|
|
13
|
+
Starting with n = 12, the steps would be as follows:
|
|
14
|
+
|
|
15
|
+
0. 12
|
|
16
|
+
1. 6
|
|
17
|
+
2. 3
|
|
18
|
+
3. 10
|
|
19
|
+
4. 5
|
|
20
|
+
5. 16
|
|
21
|
+
6. 8
|
|
22
|
+
7. 4
|
|
23
|
+
8. 2
|
|
24
|
+
9. 1
|
|
25
|
+
|
|
26
|
+
Resulting in 9 steps. So for input n = 12, the return value would be 9.
|
|
27
|
+
|
|
28
|
+
## Source
|
|
29
|
+
|
|
30
|
+
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)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Submitting Incomplete Solutions
|
|
34
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|