trackler 2.2.1.86 → 2.2.1.87

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/reverse-string/metadata.yml +0 -1
  4. data/tracks/bash/CONTRIBUTING.md +129 -28
  5. data/tracks/bash/config/exercise_readme.go.tmpl +10 -4
  6. data/tracks/bash/exercises/acronym/README.md +8 -11
  7. data/tracks/bash/exercises/acronym/{acronym_tests.sh → acronym_test.sh} +0 -0
  8. data/tracks/bash/exercises/anagram/README.md +6 -1
  9. data/tracks/bash/exercises/anagram/anagram_test.sh +1 -1
  10. data/tracks/bash/exercises/armstrong-numbers/README.md +10 -2
  11. data/tracks/bash/exercises/atbash-cipher/README.md +6 -6
  12. data/tracks/bash/exercises/bob/README.md +8 -1
  13. data/tracks/bash/exercises/collatz-conjecture/README.md +11 -2
  14. data/tracks/bash/exercises/collatz-conjecture/{collatz_test.sh → collatz_conjecture_test.sh} +6 -6
  15. data/tracks/bash/exercises/difference-of-squares/README.md +6 -1
  16. data/tracks/bash/exercises/error-handling/README.md +13 -5
  17. data/tracks/bash/exercises/error-handling/error_handling_test.sh +18 -22
  18. data/tracks/bash/exercises/error-handling/example.sh +7 -6
  19. data/tracks/bash/exercises/gigasecond/.meta/hints.md +0 -5
  20. data/tracks/bash/exercises/gigasecond/README.md +36 -1
  21. data/tracks/bash/exercises/grains/README.md +10 -2
  22. data/tracks/bash/exercises/hamming/README.md +6 -1
  23. data/tracks/bash/exercises/hello-world/README.md +7 -2
  24. data/tracks/bash/exercises/leap/README.md +7 -2
  25. data/tracks/bash/exercises/luhn/README.md +7 -2
  26. data/tracks/bash/exercises/nucleotide-count/README.md +13 -22
  27. data/tracks/bash/exercises/pangram/README.md +7 -2
  28. data/tracks/bash/exercises/phone-number/README.md +10 -4
  29. data/tracks/bash/exercises/raindrops/README.md +6 -1
  30. data/tracks/bash/exercises/reverse-string/README.md +11 -2
  31. data/tracks/bash/exercises/rna-transcription/README.md +7 -2
  32. data/tracks/bash/exercises/roman-numerals/README.md +11 -2
  33. data/tracks/bash/exercises/triangle/README.md +5 -4
  34. data/tracks/bash/exercises/two-fer/README.md +7 -9
  35. data/tracks/bash/exercises/word-count/README.md +6 -2
  36. data/tracks/bash/exercises/word-count/example.sh +22 -13
  37. data/tracks/bash/scripts/canonical_data_check.sh +112 -0
  38. data/tracks/c/exercises/acronym/src/{example.h → acronym.h} +0 -0
  39. data/tracks/c/exercises/gigasecond/.meta/hints.md +124 -0
  40. data/tracks/c/exercises/gigasecond/README.md +126 -0
  41. data/tracks/c/exercises/isogram/src/{example.h → isogram.h} +0 -0
  42. data/tracks/c/exercises/meetup/.meta/hints.md +124 -0
  43. data/tracks/c/exercises/meetup/README.md +142 -12
  44. data/tracks/c/exercises/pangram/src/{example.h → pangram.h} +0 -0
  45. data/tracks/c/exercises/space-age/.meta/hints.md +124 -0
  46. data/tracks/c/exercises/space-age/README.md +127 -2
  47. data/tracks/elisp/bin/test-examples +11 -14
  48. data/tracks/elisp/config.json +9 -1
  49. data/tracks/elisp/exercises/acronym/README.md +13 -0
  50. data/tracks/elisp/exercises/acronym/acronym-test.el +28 -0
  51. data/tracks/elisp/exercises/acronym/acronym.el +11 -0
  52. data/tracks/elisp/exercises/acronym/example.el +14 -0
  53. data/tracks/elisp/exercises/bob/example.el +1 -3
  54. data/tracks/elisp/exercises/hamming/README.md +2 -0
  55. data/tracks/elisp/exercises/hamming/hamming-test.el +35 -12
  56. data/tracks/elisp/exercises/hamming/hamming.el +0 -3
  57. data/tracks/fsharp/exercises/custom-set/CustomSetTest.fs +206 -132
  58. data/tracks/fsharp/exercises/custom-set/Example.fs +2 -0
  59. data/tracks/fsharp/generators/Generators.fs +61 -0
  60. data/tracks/go/config.json +25 -2
  61. data/tracks/go/exercises/acronym/acronym_test.go +8 -0
  62. data/tracks/go/exercises/alphametics/.meta/gen.go +72 -0
  63. data/tracks/go/exercises/alphametics/.meta/hints.md +38 -0
  64. data/tracks/go/exercises/alphametics/README.md +93 -0
  65. data/tracks/go/exercises/alphametics/alphametics_test.go +33 -0
  66. data/tracks/go/exercises/alphametics/cases_test.go +59 -0
  67. data/tracks/go/exercises/alphametics/example.go +212 -0
  68. data/tracks/go/exercises/atbash-cipher/.meta/gen.go +6 -4
  69. data/tracks/go/exercises/atbash-cipher/cases_test.go +2 -2
  70. data/tracks/go/exercises/change/.meta/gen.go +7 -5
  71. data/tracks/go/exercises/change/cases_test.go +2 -2
  72. data/tracks/go/exercises/collatz-conjecture/.meta/gen.go +5 -3
  73. data/tracks/go/exercises/collatz-conjecture/cases_test.go +2 -2
  74. data/tracks/go/exercises/connect/.meta/gen.go +5 -3
  75. data/tracks/go/exercises/connect/cases_test.go +2 -2
  76. data/tracks/go/exercises/flatten-array/.meta/gen.go +5 -3
  77. data/tracks/go/exercises/flatten-array/cases_test.go +2 -2
  78. data/tracks/go/exercises/meetup/.meta/gen.go +19 -8
  79. data/tracks/go/exercises/meetup/cases_test.go +2 -2
  80. data/tracks/go/exercises/simple-linked-list/README.md +47 -0
  81. data/tracks/go/exercises/simple-linked-list/example.go +74 -0
  82. data/tracks/go/exercises/simple-linked-list/linked_list_test.go +210 -0
  83. data/tracks/idris/config.json +2 -2
  84. data/tracks/java/exercises/all-your-base/.meta/src/reference/java/BaseConverter.java +1 -5
  85. data/tracks/java/exercises/all-your-base/.meta/version +1 -1
  86. data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +34 -10
  87. data/tracks/java/exercises/bob/README.md +2 -0
  88. data/tracks/java/exercises/kindergarten-garden/.meta/version +1 -0
  89. data/tracks/java/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java +0 -55
  90. data/tracks/java/exercises/meetup/.meta/version +1 -0
  91. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +32 -0
  92. data/tracks/java/exercises/parallel-letter-frequency/README.md +1 -0
  93. data/tracks/java/exercises/proverb/README.md +16 -10
  94. data/tracks/java/exercises/rail-fence-cipher/README.md +5 -6
  95. data/tracks/java/exercises/two-fer/README.md +1 -1
  96. data/tracks/java/exercises/word-search/.meta/version +1 -1
  97. data/tracks/java/exercises/word-search/src/test/java/WordSearcherTest.java +240 -2
  98. data/tracks/javascript/.eslintignore +0 -1
  99. data/tracks/javascript/exercises/palindrome-products/example.js +3 -3
  100. data/tracks/kotlin/docs/INSTALLATION.md +77 -68
  101. data/tracks/kotlin/docs/TESTS.md +41 -39
  102. data/tracks/perl6/exercises/acronym/acronym.t +20 -8
  103. data/tracks/perl6/exercises/acronym/example.yaml +1 -1
  104. data/tracks/perl6/exercises/all-your-base/all-your-base.t +108 -66
  105. data/tracks/perl6/exercises/all-your-base/example.yaml +2 -2
  106. data/tracks/perl6/exercises/allergies/allergies.t +39 -15
  107. data/tracks/perl6/exercises/allergies/example.yaml +2 -2
  108. data/tracks/perl6/exercises/anagram/anagram.t +73 -40
  109. data/tracks/perl6/exercises/anagram/example.yaml +1 -1
  110. data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +38 -15
  111. data/tracks/perl6/exercises/atbash-cipher/example.yaml +1 -1
  112. data/tracks/perl6/exercises/bob/bob.t +77 -27
  113. data/tracks/perl6/exercises/bob/example.yaml +1 -1
  114. data/tracks/perl6/exercises/flatten-array/example.yaml +1 -1
  115. data/tracks/perl6/exercises/flatten-array/flatten-array.t +20 -8
  116. data/tracks/perl6/exercises/luhn/example.yaml +1 -1
  117. data/tracks/perl6/exercises/luhn/luhn.t +42 -16
  118. data/tracks/perl6/exercises/roman-numerals/README.md +68 -0
  119. data/tracks/php/exercises/gigasecond/gigasecond_test.php +1 -1
  120. data/tracks/python/docs/ABOUT.md +2 -2
  121. metadata +27 -10
  122. data/tracks/bash/docs/EXERCISE_README_INSERT.md +0 -3
  123. data/tracks/bash/exercises/word-count/example.awk +0 -12
  124. data/tracks/java/exercises/alphametics/src/main/java/.keep +0 -0
