From ce0e95d83742b8a2b3f90478f5395e9c381b54d0 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:33:34 +1000 Subject: [PATCH 01/43] accumulate stub file --- exercises/accumulate/accumulate.coffee | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 exercises/accumulate/accumulate.coffee diff --git a/exercises/accumulate/accumulate.coffee b/exercises/accumulate/accumulate.coffee new file mode 100644 index 00000000..0b4171f8 --- /dev/null +++ b/exercises/accumulate/accumulate.coffee @@ -0,0 +1,3 @@ +# This is a stub file for the CoffeeScript track + +Array::accumulate = (args) -> From dc7f3a8a34c4b802c7125eec3c36fea230d08f92 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:34:38 +1000 Subject: [PATCH 02/43] Anagram stub file --- exercises/anagram/anagram.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 exercises/anagram/anagram.coffee diff --git a/exercises/anagram/anagram.coffee b/exercises/anagram/anagram.coffee new file mode 100644 index 00000000..842096d3 --- /dev/null +++ b/exercises/anagram/anagram.coffee @@ -0,0 +1,8 @@ +# This is a stub file for the CoffeeScript track + +class Anagram + constructor: (args) -> + + match: (targets) -> + +module.exports = Anagram From 62c66a4bdb4a22cbd84342b22377f55bd9f9bd2e Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:35:25 +1000 Subject: [PATCH 03/43] Atbash stub file --- exercises/atbash-cipher/atbash.coffee | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 exercises/atbash-cipher/atbash.coffee diff --git a/exercises/atbash-cipher/atbash.coffee b/exercises/atbash-cipher/atbash.coffee new file mode 100644 index 00000000..d5197af8 --- /dev/null +++ b/exercises/atbash-cipher/atbash.coffee @@ -0,0 +1,5 @@ +class Atbash + + @encode: (args) -> + +module.exports = Atbash From b04a45190849e2f4cb3f56024234c4da51df9ab7 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:37:21 +1000 Subject: [PATCH 04/43] beer-song stub file --- exercises/beer-song/beer-song.coffee | 7 +++++++ exercises/beer-song/beer-song_test.spec.coffee | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 exercises/beer-song/beer-song.coffee diff --git a/exercises/beer-song/beer-song.coffee b/exercises/beer-song/beer-song.coffee new file mode 100644 index 00000000..8a3bbadb --- /dev/null +++ b/exercises/beer-song/beer-song.coffee @@ -0,0 +1,7 @@ +class Atbash + + @verse: (args) -> + + @sing: (args) -> + +module.exports = Atbash diff --git a/exercises/beer-song/beer-song_test.spec.coffee b/exercises/beer-song/beer-song_test.spec.coffee index cdc82ce5..8ad39055 100644 --- a/exercises/beer-song/beer-song_test.spec.coffee +++ b/exercises/beer-song/beer-song_test.spec.coffee @@ -1,4 +1,4 @@ -Beer = require("./beer") +Beer = require("./beer-song") describe "Beer", -> it "prints an arbitrary verse", -> expect(Beer.verse 8).toEqual """ @@ -46,5 +46,3 @@ describe "Beer", -> Go to the store and buy some more, 99 bottles of beer on the wall. """ - - From be5acca69a3fc9afe2473c79bf38b35f225b03dd Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sun, 26 Jan 2020 14:26:32 +1000 Subject: [PATCH 05/43] validates strand (#115) --- .../nucleotide-count/nucleotide-count_test.spec.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exercises/nucleotide-count/nucleotide-count_test.spec.coffee b/exercises/nucleotide-count/nucleotide-count_test.spec.coffee index 49aa0a1d..cbbcd4fc 100644 --- a/exercises/nucleotide-count/nucleotide-count_test.spec.coffee +++ b/exercises/nucleotide-count/nucleotide-count_test.spec.coffee @@ -36,11 +36,17 @@ describe 'DNA', -> dna.count('T') expect(dna.count('T')).toEqual 2 + xit 'validates strand', -> + dna = new DNA('AGTXCG') + expect -> + dna.count 'G' + .toThrow new Error('Invalid nucleotide strand') + xit 'validates nucleotides', -> dna = new DNA('GGTTGG') expect -> dna.count 'X' - .toThrow new Error('Invalid Nucleotide') + .toThrow new Error('Invalid nucleotide') xit 'counts all nucleotides', -> dna = new DNA('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC') From f6f18d85cc6ea2f6282f0972bacd53c01858b536 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sun, 26 Jan 2020 14:30:44 +1000 Subject: [PATCH 06/43] rename test files (#118) * rename test files * rename test files --- .../{accumulate_test.spec.coffee => accumulate.spec.coffee} | 0 .../anagram/{anagram_test.spec.coffee => anagram.spec.coffee} | 0 .../{atbash_cipher_test.spec.coffee => atbash_cipher.spec.coffee} | 0 .../{beer-song_test.spec.coffee => beer-song.spec.coffee} | 0 ...earch_tree_test.spec.coffee => binary_search_tree.spec.coffee} | 0 exercises/binary/{binary_test.spec.coffee => binary.spec.coffee} | 0 exercises/bob/{bob_test.spec.coffee => bob.spec.coffee} | 0 exercises/clock/{clock_test.spec.coffee => clock.spec.coffee} | 0 .../{hexadecimal_test.spec.coffee => hexadecimal.spec.coffee} | 0 .../{linked-list_test.spec.coffee => linked-list.spec.coffee} | 0 exercises/luhn/{luhn_test.spec.coffee => luhn.spec.coffee} | 0 .../{nth_prime_test.spec.coffee => nth_prime.spec.coffee} | 0 ...eotide-count_test.spec.coffee => nucleotide-count.spec.coffee} | 0 ..._products_test.spec.coffee => palindrome_products.spec.coffee} | 0 .../{queen_attack_test.spec.coffee => queen_attack.spec.coffee} | 0 .../triangle/{triangle_test.spec.coffee => triangle.spec.coffee} | 0 .../trinary/{trinary_test.spec.coffee => trinary.spec.coffee} | 0 .../{word-count_test.spec.coffee => word-count.spec.coffee} | 0 exercises/wordy/{wordy_test.spec.coffee => wordy.spec.coffee} | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename exercises/accumulate/{accumulate_test.spec.coffee => accumulate.spec.coffee} (100%) rename exercises/anagram/{anagram_test.spec.coffee => anagram.spec.coffee} (100%) rename exercises/atbash-cipher/{atbash_cipher_test.spec.coffee => atbash_cipher.spec.coffee} (100%) rename exercises/beer-song/{beer-song_test.spec.coffee => beer-song.spec.coffee} (100%) rename exercises/binary-search-tree/{binary_search_tree_test.spec.coffee => binary_search_tree.spec.coffee} (100%) rename exercises/binary/{binary_test.spec.coffee => binary.spec.coffee} (100%) rename exercises/bob/{bob_test.spec.coffee => bob.spec.coffee} (100%) rename exercises/clock/{clock_test.spec.coffee => clock.spec.coffee} (100%) rename exercises/hexadecimal/{hexadecimal_test.spec.coffee => hexadecimal.spec.coffee} (100%) rename exercises/linked-list/{linked-list_test.spec.coffee => linked-list.spec.coffee} (100%) rename exercises/luhn/{luhn_test.spec.coffee => luhn.spec.coffee} (100%) rename exercises/nth-prime/{nth_prime_test.spec.coffee => nth_prime.spec.coffee} (100%) rename exercises/nucleotide-count/{nucleotide-count_test.spec.coffee => nucleotide-count.spec.coffee} (100%) rename exercises/palindrome-products/{palindrome_products_test.spec.coffee => palindrome_products.spec.coffee} (100%) rename exercises/queen-attack/{queen_attack_test.spec.coffee => queen_attack.spec.coffee} (100%) rename exercises/triangle/{triangle_test.spec.coffee => triangle.spec.coffee} (100%) rename exercises/trinary/{trinary_test.spec.coffee => trinary.spec.coffee} (100%) rename exercises/word-count/{word-count_test.spec.coffee => word-count.spec.coffee} (100%) rename exercises/wordy/{wordy_test.spec.coffee => wordy.spec.coffee} (100%) diff --git a/exercises/accumulate/accumulate_test.spec.coffee b/exercises/accumulate/accumulate.spec.coffee similarity index 100% rename from exercises/accumulate/accumulate_test.spec.coffee rename to exercises/accumulate/accumulate.spec.coffee diff --git a/exercises/anagram/anagram_test.spec.coffee b/exercises/anagram/anagram.spec.coffee similarity index 100% rename from exercises/anagram/anagram_test.spec.coffee rename to exercises/anagram/anagram.spec.coffee diff --git a/exercises/atbash-cipher/atbash_cipher_test.spec.coffee b/exercises/atbash-cipher/atbash_cipher.spec.coffee similarity index 100% rename from exercises/atbash-cipher/atbash_cipher_test.spec.coffee rename to exercises/atbash-cipher/atbash_cipher.spec.coffee diff --git a/exercises/beer-song/beer-song_test.spec.coffee b/exercises/beer-song/beer-song.spec.coffee similarity index 100% rename from exercises/beer-song/beer-song_test.spec.coffee rename to exercises/beer-song/beer-song.spec.coffee diff --git a/exercises/binary-search-tree/binary_search_tree_test.spec.coffee b/exercises/binary-search-tree/binary_search_tree.spec.coffee similarity index 100% rename from exercises/binary-search-tree/binary_search_tree_test.spec.coffee rename to exercises/binary-search-tree/binary_search_tree.spec.coffee diff --git a/exercises/binary/binary_test.spec.coffee b/exercises/binary/binary.spec.coffee similarity index 100% rename from exercises/binary/binary_test.spec.coffee rename to exercises/binary/binary.spec.coffee diff --git a/exercises/bob/bob_test.spec.coffee b/exercises/bob/bob.spec.coffee similarity index 100% rename from exercises/bob/bob_test.spec.coffee rename to exercises/bob/bob.spec.coffee diff --git a/exercises/clock/clock_test.spec.coffee b/exercises/clock/clock.spec.coffee similarity index 100% rename from exercises/clock/clock_test.spec.coffee rename to exercises/clock/clock.spec.coffee diff --git a/exercises/hexadecimal/hexadecimal_test.spec.coffee b/exercises/hexadecimal/hexadecimal.spec.coffee similarity index 100% rename from exercises/hexadecimal/hexadecimal_test.spec.coffee rename to exercises/hexadecimal/hexadecimal.spec.coffee diff --git a/exercises/linked-list/linked-list_test.spec.coffee b/exercises/linked-list/linked-list.spec.coffee similarity index 100% rename from exercises/linked-list/linked-list_test.spec.coffee rename to exercises/linked-list/linked-list.spec.coffee diff --git a/exercises/luhn/luhn_test.spec.coffee b/exercises/luhn/luhn.spec.coffee similarity index 100% rename from exercises/luhn/luhn_test.spec.coffee rename to exercises/luhn/luhn.spec.coffee diff --git a/exercises/nth-prime/nth_prime_test.spec.coffee b/exercises/nth-prime/nth_prime.spec.coffee similarity index 100% rename from exercises/nth-prime/nth_prime_test.spec.coffee rename to exercises/nth-prime/nth_prime.spec.coffee diff --git a/exercises/nucleotide-count/nucleotide-count_test.spec.coffee b/exercises/nucleotide-count/nucleotide-count.spec.coffee similarity index 100% rename from exercises/nucleotide-count/nucleotide-count_test.spec.coffee rename to exercises/nucleotide-count/nucleotide-count.spec.coffee diff --git a/exercises/palindrome-products/palindrome_products_test.spec.coffee b/exercises/palindrome-products/palindrome_products.spec.coffee similarity index 100% rename from exercises/palindrome-products/palindrome_products_test.spec.coffee rename to exercises/palindrome-products/palindrome_products.spec.coffee diff --git a/exercises/queen-attack/queen_attack_test.spec.coffee b/exercises/queen-attack/queen_attack.spec.coffee similarity index 100% rename from exercises/queen-attack/queen_attack_test.spec.coffee rename to exercises/queen-attack/queen_attack.spec.coffee diff --git a/exercises/triangle/triangle_test.spec.coffee b/exercises/triangle/triangle.spec.coffee similarity index 100% rename from exercises/triangle/triangle_test.spec.coffee rename to exercises/triangle/triangle.spec.coffee diff --git a/exercises/trinary/trinary_test.spec.coffee b/exercises/trinary/trinary.spec.coffee similarity index 100% rename from exercises/trinary/trinary_test.spec.coffee rename to exercises/trinary/trinary.spec.coffee diff --git a/exercises/word-count/word-count_test.spec.coffee b/exercises/word-count/word-count.spec.coffee similarity index 100% rename from exercises/word-count/word-count_test.spec.coffee rename to exercises/word-count/word-count.spec.coffee diff --git a/exercises/wordy/wordy_test.spec.coffee b/exercises/wordy/wordy.spec.coffee similarity index 100% rename from exercises/wordy/wordy_test.spec.coffee rename to exercises/wordy/wordy.spec.coffee From a42482606943456956d0bbe5b38686a08973e8e1 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sun, 26 Jan 2020 14:36:33 +1000 Subject: [PATCH 07/43] Update INSTALLATION.md --- docs/INSTALLATION.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index f1f50f03..fdd46fde 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -4,16 +4,16 @@ [linstall]: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager -Install `jasmine-node` and `coffee`: +Install `jasmine-node` and `coffeescript`: ```bash -$ npm install jasmine-node coffeescript -g +$ npm install -g jasmine-node coffeescript ``` Depending on your setup, you may need super user privileges to install an `npm` module globally. This is the case if you've used the official installer linked to above. If NPM gives you an error saying you don't have access, add `sudo` to the command above: ```bash -$ sudo npm install jasmine-node coffeescript -g +$ sudo npm install -g jasmine-node coffeescript ``` If you've used the official installer, your `PATH` should have been automatically configured, but if your shell has trouble locating your globally installed modules--or if you build Node.js from source--update your `PATH` to include the `npm` binaries by adding the following to either `~/.bash_profile` or `~/.zshrc`: From 01f00c58e1aee31a60886ae2b54e62a4f5737f7a Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 16:57:34 +1000 Subject: [PATCH 08/43] remove .meta from bob (#119) --- exercises/bob/.meta/description.md | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 exercises/bob/.meta/description.md diff --git a/exercises/bob/.meta/description.md b/exercises/bob/.meta/description.md deleted file mode 100644 index 1072139f..00000000 --- a/exercises/bob/.meta/description.md +++ /dev/null @@ -1,10 +0,0 @@ -Bob is a lackadaisical teenager. In conversation, his responses are very limited. - -Bob answers 'Sure.' if you ask him a question. - -He answers 'Whoa, chill out!' if you yell at him. - -He says 'Fine. Be that way!' if you address him without actually saying -anything. - -He answers 'Whatever.' to anything else. From 5e7e05e2f8a89b9c208ccdbe9028446568127701 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:09:23 +1000 Subject: [PATCH 09/43] update luhn tests to newest canonical data (#120) --- exercises/luhn/luhn.spec.coffee | 86 +++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/exercises/luhn/luhn.spec.coffee b/exercises/luhn/luhn.spec.coffee index 08703886..9c78d32c 100644 --- a/exercises/luhn/luhn.spec.coffee +++ b/exercises/luhn/luhn.spec.coffee @@ -2,46 +2,70 @@ Luhn = require './luhn' describe 'Luhn', -> - it "check digit", -> - luhn = new Luhn(34567) - expect(luhn.checkDigit).toEqual(7) + it 'single digit strings can not be valid', -> + luhn = new Luhn('1') + expect(luhn.valid).toEqual(false) - xit "check digit again", -> - luhn = new Luhn(91370) - expect(luhn.checkDigit).toEqual(0) + xit 'a single zero is invalid', -> + luhn = new Luhn('0') + expect(luhn.valid).toEqual(false) - xit "addends", -> - luhn = new Luhn(12121) - expect(luhn.addends).toEqual([1, 4, 1, 4, 1]) + xit 'a simple valid SIN that remains valid if reversed', -> + luhn = new Luhn('059') + expect(luhn.valid).toEqual(true) - xit "too large added", -> - luhn = new Luhn(8631) - expect(luhn.addends).toEqual([7, 6, 6, 1]) + xit 'a simple valid SIN that becomes invalid if reversed', -> + luhn = new Luhn('59') + expect(luhn.valid).toEqual(true) - xit "checksum", -> - luhn = new Luhn(4913) - expect(luhn.checksum).toEqual(22) + xit 'a valid Canadian SIN', -> + luhn = new Luhn('055 444 286') + expect(luhn.valid).toEqual(true) - xit "checksum again", -> - luhn = new Luhn(201773) - expect(luhn.checksum).toEqual(21) + xit 'invalid credit card', -> + luhn = new Luhn('8273 1232 7352 0569') + expect(luhn.valid).toEqual(false) - xit "invalid number", -> - luhn = new Luhn(738) + xit 'invalid credit card', -> + luhn = new Luhn('8273 1232 7352 0569') expect(luhn.valid).toEqual(false) - xit "valid number", -> - luhn = new Luhn(8739567) + xit 'valid number with an even number of digits', -> + luhn = new Luhn('095 245 88') expect(luhn.valid).toEqual(true) - xit "create valid number", -> - number = Luhn.create(123) - expect(number).toEqual(1230) + xit 'valid number with an odd number of spaces', -> + luhn = new Luhn('234 567 891 234') + expect(luhn.valid).toEqual(true) - xit "create other valid number", -> - number = Luhn.create(873956) - expect(number).toEqual(8739567) + xit 'valid strings with a non-digit added at the end become invalid', -> + luhn = new Luhn('059a') + expect(luhn.valid).toEqual(false) - xit "create yet another valid number", -> - number = Luhn.create(837263756) - expect(number).toEqual(8372637564) + xit 'valid strings with punctuation included become invalid', -> + luhn = new Luhn('055-444-285') + expect(luhn.valid).toEqual(false) + + xit 'valid strings with symbols included become invalid', -> + luhn = new Luhn('055# 444$ 285') + expect(luhn.valid).toEqual(false) + + xit 'single zero with space is invalid', -> + luhn = new Luhn(' 0') + expect(luhn.valid).toEqual(false) + + xit 'more than a single zero is valid', -> + luhn = new Luhn('0000 0') + expect(luhn.valid).toEqual(true) + + xit 'input digit 9 is correctly converted to output digit 9', -> + luhn = new Luhn('091') + expect(luhn.valid).toEqual(true) + + xit 'using ascii value for non-doubled non-digit isn\'t allowed', -> + luhn = new Luhn('055b 444 285') + expect(luhn.valid).toEqual(false) + + xit 'using ascii value for non-doubled non-digit isn\'t allowed', -> + luhn = new Luhn(':9') + expect(luhn.valid).toEqual(false) From d8b11e17bde00140b25d8b5c2cff73f697d093eb Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:12:30 +1000 Subject: [PATCH 10/43] fix luhn test description (oops) --- exercises/luhn/luhn.spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/luhn/luhn.spec.coffee b/exercises/luhn/luhn.spec.coffee index 9c78d32c..03386724 100644 --- a/exercises/luhn/luhn.spec.coffee +++ b/exercises/luhn/luhn.spec.coffee @@ -66,6 +66,6 @@ describe 'Luhn', -> luhn = new Luhn('055b 444 285') expect(luhn.valid).toEqual(false) - xit 'using ascii value for non-doubled non-digit isn\'t allowed', -> + xit 'using ascii value for doubled non-digit isn\'t allowed', -> luhn = new Luhn(':9') expect(luhn.valid).toEqual(false) From 9a9c0fa018c6fef6d08eaf140b2aba2f87c42dcc Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:35:40 +1000 Subject: [PATCH 11/43] renaming and change quotes (#121) --- exercises/accumulate/accumulate.spec.coffee | 6 +- exercises/anagram/anagram.spec.coffee | 84 +++++++++--------- ....spec.coffee => atbash-cipher.spec.coffee} | 2 +- exercises/beer-song/beer-song.spec.coffee | 36 ++++---- ....coffee => binary-search-tree.spec.coffee} | 2 +- exercises/bob/bob.spec.coffee | 88 +++++++++---------- exercises/clock/clock.spec.coffee | 45 +++++----- ...{hello_world.coffee => hello-world.coffee} | 0 ...ld.spec.coffee => hello-world.spec.coffee} | 4 +- exercises/hexadecimal/hexadecimal.spec.coffee | 44 +++++----- exercises/linked-list/linked-list.spec.coffee | 3 +- ...rime.spec.coffee => nth-prime.spec.coffee} | 4 +- .../nucleotide-count.spec.coffee | 2 +- ...coffee => palindrome-products.spec.coffee} | 14 +-- ...ec.coffee => pascals-triangle.spec.coffee} | 3 +- ...k.spec.coffee => queen-attack.spec.coffee} | 33 ++++--- exercises/triangle/triangle.spec.coffee | 10 +-- exercises/word-count/word-count.spec.coffee | 28 +++--- 18 files changed, 201 insertions(+), 207 deletions(-) rename exercises/atbash-cipher/{atbash_cipher.spec.coffee => atbash-cipher.spec.coffee} (95%) rename exercises/binary-search-tree/{binary_search_tree.spec.coffee => binary-search-tree.spec.coffee} (97%) rename exercises/hello-world/{hello_world.coffee => hello-world.coffee} (100%) rename exercises/hello-world/{hello_world.spec.coffee => hello-world.spec.coffee} (65%) rename exercises/nth-prime/{nth_prime.spec.coffee => nth-prime.spec.coffee} (79%) rename exercises/palindrome-products/{palindrome_products.spec.coffee => palindrome-products.spec.coffee} (75%) rename exercises/pascals-triangle/{pascal-triangle-spec.coffee => pascals-triangle.spec.coffee} (95%) rename exercises/queen-attack/{queen_attack.spec.coffee => queen-attack.spec.coffee} (58%) diff --git a/exercises/accumulate/accumulate.spec.coffee b/exercises/accumulate/accumulate.spec.coffee index 6d8d1f27..20fd3f3b 100644 --- a/exercises/accumulate/accumulate.spec.coffee +++ b/exercises/accumulate/accumulate.spec.coffee @@ -20,10 +20,10 @@ describe '[].accumulate()', -> accumulator = (word) -> word.split('').reverse().join('') result = 'the quick brown fox etc'.split(/\s/).accumulate accumulator - expect(result).toEqual ["eht", "kciuq", "nworb", "xof", "cte"] + expect(result).toEqual ['eht', 'kciuq', 'nworb', 'xof', 'cte'] xit 'accumulate recursively', -> result = 'a b c'.split(/\s+/).accumulate (char) -> - '1 2 3'.split(/\s+/).accumulate (digit) -> "#{char}#{digit}" + '1 2 3'.split(/\s+/).accumulate (digit) -> '#{char}#{digit}' - expect(result).toEqual([["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]]) + expect(result).toEqual([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']]) diff --git a/exercises/anagram/anagram.spec.coffee b/exercises/anagram/anagram.spec.coffee index d1b5d9b1..caa53fd2 100644 --- a/exercises/anagram/anagram.spec.coffee +++ b/exercises/anagram/anagram.spec.coffee @@ -1,56 +1,56 @@ -Anagram = require "./anagram" -describe "Anagram", -> - it "no matches", -> - detector = new Anagram "diaper" - matches = detector.match ["hello", "world", "zombies", "pants"] +Anagram = require './anagram' +describe 'Anagram', -> + it 'no matches', -> + detector = new Anagram 'diaper' + matches = detector.match ['hello', 'world', 'zombies', 'pants'] expect(matches).toEqual [] - xit "detects simple anagram", -> - detector = new Anagram "ant" - matches = detector.match ["tan", "stand", "at"] - expect(matches).toEqual ["tan"] + xit 'detects simple anagram', -> + detector = new Anagram 'ant' + matches = detector.match ['tan', 'stand', 'at'] + expect(matches).toEqual ['tan'] - xit "does not detect false positives", -> - detector = new Anagram "galea" - matches = detector.match ["eagle"] + xit 'does not detect false positives', -> + detector = new Anagram 'galea' + matches = detector.match ['eagle'] expect(matches).toEqual [] - xit "detects multiple anagrams", -> - detector = new Anagram "master" - matches = detector.match ["stream", "pigeon", "maters"] - expect(matches).toEqual ["stream", "maters"] + xit 'detects multiple anagrams', -> + detector = new Anagram 'master' + matches = detector.match ['stream', 'pigeon', 'maters'] + expect(matches).toEqual ['stream', 'maters'] - xit "does not detect anagram subsets", -> - detector = new Anagram "good" - matches = detector.match ["dog", "goody"] + xit 'does not detect anagram subsets', -> + detector = new Anagram 'good' + matches = detector.match ['dog', 'goody'] expect(matches).toEqual [] - xit "detects anagram", -> - detector = new Anagram "listen" - matches = detector.match ["enlists", "google", "inlets", "banana"] - expect(matches).toEqual ["inlets"] + xit 'detects anagram', -> + detector = new Anagram 'listen' + matches = detector.match ['enlists', 'google', 'inlets', 'banana'] + expect(matches).toEqual ['inlets'] - xit "detects multiple anagrams", -> - detector = new Anagram "allergy" - matches = detector.match ["gallery", "ballerina", "regally", "clergy", "largely", "leading"] - expect(matches).toEqual ["gallery", "regally", "largely"] + xit 'detects multiple anagrams', -> + detector = new Anagram 'allergy' + matches = detector.match ['gallery', 'ballerina', 'regally', 'clergy', 'largely', 'leading'] + expect(matches).toEqual ['gallery', 'regally', 'largely'] - xit "does not detect identical words", -> - detector = new Anagram "corn" - matches = detector.match ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"] - expect(matches).toEqual ["cron"] + xit 'does not detect identical words', -> + detector = new Anagram 'corn' + matches = detector.match ['corn', 'dark', 'Corn', 'rank', 'CORN', 'cron', 'park'] + expect(matches).toEqual ['cron'] - xit "does not detect non-anagrams with identical checksum", -> - detector = new Anagram "mass" - matches = detector.match ["last"] + xit 'does not detect non-anagrams with identical checksum', -> + detector = new Anagram 'mass' + matches = detector.match ['last'] expect(matches).toEqual [] - xit "detects anagrams using case-insensitive subject", -> - detector = new Anagram "Orchestra" - matches = detector.match ["cashregister", "carthorse", "radishes"] - expect(matches).toEqual ["carthorse"] + xit 'detects anagrams using case-insensitive subject', -> + detector = new Anagram 'Orchestra' + matches = detector.match ['cashregister', 'carthorse', 'radishes'] + expect(matches).toEqual ['carthorse'] - xit "detects anagrams using case-insensitive candidates", -> - detector = new Anagram "orchestra" - matches = detector.match ["cashregister", "Carthorse", "radishes"] - expect(matches).toEqual ["carthorse"] + xit 'detects anagrams using case-insensitive candidates', -> + detector = new Anagram 'orchestra' + matches = detector.match ['cashregister', 'Carthorse', 'radishes'] + expect(matches).toEqual ['carthorse'] diff --git a/exercises/atbash-cipher/atbash_cipher.spec.coffee b/exercises/atbash-cipher/atbash-cipher.spec.coffee similarity index 95% rename from exercises/atbash-cipher/atbash_cipher.spec.coffee rename to exercises/atbash-cipher/atbash-cipher.spec.coffee index a277f9d0..44e34372 100644 --- a/exercises/atbash-cipher/atbash_cipher.spec.coffee +++ b/exercises/atbash-cipher/atbash-cipher.spec.coffee @@ -1,4 +1,4 @@ -Atbash = require './atbash' +Atbash = require './atbash-cipher' describe 'Atbash', -> it 'encodes no', -> diff --git a/exercises/beer-song/beer-song.spec.coffee b/exercises/beer-song/beer-song.spec.coffee index cdc82ce5..e54882bc 100644 --- a/exercises/beer-song/beer-song.spec.coffee +++ b/exercises/beer-song/beer-song.spec.coffee @@ -1,25 +1,25 @@ -Beer = require("./beer") -describe "Beer", -> - it "prints an arbitrary verse", -> - expect(Beer.verse 8).toEqual """ +Beer = require './beer-song' +describe 'Beer', -> + it 'prints an arbitrary verse', -> + expect(Beer.verse 8).toEqual ' 8 bottles of beer on the wall, 8 bottles of beer. Take one down and pass it around, 7 bottles of beer on the wall. - """ + ' - xit "handles 1 bottle", -> - expect(Beer.verse 1).toEqual """ + xit 'handles 1 bottle', -> + expect(Beer.verse 1).toEqual ' 1 bottle of beer on the wall, 1 bottle of beer. Take it down and pass it around, no more bottles of beer on the wall. - """ + ' - xit "handles 0 bottles", -> - expect(Beer.verse 0).toEqual """ + xit 'handles 0 bottles', -> + expect(Beer.verse 0).toEqual ' No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. - """ + ' - xit "sings several verses", -> - expect(Beer.sing 8, 6).toEqual """ + xit 'sings several verses', -> + expect(Beer.sing 8, 6).toEqual ' 8 bottles of beer on the wall, 8 bottles of beer. Take one down and pass it around, 7 bottles of beer on the wall. @@ -29,10 +29,10 @@ describe "Beer", -> 6 bottles of beer on the wall, 6 bottles of beer. Take one down and pass it around, 5 bottles of beer on the wall. - """ + ' - xit "sings the rest of the verses", -> - expect(Beer.sing 3).toEqual """ + xit 'sings the rest of the verses', -> + expect(Beer.sing 3).toEqual ' 3 bottles of beer on the wall, 3 bottles of beer. Take one down and pass it around, 2 bottles of beer on the wall. @@ -45,6 +45,4 @@ describe "Beer", -> No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. - """ - - + ' diff --git a/exercises/binary-search-tree/binary_search_tree.spec.coffee b/exercises/binary-search-tree/binary-search-tree.spec.coffee similarity index 97% rename from exercises/binary-search-tree/binary_search_tree.spec.coffee rename to exercises/binary-search-tree/binary-search-tree.spec.coffee index 6355c6a7..25081944 100644 --- a/exercises/binary-search-tree/binary_search_tree.spec.coffee +++ b/exercises/binary-search-tree/binary-search-tree.spec.coffee @@ -1,4 +1,4 @@ -Bst = require './bst' +Bst = require './binary-search-tree' recordAllData = (bst) -> out = [] diff --git a/exercises/bob/bob.spec.coffee b/exercises/bob/bob.spec.coffee index 435a5e32..428757c3 100644 --- a/exercises/bob/bob.spec.coffee +++ b/exercises/bob/bob.spec.coffee @@ -1,58 +1,58 @@ -Bob = require "./bob" -describe "Bob", -> +Bob = require './bob' +describe 'Bob', -> bob = new Bob() - it "stating something", -> - result = bob.hey "Tom-ay-to, tom-aaaah-to." - expect(result).toEqual "Whatever." + it 'stating something', -> + result = bob.hey 'Tom-ay-to, tom-aaaah-to.' + expect(result).toEqual 'Whatever.' - xit "shouting", -> - result = bob.hey "WATCH OUT!" - expect(result).toEqual "Whoa, chill out!" + xit 'shouting', -> + result = bob.hey 'WATCH OUT!' + expect(result).toEqual 'Whoa, chill out!' - xit "asking a question", -> - result = bob.hey "Does this cryogenic chamber make me look fat?" - expect(result).toEqual "Sure." + xit 'asking a question', -> + result = bob.hey 'Does this cryogenic chamber make me look fat?' + expect(result).toEqual 'Sure.' - xit "talking forcefully", -> - result = bob.hey "Let's go make out behind the gym!" - expect(result).toEqual "Whatever." + xit 'talking forcefully', -> + result = bob.hey 'Let's go make out behind the gym!' + expect(result).toEqual 'Whatever.' - xit "using acronyms in regular speech", -> - result = bob.hey "It's OK if you don't want to go to the DMV." - expect(result).toEqual "Whatever." + xit 'using acronyms in regular speech', -> + result = bob.hey 'It's OK if you don't want to go to the DMV.' + expect(result).toEqual 'Whatever.' - xit "forceful questions", -> - result = bob.hey "WHAT THE HELL WERE YOU THINKING?" - expect(result).toEqual "Whoa, chill out!" + xit 'forceful questions', -> + result = bob.hey 'WHAT THE HELL WERE YOU THINKING?' + expect(result).toEqual 'Whoa, chill out!' - xit "shouting numbers", -> - result = bob.hey "1, 2, 3 GO!" - expect(result).toEqual "Whoa, chill out!" + xit 'shouting numbers', -> + result = bob.hey '1, 2, 3 GO!' + expect(result).toEqual 'Whoa, chill out!' - xit "only number", -> - result = bob.hey "1, 2, 3" - expect(result).toEqual "Whatever." + xit 'only number', -> + result = bob.hey '1, 2, 3' + expect(result).toEqual 'Whatever.' - xit "shouting with special characters", -> - result = bob.hey "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" - expect(result).toEqual "Whoa, chill out!" + xit 'shouting with special characters', -> + result = bob.hey 'ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!' + expect(result).toEqual 'Whoa, chill out!' - xit "shouting with no exclamation mark", -> - result = bob.hey "I HATE YOU" - expect(result).toEqual "Whoa, chill out!" + xit 'shouting with no exclamation mark', -> + result = bob.hey 'I HATE YOU' + expect(result).toEqual 'Whoa, chill out!' - xit "statement containing question mark", -> - result = bob.hey "Ending with a ? means a question." - expect(result).toEqual "Whatever." + xit 'statement containing question mark', -> + result = bob.hey 'Ending with a ? means a question.' + expect(result).toEqual 'Whatever.' - xit "prattling on", -> - result = bob.hey "Wait! Hang on. Are you going to be OK?" - expect(result).toEqual "Sure." + xit 'prattling on', -> + result = bob.hey 'Wait! Hang on. Are you going to be OK?' + expect(result).toEqual 'Sure.' - xit "silence", -> - result = bob.hey "" - expect(result).toEqual "Fine. Be that way!" + xit 'silence', -> + result = bob.hey '' + expect(result).toEqual 'Fine. Be that way!' - xit "prolonged silence", -> - result = bob.hey " " - expect(result).toEqual "Fine. Be that way!" + xit 'prolonged silence', -> + result = bob.hey ' ' + expect(result).toEqual 'Fine. Be that way!' diff --git a/exercises/clock/clock.spec.coffee b/exercises/clock/clock.spec.coffee index 815f2870..ee7dd276 100644 --- a/exercises/clock/clock.spec.coffee +++ b/exercises/clock/clock.spec.coffee @@ -1,47 +1,46 @@ Clock = require './clock' -describe "Clock", -> - it "prints the hour", -> - expect(Clock.at(8).toString()).toEqual "08:00" - expect(Clock.at(9).toString()).toEqual "09:00" +describe 'Clock', -> + it 'prints the hour', -> + expect(Clock.at(8).toString()).toEqual '08:00' + expect(Clock.at(9).toString()).toEqual '09:00' - xit "prints past the hour", -> - expect(Clock.at(11, 9).toString()).toEqual "11:09" - expect(Clock.at(11, 19).toString()).toEqual "11:19" + xit 'prints past the hour', -> + expect(Clock.at(11, 9).toString()).toEqual '11:09' + expect(Clock.at(11, 19).toString()).toEqual '11:19' - xit "can add minutes", -> + xit 'can add minutes', -> clock = Clock.at(10).plus 3 - expect(clock.toString()).toEqual "10:03" + expect(clock.toString()).toEqual '10:03' - xit "can add over an hour", -> + xit 'can add over an hour', -> clock = Clock.at(10).plus 61 - expect(clock.toString()).toEqual "11:01" + expect(clock.toString()).toEqual '11:01' - xit "wraps around midnight", -> + xit 'wraps around midnight', -> clock = Clock.at(23, 59).plus 2 - expect(clock.toString()).toEqual "00:01" + expect(clock.toString()).toEqual '00:01' - xit "can subtract minutes", -> + xit 'can subtract minutes', -> clock = Clock.at(10, 3).minus 3 - expect(clock.toString()).toEqual "10:00" + expect(clock.toString()).toEqual '10:00' - xit "can subtract over an hour", -> + xit 'can subtract over an hour', -> clock = Clock.at(10, 3).minus 30 - expect(clock.toString()).toEqual "09:33" + expect(clock.toString()).toEqual '09:33' clock = Clock.at(10, 3).minus 70 - expect(clock.toString()).toEqual "08:53" + expect(clock.toString()).toEqual '08:53' - xit "can know if it's equal to another clock", -> + xit 'can know if it's equal to another clock', -> clock1 = Clock.at(10, 3) clock2 = Clock.at(10, 3) expect(clock1.equals clock2).toBe true - xit "can know if it's not equal to another clock", -> + xit 'can know if it's not equal to another clock', -> clock1 = Clock.at(10, 3) clock2 = Clock.at(10, 4) expect(clock1.equals clock2).toBe false - xit "wraps around midnight backwards", -> + xit 'wraps around midnight backwards', -> clock = Clock.at(0, 3).minus 4 - expect(clock.toString()).toEqual "23:59" - + expect(clock.toString()).toEqual '23:59' diff --git a/exercises/hello-world/hello_world.coffee b/exercises/hello-world/hello-world.coffee similarity index 100% rename from exercises/hello-world/hello_world.coffee rename to exercises/hello-world/hello-world.coffee diff --git a/exercises/hello-world/hello_world.spec.coffee b/exercises/hello-world/hello-world.spec.coffee similarity index 65% rename from exercises/hello-world/hello_world.spec.coffee rename to exercises/hello-world/hello-world.spec.coffee index c5e6e037..f457f579 100644 --- a/exercises/hello-world/hello_world.spec.coffee +++ b/exercises/hello-world/hello-world.spec.coffee @@ -1,8 +1,8 @@ -HelloWorld = require "./hello_world" +HelloWorld = require './hello-world' describe 'HelloWorld', -> hello_world = new HelloWorld() - it "says 'Hello, World!'", -> + it 'says \'Hello, World!\'', -> result = hello_world.hello() expect(result).toEqual 'Hello, World!' diff --git a/exercises/hexadecimal/hexadecimal.spec.coffee b/exercises/hexadecimal/hexadecimal.spec.coffee index a442565e..a786126b 100644 --- a/exercises/hexadecimal/hexadecimal.spec.coffee +++ b/exercises/hexadecimal/hexadecimal.spec.coffee @@ -1,43 +1,43 @@ -Hexadecimal = require('./hexadecimal') +Hexadecimal = require './hexadecimal' -describe "Hexadecimal", -> +describe 'Hexadecimal', -> - it "hex 1 is decimal 1", -> - hex = new Hexadecimal("1") + it 'hex 1 is decimal 1', -> + hex = new Hexadecimal('1') expect(hex.toDecimal()).toEqual(1) - xit "hex c is decimal 12", -> - hex = new Hexadecimal("c") + xit 'hex c is decimal 12', -> + hex = new Hexadecimal('c') expect(hex.toDecimal()).toEqual(12) - xit "hex 10 is decimal 16", -> - hex = new Hexadecimal("10") + xit 'hex 10 is decimal 16', -> + hex = new Hexadecimal('10') expect(hex.toDecimal()).toEqual(16) - xit "hex af is decimal 175", -> - hex = new Hexadecimal("af") + xit 'hex af is decimal 175', -> + hex = new Hexadecimal('af') expect(hex.toDecimal()).toEqual(175) - xit "hex 100 is decimal 256", -> - hex = new Hexadecimal("100") + xit 'hex 100 is decimal 256', -> + hex = new Hexadecimal('100') expect(hex.toDecimal()).toEqual(256) - xit "hex 19ace is decimal 105166", -> - hex = new Hexadecimal("19ace") + xit 'hex 19ace is decimal 105166', -> + hex = new Hexadecimal('19ace') expect(hex.toDecimal()).toEqual(105166) - xit "invalid hex is decimal 0", -> - hex = new Hexadecimal("carrot") + xit 'invalid hex is decimal 0', -> + hex = new Hexadecimal('carrot') expect(hex.toDecimal()).toEqual(0) - xit "black", -> - hex = new Hexadecimal("000000") + xit 'black', -> + hex = new Hexadecimal('000000') expect(hex.toDecimal()).toEqual(0) - xit "white", -> - hex = new Hexadecimal("ffffff") + xit 'white', -> + hex = new Hexadecimal('ffffff') expect(hex.toDecimal()).toEqual(16777215) - xit "yellow", -> - hex = new Hexadecimal("ffff00") + xit 'yellow', -> + hex = new Hexadecimal('ffff00') expect(hex.toDecimal()).toEqual(16776960) diff --git a/exercises/linked-list/linked-list.spec.coffee b/exercises/linked-list/linked-list.spec.coffee index 64760f43..cdf23717 100644 --- a/exercises/linked-list/linked-list.spec.coffee +++ b/exercises/linked-list/linked-list.spec.coffee @@ -1,4 +1,4 @@ -LinkedList = require('./linkedList') +LinkedList = require './linked-list' describe 'LinkedList', -> it 'init', -> @@ -66,4 +66,3 @@ describe 'LinkedList', -> list.pushNode(10) list.deleteNode(10) expect(list.countNodes()).toBe 0 - diff --git a/exercises/nth-prime/nth_prime.spec.coffee b/exercises/nth-prime/nth-prime.spec.coffee similarity index 79% rename from exercises/nth-prime/nth_prime.spec.coffee rename to exercises/nth-prime/nth-prime.spec.coffee index 581e7324..4fdef710 100644 --- a/exercises/nth-prime/nth_prime.spec.coffee +++ b/exercises/nth-prime/nth-prime.spec.coffee @@ -1,4 +1,4 @@ -Prime = require './prime' +Prime = require './nth-prime' describe 'Prime', -> @@ -19,4 +19,4 @@ describe 'Prime', -> expect(prime).toEqual(104743) xit 'weird case', -> - expect(-> Prime.nth(0)).toThrow("Prime is not possible") + expect(-> Prime.nth(0)).toThrow('Prime is not possible') diff --git a/exercises/nucleotide-count/nucleotide-count.spec.coffee b/exercises/nucleotide-count/nucleotide-count.spec.coffee index cbbcd4fc..b5f80e50 100644 --- a/exercises/nucleotide-count/nucleotide-count.spec.coffee +++ b/exercises/nucleotide-count/nucleotide-count.spec.coffee @@ -1,4 +1,4 @@ -DNA = require './example' +DNA = require './nucleotide-count' describe 'DNA', -> it 'has no nucleotides', -> diff --git a/exercises/palindrome-products/palindrome_products.spec.coffee b/exercises/palindrome-products/palindrome-products.spec.coffee similarity index 75% rename from exercises/palindrome-products/palindrome_products.spec.coffee rename to exercises/palindrome-products/palindrome-products.spec.coffee index 7296cc88..8c460f74 100644 --- a/exercises/palindrome-products/palindrome_products.spec.coffee +++ b/exercises/palindrome-products/palindrome-products.spec.coffee @@ -1,36 +1,36 @@ -Palindromes = require('./palindromes') +Palindromes = require './palindrome-products' -describe "Palindrome", -> +describe 'Palindrome', -> - it "largest palindrome from single digit factors", -> + it 'largest palindrome from single digit factors', -> palindromes = new Palindromes({maxFactor: 9}) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(9) expect([[[3, 3], [1, 9]], [[1, 9], [3, 3]]]).toContain(largest.factors) - xit "largest palindrome from double digit factors", -> + xit 'largest palindrome from double digit factors', -> palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 }) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(9009) expect(largest.factors).toEqual([[91, 99]]) - xit "smallest palindrome from double digit factors", -> + xit 'smallest palindrome from double digit factors', -> palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 }) palindromes.generate() smallest = palindromes.smallest() expect(smallest.value).toEqual(121) expect(smallest.factors).toEqual([[11, 11]]) - xit "largest palindrome from triple digit factors", -> + xit 'largest palindrome from triple digit factors', -> palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 }) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(906609) expect(largest.factors).toEqual([[913, 993]]) - xit "smallest palindrome from triple digit factors", -> + xit 'smallest palindrome from triple digit factors', -> palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 }) palindromes.generate() smallest = palindromes.smallest() diff --git a/exercises/pascals-triangle/pascal-triangle-spec.coffee b/exercises/pascals-triangle/pascals-triangle.spec.coffee similarity index 95% rename from exercises/pascals-triangle/pascal-triangle-spec.coffee rename to exercises/pascals-triangle/pascals-triangle.spec.coffee index af441c13..180b4d15 100644 --- a/exercises/pascals-triangle/pascal-triangle-spec.coffee +++ b/exercises/pascals-triangle/pascals-triangle.spec.coffee @@ -1,4 +1,4 @@ -Pascal = require './example.coffee' +Pascal = require './pascals-triangle' describe 'Pascal', -> it 'with one row', -> @@ -24,4 +24,3 @@ describe 'Pascal', -> xit 'should equal 20th row', -> arr = new Pascal(20) expect(arr.array[19]).toEqual [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1] - diff --git a/exercises/queen-attack/queen_attack.spec.coffee b/exercises/queen-attack/queen-attack.spec.coffee similarity index 58% rename from exercises/queen-attack/queen_attack.spec.coffee rename to exercises/queen-attack/queen-attack.spec.coffee index 38ff743b..b62785e6 100644 --- a/exercises/queen-attack/queen_attack.spec.coffee +++ b/exercises/queen-attack/queen-attack.spec.coffee @@ -1,59 +1,58 @@ -Queens = require './queens' +Queens = require './queen-attack' -describe "Queens", -> - it "has the correct default positions", -> +describe 'Queens', -> + it 'has the correct default positions', -> queens = new Queens expect(queens.white).toEqual([0,3]) expect(queens.black).toEqual([7,3]) - xit "initialized with specific placement", -> + xit 'initialized with specific placement', -> queens = new Queens({white: [3,7], black: [6,1] }) expect(queens.white).toEqual([3, 7]) expect(queens.black).toEqual([6, 1]) - xit "cannot occupy the same space", -> + xit 'cannot occupy the same space', -> positioning = { white: [2,4], black: [2,4] } - expect(-> new Queens(positioning)).toThrow("Queens cannot share the same space") + expect(-> new Queens(positioning)).toThrow('Queens cannot share the same space') - xit "toString representation", -> + xit 'toString representation', -> positioning = {white: [2, 4], black: [6, 6]} queens = new Queens(positioning) - board = "_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n" + - "_ _ W _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ B _\n_ _ _ _ _ _ _ _" + board = '_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n' + + '_ _ W _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ B _\n_ _ _ _ _ _ _ _' expect(queens.toString()).toEqual(board) - xit "queens cannot attack", -> + xit 'queens cannot attack', -> queens = new Queens({ white: [2,3], black: [4,7] }) expect(queens.canAttack()).toEqual(false) - xit "queens can attack when they are on the same row", -> + xit 'queens can attack when they are on the same row', -> queens = new Queens({ white: [2,4], black: [2,7] }) expect(queens.canAttack()).toEqual(true) - xit "queens can attack when they are on the same column", -> + xit 'queens can attack when they are on the same column', -> queens = new Queens({ white: [5,4], black: [2,4] }) expect(queens.canAttack()).toEqual(true) - xit "queens can attack diagonally", -> + xit 'queens can attack diagonally', -> queens = new Queens({ white: [1, 1], black: [6, 6] }) expect(queens.canAttack()).toEqual(true) - xit "queens can attack another diagonally", -> + xit 'queens can attack another diagonally', -> queens = new Queens({ white: [0, 6], black: [1, 7] }) expect(queens.canAttack()).toEqual(true) - xit "queens can attack yet another diagonally", -> + xit 'queens can attack yet another diagonally', -> queens = new Queens({ white: [4, 1], black: [6, 3] }) expect(queens.canAttack()).toEqual(true) - xit "queens can attack yet yet another diagonally", -> + xit 'queens can attack yet yet another diagonally', -> queens = new Queens({ white: [6, 1], black: [1, 6] }) expect(queens.canAttack()).toEqual(true) - diff --git a/exercises/triangle/triangle.spec.coffee b/exercises/triangle/triangle.spec.coffee index a36be19b..664691dd 100644 --- a/exercises/triangle/triangle.spec.coffee +++ b/exercises/triangle/triangle.spec.coffee @@ -1,6 +1,6 @@ Triangle = require './triangle' -describe "Triangle", -> +describe 'Triangle', -> it 'is equilateral with equal sides', -> triangle = new Triangle(2,2,2) expect(triangle.kind()).toBe 'equilateral' @@ -42,13 +42,13 @@ describe "Triangle", -> expect(triangle.kind()).toBe 'scalene' xit 'is illegal when a side is negative', -> - expect(-> new Triangle(2,3,-5)).toThrow("negative sides are illegal") + expect(-> new Triangle(2,3,-5)).toThrow('negative sides are illegal') xit 'is illegal when violating triangle inequality', -> - expect(-> new Triangle(1,1,3)).toThrow("violation of triangle inequality") + expect(-> new Triangle(1,1,3)).toThrow('violation of triangle inequality') xit 'is illegal when violating triangle inequality 2', -> - expect(-> new Triangle(2,2,5)).toThrow("violation of triangle inequality") + expect(-> new Triangle(2,2,5)).toThrow('violation of triangle inequality') xit 'is illegal when violating triangle inequality 3', -> - expect(-> new Triangle(7,3,2)).toThrow("violation of triangle inequality") + expect(-> new Triangle(7,3,2)).toThrow('violation of triangle inequality') diff --git a/exercises/word-count/word-count.spec.coffee b/exercises/word-count/word-count.spec.coffee index 134ae701..17f1fe75 100644 --- a/exercises/word-count/word-count.spec.coffee +++ b/exercises/word-count/word-count.spec.coffee @@ -1,20 +1,20 @@ -Words = require "./words" +Words = require './word-count' -describe "Words", -> - it "counts one word", -> - words = new Words "word" +describe 'Words', -> + it 'counts one word', -> + words = new Words 'word' expect(words.count()).toEqual word: 1 - xit "counts one of each", -> - words = new Words "one of each" + xit 'counts one of each', -> + words = new Words 'one of each' expect(words.count()).toEqual one: 1 of: 1 each: 1 - xit "counts multiple occurrences", -> - words = new Words "one fish two fish red fish blue fish" + xit 'counts multiple occurrences', -> + words = new Words 'one fish two fish red fish blue fish' expect(words.count()).toEqual one: 1 fish: 4 @@ -22,8 +22,8 @@ describe "Words", -> red: 1 blue: 1 - xit "ignores punctuation", -> - words = new Words "car : carpet as java : javascript!!&@$%^&" + xit 'ignores punctuation', -> + words = new Words 'car : carpet as java : javascript!!&@$%^&' expect(words.count()).toEqual car: 1 carpet: 1 @@ -31,14 +31,14 @@ describe "Words", -> java: 1 javascript: 1 - xit "includes numbers", -> - words = new Words "testing, 1, 2 testing" + xit 'includes numbers', -> + words = new Words 'testing, 1, 2 testing' expect(words.count()).toEqual testing: 2 1: 1 2: 1 - xit "normalizes case", -> - words = new Words "go Go GO" + xit 'normalizes case', -> + words = new Words 'go Go GO' expect(words.count()).toEqual go: 3 From d39d0c89e599cde9d16d4b41e6ff08cf886db22c Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:36:15 +1000 Subject: [PATCH 12/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4148e66..fec3e578 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# xCoffeeScript +# CoffeeScript Exercism exercises in CoffeeScript From aa9af63f786d354846ef02deba3f8fc91672d873 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:33:34 +1000 Subject: [PATCH 13/43] accumulate stub file --- exercises/accumulate/accumulate.coffee | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 exercises/accumulate/accumulate.coffee diff --git a/exercises/accumulate/accumulate.coffee b/exercises/accumulate/accumulate.coffee new file mode 100644 index 00000000..0b4171f8 --- /dev/null +++ b/exercises/accumulate/accumulate.coffee @@ -0,0 +1,3 @@ +# This is a stub file for the CoffeeScript track + +Array::accumulate = (args) -> From e732d8fa26f1de308c01a91c97040cb3ceff1d5f Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:34:38 +1000 Subject: [PATCH 14/43] Anagram stub file --- exercises/anagram/anagram.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 exercises/anagram/anagram.coffee diff --git a/exercises/anagram/anagram.coffee b/exercises/anagram/anagram.coffee new file mode 100644 index 00000000..842096d3 --- /dev/null +++ b/exercises/anagram/anagram.coffee @@ -0,0 +1,8 @@ +# This is a stub file for the CoffeeScript track + +class Anagram + constructor: (args) -> + + match: (targets) -> + +module.exports = Anagram From 55aa8adc81e28f59616020385bde29f674c91e05 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Sat, 25 Jan 2020 15:35:25 +1000 Subject: [PATCH 15/43] Atbash stub file --- exercises/atbash-cipher/atbash.coffee | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 exercises/atbash-cipher/atbash.coffee diff --git a/exercises/atbash-cipher/atbash.coffee b/exercises/atbash-cipher/atbash.coffee new file mode 100644 index 00000000..d5197af8 --- /dev/null +++ b/exercises/atbash-cipher/atbash.coffee @@ -0,0 +1,5 @@ +class Atbash + + @encode: (args) -> + +module.exports = Atbash From bce3e811e557d78b59ff4575564c05cd4795bed1 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:38:15 +1000 Subject: [PATCH 16/43] fix conflict --- exercises/beer-song/beer-song.coffee | 7 +++++++ exercises/beer-song/beer-song.spec.coffee | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 exercises/beer-song/beer-song.coffee diff --git a/exercises/beer-song/beer-song.coffee b/exercises/beer-song/beer-song.coffee new file mode 100644 index 00000000..8a3bbadb --- /dev/null +++ b/exercises/beer-song/beer-song.coffee @@ -0,0 +1,7 @@ +class Atbash + + @verse: (args) -> + + @sing: (args) -> + +module.exports = Atbash diff --git a/exercises/beer-song/beer-song.spec.coffee b/exercises/beer-song/beer-song.spec.coffee index e54882bc..f1b8c562 100644 --- a/exercises/beer-song/beer-song.spec.coffee +++ b/exercises/beer-song/beer-song.spec.coffee @@ -45,4 +45,8 @@ describe 'Beer', -> No more bottles of beer on the wall, no more bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. +<<<<<<< HEAD:exercises/beer-song/beer-song.spec.coffee ' +======= + """ +>>>>>>> beer-song stub file:exercises/beer-song/beer-song_test.spec.coffee From 6dcf60e9fee001c2e5f92b52900ba2914ff98ce2 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:42:36 +1000 Subject: [PATCH 17/43] binary stub file --- exercises/atbash-cipher/atbash.coffee | 3 ++- exercises/beer-song/beer-song.coffee | 3 ++- exercises/binary/binary.coffee | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 exercises/binary/binary.coffee diff --git a/exercises/atbash-cipher/atbash.coffee b/exercises/atbash-cipher/atbash.coffee index d5197af8..6e63fe0f 100644 --- a/exercises/atbash-cipher/atbash.coffee +++ b/exercises/atbash-cipher/atbash.coffee @@ -1,5 +1,6 @@ -class Atbash +# This is a stub file for the CoffeeScript track +class Atbash @encode: (args) -> module.exports = Atbash diff --git a/exercises/beer-song/beer-song.coffee b/exercises/beer-song/beer-song.coffee index 8a3bbadb..42f81569 100644 --- a/exercises/beer-song/beer-song.coffee +++ b/exercises/beer-song/beer-song.coffee @@ -1,5 +1,6 @@ -class Atbash +# This is a stub file for the CoffeeScript track +class Atbash @verse: (args) -> @sing: (args) -> diff --git a/exercises/binary/binary.coffee b/exercises/binary/binary.coffee new file mode 100644 index 00000000..5a069d2c --- /dev/null +++ b/exercises/binary/binary.coffee @@ -0,0 +1,6 @@ +# This is a stub file for the CoffeeScript track + +class Binary + constructor: (args) -> + + @toDecimal: -> From 0f78635e582856ca0752e2006a1f648a60193445 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:43:59 +1000 Subject: [PATCH 18/43] binary-search-tree stub file --- .../binary-search-tree.spec.coffee | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/exercises/binary-search-tree/binary-search-tree.spec.coffee b/exercises/binary-search-tree/binary-search-tree.spec.coffee index 25081944..f768c67d 100644 --- a/exercises/binary-search-tree/binary-search-tree.spec.coffee +++ b/exercises/binary-search-tree/binary-search-tree.spec.coffee @@ -1,4 +1,4 @@ -Bst = require './binary-search-tree' +BST = require './binary-search-tree' recordAllData = (bst) -> out = [] @@ -8,31 +8,31 @@ recordAllData = (bst) -> describe 'BinarySearchTree', -> it 'data is retained', -> - expect(4).toEqual new Bst(4).data + expect(4).toEqual new BST(4).data xit 'inserting less', -> - four = new Bst(4) + four = new BST(4) four.insert(2) expect(four.data).toEqual 4 expect(four.left.data).toEqual 2 xit 'inserting same', -> - four = new Bst(4) + four = new BST(4) four.insert(4) expect(four.data).toEqual 4 expect(four.left.data).toEqual 4 xit 'inserting right', -> - four = new Bst(4) + four = new BST(4) four.insert(5) expect(four.data).toEqual 4 expect(four.right.data).toEqual xit 'complex tree', -> - four = new Bst(4) + four = new BST(4) four.insert(2) four.insert(6) four.insert(1) @@ -49,22 +49,22 @@ describe 'BinarySearchTree', -> expect(four.right.right.data).toEqual 7 xit 'iterating one element', -> - expect(recordAllData(new Bst(4))).toEqual [4] + expect(recordAllData(new BST(4))).toEqual [4] xit 'iterating over smaller element', -> - four = new Bst(4) + four = new BST(4) four.insert(2) expect(recordAllData(four)).toEqual [2, 4] xit 'iterating over larger element', -> - four = new Bst(4) + four = new BST(4) four.insert(5) expect(recordAllData(four)).toEqual [4, 5] xit 'iterating over complex tree', -> - four = new Bst(4) + four = new BST(4) four.insert(2) four.insert(1) four.insert(3) From 9ae3a594db9a564cd1e415c55889725f756e9b4d Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:44:48 +1000 Subject: [PATCH 19/43] binary-search-tree stub file --- exercises/binary-search-tree/binary-search-tree.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 exercises/binary-search-tree/binary-search-tree.coffee diff --git a/exercises/binary-search-tree/binary-search-tree.coffee b/exercises/binary-search-tree/binary-search-tree.coffee new file mode 100644 index 00000000..c81ddb0f --- /dev/null +++ b/exercises/binary-search-tree/binary-search-tree.coffee @@ -0,0 +1,9 @@ +# This is a stub file for the CoffeeScript track +class BST + constructor: (args) -> + + @insert: (args) -> + + @data: -> + +module.exports = BST From 5284d18b9760af27f68f9ee7ea8f46123f4a78bc Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:44:54 +1000 Subject: [PATCH 20/43] bob stub file --- exercises/bob/bob.coffee | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 exercises/bob/bob.coffee diff --git a/exercises/bob/bob.coffee b/exercises/bob/bob.coffee new file mode 100644 index 00000000..6fa2dd90 --- /dev/null +++ b/exercises/bob/bob.coffee @@ -0,0 +1,4 @@ +class Bob + hey: (args) -> + +module.exports = Bob From ca63f80ef895e11d6e862d6a6bff3afe0d9ddb08 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:45:53 +1000 Subject: [PATCH 21/43] hello-world stub file --- exercises/hello-world/hello-world.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/hello-world/hello-world.coffee b/exercises/hello-world/hello-world.coffee index 7f253da3..09c28c85 100644 --- a/exercises/hello-world/hello-world.coffee +++ b/exercises/hello-world/hello-world.coffee @@ -1,5 +1,4 @@ -# Simply return the string 'Hello, World!' - +# This is a stub file for the CoffeeScript track class HelloWorld hello: -> '' From 8b932da5caef140b68280a842123a7eaf409e0d2 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:47:15 +1000 Subject: [PATCH 22/43] hexadecimal stub file --- exercises/hexadecimal/hexadecimal.coffee | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 exercises/hexadecimal/hexadecimal.coffee diff --git a/exercises/hexadecimal/hexadecimal.coffee b/exercises/hexadecimal/hexadecimal.coffee new file mode 100644 index 00000000..c78c6d3b --- /dev/null +++ b/exercises/hexadecimal/hexadecimal.coffee @@ -0,0 +1,7 @@ +# This is a stub file for the CoffeeScript track +class Hexadecimal + constructor: (args) -> + + toDecimal: (args) -> + +module.exports = Hexadecimal From a3b261e0f1db9f31e3cb9e5e2f1b8091b0600e20 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:48:08 +1000 Subject: [PATCH 23/43] fix binary --- exercises/binary/binary.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/binary/binary.coffee b/exercises/binary/binary.coffee index 5a069d2c..6203cc6a 100644 --- a/exercises/binary/binary.coffee +++ b/exercises/binary/binary.coffee @@ -3,4 +3,4 @@ class Binary constructor: (args) -> - @toDecimal: -> + toDecimal: -> From d14a7d7caf5a2ac614d5bd8d7e4765329739bfe3 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:48:36 +1000 Subject: [PATCH 24/43] fix atbash-cipher --- exercises/atbash-cipher/{atbash.coffee => atbash-cipher.coffee} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename exercises/atbash-cipher/{atbash.coffee => atbash-cipher.coffee} (80%) diff --git a/exercises/atbash-cipher/atbash.coffee b/exercises/atbash-cipher/atbash-cipher.coffee similarity index 80% rename from exercises/atbash-cipher/atbash.coffee rename to exercises/atbash-cipher/atbash-cipher.coffee index 6e63fe0f..4b2582ca 100644 --- a/exercises/atbash-cipher/atbash.coffee +++ b/exercises/atbash-cipher/atbash-cipher.coffee @@ -1,6 +1,6 @@ # This is a stub file for the CoffeeScript track class Atbash - @encode: (args) -> + encode: (args) -> module.exports = Atbash From 03ded411b5f82e252b1685eb3411ad7d6b8eca19 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:49:05 +1000 Subject: [PATCH 25/43] fix beer-song --- exercises/beer-song/beer-song.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/beer-song/beer-song.coffee b/exercises/beer-song/beer-song.coffee index 42f81569..f9032b46 100644 --- a/exercises/beer-song/beer-song.coffee +++ b/exercises/beer-song/beer-song.coffee @@ -1,8 +1,8 @@ # This is a stub file for the CoffeeScript track -class Atbash - @verse: (args) -> +class Beer + verse: (args) -> - @sing: (args) -> + sing: (args) -> -module.exports = Atbash +module.exports = Beer From 512800f8d10316d21d90b6bbf6ada9e7f9fbe696 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:49:13 +1000 Subject: [PATCH 26/43] fix binary --- exercises/binary/binary.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/binary/binary.coffee b/exercises/binary/binary.coffee index 6203cc6a..16a062d1 100644 --- a/exercises/binary/binary.coffee +++ b/exercises/binary/binary.coffee @@ -4,3 +4,5 @@ class Binary constructor: (args) -> toDecimal: -> + +module.exports = Binary From c7b0e479b3423a338da6d13b715021ab1b6dc55f Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:49:51 +1000 Subject: [PATCH 27/43] fix binary-search-tree --- exercises/binary-search-tree/binary-search-tree.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/binary-search-tree/binary-search-tree.coffee b/exercises/binary-search-tree/binary-search-tree.coffee index c81ddb0f..9b22f0ed 100644 --- a/exercises/binary-search-tree/binary-search-tree.coffee +++ b/exercises/binary-search-tree/binary-search-tree.coffee @@ -2,8 +2,8 @@ class BST constructor: (args) -> - @insert: (args) -> + insert: (args) -> - @data: -> + data: -> module.exports = BST From a99d8e811c431795c19a5d2287b6430f5b53116d Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:50:18 +1000 Subject: [PATCH 28/43] fix beer-song --- exercises/beer-song/beer-song.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/beer-song/beer-song.coffee b/exercises/beer-song/beer-song.coffee index f9032b46..5a3ac0a4 100644 --- a/exercises/beer-song/beer-song.coffee +++ b/exercises/beer-song/beer-song.coffee @@ -1,8 +1,8 @@ # This is a stub file for the CoffeeScript track -class Beer +class BeerSong verse: (args) -> sing: (args) -> -module.exports = Beer +module.exports = BeerSong From 49a7986e41cbfc6e332bfa03d6d4be65ed3f1301 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:50:28 +1000 Subject: [PATCH 29/43] fix atbash-cipher --- exercises/atbash-cipher/atbash-cipher.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/atbash-cipher/atbash-cipher.coffee b/exercises/atbash-cipher/atbash-cipher.coffee index 4b2582ca..502ad1cb 100644 --- a/exercises/atbash-cipher/atbash-cipher.coffee +++ b/exercises/atbash-cipher/atbash-cipher.coffee @@ -1,6 +1,6 @@ # This is a stub file for the CoffeeScript track -class Atbash +class AtbashCipher encode: (args) -> -module.exports = Atbash +module.exports = AtbashCipher From 06c96ec8e085f52aa8b7ab63e21f44cedf97e17f Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:51:00 +1000 Subject: [PATCH 30/43] fix binary-search-tree --- .../binary-search-tree.coffee | 4 ++-- .../binary-search-tree.spec.coffee | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/exercises/binary-search-tree/binary-search-tree.coffee b/exercises/binary-search-tree/binary-search-tree.coffee index 9b22f0ed..e843b0e9 100644 --- a/exercises/binary-search-tree/binary-search-tree.coffee +++ b/exercises/binary-search-tree/binary-search-tree.coffee @@ -1,9 +1,9 @@ # This is a stub file for the CoffeeScript track -class BST +class BinarySearchTree constructor: (args) -> insert: (args) -> data: -> -module.exports = BST +module.exports = BinarySearchTree diff --git a/exercises/binary-search-tree/binary-search-tree.spec.coffee b/exercises/binary-search-tree/binary-search-tree.spec.coffee index f768c67d..03856b5d 100644 --- a/exercises/binary-search-tree/binary-search-tree.spec.coffee +++ b/exercises/binary-search-tree/binary-search-tree.spec.coffee @@ -1,4 +1,4 @@ -BST = require './binary-search-tree' +BinarySearchTree = require './binary-search-tree' recordAllData = (bst) -> out = [] @@ -8,31 +8,31 @@ recordAllData = (bst) -> describe 'BinarySearchTree', -> it 'data is retained', -> - expect(4).toEqual new BST(4).data + expect(4).toEqual new BinarySearchTree(4).data xit 'inserting less', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(2) expect(four.data).toEqual 4 expect(four.left.data).toEqual 2 xit 'inserting same', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(4) expect(four.data).toEqual 4 expect(four.left.data).toEqual 4 xit 'inserting right', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(5) expect(four.data).toEqual 4 expect(four.right.data).toEqual xit 'complex tree', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(2) four.insert(6) four.insert(1) @@ -49,22 +49,22 @@ describe 'BinarySearchTree', -> expect(four.right.right.data).toEqual 7 xit 'iterating one element', -> - expect(recordAllData(new BST(4))).toEqual [4] + expect(recordAllData(new BinarySearchTree(4))).toEqual [4] xit 'iterating over smaller element', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(2) expect(recordAllData(four)).toEqual [2, 4] xit 'iterating over larger element', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(5) expect(recordAllData(four)).toEqual [4, 5] xit 'iterating over complex tree', -> - four = new BST(4) + four = new BinarySearchTree(4) four.insert(2) four.insert(1) four.insert(3) From dd61665fe5700bdf3e048d0e408ba493b88a13bd Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:57:04 +1000 Subject: [PATCH 31/43] linked-list stub file --- exercises/linked-list/linked-list.spec.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exercises/linked-list/linked-list.spec.coffee b/exercises/linked-list/linked-list.spec.coffee index cdf23717..930c7cdb 100644 --- a/exercises/linked-list/linked-list.spec.coffee +++ b/exercises/linked-list/linked-list.spec.coffee @@ -4,6 +4,7 @@ describe 'LinkedList', -> it 'init', -> list = new LinkedList() expect(list.count).toBe 0 + xit 'push/pop', -> list = new LinkedList() list.pushNode(10) @@ -11,12 +12,14 @@ describe 'LinkedList', -> list.pushNode(30) expect(list.popNode()).toBe 30 expect(list.popNode()).toBe 20 + xit 'push/shift', -> list = new LinkedList() list.pushNode(10) list.pushNode(20) expect(list.shiftNode()).toBe 10 expect(list.shiftNode()).toBe 20 + xit 'unshift/shift', -> list = new LinkedList() list.unshiftNode(20) @@ -24,11 +27,13 @@ describe 'LinkedList', -> list.unshiftNode(30) expect(list.shiftNode()).toBe 30 expect(list.shiftNode()).toBe 10 + xit 'unshift/pop', -> list = new LinkedList() list.unshiftNode(20) list.unshiftNode(30) expect(list.popNode()).toBe 20 + xit 'example', -> list = new LinkedList() list.pushNode(10) @@ -44,9 +49,11 @@ describe 'LinkedList', -> list.deleteNode(60) expect(list.countNodes()).toBe 1 expect(list.shiftNode()).toBe 30 + xit 'pops undefined when there are no elements', -> list = new LinkedList() expect(list.popNode()).toBe undefined + xit ' can count its elements', -> list = new LinkedList() list.pushNode(20) @@ -61,6 +68,7 @@ describe 'LinkedList', -> list.deleteNode(10) expect(list.countNodes()).toBe 2 expect(list.shiftNode()).toBe 20 + xit 'deletes only the last element', -> list = new LinkedList() list.pushNode(10) From 332d4206fbce24332eafc31bb186f1fdc3a86f5f Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:57:41 +1000 Subject: [PATCH 32/43] linked-list stub file --- exercises/linked-list/linked-list.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 exercises/linked-list/linked-list.coffee diff --git a/exercises/linked-list/linked-list.coffee b/exercises/linked-list/linked-list.coffee new file mode 100644 index 00000000..3112d8eb --- /dev/null +++ b/exercises/linked-list/linked-list.coffee @@ -0,0 +1,17 @@ +class LinkedList + count: -> + + pushNode: (args) -> + + popNode: (args) -> + + deleteNode: (args) -> + + shiftNode: (args) -> + + unshiftNode: (args) -> + + countNodes: -> + + +module.exports = LinkedList From b30430d4899aeffe347b453900ac679207b23086 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:57:47 +1000 Subject: [PATCH 33/43] luhn stub file --- exercises/luhn/luhn.coffee | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 exercises/luhn/luhn.coffee diff --git a/exercises/luhn/luhn.coffee b/exercises/luhn/luhn.coffee new file mode 100644 index 00000000..d7c04f2e --- /dev/null +++ b/exercises/luhn/luhn.coffee @@ -0,0 +1,7 @@ +class Luhn + constructor: (args) -> + + valid: -> + + +module.exports = Luhn From 22608eccf29716d3071aa0336bf5e9e60d3934dc Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 17:58:45 +1000 Subject: [PATCH 34/43] nth-prime stub file --- exercises/nth-prime/nth-prime.coffee | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 exercises/nth-prime/nth-prime.coffee diff --git a/exercises/nth-prime/nth-prime.coffee b/exercises/nth-prime/nth-prime.coffee new file mode 100644 index 00000000..2e03189a --- /dev/null +++ b/exercises/nth-prime/nth-prime.coffee @@ -0,0 +1,4 @@ +class NthPrime + nth: (args) -> + +module.exports = NthPrime From a00ce02071079fdcd9651d5a15feeee2d39c0d96 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:00:54 +1000 Subject: [PATCH 35/43] nucleotide-count stub file --- .../nucleotide-count/nucleotide-count.coffee | 5 +++++ .../nucleotide-count.spec.coffee | 22 +++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 exercises/nucleotide-count/nucleotide-count.coffee diff --git a/exercises/nucleotide-count/nucleotide-count.coffee b/exercises/nucleotide-count/nucleotide-count.coffee new file mode 100644 index 00000000..845d6e17 --- /dev/null +++ b/exercises/nucleotide-count/nucleotide-count.coffee @@ -0,0 +1,5 @@ +class NucleotideCount + constructor: (args) -> + @nucleotideCounts = + +module.exports = NucleotideCount diff --git a/exercises/nucleotide-count/nucleotide-count.spec.coffee b/exercises/nucleotide-count/nucleotide-count.spec.coffee index b5f80e50..c97ef99a 100644 --- a/exercises/nucleotide-count/nucleotide-count.spec.coffee +++ b/exercises/nucleotide-count/nucleotide-count.spec.coffee @@ -1,25 +1,25 @@ -DNA = require './nucleotide-count' +NucleotideCount = require './nucleotide-count' -describe 'DNA', -> +describe 'NucleotideCount', -> it 'has no nucleotides', -> expected = A: 0 T: 0 C: 0 G: 0 - dna = new DNA('') + dna = new NucleotideCount('') expect(dna.nucleotideCounts).toEqual expected xit 'has no adoenosine', -> - dna = new DNA('') + dna = new NucleotideCount('') expect(dna.count('A')).toEqual 0 xit 'repetitive cytidine gets counts', -> - dna = new DNA('CCCCC') + dna = new NucleotideCount('CCCCC') expect(dna.count('C')).toEqual 5 xit 'repetitive sequence has only gaunosine', -> - dna = new DNA('GGGGGGGG') + dna = new NucleotideCount('GGGGGGGG') expected = A: 0 T: 0 @@ -28,28 +28,28 @@ describe 'DNA', -> expect(dna.nucleotideCounts).toEqual expected xit 'counts only thymidine', -> - dna = new DNA('GGGGTAACCCGG') + dna = new NucleotideCount('GGGGTAACCCGG') expect(dna.count('T')).toEqual 1 xit 'counts a nucleotide only once', -> - dna = new DNA('GGTTGG') + dna = new NucleotideCount('GGTTGG') dna.count('T') expect(dna.count('T')).toEqual 2 xit 'validates strand', -> - dna = new DNA('AGTXCG') + dna = new NucleotideCount('AGTXCG') expect -> dna.count 'G' .toThrow new Error('Invalid nucleotide strand') xit 'validates nucleotides', -> - dna = new DNA('GGTTGG') + dna = new NucleotideCount('GGTTGG') expect -> dna.count 'X' .toThrow new Error('Invalid nucleotide') xit 'counts all nucleotides', -> - dna = new DNA('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC') + dna = new NucleotideCount('AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC') expected = A: 20 T: 21 From fc3ca6d93747eb86fc74b78f6446d1823f1c97b1 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:01:04 +1000 Subject: [PATCH 36/43] nucleotide-count stub file --- exercises/nucleotide-count/nucleotide-count.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/nucleotide-count/nucleotide-count.coffee b/exercises/nucleotide-count/nucleotide-count.coffee index 845d6e17..0e0edd59 100644 --- a/exercises/nucleotide-count/nucleotide-count.coffee +++ b/exercises/nucleotide-count/nucleotide-count.coffee @@ -2,4 +2,6 @@ class NucleotideCount constructor: (args) -> @nucleotideCounts = + count: (args) -> + module.exports = NucleotideCount From 5760e6025faf52caf312f33e7169a6fab4f731da Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:03:53 +1000 Subject: [PATCH 37/43] palindrome-products stub file --- .../palindrome-products/palindrome-products.coffee | 10 ++++++++++ .../palindrome-products.spec.coffee | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 exercises/palindrome-products/palindrome-products.coffee diff --git a/exercises/palindrome-products/palindrome-products.coffee b/exercises/palindrome-products/palindrome-products.coffee new file mode 100644 index 00000000..926f6a7c --- /dev/null +++ b/exercises/palindrome-products/palindrome-products.coffee @@ -0,0 +1,10 @@ +class PalindromeProducts + constructor: (args) -> + + generate: -> + + smallest: -> + + largest: -> + +module.export = PalindromeProducts diff --git a/exercises/palindrome-products/palindrome-products.spec.coffee b/exercises/palindrome-products/palindrome-products.spec.coffee index 8c460f74..8fe0bf8f 100644 --- a/exercises/palindrome-products/palindrome-products.spec.coffee +++ b/exercises/palindrome-products/palindrome-products.spec.coffee @@ -3,35 +3,35 @@ Palindromes = require './palindrome-products' describe 'Palindrome', -> it 'largest palindrome from single digit factors', -> - palindromes = new Palindromes({maxFactor: 9}) + palindromes = new PalindromeProducts({maxFactor: 9}) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(9) expect([[[3, 3], [1, 9]], [[1, 9], [3, 3]]]).toContain(largest.factors) xit 'largest palindrome from double digit factors', -> - palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 }) + palindromes = new PalindromeProducts({ maxFactor: 99, minFactor: 10 }) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(9009) expect(largest.factors).toEqual([[91, 99]]) xit 'smallest palindrome from double digit factors', -> - palindromes = new Palindromes({ maxFactor: 99, minFactor: 10 }) + palindromes = new PalindromeProducts({ maxFactor: 99, minFactor: 10 }) palindromes.generate() smallest = palindromes.smallest() expect(smallest.value).toEqual(121) expect(smallest.factors).toEqual([[11, 11]]) xit 'largest palindrome from triple digit factors', -> - palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 }) + palindromes = new PalindromeProducts({ maxFactor: 999, minFactor: 100 }) palindromes.generate() largest = palindromes.largest() expect(largest.value).toEqual(906609) expect(largest.factors).toEqual([[913, 993]]) xit 'smallest palindrome from triple digit factors', -> - palindromes = new Palindromes({ maxFactor: 999, minFactor: 100 }) + palindromes = new PalindromeProducts({ maxFactor: 999, minFactor: 100 }) palindromes.generate() smallest = palindromes.smallest() expect(smallest.value).toEqual(10201) From 5969f3b0a4caee14994abccc641db9d5a11e4339 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:05:09 +1000 Subject: [PATCH 38/43] pascals-triangle stub file --- exercises/pascals-triangle/pascals-triangle.coffee | 5 +++++ .../pascals-triangle/pascals-triangle.spec.coffee | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 exercises/pascals-triangle/pascals-triangle.coffee diff --git a/exercises/pascals-triangle/pascals-triangle.coffee b/exercises/pascals-triangle/pascals-triangle.coffee new file mode 100644 index 00000000..c59ec36d --- /dev/null +++ b/exercises/pascals-triangle/pascals-triangle.coffee @@ -0,0 +1,5 @@ +class PascalsTriangle + constructor: (args) -> + @array = + +module.exports = PascalsTriangle diff --git a/exercises/pascals-triangle/pascals-triangle.spec.coffee b/exercises/pascals-triangle/pascals-triangle.spec.coffee index 180b4d15..4028a0fc 100644 --- a/exercises/pascals-triangle/pascals-triangle.spec.coffee +++ b/exercises/pascals-triangle/pascals-triangle.spec.coffee @@ -2,25 +2,25 @@ Pascal = require './pascals-triangle' describe 'Pascal', -> it 'with one row', -> - arr = new Pascal(1) + arr = new PascalsTriangle(1) expect(arr.array).toEqual [[1]] xit 'with two rows', -> - arr = new Pascal(2) + arr = new PascalsTriangle(2) expect(arr.array).toEqual [[1], [1,1]] xit 'with three rows', -> - arr = new Pascal(3) + arr = new PascalsTriangle(3) expect(arr.array).toEqual [[1], [1,1], [1,2,1]] xit 'with four rows', -> - arr = new Pascal(4) + arr = new PascalsTriangle(4) expect(arr.array).toEqual [[1], [1,1], [1,2,1], [1,3,3,1]] xit 'with five rows', -> - arr = new Pascal(5) + arr = new PascalsTriangle(5) expect(arr.array).toEqual [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]] xit 'should equal 20th row', -> - arr = new Pascal(20) + arr = new PascalsTriangle(20) expect(arr.array[19]).toEqual [1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1] From 6e3573ec3e0e4da9695b5f2c7c4b7705bc878743 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:06:30 +1000 Subject: [PATCH 39/43] queen-attack stub file --- exercises/queen-attack/queen-attack.coffee | 6 ++++++ exercises/queen-attack/queen-attack.spec.coffee | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 exercises/queen-attack/queen-attack.coffee diff --git a/exercises/queen-attack/queen-attack.coffee b/exercises/queen-attack/queen-attack.coffee new file mode 100644 index 00000000..e0b55a07 --- /dev/null +++ b/exercises/queen-attack/queen-attack.coffee @@ -0,0 +1,6 @@ +class QueenAttack + constructor: (args) -> + @white = + @black = + +module.exports = QueenAttack diff --git a/exercises/queen-attack/queen-attack.spec.coffee b/exercises/queen-attack/queen-attack.spec.coffee index b62785e6..3a891c1d 100644 --- a/exercises/queen-attack/queen-attack.spec.coffee +++ b/exercises/queen-attack/queen-attack.spec.coffee @@ -2,40 +2,40 @@ Queens = require './queen-attack' describe 'Queens', -> it 'has the correct default positions', -> - queens = new Queens + queens = new QueenAttack expect(queens.white).toEqual([0,3]) expect(queens.black).toEqual([7,3]) xit 'initialized with specific placement', -> - queens = new Queens({white: [3,7], black: [6,1] }) + queens = new QueenAttack({white: [3,7], black: [6,1] }) expect(queens.white).toEqual([3, 7]) expect(queens.black).toEqual([6, 1]) xit 'cannot occupy the same space', -> positioning = { white: [2,4], black: [2,4] } - expect(-> new Queens(positioning)).toThrow('Queens cannot share the same space') + expect(-> new QueenAttack(positioning)).toThrow('Queens cannot share the same space') xit 'toString representation', -> positioning = {white: [2, 4], black: [6, 6]} - queens = new Queens(positioning) + queens = new QueenAttack(positioning) board = '_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ _ _\n' + '_ _ W _ _ _ _ _\n_ _ _ _ _ _ _ _\n_ _ _ _ _ _ B _\n_ _ _ _ _ _ _ _' expect(queens.toString()).toEqual(board) xit 'queens cannot attack', -> - queens = new Queens({ white: [2,3], black: [4,7] }) + queens = new QueenAttack({ white: [2,3], black: [4,7] }) expect(queens.canAttack()).toEqual(false) xit 'queens can attack when they are on the same row', -> - queens = new Queens({ white: [2,4], black: [2,7] }) + queens = new QueenAttack({ white: [2,4], black: [2,7] }) expect(queens.canAttack()).toEqual(true) xit 'queens can attack when they are on the same column', -> - queens = new Queens({ white: [5,4], black: [2,4] }) + queens = new QueenAttack({ white: [5,4], black: [2,4] }) expect(queens.canAttack()).toEqual(true) From 71afa64be232744a6967a4541bd6d3426f03e2d8 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:07:22 +1000 Subject: [PATCH 40/43] triangle stub file --- exercises/triangle/triangle.coffee | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 exercises/triangle/triangle.coffee diff --git a/exercises/triangle/triangle.coffee b/exercises/triangle/triangle.coffee new file mode 100644 index 00000000..5816d817 --- /dev/null +++ b/exercises/triangle/triangle.coffee @@ -0,0 +1,6 @@ +class Triangle + constructor: (args) -> + + kind: -> + +module.exports = Triangle From ba02f36b53f49f58365cffd007738c484c5a4385 Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:07:53 +1000 Subject: [PATCH 41/43] trinary stub file --- exercises/trinary/trinary.coffee | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 exercises/trinary/trinary.coffee diff --git a/exercises/trinary/trinary.coffee b/exercises/trinary/trinary.coffee new file mode 100644 index 00000000..a2039910 --- /dev/null +++ b/exercises/trinary/trinary.coffee @@ -0,0 +1,4 @@ +class Trinary + constructor: (args) -> + +module.exports = Trinary From 0dc956a59c37771f4986b72c560fed2c5667d38a Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:08:38 +1000 Subject: [PATCH 42/43] word-count stub file --- exercises/word-count/word-count.coffee | 7 +++++++ exercises/word-count/word-count.spec.coffee | 16 ++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 exercises/word-count/word-count.coffee diff --git a/exercises/word-count/word-count.coffee b/exercises/word-count/word-count.coffee new file mode 100644 index 00000000..ba5f1a47 --- /dev/null +++ b/exercises/word-count/word-count.coffee @@ -0,0 +1,7 @@ +class WordCount + constructor: (args) -> + + count: -> + + +module.exports = WordCount diff --git a/exercises/word-count/word-count.spec.coffee b/exercises/word-count/word-count.spec.coffee index 17f1fe75..339f1ae9 100644 --- a/exercises/word-count/word-count.spec.coffee +++ b/exercises/word-count/word-count.spec.coffee @@ -1,20 +1,20 @@ -Words = require './word-count' +WordCount = require './word-count' -describe 'Words', -> +describe 'WordCount', -> it 'counts one word', -> - words = new Words 'word' + words = new WordCount 'word' expect(words.count()).toEqual word: 1 xit 'counts one of each', -> - words = new Words 'one of each' + words = new WordCount 'one of each' expect(words.count()).toEqual one: 1 of: 1 each: 1 xit 'counts multiple occurrences', -> - words = new Words 'one fish two fish red fish blue fish' + words = new WordCount 'one fish two fish red fish blue fish' expect(words.count()).toEqual one: 1 fish: 4 @@ -23,7 +23,7 @@ describe 'Words', -> blue: 1 xit 'ignores punctuation', -> - words = new Words 'car : carpet as java : javascript!!&@$%^&' + words = new WordCount 'car : carpet as java : javascript!!&@$%^&' expect(words.count()).toEqual car: 1 carpet: 1 @@ -32,13 +32,13 @@ describe 'Words', -> javascript: 1 xit 'includes numbers', -> - words = new Words 'testing, 1, 2 testing' + words = new WordCount 'testing, 1, 2 testing' expect(words.count()).toEqual testing: 2 1: 1 2: 1 xit 'normalizes case', -> - words = new Words 'go Go GO' + words = new WordCount 'go Go GO' expect(words.count()).toEqual go: 3 From e45977e0c68b556c9f58df0a692aa1204f9e65ae Mon Sep 17 00:00:00 2001 From: Adam Morris Date: Mon, 27 Jan 2020 18:09:17 +1000 Subject: [PATCH 43/43] wordy stub file --- exercises/wordy/wordy.coffee | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 exercises/wordy/wordy.coffee diff --git a/exercises/wordy/wordy.coffee b/exercises/wordy/wordy.coffee new file mode 100644 index 00000000..098a910e --- /dev/null +++ b/exercises/wordy/wordy.coffee @@ -0,0 +1,6 @@ +class Wordy + constructor: (args) -> + + answer: -> + +module.exports = Wordy