trackler 2.2.1.74 → 2.2.1.75
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fixtures/tracks/fruit/docs/something.md +0 -0
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/README.md +8 -4
- data/problem-specifications/exercises/acronym/canonical-data.json +19 -7
- data/problem-specifications/exercises/all-your-base/canonical-data.json +106 -64
- data/problem-specifications/exercises/allergies/canonical-data.json +37 -13
- data/tracks/c/config.json +176 -176
- data/tracks/clojure/config.json +17 -1
- data/tracks/clojure/exercises/isbn-verifier/README.md +43 -0
- data/tracks/clojure/exercises/isbn-verifier/project.clj +4 -0
- data/tracks/clojure/exercises/isbn-verifier/src/example.clj +17 -0
- data/tracks/clojure/exercises/isbn-verifier/src/isbn_verifier.clj +3 -0
- data/tracks/clojure/exercises/isbn-verifier/test/isbn_verifier_test.clj +42 -0
- data/tracks/clojure/exercises/proverb/README.md +15 -0
- data/tracks/clojure/exercises/proverb/project.clj +4 -0
- data/tracks/clojure/exercises/proverb/src/example.clj +15 -0
- data/tracks/clojure/exercises/proverb/src/proverb.clj +3 -0
- data/tracks/clojure/exercises/proverb/test/proverb_test.clj +14 -0
- data/tracks/common-lisp/docs/LEARNING.md +4 -3
- data/tracks/common-lisp/docs/RESOURCES.md +11 -0
- data/tracks/delphi/.gitignore +1 -0
- data/tracks/delphi/config.json +24 -0
- data/tracks/delphi/docs/INSTALLATION.md +1 -1
- data/tracks/delphi/exercises/isbn-verifier/ISBNVerifier.dpr +60 -0
- data/tracks/delphi/exercises/isbn-verifier/README.md +68 -0
- data/tracks/delphi/exercises/isbn-verifier/uISBNVerifierExample.pas +46 -0
- data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +136 -0
- data/tracks/delphi/exercises/secret-handshake/README.md +56 -0
- data/tracks/delphi/exercises/secret-handshake/SecretHandshake.dpr +60 -0
- data/tracks/delphi/exercises/secret-handshake/uSecretHandshakeExample.pas +56 -0
- data/tracks/delphi/exercises/secret-handshake/uTestSecretHandshake.pas +215 -0
- data/tracks/ecmascript/docs/ABOUT.md +13 -9
- data/tracks/factor/exercises/two-fer/README.md +1 -1
- data/tracks/fsharp/docs/RESOURCES.md +1 -1
- data/tracks/fsharp/generators/{Input.fs → CanonicalData.fs} +5 -10
- data/tracks/fsharp/generators/Exercise.fs +11 -10
- data/tracks/fsharp/generators/{Output.fs → Formatting.fs} +2 -56
- data/tracks/fsharp/generators/Generators.fs +93 -93
- data/tracks/fsharp/generators/Generators.fsproj +9 -4
- data/tracks/fsharp/generators/Options.fs +1 -1
- data/tracks/fsharp/generators/Program.fs +3 -3
- data/tracks/fsharp/generators/Rendering.fs +57 -0
- data/tracks/go/exercises/all-your-base/.meta/gen.go +80 -0
- data/tracks/go/exercises/all-your-base/.meta/hints.md +13 -0
- data/tracks/go/exercises/all-your-base/README.md +16 -1
- data/tracks/go/exercises/all-your-base/all_your_base_test.go +12 -163
- data/tracks/go/exercises/all-your-base/cases_test.go +183 -0
- data/tracks/go/exercises/all-your-base/example.go +25 -29
- data/tracks/java/CONTRIBUTING.md +1 -1
- data/tracks/java/POLICIES.md +15 -1
- data/tracks/java/exercises/flatten-array/.meta/hints.md +58 -0
- data/tracks/java/exercises/flatten-array/README.md +62 -0
- data/tracks/java/exercises/hamming/src/main/java/Hamming.java +1 -1
- data/tracks/java/exercises/matrix/.meta/src/reference/java/Matrix.java +6 -6
- data/tracks/java/exercises/meetup/.meta/src/reference/java/Meetup.java +2 -2
- data/tracks/java/exercises/meetup/.meta/src/reference/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/meetup/src/main/java/MeetupSchedule.java +1 -1
- data/tracks/java/exercises/pig-latin/.meta/hints.md +58 -0
- data/tracks/java/exercises/pig-latin/README.md +61 -0
- data/tracks/java/exercises/reverse-string/src/main/java/ReverseString.java +2 -2
- data/tracks/java/exercises/secret-handshake/README.md +1 -1
- data/tracks/javascript/.eslintignore +0 -3
- data/tracks/javascript/exercises/food-chain/example.js +50 -37
- data/tracks/javascript/exercises/octal/example.js +1 -1
- data/tracks/javascript/exercises/robot-name/robot-name.spec.js +7 -7
- data/tracks/javascript/package-lock.json +1846 -0
- data/tracks/python/docs/EXERCISE_README_INSERT.md +15 -0
- data/tracks/python/exercises/accumulate/README.md +15 -0
- data/tracks/python/exercises/acronym/README.md +15 -0
- data/tracks/python/exercises/all-your-base/README.md +15 -0
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +19 -9
- data/tracks/python/exercises/allergies/README.md +15 -0
- data/tracks/python/exercises/alphametics/README.md +15 -0
- data/tracks/python/exercises/anagram/README.md +15 -0
- data/tracks/python/exercises/atbash-cipher/README.md +15 -0
- data/tracks/python/exercises/beer-song/README.md +16 -1
- data/tracks/python/exercises/binary-search-tree/README.md +16 -2
- data/tracks/python/exercises/binary-search/README.md +15 -0
- data/tracks/python/exercises/binary-search/binary_search_test.py +14 -4
- data/tracks/python/exercises/binary/README.md +15 -0
- data/tracks/python/exercises/binary/binary_test.py +14 -4
- data/tracks/python/exercises/bob/README.md +15 -0
- data/tracks/python/exercises/book-store/README.md +15 -0
- data/tracks/python/exercises/bracket-push/README.md +15 -0
- data/tracks/python/exercises/change/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/README.md +15 -0
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +15 -5
- data/tracks/python/exercises/circular-buffer/example.py +2 -2
- data/tracks/python/exercises/clock/README.md +15 -0
- data/tracks/python/exercises/collatz-conjecture/.meta/hints.md +1 -1
- data/tracks/python/exercises/collatz-conjecture/README.md +15 -0
- data/tracks/python/exercises/complex-numbers/README.md +15 -0
- data/tracks/python/exercises/connect/README.md +18 -3
- data/tracks/python/exercises/crypto-square/README.md +15 -0
- data/tracks/python/exercises/diamond/README.md +15 -0
- data/tracks/python/exercises/difference-of-squares/README.md +15 -0
- data/tracks/python/exercises/diffie-hellman/README.md +14 -0
- data/tracks/python/exercises/dominoes/README.md +16 -1
- data/tracks/python/exercises/error-handling/README.md +17 -0
- data/tracks/python/exercises/error-handling/error_handling_test.py +13 -3
- data/tracks/python/exercises/error-handling/example.py +1 -1
- data/tracks/python/exercises/etl/README.md +16 -1
- data/tracks/python/exercises/flatten-array/README.md +15 -0
- data/tracks/python/exercises/food-chain/README.md +15 -0
- data/tracks/python/exercises/forth/README.md +15 -0
- data/tracks/python/exercises/forth/example.py +7 -9
- data/tracks/python/exercises/forth/forth_test.py +107 -17
- data/tracks/python/exercises/gigasecond/README.md +15 -0
- data/tracks/python/exercises/go-counting/README.md +21 -3
- data/tracks/python/exercises/grade-school/README.md +15 -0
- data/tracks/python/exercises/grains/README.md +15 -0
- data/tracks/python/exercises/grains/grains_test.py +16 -6
- data/tracks/python/exercises/grep/README.md +15 -0
- data/tracks/python/exercises/hamming/README.md +15 -0
- data/tracks/python/exercises/hamming/hamming_test.py +12 -2
- data/tracks/python/exercises/hello-world/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/README.md +15 -0
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +11 -1
- data/tracks/python/exercises/house/README.md +16 -1
- data/tracks/python/exercises/isogram/README.md +15 -0
- data/tracks/python/exercises/kindergarten-garden/README.md +18 -3
- data/tracks/python/exercises/largest-series-product/README.md +15 -0
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +14 -4
- data/tracks/python/exercises/leap/README.md +15 -0
- data/tracks/python/exercises/linked-list/README.md +15 -0
- data/tracks/python/exercises/list-ops/README.md +15 -0
- data/tracks/python/exercises/luhn/README.md +15 -0
- data/tracks/python/exercises/markdown/README.md +18 -0
- data/tracks/python/exercises/matrix/README.md +15 -0
- data/tracks/python/exercises/meetup/README.md +31 -12
- data/tracks/python/exercises/meetup/meetup_test.py +11 -1
- data/tracks/python/exercises/minesweeper/README.md +15 -0
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +12 -2
- data/tracks/python/exercises/nth-prime/README.md +15 -0
- data/tracks/python/exercises/nth-prime/nth_prime_test.py +11 -1
- data/tracks/python/exercises/nucleotide-count/README.md +17 -2
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +11 -1
- data/tracks/python/exercises/ocr-numbers/README.md +16 -1
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +12 -2
- data/tracks/python/exercises/octal/README.md +15 -0
- data/tracks/python/exercises/octal/octal_test.py +16 -3
- data/tracks/python/exercises/palindrome-products/README.md +16 -1
- data/tracks/python/exercises/pangram/README.md +15 -0
- data/tracks/python/exercises/pascals-triangle/README.md +16 -1
- data/tracks/python/exercises/perfect-numbers/README.md +15 -0
- data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +13 -3
- data/tracks/python/exercises/phone-number/README.md +16 -2
- data/tracks/python/exercises/phone-number/example.py +1 -1
- data/tracks/python/exercises/phone-number/phone_number_test.py +17 -7
- data/tracks/python/exercises/pig-latin/README.md +15 -0
- data/tracks/python/exercises/point-mutations/README.md +15 -0
- data/tracks/python/exercises/poker/README.md +15 -0
- data/tracks/python/exercises/pov/README.md +20 -2
- data/tracks/python/exercises/pov/example.py +2 -2
- data/tracks/python/exercises/pov/pov_test.py +15 -5
- data/tracks/python/exercises/prime-factors/README.md +15 -0
- data/tracks/python/exercises/protein-translation/README.md +15 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +10 -0
- data/tracks/python/exercises/proverb/README.md +14 -0
- data/tracks/python/exercises/pythagorean-triplet/README.md +15 -0
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +11 -1
- data/tracks/python/exercises/queen-attack/README.md +15 -0
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +17 -7
- data/tracks/python/exercises/rail-fence-cipher/README.md +15 -0
- data/tracks/python/exercises/raindrops/README.md +15 -0
- data/tracks/python/exercises/react/README.md +15 -1
- data/tracks/python/exercises/rectangles/README.md +24 -9
- data/tracks/python/exercises/rna-transcription/.meta/hints.md +1 -0
- data/tracks/python/exercises/rna-transcription/README.md +18 -5
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +13 -3
- data/tracks/python/exercises/robot-name/README.md +15 -0
- data/tracks/python/exercises/robot-simulator/README.md +15 -0
- data/tracks/python/exercises/roman-numerals/README.md +15 -0
- data/tracks/python/exercises/rotational-cipher/README.md +15 -0
- data/tracks/python/exercises/run-length-encoding/README.md +15 -0
- data/tracks/python/exercises/saddle-points/README.md +15 -0
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +11 -1
- data/tracks/python/exercises/say/README.md +15 -0
- data/tracks/python/exercises/say/say_test.py +12 -2
- data/tracks/python/exercises/scale-generator/README.md +15 -0
- data/tracks/python/exercises/scale-generator/example.py +3 -3
- data/tracks/python/exercises/scale-generator/scale_generator_test.py +11 -1
- data/tracks/python/exercises/scrabble-score/README.md +15 -0
- data/tracks/python/exercises/secret-handshake/README.md +16 -1
- data/tracks/python/exercises/series/README.md +15 -0
- data/tracks/python/exercises/series/series_test.py +12 -2
- data/tracks/python/exercises/sieve/README.md +15 -0
- data/tracks/python/exercises/simple-cipher/.meta/hints.md +6 -6
- data/tracks/python/exercises/simple-cipher/README.md +17 -1
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +12 -2
- data/tracks/python/exercises/simple-linked-list/{hints.md → .meta/hints.md} +10 -10
- data/tracks/python/exercises/simple-linked-list/README.md +16 -0
- data/tracks/python/exercises/simple-linked-list/example.py +2 -2
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +13 -3
- data/tracks/python/exercises/space-age/README.md +15 -0
- data/tracks/python/exercises/strain/README.md +16 -3
- data/tracks/python/exercises/sublist/README.md +15 -0
- data/tracks/python/exercises/sum-of-multiples/README.md +18 -3
- data/tracks/python/exercises/tournament/README.md +15 -0
- data/tracks/python/exercises/transpose/README.md +15 -0
- data/tracks/python/exercises/tree-building/README.md +30 -0
- data/tracks/python/exercises/tree-building/example.py +3 -5
- data/tracks/python/exercises/tree-building/tree_building_test.py +16 -6
- data/tracks/python/exercises/triangle/README.md +15 -0
- data/tracks/python/exercises/triangle/example.py +1 -1
- data/tracks/python/exercises/triangle/triangle_test.py +15 -5
- data/tracks/python/exercises/trinary/README.md +15 -0
- data/tracks/python/exercises/twelve-days/README.md +15 -0
- data/tracks/python/exercises/two-bucket/README.md +22 -7
- data/tracks/python/exercises/two-fer/README.md +16 -0
- data/tracks/python/exercises/variable-length-quantity/README.md +15 -0
- data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +12 -2
- data/tracks/python/exercises/word-count/README.md +15 -0
- data/tracks/python/exercises/word-search/README.md +15 -0
- data/tracks/python/exercises/wordy/README.md +15 -0
- data/tracks/python/exercises/wordy/wordy_test.py +14 -4
- data/tracks/python/exercises/zebra-puzzle/README.md +15 -0
- data/tracks/python/exercises/zipper/README.md +16 -3
- data/tracks/rust/config.json +11 -0
- data/tracks/rust/exercises/saddle-points/.gitignore +8 -0
- data/tracks/rust/exercises/saddle-points/Cargo.toml +5 -0
- data/tracks/rust/exercises/saddle-points/README.md +66 -0
- data/tracks/rust/exercises/saddle-points/example.rs +24 -0
- data/tracks/rust/exercises/saddle-points/src/lib.rs +3 -0
- data/tracks/rust/exercises/saddle-points/tests/saddle-points.rs +60 -0
- metadata +38 -5
data/tracks/clojure/config.json
CHANGED
@@ -33,6 +33,14 @@
|
|
33
33
|
"unlocked_by": null,
|
34
34
|
"uuid": "04a6c1d6-6cce-4c87-a34b-23fdd9baf70d"
|
35
35
|
},
|
36
|
+
{
|
37
|
+
"core": false,
|
38
|
+
"difficulty": 1,
|
39
|
+
"slug": "isbn-verifier",
|
40
|
+
"topics": null,
|
41
|
+
"unlocked_by": null,
|
42
|
+
"uuid": "e6411d18-d9b9-48fa-8ee6-0df8c13d3dee"
|
43
|
+
},
|
36
44
|
{
|
37
45
|
"core": false,
|
38
46
|
"difficulty": 1,
|
@@ -541,8 +549,16 @@
|
|
541
549
|
"pattern matching"
|
542
550
|
],
|
543
551
|
"uuid": "c4b7120c-a7c5-4a39-a08e-8d4fb9861a27"
|
552
|
+
},
|
553
|
+
{
|
554
|
+
"core": false,
|
555
|
+
"difficulty": 1,
|
556
|
+
"slug": "proverb",
|
557
|
+
"topics": null,
|
558
|
+
"unlocked_by": null,
|
559
|
+
"uuid": "c8ba6ce5-9a7e-4c1c-8044-bb18a0d6ad39"
|
544
560
|
}
|
545
561
|
],
|
546
562
|
"foregone": [],
|
547
563
|
"language": "Clojure"
|
548
|
-
}
|
564
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Check if a given ISBN-10 is valid.
|
2
|
+
|
3
|
+
## Functionality
|
4
|
+
|
5
|
+
Given an unknown string the program should check if the provided string is a valid ISBN-10.
|
6
|
+
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
7
|
+
|
8
|
+
The program should allow for ISBN-10 without the separating dashes to be verified as well.
|
9
|
+
|
10
|
+
## ISBN
|
11
|
+
|
12
|
+
Let's take a random ISBN-10 number, say `3-598-21508-8` for this.
|
13
|
+
The first digit block indicates the group where the ISBN belongs. Groups can consist of shared languages, geographic regions or countries. The leading '3' signals this ISBN is from a german speaking country.
|
14
|
+
The following number block is to identify the publisher. Since this is a three digit publisher number there is a 5 digit title number for this book.
|
15
|
+
The last digit in the ISBN is the check digit which is used to detect read errors.
|
16
|
+
|
17
|
+
The first 9 digits in the ISBN have to be between 0 and 9.
|
18
|
+
The check digit can additionally be an 'X' to allow 10 to be a valid check digit as well.
|
19
|
+
|
20
|
+
A valid ISBN-10 is calculated with this formula `(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0`
|
21
|
+
So for our example ISBN this means:
|
22
|
+
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 = 0
|
23
|
+
|
24
|
+
Which proves that the ISBN is valid.
|
25
|
+
|
26
|
+
## Caveats
|
27
|
+
|
28
|
+
Converting from string to number can be tricky in certain languages.
|
29
|
+
It's getting even trickier since the check-digit of an ISBN-10 can be 'X'.
|
30
|
+
|
31
|
+
## Bonus tasks
|
32
|
+
|
33
|
+
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier)
|
34
|
+
|
35
|
+
* Generate valid ISBN, maybe even from a given starting ISBN
|
36
|
+
|
37
|
+
## Source
|
38
|
+
|
39
|
+
Converting a string into a number and some basic processing utilizing a relatable real world example.
|
40
|
+
[https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation](https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation)
|
41
|
+
|
42
|
+
## Submitting Incomplete Solutions
|
43
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
(ns isbn-verifier)
|
2
|
+
|
3
|
+
(defn is-in? [xs x] (some #(= x %) xs))
|
4
|
+
|
5
|
+
(defn isbn-chars [isbn]
|
6
|
+
(filter #(is-in? [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \X] %) isbn))
|
7
|
+
|
8
|
+
(defn isbn? [isbn]
|
9
|
+
(let [chars (isbn-chars isbn)
|
10
|
+
nums (map #(if (= \X %) 10 (Character/digit % 10)) chars)]
|
11
|
+
(and (-> chars butlast (is-in? \X) not)
|
12
|
+
(= 10 (count chars))
|
13
|
+
(as-> nums x
|
14
|
+
(map #(* %1 %2) (range 10 0 -1) x)
|
15
|
+
(reduce + x)
|
16
|
+
(mod x 11)
|
17
|
+
(zero? x)))))
|
@@ -0,0 +1,42 @@
|
|
1
|
+
(ns isbn-verifier-test
|
2
|
+
(:require [clojure.test :refer [deftest is]]
|
3
|
+
[isbn-verifier :refer [isbn?]]))
|
4
|
+
|
5
|
+
(deftest valid-isbn-number
|
6
|
+
(is (= true (isbn? "3-598-21508-8"))))
|
7
|
+
|
8
|
+
(deftest invalid-isbn-check-digit
|
9
|
+
(is (= false (isbn? "3-598-21508-9"))))
|
10
|
+
|
11
|
+
(deftest valid-isbn-number-with-a-check-digit-of-10
|
12
|
+
(is (= true (isbn? "3-598-21507-X"))))
|
13
|
+
|
14
|
+
(deftest check-digit-is-a-character-other-than-X
|
15
|
+
(is (= false (isbn? "3-598-21507-A"))))
|
16
|
+
|
17
|
+
(deftest invalid-character-in-isbn
|
18
|
+
(is (= false (isbn? "3-598-2K507-0"))))
|
19
|
+
|
20
|
+
(deftest X-is-only-valid-as-a-check-digit
|
21
|
+
(is (= false (isbn? "3-598-2X507-9"))))
|
22
|
+
|
23
|
+
(deftest valid-isbn-without-separating-dashes
|
24
|
+
(is (= true (isbn? "3598215088"))))
|
25
|
+
|
26
|
+
(deftest isbn-without-separating-dashes-and-X-as-check-digit
|
27
|
+
(is (= true (isbn? "359821507X"))))
|
28
|
+
|
29
|
+
(deftest isbn-without-check-digit-and-dashes
|
30
|
+
(is (= false (isbn? "359821507"))))
|
31
|
+
|
32
|
+
(deftest too-long-isbn-and-no-dashes
|
33
|
+
(is (= false (isbn? "3598215078X"))))
|
34
|
+
|
35
|
+
(deftest isbn-without-check-digit
|
36
|
+
(is (= false (isbn? "3-598-21507"))))
|
37
|
+
|
38
|
+
(deftest too-long-isbn
|
39
|
+
(is (= false (isbn? "3-598-21507-XX"))))
|
40
|
+
|
41
|
+
(deftest check-digit-of-X-should-not-be-used-for-0
|
42
|
+
(is (= false (isbn? "3-598-21515-X"))))
|
@@ -0,0 +1,15 @@
|
|
1
|
+
For want of a horseshoe nail, a kingdom was lost, or so the saying goes.
|
2
|
+
|
3
|
+
Given a list of inputs, generate the relevant proverb. For example, given the list `["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]`, you will output the full text of this proverbial rhyme:
|
4
|
+
|
5
|
+
```text
|
6
|
+
For want of a nail the shoe was lost.
|
7
|
+
For want of a shoe the horse was lost.
|
8
|
+
For want of a horse the rider was lost.
|
9
|
+
For want of a rider the message was lost.
|
10
|
+
For want of a message the battle was lost.
|
11
|
+
For want of a battle the kingdom was lost.
|
12
|
+
And all for the want of a nail.
|
13
|
+
```
|
14
|
+
|
15
|
+
Note that the list of inputs may vary; your solution should be able to handle lists of arbitrary length and content. No line of the output text should be a static, unchanging string; all should vary according to the input given.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
(ns proverb
|
2
|
+
(:require [clojure.string :as str]))
|
3
|
+
|
4
|
+
(def subjects ["nail" "shoe" "horse" "rider" "message" "battle" "kingdom"])
|
5
|
+
|
6
|
+
(def last-line "And all for the want of a horseshoe nail.")
|
7
|
+
|
8
|
+
(defn- line [[cause-subject effect-subject]]
|
9
|
+
(format "For want of a %s the %s was lost." cause-subject effect-subject))
|
10
|
+
|
11
|
+
(def proverb (->> subjects
|
12
|
+
(partition 2 1)
|
13
|
+
(map line)
|
14
|
+
(#(conj (vec %) last-line))
|
15
|
+
(str/join "\n")))
|
@@ -0,0 +1,14 @@
|
|
1
|
+
(ns proverb-test
|
2
|
+
(:require [clojure.test :refer [deftest is]]
|
3
|
+
[proverb :refer [proverb]]
|
4
|
+
[clojure.string :as str]))
|
5
|
+
|
6
|
+
(deftest full-text-is-correct
|
7
|
+
(is (= proverb
|
8
|
+
(str/join "\n" ["For want of a nail the shoe was lost."
|
9
|
+
"For want of a shoe the horse was lost."
|
10
|
+
"For want of a horse the rider was lost."
|
11
|
+
"For want of a rider the message was lost."
|
12
|
+
"For want of a message the battle was lost."
|
13
|
+
"For want of a battle the kingdom was lost."
|
14
|
+
"And all for the want of a horseshoe nail."]))))
|
@@ -2,6 +2,7 @@ Exercism provides exercises and feedback but can be difficult to jump
|
|
2
2
|
into for those learning Common Lisp for the first time. These
|
3
3
|
resources can help you get started:
|
4
4
|
|
5
|
+
* [Practical Common Lisp](http://www.gigamonkeys.com/book/), a complete book for learning Common Lisp, available free online (as well as in print)
|
5
6
|
* [Cliki.net Getting Start Started Page](http://cliki.net/Getting%20Started),
|
6
7
|
by various contributors
|
7
8
|
* [Wikibooks book of Common Lisp, First steps](http://en.wikibooks.org/wiki/Common_Lisp/First_steps),
|
@@ -10,6 +11,6 @@ resources can help you get started:
|
|
10
11
|
Paul Nathan
|
11
12
|
* [Northwestern University EECS 325 Readings](http://www.cs.northwestern.edu/academics/courses/325/readings/readings.php),
|
12
13
|
by Chris Riesbeck
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
See also, within this Exercism Common Lisp track: [Important Resources](http://exercism.io/languages/common-lisp/resources)
|
16
|
+
|
@@ -37,3 +37,14 @@ be afraid of them, they're quite accessible and "classics".
|
|
37
37
|
The last is actually on a related Lisp dialect, Scheme, but it's very
|
38
38
|
helpful book, generally. If you find you prefer Scheme, it's an
|
39
39
|
excellent start.
|
40
|
+
|
41
|
+
|
42
|
+
### Quick reference
|
43
|
+
|
44
|
+
Quick-guides / cheat sheets for Common Lisp:
|
45
|
+
|
46
|
+
* [The Common Lisp Cookbook](http://lispcookbook.github.io/cl-cookbook/)
|
47
|
+
by various contributors, includes quick help on often used commands or features.
|
48
|
+
([legacy SF site](http://cl-cookbook.sourceforge.net/))
|
49
|
+
* [Common Lisp Quick Reference](http://clqr.boundp.org/) is a print-it-yourself booklet for having a quick reference handy.
|
50
|
+
* [Simplified Common Lisp Reference](http://jtra.cz/stuff/lisp/sclr/index.html) gives a quick glance at often used commands, ideal for newcomers.
|
data/tracks/delphi/.gitignore
CHANGED
data/tracks/delphi/config.json
CHANGED
@@ -52,6 +52,19 @@
|
|
52
52
|
],
|
53
53
|
"uuid": "9e54a998-450c-4020-834e-eaa77f909744"
|
54
54
|
},
|
55
|
+
{
|
56
|
+
"core": false,
|
57
|
+
"difficulty": 4,
|
58
|
+
"slug": "isbn-verifier",
|
59
|
+
"topics": [
|
60
|
+
"conditionals",
|
61
|
+
"loops",
|
62
|
+
"pattern_matching",
|
63
|
+
"strings"
|
64
|
+
],
|
65
|
+
"unlocked_by": "bob",
|
66
|
+
"uuid": "4cdb8216-4526-49ac-8ab5-68d70060a54e"
|
67
|
+
},
|
55
68
|
{
|
56
69
|
"core": false,
|
57
70
|
"difficulty": 1,
|
@@ -172,6 +185,17 @@
|
|
172
185
|
"unlocked_by": "collatz-conjecture",
|
173
186
|
"uuid": "cba5cf99-8001-4113-af80-cf9c041f1b21"
|
174
187
|
},
|
188
|
+
{
|
189
|
+
"core": false,
|
190
|
+
"difficulty": 3,
|
191
|
+
"slug": "secret-handshake",
|
192
|
+
"topics": [
|
193
|
+
"arrays",
|
194
|
+
"bitwise_operations"
|
195
|
+
],
|
196
|
+
"unlocked_by": "collatz-conjecture",
|
197
|
+
"uuid": "2032ba03-845a-460b-ad93-0958e97eb7cc"
|
198
|
+
},
|
175
199
|
{
|
176
200
|
"core": false,
|
177
201
|
"difficulty": 3,
|
@@ -17,7 +17,7 @@ With Delphi successfully installed, and working correctly, please follow these s
|
|
17
17
|
- Step-by-step instructions on how to install DUnitX into Delphi have been posted by Vincent Parrett in a blog post located [here](https://www.finalbuilder.com/resources/blogs/postid/702/dunitx-has-a-wizard).
|
18
18
|
- The Starter Edition of Delphi doesn't allow the use of project experts. DUnitX comes with an expert which will aid the student in creating a new DUnitX based project. The expert creates the project's .DPR file. The exercises in this track all include the .DPR file making the expert not necessary. DUnitX otherwise has no issues with projects created in Delphi versions starting with XE all the way up to and including the Starter Edition of Berlin.
|
19
19
|
|
20
|
-
### Delphi Configuration for
|
20
|
+
### Delphi Configuration for DUnitX ###
|
21
21
|
|
22
22
|
If you had to install DUnitX because your installation didn't already come with it then please follow the following illustrated steps to make the necessary configuration changes to Delphi in order for it to locate your installation of DUnitX.
|
23
23
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
program ISBNVerifier;
|
2
|
+
|
3
|
+
{$IFNDEF TESTINSIGHT}
|
4
|
+
{$APPTYPE CONSOLE}
|
5
|
+
{$ENDIF}{$STRONGLINKTYPES ON}
|
6
|
+
uses
|
7
|
+
System.SysUtils,
|
8
|
+
{$IFDEF TESTINSIGHT}
|
9
|
+
TestInsight.DUnitX,
|
10
|
+
{$ENDIF }
|
11
|
+
DUnitX.Loggers.Console,
|
12
|
+
DUnitX.Loggers.Xml.NUnit,
|
13
|
+
DUnitX.TestFramework,
|
14
|
+
uTestISBNVerifier in 'uTestISBNVerifier.pas',
|
15
|
+
uISBNVerifier in 'uISBNVerifier.pas';
|
16
|
+
|
17
|
+
var
|
18
|
+
runner : ITestRunner;
|
19
|
+
results : IRunResults;
|
20
|
+
logger : ITestLogger;
|
21
|
+
nunitLogger : ITestLogger;
|
22
|
+
begin
|
23
|
+
{$IFDEF TESTINSIGHT}
|
24
|
+
TestInsight.DUnitX.RunRegisteredTests;
|
25
|
+
exit;
|
26
|
+
{$ENDIF}
|
27
|
+
try
|
28
|
+
//Check command line options, will exit if invalid
|
29
|
+
TDUnitX.CheckCommandLine;
|
30
|
+
//Create the test runner
|
31
|
+
runner := TDUnitX.CreateRunner;
|
32
|
+
//Tell the runner to use RTTI to find Fixtures
|
33
|
+
runner.UseRTTI := True;
|
34
|
+
//tell the runner how we will log things
|
35
|
+
//Log to the console window
|
36
|
+
logger := TDUnitXConsoleLogger.Create(true);
|
37
|
+
runner.AddLogger(logger);
|
38
|
+
//Generate an NUnit compatible XML File
|
39
|
+
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
|
40
|
+
runner.AddLogger(nunitLogger);
|
41
|
+
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
|
42
|
+
|
43
|
+
//Run tests
|
44
|
+
results := runner.Execute;
|
45
|
+
if not results.AllPassed then
|
46
|
+
System.ExitCode := EXIT_ERRORS;
|
47
|
+
|
48
|
+
{$IFNDEF CI}
|
49
|
+
//We don't want this happening when running under CI.
|
50
|
+
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
|
51
|
+
begin
|
52
|
+
System.Write('Done.. press <Enter> key to quit.');
|
53
|
+
System.Readln;
|
54
|
+
end;
|
55
|
+
{$ENDIF}
|
56
|
+
except
|
57
|
+
on E: Exception do
|
58
|
+
System.Writeln(E.ClassName, ': ', E.Message);
|
59
|
+
end;
|
60
|
+
end.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Isbn Verifier
|
2
|
+
|
3
|
+
The [ISBN-10 verification process](https://en.wikipedia.org/wiki/International_Standard_Book_Number) is used to validate book identification
|
4
|
+
numbers. These normally contain dashes and look like: `3-598-21508-8`
|
5
|
+
|
6
|
+
## ISBN
|
7
|
+
|
8
|
+
The ISBN-10 format is 9 digits (0 to 9) plus one check character (either a digit or an X only). In the case the check character is an X, this represents the value '10'. These may be communicated with or without hyphens, and can be checked for their validity by the following formula:
|
9
|
+
|
10
|
+
```
|
11
|
+
(x1 * 10 + x2 * 9 + x3 * 8 + x4 * 7 + x5 * 6 + x6 * 5 + x7 * 4 + x8 * 3 + x9 * 2 + x10 * 1) mod 11 == 0
|
12
|
+
```
|
13
|
+
|
14
|
+
If the result is 0, then it is a valid ISBN-10, otherwise it is invalid.
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
Let's take the ISBN-10 `3-598-21508-8`. We plug it in to the formula, and get:
|
19
|
+
```
|
20
|
+
(3 * 10 + 5 * 9 + 9 * 8 + 8 * 7 + 2 * 6 + 1 * 5 + 5 * 4 + 0 * 3 + 8 * 2 + 8 * 1) mod 11 == 0
|
21
|
+
```
|
22
|
+
|
23
|
+
Since the result is 0, this proves that our ISBN is valid.
|
24
|
+
|
25
|
+
## Task
|
26
|
+
|
27
|
+
Given a string the program should check if the provided string is a valid ISBN-10.
|
28
|
+
Putting this into place requires some thinking about preprocessing/parsing of the string prior to calculating the check digit for the ISBN.
|
29
|
+
|
30
|
+
The program should be able to verify ISBN-10 both with and without separating dashes.
|
31
|
+
|
32
|
+
|
33
|
+
## Caveats
|
34
|
+
|
35
|
+
Converting from strings to numbers can be tricky in certain languages.
|
36
|
+
Now, it's even trickier since the check digit of an ISBN-10 may be 'X' (representing '10'). For instance `3-598-21507-X` is a valid ISBN-10.
|
37
|
+
|
38
|
+
## Bonus tasks
|
39
|
+
|
40
|
+
* Generate a valid ISBN-13 from the input ISBN-10 (and maybe verify it again with a derived verifier).
|
41
|
+
|
42
|
+
* Generate valid ISBN, maybe even from a given starting ISBN.
|
43
|
+
## Testing
|
44
|
+
|
45
|
+
In order to run the tests for this track, you will need to install
|
46
|
+
DUnitX. Please see the [installation](http://www.exercism.io/languages/delphi/installation) instructions for more information.
|
47
|
+
|
48
|
+
### Loading Exercises into Delphi
|
49
|
+
|
50
|
+
If Delphi is properly installed, and `*.dpr` file types have been associated with Delphi, then double clicking the supplied `*.dpr` file will start Delphi and load the exercise/project. `control + F9` is the keyboard shortcut to compile the project or pressing `F9` will compile and run the project.
|
51
|
+
|
52
|
+
Alternatively you may opt to start Delphi and load your project via. the `File` drop down menu.
|
53
|
+
|
54
|
+
### When Questions Come Up
|
55
|
+
We monitor the [Pascal-Delphi](https://gitter.im/exercism/Pascal-Delphi) support room on [gitter.im](https://gitter.im) to help you with any questions that might arise.
|
56
|
+
|
57
|
+
### Submitting Exercises
|
58
|
+
|
59
|
+
Note that, when trying to submit an exercise, make sure the exercise file you're submitting is in the `exercism/delphi/<exerciseName>` directory.
|
60
|
+
|
61
|
+
For example, if you're submitting `ubob.pas` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/delphi/bob/ubob.pas`.
|
62
|
+
|
63
|
+
## Source
|
64
|
+
|
65
|
+
Converting a string into a number and some basic processing utilizing a relatable real world example. [https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation](https://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digit_calculation)
|
66
|
+
|
67
|
+
## Submitting Incomplete Solutions
|
68
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
unit uISBNVerifier;
|
2
|
+
|
3
|
+
interface
|
4
|
+
|
5
|
+
type
|
6
|
+
TIsbn = class
|
7
|
+
public
|
8
|
+
class function isValid(aInput: string): Boolean;
|
9
|
+
end;
|
10
|
+
|
11
|
+
implementation
|
12
|
+
uses sysutils, RegularExpressions;
|
13
|
+
|
14
|
+
{ TIsbn }
|
15
|
+
|
16
|
+
class function TIsbn.isValid(aInput: string): Boolean;
|
17
|
+
var
|
18
|
+
wrkStr: string;
|
19
|
+
sum,
|
20
|
+
weight,
|
21
|
+
digit,
|
22
|
+
i: integer;
|
23
|
+
begin
|
24
|
+
result := false;
|
25
|
+
wrkStr := aInput.replace('-','');
|
26
|
+
|
27
|
+
if TRegex.IsMatch(wrkStr, '^(\d{9}[\dX])$') then
|
28
|
+
begin
|
29
|
+
sum := 0;
|
30
|
+
weight := 10;
|
31
|
+
digit := 0;
|
32
|
+
for i := low(wrkStr) to high(wrkStr) do
|
33
|
+
begin
|
34
|
+
if (wrkStr[i] = 'X') and (i = 10) then
|
35
|
+
digit := 10
|
36
|
+
else
|
37
|
+
digit := string.ToInteger(wrkStr[i]);
|
38
|
+
sum := sum + (digit * weight);
|
39
|
+
dec(weight);
|
40
|
+
end;
|
41
|
+
result := sum mod 11 = 0;
|
42
|
+
end;
|
43
|
+
|
44
|
+
end;
|
45
|
+
|
46
|
+
end.
|