@@ -4,6 +4,132 @@ Calculate the moment when someone has lived for 10^9 seconds.
4
4
 
5
5
  A gigasecond is 10^9 (1,000,000,000) seconds.
6
6
 
7
+ ## Exercises without stub implementations
8
+
9
+ Like the majority of C programs you will write, this exercise comes without any header file (`*.h`) or source file (`*.c`).
10
+
11
+
12
+ ### Add the required files
13
+
14
+ You will need to create these yourself as part of the exercise.
15
+ This is so that you get to practice deciding on and creating the program's interface yourself, which is an important part of programming in C.
16
+ It does mean that when you first try to run the tests, they won't compile.
17
+ They will give you an error similar to:
18
+
19
+ ```bash
20
+ make: *** No rule to make target 'src/exercise_name.c', needed by 'tests.out'. Stop.
21
+ ```
22
+
23
+ This error occurs because the `makefile` attempts to use a file that hasn't been created yet (`exercise_name.c`).
24
+ To resolve this error you will need to add a matching file to the `src` directory.
25
+ For example, for the error above you would add a file called `exercise_name.c`.
26
+
27
+ When you try to run the tests again you will get a slightly different error.
28
+
29
+ ```bash
30
+ make: *** No rule to make target 'src/exercise_name.h', needed by 'tests.out'. Stop.
31
+ ```
32
+
33
+ Again the `makefile` still needs another file that has yet to be created (`exercise_name.h`).
34
+ The solution to this error is similar to the last, add the matching file to the `src` directory.
35
+ For example, for the above error you would add a file called `exercise_name.h`
36
+
37
+
38
+ ### Add the required declarations
39
+
40
+ Running the tests a third time you see you will get new errors, similar to:
41
+
42
+ ```bash
43
+ Compiling tests.out
44
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
45
+ cc1: all warnings being treated as errors
46
+ test/test_exercise_name.c:13:1: error: unknown type name ‘bar_t’; did you mean ‘__bar_t’?
47
+ bar_t b = foo(a, 2.5);
48
+ ^~~~~~
49
+ __bar_t
50
+ test/test_exercise_name.c:15:14: error: storage size of fizz isn’t known
51
+ struct baz fizz;
52
+ ^~~~
53
+ test/test_exercise_name.c:29:20: error: implicit declaration of function ‘foo’ [-Werror=implicit-function-declaration]
54
+ bar_t b = foo_function(fizz, 2.5);
55
+ ```
56
+
57
+ This error means that you need to add function, type and variable decarations to the header file to match those the test file is attempting to use.
58
+ In doing this you will need to look at the build errors and the test code to determine what needs to be declared in the header file.
59
+
60
+ For example, for the error above you should declare a type named `bar_t`, a `struct` called `baz` and a function named `foo()`.
61
+ Additionally we can tell from looking at the above errors that function `foo()` has two parameters.
62
+
63
+ The first parameter is passed an argument of `fizz` and thus should have a type of `struct baz`.
64
+ The second parameter is passed `2.5` and so could have one of two types, either `float` or `double`.
65
+ You will need to look at the test code to determine which.
66
+
67
+ The _names_ of the parameters are not determined by the test code and so are left up to you to decide, though in keeping with C programming practices they should be descriptive but not overly long.
68
+
69
+ Further, we can see that the the return type expected by the test code is of the type `bar_t`.
70
+
71
+ Putting this all together we end up with a function declaration that looks like the following:
72
+
73
+ ```c
74
+ // The parameter names are not very good here they should be more descriptive in a real exercise.
75
+ // We have decide on a double for the second parameter in this hypothetical example.
76
+ bar_t foo(struct baz b, double d);
77
+ ```
78
+
79
+ You should continue to do this for any further similar errors.
80
+ To check that you have correctly determined the required declaration, just run the tests again and analyse any errors similarly.
81
+
82
+ Additionally, remember to add any includes to the header file any headers that it itself requires.
83
+
84
+
85
+ ### Include guards
86
+
87
+ Before you are finished with the header file, you should add include guards.
88
+ Include guards are used to help prevent the file from being included multiple times by accident.
89
+ If the file _was_ included multiple times then the functions and other items would be declared twice; In C this is an error because the compiler thinks you are trying to declare another _different_ function that has the same name.
90
+
91
+ To add include guards, add something similar to the following as the first two lines of the header:
92
+
93
+ ```c
94
+ #ifndef EXERCISE_NAME_H
95
+ #define EXERCISE_NAME_H
96
+ ```
97
+
98
+ And on the very last line:
99
+
100
+ ```c
101
+ #endif
102
+ ```
103
+
104
+
105
+ ### Add the required definitions
106
+
107
+ Once the header file is complete you may still have build errors similar to the following:
108
+
109
+ ```bash
110
+ Compiling tests.out
111
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
112
+ cc1: all warnings being treated as errors
113
+ makefile:24: recipe for target 'tests.out' failed
114
+ make: *** [tests.out] Error 1
115
+ ```
116
+
117
+ This is because although you have _declared_ all the items you need to, they have not yet been _defined_.
118
+ To define the needed items you need to add their implementation to the `exercise_name.c` file.
119
+ For the function `foo()` from the previous example, this would look similar to:
120
+
121
+ ```c
122
+ #include "exercise_name.h"
123
+
124
+ bar_t foo(struct baz b, double d)
125
+ {
126
+ // Your exercise code here
127
+ }
128
+ ```
129
+
130
+ After having resolved these errors you should be ready to start making the tests pass!
131
+
132
+
7
133
  ## Getting Started
