trackler 2.0.3.4 → 2.0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/all-your-base/canonical-data.json +21 -21
  3. data/common/exercises/wordy/description.md +24 -38
  4. data/common/exercises/wordy/metadata.yml +1 -1
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/c/config.json +10 -0
  7. data/tracks/c/exercises/meetup/makefile +15 -0
  8. data/tracks/c/exercises/meetup/src/example.c +139 -0
  9. data/tracks/c/exercises/meetup/src/example.h +7 -0
  10. data/tracks/c/exercises/meetup/test/test_meetup.c +223 -0
  11. data/tracks/c/exercises/meetup/test/vendor/unity.c +1300 -0
  12. data/tracks/c/exercises/meetup/test/vendor/unity.h +274 -0
  13. data/tracks/c/exercises/meetup/test/vendor/unity_internals.h +701 -0
  14. data/tracks/crystal/config.json +12 -0
  15. data/tracks/crystal/exercises/pascals-triangle/spec/pascals_triangle_spec.cr +30 -0
  16. data/tracks/crystal/exercises/pascals-triangle/src/example.cr +19 -0
  17. data/tracks/crystal/exercises/pascals-triangle/src/pascals_triangle.cr +1 -0
  18. data/tracks/crystal/exercises/run-length-encoding/spec/run_length_encoding_spec.cr +36 -0
  19. data/tracks/crystal/exercises/run-length-encoding/src/example.cr +40 -0
  20. data/tracks/crystal/src/generator/exercises/pascals-triangle.cr +58 -0
  21. data/tracks/crystal/src/generator/exercises/run_length_encoding.cr +42 -0
  22. data/tracks/javascript/config.json +8 -1
  23. data/tracks/javascript/exercises/all-your-base/all-your-base.spec.js +141 -0
  24. data/tracks/javascript/exercises/all-your-base/example.js +59 -0
  25. data/tracks/javascript/exercises/word-count/example.js +5 -5
  26. data/tracks/javascript/exercises/word-count/word-count.spec.js +23 -8
  27. data/tracks/lua/SETUP.md +60 -7
  28. data/tracks/lua/config.json +9 -0
  29. data/tracks/lua/exercises/say/example.lua +4 -4
  30. data/tracks/lua/exercises/variable-length-quantity/example.lua +36 -0
  31. data/tracks/lua/exercises/variable-length-quantity/variable-length-quantity_spec.lua +73 -0
  32. data/tracks/objective-c/.travis.yml +1 -0
  33. data/tracks/objective-c/config.json +8 -0
  34. data/tracks/objective-c/docs/TESTS.md +1 -1
  35. data/tracks/objective-c/exercises/transpose/TransposeExample.h +7 -0
  36. data/tracks/objective-c/exercises/transpose/TransposeExample.m +59 -0
  37. data/tracks/objective-c/exercises/transpose/TransposeTest.m +150 -0
  38. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  39. data/tracks/ocaml/.gitignore +1 -0
  40. data/tracks/ocaml/tools/test-generator/Makefile +3 -0
  41. data/tracks/ocaml/tools/test-generator/src/controller.ml +11 -16
  42. data/tracks/ocaml/tools/test-generator/src/model.ml +4 -0
  43. data/tracks/ocaml/tools/test-generator/src/parser.ml +8 -1
  44. data/tracks/ocaml/tools/test-generator/src/special_cases.ml +5 -0
  45. data/tracks/ocaml/tools/test-generator/templates/all-your-base/template.ml +16 -0
  46. data/tracks/ocaml/tools/test-generator/test/model_test.ml +2 -0
  47. data/tracks/ocaml/tools/test-generator/test/parser_test.ml +8 -0
  48. data/tracks/perl5/docs/RESOURCES.md +57 -0
  49. data/tracks/perl5/exercises/hamming/Example.pm +7 -0
  50. data/tracks/perl5/exercises/hamming/hamming.t +17 -4
  51. data/tracks/perl5/exercises/rna-transcription/rna.t +4 -4
  52. data/tracks/perl6/.gitignore +2 -0
  53. data/tracks/perl6/config.json +5 -0
  54. data/tracks/perl6/exercises/phone-number/Example.pm +30 -0
  55. data/tracks/perl6/exercises/phone-number/cases.json +47 -0
  56. data/tracks/perl6/exercises/phone-number/phone.t +48 -0
  57. data/tracks/purescript/.gitignore +8 -0
  58. data/tracks/purescript/config.json +8 -3
  59. data/tracks/purescript/exercises/hello-world/bower.json +17 -0
  60. data/tracks/purescript/exercises/hello-world/examples/src/HelloWorld.purs +8 -0
  61. data/tracks/purescript/exercises/hello-world/src/HelloWorld.purs +6 -0
  62. data/tracks/purescript/exercises/hello-world/test/Main.purs +18 -0
  63. data/tracks/scala/exercises/leap/HINTS.md +4 -0
  64. data/tracks/scala/exercises/robot-name/HINTS.md +5 -0
  65. data/tracks/swift/docs/INSTALLATION.md +4 -1
  66. data/tracks/swift/exercises/accumulate/AccumulateTest.swift +1 -1
  67. data/tracks/swift/exercises/binary/BinaryExample.swift +4 -1
  68. data/tracks/swift/exercises/crypto-square/CryptoSquareExample.swift +3 -2
  69. data/tracks/swift/exercises/leap/LeapExample.swift +1 -3
  70. data/tracks/swift/exercises/pascals-triangle/PascalsTriangleTest.swift +1 -1
  71. data/tracks/swift/exercises/poker/PokerExample.swift +3 -3
  72. data/tracks/swift/exercises/poker/PokerTest.swift +38 -38
  73. data/tracks/swift/exercises/saddle-points/SaddlePointsTest.swift +1 -1
  74. data/tracks/swift/exercises/scrabble-score/ScrabbleScoreExample.swift +6 -3
  75. data/tracks/swift/exercises/series/SeriesTest.swift +1 -1
  76. data/tracks/swift/exercises/simple-linked-list/SimpleLinkedListExample.swift +2 -2
  77. data/tracks/swift/exercises/space-age/SpaceAgeExample.swift +10 -12
  78. data/tracks/swift/exercises/strain/StrainTest.swift +1 -1
  79. data/tracks/swift/exercises/tournament/TournamentExample.swift +2 -2
  80. data/tracks/swift/exercises/triangle/TriangleExample.swift +7 -3
  81. data/tracks/swift/exercises/wordy/WordyExample.swift +1 -2
  82. metadata +34 -3
  83. data/tracks/purescript/exercises/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36080e740c50fc72852fc37ec458b86bfbfc9e44
