trackler 2.2.1.13 → 2.2.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/change/canonical-data.json +8 -1
  4. data/tracks/csharp/config.json +25 -26
  5. data/tracks/csharp/docs/SNIPPET.txt +7 -0
  6. data/tracks/csharp/exercises/house/Example.cs +5 -5
  7. data/tracks/csharp/exercises/house/House.cs +6 -1
  8. data/tracks/csharp/exercises/house/HouseTest.cs +208 -5
  9. data/tracks/csharp/exercises/phone-number/Example.cs +2 -1
  10. data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +8 -7
  11. data/tracks/csharp/exercises/rna-transcription/Example.cs +2 -1
  12. data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +4 -3
  13. data/tracks/csharp/exercises/say/SayTest.cs +20 -24
  14. data/tracks/csharp/exercises/sieve/Example.cs +6 -0
  15. data/tracks/csharp/exercises/sieve/SieveTest.cs +25 -17
  16. data/tracks/csharp/exercises/space-age/SpaceAgeTest.cs +19 -24
  17. data/tracks/csharp/exercises/sum-of-multiples/Example.cs +1 -1
  18. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiples.cs +1 -1
  19. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiplesTest.cs +48 -16
  20. data/tracks/csharp/generators/Exercises/House.cs +16 -0
  21. data/tracks/csharp/generators/Exercises/PhoneNumber.cs +3 -1
  22. data/tracks/csharp/generators/Exercises/RnaTranscription.cs +11 -1
  23. data/tracks/csharp/generators/Exercises/Say.cs +22 -0
  24. data/tracks/csharp/generators/Exercises/Sieve.cs +17 -0
  25. data/tracks/csharp/generators/Exercises/SpaceAge.cs +25 -0
  26. data/tracks/csharp/generators/Exercises/SumOfMultiples.cs +22 -0
  27. data/tracks/csharp/generators/Output/ValueFormatter.cs +4 -0
  28. data/tracks/dart/docs/ABOUT.md +21 -0
  29. data/tracks/ecmascript/README.md +1 -1
  30. data/tracks/ecmascript/config.json +15 -0
  31. data/tracks/ecmascript/exercises/proverb/README.md +63 -0
  32. data/tracks/ecmascript/exercises/proverb/example.js +23 -0
  33. data/tracks/ecmascript/exercises/proverb/package.json +69 -0
  34. data/tracks/ecmascript/exercises/proverb/proverb.spec.js +70 -0
  35. data/tracks/go/config.json +226 -226
  36. data/tracks/groovy/config.json +11 -0
  37. data/tracks/groovy/exercises/two-fer/Example.groovy +6 -0
  38. data/tracks/groovy/exercises/two-fer/README.md +62 -0
  39. data/tracks/groovy/exercises/two-fer/TwoFer.groovy +6 -0
  40. data/tracks/groovy/exercises/two-fer/TwoFerSpec.groovy +24 -0
  41. data/tracks/java/.travis.yml +2 -2
  42. data/tracks/java/bin/journey-test.sh +44 -1
  43. data/tracks/java/bin/run-journey-test-from-ci.sh +28 -0
  44. data/tracks/java/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
  45. data/tracks/java/exercises/bank-account/{HINTS.md → .meta/hints.md} +0 -0
  46. data/tracks/java/exercises/change/src/test/java/ChangeCalculatorTest.java +27 -2
  47. data/tracks/java/exercises/clock/{HINTS.md → .meta/hints.md} +0 -0
  48. data/tracks/java/exercises/hamming/{HINTS.md → .meta/hints.md} +0 -0
  49. data/tracks/java/exercises/hello-world/{HINTS.md → .meta/hints.md} +0 -0
  50. data/tracks/java/exercises/isogram/{HINTS.md → .meta/hints.md} +0 -0
  51. data/tracks/java/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
  52. data/tracks/java/exercises/pig-latin/src/example/java/PigLatinTranslator.java +17 -20
  53. data/tracks/java/exercises/simple-cipher/{HINTS.md → .meta/hints.md} +0 -0
  54. data/tracks/java/exercises/two-fer/{HINTS.md → .meta/hints.md} +0 -0
  55. data/tracks/kotlin/{docs/EXERCISE_README_INSERT.md → config/exercise-readme-insert.md} +0 -0
  56. data/tracks/kotlin/exercises/accumulate/README.md +1 -4
  57. data/tracks/kotlin/exercises/acronym/README.md +1 -1
  58. data/tracks/kotlin/exercises/all-your-base/README.md +1 -1
  59. data/tracks/kotlin/exercises/allergies/README.md +1 -1
  60. data/tracks/kotlin/exercises/anagram/README.md +1 -1
  61. data/tracks/kotlin/exercises/atbash-cipher/README.md +1 -1
  62. data/tracks/kotlin/exercises/bank-account/README.md +1 -1
  63. data/tracks/kotlin/exercises/beer-song/README.md +1 -1
  64. data/tracks/kotlin/exercises/binary-search/README.md +1 -1
  65. data/tracks/kotlin/exercises/binary/README.md +1 -1
  66. data/tracks/kotlin/exercises/bob/README.md +1 -1
  67. data/tracks/kotlin/exercises/bracket-push/README.md +1 -1
  68. data/tracks/kotlin/exercises/change/README.md +1 -1
  69. data/tracks/kotlin/exercises/clock/README.md +1 -1
  70. data/tracks/kotlin/exercises/collatz-conjecture/README.md +1 -1
  71. data/tracks/kotlin/exercises/complex-numbers/README.md +1 -1
  72. data/tracks/kotlin/exercises/diamond/README.md +1 -1
  73. data/tracks/kotlin/exercises/difference-of-squares/README.md +1 -1
  74. data/tracks/kotlin/exercises/etl/README.md +1 -1
  75. data/tracks/kotlin/exercises/flatten-array/README.md +1 -1
  76. data/tracks/kotlin/exercises/gigasecond/README.md +1 -1
  77. data/tracks/kotlin/exercises/grade-school/README.md +1 -1
  78. data/tracks/kotlin/exercises/grains/README.md +1 -1
  79. data/tracks/kotlin/exercises/hamming/README.md +1 -1
  80. data/tracks/kotlin/exercises/hello-world/README.md +1 -1
  81. data/tracks/kotlin/exercises/hexadecimal/README.md +1 -1
  82. data/tracks/kotlin/exercises/isogram/README.md +1 -1
  83. data/tracks/kotlin/exercises/largest-series-product/README.md +1 -1
  84. data/tracks/kotlin/exercises/leap/README.md +1 -1
  85. data/tracks/kotlin/exercises/linked-list/README.md +1 -1
  86. data/tracks/kotlin/exercises/list-ops/{HINTS.md → .meta/hints.md} +0 -0
  87. data/tracks/kotlin/exercises/list-ops/README.md +1 -1
  88. data/tracks/kotlin/exercises/luhn/README.md +1 -1
  89. data/tracks/kotlin/exercises/minesweeper/README.md +1 -1
  90. data/tracks/kotlin/exercises/nth-prime/README.md +1 -1
  91. data/tracks/kotlin/exercises/nucleotide-count/README.md +1 -1
  92. data/tracks/kotlin/exercises/pangram/README.md +1 -1
  93. data/tracks/kotlin/exercises/pascals-triangle/README.md +1 -1
  94. data/tracks/kotlin/exercises/perfect-numbers/README.md +1 -1
  95. data/tracks/kotlin/exercises/phone-number/README.md +1 -1
  96. data/tracks/kotlin/exercises/pig-latin/README.md +1 -1
  97. data/tracks/kotlin/exercises/prime-factors/README.md +1 -1
  98. data/tracks/kotlin/exercises/raindrops/README.md +1 -1
  99. data/tracks/kotlin/exercises/react/README.md +1 -1
  100. data/tracks/kotlin/exercises/rna-transcription/README.md +1 -1
  101. data/tracks/kotlin/exercises/robot-name/README.md +1 -1
  102. data/tracks/kotlin/exercises/robot-simulator/README.md +1 -1
  103. data/tracks/kotlin/exercises/roman-numerals/README.md +1 -1
  104. data/tracks/kotlin/exercises/saddle-points/README.md +1 -1
  105. data/tracks/kotlin/exercises/scrabble-score/README.md +1 -1
  106. data/tracks/kotlin/exercises/secret-handshake/README.md +1 -1
  107. data/tracks/kotlin/exercises/series/README.md +1 -1
  108. data/tracks/kotlin/exercises/sieve/README.md +1 -1
  109. data/tracks/kotlin/exercises/simple-cipher/README.md +2 -2
  110. data/tracks/kotlin/exercises/space-age/README.md +3 -2
  111. data/tracks/kotlin/exercises/spiral-matrix/README.md +1 -1
  112. data/tracks/kotlin/exercises/strain/README.md +1 -1
  113. data/tracks/kotlin/exercises/sublist/README.md +1 -1
  114. data/tracks/kotlin/exercises/sum-of-multiples/README.md +1 -1
  115. data/tracks/kotlin/exercises/triangle/README.md +1 -1
  116. data/tracks/kotlin/exercises/word-count/README.md +1 -1
  117. data/tracks/pony/exercises/atbash-cipher/example.pony +4 -3
  118. data/tracks/pony/exercises/beer-song/example.pony +10 -9
  119. data/tracks/pony/exercises/bob/example.pony +1 -1
  120. data/tracks/pony/exercises/difference-of-squares/example.pony +2 -2
  121. data/tracks/pony/exercises/hamming/example.pony +1 -1
  122. data/tracks/pony/exercises/hamming/test.pony +2 -2
  123. data/tracks/pony/exercises/leap/example.pony +1 -1
  124. data/tracks/pony/exercises/pascals-triangle/example.pony +2 -2
  125. data/tracks/pony/exercises/rna-transcription/test.pony +2 -2
  126. data/tracks/pony/exercises/roman-numerals/test.pony +2 -2
  127. data/tracks/python/config.json +22 -0
  128. data/tracks/python/docs/ABOUT.md +11 -3
  129. data/tracks/python/exercises/collatz-conjecture/README.md +61 -0
  130. data/tracks/python/exercises/collatz-conjecture/collatz_conjecture.py +2 -0
  131. data/tracks/python/exercises/collatz-conjecture/collatz_conjecture_test.py +32 -0
  132. data/tracks/python/exercises/collatz-conjecture/example.py +17 -0
  133. data/tracks/python/exercises/isogram/isogram.py +1 -1
  134. data/tracks/python/exercises/isogram/isogram_test.py +3 -0
  135. data/tracks/python/exercises/scale-generator/example.py +2 -0
  136. data/tracks/python/exercises/scale-generator/scale_generator_test.py +4 -0
  137. data/tracks/python/exercises/two-fer/README.md +29 -0
  138. data/tracks/python/exercises/two-fer/example.py +5 -0
  139. data/tracks/python/exercises/two-fer/two_fer.py +2 -0
  140. data/tracks/python/exercises/two-fer/two_fer_test.py +18 -0
  141. data/tracks/r/config/maintainers.json +2 -2
  142. data/tracks/ruby/config.json +2 -1
  143. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +85 -36
  144. data/tracks/scala/testgen/src/main/scala/MinesweeperTestGenerator.scala +15 -0
  145. data/tracks/vimscript/README.md +1 -1
  146. metadata +37 -13