8
134
 
9
135
  Make sure you have read the
@@ -0,0 +1,124 @@
1
+ ## Exercises without stub implementations
2
+
3
+ Like the majority of C programs you will write, this exercise comes without any header file (`*.h`) or source file (`*.c`).
4
+
5
+
6
+ ### Add the required files
7
+
8
+ You will need to create these yourself as part of the exercise.
9
+ This is so that you get to practice deciding on and creating the program's interface yourself, which is an important part of programming in C.
10
+ It does mean that when you first try to run the tests, they won't compile.
11
+ They will give you an error similar to:
12
+
13
+ ```bash
14
+ make: *** No rule to make target 'src/exercise_name.c', needed by 'tests.out'. Stop.
15
+ ```
16
+
17
+ This error occurs because the `makefile` attempts to use a file that hasn't been created yet (`exercise_name.c`).
18
+ To resolve this error you will need to add a matching file to the `src` directory.
19
+ For example, for the error above you would add a file called `exercise_name.c`.
20
+
21
+ When you try to run the tests again you will get a slightly different error.
22
+
23
+ ```bash
24
+ make: *** No rule to make target 'src/exercise_name.h', needed by 'tests.out'. Stop.
25
+ ```
26
+
27
+ Again the `makefile` still needs another file that has yet to be created (`exercise_name.h`).
28
+ The solution to this error is similar to the last, add the matching file to the `src` directory.
29
+ For example, for the above error you would add a file called `exercise_name.h`
30
+
31
+
32
+ ### Add the required declarations
33
+
34
+ Running the tests a third time you see you will get new errors, similar to:
35
+
36
+ ```bash
37
+ Compiling tests.out
38
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
39
+ cc1: all warnings being treated as errors
40
+ test/test_exercise_name.c:13:1: error: unknown type name ‘bar_t’; did you mean ‘__bar_t’?
41
+ bar_t b = foo(a, 2.5);
42
+ ^~~~~~
43
+ __bar_t
44
+ test/test_exercise_name.c:15:14: error: storage size of fizz isn’t known
45
+ struct baz fizz;
46
+ ^~~~
47
+ test/test_exercise_name.c:29:20: error: implicit declaration of function ‘foo’ [-Werror=implicit-function-declaration]
48
+ bar_t b = foo_function(fizz, 2.5);
49
+ ```
50
+
51
+ This error means that you need to add function, type and variable decarations to the header file to match those the test file is attempting to use.
52
+ In doing this you will need to look at the build errors and the test code to determine what needs to be declared in the header file.
53
+
54
+ For example, for the error above you should declare a type named `bar_t`, a `struct` called `baz` and a function named `foo()`.
55
+ Additionally we can tell from looking at the above errors that function `foo()` has two parameters.
56
+
57
+ The first parameter is passed an argument of `fizz` and thus should have a type of `struct baz`.
58
+ The second parameter is passed `2.5` and so could have one of two types, either `float` or `double`.
59
+ You will need to look at the test code to determine which.
60
+
61
+ The _names_ of the parameters are not determined by the test code and so are left up to you to decide, though in keeping with C programming practices they should be descriptive but not overly long.
62
+
63
+ Further, we can see that the the return type expected by the test code is of the type `bar_t`.
64
+
65
+ Putting this all together we end up with a function declaration that looks like the following:
66
+
67
+ ```c
68
+ // The parameter names are not very good here they should be more descriptive in a real exercise.
69
+ // We have decide on a double for the second parameter in this hypothetical example.
70
+ bar_t foo(struct baz b, double d);
71
+ ```
72
+
73
+ You should continue to do this for any further similar errors.
74
+ To check that you have correctly determined the required declaration, just run the tests again and analyse any errors similarly.
75
+
76
+ Additionally, remember to add any includes to the header file any headers that it itself requires.
77
+
78
+
79
+ ### Include guards
80
+
81
+ Before you are finished with the header file, you should add include guards.
82
+ Include guards are used to help prevent the file from being included multiple times by accident.
83
+ If the file _was_ included multiple times then the functions and other items would be declared twice; In C this is an error because the compiler thinks you are trying to declare another _different_ function that has the same name.
84
+
85
+ To add include guards, add something similar to the following as the first two lines of the header:
86
+
87
+ ```c
88
+ #ifndef EXERCISE_NAME_H
89
+ #define EXERCISE_NAME_H
90
+ ```
91
+
92
+ And on the very last line:
93
+
94
+ ```c
95
+ #endif
96
+ ```
97
+
98
+
99
+ ### Add the required definitions
100
+
101
+ Once the header file is complete you may still have build errors similar to the following:
102
+
103
+ ```bash
104
+ Compiling tests.out
105
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
106
+ cc1: all warnings being treated as errors
107
+ makefile:24: recipe for target 'tests.out' failed
108
+ make: *** [tests.out] Error 1
109
+ ```
110
+
111
+ This is because although you have _declared_ all the items you need to, they have not yet been _defined_.
112
+ To define the needed items you need to add their implementation to the `exercise_name.c` file.
113
+ For the function `foo()` from the previous example, this would look similar to:
114
+
115
+ ```c
116
+ #include "exercise_name.h"
117
+
118
+ bar_t foo(struct baz b, double d)
119
+ {
120
+ // Your exercise code here
121
+ }
122
+ ```
123
+
124
+ After having resolved these errors you should be ready to start making the tests pass!
@@ -2,25 +2,155 @@
2
2
 
