trackler 2.0.6.19 → 2.0.6.20

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/config.json +8 -0
  4. data/tracks/csharp/exercises/forth/Example.cs +257 -0
  5. data/tracks/csharp/exercises/forth/ForthTest.cs +134 -0
  6. data/tracks/fsharp/config.json +7 -1
  7. data/tracks/fsharp/exercises/exercises.fsproj +20 -0
  8. data/tracks/fsharp/exercises/lens-person/Example.fs +50 -0
  9. data/tracks/fsharp/exercises/lens-person/HINTS.md +2 -0
  10. data/tracks/fsharp/exercises/lens-person/LensPerson.fs +24 -0
  11. data/tracks/fsharp/exercises/lens-person/LensPersonTest.fs +43 -0
  12. data/tracks/fsharp/exercises/paket.references +2 -1
  13. data/tracks/fsharp/paket.dependencies +1 -0
  14. data/tracks/fsharp/paket.lock +1 -0
  15. data/tracks/javascript/exercises/{bob/bob.js → leap/leap.js} +3 -3
  16. data/tracks/julia/README.md +16 -0
  17. data/tracks/objective-c/config.json +17 -0
  18. data/tracks/objective-c/exercises/bracket-push/BracketPushExample.h +8 -0
  19. data/tracks/objective-c/exercises/bracket-push/BracketPushExample.m +386 -0
  20. data/tracks/objective-c/exercises/bracket-push/BracketPushTest.m +84 -0
  21. data/tracks/objective-c/exercises/sublist/SublistExample.h +7 -0
  22. data/tracks/objective-c/exercises/sublist/SublistExample.m +67 -0
  23. data/tracks/objective-c/exercises/sublist/SublistTest.m +139 -0
  24. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +55 -2
  25. data/tracks/ocaml/exercises/dominoes/test.ml +11 -5
  26. data/tracks/ocaml/exercises/luhn/test.ml +3 -3
  27. data/tracks/ocaml/tools/test-generator/templates/dominoes/template.ml +11 -5
  28. data/tracks/pascal/config.json +1 -1
  29. data/tracks/pascal/docs/INSTALLATION.md +52 -0
  30. data/tracks/pascal/docs/img/00delphiwelcomepage.png +0 -0
  31. data/tracks/pascal/docs/img/01delphiclicktools.png +0 -0
  32. data/tracks/pascal/docs/img/02delphiclickoptions.png +0 -0
  33. data/tracks/pascal/docs/img/03delphioptionsenvironmentvariables.png +0 -0
  34. data/tracks/pascal/docs/img/04delphioptionsenvironmentvariablesclicknew.png +0 -0
  35. data/tracks/pascal/docs/img/05delphinewuservariable.png +0 -0
  36. data/tracks/pascal/docs/img/06delphioptionslibrary.png +0 -0
  37. data/tracks/pascal/docs/img/07delphiclicklibrarypathbutton.png +0 -0
  38. data/tracks/pascal/docs/img/08delphidirectoriesinputvarnameclickadd.png +0 -0
  39. data/tracks/pascal/docs/img/09delphidirectoriesclickok.png +0 -0
  40. data/tracks/pascal/docs/img/10delphioptonsclickok.png +0 -0
  41. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountExample.pas +9 -18
  42. data/tracks/pascal/exercises/nucleotide-count/uNucleotideCountTest.pas +16 -16
  43. data/tracks/php/config.json +7 -0
  44. data/tracks/php/exercises/book-store/book-store_test.php +146 -0
  45. data/tracks/php/exercises/book-store/example.php +38 -0
  46. data/tracks/swift/docs/TESTS.md +40 -35
  47. data/tracks/swift/docs/img/tests-fail.png +0 -0
  48. data/tracks/swift/docs/img/tests-pass.png +0 -0
  49. data/tracks/swift/docs/img/tests.png +0 -0
  50. metadata +28 -3