@@ -12,12 +12,13 @@ Given an age in seconds, calculate how old someone would be on:
12
12
  - Neptune: orbital period 164.79132 Earth years
13
13
 
14
14
  So if you were told someone were 1,000,000,000 seconds old, you should
15
- be able to say that they're 31 Earth-years old.
15
+ be able to say that they're 31.69 Earth-years old. Round all ages to
16
+ the nearest hundredth of a year.
16
17
 
17
18
  If you're wondering why Pluto didn't make the cut, go watch [this
18
19
  youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs).
19
20
 
20
-
21
+
21
22
 
22
23
  ## Source
23
24
 
@@ -23,7 +23,7 @@ like these examples:
23
23
  10 9 8 7
24
24
  ```
25
25
 
26
-
26
+
27
27
 
28
28
  ## Source
29
29
 
@@ -33,7 +33,7 @@ Keep your hands off that filter/reject/whatchamacallit functionality
33
33
  provided by your standard library! Solve this one yourself using other
34
34
  basic tools instead.
35
35
 
36
-
36
+
37
37
 
38
38
  ## Source
39
39
 
@@ -17,7 +17,7 @@ Examples:
17
17
  * A = [1, 2, 3, 4, 5], B = [2, 3, 4], A is a superlist of B
18
18
  * A = [1, 2, 4], B = [1, 2, 3, 4, 5], A is not a superlist of, sublist of or equal to B
19
19
 
20
-
20
+
21
21
 
22
22
 
23
23
  ## Submitting Incomplete Solutions
@@ -11,7 +11,7 @@ The sum of these multiples is 78.
11
11
  Given a number, find the sum of the multiples of a given set of numbers,
12
12
  up to but not including that number.
13
13
 
14
-
14
+
15
15
 
16
16
  ## Source
17
17
 
@@ -19,7 +19,7 @@ length of the third side. See [Triangle Inequality](https://en.wikipedia.org/wik
19
19
  The case where the sum of the lengths of two sides _equals_ that of the
20
20
  third is known as a _degenerate_ triangle - it has zero area and looks like
21
21
  a single line. Feel free to add your own code/tests to check for degenerate triangles.
22
-
22
+
23
23
 
24
24
  ## Source
25
25
 
@@ -12,7 +12,7 @@ free: 1
12
12
  ```