3
3
  Calculate the date of meetups.
4
4
 
5
- Typically meetups happen on the same day of the week. In this exercise, you will take
6
- a description of a meetup date, and return the actual meetup date.
5
+ Typically meetups happen on the same day of the week. In this exercise, you
6
+ will take a description of a meetup date, and return the actual meetup date.
7
7
 
8
8
  Examples of general descriptions are:
9
9
 
10
- - the first Monday of January 2017
11
- - the third Tuesday of January 2017
12
- - the Wednesteenth of January 2017
13
- - the last Thursday of January 2017
10
+ - The first Monday of January 2017
11
+ - The third Tuesday of January 2017
12
+ - The wednesteenth of January 2017
13
+ - The last Thursday of January 2017
14
14
 
15
- Note that "Monteenth", "Tuesteenth", etc are all made up words. There
16
- was a meetup whose members realized that there are exactly 7 numbered days in a month that
17
- end in '-teenth'. Therefore, one is guaranteed that each day of the week
15
+ The descriptors you are expected to parse are:
16
+ first, second, third, fourth, fifth, last, monteenth, tuesteenth, wednesteenth,
17
+ thursteenth, friteenth, saturteenth, sunteenth
18
+
19
+ Note that "monteenth", "tuesteenth", etc are all made up words. There was a
20
+ meetup whose members realized that there are exactly 7 numbered days in a month
21
+ that end in '-teenth'. Therefore, one is guaranteed that each day of the week
18
22
  (Monday, Tuesday, ...) will have exactly one date that is named with '-teenth'