4
- data.tar.gz: a5c5c21f888bc1a2c926b81bfa7cf0c3b529558a
3
+ metadata.gz: a7246bea41baef8aa38999af188d6a25fb21c359
4
+ data.tar.gz: c9b3666bcd5f4c51d3251b9fb1f97048425ed156
5
5
  SHA512:
6
- metadata.gz: 54197c20523de15b52d62db122611be7b844ce329283a3d2bb59840899a7545bed21c0f44e6e2c094765b546d46ee4f95a311941cc23a4761d1f87f50fbce44d
7
- data.tar.gz: 1e14225a99cab48c3125db478b9d50440aad4109efbdb88a5fd77cc383c29bfc9cdcb9295d6920ea7772d9e56a1f1f0eec8dc774ff8168c8d0d09a0ddd2821e9
6
+ metadata.gz: 5e45c5da080f94f7723a6f32aaabf00005108f74e1000a03436904fa1b7b8f283f3b1c66c2923a3d38ce29d41607c4d61df35986c419faafdb33f94135c5e68a
7
+ data.tar.gz: 5e0c721dd96f6beb5e4e4a7e7dde487d74161ff94bb861f62dfe7928fa3fce7a3b45aef1a824c2bd5452a0bdb16295e51ec8e462f33e663802d83633f88f498c
@@ -23,126 +23,126 @@
23
23
  , "input_base" : 2