13
13
 
14
14
 
15
-
15
+
16
16
 
17
17
  ## Source
18
18
 
@@ -18,7 +18,7 @@ primitive Atbash
18
18
  last.push(c)
19
19
  else
20
20
  last.push(' ')
21
- groups.push(String(6).>push(c))
21
+ groups.push(String(6) .> push(c))
22
22
  end
23
23
  groups
24
24
 
@@ -27,8 +27,9 @@ primitive Atbash
27
27
  String.join(
28
28
  Iter[U8](input.lower().values())
29
29
  .filter(this~_transposable())
30
- .map[U8]({(c: U8): U8 => Atbash._transpose(c)})
31
- .fold[Array[String ref]](this~_group(), [String(6)])?)
30
+ .map[U8]({(c: U8): U8 => Atbash._transpose(c) })
31
+ .fold[Array[String ref]](this~_group(), [String(6)])?
32
+ .values())
32
33
  else
33
34
  recover String end
34
35
  end
@@ -23,12 +23,12 @@ primitive BeerSong
23
23
  let ns: String = n.string()
24
24
  let ns': String = (n - 1).string()
25
25
  recover String
26
- .>append(ns)
27
- .>append(" bottles of beer on the wall, ")
28
- .>append(ns)
29
- .>append(" bottles of beer.\nTake one down and pass it around, ")
30
- .>append(ns')
31
- .>append(" bottles of beer on the wall.\n")
26
+ .> append(ns)
27
+ .> append(" bottles of beer on the wall, ")
28
+ .> append(ns)
29
+ .> append(" bottles of beer.\nTake one down and pass it around, ")
30
+ .> append(ns')
31
+ .> append(" bottles of beer on the wall.\n")
32
32
  end
33
33
  end
34
34
 
@@ -36,9 +36,10 @@ primitive BeerSong
36
36
  try
37
37
  String.join(
38
38
  Iter[USize](Reverse(start, stop))
39
- .map[String]({(n: USize): String => BeerSong.verse(n) + "\n"})
40
- .collect(Array[String](start - stop)))
41
- .>pop()?
39
+ .map[String]({(n: USize): String => BeerSong.verse(n) + "\n" })
40
+ .collect(Array[String](start - stop))
41
+ .values())
42
+ .> pop()?
42
43
  else
43
44
  recover String end
44
45
  end
@@ -13,7 +13,7 @@ primitive Bob
13
13
  end
14
14
 
15
15
  fun _silent(phrase: String): Bool =>
16
- phrase.clone().>strip() == ""
16
+ phrase.clone() .> strip() == ""
17
17
 
18
18
  fun _loud(phrase: String): Bool =>
19
19
  Iter[U8](phrase.values()).all(this~_not_lowercase())
@@ -9,8 +9,8 @@ primitive Squares
9
9
  fun sum_of_squares(n: USize): USize =>
10
10
  try
11
11
  Iter[USize](Range(0, n + 1))
12
- .map[USize]({(x: USize): USize => x * x})
13
- .fold[USize]({(acc: USize, x: USize): USize => acc + x}, 0)?
12
+ .map[USize]({(x: USize): USize => x * x })
13
+ .fold[USize]({(acc: USize, x: USize): USize => acc + x }, 0)?
14
14
  else
15
15
  0
16
16
  end
@@ -7,5 +7,5 @@ primitive HammingDistance
7
7
 
8
8
  Iter[U8](strand1.values())
9
9
  .zip[U8](strand2.values())
10
- .filter({(t: (U8, U8)): Bool => t._1 != t._2})
10
+ .filter({(t: (U8, U8)): Bool => t._1 != t._2 })
11
11
  .count()
@@ -22,5 +22,5 @@ class iso _TestHammingDistance is UnitTest
22
22
  h.assert_eq[USize](4, HammingDistance("GATACA", "GCATAA")?)
23
23
  h.assert_eq[USize](9, HammingDistance("GGACGGATTCTG", "AGGACGGATTCT")?)
24
24
 
25
- h.assert_error({()? => HammingDistance("GAT", "GA")?})
26
- h.assert_error({()? => HammingDistance("GA", "GAC")?})
25
+ h.assert_error({()? => HammingDistance("GAT", "GA")? })
26
+ h.assert_error({()? => HammingDistance("GA", "GAC")? })
@@ -1,4 +1,4 @@
1
1
  primitive Leap
2
2
  fun apply(year: USize): Bool =>
3
- let has_factor = {(n: USize)(year): Bool => (year % n) == 0}
3
+ let has_factor = {(n: USize)(year): Bool => (year % n) == 0 }
4
4
  has_factor(4) and (not has_factor(100) or has_factor(400))
@@ -4,11 +4,11 @@ use "itertools"
4
4
  primitive PascalsTriangle
5
5
  fun rows(count: USize): Array[Array[USize]] =>
6
6
  Iter[USize](Range(0, count))
7
- .map[Array[USize]]({(n: USize): Array[USize] => PascalsTriangle.row(n)})
7
+ .map[Array[USize]]({(n: USize): Array[USize] => PascalsTriangle.row(n) })
8
8
  .collect(Array[Array[USize]](count))
9
9
 
10
10
  fun row(n: USize): Array[USize] =>
11
- let r = Array[USize](n).>push(1)
11
+ let r = Array[USize](n) .> push(1)
12
12
  for i in Range(1, n + 1) do
13
13
  try
14
14
  let last = r(i - 1)?
@@ -28,5 +28,5 @@ class iso _TestRNATrancription is UnitTest
28
28
  h.assert_eq[String](ToRNA(input)?, expected)
29
29
  end
30
30
 
31
- h.assert_error({() ? => ToRNA("U")?})
32
- h.assert_error({() ? => ToRNA("ACGTXXXCTTAA")?})
31
+ h.assert_error({() ? => ToRNA("U")? })
32
+ h.assert_error({() ? => ToRNA("ACGTXXXCTTAA")? })
@@ -41,5 +41,5 @@ class iso _TestRomanNumerals is UnitTest
41
41
  end
42
42
  end
43
43
 
44
- h.assert_error({() ? => RomanNumerals(-1)?})
45
- h.assert_error({() ? => RomanNumerals(4000)?})
44
+ h.assert_error({() ? => RomanNumerals(-1)? })
45
+ h.assert_error({() ? => RomanNumerals(4000)? })
@@ -801,6 +801,28 @@
801
801
  "Algorithms"
802
802
  ]