19
23
  in every month.
20
24
 
21
- Given examples of a meetup dates, each containing a month, day, year, and descriptor
22
- (first, second, teenth, etc), calculate the date of the actual meetup.
23
- For example, if given "First Monday of January 2017", the correct meetup date is 2017/1/2
25
+ Given examples of a meetup dates, each containing a month, day, year, and
26
+ descriptor calculate the date of the actual meetup. For example, if given
27
+ "The first Monday of January 2017", the correct meetup date is 2017/1/2.
28
+
29
+ ## Exercises without stub implementations
30
+
31
+ Like the majority of C programs you will write, this exercise comes without any header file (`*.h`) or source file (`*.c`).
32
+
33
+
34
+ ### Add the required files
35
+
36
+ You will need to create these yourself as part of the exercise.
37
+ This is so that you get to practice deciding on and creating the program's interface yourself, which is an important part of programming in C.
38
+ It does mean that when you first try to run the tests, they won't compile.
39
+ They will give you an error similar to:
40
+
41
+ ```bash
42
+ make: *** No rule to make target 'src/exercise_name.c', needed by 'tests.out'. Stop.
43
+ ```
44
+
45
+ This error occurs because the `makefile` attempts to use a file that hasn't been created yet (`exercise_name.c`).
46
+ To resolve this error you will need to add a matching file to the `src` directory.
47
+ For example, for the error above you would add a file called `exercise_name.c`.
48
+
49
+ When you try to run the tests again you will get a slightly different error.
50
+
51
+ ```bash
52
+ make: *** No rule to make target 'src/exercise_name.h', needed by 'tests.out'. Stop.
53
+ ```
54
+
55
+ Again the `makefile` still needs another file that has yet to be created (`exercise_name.h`).
56
+ The solution to this error is similar to the last, add the matching file to the `src` directory.
57
+ For example, for the above error you would add a file called `exercise_name.h`
58
+
59
+
60
+ ### Add the required declarations
61
+
62
+ Running the tests a third time you see you will get new errors, similar to:
63
+
64
+ ```bash
65
+ Compiling tests.out
66
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
67
+ cc1: all warnings being treated as errors
68
+ test/test_exercise_name.c:13:1: error: unknown type name ‘bar_t’; did you mean ‘__bar_t’?
69
+ bar_t b = foo(a, 2.5);
70
+ ^~~~~~
71
+ __bar_t
72
+ test/test_exercise_name.c:15:14: error: storage size of fizz isn’t known
73
+ struct baz fizz;
74
+ ^~~~
75
+ test/test_exercise_name.c:29:20: error: implicit declaration of function ‘foo’ [-Werror=implicit-function-declaration]
76
+ bar_t b = foo_function(fizz, 2.5);
77
+ ```
78
+
79
+ This error means that you need to add function, type and variable decarations to the header file to match those the test file is attempting to use.
80
+ In doing this you will need to look at the build errors and the test code to determine what needs to be declared in the header file.
81
+
82
+ For example, for the error above you should declare a type named `bar_t`, a `struct` called `baz` and a function named `foo()`.
83
+ Additionally we can tell from looking at the above errors that function `foo()` has two parameters.
84
+
85
+ The first parameter is passed an argument of `fizz` and thus should have a type of `struct baz`.
86
+ The second parameter is passed `2.5` and so could have one of two types, either `float` or `double`.
87
+ You will need to look at the test code to determine which.
88
+
89
+ The _names_ of the parameters are not determined by the test code and so are left up to you to decide, though in keeping with C programming practices they should be descriptive but not overly long.
90
+
91
+ Further, we can see that the the return type expected by the test code is of the type `bar_t`.
92
+
93
+ Putting this all together we end up with a function declaration that looks like the following:
94
+
95
+ ```c
96
+ // The parameter names are not very good here they should be more descriptive in a real exercise.
97
+ // We have decide on a double for the second parameter in this hypothetical example.
98
+ bar_t foo(struct baz b, double d);
99
+ ```
100
+
101
+ You should continue to do this for any further similar errors.
102
+ To check that you have correctly determined the required declaration, just run the tests again and analyse any errors similarly.
103
+
104
+ Additionally, remember to add any includes to the header file any headers that it itself requires.
105
+
106
+
107
+ ### Include guards
108
+
109
+ Before you are finished with the header file, you should add include guards.
110
+ Include guards are used to help prevent the file from being included multiple times by accident.
111
+ If the file _was_ included multiple times then the functions and other items would be declared twice; In C this is an error because the compiler thinks you are trying to declare another _different_ function that has the same name.
112
+
113
+ To add include guards, add something similar to the following as the first two lines of the header:
114
+
115
+ ```c
116
+ #ifndef EXERCISE_NAME_H
117
+ #define EXERCISE_NAME_H
118
+ ```
119
+
120
+ And on the very last line:
121
+
122
+ ```c
123
+ #endif
124
+ ```
125
+
126
+
127
+ ### Add the required definitions
128
+
129
+ Once the header file is complete you may still have build errors similar to the following:
130
+
131
+ ```bash
132
+ Compiling tests.out
133
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
134
+ cc1: all warnings being treated as errors
135
+ makefile:24: recipe for target 'tests.out' failed
136
+ make: *** [tests.out] Error 1
137
+ ```
138
+
139
+ This is because although you have _declared_ all the items you need to, they have not yet been _defined_.
140
+ To define the needed items you need to add their implementation to the `exercise_name.c` file.
141
+ For the function `foo()` from the previous example, this would look similar to:
142
+
143
+ ```c
144
+ #include "exercise_name.h"
145
+
146
+ bar_t foo(struct baz b, double d)
147
+ {
148
+ // Your exercise code here
149
+ }
150
+ ```
151
+
152
+ After having resolved these errors you should be ready to start making the tests pass!
153
+
24
154
 