24
24
  , "input_digits" : [1]
25
25
  , "output_base" : 10
26
- , "output_digits": [1]
26
+ , "expected" : [1]
27
27
  },
28
28
  { "description" : "binary to single decimal"
29
29
  , "input_base" : 2
30
30
  , "input_digits" : [1, 0, 1]
31
31
  , "output_base" : 10
32
- , "output_digits": [5]
32
+ , "expected" : [5]
33
33
  },
34
34
  { "description" : "single decimal to binary"
35
35
  , "input_base" : 10
36
36
  , "input_digits" : [5]
37
37
  , "output_base" : 2
38
- , "output_digits": [1, 0, 1]
38
+ , "expected" : [1, 0, 1]
39
39
  },
40
40
  { "description" : "binary to multiple decimal"
41
41
  , "input_base" : 2
42
42
  , "input_digits" : [1, 0, 1, 0, 1, 0]
43
43
  , "output_base" : 10
44
- , "output_digits": [4, 2]
44
+ , "expected" : [4, 2]
45
45
  },
46
46
  { "description" : "decimal to binary"
47
47
  , "input_base" : 10
48
48
  , "input_digits" : [4, 2]
49
49
  , "output_base" : 2
50
- , "output_digits": [1, 0, 1, 0, 1, 0]
50
+ , "expected" : [1, 0, 1, 0, 1, 0]
51
51
  },
52
52
  { "description" : "trinary to hexadecimal"
53
53
  , "input_base" : 3
54
54
  , "input_digits" : [1, 1, 2, 0]
55
55
  , "output_base" : 16
56
- , "output_digits": [2, 10]
56
+ , "expected" : [2, 10]
57
57
  },
58
58
  { "description" : "hexadecimal to trinary"
59
59
  , "input_base" : 16
60
60
  , "input_digits" : [2, 10]
61
61
  , "output_base" : 3
62
- , "output_digits": [1, 1, 2, 0]
62
+ , "expected" : [1, 1, 2, 0]
63
63
  },
64
64
  { "description" : "15-bit integer"
65
65
  , "input_base" : 97
66
66
  , "input_digits" : [3,46,60]
67
67
  , "output_base" : 73
68
- , "output_digits": [6,10,45]
68
+ , "expected" : [6,10,45]
69
69
  },
70
70
  { "description" : "empty list"
71
71
  , "input_base" : 2
72
72
  , "input_digits" : []
73
73
  , "output_base" : 10
74
- , "output_digits": null
74
+ , "expected" : null
75
75
  },
76
76
  { "description" : "single zero"
77
77
  , "input_base" : 10
78
78
  , "input_digits" : [0]
79
79
  , "output_base" : 2
80
- , "output_digits": null
80
+ , "expected" : null
81
81
  },
82
82
  { "description" : "multiple zeros"
83
83
  , "input_base" : 10
84
84
  , "input_digits" : [0, 0, 0]
85
85
  , "output_base" : 2
86
- , "output_digits": null
86
+ , "expected" : null
87
87
  },
88
88
  { "description" : "leading zeros"
89
89
  , "input_base" : 7
90
90
  , "input_digits" : [0, 6, 0]
91
91
  , "output_base" : 10
92
- , "output_digits": null
92
+ , "expected" : null
93
93
  },
94
94
  { "description" : "negative digit"
95
95
  , "input_base" : 2
96
96
  , "input_digits" : [1, -1, 1, 0, 1, 0]
97
97
  , "output_base" : 10
98
- , "output_digits": null
98
+ , "expected" : null
99
99
  },
100
100
  { "description" : "invalid positive digit"
101
101
  , "input_base" : 2
102
102
  , "input_digits" : [1, 2, 1, 0, 1, 0]
103
103
  , "output_base" : 10
104
- , "output_digits": null
104
+ , "expected" : null
105
105
  },
106
106
  { "description" : "first base is one"
107
107
  , "input_base" : 1
108
108
  , "input_digits" : []
109
109
  , "output_base" : 10
110
- , "output_digits": null
110
+ , "expected" : null
111
111
  },
