trackler 2.2.1.102 → 2.2.1.103
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/two-fer/metadata.yml +0 -1
- data/tracks/c/exercises/bob/.meta/description.md +10 -0
- data/tracks/cfml/exercises/acronym/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/anagram/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/atbash-cipher/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/bob/.meta/description.md +10 -0
- data/tracks/cfml/exercises/bob/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/diamond/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/difference-of-squares/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/flatten-array/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/gigasecond/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/grains/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/hamming/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/isogram/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/largest-series-product/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/luhn/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/markdown/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/nth-prime/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/pangram/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/pig-latin/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/raindrops/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/rna-transcription/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/saddle-points/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/scrabble-score/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/secret-handshake/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/space-age/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/sum-of-multiples/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/triangle/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/cfml/exercises/word-count/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/coffeescript/exercises/bob/.meta/description.md +10 -0
- data/tracks/common-lisp/exercises/bob/.meta/description.md +10 -0
- data/tracks/cpp/exercises/bob/.meta/description.md +10 -0
- data/tracks/crystal/exercises/triangle/README.md +52 -0
- data/tracks/csharp/exercises/complex-numbers/README.md +44 -0
- data/tracks/d/exercises/bob/.meta/description.md +10 -0
- data/tracks/dart/exercises/bob/.meta/description.md +10 -0
- data/tracks/dart/exercises/bob/README.md +0 -1
- data/tracks/ecmascript/exercises/bob/.meta/description.md +10 -0
- data/tracks/ecmascript/exercises/bob/README.md +1 -1
- data/tracks/elisp/config/exercise_readme.go.tmpl +0 -3
- data/tracks/elm/exercises/bob/.meta/description.md +10 -0
- data/tracks/elm/exercises/collatz-conjecture/README.md +63 -0
- data/tracks/erlang/exercises/bob/.meta/description.md +10 -0
- data/tracks/erlang/exercises/complex-numbers/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/erlang/exercises/robot-simulator/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/fortran/config/exercise_readme.go.tmpl +0 -3
- data/tracks/fsharp/exercises/clock/ClockTest.fs +9 -9
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +1 -1
- data/tracks/fsharp/exercises/ocr-numbers/OcrNumbersTest.fs +35 -35
- data/tracks/fsharp/exercises/palindrome-products/PalindromeProductsTest.fs +1 -1
- data/tracks/fsharp/exercises/poker/PokerTest.fs +57 -57
- data/tracks/fsharp/exercises/prime-factors/PrimeFactorsTest.fs +1 -1
- data/tracks/fsharp/exercises/protein-translation/ProteinTranslationTest.fs +1 -1
- data/tracks/fsharp/exercises/proverb/ProverbTest.fs +13 -13
- data/tracks/fsharp/exercises/queen-attack/QueenAttackTest.fs +1 -1
- data/tracks/fsharp/exercises/rail-fence-cipher/RailFenceCipherTest.fs +1 -1
- data/tracks/fsharp/exercises/raindrops/RaindropsTest.fs +1 -1
- data/tracks/fsharp/exercises/rectangles/RectanglesTest.fs +70 -70
- data/tracks/fsharp/exercises/reverse-string/ReverseStringTest.fs +1 -1
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulatorTest.fs +1 -1
- data/tracks/fsharp/exercises/roman-numerals/RomanNumeralsTest.fs +5 -1
- data/tracks/fsharp/exercises/run-length-encoding/RunLengthEncodingTest.fs +1 -1
- data/tracks/fsharp/exercises/word-count/Example.fs +1 -1
- data/tracks/fsharp/exercises/word-count/WordCount.fs +1 -1
- data/tracks/fsharp/exercises/word-count/WordCountTest.fs +12 -12
- data/tracks/fsharp/generators/Generators.fs +26 -40
- data/tracks/gnu-apl/config/exercise_readme.go.tmpl +0 -3
- data/tracks/go/exercises/armstrong-numbers/README.md +36 -0
- data/tracks/go/exercises/two-bucket/.meta/hints.md +23 -3
- data/tracks/go/exercises/two-bucket/README.md +23 -3
- data/tracks/go/exercises/two-bucket/bonus_test.go +22 -0
- data/tracks/go/exercises/two-bucket/example.go +9 -5
- data/tracks/go/exercises/two-bucket/two_bucket_test.go +31 -27
- data/tracks/haxe/config/exercise_readme.go.tmpl +0 -3
- data/tracks/haxe/exercises/leap/README.md +33 -0
- data/tracks/java/exercises/parallel-letter-frequency/.meta/{HINTS.md → hints.md} +0 -0
- data/tracks/java/exercises/protein-translation/README.md +2 -2
- data/tracks/lfe/exercises/bob/.meta/description.md +10 -0
- data/tracks/nim/config/exercise_readme.go.tmpl +0 -3
- data/tracks/objective-c/exercises/collatz-conjecture/README.md +50 -0
- data/tracks/objective-c/exercises/grains/README.md +50 -0
- data/tracks/objective-c/exercises/nth-prime/README.md +32 -0
- data/tracks/objective-c/exercises/say/README.md +86 -0
- data/tracks/objective-c/exercises/two-fer/README.md +36 -0
- data/tracks/php/exercises/collatz-conjecture/README.md +48 -0
- data/tracks/php/exercises/crypto-square/README.md +91 -0
- data/tracks/php/exercises/flatten-array/README.md +32 -0
- data/tracks/php/exercises/transpose/README.md +80 -0
- data/tracks/plsql/exercises/hello-world/README.md +41 -0
- data/tracks/powershell/config/exercise_readme.go.tmpl +0 -3
- data/tracks/prolog/config/exercise_readme.go.tmpl +0 -3
- data/tracks/python/exercises/bowling/README.md +92 -0
- data/tracks/r/config.json +12 -1
- data/tracks/r/exercises/bob/.meta/description.md +10 -0
- data/tracks/r/exercises/diamond/README.md +69 -0
- data/tracks/r/exercises/diamond/diamond.R +3 -0
- data/tracks/r/exercises/diamond/example.R +15 -0
- data/tracks/r/exercises/diamond/test_diamond.R +90 -0
- data/tracks/scala/exercises/bob/.meta/description.md +10 -0
- data/tracks/sml/exercises/bob/.meta/description.md +10 -0
- data/tracks/swift/exercises/rotational-cipher/README.md +45 -0
- data/tracks/typescript/exercises/bob/.meta/description.md +10 -0
- data/tracks/vbnet/exercises/bob/.meta/description.md +10 -0
- data/tracks/vimscript/exercises/bob/.meta/description.md +10 -0
- metadata +70 -38
- data/tracks/elisp/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/fortran/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/gnu-apl/config/exercise-readme-insert.md +0 -0
- data/tracks/haxe/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/nim/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/powershell/docs/EXERCISE_README_INSERT.md +0 -0
- data/tracks/prolog/docs/EXERCISE_README_INSERT.md +0 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
# Armstrong Numbers
|
2
|
+
|
3
|
+
An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
|
4
|
+
|
5
|
+
For example:
|
6
|
+
|
7
|
+
- 9 is an Armstrong number, because `9 = 9^1 = 9`
|
8
|
+
- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 2`
|
9
|
+
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
|
10
|
+
- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
|
11
|
+
|
12
|
+
Write some code to determine whether a number is an Armstrong number.
|
13
|
+
|
14
|
+
## Running the tests
|
15
|
+
|
16
|
+
To run the tests run the command `go test` from within the exercise directory.
|
17
|
+
|
18
|
+
If the test suite contains benchmarks, you can run these with the `-bench`
|
19
|
+
flag:
|
20
|
+
|
21
|
+
go test -bench .
|
22
|
+
|
23
|
+
Keep in mind that each reviewer will run benchmarks on a different machine, with
|
24
|
+
different specs, so the results from these benchmark tests may vary.
|
25
|
+
|
26
|
+
## Further information
|
27
|
+
|
28
|
+
For more detailed information about the Go track, including how to get help if
|
29
|
+
you're having trouble, please visit the exercism.io [Go language page](http://exercism.io/languages/go/about).
|
30
|
+
|
31
|
+
## Source
|
32
|
+
|
33
|
+
Wikipedia [https://en.wikipedia.org/wiki/Narcissistic_number](https://en.wikipedia.org/wiki/Narcissistic_number)
|
34
|
+
|
35
|
+
## Submitting Incomplete Solutions
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -11,6 +11,26 @@ func Solve(sizeBucketOne,
|
|
11
11
|
```
|
12
12
|
Solve returns four values: the resulting goal bucket("one" or two"),
|
13
13
|
the number of moves/steps to achieve the goal amount,
|
14
|
-
the liters left in the other bucket,
|
15
|
-
|
16
|
-
|
14
|
+
the liters left in the other bucket, and an error value.
|
15
|
+
The returned error value should be nil when the parameters are valid.
|
16
|
+
Return an error for any invalid parameter.
|
17
|
+
Solve should also return an error when a solution cannot be found,
|
18
|
+
but this error relates only to the bonus exercise below, so you may
|
19
|
+
ignore that error case for your initial solution.
|
20
|
+
|
21
|
+
### Bonus exercise
|
22
|
+
|
23
|
+
Once you get `go test` passing, try `go test -tags bonus`. This uses a *build
|
24
|
+
tag* to enable tests that were not previously enabled. Build tags control which
|
25
|
+
files should be included in the package. You can read more about those at [the
|
26
|
+
Go documentation](https://golang.org/pkg/go/build/#hdr-Build_Constraints).
|
27
|
+
|
28
|
+
The exercise limits `go test` to only build the tests referenced in the
|
29
|
+
`two_bucket_test.go` file. The bonus test cases are found in the file
|
30
|
+
`bonus_test.go`. Enable those tests as described above.
|
31
|
+
|
32
|
+
To get the bonus tests to pass, the Solve func must detect when
|
33
|
+
a solution cannot be found and return an error.
|
34
|
+
A solution cannot be found when input test case bucket sizes
|
35
|
+
are not ones which allow the three operations to succeed in creating the goal amount,
|
36
|
+
which occurs when the two bucket sizes are not relatively prime to one another.
|
@@ -42,9 +42,29 @@ func Solve(sizeBucketOne,
|
|
42
42
|
```
|
43
43
|
Solve returns four values: the resulting goal bucket("one" or two"),
|
44
44
|
the number of moves/steps to achieve the goal amount,
|
45
|
-
the liters left in the other bucket,
|
46
|
-
|
47
|
-
|
45
|
+
the liters left in the other bucket, and an error value.
|
46
|
+
The returned error value should be nil when the parameters are valid.
|
47
|
+
Return an error for any invalid parameter.
|
48
|
+
Solve should also return an error when a solution cannot be found,
|
49
|
+
but this error relates only to the bonus exercise below, so you may
|
50
|
+
ignore that error case for your initial solution.
|
51
|
+
|
52
|
+
### Bonus exercise
|
53
|
+
|
54
|
+
Once you get `go test` passing, try `go test -tags bonus`. This uses a *build
|
55
|
+
tag* to enable tests that were not previously enabled. Build tags control which
|
56
|
+
files should be included in the package. You can read more about those at [the
|
57
|
+
Go documentation](https://golang.org/pkg/go/build/#hdr-Build_Constraints).
|
58
|
+
|
59
|
+
The exercise limits `go test` to only build the tests referenced in the
|
60
|
+
`two_bucket_test.go` file. The bonus test cases are found in the file
|
61
|
+
`bonus_test.go`. Enable those tests as described above.
|
62
|
+
|
63
|
+
To get the bonus tests to pass, the Solve func must detect when
|
64
|
+
a solution cannot be found and return an error.
|
65
|
+
A solution cannot be found when input test case bucket sizes
|
66
|
+
are not ones which allow the three operations to succeed in creating the goal amount,
|
67
|
+
which occurs when the two bucket sizes are not relatively prime to one another.
|
48
68
|
|
49
69
|
|
50
70
|
## Running the tests
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// +build bonus
|
2
|
+
|
3
|
+
package twobucket
|
4
|
+
|
5
|
+
import "testing"
|
6
|
+
|
7
|
+
var noSolutionCases = []bucketTestCase{
|
8
|
+
{
|
9
|
+
"No solution case 1",
|
10
|
+
2, 4, 1, "two", "", 0, 0, true,
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"No solution case 2",
|
14
|
+
3, 6, 1, "one", "", 0, 0, true,
|
15
|
+
},
|
16
|
+
}
|
17
|
+
|
18
|
+
func TestSolve_bonus(t *testing.T) {
|
19
|
+
for _, tc := range noSolutionCases {
|
20
|
+
runTestCase(t, tc)
|
21
|
+
}
|
22
|
+
}
|
@@ -69,10 +69,13 @@ func Solve(sizeBucketOne,
|
|
69
69
|
if !isSolution(p, s) {
|
70
70
|
s = findGoal(p, s)
|
71
71
|
}
|
72
|
-
|
72
|
+
switch {
|
73
|
+
case s.level[bOne] == p.goal:
|
73
74
|
return FirstBucketName, s.numSteps, s.level[bTwo], nil
|
75
|
+
case s.level[bTwo] == p.goal:
|
76
|
+
return SecondBucketName, s.numSteps, s.level[bOne], nil
|
74
77
|
}
|
75
|
-
return
|
78
|
+
return "", 0, 0, errors.New("no solution")
|
76
79
|
}
|
77
80
|
|
78
81
|
func validateParameters(sizeBucketOne, sizeBucketTwo, goalAmount int, startBucket string) error {
|
@@ -110,7 +113,7 @@ func findGoal(p problem, s state) (g state) {
|
|
110
113
|
visited[[2]int{p.capacity[bOne], 0}] = true
|
111
114
|
}
|
112
115
|
|
113
|
-
for {
|
116
|
+
for len(searchList) != 0 {
|
114
117
|
// Pop one item from the searchList each pass.
|
115
118
|
current := searchList[0]
|
116
119
|
searchList = searchList[1:]
|
@@ -127,6 +130,7 @@ func findGoal(p problem, s state) (g state) {
|
|
127
130
|
}
|
128
131
|
}
|
129
132
|
}
|
133
|
+
return state{}
|
130
134
|
}
|
131
135
|
|
132
136
|
func performStep(p problem, s *state, x step) {
|
@@ -160,14 +164,14 @@ func pour(p problem, s *state, a, b bucket) {
|
|
160
164
|
|
161
165
|
func getPossibleSteps(p problem, s state) (list []step) {
|
162
166
|
for x := emptyOne; x <= pourTwoToOne; x++ {
|
163
|
-
if
|
167
|
+
if canPerformStep(p, s, x) {
|
164
168
|
list = append(list, x)
|
165
169
|
}
|
166
170
|
}
|
167
171
|
return list
|
168
172
|
}
|
169
173
|
|
170
|
-
func
|
174
|
+
func canPerformStep(p problem, s state, x step) bool {
|
171
175
|
switch x {
|
172
176
|
case emptyOne:
|
173
177
|
if s.previousStep == fillOne || s.previousStep == pourOneToTwo {
|
@@ -2,40 +2,44 @@ package twobucket
|
|
2
2
|
|
3
3
|
import "testing"
|
4
4
|
|
5
|
+
func runTestCase(t *testing.T, tc bucketTestCase) {
|
6
|
+
g, m, other, e := Solve(tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket)
|
7
|
+
var _ error = e
|
8
|
+
if e == nil {
|
9
|
+
if tc.errorExpected {
|
10
|
+
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected error\nActual: %q, %d, %d",
|
11
|
+
tc.description,
|
12
|
+
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
13
|
+
g, m, other)
|
14
|
+
}
|
15
|
+
if g != tc.goalBucket || m != tc.moves || other != tc.otherBucket {
|
16
|
+
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected: %q, %d, %d\nActual: %q, %d, %d",
|
17
|
+
tc.description,
|
18
|
+
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
19
|
+
tc.goalBucket, tc.moves, tc.otherBucket,
|
20
|
+
g, m, other)
|
21
|
+
}
|
22
|
+
} else if e != nil {
|
23
|
+
if !tc.errorExpected {
|
24
|
+
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected: %q, %d, %d\nGot Error %q",
|
25
|
+
tc.description,
|
26
|
+
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
27
|
+
tc.goalBucket, tc.moves, tc.otherBucket,
|
28
|
+
e)
|
29
|
+
}
|
30
|
+
}
|
31
|
+
t.Logf("PASS: %s", tc.description)
|
32
|
+
}
|
33
|
+
|
5
34
|
func TestSolve(t *testing.T) {
|
6
35
|
for _, tc := range append(testCases, errorTestCases...) {
|
7
|
-
|
8
|
-
var _ error = e
|
9
|
-
if e == nil {
|
10
|
-
if tc.errorExpected {
|
11
|
-
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected error\nActual: %q, %d, %d",
|
12
|
-
tc.description,
|
13
|
-
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
14
|
-
g, m, other)
|
15
|
-
}
|
16
|
-
if g != tc.goalBucket || m != tc.moves || other != tc.otherBucket {
|
17
|
-
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected: %q, %d, %d\nActual: %q, %d, %d",
|
18
|
-
tc.description,
|
19
|
-
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
20
|
-
tc.goalBucket, tc.moves, tc.otherBucket,
|
21
|
-
g, m, other)
|
22
|
-
}
|
23
|
-
} else if e != nil {
|
24
|
-
if !tc.errorExpected {
|
25
|
-
t.Fatalf("FAIL: %s\nSolve(%d, %d, %d, %q)\nExpected: %q, %d, %d\nnGot Error %q",
|
26
|
-
tc.description,
|
27
|
-
tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket,
|
28
|
-
tc.goalBucket, tc.moves, tc.otherBucket,
|
29
|
-
e)
|
30
|
-
}
|
31
|
-
}
|
32
|
-
t.Logf("PASS: %s", tc.description)
|
36
|
+
runTestCase(t, tc)
|
33
37
|
}
|
34
38
|
}
|
35
39
|
|
36
40
|
func BenchmarkSolve(b *testing.B) {
|
37
41
|
for i := 0; i < b.N; i++ {
|
38
|
-
for _, tc := range testCases {
|
42
|
+
for _, tc := range append(testCases, errorTestCases...) {
|
39
43
|
Solve(tc.bucketOne, tc.bucketTwo, tc.goal, tc.startBucket)
|
40
44
|
}
|
41
45
|
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Leap
|
2
|
+
|
3
|
+
Given a year, report if it is a leap year.
|
4
|
+
|
5
|
+
The tricky thing here is that a leap year in the Gregorian calendar occurs:
|
6
|
+
|
7
|
+
```text
|
8
|
+
on every year that is evenly divisible by 4
|
9
|
+
except every year that is evenly divisible by 100
|
10
|
+
unless the year is also evenly divisible by 400
|
11
|
+
```
|
12
|
+
|
13
|
+
For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap
|
14
|
+
year, but 2000 is.
|
15
|
+
|
16
|
+
If your language provides a method in the standard library that does
|
17
|
+
this look-up, pretend it doesn't exist and implement it yourself.
|
18
|
+
|
19
|
+
## Notes
|
20
|
+
|
21
|
+
Though our exercise adopts some very simple rules, there is more to
|
22
|
+
learn!
|
23
|
+
|
24
|
+
For a delightful, four minute explanation of the whole leap year
|
25
|
+
phenomenon, go watch [this youtube video][video].
|
26
|
+
|
27
|
+
[video]: http://www.youtube.com/watch?v=xX96xng7sAE
|
28
|
+
## Source
|
29
|
+
|
30
|
+
JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)
|
31
|
+
|
32
|
+
## Submitting Incomplete Solutions
|
33
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
File without changes
|
@@ -20,11 +20,11 @@ All subsequent codons after are ignored, like this:
|
|
20
20
|
|
21
21
|
RNA: `"AUGUUUUCUUAAAUG"` =>
|
22
22
|
|
23
|
-
Codons: `"AUG", "UUU", "UCU", "
|
23
|
+
Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` =>
|
24
24
|
|
25
25
|
Protein: `"Methionine", "Phenylalanine", "Serine"`
|
26
26
|
|
27
|
-
Note the stop codon terminates the translation and the final methionine is not translated into the protein sequence.
|
27
|
+
Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence.
|
28
28
|
|
29
29
|
Below are the codons and resulting Amino Acids needed for the exercise.
|
30
30
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
|
2
|
+
|
3
|
+
Bob answers 'Sure.' if you ask him a question.
|
4
|
+
|
5
|
+
He answers 'Whoa, chill out!' if you yell at him.
|
6
|
+
|
7
|
+
He says 'Fine. Be that way!' if you address him without actually saying
|
8
|
+
anything.
|
9
|
+
|
10
|
+
He answers 'Whatever.' to anything else.
|
@@ -0,0 +1,50 @@
|
|
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
|
+
|
14
|
+
Starting with n = 12, the steps would be as follows:
|
15
|
+
|
16
|
+
0. 12
|
17
|
+
1. 6
|
18
|
+
2. 3
|
19
|
+
3. 10
|
20
|
+
4. 5
|
21
|
+
5. 16
|
22
|
+
6. 8
|
23
|
+
7. 4
|
24
|
+
8. 2
|
25
|
+
9. 1
|
26
|
+
|
27
|
+
Resulting in 9 steps. So for input n = 12, the return value would be 9.
|
28
|
+
|
29
|
+
## Setup
|
30
|
+
|
31
|
+
There are two different methods of getting set up to run the tests with Objective-C:
|
32
|
+
|
33
|
+
- Create an Xcode project with a test target which will run the tests.
|
34
|
+
- Use the ruby gem `objc` as a test runner utility.
|
35
|
+
|
36
|
+
Both are described in more detail here: http://exercism.io/languages/objective-c
|
37
|
+
|
38
|
+
|
39
|
+
### Submitting Exercises
|
40
|
+
|
41
|
+
When submitting an exercise, make sure your solution file is in the same directory as the test code.
|
42
|
+
|
43
|
+
For example, if you're submitting `Bob.m` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/objective-c/bob/Bob.m`.
|
44
|
+
|
45
|
+
## Source
|
46
|
+
|
47
|
+
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)
|
48
|
+
|
49
|
+
## Submitting Incomplete Solutions
|
50
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Grains
|
2
|
+
|
3
|
+
Calculate the number of grains of wheat on a chessboard given that the number
|
4
|
+
on each square doubles.
|
5
|
+
|
6
|
+
There once was a wise servant who saved the life of a prince. The king
|
7
|
+
promised to pay whatever the servant could dream up. Knowing that the
|
8
|
+
king loved chess, the servant told the king he would like to have grains
|
9
|
+
of wheat. One grain on the first square of a chess board. Two grains on
|
10
|
+
the next. Four on the third, and so on.
|
11
|
+
|
12
|
+
There are 64 squares on a chessboard.
|
13
|
+
|
14
|
+
Write code that shows:
|
15
|
+
- how many grains were on each square, and
|
16
|
+
- the total number of grains
|
17
|
+
|
18
|
+
## For bonus points
|
19
|
+
|
20
|
+
Did you get the tests passing and the code clean? If you want to, these
|
21
|
+
are some additional things you could try:
|
22
|
+
|
23
|
+
- Optimize for speed.
|
24
|
+
- Optimize for readability.
|
25
|
+
|
26
|
+
Then please share your thoughts in a comment on the submission. Did this
|
27
|
+
experiment make the code better? Worse? Did you learn anything from it?
|
28
|
+
|
29
|
+
## Setup
|
30
|
+
|
31
|
+
There are two different methods of getting set up to run the tests with Objective-C:
|
32
|
+
|
33
|
+
- Create an Xcode project with a test target which will run the tests.
|
34
|
+
- Use the ruby gem `objc` as a test runner utility.
|
35
|
+
|
36
|
+
Both are described in more detail here: http://exercism.io/languages/objective-c
|
37
|
+
|
38
|
+
|
39
|
+
### Submitting Exercises
|
40
|
+
|
41
|
+
When submitting an exercise, make sure your solution file is in the same directory as the test code.
|
42
|
+
|
43
|
+
For example, if you're submitting `Bob.m` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/objective-c/bob/Bob.m`.
|
44
|
+
|
45
|
+
## Source
|
46
|
+
|
47
|
+
JavaRanch Cattle Drive, exercise 6 [http://www.javaranch.com/grains.jsp](http://www.javaranch.com/grains.jsp)
|
48
|
+
|
49
|
+
## Submitting Incomplete Solutions
|
50
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Nth Prime
|
2
|
+
|
3
|
+
Given a number n, determine what the nth prime is.
|
4
|
+
|
5
|
+
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
|
6
|
+
the 6th prime is 13.
|
7
|
+
|
8
|
+
If your language provides methods in the standard library to deal with prime
|
9
|
+
numbers, pretend they don't exist and implement them yourself.
|
10
|
+
|
11
|
+
## Setup
|
12
|
+
|
13
|
+
There are two different methods of getting set up to run the tests with Objective-C:
|
14
|
+
|
15
|
+
- Create an Xcode project with a test target which will run the tests.
|
16
|
+
- Use the ruby gem `objc` as a test runner utility.
|
17
|
+
|
18
|
+
Both are described in more detail here: http://exercism.io/languages/objective-c
|
19
|
+
|
20
|
+
|
21
|
+
### Submitting Exercises
|
22
|
+
|
23
|
+
When submitting an exercise, make sure your solution file is in the same directory as the test code.
|
24
|
+
|
25
|
+
For example, if you're submitting `Bob.m` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/objective-c/bob/Bob.m`.
|
26
|
+
|
27
|
+
## Source
|
28
|
+
|
29
|
+
A variation on Problem 7 at Project Euler [http://projecteuler.net/problem=7](http://projecteuler.net/problem=7)
|
30
|
+
|
31
|
+
## Submitting Incomplete Solutions
|
32
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|