25
155
  ## Getting Started
26
156
 
@@ -0,0 +1,124 @@
1
+ ## Exercises without stub implementations
2
+
3
+ Like the majority of C programs you will write, this exercise comes without any header file (`*.h`) or source file (`*.c`).
4
+
5
+
6
+ ### Add the required files
7
+
8
+ You will need to create these yourself as part of the exercise.
9
+ This is so that you get to practice deciding on and creating the program's interface yourself, which is an important part of programming in C.
10
+ It does mean that when you first try to run the tests, they won't compile.
11
+ They will give you an error similar to:
12
+
13
+ ```bash
14
+ make: *** No rule to make target 'src/exercise_name.c', needed by 'tests.out'. Stop.
15
+ ```
16
+
17
+ This error occurs because the `makefile` attempts to use a file that hasn't been created yet (`exercise_name.c`).
18
+ To resolve this error you will need to add a matching file to the `src` directory.
19
+ For example, for the error above you would add a file called `exercise_name.c`.
20
+
21
+ When you try to run the tests again you will get a slightly different error.
22
+
23
+ ```bash
24
+ make: *** No rule to make target 'src/exercise_name.h', needed by 'tests.out'. Stop.
25
+ ```
26
+
27
+ Again the `makefile` still needs another file that has yet to be created (`exercise_name.h`).
28
+ The solution to this error is similar to the last, add the matching file to the `src` directory.
29
+ For example, for the above error you would add a file called `exercise_name.h`
30
+
31
+
32
+ ### Add the required declarations
33
+
34
+ Running the tests a third time you see you will get new errors, similar to:
35
+
36
+ ```bash
37
+ Compiling tests.out
38
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
39
+ cc1: all warnings being treated as errors
40
+ test/test_exercise_name.c:13:1: error: unknown type name ‘bar_t’; did you mean ‘__bar_t’?
41
+ bar_t b = foo(a, 2.5);
42
+ ^~~~~~
43
+ __bar_t
44
+ test/test_exercise_name.c:15:14: error: storage size of fizz isn’t known
45
+ struct baz fizz;
46
+ ^~~~
47
+ test/test_exercise_name.c:29:20: error: implicit declaration of function ‘foo’ [-Werror=implicit-function-declaration]
48
+ bar_t b = foo_function(fizz, 2.5);
49
+ ```
50
+
51
+ This error means that you need to add function, type and variable decarations to the header file to match those the test file is attempting to use.
52
+ In doing this you will need to look at the build errors and the test code to determine what needs to be declared in the header file.
53
+
54
+ For example, for the error above you should declare a type named `bar_t`, a `struct` called `baz` and a function named `foo()`.
55
+ Additionally we can tell from looking at the above errors that function `foo()` has two parameters.
56
+
57
+ The first parameter is passed an argument of `fizz` and thus should have a type of `struct baz`.
58
+ The second parameter is passed `2.5` and so could have one of two types, either `float` or `double`.
59
+ You will need to look at the test code to determine which.
60
+
61
+ The _names_ of the parameters are not determined by the test code and so are left up to you to decide, though in keeping with C programming practices they should be descriptive but not overly long.
62
+
63
+ Further, we can see that the the return type expected by the test code is of the type `bar_t`.
64
+
65
+ Putting this all together we end up with a function declaration that looks like the following:
66
+
67
+ ```c
68
+ // The parameter names are not very good here they should be more descriptive in a real exercise.
69
+ // We have decide on a double for the second parameter in this hypothetical example.
70
+ bar_t foo(struct baz b, double d);
71
+ ```
72
+
73
+ You should continue to do this for any further similar errors.
74
+ To check that you have correctly determined the required declaration, just run the tests again and analyse any errors similarly.
75
+
76
+ Additionally, remember to add any includes to the header file any headers that it itself requires.
77
+
78
+
79
+ ### Include guards
80
+
81
+ Before you are finished with the header file, you should add include guards.
82
+ Include guards are used to help prevent the file from being included multiple times by accident.
83
+ If the file _was_ included multiple times then the functions and other items would be declared twice; In C this is an error because the compiler thinks you are trying to declare another _different_ function that has the same name.
84
+
85
+ To add include guards, add something similar to the following as the first two lines of the header:
86
+
87
+ ```c
88
+ #ifndef EXERCISE_NAME_H
89
+ #define EXERCISE_NAME_H
90
+ ```
91
+
92
+ And on the very last line:
93
+
94
+ ```c
95
+ #endif
96
+ ```
97
+
98
+
99
+ ### Add the required definitions
100
+
101
+ Once the header file is complete you may still have build errors similar to the following:
102
+
103
+ ```bash
104
+ Compiling tests.out
105
+ src/exercise_name.c:1:0: error: ISO C forbids an empty translation unit [-Werror=pedantic]
106
+ cc1: all warnings being treated as errors
107
+ makefile:24: recipe for target 'tests.out' failed
108
+ make: *** [tests.out] Error 1
109
+ ```
110
+
111
+ This is because although you have _declared_ all the items you need to, they have not yet been _defined_.
112
+ To define the needed items you need to add their implementation to the `exercise_name.c` file.
113
+ For the function `foo()` from the previous example, this would look similar to:
114
+
115
+ ```c
116
+ #include "exercise_name.h"
117
+
118
+ bar_t foo(struct baz b, double d)
119
+ {
120
+ // Your exercise code here
121
+ }
122
+ ```
123
+
124
+ After having resolved these errors you should be ready to start making the tests pass!