112
112
  { "description" : "second base is one"
113
113
  , "input_base" : 2
114
114
  , "input_digits" : [1, 0, 1, 0, 1, 0]
115
115
  , "output_base" : 1
116
- , "output_digits": null
116
+ , "expected" : null
117
117
  },
118
118
  { "description" : "first base is zero"
119
119
  , "input_base" : 0
120
120
  , "input_digits" : []
121
121
  , "output_base" : 10
122
- , "output_digits": null
122
+ , "expected" : null
123
123
  },
124
124
  { "description" : "second base is zero"
125
125
  , "input_base" : 10
126
126
  , "input_digits" : [7]
127
127
  , "output_base" : 0
128
- , "output_digits": null
128
+ , "expected" : null
129
129
  },
130
130
  { "description" : "first base is negative"
131
131
  , "input_base" : -2
132
132
  , "input_digits" : [1]
133
133
  , "output_base" : 10
134
- , "output_digits": null
134
+ , "expected" : null
135
135
  },
136
136
  { "description" : "second base is negative"
137
137
  , "input_base" : 2
138
138
  , "input_digits" : [1]
139
139
  , "output_base" : -7
140
- , "output_digits": null
140
+ , "expected" : null
141
141
  },
142
142
  { "description" : "both bases are negative"
143
143
  , "input_base" : -2
144
144
  , "input_digits" : [1]
145
145
  , "output_base" : -7
146
- , "output_digits": null
146
+ , "expected" : null
147
147
  } ]
148
148
  }
@@ -1,67 +1,53 @@
1
- ## Step 1
2
1
 
3
- E.g.
2
+ ## Iteration 1 — Addition
4
3
 
5
- > What is 5 plus 13?
4
+ Add two numbers together.
6
5
 
7
- The program should handle large numbers and negative numbers.
6
+ > What is 5 plus 13?
8
7
 
9
- Remember, that these are verbal word problems, not treated as you
10
- normally would treat a written problem. This means that you calculate
11
- as you move forward each step. In other words, you should ignore order
12
- of operations. 3 + 2 * 3 = 15, not 9.
8
+ Evaluates to 18.
13
9
 
14
- Use the tests to drive your solution by deleting the `skip` in one test
15
- at a time.
10
+ Handle large numbers and negative numbers.
16
11
 
17
- ## Step 2
18
12
 
19
- E.g.
13
+ ## Iteration 2 — Subtraction, Multiplication and Division
20
14
 
21
- > What is 5 plus 13?
15
+ Now, perform the other three operations.
22
16
 
23
17
  > What is 7 minus 5?
24
18
 
25
- > What is 6 multiplied by 4?
19
+ 2
26
20
 
27
- > What is 25 divided by 5?
28
-
29
- ## Step 3
30
-
31
- E.g.
32
-
33
- > What is 5 plus 13 plus 6?
34
-
35
- > What is 7 minus 5 minus 1?
21
+ > What is 6 multiplied by 4?
36
22
 
37
- > What is 9 minus 3 plus 5?
23
+ 24
38
24
 
39
- > What is 3 plus 5 minus 8?
25
+ > What is 25 divided by 5?
40
26
 
41
- ## Step 4
27
+ 5
42
28
 
43
- E.g.
44
29
 
45
- > What is 5 plus 13?
30
+ ## Iteration 3 Multiple Operations
46
31
 
47
- > What is 7 minus 5?
32
+ Handle a set of operations, in sequence.
48
33
 
49
- > What is 6 times 4?
34
+ Since these are verbal word problems, evaluate the expression from
35
+ left-to-right, _ignoring the typical order of operations._
50
36
 
51
- > What is 25 divided by 5?
37
+ > What is 5 plus 13 plus 6?
52
38
 
53
- > What is 78 plus 5 minus 3?
39
+ 24
54
40
 
55
- > What is 18 times 3 plus 16?
41
+ > What is 3 plus 2 times 3?
56
42
 