@@ -0,0 +1,84 @@
1
+ #import <XCTest/XCTest.h>
2
+ #if __has_include("BracketPushExample.h")
3
+ # import "BracketPushExample.h"
4
+ # else
5
+ # import "BracketPush.h"
6
+ #endif
7
+ @interface BracketPushTest : XCTestCase
8
+
9
+ @end
10
+
11
+ @implementation BracketPushTest
12
+
13
+ - (void)testPairedSquareBrackets {
14
+
15
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"[]"]);
16
+ }
17
+
18
+ -(void)testEmptyString{
19
+
20
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@""]);
21
+
22
+ }
23
+
24
+ -(void)testUnpairedBrackets{
25
+
26
+ XCTAssertFalse([BracketPushExample validateBracketPairingAndNestingInString:@"[["]);
27
+
28
+ }
29
+
30
+ -(void)testWrongOrderedBrackets{
31
+
32
+ XCTAssertFalse([BracketPushExample validateBracketPairingAndNestingInString:@"}{"]);
33
+
34
+ }
35
+
36
+ -(void)testPairedWithWhitespace{
37
+
38
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"{ }"]);
39
+
40
+ }
41
+
42
+ -(void)testSimpleNestedBrackets{
43
+
44
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"{[]}"]);
45
+
46
+ }
47
+
48
+ -(void)testSeveralPairedBrackets{
49
+
50
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"{}[]"]);
51
+ }
52
+
53
+ -(void)testPairedAndNestedBrackets{
54
+
55
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"([{}({}[])])"]);
56
+ }
57
+
58
+ -(void)testUnopenedClosingBrackets{
59
+
60
+ XCTAssertFalse([BracketPushExample validateBracketPairingAndNestingInString:@"{[)][]}"]);
61
+
62
+ }
63
+
64
+ -(void)testUnpairedAndNestedBrackets{
65
+
66
+ XCTAssertFalse([BracketPushExample validateBracketPairingAndNestingInString:@"([{])"]);
67
+ }
68
+
69
+ -(void)testPairedAndWrongNestedBrackets{
70
+
71
+ XCTAssertFalse([BracketPushExample validateBracketPairingAndNestingInString:@"[({]})"]);
72
+
73
+ }
74
+
75
+ -(void)testMathExpression{
76
+
77
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"(((185 + 223.85) * 15) - 543)/2"]);
78
+ }
79
+
80
+ -(void)testComplexLatexExpression{
81
+
82
+ XCTAssertTrue([BracketPushExample validateBracketPairingAndNestingInString:@"\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)"]);
83
+ }
84
+ @end
@@ -0,0 +1,7 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ @interface SublistExample : NSObject
4
+
5
+ +(NSString*)classifierForFirstList:(NSArray*)firstArray andSecondList:(NSArray*)secondArray;
6
+
7
+ @end
@@ -0,0 +1,67 @@
1
+ #import "SublistExample.h"
2
+
3
+ @implementation SublistExample
4
+
5
+ +(NSString*)classifierForFirstList:(NSArray *)firstArray andSecondList:(NSArray *)secondArray{
6
+
7
+ if([firstArray isEqualToArray:secondArray]){
8
+
9
+ return @"equal";
10
+
11
+ }else if(firstArray.count == 0 || secondArray.count == 0){
12
+
13
+ if(firstArray.count == 0){
14
+
15
+ return @"sublist";
16
+ }
17
+
18
+ return @"superlist";
19
+
20
+ }else if(firstArray.count != secondArray.count){
21
+
22
+ int i = 0;
23
+ int count = 0;
24
+ NSMutableArray *smallerArray = [NSMutableArray array];
25
+
26
+ int iterations = 0;
27
+ iterations = MAX((int)firstArray.count, (int)secondArray.count) - ((MIN((int)firstArray.count, (int)secondArray.count)-1));
28
+
29
+ while(iterations > 0){
30
+
31
+ int j = i;
32
+ while(count <= (MIN(firstArray.count, secondArray.count) - 1)){
33
+
34
+ if(firstArray.count > secondArray.count){
35
+
36
+ [smallerArray addObject:[firstArray objectAtIndex:j]];
37
+ }else{
38
+
39
+ [smallerArray addObject:[secondArray objectAtIndex:j]];
40
+ }
41
+ j++;
42
+ count++;
43
+ }
44
+
45
+ if([smallerArray isEqualToArray:firstArray]){
46
+
47
+ return @"sublist";
48
+
49
+ }else if([smallerArray isEqualToArray:secondArray]){
50
+
51
+ return @"superlist";
52
+ }else{
53
+
54
+ [smallerArray removeAllObjects];
55
+ i++;
56
+ count=0;
57
+ }
58
+
59
+
60
+ iterations--;
61
+ }
62
+
63
+ }
64
+
65
+ return @"unequal";
66
+ }
67
+ @end
@@ -0,0 +1,139 @@
1
+ #import <XCTest/XCTest.h>
2
+
3
+ #if __has_include("SublistExample.h")
4
+ # import "SublistExample.h"
5
+ # else
6
+ # import "Sublist.h"
7
+ #endif
8
+
9
+ @interface SublistTest : XCTestCase
10
+
11
+ @end
12
+
13
+ @implementation SublistTest
14
+
15
+
16
+ - (void)testEmptyLists {
17
+
18
+ XCTAssertEqualObjects(@"equal", [SublistExample classifierForFirstList:@[] andSecondList:@[]]);
19
+ }
20
+
21
+ - (void)testEmptyListWithinNonEmptyList{
22
+
23
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
24
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:@[] andSecondList:secondList]);
25
+
26
+ }
27
+
28
+ - (void)testNonEmptyListContainsEmptyList{
29
+
30
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
31
+ XCTAssertEqualObjects(@"superlist", [SublistExample classifierForFirstList:firstList andSecondList:@[]]);
32
+ }
33
+
34
+ - (void)testListEqualsItself{
35
+
36
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
37
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
38
+ XCTAssertEqualObjects(@"equal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
39
+ }
40
+
41
+ -(void)testDifferentLists{
42
+
43
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
44
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4], nil];
45
+ XCTAssertEqualObjects(@"unequal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
46
+ }
47
+
48
+ -(void)testFalseStart{
49
+
50
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:5], nil];
51
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:5],[NSNumber numberWithInt:6], nil];
52
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
53
+ }
54
+
55
+ -(void)testConsecutive{
56
+
57
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2], nil];
58
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:1],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2], nil];
59
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
60
+ }
61
+
62
+ -(void)testSublistAtStart{
63
+
64
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2], nil];
65
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
66
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
67
+ }
68
+
69
+ -(void)testSublistInMiddle{
70
+
71
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4], nil];
72
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
73
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
74
+ }
75
+
76
+ -(void)testSublistAtEnd{
77
+
78
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
79
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
80
+ XCTAssertEqualObjects(@"sublist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
81
+ }
82
+
83
+ -(void)testAtStartOfSuperlist{
84
+
85
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
86
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2], nil];
87
+ ;
88
+ XCTAssertEqualObjects(@"superlist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
89
+ }
90
+
91
+ -(void)testAtMiddleOfSuperlist{
92
+
93
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
94
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
95
+ ;
96
+ XCTAssertEqualObjects(@"superlist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
97
+ }
98
+
99
+ -(void)testAtEndOfSuperlist{
100
+
101
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
102
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:3],[NSNumber numberWithInt:4],[NSNumber numberWithInt:5], nil];
103
+ ;
104
+ XCTAssertEqualObjects(@"superlist", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
105
+ }
106
+
107
+ -(void)testFirstListMissingElementFromSecondList{
108
+
109
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:3], nil];
110
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
111
+ ;
112
+ XCTAssertEqualObjects(@"unequal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
113
+ }
114
+
115
+ -(void)testSecondListMissingOneElementFromFirstList{
116
+
117
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3], nil];
118
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:3], nil];
119
+ ;
120
+ XCTAssertEqualObjects(@"unequal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
121
+ }
122
+
123
+ -(void)testOrderMattersToAList{
124
+
125
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],nil];
126
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:3],[NSNumber numberWithInt:2],[NSNumber numberWithInt:1], nil];
127
+ ;
128
+ XCTAssertEqualObjects(@"unequal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
129
+ }
130
+
131
+ -(void)testSameDigitsButDifferentNumbers{
132
+
133
+ NSArray *firstList = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:0],[NSNumber numberWithInt:1],nil];
134
+ NSArray *secondList = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:1], nil];
135
+ ;
136
+ XCTAssertEqualObjects(@"unequal", [SublistExample classifierForFirstList:firstList andSecondList:secondList]);
137
+ }
138
+
139
+ @end
@@ -47,9 +47,18 @@
47
47
  1EFACABA1CCCAF3D006F2E69 /* SpaceAgeTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFACA9F1CCCAF3D006F2E69 /* SpaceAgeTest.m */; };
