trackler 2.2.1.119 → 2.2.1.120
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/haskell/.travis.yml +3 -3
- data/tracks/haskell/exercises/accumulate/stack.yaml +1 -1
- data/tracks/haskell/exercises/acronym/stack.yaml +1 -1
- data/tracks/haskell/exercises/all-your-base/stack.yaml +1 -1
- data/tracks/haskell/exercises/allergies/stack.yaml +1 -1
- data/tracks/haskell/exercises/alphametics/stack.yaml +1 -1
- data/tracks/haskell/exercises/anagram/stack.yaml +1 -1
- data/tracks/haskell/exercises/atbash-cipher/stack.yaml +1 -1
- data/tracks/haskell/exercises/bank-account/stack.yaml +1 -1
- data/tracks/haskell/exercises/beer-song/stack.yaml +1 -1
- data/tracks/haskell/exercises/binary-search-tree/stack.yaml +1 -1
- data/tracks/haskell/exercises/binary/stack.yaml +1 -1
- data/tracks/haskell/exercises/bob/stack.yaml +1 -1
- data/tracks/haskell/exercises/bowling/stack.yaml +1 -1
- data/tracks/haskell/exercises/bracket-push/stack.yaml +1 -1
- data/tracks/haskell/exercises/change/stack.yaml +1 -1
- data/tracks/haskell/exercises/clock/stack.yaml +1 -1
- data/tracks/haskell/exercises/collatz-conjecture/stack.yaml +1 -1
- data/tracks/haskell/exercises/complex-numbers/stack.yaml +1 -1
- data/tracks/haskell/exercises/connect/stack.yaml +1 -1
- data/tracks/haskell/exercises/crypto-square/stack.yaml +1 -1
- data/tracks/haskell/exercises/custom-set/stack.yaml +1 -1
- data/tracks/haskell/exercises/diamond/stack.yaml +1 -1
- data/tracks/haskell/exercises/difference-of-squares/stack.yaml +1 -1
- data/tracks/haskell/exercises/dominoes/stack.yaml +1 -1
- data/tracks/haskell/exercises/etl/stack.yaml +1 -1
- data/tracks/haskell/exercises/food-chain/stack.yaml +1 -1
- data/tracks/haskell/exercises/forth/stack.yaml +1 -1
- data/tracks/haskell/exercises/gigasecond/stack.yaml +1 -1
- data/tracks/haskell/exercises/go-counting/stack.yaml +1 -1
- data/tracks/haskell/exercises/grade-school/stack.yaml +1 -1
- data/tracks/haskell/exercises/grains/stack.yaml +1 -1
- data/tracks/haskell/exercises/hamming/stack.yaml +1 -1
- data/tracks/haskell/exercises/hello-world/stack.yaml +1 -1
- data/tracks/haskell/exercises/hexadecimal/stack.yaml +1 -1
- data/tracks/haskell/exercises/house/stack.yaml +1 -1
- data/tracks/haskell/exercises/isbn-verifier/stack.yaml +1 -1
- data/tracks/haskell/exercises/isogram/stack.yaml +1 -1
- data/tracks/haskell/exercises/kindergarten-garden/stack.yaml +1 -1
- data/tracks/haskell/exercises/largest-series-product/stack.yaml +1 -1
- data/tracks/haskell/exercises/leap/stack.yaml +1 -1
- data/tracks/haskell/exercises/lens-person/stack.yaml +1 -1
- data/tracks/haskell/exercises/linked-list/stack.yaml +1 -1
- data/tracks/haskell/exercises/list-ops/stack.yaml +1 -1
- data/tracks/haskell/exercises/luhn/stack.yaml +1 -1
- data/tracks/haskell/exercises/matrix/stack.yaml +1 -1
- data/tracks/haskell/exercises/meetup/stack.yaml +1 -1
- data/tracks/haskell/exercises/minesweeper/stack.yaml +1 -1
- data/tracks/haskell/exercises/nth-prime/stack.yaml +1 -1
- data/tracks/haskell/exercises/nucleotide-count/stack.yaml +1 -1
- data/tracks/haskell/exercises/ocr-numbers/stack.yaml +1 -1
- data/tracks/haskell/exercises/octal/stack.yaml +1 -1
- data/tracks/haskell/exercises/palindrome-products/stack.yaml +1 -1
- data/tracks/haskell/exercises/pangram/stack.yaml +1 -1
- data/tracks/haskell/exercises/parallel-letter-frequency/stack.yaml +1 -1
- data/tracks/haskell/exercises/pascals-triangle/stack.yaml +1 -1
- data/tracks/haskell/exercises/perfect-numbers/stack.yaml +1 -1
- data/tracks/haskell/exercises/phone-number/stack.yaml +1 -1
- data/tracks/haskell/exercises/pig-latin/README.md +4 -4
- data/tracks/haskell/exercises/pig-latin/stack.yaml +1 -1
- data/tracks/haskell/exercises/poker/stack.yaml +1 -1
- data/tracks/haskell/exercises/pov/stack.yaml +1 -1
- data/tracks/haskell/exercises/prime-factors/stack.yaml +1 -1
- data/tracks/haskell/exercises/protein-translation/stack.yaml +1 -1
- data/tracks/haskell/exercises/pythagorean-triplet/stack.yaml +1 -1
- data/tracks/haskell/exercises/queen-attack/stack.yaml +1 -1
- data/tracks/haskell/exercises/rail-fence-cipher/stack.yaml +1 -1
- data/tracks/haskell/exercises/raindrops/stack.yaml +1 -1
- data/tracks/haskell/exercises/rna-transcription/stack.yaml +1 -1
- data/tracks/haskell/exercises/robot-name/stack.yaml +1 -1
- data/tracks/haskell/exercises/robot-simulator/stack.yaml +1 -1
- data/tracks/haskell/exercises/roman-numerals/stack.yaml +1 -1
- data/tracks/haskell/exercises/rotational-cipher/stack.yaml +1 -1
- data/tracks/haskell/exercises/run-length-encoding/stack.yaml +1 -1
- data/tracks/haskell/exercises/saddle-points/stack.yaml +1 -1
- data/tracks/haskell/exercises/say/stack.yaml +1 -1
- data/tracks/haskell/exercises/scrabble-score/stack.yaml +1 -1
- data/tracks/haskell/exercises/secret-handshake/stack.yaml +1 -1
- data/tracks/haskell/exercises/series/stack.yaml +1 -1
- data/tracks/haskell/exercises/sgf-parsing/stack.yaml +1 -1
- data/tracks/haskell/exercises/sieve/stack.yaml +1 -1
- data/tracks/haskell/exercises/simple-cipher/stack.yaml +1 -1
- data/tracks/haskell/exercises/simple-linked-list/stack.yaml +1 -1
- data/tracks/haskell/exercises/space-age/stack.yaml +1 -1
- data/tracks/haskell/exercises/spiral-matrix/stack.yaml +1 -1
- data/tracks/haskell/exercises/strain/stack.yaml +1 -1
- data/tracks/haskell/exercises/sublist/stack.yaml +1 -1
- data/tracks/haskell/exercises/sum-of-multiples/stack.yaml +1 -1
- data/tracks/haskell/exercises/transpose/stack.yaml +1 -1
- data/tracks/haskell/exercises/triangle/stack.yaml +1 -1
- data/tracks/haskell/exercises/trinary/stack.yaml +1 -1
- data/tracks/haskell/exercises/twelve-days/stack.yaml +1 -1
- data/tracks/haskell/exercises/word-count/stack.yaml +1 -1
- data/tracks/haskell/exercises/wordy/stack.yaml +1 -1
- data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -1
- data/tracks/haskell/exercises/zipper/stack.yaml +1 -1
- data/tracks/objective-c/config.json +15 -4
- data/tracks/objective-c/exercises/strain/README.md +48 -0
- data/tracks/objective-c/exercises/strain/StrainExample.h +10 -0
- data/tracks/objective-c/exercises/strain/StrainExample.m +36 -0
- data/tracks/objective-c/exercises/strain/StrainTest.m +233 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +19 -1
- data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotSimulatorTest.scala +1 -1
- data/tracks/scala/testgen/src/main/scala/RobotSimulatorTestGenerator.scala +31 -20
- data/tracks/typescript/config.json +16 -0
- data/tracks/typescript/exercises/transpose/README.md +91 -0
- data/tracks/typescript/exercises/transpose/package.json +36 -0
- data/tracks/typescript/exercises/transpose/transpose.example.ts +17 -0
- data/tracks/typescript/exercises/transpose/transpose.test.ts +58 -0
- data/tracks/typescript/exercises/transpose/transpose.ts +0 -0
- data/tracks/typescript/exercises/transpose/tsconfig.json +22 -0
- data/tracks/typescript/exercises/transpose/tslint.json +127 -0
- data/tracks/typescript/exercises/transpose/yarn.lock +2624 -0
- metadata +14 -2
@@ -0,0 +1,48 @@
|
|
1
|
+
# Strain
|
2
|
+
|
3
|
+
Implement the keep and discard operation on collections. Given a collection and a predicate on the collection's elements, keep returns a new collection containing those elements where the predicate is true, while discard returns a new collection containing those elements where the predicate is false.
|
4
|
+
|
5
|
+
For example, given the collection of numbers:
|
6
|
+
|
7
|
+
1, 2, 3, 4, 5
|
8
|
+
And the predicate:
|
9
|
+
|
10
|
+
is the number even?
|
11
|
+
Then your keep operation should produce:
|
12
|
+
|
13
|
+
2, 4
|
14
|
+
While your discard operation should produce:
|
15
|
+
|
16
|
+
1, 3, 5
|
17
|
+
Note that the union of keep and discard is all the elements.
|
18
|
+
|
19
|
+
The functions may be called keep and discard, or they may need different names in order to not clash with existing functions or concepts in your language.
|
20
|
+
|
21
|
+
Restrictions -
|
22
|
+
|
23
|
+
The filter/reject/whatchamacallit functionality provided by the standard library should not be used! This should be solved using other basic tools instead.
|
24
|
+
|
25
|
+
## Setup
|
26
|
+
|
27
|
+
There are two different methods of getting set up to run the tests with Objective-C:
|
28
|
+
|
29
|
+
- Create an Xcode project with a test target which will run the tests.
|
30
|
+
- Use the ruby gem `objc` as a test runner utility.
|
31
|
+
|
32
|
+
Both are described in more detail here: http://exercism.io/languages/objective-c
|
33
|
+
|
34
|
+
### Submitting Exercises
|
35
|
+
|
36
|
+
When submitting an exercise, make sure your solution file is in the same directory as the test code.
|
37
|
+
|
38
|
+
The submit command will look something like:
|
39
|
+
|
40
|
+
```shell
|
41
|
+
exercism submit <path-to-exercism-workspace>/objective-c/strain/Strain.m
|
42
|
+
```
|
43
|
+
|
44
|
+
You can find the Exercism workspace by running `exercism debug` and looking for the line beginning
|
45
|
+
with Workspace.
|
46
|
+
|
47
|
+
## Submitting Incomplete Solutions
|
48
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
#import "StrainExample.h"
|
3
|
+
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
5
|
+
|
6
|
+
@implementation NSArray (StrainExample)
|
7
|
+
|
8
|
+
-(instancetype)keep:(BOOL)compare where:(BOOL (^)(id))completionHandler{
|
9
|
+
|
10
|
+
NSMutableArray *filteredArray = [NSMutableArray array];
|
11
|
+
|
12
|
+
for(int index = 0;index < self.count;index++){
|
13
|
+
|
14
|
+
id objectInArray = self[index];
|
15
|
+
|
16
|
+
BOOL flag = completionHandler(objectInArray);
|
17
|
+
|
18
|
+
if(flag == compare){
|
19
|
+
|
20
|
+
[filteredArray addObject:objectInArray];
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
return filteredArray;
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
-(instancetype)discard:(BOOL (^)(id))completionHandler{
|
29
|
+
|
30
|
+
return [self keep:false where:completionHandler];
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
@end
|
35
|
+
|
36
|
+
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,233 @@
|
|
1
|
+
#import <XCTest/XCTest.h>
|
2
|
+
|
3
|
+
#if __has_include("StrainExample.h")
|
4
|
+
# import "StrainExample.h"
|
5
|
+
# else
|
6
|
+
# import "Strain.h"
|
7
|
+
#endif
|
8
|
+
|
9
|
+
@interface StrainTest : XCTestCase
|
10
|
+
|
11
|
+
@end
|
12
|
+
|
13
|
+
@implementation StrainTest
|
14
|
+
|
15
|
+
- (void)setUp {
|
16
|
+
[super setUp];
|
17
|
+
// Put setup code here. This method is called before the invocation of each test method in the class.
|
18
|
+
}
|
19
|
+
|
20
|
+
- (void)tearDown {
|
21
|
+
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
22
|
+
[super tearDown];
|
23
|
+
}
|
24
|
+
|
25
|
+
- (void)testEmptyKeep {
|
26
|
+
|
27
|
+
NSArray *inputArray = @[];
|
28
|
+
|
29
|
+
NSArray *expectedArray = inputArray;
|
30
|
+
|
31
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
32
|
+
|
33
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
34
|
+
int integerNumber = number.intValue;
|
35
|
+
return integerNumber < 10;
|
36
|
+
|
37
|
+
}]);
|
38
|
+
}
|
39
|
+
|
40
|
+
- (void)testKeepEverything {
|
41
|
+
|
42
|
+
NSArray *inputArray = @[@1,@2,@3];
|
43
|
+
|
44
|
+
NSArray *expectedArray = inputArray;
|
45
|
+
|
46
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
47
|
+
|
48
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
49
|
+
int integerNumber = number.intValue;
|
50
|
+
return integerNumber < 10;
|
51
|
+
|
52
|
+
}]);
|
53
|
+
}
|
54
|
+
|
55
|
+
-(void)testKeepFirstAndLastElements {
|
56
|
+
|
57
|
+
NSArray *inputArray = @[@1,@2,@3];
|
58
|
+
|
59
|
+
NSArray *expectedArray = @[@1,@3];
|
60
|
+
|
61
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
62
|
+
|
63
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
64
|
+
int integerNumber = number.intValue;
|
65
|
+
return integerNumber % 2 != 0;
|
66
|
+
|
67
|
+
}]);
|
68
|
+
}
|
69
|
+
|
70
|
+
-(void)testKeepNeitherFirstNorLastElement {
|
71
|
+
|
72
|
+
NSArray *inputArray = @[@1,@2,@3,@4,@5];
|
73
|
+
|
74
|
+
NSArray *expectedArray = @[@2,@4];
|
75
|
+
|
76
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
77
|
+
|
78
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
79
|
+
int integerNumber = number.intValue;
|
80
|
+
return integerNumber % 2 == 0;
|
81
|
+
|
82
|
+
}]);
|
83
|
+
}
|
84
|
+
|
85
|
+
-(void)testKeepStrings {
|
86
|
+
|
87
|
+
NSArray *inputArray = @[@"apple",@"zebra",@"banana",@"Zombies",@"cherimoya",@"zealot"];
|
88
|
+
|
89
|
+
NSArray *expectedArray = @[@"zebra",@"Zombies",@"zealot"];
|
90
|
+
|
91
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
92
|
+
|
93
|
+
NSString *string = (NSString*)arrayElement;
|
94
|
+
|
95
|
+
return ([string rangeOfString:@"z"].location != NSNotFound || [string rangeOfString:@"Z"].location != NSNotFound);
|
96
|
+
|
97
|
+
}]);
|
98
|
+
}
|
99
|
+
|
100
|
+
-(void)testKeepArrays {
|
101
|
+
|
102
|
+
NSArray *inputArray = @[@[@1,@2,@3],@[@5,@5,@5],@[@5,@1,@2],@[@2,@1,@2],@[@1,@5,@2],@[@2,@2,@1],@[@1,@2,@5]];
|
103
|
+
|
104
|
+
NSArray *expectedArray = @[@[@5,@5,@5],@[@5,@1,@2],@[@1,@5,@2],@[@1,@2,@5]];
|
105
|
+
|
106
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
107
|
+
|
108
|
+
NSArray *nestedArray = (NSArray*)arrayElement;
|
109
|
+
return [nestedArray containsObject:@5];
|
110
|
+
|
111
|
+
}]);
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
-(void)testDiscardEmptyArray {
|
116
|
+
|
117
|
+
NSArray *inputArray = @[];
|
118
|
+
|
119
|
+
NSArray *expectedArray = inputArray;
|
120
|
+
|
121
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
122
|
+
|
123
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
124
|
+
int integerNumber = number.intValue;
|
125
|
+
return integerNumber < 10;
|
126
|
+
|
127
|
+
}]);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
-(void)testDiscardNothing {
|
132
|
+
|
133
|
+
NSArray *inputArray = @[@1,@2,@3];
|
134
|
+
|
135
|
+
NSArray *expectedArray = inputArray;
|
136
|
+
|
137
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
138
|
+
|
139
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
140
|
+
int integerNumber = number.intValue;
|
141
|
+
return integerNumber > 10;
|
142
|
+
|
143
|
+
}]);
|
144
|
+
}
|
145
|
+
|
146
|
+
-(void)testDiscardFirstAndLastElements {
|
147
|
+
|
148
|
+
NSArray *inputArray = @[@1,@2,@3];
|
149
|
+
|
150
|
+
NSArray *expectedArray = @[@2];
|
151
|
+
|
152
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
153
|
+
|
154
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
155
|
+
int integerNumber = number.intValue;
|
156
|
+
return integerNumber % 2 != 0;
|
157
|
+
|
158
|
+
}]);
|
159
|
+
}
|
160
|
+
|
161
|
+
-(void)testDiscardNeitherFirstNorLastElement {
|
162
|
+
|
163
|
+
NSArray *inputArray = @[@1,@2,@3,@4,@5];
|
164
|
+
|
165
|
+
NSArray *expectedArray = @[@1,@3,@5];
|
166
|
+
|
167
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
168
|
+
|
169
|
+
NSNumber *number = (NSNumber*)arrayElement;
|
170
|
+
int integerNumber = number.intValue;
|
171
|
+
return integerNumber % 2 == 0;
|
172
|
+
|
173
|
+
}]);
|
174
|
+
}
|
175
|
+
|
176
|
+
-(void)testDiscardStrings {
|
177
|
+
|
178
|
+
NSArray *inputArray = @[@"apple",@"zebra",@"banana",@"Zombies",@"cherimoya",@"zealot"];
|
179
|
+
|
180
|
+
NSArray *expectedArray = @[@"apple",@"banana",@"cherimoya"];
|
181
|
+
|
182
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
183
|
+
|
184
|
+
NSString *string = (NSString*)arrayElement;
|
185
|
+
|
186
|
+
return ([string rangeOfString:@"z"].location != NSNotFound || [string rangeOfString:@"Z"].location != NSNotFound);
|
187
|
+
|
188
|
+
}]);
|
189
|
+
}
|
190
|
+
|
191
|
+
-(void)testDiscardArrays {
|
192
|
+
|
193
|
+
NSArray *inputArray = @[@[@1,@2,@3],@[@5,@5,@5],@[@5,@1,@2],@[@2,@1,@2],@[@1,@5,@2],@[@2,@2,@1],@[@1,@2,@5]];
|
194
|
+
|
195
|
+
NSArray *expectedArray = @[@[@1,@2,@3],@[@2,@1,@2],@[@2,@2,@1]];
|
196
|
+
|
197
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
198
|
+
|
199
|
+
NSArray *nestedArray = (NSArray*)arrayElement;
|
200
|
+
return [nestedArray containsObject:@5];
|
201
|
+
|
202
|
+
}]);
|
203
|
+
}
|
204
|
+
|
205
|
+
-(void)testKeepOnMutableArrays {
|
206
|
+
|
207
|
+
NSMutableArray *inputArray = [NSMutableArray arrayWithObjects:@[@1,@2,@3],@[@5,@5,@5],@[@5,@1,@2],@[@2,@1,@2],@[@1,@5,@2],@[@2,@2,@1],@[@1,@2,@5], nil];
|
208
|
+
|
209
|
+
NSArray *expectedArray = @[@[@5,@5,@5],@[@5,@1,@2],@[@1,@5,@2],@[@1,@2,@5]];
|
210
|
+
|
211
|
+
XCTAssertEqualObjects(expectedArray, [inputArray keep:true where:^BOOL(id _Nonnull arrayElement) {
|
212
|
+
|
213
|
+
NSArray *nestedArray = (NSArray*)arrayElement;
|
214
|
+
return [nestedArray containsObject:@5];
|
215
|
+
|
216
|
+
}]);
|
217
|
+
}
|
218
|
+
|
219
|
+
-(void)testDiscardOnMutableArrays {
|
220
|
+
|
221
|
+
NSMutableArray *inputArray = [NSMutableArray arrayWithObjects:@[@1,@2,@3],@[@5,@5,@5],@[@5,@1,@2],@[@2,@1,@2],@[@1,@5,@2],@[@2,@2,@1],@[@1,@2,@5], nil];
|
222
|
+
|
223
|
+
NSArray *expectedArray = @[@[@1,@2,@3],@[@2,@1,@2],@[@2,@2,@1]];
|
224
|
+
|
225
|
+
XCTAssertEqualObjects(expectedArray, [inputArray discard:^BOOL(id _Nonnull arrayElement) {
|
226
|
+
|
227
|
+
NSArray *nestedArray = (NSArray*)arrayElement;
|
228
|
+
return [nestedArray containsObject:@5];
|
229
|
+
|
230
|
+
}]);
|
231
|
+
}
|
232
|
+
|
233
|
+
@end
|
@@ -57,6 +57,8 @@
|
|
57
57
|
A09A4C051E38763300FEFB7A /* FlattenArrayTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A09A4C041E38763300FEFB7A /* FlattenArrayTest.m */; };
|
58
58
|
A0BBFCBF1E37719800230071 /* SublistExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCBE1E37719800230071 /* SublistExample.m */; };
|
59
59
|
A0BBFCC31E37728100230071 /* SublistTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BBFCC21E37728100230071 /* SublistTest.m */; };
|
60
|
+
A0CFCBF82056956B00DFE959 /* StrainExample.m in Sources */ = {isa = PBXBuildFile; fileRef = A0CFCBF52056956A00DFE959 /* StrainExample.m */; };
|
61
|
+
A0CFCBF92056956B00DFE959 /* StrainTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A0CFCBF62056956A00DFE959 /* StrainTest.m */; };
|
60
62
|
E90343B62041F989006F1833 /* PrimeFactorsExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E90343B52041F989006F1833 /* PrimeFactorsExample.m */; };
|
61
63
|
E90343BC20447437006F1833 /* PrimeFactorsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E90343BB20447437006F1833 /* PrimeFactorsTest.m */; };
|
62
64
|
E907D0CA1D6B731600106C42 /* GigasecondExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E907D0C91D6B731600106C42 /* GigasecondExample.m */; };
|
@@ -174,6 +176,9 @@
|
|
174
176
|
A0BBFCBD1E37719800230071 /* SublistExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SublistExample.h; path = ../../exercises/sublist/SublistExample.h; sourceTree = "<group>"; };
|
175
177
|
A0BBFCBE1E37719800230071 /* SublistExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistExample.m; path = ../../exercises/sublist/SublistExample.m; sourceTree = "<group>"; };
|
176
178
|
A0BBFCC21E37728100230071 /* SublistTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SublistTest.m; path = ../../exercises/sublist/SublistTest.m; sourceTree = "<group>"; };
|
179
|
+
A0CFCBF52056956A00DFE959 /* StrainExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StrainExample.m; path = ../../exercises/strain/StrainExample.m; sourceTree = "<group>"; };
|
180
|
+
A0CFCBF62056956A00DFE959 /* StrainTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StrainTest.m; path = ../../exercises/strain/StrainTest.m; sourceTree = "<group>"; };
|
181
|
+
A0CFCBF72056956A00DFE959 /* StrainExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StrainExample.h; path = ../../exercises/strain/StrainExample.h; sourceTree = "<group>"; };
|
177
182
|
E90343B42041F989006F1833 /* PrimeFactorsExample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PrimeFactorsExample.h; path = "../../exercises/prime-factors/PrimeFactorsExample.h"; sourceTree = "<group>"; };
|
178
183
|
E90343B52041F989006F1833 /* PrimeFactorsExample.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PrimeFactorsExample.m; path = "../../exercises/prime-factors/PrimeFactorsExample.m"; sourceTree = "<group>"; };
|
179
184
|
E90343BB20447437006F1833 /* PrimeFactorsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PrimeFactorsTest.m; path = "../../exercises/prime-factors/PrimeFactorsTest.m"; sourceTree = "<group>"; };
|
@@ -318,6 +323,7 @@
|
|
318
323
|
E90E59C720489199008C0FB5 /* Series */,
|
319
324
|
E97320091E9DA06500ABEE5C /* Sieve */,
|
320
325
|
E9E8B6F61D519E340012F12C /* SpaceAge */,
|
326
|
+
A0CFCBEF20568C3F00DFE959 /* Strain */,
|
321
327
|
A0BBFCBC1E37703D00230071 /* Sublist */,
|
322
328
|
E99D1D7B1D5532C50006A303 /* SumOfMultiples */,
|
323
329
|
E96993951DF60DF1009EA223 /* Transpose */,
|
@@ -396,6 +402,16 @@
|
|
396
402
|
name = BeerSong;
|
397
403
|
sourceTree = "<group>";
|
398
404
|
};
|
405
|
+
A0CFCBEF20568C3F00DFE959 /* Strain */ = {
|
406
|
+
isa = PBXGroup;
|
407
|
+
children = (
|
408
|
+
A0CFCBF72056956A00DFE959 /* StrainExample.h */,
|
409
|
+
A0CFCBF52056956A00DFE959 /* StrainExample.m */,
|
410
|
+
A0CFCBF62056956A00DFE959 /* StrainTest.m */,
|
411
|
+
);
|
412
|
+
name = Strain;
|
413
|
+
sourceTree = "<group>";
|
414
|
+
};
|
399
415
|
E90343B32041F93F006F1833 /* PrimeFactors */ = {
|
400
416
|
isa = PBXGroup;
|
401
417
|
children = (
|
@@ -893,7 +909,7 @@
|
|
893
909
|
);
|
894
910
|
runOnlyForDeploymentPostprocessing = 0;
|
895
911
|
shellPath = /bin/sh;
|
896
|
-
shellScript = "if [ -f ~/.
|
912
|
+
shellScript = "if [ -f ~/.profile ]; then\nsource ~/.profile\nfi\n\nhash oclint &> /dev/null\nif [ $? -eq 1 ]; then\necho >&2 \"oclint not found, analyzing stopped\"\nexit 1\nfi\n\nif [ ! -f \"${TARGET_TEMP_DIR}\"/xcodebuild.log ]; then\necho \"[*] xcodebuild.log not found, possibly clean was performed\"\necho \"[*] starting xcodebuild to rebuild the project..\"\n\ncd \"${SRCROOT}\"\n\nxcodebuild clean -configuration \"${CONFIGURATION}\" -project \"${PROJECT_NAME}\".xcodeproj\n\n#build xcodebuild.log\nxcodebuild -configuration \"${CONFIGURATION}\" -project \"${PROJECT_NAME}\".xcodeproj | tee \"${TARGET_TEMP_DIR}\"/xcodebuild.log\nfi\n\ncd \"${TARGET_TEMP_DIR}\"\n\necho \"[*] transforming xcodebuild.log into compile_commands.json...\"\n#transform it into compile_commands.json\noclint-xcodebuild\n\necho \"[*] starting analyzing\"\noclint-json-compilation-database -- \\\n -rc LONG_LINE=200 -disable-rule UselessParentheses -disable-rule ConstantConditionalOperator -disable-rule DoubleNegative -disable-rule MultipleUnaryOperator -p \"${TARGET_TEMP_DIR}\" \\\n | sed -E 's/(.*\\.(c|m{1,2}):[0-9]*:[0-9]*:)/\\1 warning:/'";
|
897
913
|
};
|
898
914
|
/* End PBXShellScriptBuildPhase section */
|
899
915
|
|
@@ -904,6 +920,7 @@
|
|
904
920
|
files = (
|
905
921
|
1EFACAA71CCCAF3D006F2E69 /* EtlExample.m in Sources */,
|
906
922
|
1EFACAA31CCCAF3D006F2E69 /* AnagramExample.m in Sources */,
|
923
|
+
A0CFCBF92056956B00DFE959 /* StrainTest.m in Sources */,
|
907
924
|
E9B062201E9E7C6D000BE589 /* SieveTest.m in Sources */,
|
908
925
|
E94ACA131D41760300D56CC2 /* AllYourBaseExample.m in Sources */,
|
909
926
|
E94ACA151D41763800D56CC2 /* AllYourBaseTest.m in Sources */,
|
@@ -950,6 +967,7 @@
|
|
950
967
|
E9C1C0311D9EC1270015E86E /* RunLengthEncodingTest.m in Sources */,
|
951
968
|
1EFACAA81CCCAF3D006F2E69 /* EtlTest.m in Sources */,
|
952
969
|
A097D40F1E363C2700EAF2C2 /* BracketPushExample.m in Sources */,
|
970
|
+
A0CFCBF82056956B00DFE959 /* StrainExample.m in Sources */,
|
953
971
|
E947A4E01D81FE3A00633720 /* TriangleTest.m in Sources */,
|
954
972
|
1EFACAA91CCCAF3D006F2E69 /* GradeSchoolExample.m in Sources */,
|
955
973
|
1EFACABA1CCCAF3D006F2E69 /* SpaceAgeTest.m in Sources */,
|
@@ -7,18 +7,25 @@ object RobotSimulatorTestGenerator {
|
|
7
7
|
def main(args: Array[String]): Unit = {
|
8
8
|
val file = new File("src/main/resources/robot-simulator.json")
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
labeledTest.result("robot").
|
15
|
-
asInstanceOf[Map[String, String]]
|
10
|
+
def getPosition(labeledTest: LabeledTest): (Int, Int) = {
|
11
|
+
val inputMap = fromInputMap(labeledTest.result, "position")
|
12
|
+
.asInstanceOf[Map[String, Any]]
|
13
|
+
getPosition2(inputMap)
|
16
14
|
}
|
17
15
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def getPosition2(positionMap: Map[String, Any]): (Int, Int) =
|
17
|
+
(positionMap("x").asInstanceOf[Int], positionMap("y").asInstanceOf[Int])
|
18
|
+
|
19
|
+
|
20
|
+
def getDirection(labeledTest: LabeledTest): String =
|
21
|
+
fromInputMap(labeledTest.result, "direction").toString
|
22
|
+
|
23
|
+
def toPositionArgs(position: (Int, Int)): String =
|
24
|
+
s"${position._1}, ${position._2}"
|
25
|
+
|
26
|
+
|
27
|
+
def getExpectedMap(labeledTest: LabeledTest): Map[String, Any] =
|
28
|
+
labeledTest.result("expected").asInstanceOf[Map[String, Any]]
|
22
29
|
|
23
30
|
def directionToBearing(direction: String): String =
|
24
31
|
direction.toLowerCase match {
|
@@ -29,18 +36,19 @@ object RobotSimulatorTestGenerator {
|
|
29
36
|
}
|
30
37
|
|
31
38
|
def toCreateSutCall(labeledTest: LabeledTest): String = {
|
32
|
-
val
|
33
|
-
|
34
|
-
s"Robot($bearing, (${getPositionArgs(robotMap)}))"
|
39
|
+
val bearing = directionToBearing(getDirection(labeledTest))
|
40
|
+
s"Robot($bearing, (${toPositionArgs(getPosition(labeledTest))}))"
|
35
41
|
}
|
36
42
|
|
37
43
|
def toCreateExpected(labeledTest: LabeledTest): String = {
|
38
44
|
val robotMap = getExpectedMap(labeledTest)
|
39
|
-
val bearing = directionToBearing(robotMap("direction"))
|
40
|
-
|
45
|
+
val bearing = directionToBearing(robotMap("direction").toString)
|
46
|
+
val positionArgs = toPositionArgs(getPosition2(robotMap("position")
|
47
|
+
.asInstanceOf[Map[String, Int]]))
|
48
|
+
s"Robot($bearing, ($positionArgs))"
|
41
49
|
}
|
42
50
|
|
43
|
-
def toTurnFunction(map: Map[String,
|
51
|
+
def toTurnFunction(map: Map[String, Any]) =
|
44
52
|
map.get("direction") match {
|
45
53
|
case Some(_) => "bearing"
|
46
54
|
case None => "coordinates"
|
@@ -54,15 +62,18 @@ object RobotSimulatorTestGenerator {
|
|
54
62
|
|
55
63
|
def toTurnExpected(labeledTest: LabeledTest): String = {
|
56
64
|
val expected = getExpectedMap(labeledTest)
|
65
|
+
expected.foreach{case (k, v) => System.out.println(s"$k")}
|
57
66
|
expected.get("direction") match {
|
58
|
-
case Some(s) => directionToBearing(s)
|
59
|
-
case None =>
|
67
|
+
case Some(s: String) => directionToBearing(s)
|
68
|
+
case None => {
|
69
|
+
val positionMap = expected("position").asInstanceOf[Map[String, Int]]
|
70
|
+
s"(${toPositionArgs(getPosition2(positionMap))})"
|
71
|
+
}
|
60
72
|
}
|
61
73
|
}
|
62
74
|
|
63
75
|
def toInstructSutCall(labeledTest: LabeledTest): String = {
|
64
|
-
val
|
65
|
-
val instructions = labeledTest.result("instructions")
|
76
|
+
val instructions = fromInputMap(labeledTest.result, "instructions")
|
66
77
|
s"""${toCreateSutCall(labeledTest)}.simulate("$instructions")"""
|
67
78
|
}
|
68
79
|
|