803
803
  },
804
+ {
805
+ "uuid": "bacb2184-025f-0980-38d6-34fb419e03a6d3d8b44",
806
+ "slug": "two-fer",
807
+ "core": false,
808
+ "unlocked_by": null,
809
+ "difficulty": 1,
810
+ "topics": [
811
+ "control-flow (if-else statements)",
812
+ "optional values",
813
+ "text formatting"
814
+ ]
815
+ },
816
+ {
817
+ "uuid": "33f689ee-1d9c-4908-a71c-f84bff3510df",
818
+ "slug": "collatz-conjecture",
819
+ "core": false,
820
+ "unlocked_by": null,
821
+ "difficulty": 1,
822
+ "topics": [
823
+ "control-flow (loops)"
824
+ ]
825
+ },
804
826
  {
805
827
  "uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd",
806
828
  "slug": "accumulate",
@@ -1,7 +1,15 @@
1
- Python is a strong language for beginners. There are many resources available for programmers of all levels, the code is highly readable, and in many cases phrases are comparable to those in the English language. Code can be written and executed from the command line, in an interactive IPython session, or in a [Jupyter](http://jupyter.org) (IPython) notebook.
1
+ Python is a strong language for beginners.
2
+ There are many resources available for programmers of all levels, the code is highly readable, and in many cases phrases are comparable to those in the English language.
3
+ Code can be written and executed from the command line, in an interactive IPython session, or in a [Jupyter](http://jupyter.org) (IPython) notebook.
2
4
 
3
- The most common form of Python is compiled in C. This is often invisible to the beginning programmer, but if there are uses for which exceptionally fast implementation is needed then C extensions can be written to optimize Python execution.
5
+ The most common form of Python is compiled in C.
6
+ This is often invisible to the beginning programmer, but if there are uses for which exceptionally fast implementation is needed then C extensions can be written to optimize Python execution.
4
7
 
5
8
  [Python is used extensively](https://www.python.org/about/apps/) in scientific computing, finance, games, networking, internet development, and in assembling pipelines of other programs.
6
9
 
7
- Python was started by Guido van Rossum in 1989. Its name is an homage to the comedy troupe Monty Python. Python 2 is used widely but support may end by 2020. Python 3 was introduced in 2008 and is beginning to be adopted more widely. They are similar, but users will encounter [some differences](http://blog.teamtreehouse.com/python-2-vs-python-3). Python development is shepherded by [The Python Software Foundation](https://www.python.org/about/) and there are active community-based user groups worldwide.
10
+ Python was started by Guido van Rossum in 1989.
11
+ Its name is an homage to the comedy troupe Monty Python.
12
+ Python 2 is used widely but support may end by 2020.
13
+ Python 3 was introduced in 2008 and is beginning to be adopted more widely.
14
+ They are similar, but users will encounter [some differences](http://blog.teamtreehouse.com/python-2-vs-python-3).
15
+ Python development is shepherded by [The Python Software Foundation](https://www.python.org/about/) and there are active community-based user groups worldwide.
@@ -0,0 +1,61 @@
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
+ (Keep in mind that the Conjecture is only concerned with strictly positive
13
+ integers, so your solution should return `None` if given 0 or a negative
14
+ integer.)
15
+
16
+ ## Examples
17
+
18
+ Starting with n = 3, the steps would be as follows:
19
+
20
+ 0. 3
21
+ 1. 10
22
+ 2. 5
23
+ 3. 16
24
+ 4. 8
25
+ 5. 4
26
+ 6. 2
27
+ 7. 1
28
+
29
+ Resulting in 7 steps. So for input n = 3, the return value would be 7.
30
+
31
+ Starting with n = 12, the steps would be as follows:
32
+
33
+ 0. 12
34
+ 1. 6
35
+ 2. 3
36
+ 3. 10
37
+ 4. 5
38
+ 5. 16
39
+ 6. 8
40
+ 7. 4
41
+ 8. 2
42
+ 9. 1
43
+
44
+ Resulting in 9 steps. So for input n = 12, the return value would be 9.
45
+
46
+ ### Submitting Exercises
47
+
48
+ Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
49
+
50
+ For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
51
+
52
+
53
+ For more detailed information about running tests, code style and linting,
54
+ please see the [help page](http://exercism.io/languages/python).
55
+
56
+ ## Source
57
+
58
+ 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)
59
+
60
+ ## Submitting Incomplete Solutions
61
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,2 @@
1
+ def collatz_steps():
2
+ pass
@@ -0,0 +1,32 @@
1
+ import unittest
2
+
3
+ from collatz_conjecture import collatz_steps
4
+
5
+ # Test cases adapted from `x-common//canonical-data.json` @ version: 1.1.1
6
+
7
+
8
+ class CollatzConjectureTests(unittest.TestCase):
9
+
10
+ def test_zero_steps_for_one(self):
11
+ self.assertEqual(collatz_steps(1), 0)
12
+
13
+ def test_divide_if_even(self):
14
+ self.assertEqual(collatz_steps(16), 4)
15
+
16
+ def test_even_and_odd_steps(self):
17
+ self.assertEqual(collatz_steps(12), 9)
18
+
19
+ def test_large_number_of_even_and_odd_steps(self):
20
+ self.assertEqual(collatz_steps(1000000), 152)
21
+
22
+ def test_zero_is_invalid_input(self):
23
+ self.assertEqual(collatz_steps(0), None)
24
+
25
+ def test_negative_number_is_invalid_input(self):
26
+ self.assertEqual(collatz_steps(-1), None)
27
+
28
+ self.assertEqual(collatz_steps(-15), None)
29
+
30
+
31
+ if __name__ == '__main__':
32
+ unittest.main()
@@ -0,0 +1,17 @@
1
+ def collatz_steps(n):
2
+ if n <= 0:
3
+ return
4
+
5
+ step_count = 0
6
+ while n > 1:
7
+ if is_odd(n):
8
+ n = n * 3 + 1
9
+ else:
10
+ n = n / 2
11
+ step_count += 1
12
+
13
+ return step_count
14
+
15
+
16
+ def is_odd(n):
17
+ return n % 2 == 1
@@ -1,2 +1,2 @@
1
- def is_isogram():
1
+ def is_isogram(string):
2
2
  pass
@@ -34,6 +34,9 @@ class TestIsogram(unittest.TestCase):
34
34
  def test_duplicated_character_in_the_middle(self):
35
35
  self.assertFalse(is_isogram("accentor"))
36
36
 
37
+ def test_isogram_with_duplicated_letter_and_nonletter_character(self):
38
+ self.assertFalse(is_isogram("Aleph Bot Chap"))
39
+
37
40
 
38
41
  if __name__ == '__main__':
39
42
  unittest.main()
@@ -26,6 +26,8 @@ class Scale(object):
26
26
  for i, interval in enumerate(self.pattern):
27
27
  pitches.append(scale[last_index])
28
28
  last_index += self.ASCENDING_INTERVALS.index(interval) + 1
29
+ if pitches[0] != scale[last_index % len(scale)]:
30
+ raise ValueError()
29
31
  return pitches
30
32
 
31
33
  def _reorder_chromatic_scale(self):
@@ -115,6 +115,10 @@ class ScaleGeneratorTest(unittest.TestCase):
115
115
  actual = enigmatic.pitches
116
116
  self.assertEqual(expected, actual)
117
117
 
118
+ def test_brokeninterval(self):
119
+ with self.assertRaises(ValueError):
120
+ Scale('G', 'enigmatic', 'mAMMMmM')
121
+
118
122
 
119
123
  if __name__ == '__main__':
120
124
  unittest.main()
@@ -0,0 +1,29 @@
1
+ # Two-fer
2
+
3
+ `Two-fer` or `2-fer` is short for two for one. One for you and one for me.
4
+
5
+ ```
6
+ "One for X, one for me."
7
+ ```
8
+
9
+ When X is a name or "you".
10
+
11
+ If the given name is "Alice", the result should be "One for Alice, one for me."
12
+ If no name is given, the result should be "One for you, one for me."
13
+
14
+ ### Submitting Exercises
15
+
16
+ Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
17
+
18
+ For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
19
+
20
+
21
+ For more detailed information about running tests, code style and linting,
22
+ please see the [help page](http://exercism.io/languages/python).
23
+
24
+ ## Source
25
+
26
+ This is an exercise to introduce users to basic programming constructs, just after hello World. [https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
27
+
28
+ ## Submitting Incomplete Solutions
29
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,5 @@
1
+ def two_fer(name=""):
2
+ if not name.strip():
3
+ return "One for you, one for me."
4
+ else:
5
+ return "One for %s, one for me." % name