48
48
  1EFACABB1CCCAF3D006F2E69 /* WordCountExample.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFACAA11CCCAF3D006F2E69 /* WordCountExample.m */; };
49
49
  1EFACABC1CCCAF3D006F2E69 /* WordCountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFACAA21CCCAF3D006F2E69 /* WordCountTest.m */; };
50
+
51
+ A0BBFCBF1E37719800230071 /* SublistExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCBE1E37719800230071 /* SublistExample.m */; };
52
+ A0BBFCC31E37728100230071 /* SublistTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCC21E37728100230071 /* SublistTest.m */; };
53
+
54
+
55
+ A097D40F1E363C2700EAF2C2 /* BracketPushExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A097D40D1E363C2700EAF2C2 /* BracketPushExample.m */; };
56
+ A097D4101E363C2700EAF2C2 /* BracketPushTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A097D40E1E363C2700EAF2C2 /* BracketPushTest.m */; };
57
+
50
58
  A065F5781E3098080048E337 /* BeerSongExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A065F5761E3098080048E337 /* BeerSongExample.m */; };
51
59
  A065F5791E3098080048E337 /* BeerSongTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A065F5771E3098080048E337 /* BeerSongTest.m */; };
52
- E907D0CA1D6B731600106C42 /* GigasecondExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E907D0C91D6B731600106C42 /* GigasecondExample.m */; };
60
+
61
+ E907D0CA1D6B731600106C42 /* GigasecondExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E907D0C91D6B731600106C42 /* GigasecondExample.m */; };
53
62
  E907D0CC1D6B734800106C42 /* GigasecondTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E907D0CB1D6B734800106C42 /* GigasecondTest.m */; };