57
- > What is 4 times 3 divided by 6?
43
+ 15 (i.e. not 9)
58
44
 
59
- > What is 4 plus 3 times 2?
60
45
 
61
- ## Extensions
46
+ ## Bonus — Exponentials
62
47
 
63
- Implement questions of the type:
48
+ If you'd like, handle exponentials.
64
49
 
65
50
  > What is 2 raised to the 5th power?
66
51
 
67
- Remember to write failing tests for this code.
52
+ 32
53
+
@@ -1,4 +1,4 @@
1
1
  ---
2
- blurb: "Write a program that takes a word problem and returns the answer as an integer."
2
+ blurb: "Parse and evaluate simple math word problems returning the answer as an integer."
3
3
  source: "Inspired by one of the generated questions in the Extreme Startup game."
4
4
  source_url: "https://github.com/rchatley/extreme_startup"
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.3.4"
2
+ VERSION = "2.0.3.5"
3
3
  end
data/tracks/c/config.json CHANGED
@@ -196,6 +196,16 @@
196
196
  "text formatting",
197
197
  "memory management"
198
198
  ]
199
+ }, {
200
+ "difficulty": 4,
201
+ "slug": "meetup",
202
+ "topics": [
203
+ "control-flow (if-statements)",
204
+ "strings",
205
+ "structs",
206
+ "time functions",
207
+ "preprocessor (x-macros in test)"
208
+ ]
199
209
  }, {
200
210
  "difficulty": 2,
201
211
  "slug": "robot-simulator",
@@ -0,0 +1,15 @@
1
+ CFLAGS = -std=c99
2
+ CFLAGS += -Wall
3
+ CFLAGS += -Wextra
4
+ CFLAGS += -pedantic
5
+ CFLAGS += -Werror
6
+
7
+ test: tests.out
8
+ @./tests.out
9
+
10
+ clean:
11
+ rm -f *.o *.out
12
+
13
+ tests.out: test/test_meetup.c src/meetup.c src/meetup.h src/example.c
14
+ @echo Compiling $@
15
+ @cc $(CFLAGS) src/meetup.c test/vendor/unity.c test/test_meetup.c -o tests.out
@@ -0,0 +1,139 @@
1
+ #include <string.h>
2
+ #include <stdbool.h>
3
+ #include <time.h>
4
+ #include "meetup.h"
5
+
6
+ #define BAD_DATE_REQUESTED (0)
7
+
8
+ typedef struct {
9
+ const char *text;
10
+ int number;
11
+ } TextToIntLookup_t;
12
+
13
+ static bool isLeapyear(int year)
14
+ {
15
+ return ((((year % 4) == 0) && ((year % 100) != 0)) || ((year % 400) == 0));
16
+ }
17
+
18
+ static int daysInMonth(int year, int month)
19
+ {
20
+ int numberOfDays = 31;
21
+
22
+ switch (month) {
23
+ case 4:
24
+ case 6:
25
+ case 9:
26
+ case 11:
27
+ numberOfDays = 30;
28
+ break;
29
+ case 2:
30
+ if (isLeapyear(year)) {
31
+ numberOfDays = 29;
32
+ } else {
33
+ numberOfDays = 28;
34
+ }
35
+ break;
36
+ }
37
+ return numberOfDays;
38
+ }
39
+
40
+ static int getNumberGivenText(const char *text, TextToIntLookup_t * lookup,
41
+ size_t numberEntries)
42
+ {
43
+ int matchNumber = -1;
44
+
45
+ for (size_t index = 0; index < numberEntries; index++) {
46
+ if (0 == strcmp(text, lookup[index].text)) {
47
+ matchNumber = lookup[index].number;
48
+ break;
49
+ }
50
+ }
51
+ return matchNumber;
52
+ }
53
+
54
+ static int getDayOfWeekFromDate(unsigned int year, unsigned int month,
55
+ unsigned int day)
56
+ {
57
+ struct tm firstDayOfTestMonth;
58
+ time_t midnightFirstDayofTestMonth;
59
+
60
+ firstDayOfTestMonth.tm_year = year - 1900;
61
+ firstDayOfTestMonth.tm_mon = month - 1;
62
+ firstDayOfTestMonth.tm_mday = day;
63
+ firstDayOfTestMonth.tm_hour = 0;
64
+ firstDayOfTestMonth.tm_min = 0;
65
+ firstDayOfTestMonth.tm_sec = 0;
66
+ firstDayOfTestMonth.tm_isdst = 0;
67
+ midnightFirstDayofTestMonth = mktime(&firstDayOfTestMonth);
68
+
69
+ return (localtime(&midnightFirstDayofTestMonth)->tm_wday);
70
+ }
71
+
72
+ static int getWeekOfMonth(const char *week)
73
+ {
74
+ TextToIntLookup_t whichWeekOfMonthLookup[] = {
75
+ {"first", 1},
76
+ {"second", 2},
77
+ {"third", 3},
78
+ {"fourth", 4},
79
+ {"fifth", 5},
80
+ {"last", 6},
81
+ {"teenth", 7}
82
+ };
83
+
84
+ return getNumberGivenText(week, &whichWeekOfMonthLookup[0],
85
+ sizeof(whichWeekOfMonthLookup) /
86
+ sizeof(TextToIntLookup_t));
87
+ }
88
+
89
+ static int getRequestedDayOfWeek(const char *dayOfWeek)
90
+ {
91
+ TextToIntLookup_t dayLookup[] = {
92
+ {"Sunday", 0},
93
+ {"Monday", 1},
94
+ {"Tuesday", 2},
95
+ {"Wednesday", 3},
96
+ {"Thursday", 4},
97
+ {"Friday", 5},
98
+ {"Saturday", 6}
99
+ };
100
+
101
+ return getNumberGivenText(dayOfWeek, &dayLookup[0],
102
+ sizeof(dayLookup) / sizeof(TextToIntLookup_t));
103
+ }
104
+
105
+ int meetupDayOfMonth(unsigned int year, unsigned int month, const char *week,
106
+ const char *dayOfWeek)
107
+ {
108
+ int dayOfMonth = BAD_DATE_REQUESTED;
109
+ int baselineDayOfWeek;
110
+ int daysInTestMonth = daysInMonth(year, month);
111
+ int dayOffset;
112
+ int referenceDay = 1; // used to calculate a baseline day of week given a target date.
113
+
114
+ int whichWeekOfMonth = getWeekOfMonth(week);
115
+ int targetDayInWeek = getRequestedDayOfWeek(dayOfWeek);
116
+
117
+ // check for valid lookup...
118
+ if ((whichWeekOfMonth >= 0) && (targetDayInWeek >= 0)) {
119
+ // first - fifth Xday of month
120
+ if (whichWeekOfMonth <= 5) {
121
+ dayOffset = 1 + ((whichWeekOfMonth - 1) * 7);
122
+ } else {
123
+ // code for last Xday of month
124
+ if (6 == whichWeekOfMonth) {
125
+ referenceDay = daysInTestMonth - 6; // use the last unique day near end of month as reference
126
+ } else {
127
+ referenceDay = 13; // use first teenth day as reference
128
+ }
129
+ dayOffset = referenceDay;
130
+ }
131
+ baselineDayOfWeek = getDayOfWeekFromDate(year, month, referenceDay);
132
+ dayOfMonth = dayOffset + ((targetDayInWeek + 7 - baselineDayOfWeek) % 7);
133
+ }
134
+
135
+ if (dayOfMonth > daysInTestMonth) {
136
+ dayOfMonth = BAD_DATE_REQUESTED;
137
+ }
138
+ return dayOfMonth;
139
+ }
@@ -0,0 +1,7 @@
1
+ #ifndef _MEETUP_H
2
+ #define _MEETUP_H
3
+
4
+ int meetupDayOfMonth(unsigned int year, unsigned int month, const char *week,
5
+ const char *dayOfWeek);
6
+
7
+ #endif