trackler 2.2.1.51 → 2.2.1.52
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.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/saddle-points/description.md +1 -1
- data/tracks/cfml/.gitattributes +19 -0
- data/tracks/cfml/config.json +180 -186
- data/tracks/cfml/tasks/FormatConfig.cfc +26 -0
- data/tracks/cfml/tasks/ScaffoldExercise.cfc +1 -1
- data/tracks/common-lisp/config.json +26 -9
- data/tracks/common-lisp/exercises/acronym/README.md +61 -0
- data/tracks/common-lisp/exercises/acronym/acronym-test.lisp +48 -0
- data/tracks/common-lisp/exercises/acronym/acronym.lisp +6 -0
- data/tracks/common-lisp/exercises/acronym/example.lisp +24 -0
- data/tracks/common-lisp/exercises/isogram/README.md +65 -0
- data/tracks/common-lisp/exercises/isogram/example.lisp +18 -0
- data/tracks/common-lisp/exercises/isogram/isogram-test.lisp +39 -0
- data/tracks/common-lisp/exercises/isogram/isogram.lisp +8 -0
- data/tracks/delphi/exercises/etl/README.md +1 -1
- data/tracks/delphi/exercises/rna-transcription/README.md +1 -1
- data/tracks/delphi/exercises/saddle-points/README.md +1 -1
- data/tracks/fsharp/exercises/all-your-base/AllYourBaseTest.fs +21 -21
- data/tracks/fsharp/exercises/kindergarten-garden/Example.fs +13 -14
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGarden.fs +1 -3
- data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +9 -41
- data/tracks/fsharp/exercises/phone-number/PhoneNumberTest.fs +12 -12
- data/tracks/fsharp/exercises/rna-transcription/RnaTranscriptionTest.fs +8 -8
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulator.fs +3 -0
- data/tracks/fsharp/exercises/robot-simulator/RobotSimulatorTest.fs +129 -26
- data/tracks/fsharp/generators/Common.fs +10 -0
- data/tracks/fsharp/generators/Exercise.fs +5 -1
- data/tracks/fsharp/generators/Generators.fs +122 -33
- data/tracks/fsharp/generators/Output.fs +6 -1
- data/tracks/haskell/exercises/crypto-square/README.md +6 -4
- data/tracks/haskell/exercises/kindergarten-garden/README.md +10 -10
- data/tracks/haskell/exercises/saddle-points/README.md +1 -1
- data/tracks/haskell/exercises/space-age/README.md +1 -1
- data/tracks/java/config.json +8 -2
- data/tracks/java/exercises/queen-attack/.meta/src/reference/java/BoardCoordinate.java +12 -12
- data/tracks/java/exercises/queen-attack/.meta/src/reference/java/QueenAttackCalculator.java +14 -14
- data/tracks/java/exercises/queen-attack/.meta/version +1 -1
- data/tracks/java/exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java +11 -11
- data/tracks/javascript/exercises/prime-factors/example.js +10 -9
- data/tracks/julia/config.json +12 -0
- data/tracks/julia/exercises/run-length-encoding/README.md +31 -0
- data/tracks/julia/exercises/run-length-encoding/example.jl +22 -0
- data/tracks/julia/exercises/run-length-encoding/run-length-encoding.jl +7 -0
- data/tracks/julia/exercises/run-length-encoding/runtests.jl +29 -0
- data/tracks/objective-c/README.md +79 -1
- data/tracks/ocaml/config.json +430 -433
- data/tracks/ocaml/config/maintainers.json +11 -11
- data/tracks/php/config.json +16 -0
- data/tracks/php/exercises/all-your-base/README.md +31 -0
- data/tracks/php/exercises/all-your-base/all-your-base_test.php +135 -0
- data/tracks/php/exercises/all-your-base/example.php +27 -0
- data/tracks/php/exercises/series/README.md +21 -0
- data/tracks/php/exercises/series/example.php +15 -0
- data/tracks/php/exercises/series/series_test.php +64 -0
- data/tracks/python/README.md +1 -1
- data/tracks/python/config.json +4 -1
- data/tracks/python/exercises/forth/forth.py +4 -0
- data/tracks/python/exercises/forth/forth_test.py +1 -1
- data/tracks/python/exercises/markdown/example.py +1 -1
- data/tracks/python/exercises/markdown/markdown_test.py +3 -3
- data/tracks/ruby/exercises/two-bucket/.meta/.version +1 -1
- data/tracks/ruby/exercises/two-bucket/.meta/solutions/two_bucket.rb +23 -3
- data/tracks/ruby/exercises/two-bucket/two_bucket_test.rb +4 -4
- metadata +22 -2
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"active": true,
|
|
3
3
|
"exercises": [
|
|
4
|
+
{
|
|
5
|
+
"core": false,
|
|
6
|
+
"difficulty": 1,
|
|
7
|
+
"slug": "acronym",
|
|
8
|
+
"topics": [
|
|
9
|
+
"strings",
|
|
10
|
+
"transforming"
|
|
11
|
+
],
|
|
12
|
+
"unlocked_by": null,
|
|
13
|
+
"uuid": "6efa02be-0f9e-1d80-7efb-536d383535c98b1d883"
|
|
14
|
+
},
|
|
4
15
|
{
|
|
5
16
|
"core": true,
|
|
6
17
|
"difficulty": 1,
|
|
@@ -26,20 +37,16 @@
|
|
|
26
37
|
"uuid": "c029678b-9b9f-4fb2-958f-3a118efa16a9"
|
|
27
38
|
},
|
|
28
39
|
{
|
|
29
|
-
"uuid": "428e5b28-31b6-4c84-8eae-d7753d45efc1",
|
|
30
|
-
"slug": "sublist",
|
|
31
40
|
"core": false,
|
|
32
|
-
"unlocked_by": null,
|
|
33
41
|
"difficulty": 1,
|
|
42
|
+
"slug": "sublist",
|
|
34
43
|
"topics": [
|
|
35
|
-
"
|
|
36
|
-
]
|
|
44
|
+
"lists"
|
|
45
|
+
],
|
|
46
|
+
"unlocked_by": null,
|
|
47
|
+
"uuid": "428e5b28-31b6-4c84-8eae-d7753d45efc1"
|
|
37
48
|
},
|
|
38
49
|
{
|
|
39
|
-
"uuid": "eb3a92bf-0748-4406-ba67-9e27e367ae45",
|
|
40
|
-
"slug": "grains",
|
|
41
|
-
"core": false,
|
|
42
|
-
"unlocked_by": null,
|
|
43
50
|
"core": true,
|
|
44
51
|
"difficulty": 1,
|
|
45
52
|
"slug": "leap",
|
|
@@ -249,6 +256,16 @@
|
|
|
249
256
|
"unlocked_by": null,
|
|
250
257
|
"uuid": "b3ad38c2-2962-4b47-9b15-15ca262ebff6"
|
|
251
258
|
},
|
|
259
|
+
{
|
|
260
|
+
"core": false,
|
|
261
|
+
"difficulty": 1,
|
|
262
|
+
"slug": "isogram",
|
|
263
|
+
"topics": [
|
|
264
|
+
"strings"
|
|
265
|
+
],
|
|
266
|
+
"unlocked_by": null,
|
|
267
|
+
"uuid": "89ea51d0-3f7e-4e07-8e2b-4dde4c76608b"
|
|
268
|
+
},
|
|
252
269
|
{
|
|
253
270
|
"core": false,
|
|
254
271
|
"difficulty": 1,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Acronym
|
|
2
|
+
|
|
3
|
+
Convert a phrase to its acronym.
|
|
4
|
+
|
|
5
|
+
Techies love their TLA (Three Letter Acronyms)!
|
|
6
|
+
|
|
7
|
+
Help generate some jargon by writing a program that converts a long name
|
|
8
|
+
like Portable Network Graphics to its acronym (PNG).
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
Check out [Exercism Help](http://exercism.io/languages/lisp) for instructions to
|
|
13
|
+
get started writing Common Lisp. That page will explain how to install and setup
|
|
14
|
+
a Lisp implementation and how to run the tests.
|
|
15
|
+
|
|
16
|
+
## Formatting
|
|
17
|
+
|
|
18
|
+
While Common Lisp doesn't care about indentation and layout of code,
|
|
19
|
+
nor whether you use spaces or tabs, this is an important consideration
|
|
20
|
+
for submissions to exercism.io. Excercism.io's code widget cannot
|
|
21
|
+
handle mixing of tab and space characters well so using only spaces is recommended to make
|
|
22
|
+
the code more readable to the human reviewers. Please review your
|
|
23
|
+
editors settings on how to accomplish this. Below are instructions for
|
|
24
|
+
popular editors for Common Lisp.
|
|
25
|
+
|
|
26
|
+
### VIM
|
|
27
|
+
|
|
28
|
+
Use the following commands to ensure VIM uses only spaces for
|
|
29
|
+
indentation:
|
|
30
|
+
|
|
31
|
+
```vimscript
|
|
32
|
+
:set tabstop=2
|
|
33
|
+
:set shiftwidth=2
|
|
34
|
+
:set expandtab
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
(or as a oneliner `:set tabstop=2 shiftwidth=2 expandtab`). This can
|
|
38
|
+
be added to your `~/.vimrc` file to use it all the time.
|
|
39
|
+
|
|
40
|
+
### Emacs
|
|
41
|
+
|
|
42
|
+
Emacs is very well suited for editing Common Lisp and has many
|
|
43
|
+
powerful add-on packages available. The only thing that one needs to
|
|
44
|
+
do with a stock emacs to make it work well with exercism.io is to
|
|
45
|
+
evaluate the following code:
|
|
46
|
+
|
|
47
|
+
`(setq indent-tab-mode nil)`
|
|
48
|
+
|
|
49
|
+
This can be placed in your `~/.emacs` (or `~/.emacs.d/init.el`) in
|
|
50
|
+
order to have it set whenever Emacs is launched.
|
|
51
|
+
|
|
52
|
+
One suggested add-on for Emacs and Common Lisp is
|
|
53
|
+
[SLIME](https://github.com/slime/slime) which offers tight integration
|
|
54
|
+
with the REPL; making iterative coding and testing very easy.
|
|
55
|
+
|
|
56
|
+
## Source
|
|
57
|
+
|
|
58
|
+
Julien Vanier [https://github.com/monkbroc](https://github.com/monkbroc)
|
|
59
|
+
|
|
60
|
+
## Submitting Incomplete Solutions
|
|
61
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
(ql:quickload "lisp-unit")
|
|
2
|
+
#-xlisp-test (load "acronym")
|
|
3
|
+
|
|
4
|
+
(defpackage #:acronym-test
|
|
5
|
+
(:use #:common-lisp #:lisp-unit))
|
|
6
|
+
|
|
7
|
+
(in-package #:acronym-test)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
(define-test empty-gives-empty
|
|
11
|
+
(assert-equal
|
|
12
|
+
""
|
|
13
|
+
(acronym:acronym "")))
|
|
14
|
+
|
|
15
|
+
(define-test png-test
|
|
16
|
+
(assert-equal
|
|
17
|
+
"PNG"
|
|
18
|
+
(acronym:acronym "Portable Network Graphics")))
|
|
19
|
+
|
|
20
|
+
(define-test ror-test
|
|
21
|
+
(assert-equal
|
|
22
|
+
"ROR"
|
|
23
|
+
(acronym:acronym "Ruby on Rails")))
|
|
24
|
+
|
|
25
|
+
(define-test html-test
|
|
26
|
+
(assert-equal
|
|
27
|
+
"HTML"
|
|
28
|
+
(acronym:acronym "HyperText Markup Language")))
|
|
29
|
+
|
|
30
|
+
(define-test fifo-test
|
|
31
|
+
(assert-equal
|
|
32
|
+
"FIFO"
|
|
33
|
+
(acronym:acronym "First In, First Out")))
|
|
34
|
+
|
|
35
|
+
(define-test php-test
|
|
36
|
+
(assert-equal
|
|
37
|
+
"PHP"
|
|
38
|
+
(acronym:acronym "PHP: Hypertext Preprocessor")))
|
|
39
|
+
|
|
40
|
+
(define-test cmos-test
|
|
41
|
+
(assert-equal
|
|
42
|
+
"CMOS"
|
|
43
|
+
(acronym:acronym "Complementary metal-oxide semiconductor")))
|
|
44
|
+
|
|
45
|
+
#-xlisp-test
|
|
46
|
+
(let ((*print-errors* t)
|
|
47
|
+
(*print-failures* t))
|
|
48
|
+
(run-tests :all :acronym-test))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(in-package #:cl-user)
|
|
2
|
+
(defpackage #:acronym
|
|
3
|
+
(:use #:cl)
|
|
4
|
+
(:export #:acronym))
|
|
5
|
+
|
|
6
|
+
(in-package #:acronym)
|
|
7
|
+
|
|
8
|
+
(defun acronym (str)
|
|
9
|
+
(labels ((recur (st ls)
|
|
10
|
+
(cond
|
|
11
|
+
((equal "" st)
|
|
12
|
+
ls)
|
|
13
|
+
((both-case-p (elt st 0))
|
|
14
|
+
(recur (string-left-trim
|
|
15
|
+
"abcdefghijklmnopqrstuvwxyz"
|
|
16
|
+
(string-left-trim
|
|
17
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
18
|
+
st))
|
|
19
|
+
(cons (elt st 0)
|
|
20
|
+
ls)))
|
|
21
|
+
(t (recur (subseq st 1) ls)))))
|
|
22
|
+
(map 'string
|
|
23
|
+
#'char-upcase
|
|
24
|
+
(nreverse (recur str nil)))))
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Determine if a word or phrase is an isogram.
|
|
2
|
+
|
|
3
|
+
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.
|
|
4
|
+
|
|
5
|
+
Examples of isograms:
|
|
6
|
+
|
|
7
|
+
- lumberjacks
|
|
8
|
+
- background
|
|
9
|
+
- downstream
|
|
10
|
+
- six-year-old
|
|
11
|
+
|
|
12
|
+
The word *isograms*, however, is not an isogram, because the s repeats.
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Check out [Exercism Help](http://exercism.io/languages/lisp) for instructions to
|
|
17
|
+
get started writing Common Lisp. That page will explain how to install and setup
|
|
18
|
+
a Lisp implementation and how to run the tests.
|
|
19
|
+
|
|
20
|
+
## Formatting
|
|
21
|
+
|
|
22
|
+
While Common Lisp doesn't care about indentation and layout of code,
|
|
23
|
+
nor whether you use spaces or tabs, this is an important consideration
|
|
24
|
+
for submissions to exercism.io. Excercism.io's code widget cannot
|
|
25
|
+
handle mixing of tab and space characters well so using only spaces is recommended to make
|
|
26
|
+
the code more readable to the human reviewers. Please review your
|
|
27
|
+
editors settings on how to accomplish this. Below are instructions for
|
|
28
|
+
popular editors for Common Lisp.
|
|
29
|
+
|
|
30
|
+
### VIM
|
|
31
|
+
|
|
32
|
+
Use the following commands to ensure VIM uses only spaces for
|
|
33
|
+
indentation:
|
|
34
|
+
|
|
35
|
+
```vimscript
|
|
36
|
+
:set tabstop=2
|
|
37
|
+
:set shiftwidth=2
|
|
38
|
+
:set expandtab
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
(or as a oneliner `:set tabstop=2 shiftwidth=2 expandtab`). This can
|
|
42
|
+
be added to your `~/.vimrc` file to use it all the time.
|
|
43
|
+
|
|
44
|
+
### Emacs
|
|
45
|
+
|
|
46
|
+
Emacs is very well suited for editing Common Lisp and has many
|
|
47
|
+
powerful add-on packages available. The only thing that one needs to
|
|
48
|
+
do with a stock emacs to make it work well with exercism.io is to
|
|
49
|
+
evaluate the following code:
|
|
50
|
+
|
|
51
|
+
`(setq indent-tab-mode nil)`
|
|
52
|
+
|
|
53
|
+
This can be placed in your `~/.emacs` (or `~/.emacs.d/init.el`) in
|
|
54
|
+
order to have it set whenever Emacs is launched.
|
|
55
|
+
|
|
56
|
+
One suggested add-on for Emacs and Common Lisp is
|
|
57
|
+
[SLIME](https://github.com/slime/slime) which offers tight integration
|
|
58
|
+
with the REPL; making iterative coding and testing very easy.
|
|
59
|
+
|
|
60
|
+
## Source
|
|
61
|
+
|
|
62
|
+
Learn more about Isograms at [wikipedia](https://en.wikipedia.org/wiki/Isogram")
|
|
63
|
+
|
|
64
|
+
## Submitting Incomplete Solutions
|
|
65
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(defpackage #:isogram
|
|
2
|
+
(:use #:common-lisp)
|
|
3
|
+
(:export #:is-isogram))
|
|
4
|
+
|
|
5
|
+
(in-package #:isogram)
|
|
6
|
+
|
|
7
|
+
(defun str-list (s)
|
|
8
|
+
(assert (stringp s) (s))
|
|
9
|
+
(coerce (string-upcase s) 'list))
|
|
10
|
+
|
|
11
|
+
(defun is-isogram-helper (xs)
|
|
12
|
+
(if (null xs) T
|
|
13
|
+
(and (not (and (find (car xs) "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
|
14
|
+
(find (car xs) (cdr xs))))
|
|
15
|
+
(is-isogram-helper (cdr xs)))))
|
|
16
|
+
|
|
17
|
+
(defun is-isogram (xs)
|
|
18
|
+
(is-isogram-helper (str-list xs)))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
(ql:quickload "lisp-unit")
|
|
2
|
+
#-xlisp-test (load "isogram")
|
|
3
|
+
|
|
4
|
+
(defpackage #:isogram-test
|
|
5
|
+
(:use #:common-lisp #:lisp-unit))
|
|
6
|
+
|
|
7
|
+
(in-package #:isogram-test)
|
|
8
|
+
|
|
9
|
+
(define-test empty-string
|
|
10
|
+
(assert-true (isogram:is-isogram "")))
|
|
11
|
+
|
|
12
|
+
(define-test isogram-with-only-lower-case-characters
|
|
13
|
+
(assert-true (isogram:is-isogram "isogram")))
|
|
14
|
+
|
|
15
|
+
(define-test word-with-one-duplicated-character
|
|
16
|
+
(assert-false (isogram:is-isogram "eleven")))
|
|
17
|
+
|
|
18
|
+
(define-test longest-reported-english-isogram
|
|
19
|
+
(assert-true (isogram:is-isogram "subdermatoglyphic")))
|
|
20
|
+
|
|
21
|
+
(define-test word-with-duplicated-character-in-mixed-case
|
|
22
|
+
(assert-false (isogram:is-isogram "Alphabet")))
|
|
23
|
+
|
|
24
|
+
(define-test hypothetical-isogrammic-word-with-hyphen
|
|
25
|
+
(assert-true (isogram:is-isogram "thumbscrew-japingly")))
|
|
26
|
+
|
|
27
|
+
(define-test isogram-with-duplicated-hyphen
|
|
28
|
+
(assert-true (isogram:is-isogram "six-year-old")))
|
|
29
|
+
|
|
30
|
+
(define-test made-up-name-that-is-an-isogam
|
|
31
|
+
(assert-true (isogram:is-isogram "Emily Jung Schwartzkopf")))
|
|
32
|
+
|
|
33
|
+
(define-test duplicated-character-in-the-middle
|
|
34
|
+
(assert-false (isogram:is-isogram "accentor")))
|
|
35
|
+
|
|
36
|
+
#-xlisp-test
|
|
37
|
+
(let ((*print-errors* t)
|
|
38
|
+
(*print-failures* t))
|
|
39
|
+
(run-tests :all :isogram-test))
|
|
@@ -15,7 +15,7 @@ So say you have a matrix like so:
|
|
|
15
15
|
It has a saddle point at (1, 0).
|
|
16
16
|
|
|
17
17
|
It's called a "saddle point" because it is greater than or equal to
|
|
18
|
-
every element in its row and
|
|
18
|
+
every element in its row and less than or equal to every element in
|
|
19
19
|
its column.
|
|
20
20
|
|
|
21
21
|
A matrix may have zero or more saddle points.
|
|
@@ -9,169 +9,169 @@ open AllYourBase
|
|
|
9
9
|
|
|
10
10
|
[<Fact>]
|
|
11
11
|
let ``Single bit one to decimal`` () =
|
|
12
|
-
let expected = Some [1]
|
|
13
12
|
let inputBase = 2
|
|
14
13
|
let inputDigits = [1]
|
|
15
14
|
let outputBase = 10
|
|
15
|
+
let expected = Some [1]
|
|
16
16
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
17
17
|
|
|
18
18
|
[<Fact(Skip = "Remove to run test")>]
|
|
19
19
|
let ``Binary to single decimal`` () =
|
|
20
|
-
let expected = Some [5]
|
|
21
20
|
let inputBase = 2
|
|
22
21
|
let inputDigits = [1; 0; 1]
|
|
23
22
|
let outputBase = 10
|
|
23
|
+
let expected = Some [5]
|
|
24
24
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
25
25
|
|
|
26
26
|
[<Fact(Skip = "Remove to run test")>]
|
|
27
27
|
let ``Single decimal to binary`` () =
|
|
28
|
-
let expected = Some [1; 0; 1]
|
|
29
28
|
let inputBase = 10
|
|
30
29
|
let inputDigits = [5]
|
|
31
30
|
let outputBase = 2
|
|
31
|
+
let expected = Some [1; 0; 1]
|
|
32
32
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
33
33
|
|
|
34
34
|
[<Fact(Skip = "Remove to run test")>]
|
|
35
35
|
let ``Binary to multiple decimal`` () =
|
|
36
|
-
let expected = Some [4; 2]
|
|
37
36
|
let inputBase = 2
|
|
38
37
|
let inputDigits = [1; 0; 1; 0; 1; 0]
|
|
39
38
|
let outputBase = 10
|
|
39
|
+
let expected = Some [4; 2]
|
|
40
40
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
41
41
|
|
|
42
42
|
[<Fact(Skip = "Remove to run test")>]
|
|
43
43
|
let ``Decimal to binary`` () =
|
|
44
|
-
let expected = Some [1; 0; 1; 0; 1; 0]
|
|
45
44
|
let inputBase = 10
|
|
46
45
|
let inputDigits = [4; 2]
|
|
47
46
|
let outputBase = 2
|
|
47
|
+
let expected = Some [1; 0; 1; 0; 1; 0]
|
|
48
48
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
49
49
|
|
|
50
50
|
[<Fact(Skip = "Remove to run test")>]
|
|
51
51
|
let ``Trinary to hexadecimal`` () =
|
|
52
|
-
let expected = Some [2; 10]
|
|
53
52
|
let inputBase = 3
|
|
54
53
|
let inputDigits = [1; 1; 2; 0]
|
|
55
54
|
let outputBase = 16
|
|
55
|
+
let expected = Some [2; 10]
|
|
56
56
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
57
57
|
|
|
58
58
|
[<Fact(Skip = "Remove to run test")>]
|
|
59
59
|
let ``Hexadecimal to trinary`` () =
|
|
60
|
-
let expected = Some [1; 1; 2; 0]
|
|
61
60
|
let inputBase = 16
|
|
62
61
|
let inputDigits = [2; 10]
|
|
63
62
|
let outputBase = 3
|
|
63
|
+
let expected = Some [1; 1; 2; 0]
|
|
64
64
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
65
65
|
|
|
66
66
|
[<Fact(Skip = "Remove to run test")>]
|
|
67
67
|
let ``15-bit integer`` () =
|
|
68
|
-
let expected = Some [6; 10; 45]
|
|
69
68
|
let inputBase = 97
|
|
70
69
|
let inputDigits = [3; 46; 60]
|
|
71
70
|
let outputBase = 73
|
|
71
|
+
let expected = Some [6; 10; 45]
|
|
72
72
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
73
73
|
|
|
74
74
|
[<Fact(Skip = "Remove to run test")>]
|
|
75
75
|
let ``Empty list`` () =
|
|
76
|
-
let expected = None
|
|
77
76
|
let inputBase = 2
|
|
78
77
|
let inputDigits = []
|
|
79
78
|
let outputBase = 10
|
|
79
|
+
let expected = None
|
|
80
80
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
81
81
|
|
|
82
82
|
[<Fact(Skip = "Remove to run test")>]
|
|
83
83
|
let ``Single zero`` () =
|
|
84
|
-
let expected = None
|
|
85
84
|
let inputBase = 10
|
|
86
85
|
let inputDigits = [0]
|
|
87
86
|
let outputBase = 2
|
|
87
|
+
let expected = None
|
|
88
88
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
89
89
|
|
|
90
90
|
[<Fact(Skip = "Remove to run test")>]
|
|
91
91
|
let ``Multiple zeros`` () =
|
|
92
|
-
let expected = None
|
|
93
92
|
let inputBase = 10
|
|
94
93
|
let inputDigits = [0; 0; 0]
|
|
95
94
|
let outputBase = 2
|
|
95
|
+
let expected = None
|
|
96
96
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
97
97
|
|
|
98
98
|
[<Fact(Skip = "Remove to run test")>]
|
|
99
99
|
let ``Leading zeros`` () =
|
|
100
|
-
let expected = None
|
|
101
100
|
let inputBase = 7
|
|
102
101
|
let inputDigits = [0; 6; 0]
|
|
103
102
|
let outputBase = 10
|
|
103
|
+
let expected = None
|
|
104
104
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
105
105
|
|
|
106
106
|
[<Fact(Skip = "Remove to run test")>]
|
|
107
107
|
let ``First base is one`` () =
|
|
108
|
-
let expected = None
|
|
109
108
|
let inputBase = 1
|
|
110
109
|
let inputDigits = []
|
|
111
110
|
let outputBase = 10
|
|
111
|
+
let expected = None
|
|
112
112
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
113
113
|
|
|
114
114
|
[<Fact(Skip = "Remove to run test")>]
|
|
115
115
|
let ``First base is zero`` () =
|
|
116
|
-
let expected = None
|
|
117
116
|
let inputBase = 0
|
|
118
117
|
let inputDigits = []
|
|
119
118
|
let outputBase = 10
|
|
119
|
+
let expected = None
|
|
120
120
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
121
121
|
|
|
122
122
|
[<Fact(Skip = "Remove to run test")>]
|
|
123
123
|
let ``First base is negative`` () =
|
|
124
|
-
let expected = None
|
|
125
124
|
let inputBase = -2
|
|
126
125
|
let inputDigits = [1]
|
|
127
126
|
let outputBase = 10
|
|
127
|
+
let expected = None
|
|
128
128
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
129
129
|
|
|
130
130
|
[<Fact(Skip = "Remove to run test")>]
|
|
131
131
|
let ``Negative digit`` () =
|
|
132
|
-
let expected = None
|
|
133
132
|
let inputBase = 2
|
|
134
133
|
let inputDigits = [1; -1; 1; 0; 1; 0]
|
|
135
134
|
let outputBase = 10
|
|
135
|
+
let expected = None
|
|
136
136
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
137
137
|
|
|
138
138
|
[<Fact(Skip = "Remove to run test")>]
|
|
139
139
|
let ``Invalid positive digit`` () =
|
|
140
|
-
let expected = None
|
|
141
140
|
let inputBase = 2
|
|
142
141
|
let inputDigits = [1; 2; 1; 0; 1; 0]
|
|
143
142
|
let outputBase = 10
|
|
143
|
+
let expected = None
|
|
144
144
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
145
145
|
|
|
146
146
|
[<Fact(Skip = "Remove to run test")>]
|
|
147
147
|
let ``Second base is one`` () =
|
|
148
|
-
let expected = None
|
|
149
148
|
let inputBase = 2
|
|
150
149
|
let inputDigits = [1; 0; 1; 0; 1; 0]
|
|
151
150
|
let outputBase = 1
|
|
151
|
+
let expected = None
|
|
152
152
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
153
153
|
|
|
154
154
|
[<Fact(Skip = "Remove to run test")>]
|
|
155
155
|
let ``Second base is zero`` () =
|
|
156
|
-
let expected = None
|
|
157
156
|
let inputBase = 10
|
|
158
157
|
let inputDigits = [7]
|
|
159
158
|
let outputBase = 0
|
|
159
|
+
let expected = None
|
|
160
160
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
161
161
|
|
|
162
162
|
[<Fact(Skip = "Remove to run test")>]
|
|
163
163
|
let ``Second base is negative`` () =
|
|
164
|
-
let expected = None
|
|
165
164
|
let inputBase = 2
|
|
166
165
|
let inputDigits = [1]
|
|
167
166
|
let outputBase = -7
|
|
167
|
+
let expected = None
|
|
168
168
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
169
169
|
|
|
170
170
|
[<Fact(Skip = "Remove to run test")>]
|
|
171
171
|
let ``Both bases are negative`` () =
|
|
172
|
-
let expected = None
|
|
173
172
|
let inputBase = -2
|
|
174
173
|
let inputDigits = [1]
|
|
175
174
|
let outputBase = -7
|
|
175
|
+
let expected = None
|
|
176
176
|
rebase inputBase inputDigits outputBase |> should equal expected
|
|
177
177
|
|