54
63
  E907FE921D87547D00B93DA9 /* ScrabbleScoreExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E907FE911D87547D00B93DA9 /* ScrabbleScoreExample.m */; };
55
64
  E907FE941D87554500B93DA9 /* ScrabbleScoreTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E907FE931D87554500B93DA9 /* ScrabbleScoreTest.m */; };
@@ -131,9 +140,21 @@
131
140
  1EFACAA01CCCAF3D006F2E69 /* WordCountExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordCountExample.h; path = "../../exercises/word-count/WordCountExample.h"; sourceTree = "<group>"; };
132
141
  1EFACAA11CCCAF3D006F2E69 /* WordCountExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordCountExample.m; path = "../../exercises/word-count/WordCountExample.m"; sourceTree = "<group>"; };
133
142
  1EFACAA21CCCAF3D006F2E69 /* WordCountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WordCountTest.m; path = "../../exercises/word-count/WordCountTest.m"; sourceTree = "<group>"; };
143
+
144
+ A0BBFCBD1E37719800230071 /* SublistExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SublistExample.h; path = ../../exercises/sublist/SublistExample.h; sourceTree = "<group>"; };
145
+ A0BBFCBE1E37719800230071 /* SublistExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistExample.m; path = ../../exercises/sublist/SublistExample.m; sourceTree = "<group>"; };
146
+ A0BBFCC21E37728100230071 /* SublistTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistTest.m; path = ../../exercises/sublist/SublistTest.m; sourceTree = "<group>"; };
147
+
148
+
149
+ A097D40C1E363C1A00EAF2C2 /* BracketPushExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BracketPushExample.h; path = "../../exercises/bracket-push/BracketPushExample.h"; sourceTree = "<group>"; };
150
+ A097D40D1E363C2700EAF2C2 /* BracketPushExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BracketPushExample.m; path = "../../exercises/bracket-push/BracketPushExample.m"; sourceTree = "<group>"; };
151
+ A097D40E1E363C2700EAF2C2 /* BracketPushTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BracketPushTest.m; path = "../../exercises/bracket-push/BracketPushTest.m"; sourceTree = "<group>"; };
152
+
134
153
  A065F5751E3098080048E337 /* BeerSongExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BeerSongExample.h; path = "../../exercises/beer-song/BeerSongExample.h"; sourceTree = "<group>"; };
135
154
  A065F5761E3098080048E337 /* BeerSongExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BeerSongExample.m; path = "../../exercises/beer-song/BeerSongExample.m"; sourceTree = "<group>"; };
136
155
  A065F5771E3098080048E337 /* BeerSongTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BeerSongTest.m; path = "../../exercises/beer-song/BeerSongTest.m"; sourceTree = "<group>"; };
156
+
157
+
137
158
  E907D0C81D6B731600106C42 /* GigasecondExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GigasecondExample.h; path = ../../exercises/gigasecond/GigasecondExample.h; sourceTree = "<group>"; };
138
159
  E907D0C91D6B731600106C42 /* GigasecondExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GigasecondExample.m; path = ../../exercises/gigasecond/GigasecondExample.m; sourceTree = "<group>"; };
139
160
  E907D0CB1D6B734800106C42 /* GigasecondTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GigasecondTest.m; path = ../../exercises/gigasecond/GigasecondTest.m; sourceTree = "<group>"; };
@@ -214,6 +235,7 @@
214
235
  E9386EEB1E0B68F90009A414 /* AtbashCipher */,
