trackler 2.2.1.89 → 2.2.1.90
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/book-store/canonical-data.json +20 -17
- data/problem-specifications/exercises/phone-number/canonical-data.json +15 -3
- data/tracks/c/docs/C_STYLE_GUIDE.md +14 -0
- data/tracks/delphi/exercises/book-store/uBookStoreExample.pas +10 -10
- data/tracks/delphi/exercises/book-store/uBookStoreTests.pas +40 -42
- data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedList.fs +9 -26
- data/tracks/java/.travis.yml +1 -1
- data/tracks/java/exercises/difference-of-squares/.meta/version +1 -1
- data/tracks/java/exercises/house/.meta/version +1 -0
- data/tracks/java/exercises/pangram/.meta/version +1 -1
- data/tracks/java/exercises/pangram/src/test/java/PangramCheckerTest.java +8 -2
- data/tracks/java/exercises/word-count/.meta/hints.md +58 -0
- data/tracks/java/exercises/word-count/README.md +62 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864f7f9fd0030d0ceacb92fe02ebc4cb64963a2f
|
4
|
+
data.tar.gz: 657a52e0507d4eb1c880cbd0db58e53ccf168a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a6152d2213d3450066bbcc8f92861a023d53fdccfd0080ef04118db4844fc251e6057fdc3ebb8dd2022c8b1422bb70ef1556a66d1e8b5ed56f0fe453b5a6bf2
|
7
|
+
data.tar.gz: 454d3f097d1f99585b11e8ec4a75a9df31e9f9f59a3dfb699f1bed45c995486adb320240e67e4c5ccd7e6f9b024b08970b6136572c3f3579ddca347aa83b2ba8
|
data/lib/trackler/version.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"exercise": "book-store",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"cases": [
|
5
5
|
{
|
6
6
|
"description": "Return the total basket price after applying the best discount.",
|
7
7
|
"comments": [
|
8
8
|
"Calculate lowest price for a shopping basket containing books only from ",
|
9
9
|
"a single series. There is no discount advantage for having more than ",
|
10
|
-
"one copy of any single book in a grouping."
|
10
|
+
"one copy of any single book in a grouping.",
|
11
|
+
"implementors should use proper fixed-point or currency data types of the ",
|
12
|
+
"corresponding language and not float.",
|
13
|
+
"All 'expected' amounts are in cents."
|
11
14
|
],
|
12
15
|
"cases": [
|
13
16
|
{
|
@@ -17,7 +20,7 @@
|
|
17
20
|
"input": {
|
18
21
|
"basket": [1]
|
19
22
|
},
|
20
|
-
"expected":
|
23
|
+
"expected": 800
|
21
24
|
},
|
22
25
|
{
|
23
26
|
"property": "total",
|
@@ -26,7 +29,7 @@
|
|
26
29
|
"input": {
|
27
30
|
"basket": [2,2]
|
28
31
|
},
|
29
|
-
"expected":
|
32
|
+
"expected": 1600
|
30
33
|
},
|
31
34
|
{
|
32
35
|
"property": "total",
|
@@ -35,7 +38,7 @@
|
|
35
38
|
"input": {
|
36
39
|
"basket": []
|
37
40
|
},
|
38
|
-
"expected": 0
|
41
|
+
"expected": 0
|
39
42
|
},
|
40
43
|
{
|
41
44
|
"property": "total",
|
@@ -44,7 +47,7 @@
|
|
44
47
|
"input": {
|
45
48
|
"basket": [1,2]
|
46
49
|
},
|
47
|
-
"expected":
|
50
|
+
"expected": 1520
|
48
51
|
},
|
49
52
|
{
|
50
53
|
"property": "total",
|
@@ -53,7 +56,7 @@
|
|
53
56
|
"input": {
|
54
57
|
"basket": [1,2,3]
|
55
58
|
},
|
56
|
-
"expected":
|
59
|
+
"expected": 2160
|
57
60
|
},
|
58
61
|
{
|
59
62
|
"property": "total",
|
@@ -62,7 +65,7 @@
|
|
62
65
|
"input": {
|
63
66
|
"basket": [1,2,3,4]
|
64
67
|
},
|
65
|
-
"expected":
|
68
|
+
"expected": 2560
|
66
69
|
},
|
67
70
|
{
|
68
71
|
"property": "total",
|
@@ -71,7 +74,7 @@
|
|
71
74
|
"input": {
|
72
75
|
"basket": [1,2,3,4,5]
|
73
76
|
},
|
74
|
-
"expected":
|
77
|
+
"expected": 3000
|
75
78
|
},
|
76
79
|
{
|
77
80
|
"property": "total",
|
@@ -80,7 +83,7 @@
|
|
80
83
|
"input": {
|
81
84
|
"basket": [1,1,2,2,3,3,4,5]
|
82
85
|
},
|
83
|
-
"expected":
|
86
|
+
"expected": 5120
|
84
87
|
},
|
85
88
|
{
|
86
89
|
"property": "total",
|
@@ -89,7 +92,7 @@
|
|
89
92
|
"input": {
|
90
93
|
"basket": [1,1,2,2,3,4]
|
91
94
|
},
|
92
|
-
"expected":
|
95
|
+
"expected": 4080
|
93
96
|
},
|
94
97
|
{
|
95
98
|
"property": "total",
|
@@ -98,7 +101,7 @@
|
|
98
101
|
"input": {
|
99
102
|
"basket": [1,1,2,2,3,3,4,4,5]
|
100
103
|
},
|
101
|
-
"expected":
|
104
|
+
"expected": 5560
|
102
105
|
},
|
103
106
|
{
|
104
107
|
"property": "total",
|
@@ -107,7 +110,7 @@
|
|
107
110
|
"input": {
|
108
111
|
"basket": [1,1,2,2,3,3,4,4,5,5]
|
109
112
|
},
|
110
|
-
"expected":
|
113
|
+
"expected": 6000
|
111
114
|
},
|
112
115
|
{
|
113
116
|
"property": "total",
|
@@ -116,7 +119,7 @@
|
|
116
119
|
"input": {
|
117
120
|
"basket": [1,1,2,2,3,3,4,4,5,5,1]
|
118
121
|
},
|
119
|
-
"expected":
|
122
|
+
"expected": 6800
|
120
123
|
},
|
121
124
|
{
|
122
125
|
"property": "total",
|
@@ -125,7 +128,7 @@
|
|
125
128
|
"input": {
|
126
129
|
"basket": [1,1,2,2,3,3,4,4,5,5,1,2]
|
127
130
|
},
|
128
|
-
"expected":
|
131
|
+
"expected": 7520
|
129
132
|
},
|
130
133
|
{
|
131
134
|
"property": "total",
|
@@ -134,9 +137,9 @@
|
|
134
137
|
"input": {
|
135
138
|
"basket": [1,1,2,2,3,3,4,5,1,1,2,2,3,3,4,5]
|
136
139
|
},
|
137
|
-
"expected":
|
140
|
+
"expected": 10240
|
138
141
|
}
|
139
142
|
]
|
140
143
|
}
|
141
144
|
]
|
142
|
-
}
|
145
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"exercise": "phone-number",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.3.0",
|
4
4
|
"cases": [
|
5
5
|
{
|
6
6
|
"description": "Cleanup user-entered phone numbers",
|
@@ -71,16 +71,28 @@
|
|
71
71
|
"expected": null
|
72
72
|
},
|
73
73
|
{
|
74
|
-
"description": "invalid if area code
|
74
|
+
"description": "invalid if area code starts with 0",
|
75
|
+
"property": "clean",
|
76
|
+
"phrase": "(023) 456-7890",
|
77
|
+
"expected": null
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"description": "invalid if area code starts with 1",
|
75
81
|
"property": "clean",
|
76
82
|
"phrase": "(123) 456-7890",
|
77
83
|
"expected": null
|
78
84
|
},
|
79
85
|
{
|
80
|
-
"description": "invalid if exchange code
|
86
|
+
"description": "invalid if exchange code starts with 0",
|
81
87
|
"property": "clean",
|
82
88
|
"phrase": "(223) 056-7890",
|
83
89
|
"expected": null
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"description": "invalid if exchange code starts with 1",
|
93
|
+
"property": "clean",
|
94
|
+
"phrase": "(223) 156-7890",
|
95
|
+
"expected": null
|
84
96
|
}
|
85
97
|
]
|
86
98
|
}
|
@@ -4,6 +4,10 @@ This guide describes the style intended for use with the C track exercise exampl
|
|
4
4
|
|
5
5
|
The rules within this guide are in addition to, or to call out, those in the [Linux kernel coding style guide](https://www.kernel.org/doc/html/latest/process/coding-style.html).
|
6
6
|
|
7
|
+
## C Standard
|
8
|
+
|
9
|
+
Code should conform to the C99 standard, more formally known as ISO/IEC 9899:1999. POSIX, or otherwise non-standard library functions, types or other references that are external to the implementation should not be used.
|
10
|
+
|
7
11
|
## Names
|
8
12
|
|
9
13
|
In general, the names of types, variables, structures and files should use snake case with all letters in lower case and underscores `_` are used to separate name components.
|
@@ -39,6 +43,12 @@ Upper-case snake case for macro names is appreciated, but macros resembling func
|
|
39
43
|
|
40
44
|
### Types
|
41
45
|
|
46
|
+
The standard fixed-width types (in `stdint.h`) are preferred over basic integer types.
|
47
|
+
|
48
|
+
The type `bool` (from `stdbool.h`) is preferred over `_Bool`.
|
49
|
+
|
50
|
+
Likewise, `size_t` and `ptrdiff_t` (of `stddef.h`) are preferred for representing memory-related quantities.
|
51
|
+
|
42
52
|
Types defined by a program using `typedef` should be named with a `_t` suffix.
|
43
53
|
While aware that POSIX reserves the `_t` suffix, the track does not currently utilise POSIX.
|
44
54
|
|
@@ -49,6 +59,10 @@ The names used should match in all instances.
|
|
49
59
|
That is to say that while the following function prototype is valid C, the style is incorrect because the parameter is unnamed: `void foo(int);`.
|
50
60
|
The correct prototype, providing that all other declarations and the definition also use the parameter name `bar`, would be `void foo(int bar);`.
|
51
61
|
|
62
|
+
Where it is simpler or more appropriate to do so, parameters that require passing arguments by value rather than by pointer are preferred. Note especially that this includes `struct` type parameters.
|
63
|
+
|
64
|
+
In the case that a student is not expected to change the values of a pointer-type parameter within their implementation, that parameter should be `const` qualified.
|
65
|
+
|
52
66
|
## Indentation and Format
|
53
67
|
|
54
68
|
The repository uses the `indent` tool, as outlined in the [contributing guide](https://github.com/exercism/c/blob/master/docs/CONTRIBUTING.md).
|
@@ -5,7 +5,7 @@ interface
|
|
5
5
|
type
|
6
6
|
IBasket = interface(IInvokable)
|
7
7
|
['{22B4BAF3-88E6-456D-9DE5-F6BAC743A655}']
|
8
|
-
function Total:
|
8
|
+
function Total:integer;
|
9
9
|
end;
|
10
10
|
|
11
11
|
function NewBasket(aBasket: TArray<Integer>): IBasket;
|
@@ -25,7 +25,7 @@ const
|
|
25
25
|
type
|
26
26
|
TBasket = class(TInterfacedObject, IBasket)
|
27
27
|
private
|
28
|
-
fSingleBookPrice:
|
28
|
+
fSingleBookPrice: integer;
|
29
29
|
fBasket: string;
|
30
30
|
fIntList: TList<integer>;
|
31
31
|
class function Head(inStr: string): string; static;
|
@@ -35,7 +35,7 @@ type
|
|
35
35
|
function GroupBasket:TArray<String>;
|
36
36
|
function NumberOfDifferentBooks(inStr : string):integer;
|
37
37
|
public
|
38
|
-
function Total:
|
38
|
+
function Total:integer;
|
39
39
|
constructor Create(aBasket: TArray<Integer>);
|
40
40
|
end;
|
41
41
|
|
@@ -65,7 +65,7 @@ end;
|
|
65
65
|
|
66
66
|
constructor TBasket.Create(aBasket: TArray<Integer>);
|
67
67
|
begin
|
68
|
-
fSingleBookPrice :=
|
68
|
+
fSingleBookPrice := 800;
|
69
69
|
fIntList := TList<integer>.Create;
|
70
70
|
fIntList.AddRange(aBasket);
|
71
71
|
fIntList.Sort;
|
@@ -111,28 +111,28 @@ begin
|
|
111
111
|
result := lStrArray;
|
112
112
|
end;
|
113
113
|
|
114
|
-
function TBasket.Total:
|
114
|
+
function TBasket.Total:integer;
|
115
115
|
var
|
116
116
|
subBaskets : TArray<String>;
|
117
|
-
subResult : array[0..1] of
|
117
|
+
subResult : array[0..1] of integer;
|
118
118
|
lSortedBasket : TArray<integer>;
|
119
119
|
|
120
|
-
function computeTotal:
|
120
|
+
function computeTotal: integer;
|
121
121
|
var wrkSubBasket: string;
|
122
122
|
totalBooks : integer;
|
123
|
-
subTotal :
|
123
|
+
subTotal : integer;
|
124
124
|
begin
|
125
125
|
result := 0;
|
126
126
|
for wrkSubBasket in subBaskets do
|
127
127
|
begin
|
128
128
|
totalBooks := wrkSubBasket.Length;
|
129
|
-
subTotal := totalBooks * (fSingleBookPrice * DiscountPercentage(wrkSubBasket));
|
129
|
+
subTotal := totalBooks * round(fSingleBookPrice * DiscountPercentage(wrkSubBasket));
|
130
130
|
Result := Result + subTotal;
|
131
131
|
end;
|
132
132
|
end;
|
133
133
|
|
134
134
|
begin
|
135
|
-
fillchar(subResult, sizeof(
|
135
|
+
fillchar(subResult, sizeof(integer), #0);
|
136
136
|
|
137
137
|
subBaskets := GroupBasket;
|
138
138
|
subResult[0] := computeTotal;
|
@@ -5,7 +5,7 @@ uses
|
|
5
5
|
DUnitX.TestFramework;
|
6
6
|
|
7
7
|
const
|
8
|
-
CanonicalVersion = '1.
|
8
|
+
CanonicalVersion = '1.3.0';
|
9
9
|
|
10
10
|
type
|
11
11
|
[TestFixture]
|
@@ -67,80 +67,78 @@ type
|
|
67
67
|
implementation
|
68
68
|
uses System.SysUtils, uBookStore;
|
69
69
|
|
70
|
-
const MinDelta = 0.005; //cents
|
71
|
-
|
72
70
|
procedure hpTests.A_basket_containing_only_a_single_book;
|
73
71
|
var Basket: TArray<integer>;
|
74
72
|
fBasket: IBasket;
|
75
|
-
Expected:
|
73
|
+
Expected: integer;
|
76
74
|
begin
|
77
75
|
SetLength(Basket, 1);
|
78
76
|
Basket[0] := 1;
|
79
|
-
Expected :=
|
77
|
+
Expected := 800;
|
80
78
|
|
81
79
|
fBasket := NewBasket(Basket);
|
82
|
-
assert.AreEqual(Expected, fBasket.Total,
|
80
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
83
81
|
end;
|
84
82
|
|
85
83
|
procedure hpTests.A_basket_containing_only_two_of_the_same_book;
|
86
84
|
var Basket: TArray<integer>;
|
87
85
|
fBasket: IBasket;
|
88
|
-
Expected:
|
86
|
+
Expected: integer;
|
89
87
|
begin
|
90
88
|
SetLength(Basket, 2);
|
91
89
|
Basket[0] := 2;
|
92
90
|
Basket[1] := 2;
|
93
|
-
Expected :=
|
91
|
+
Expected := 1600;
|
94
92
|
|
95
93
|
fBasket := NewBasket(Basket);
|
96
|
-
assert.AreEqual(Expected, fBasket.Total,
|
94
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
97
95
|
end;
|
98
96
|
|
99
97
|
procedure hpTests.No_charge_to_carry_around_an_empty_basket;
|
100
98
|
var Basket: TArray<integer>;
|
101
99
|
fBasket: IBasket;
|
102
|
-
Expected:
|
100
|
+
Expected: integer;
|
103
101
|
begin
|
104
102
|
SetLength(Basket, 0);
|
105
|
-
Expected := 0
|
103
|
+
Expected := 0;
|
106
104
|
|
107
105
|
fBasket := NewBasket(Basket);
|
108
|
-
assert.AreEqual(Expected, fBasket.Total,
|
106
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
109
107
|
end;
|
110
108
|
|
111
109
|
procedure hpTests.A_basket_containing_only_two_different_books;
|
112
110
|
var Basket: TArray<integer>;
|
113
111
|
fBasket: IBasket;
|
114
|
-
Expected:
|
112
|
+
Expected: integer;
|
115
113
|
begin
|
116
114
|
SetLength(Basket, 2);
|
117
115
|
Basket[0] := 1;
|
118
116
|
Basket[1] := 2;
|
119
|
-
Expected :=
|
117
|
+
Expected := 1520;
|
120
118
|
|
121
119
|
fBasket := NewBasket(Basket);
|
122
|
-
assert.AreEqual(Expected, fBasket.Total,
|
120
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
123
121
|
end;
|
124
122
|
|
125
123
|
procedure hpTests.A_basket_with_three_different_books;
|
126
124
|
var Basket: TArray<integer>;
|
127
125
|
fBasket: IBasket;
|
128
|
-
Expected:
|
126
|
+
Expected: integer;
|
129
127
|
begin
|
130
128
|
SetLength(Basket, 3);
|
131
129
|
Basket[0] := 1;
|
132
130
|
Basket[1] := 2;
|
133
131
|
Basket[2] := 3;
|
134
|
-
Expected :=
|
132
|
+
Expected := 2160;
|
135
133
|
|
136
134
|
fBasket := NewBasket(Basket);
|
137
|
-
assert.AreEqual(Expected, fBasket.Total,
|
135
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
138
136
|
end;
|
139
137
|
|
140
138
|
procedure hpTests.Four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three;
|
141
139
|
var Basket: TArray<integer>;
|
142
140
|
fBasket: IBasket;
|
143
|
-
Expected:
|
141
|
+
Expected: integer;
|
144
142
|
begin
|
145
143
|
SetLength(Basket, 16);
|
146
144
|
Basket[0] := 1;
|
@@ -159,32 +157,32 @@ begin
|
|
159
157
|
Basket[13] := 3;
|
160
158
|
Basket[14] := 4;
|
161
159
|
Basket[15] := 5;
|
162
|
-
Expected :=
|
160
|
+
Expected := 10240;
|
163
161
|
|
164
162
|
fBasket := NewBasket(Basket);
|
165
|
-
assert.AreEqual(Expected, fBasket.Total,
|
163
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
166
164
|
end;
|
167
165
|
|
168
166
|
procedure hpTests.A_basket_with_four_different_books;
|
169
167
|
var Basket: TArray<integer>;
|
170
168
|
fBasket: IBasket;
|
171
|
-
Expected:
|
169
|
+
Expected: integer;
|
172
170
|
begin
|
173
171
|
SetLength(Basket, 4);
|
174
172
|
Basket[0] := 1;
|
175
173
|
Basket[1] := 2;
|
176
174
|
Basket[2] := 3;
|
177
175
|
Basket[3] := 4;
|
178
|
-
Expected :=
|
176
|
+
Expected := 2560;
|
179
177
|
|
180
178
|
fBasket := NewBasket(Basket);
|
181
|
-
assert.AreEqual(Expected, fBasket.Total,
|
179
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
182
180
|
end;
|
183
181
|
|
184
182
|
procedure hpTests.A_basket_with_five_different_books;
|
185
183
|
var Basket: TArray<integer>;
|
186
184
|
fBasket: IBasket;
|
187
|
-
Expected:
|
185
|
+
Expected: integer;
|
188
186
|
begin
|
189
187
|
SetLength(Basket, 5);
|
190
188
|
Basket[0] := 1;
|
@@ -192,16 +190,16 @@ begin
|
|
192
190
|
Basket[2] := 3;
|
193
191
|
Basket[3] := 4;
|
194
192
|
Basket[4] := 5;
|
195
|
-
Expected :=
|
193
|
+
Expected := 3000;
|
196
194
|
|
197
195
|
fBasket := NewBasket(Basket);
|
198
|
-
assert.AreEqual(Expected, fBasket.Total,
|
196
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
199
197
|
end;
|
200
198
|
|
201
199
|
procedure hpTests.A_basket_containing_eight_books_consisting_of_a_pair_each_of_the_first_three_books_plus_one_copy_each_of_the_last_two_books;
|
202
200
|
var Basket: TArray<integer>;
|
203
201
|
fBasket: IBasket;
|
204
|
-
Expected:
|
202
|
+
Expected: integer;
|
205
203
|
begin
|
206
204
|
SetLength(Basket, 8);
|
207
205
|
Basket[0] := 1;
|
@@ -212,16 +210,16 @@ begin
|
|
212
210
|
Basket[5] := 3;
|
213
211
|
Basket[6] := 4;
|
214
212
|
Basket[7] := 5;
|
215
|
-
Expected :=
|
213
|
+
Expected := 5120;
|
216
214
|
|
217
215
|
fBasket := NewBasket(Basket);
|
218
|
-
assert.AreEqual(Expected, fBasket.Total,
|
216
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
219
217
|
end;
|
220
218
|
|
221
219
|
procedure hpTests.A_basket_containing_nine_books_consisting_of_a_pair_each_of_the_first_four_books_plus_one_of_the_last_book;
|
222
220
|
var Basket: TArray<integer>;
|
223
221
|
fBasket: IBasket;
|
224
|
-
Expected:
|
222
|
+
Expected: integer;
|
225
223
|
begin
|
226
224
|
SetLength(Basket, 9);
|
227
225
|
Basket[0] := 1;
|
@@ -233,16 +231,16 @@ begin
|
|
233
231
|
Basket[6] := 4;
|
234
232
|
Basket[7] := 4;
|
235
233
|
Basket[8] := 5;
|
236
|
-
Expected :=
|
234
|
+
Expected := 5560;
|
237
235
|
|
238
236
|
fBasket := NewBasket(Basket);
|
239
|
-
assert.AreEqual(Expected, fBasket.Total,
|
237
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
240
238
|
end;
|
241
239
|
|
242
240
|
procedure hpTests.A_basket_containing_ten_books_consisting_of_two_copies_of_each_book_in_the_series;
|
243
241
|
var Basket: TArray<integer>;
|
244
242
|
fBasket: IBasket;
|
245
|
-
Expected:
|
243
|
+
Expected: integer;
|
246
244
|
begin
|
247
245
|
SetLength(Basket, 10);
|
248
246
|
Basket[0] := 1;
|
@@ -255,16 +253,16 @@ begin
|
|
255
253
|
Basket[7] := 4;
|
256
254
|
Basket[8] := 5;
|
257
255
|
Basket[9] := 5;
|
258
|
-
Expected :=
|
256
|
+
Expected := 6000;
|
259
257
|
|
260
258
|
fBasket := NewBasket(Basket);
|
261
|
-
assert.AreEqual(Expected, fBasket.Total,
|
259
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
262
260
|
end;
|
263
261
|
|
264
262
|
procedure hpTests.A_basket_containing_eleven_books_consisting_of_three_copies_of_the_first_book_plus_two_each_of_the_remaing_four_bookes_in_the_series;
|
265
263
|
var Basket: TArray<integer>;
|
266
264
|
fBasket: IBasket;
|
267
|
-
Expected:
|
265
|
+
Expected: integer;
|
268
266
|
begin
|
269
267
|
SetLength(Basket, 11);
|
270
268
|
Basket[0] := 1;
|
@@ -278,16 +276,16 @@ begin
|
|
278
276
|
Basket[8] := 5;
|
279
277
|
Basket[9] := 5;
|
280
278
|
Basket[10] := 1;
|
281
|
-
Expected :=
|
279
|
+
Expected := 6800;
|
282
280
|
|
283
281
|
fBasket := NewBasket(Basket);
|
284
|
-
assert.AreEqual(Expected, fBasket.Total,
|
282
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
285
283
|
end;
|
286
284
|
|
287
285
|
procedure hpTests.A_basket_containing_twelve_books_consisting_of_three_copies_of_the_first_two_books_plus_two_each_of_the_remaining_three_books_in_the_series;
|
288
286
|
var Basket: TArray<integer>;
|
289
287
|
fBasket: IBasket;
|
290
|
-
Expected:
|
288
|
+
Expected: integer;
|
291
289
|
begin
|
292
290
|
SetLength(Basket, 12);
|
293
291
|
Basket[0] := 1;
|
@@ -302,10 +300,10 @@ begin
|
|
302
300
|
Basket[9] := 5;
|
303
301
|
Basket[10] := 1;
|
304
302
|
Basket[11] := 2;
|
305
|
-
Expected :=
|
303
|
+
Expected := 7520;
|
306
304
|
|
307
305
|
fBasket := NewBasket(Basket);
|
308
|
-
assert.AreEqual(Expected, fBasket.Total,
|
306
|
+
assert.AreEqual(Expected, fBasket.Total, format('Total should be %d cents',[Expected]));
|
309
307
|
end;
|
310
308
|
|
311
309
|
initialization
|
@@ -1,36 +1,19 @@
|
|
1
1
|
module SimpleLinkedList
|
2
2
|
|
3
|
-
|
4
|
-
| Nil
|
5
|
-
| Element of datum:'a * next:LinkedList<'a>
|
3
|
+
//TODO: define LinkedList type
|
6
4
|
|
7
|
-
let nil =
|
5
|
+
let nil = failwith "You need to implement this function."
|
8
6
|
|
9
|
-
let create x n =
|
7
|
+
let create x n = failwith "You need to implement this function."
|
10
8
|
|
11
|
-
let isNil x =
|
12
|
-
match x with
|
13
|
-
| Nil -> true
|
14
|
-
| _ -> false
|
9
|
+
let isNil x = failwith "You need to implement this function."
|
15
10
|
|
16
|
-
let next x =
|
17
|
-
match x with
|
18
|
-
| Nil -> Nil
|
19
|
-
| Element (_, n) -> n
|
11
|
+
let next x = failwith "You need to implement this function."
|
20
12
|
|
21
|
-
let datum x =
|
22
|
-
match x with
|
23
|
-
| Nil -> failwith "The nil list has no datum."
|
24
|
-
| Element (y, _) -> y
|
13
|
+
let datum x = failwith "You need to implement this function."
|
25
14
|
|
26
|
-
let toList x =
|
27
|
-
let rec loop acc item =
|
28
|
-
match item with
|
29
|
-
| Nil -> acc |> List.rev
|
30
|
-
| Element (b, n) -> loop (b :: acc) n
|
15
|
+
let toList x = failwith "You need to implement this function."
|
31
16
|
|
32
|
-
|
17
|
+
let fromList xs = failwith "You need to implement this function."
|
33
18
|
|
34
|
-
let
|
35
|
-
|
36
|
-
let reverse x = x |> toList |> List.rev |> fromList
|
19
|
+
let reverse x = failwith "You need to implement this function."
|
data/tracks/java/.travis.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
@@ -19,6 +19,12 @@ public class PangramCheckerTest {
|
|
19
19
|
assertFalse(pangramChecker.isPangram(""));
|
20
20
|
}
|
21
21
|
|
22
|
+
@Ignore("Remove to run test")
|
23
|
+
@Test
|
24
|
+
public void recognizesPerfectLowerCasePangram() {
|
25
|
+
assertTrue(pangramChecker.isPangram("abcdefghijklmnopqrstuvwxyz"));
|
26
|
+
}
|
27
|
+
|
22
28
|
@Ignore("Remove to run test")
|
23
29
|
@Test
|
24
30
|
public void pangramWithOnlyLowerCaseLettersIsRecognizedAsPangram() {
|
@@ -33,8 +39,8 @@ public class PangramCheckerTest {
|
|
33
39
|
|
34
40
|
@Ignore("Remove to run test")
|
35
41
|
@Test
|
36
|
-
public void
|
37
|
-
assertFalse(pangramChecker.isPangram("
|
42
|
+
public void phraseMissingAnotherCharacterIsNotPangram() {
|
43
|
+
assertFalse(pangramChecker.isPangram("five boxing wizards jump quickly at it"));
|
38
44
|
}
|
39
45
|
|
40
46
|
@Ignore("Remove to run test")
|
@@ -0,0 +1,58 @@
|
|
1
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
2
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
3
|
+
It does mean that when you first try to run the tests, they won't compile.
|
4
|
+
They will give you an error similar to:
|
5
|
+
```
|
6
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
7
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
8
|
+
^
|
9
|
+
symbol: class ExerciseClassName
|
10
|
+
location: class ExerciseClassNameTest
|
11
|
+
```
|
12
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
13
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
14
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
15
|
+
|
16
|
+
When you try to run the tests again you will get slightly different errors.
|
17
|
+
You might get an error similar to:
|
18
|
+
```
|
19
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
20
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
21
|
+
^
|
22
|
+
required: no arguments
|
23
|
+
found: String
|
24
|
+
reason: actual and formal argument lists differ in length
|
25
|
+
```
|
26
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
27
|
+
If you don't add a constructor, Java will add a default one for you.
|
28
|
+
This default constructor takes no arguments.
|
29
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
30
|
+
In the example above you could add:
|
31
|
+
```
|
32
|
+
ExerciseClassName(String input) {
|
33
|
+
|
34
|
+
}
|
35
|
+
```
|
36
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
37
|
+
|
38
|
+
You might also get an error similar to:
|
39
|
+
```
|
40
|
+
error: cannot find symbol
|
41
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
42
|
+
^
|
43
|
+
symbol: method someMethod()
|
44
|
+
location: variable exerciseClassName of type ExerciseClassName
|
45
|
+
```
|
46
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
47
|
+
In the example above you would add:
|
48
|
+
```
|
49
|
+
String someMethod() {
|
50
|
+
return "";
|
51
|
+
}
|
52
|
+
```
|
53
|
+
Make sure the return type matches what the test is expecting.
|
54
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
55
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
56
|
+
The new error should tell you which type it's expecting.
|
57
|
+
|
58
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
@@ -11,6 +11,68 @@ come: 1
|
|
11
11
|
free: 1
|
12
12
|
```
|
13
13
|
|
14
|
+
# Java Tips
|
15
|
+
|
16
|
+
Since this exercise has difficulty 5 it doesn't come with any starter implementation.
|
17
|
+
This is so that you get to practice creating classes and methods which is an important part of programming in Java.
|
18
|
+
It does mean that when you first try to run the tests, they won't compile.
|
19
|
+
They will give you an error similar to:
|
20
|
+
```
|
21
|
+
path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
|
22
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName();
|
23
|
+
^
|
24
|
+
symbol: class ExerciseClassName
|
25
|
+
location: class ExerciseClassNameTest
|
26
|
+
```
|
27
|
+
This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
|
28
|
+
To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
|
29
|
+
For example, for the error above you would add a file called `ExerciseClassName.java`.
|
30
|
+
|
31
|
+
When you try to run the tests again you will get slightly different errors.
|
32
|
+
You might get an error similar to:
|
33
|
+
```
|
34
|
+
constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
|
35
|
+
ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
|
36
|
+
^
|
37
|
+
required: no arguments
|
38
|
+
found: String
|
39
|
+
reason: actual and formal argument lists differ in length
|
40
|
+
```
|
41
|
+
This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
|
42
|
+
If you don't add a constructor, Java will add a default one for you.
|
43
|
+
This default constructor takes no arguments.
|
44
|
+
So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
|
45
|
+
In the example above you could add:
|
46
|
+
```
|
47
|
+
ExerciseClassName(String input) {
|
48
|
+
|
49
|
+
}
|
50
|
+
```
|
51
|
+
That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
|
52
|
+
|
53
|
+
You might also get an error similar to:
|
54
|
+
```
|
55
|
+
error: cannot find symbol
|
56
|
+
assertEquals(expectedOutput, exerciseClassName.someMethod());
|
57
|
+
^
|
58
|
+
symbol: method someMethod()
|
59
|
+
location: variable exerciseClassName of type ExerciseClassName
|
60
|
+
```
|
61
|
+
This error means that you need to add a method called `someMethod` to your new class.
|
62
|
+
In the example above you would add:
|
63
|
+
```
|
64
|
+
String someMethod() {
|
65
|
+
return "";
|
66
|
+
}
|
67
|
+
```
|
68
|
+
Make sure the return type matches what the test is expecting.
|
69
|
+
You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
|
70
|
+
Or you could set your method to return some random type (e.g. `void`), and run the tests again.
|
71
|
+
The new error should tell you which type it's expecting.
|
72
|
+
|
73
|
+
After having resolved these errors you should be ready to start making the tests pass!
|
74
|
+
|
75
|
+
|
14
76
|
# Running the tests
|
15
77
|
|
16
78
|
You can run all the tests for an exercise by entering
|
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.2.1.
|
4
|
+
version: 2.2.1.90
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -7469,6 +7469,7 @@ files:
|
|
7469
7469
|
- tracks/java/exercises/hexadecimal/src/main/java/.keep
|
7470
7470
|
- tracks/java/exercises/hexadecimal/src/test/java/HexadecimalTest.java
|
7471
7471
|
- tracks/java/exercises/house/.meta/src/reference/java/House.java
|
7472
|
+
- tracks/java/exercises/house/.meta/version
|
7472
7473
|
- tracks/java/exercises/house/README.md
|
7473
7474
|
- tracks/java/exercises/house/build.gradle
|
7474
7475
|
- tracks/java/exercises/house/src/main/java/.keep
|
@@ -7816,6 +7817,7 @@ files:
|
|
7816
7817
|
- tracks/java/exercises/two-fer/build.gradle
|
7817
7818
|
- tracks/java/exercises/two-fer/src/main/java/Twofer.java
|
7818
7819
|
- tracks/java/exercises/two-fer/src/test/java/TwoferTest.java
|
7820
|
+
- tracks/java/exercises/word-count/.meta/hints.md
|
7819
7821
|
- tracks/java/exercises/word-count/.meta/src/reference/java/WordCount.java
|
7820
7822
|
- tracks/java/exercises/word-count/README.md
|
7821
7823
|
- tracks/java/exercises/word-count/build.gradle
|