trackler 2.0.6.19 → 2.0.6.20
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/tracks/csharp/config.json +8 -0
- data/tracks/csharp/exercises/forth/Example.cs +257 -0
- data/tracks/csharp/exercises/forth/ForthTest.cs +134 -0
- data/tracks/fsharp/config.json +7 -1
- data/tracks/fsharp/exercises/exercises.fsproj +20 -0
- data/tracks/fsharp/exercises/lens-person/Example.fs +50 -0
- data/tracks/fsharp/exercises/lens-person/HINTS.md +2 -0
- data/tracks/fsharp/exercises/lens-person/LensPerson.fs +24 -0
- data/tracks/fsharp/exercises/lens-person/LensPersonTest.fs +43 -0
- data/tracks/fsharp/exercises/paket.references +2 -1
- data/tracks/fsharp/paket.dependencies +1 -0
- data/tracks/fsharp/paket.lock +1 -0
- data/tracks/javascript/exercises/{bob/bob.js → leap/leap.js} +3 -3
- data/tracks/julia/README.md +16 -0
- data/tracks/objective-c/config.json +17 -0
- data/tracks/objective-c/exercises/bracket-push/BracketPushExample.h +8 -0
- data/tracks/objective-c/exercises/bracket-push/BracketPushExample.m +386 -0
- data/tracks/objective-c/exercises/bracket-push/BracketPushTest.m +84 -0
- data/tracks/objective-c/exercises/sublist/SublistExample.h +7 -0
- data/tracks/objective-c/exercises/sublist/SublistExample.m +67 -0
- data/tracks/objective-c/exercises/sublist/SublistTest.m +139 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +55 -2
- data/tracks/ocaml/exercises/dominoes/test.ml +11 -5
- data/tracks/ocaml/exercises/luhn/test.ml +3 -3
- data/tracks/ocaml/tools/test-generator/templates/dominoes/template.ml +11 -5
- data/tracks/pascal/config.json +1 -1
- data/tracks/pascal/docs/INSTALLATION.md +52 -0
- data/tracks/pascal/docs/img/00delphiwelcomepage.png +0 -0
- data/tracks/pascal/docs/img/01delphiclicktools.png +0 -0
- data/tracks/pascal/docs/img/02delphiclickoptions.png +0 -0
- data/tracks/pascal/docs/img/03delphioptionsenvironmentvariables.png +0 -0
- data/tracks/pascal/docs/img/04delphioptionsenvironmentvariablesclicknew.png +0 -0
- data/tracks/pascal/docs/img/05delphinewuservariable.png +0 -0
- data/tracks/pascal/docs/img/06delphioptionslibrary.png +0 -0
- data/tracks/pascal/docs/img/07delphiclicklibrarypathbutton.png +0 -0
- data/tracks/pascal/docs/img/08delphidirectoriesinputvarnameclickadd.png +0 -0
- data/tracks/pascal/docs/img/09delphidirectoriesclickok.png +0 -0
- data/tracks/pascal/docs/img/10delphioptonsclickok.png +0 -0
- data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountExample.pas +9 -18
- data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountTest.pas +16 -16
- data/tracks/php/config.json +7 -0
- data/tracks/php/exercises/book-store/book-store_test.php +146 -0
- data/tracks/php/exercises/book-store/example.php +38 -0
- data/tracks/swift/docs/TESTS.md +40 -35
- data/tracks/swift/docs/img/tests-fail.png +0 -0
- data/tracks/swift/docs/img/tests-pass.png +0 -0
- data/tracks/swift/docs/img/tests.png +0 -0
- metadata +28 -3
@@ -0,0 +1,38 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
function total($items)
|
4
|
+
{
|
5
|
+
return calculate($items, 0);
|
6
|
+
}
|
7
|
+
|
8
|
+
function calculate($items, $total)
|
9
|
+
{
|
10
|
+
if (empty($items)) {
|
11
|
+
return $total;
|
12
|
+
}
|
13
|
+
|
14
|
+
$group = array_unique($items);
|
15
|
+
$totalMin = INF;
|
16
|
+
|
17
|
+
for ($i = count($group); $i > 0; $i--) {
|
18
|
+
$itemsToRemove = array_flip(array_slice($group, 0, $i));
|
19
|
+
$itemsRemaining = array_filter($items, function ($x) use (&$itemsToRemove) {
|
20
|
+
if (array_key_exists($x, $itemsToRemove)) {
|
21
|
+
unset($itemsToRemove[$x]);
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
return true;
|
25
|
+
});
|
26
|
+
$totalCurrent = calculate($itemsRemaining, $total + totalForGroup($i));
|
27
|
+
$totalMin = min([$totalMin, $totalCurrent]);
|
28
|
+
}
|
29
|
+
|
30
|
+
return $totalMin;
|
31
|
+
}
|
32
|
+
|
33
|
+
function totalForGroup($count)
|
34
|
+
{
|
35
|
+
$discount = [0, 0, 0.05, 0.1, 0.2, 0.25];
|
36
|
+
$price = 8;
|
37
|
+
return $price * $count * (1 - $discount[$count]);
|
38
|
+
}
|
data/tracks/swift/docs/TESTS.md
CHANGED
@@ -1,88 +1,93 @@
|
|
1
1
|
## Testing Tutorial
|
2
2
|
|
3
|
-
This guide explains how to run unit tests for the Exercism Swift exercises using either macOS or Linux.
|
3
|
+
This guide explains how to run unit tests for the Exercism Swift exercises using either macOS or Linux. It assumes you have already successfully installed the Exercism client and fetched the first exercise. If not, [do that now](http://exercism.io/languages/swift).
|
4
|
+
|
5
|
+
#### For experienced users:
|
4
6
|
|
5
|
-
### For experienced users:
|
6
7
|
1. `swift test` runs tests
|
7
8
|
2. `swift package generate-xcodeproj` creates an Xcode project
|
8
9
|
|
9
|
-
To run the tests from the command line, first `cd` to the directory
|
10
|
+
To run the tests from the command line, first `cd` to the exercise directory (for example, ~/exercism/swift/exercises/hello-world/), then execute `swift test`. This will compile the files in the Sources directory and execute the tests in the Tests directory. Alternatively, open the Xcode project and press Command-U.
|
10
11
|
|
11
12
|
### Overview
|
12
13
|
|
13
14
|
The following instructions are written with the expectation that some readers will be very new to test driven development, Exercism, or Xcode. Each step is described in detail.
|
14
15
|
|
15
|
-
**macOS users are encouraged to use Xcode.** The Xcode environment provides detailed error messages compared to those available from the command line.
|
16
|
+
**macOS users are encouraged to use Xcode.** The Xcode environment provides very detailed error messages compared to those available from the command line.
|
16
17
|
|
17
|
-
Exercism uses the [Swift Package Manager](https://github.com/apple/swift-package-manager/tree/master/Documentation) to package files and tests for Swift. Packages provide a complete set of source files that can be compiled and executed from the command line.
|
18
|
+
Exercism uses the [Swift Package Manager](https://github.com/apple/swift-package-manager/tree/master/Documentation) to package files and tests for Swift. Packages provide a complete set of source files that can be compiled and executed from the command line (or from Xcode).
|
18
19
|
|
19
20
|
To complete an Exercism exercise, you will work primarily with two files:
|
20
21
|
|
21
|
-
* **Swift Source** (hello-world/Sources/HelloWorld.swift). This is the code file you will submit to Exercism.
|
22
|
-
* **Test Source** (hello-world/Tests/HelloWorldTests/HelloWorldTest.swift). This file is provided by Exercism
|
22
|
+
* **Swift Source** (hello-world/Sources/HelloWorld.swift). This is the code file you will submit to Exercism. Typically each exercise contains a Swift Source file with the same name as the project.
|
23
|
+
* **Test Source** (hello-world/Tests/HelloWorldTests/HelloWorldTest.swift). This file is provided by Exercism. It contains the XCTestCase subclass that defines the solution to the exercise. You never edit this file, but you will have to understand it in order to fulfill its expectations.
|
23
24
|
|
24
25
|
Optionally, Xcode can create a third file for experimentation:
|
25
26
|
|
26
|
-
* **Playground** (MyPlayground.playground) is a scratchpad for drafting code
|
27
|
+
* **Playground** (MyPlayground.playground) is a scratchpad for drafting code and playing with ideas. The code executes as you type, providing instant feedback. It is not possible to call Exercism tests in a playground directly, so code must be copied to the Swift Source file before invoking the unit tests.
|
27
28
|
|
28
29
|
|
29
30
|
### Configuring Xcode
|
30
|
-
1. `cd` to the directory for an exercise (for example, ~/exercism/swift/exercises/hello-world/), then execute `swift package generate-xcodeproj
|
31
|
+
1. In the Terminal `cd` to the directory for an exercise (for example, ~/exercism/swift/exercises/hello-world/), then execute `swift package generate-xcodeproj`. This creates an Xcode project in the current directory with the same name as the package. (The generated project is ideal for unit tests. It does not include the overhead of launching the iOS simulator or a target application.)
|
31
32
|
2. Open the newly generated project file.
|
32
|
-
3. At this point the project's file inspector should look similar to the
|
33
|
-
4.
|
33
|
+
3. At this point the project's file inspector should look similar to the image below. If the `HelloWorldTests` folder is closed, click on the disclosure triangle to reveal its contents.
|
34
|
+
4. When Xcode opens a project, typically it will build automatically. If there is an initial build error, press Shift-Command-K to clean the project followed by Command-B to build again. (Cleaning is a useful Xcode troubleshooting technique for all sorts of error conditions.)
|
35
|
+
5. The items Package.swift, Configs, and Products are boilerplate that do not need modification.
|
36
|
+
6. Congratulations! If the project builds successfully, configuration is complete.
|
34
37
|
|
35
38
|
![file inspector](/docs/img/file-inspector.png)
|
36
39
|
|
37
|
-
###
|
40
|
+
### Xcode Playgrounds
|
38
41
|
|
39
|
-
|
42
|
+
Playgrounds can be useful for brainstorming solutions to the problem. The playground continuously evaluates code as you type, displaying variable states and results almost immediately.
|
40
43
|
|
41
|
-
|
44
|
+
If you generated an Xcode project, follow these steps:
|
42
45
|
|
43
|
-
|
46
|
+
1. First, make sure to select the topmost item in the File Inspector, the item marked with a blue icon that represents the project file.
|
47
|
+
2. Press Command-N and choose Playground from the template chooser. Click Next, and click Create.
|
44
48
|
|
45
|
-
|
49
|
+
Keep in mind that while playgrounds are useful for drafting code snippets and ideas, code must be moved to the Swift Source file for testing and submission.
|
46
50
|
|
47
|
-
|
51
|
+
### Running Tests with Xcode
|
48
52
|
|
49
|
-
|
53
|
+
Select the Tests Source file from the file inspector. You can trigger tests by clicking on one of the diamonds in the gutter of the file. The diamond next to the class definition will run all the tests, whereas the diamond next to each individual test will run only that test.
|
50
54
|
|
51
|
-
|
55
|
+
![tests](/docs/img/tests.png)
|
52
56
|
|
53
|
-
|
57
|
+
Tests can also be invoked with Command-U, from the Test Inspector (Command-5), or from the sub-menu under the play button in the top bar. Red errors alongside all the tests are normal, since you have not witten any code yet!
|
54
58
|
|
55
|
-
|
59
|
+
![failing tests](/docs/img/tests-fail.png)
|
56
60
|
|
57
|
-
|
61
|
+
Test driven development is a very iterative process. The first step is to successfully run the tests and have them fail. Next try "sliming a test" by creating a method that returns a correct hard coded value for the first test. Sliming will confirm the project can compile and pass one test.
|
58
62
|
|
59
|
-
|
60
|
-
2. Press Command-N and choose Playground from the template chooser. Click Next, and click Create.
|
63
|
+
Next, replace the hard coded value with code that generates the expected return value and test again. Keep repeating this cycle until all the tests pass.
|
61
64
|
|
62
|
-
|
65
|
+
Remember that the exercise is solved with code in the application source file alone. As you enter your solution into the Swift Source file, Xcode will continuously update the display with errors that highlight code that will not compile.
|
63
66
|
|
64
|
-
|
67
|
+
Once all the tests are marked with a green icon, congratulations, you have successfully completed the exercise! Now submit it to the Exercism website for review. If you are impossibly stuck, submit the exercise before it is complete to view how other users solved the exercise.
|
65
68
|
|
66
|
-
|
69
|
+
![passing tests](/docs/img/tests-pass.png)
|
67
70
|
|
68
|
-
|
71
|
+
*The Hello-World exercise is a very simple coding problem, but the complexity of Xcode can make even simple exercises complex. We can ignore most of this complexity, because we only need to edit one file. You can always regenerate the Xcode project if something goes wrong.*
|
69
72
|
|
70
73
|
## Submission
|
71
74
|
|
72
|
-
1. In the Terminal, navigate to the folder that contains the application source file. In this example, the path would be `~/exercism/swift/hello-world/HelloWorld/HelloWorld/`
|
73
|
-
2. To submit, type `exercism submit HelloWorld.swift` (_Alternatively, you can submit by using the file name with the full path from any directory. A second alternative is to locate the file you need to submit in the Finder. Open the Terminal, type exercism submit followed by a space, then drag the file from the Finder into the Terminal and press return._)
|
74
|
-
3. Once uploaded, a URL will appear that reveals your solution on the Exercism web site.
|
75
|
-
4. The Exercism CLI allows files to be submitted more than once, and each successive iteration will be added alongside the original.
|
76
|
-
|
77
75
|
To review:
|
78
76
|
|
79
77
|
* **HelloWorld.swift** is the Swift Source code file where you code the solution and later submit it to Exercism.
|
80
78
|
* **HelloWorldTest.swift** is the Test Source code file provided by Exercism. It contains the tests that define the exercise.
|
81
79
|
* **MyPlayground.playground** is for drafting code snippets and playing with ideas.
|
82
80
|
|
83
|
-
|
81
|
+
To submit:
|
82
|
+
|
83
|
+
1. In the Terminal, navigate to the folder that contains the application source file. In this example, the path would be `~/exercism/swift/hello-world/HelloWorld/HelloWorld/`
|
84
|
+
2. To submit, type `exercism submit HelloWorld.swift` (_Alternatively, you can submit by using the file name with the full path from any directory. A second alternative is to locate the file you need to submit in the Finder. Open the Terminal, type exercism submit followed by a space, then drag the file from the Finder into the Terminal and press return._)
|
85
|
+
3. Once uploaded, a URL will appear that reveals your solution on the Exercism web site.
|
86
|
+
4. The Exercism CLI allows files to be submitted more than once, and each successive iteration will be added alongside the original.
|
87
|
+
|
88
|
+
To participate in code reviews:
|
84
89
|
|
85
|
-
After you submit a file, follow the URL presented to show the submission on the web. Bookmark it for future reference. From your submission page you can view how others solved the same problem.
|
90
|
+
* After you submit a file, follow the URL presented to show the submission on the web. Bookmark it for future reference. From your submission page you can view how others solved the same problem.
|
86
91
|
|
87
92
|
### More Information
|
88
93
|
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.6.
|
4
|
+
version: 2.0.6.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -1382,6 +1382,8 @@ files:
|
|
1382
1382
|
- tracks/csharp/exercises/flatten-array/FlattenArrayTest.cs
|
1383
1383
|
- tracks/csharp/exercises/food-chain/Example.cs
|
1384
1384
|
- tracks/csharp/exercises/food-chain/FoodChainTest.cs
|
1385
|
+
- tracks/csharp/exercises/forth/Example.cs
|
1386
|
+
- tracks/csharp/exercises/forth/ForthTest.cs
|
1385
1387
|
- tracks/csharp/exercises/gigasecond/Example.cs
|
1386
1388
|
- tracks/csharp/exercises/gigasecond/GigasecondTest.cs
|
1387
1389
|
- tracks/csharp/exercises/go-counting/Example.cs
|
@@ -2566,6 +2568,10 @@ files:
|
|
2566
2568
|
- tracks/fsharp/exercises/ledger/Example.fs
|
2567
2569
|
- tracks/fsharp/exercises/ledger/Ledger.fs
|
2568
2570
|
- tracks/fsharp/exercises/ledger/LedgerTest.fs
|
2571
|
+
- tracks/fsharp/exercises/lens-person/Example.fs
|
2572
|
+
- tracks/fsharp/exercises/lens-person/HINTS.md
|
2573
|
+
- tracks/fsharp/exercises/lens-person/LensPerson.fs
|
2574
|
+
- tracks/fsharp/exercises/lens-person/LensPersonTest.fs
|
2569
2575
|
- tracks/fsharp/exercises/linked-list/Example.fs
|
2570
2576
|
- tracks/fsharp/exercises/linked-list/HINTS.md
|
2571
2577
|
- tracks/fsharp/exercises/linked-list/LinkedListTest.fs
|
@@ -3876,7 +3882,6 @@ files:
|
|
3876
3882
|
- tracks/javascript/exercises/binary-search/example.js
|
3877
3883
|
- tracks/javascript/exercises/binary/binary.spec.js
|
3878
3884
|
- tracks/javascript/exercises/binary/example.js
|
3879
|
-
- tracks/javascript/exercises/bob/bob.js
|
3880
3885
|
- tracks/javascript/exercises/bob/bob.spec.js
|
3881
3886
|
- tracks/javascript/exercises/bob/example.js
|
3882
3887
|
- tracks/javascript/exercises/bowling/bowling.spec.js
|
@@ -3925,6 +3930,7 @@ files:
|
|
3925
3930
|
- tracks/javascript/exercises/largest-series-product/example.js
|
3926
3931
|
- tracks/javascript/exercises/largest-series-product/largest-series-product.spec.js
|
3927
3932
|
- tracks/javascript/exercises/leap/example.js
|
3933
|
+
- tracks/javascript/exercises/leap/leap.js
|
3928
3934
|
- tracks/javascript/exercises/leap/leap.spec.js
|
3929
3935
|
- tracks/javascript/exercises/linked-list/example.js
|
3930
3936
|
- tracks/javascript/exercises/linked-list/linked-list.spec.js
|
@@ -4840,6 +4846,9 @@ files:
|
|
4840
4846
|
- tracks/objective-c/exercises/bob/BobExample.h
|
4841
4847
|
- tracks/objective-c/exercises/bob/BobExample.m
|
4842
4848
|
- tracks/objective-c/exercises/bob/BobTest.m
|
4849
|
+
- tracks/objective-c/exercises/bracket-push/BracketPushExample.h
|
4850
|
+
- tracks/objective-c/exercises/bracket-push/BracketPushExample.m
|
4851
|
+
- tracks/objective-c/exercises/bracket-push/BracketPushTest.m
|
4843
4852
|
- tracks/objective-c/exercises/clock/ClockExample.h
|
4844
4853
|
- tracks/objective-c/exercises/clock/ClockExample.m
|
4845
4854
|
- tracks/objective-c/exercises/clock/ClockTest.m
|
@@ -4906,6 +4915,9 @@ files:
|
|
4906
4915
|
- tracks/objective-c/exercises/space-age/SpaceAgeExample.h
|
4907
4916
|
- tracks/objective-c/exercises/space-age/SpaceAgeExample.m
|
4908
4917
|
- tracks/objective-c/exercises/space-age/SpaceAgeTest.m
|
4918
|
+
- tracks/objective-c/exercises/sublist/SublistExample.h
|
4919
|
+
- tracks/objective-c/exercises/sublist/SublistExample.m
|
4920
|
+
- tracks/objective-c/exercises/sublist/SublistTest.m
|
4909
4921
|
- tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.h
|
4910
4922
|
- tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesExample.m
|
4911
4923
|
- tracks/objective-c/exercises/sum-of-multiples/SumOfMultiplesTest.m
|
@@ -5170,6 +5182,17 @@ files:
|
|
5170
5182
|
- tracks/pascal/docs/LEARNING.md
|
5171
5183
|
- tracks/pascal/docs/RESOURCES.md
|
5172
5184
|
- tracks/pascal/docs/TESTS.md
|
5185
|
+
- tracks/pascal/docs/img/00delphiwelcomepage.png
|
5186
|
+
- tracks/pascal/docs/img/01delphiclicktools.png
|
5187
|
+
- tracks/pascal/docs/img/02delphiclickoptions.png
|
5188
|
+
- tracks/pascal/docs/img/03delphioptionsenvironmentvariables.png
|
5189
|
+
- tracks/pascal/docs/img/04delphioptionsenvironmentvariablesclicknew.png
|
5190
|
+
- tracks/pascal/docs/img/05delphinewuservariable.png
|
5191
|
+
- tracks/pascal/docs/img/06delphioptionslibrary.png
|
5192
|
+
- tracks/pascal/docs/img/07delphiclicklibrarypathbutton.png
|
5193
|
+
- tracks/pascal/docs/img/08delphidirectoriesinputvarnameclickadd.png
|
5194
|
+
- tracks/pascal/docs/img/09delphidirectoriesclickok.png
|
5195
|
+
- tracks/pascal/docs/img/10delphioptonsclickok.png
|
5173
5196
|
- tracks/pascal/exercises/.keep
|
5174
5197
|
- tracks/pascal/exercises/allergies/AllergyTests.dpr
|
5175
5198
|
- tracks/pascal/exercises/allergies/uAllergiesExample.pas
|
@@ -5472,6 +5495,8 @@ files:
|
|
5472
5495
|
- tracks/php/exercises/bob/HINTS.md
|
5473
5496
|
- tracks/php/exercises/bob/bob_test.php
|
5474
5497
|
- tracks/php/exercises/bob/example.php
|
5498
|
+
- tracks/php/exercises/book-store/book-store_test.php
|
5499
|
+
- tracks/php/exercises/book-store/example.php
|
5475
5500
|
- tracks/php/exercises/bowling/bowling_test.php
|
5476
5501
|
- tracks/php/exercises/bowling/example.php
|
5477
5502
|
- tracks/php/exercises/bracket-push/bracket-push_test.php
|