215
236
  A0CE03811E2F994200669F42 /* BeerSong */,
216
237
  E9E8B6EC1D519DEF0012F12C /* Bob */,
238
+ A09A906D1E28C1380087CCB7 /* BracketPush */,
217
239
  E9381D4F1D8F2DA4003F22A1 /* Clock */,
218
240
  E9381D431D8EDFB8003F22A1 /* DifferenceOfSquares */,
219
241
  E9E8B6ED1D519DF50012F12C /* Etl */,
@@ -236,6 +258,7 @@
236
258
  E907FE8F1D87545300B93DA9 /* ScrabbleScore */,
237
259
  E9C1C0201D9D98B80015E86E /* SecretHandshake */,
238
260
  E9E8B6F61D519E340012F12C /* SpaceAge */,
261
+ A0BBFCBC1E37703D00230071 /* Sublist */,
239
262
  E99D1D7B1D5532C50006A303 /* SumOfMultiples */,
240
263
  E96993951DF60DF1009EA223 /* Transpose */,
241
264
  E947A4DB1D81FDDA00633720 /* Triangle */,
@@ -261,6 +284,30 @@
261
284
  name = Products;
262
285
  sourceTree = "<group>";
263
286
  };
287
+
288
+ A0BBFCBC1E37703D00230071 /* Sublist */ = {
289
+ isa = PBXGroup;
290
+ children = (
291
+ A0BBFCBD1E37719800230071 /* SublistExample.h */,
292
+ A0BBFCBE1E37719800230071 /* SublistExample.m */,
293
+ A0BBFCC21E37728100230071 /* SublistTest.m */,
294
+ );
295
+ name = Sublist;
296
+ sourceTree = "<group>";
297
+ };
298
+
299
+
300
+ A09A906D1E28C1380087CCB7 /* BracketPush */ = {
301
+ isa = PBXGroup;
302
+ children = (
303
+ A097D40C1E363C1A00EAF2C2 /* BracketPushExample.h */,
304
+ A097D40D1E363C2700EAF2C2 /* BracketPushExample.m */,
305
+ A097D40E1E363C2700EAF2C2 /* BracketPushTest.m */,
306
+ );
307
+ name = BracketPush;
308
+ sourceTree = "<group>";
309
+ };
310
+
264
311
  A0CE03811E2F994200669F42 /* BeerSong */ = {
265
312
  isa = PBXGroup;
266
313
  children = (
@@ -269,8 +316,10 @@
269
316
  A065F5771E3098080048E337 /* BeerSongTest.m */,
270
317
  );
271
318
  name = BeerSong;
272
- sourceTree = "<group>";
319
+ sourceTree = "<group>";
273
320
  };
321
+
322
+
274
323
  E907D0C71D6B72B600106C42 /* Gigasecond */ = {
275
324
  isa = PBXGroup;
276
325
  children = (
@@ -685,11 +734,13 @@
685
734
  E9C1C0291D9DB16B0015E86E /* AcronymExample.m in Sources */,
686
735
  1EFACAA41CCCAF3D006F2E69 /* AnagramTest.m in Sources */,
687
736
  E907FE921D87547D00B93DA9 /* ScrabbleScoreExample.m in Sources */,
737
+ A097D4101E363C2700EAF2C2 /* BracketPushTest.m in Sources */,
688
738
  1EFACABC1CCCAF3D006F2E69 /* WordCountTest.m in Sources */,
689
739
  1EFACAB11CCCAF3D006F2E69 /* NucleotideCountExample.m in Sources */,
690
740
  E9381D481D8EE00C003F22A1 /* DifferenceOfSquaresTest.m in Sources */,
691
741
  E907FE941D87554500B93DA9 /* ScrabbleScoreTest.m in Sources */,
692
742
  1EFACAB51CCCAF3D006F2E69 /* PhoneNumberExample.m in Sources */,
743
+ A0BBFCBF1E37719800230071 /* SublistExample.m in Sources */,
693
744
  E951B6B91D429550009EB5B6 /* AllergiesTest.m in Sources */,
694
745
  A065F5791E3098080048E337 /* BeerSongTest.m in Sources */,
695
746
  E9381D461D8EDFFA003F22A1 /* DifferenceOfSquaresExample.m in Sources */,
@@ -699,6 +750,7 @@
699
750
  E9381D521D8F2DCC003F22A1 /* ClockExample.m in Sources */,
700
751
  E99D1D811D5533BF0006A303 /* SumOfMultiplesExample.m in Sources */,
701
752
  E9F390071DFCA337005C5F46 /* IsogramExample.m in Sources */,
753
+ A0BBFCC31E37728100230071 /* SublistTest.m in Sources */,
702
754
  E9C1C02F1D9EC1130015E86E /* RunLengthEncodingExample.m in Sources */,
703
755
  E92FCC0F1D78F3B600061017 /* MeetupTest.m in Sources */,
704
756
  E9381D4E1D8F2982003F22A1 /* RaindropsTest.m in Sources */,
@@ -711,6 +763,7 @@
711
763
  E907D0CC1D6B734800106C42 /* GigasecondTest.m in Sources */,
712
764
  E9C1C0311D9EC1270015E86E /* RunLengthEncodingTest.m in Sources */,
713
765
  1EFACAA81CCCAF3D006F2E69 /* EtlTest.m in Sources */,
766
+ A097D40F1E363C2700EAF2C2 /* BracketPushExample.m in Sources */,
714
767
  E947A4E01D81FE3A00633720 /* TriangleTest.m in Sources */,
715
768
  1EFACAA91CCCAF3D006F2E69 /* GradeSchoolExample.m in Sources */,
716
769
  1EFACABA1CCCAF3D006F2E69 /* SpaceAgeTest.m in Sources */,
@@ -4,16 +4,22 @@ open Dominoes
4
4
 
5
5
  let print_dominoe (d1, d2) = sprintf "(%d,%d)" d1 d2
6
6
 
7
+ let dominoes_printer xs = "[" ^ String.concat ~sep:";" (List.map xs ~f:print_dominoe) ^ "]"
7
8
  let option_printer = function
8
9
  | None -> "None"
9
- | Some xs -> "Some [" ^ String.concat ~sep:";" (List.map xs ~f:print_dominoe) ^ "]"
10
+ | Some xs -> "Some " ^ dominoes_printer xs
10
11
 
11
- let drop_1_right xs = List.rev xs |> List.tl_exn |> List.rev
12
+ let rotate_1 xs = List.tl_exn xs @ [List.hd_exn xs]
12
13
 
13
- let check_chain (chained: dominoe list) =
14
+ let norm l =
15
+ let norm1 (x, y) = if x > y then (y, x) else (x, y) in
16
+ List.map ~f:norm1 l |> List.sort ~cmp:compare
17
+
18
+ let check_chain (input: dominoe list) (chained: dominoe list) =
19
+ assert_equal (norm input) (norm chained) ~printer:dominoes_printer ~msg:"chain doesn't use the same dominoes as the input";
14
20
  let assert_dominoes_match d1 d2 =
15
21
  if snd d1 <> fst d2 then failwith @@ sprintf "%s and %s cannot be chained together" (print_dominoe d1) (print_dominoe d2) else () in
16
- let consecutives = List.zip_exn (drop_1_right chained) (List.tl_exn chained) in
22
+ let consecutives = List.zip_exn chained (rotate_1 chained) in
17
23
  List.iter consecutives ~f:(fun (d1, d2) -> assert_dominoes_match d1 d2)
18
24
 
19
25
  let assert_empty c = if List.is_empty c then () else failwith "Expected 0 length chain"
@@ -21,7 +27,7 @@ let assert_empty c = if List.is_empty c then () else failwith "Expected 0 length
21
27
  let assert_valid_chain input _ctxt =
22
28
  match chain input with
23
29
  | None -> failwith "Expecting a chain"
24
- | Some(c) -> (if List.is_empty input then assert_empty else check_chain) c
30
+ | Some(c) -> (if List.is_empty input then assert_empty else check_chain input) c
25
31
 
26
32
  let assert_no_chain input _ctxt =
27
33
  assert_equal None (chain input) ~printer:option_printer