trackler 2.2.1.25 → 2.2.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/csharp/docs/GENERATORS.md +6 -2
  4. data/tracks/csharp/docs/TESTS.md +2 -20
  5. data/tracks/csharp/exercises/Exercises.sln +557 -554
  6. data/tracks/csharp/exercises/accumulate/Accumulate.csproj +2 -2
  7. data/tracks/csharp/exercises/acronym/Acronym.csproj +2 -2
  8. data/tracks/csharp/exercises/all-your-base/AllYourBase.csproj +2 -2
  9. data/tracks/csharp/exercises/allergies/Allergies.csproj +2 -2
  10. data/tracks/csharp/exercises/alphametics/Alphametics.csproj +2 -2
  11. data/tracks/csharp/exercises/anagram/Anagram.csproj +2 -2
  12. data/tracks/csharp/exercises/atbash-cipher/AtbashCipher.csproj +2 -2
  13. data/tracks/csharp/exercises/bank-account/BankAccount.csproj +2 -2
  14. data/tracks/csharp/exercises/beer-song/BeerSong.csproj +2 -2
  15. data/tracks/csharp/exercises/binary-search-tree/BinarySearchTree.csproj +2 -2
  16. data/tracks/csharp/exercises/binary-search/BinarySearch.csproj +2 -2
  17. data/tracks/csharp/exercises/bob/Bob.csproj +2 -2
  18. data/tracks/csharp/exercises/book-store/BookStore.csproj +2 -2
  19. data/tracks/csharp/exercises/bowling/Bowling.csproj +2 -2
  20. data/tracks/csharp/exercises/bracket-push/BracketPush.csproj +2 -2
  21. data/tracks/csharp/exercises/change/Change.csproj +2 -2
  22. data/tracks/csharp/exercises/circular-buffer/CircularBuffer.csproj +2 -2
  23. data/tracks/csharp/exercises/clock/Clock.csproj +2 -2
  24. data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.csproj +1 -1
  25. data/tracks/csharp/exercises/complex-numbers/ComplexNumbers.csproj +2 -2
  26. data/tracks/csharp/exercises/connect/Connect.csproj +2 -2
  27. data/tracks/csharp/exercises/crypto-square/CryptoSquare.csproj +2 -2
  28. data/tracks/csharp/exercises/custom-set/CustomSet.csproj +2 -2
  29. data/tracks/csharp/exercises/diamond/Diamond.csproj +2 -2
  30. data/tracks/csharp/exercises/difference-of-squares/DifferenceOfSquares.csproj +2 -2
  31. data/tracks/csharp/exercises/diffie-hellman/DiffieHellman.csproj +2 -2
  32. data/tracks/csharp/exercises/dominoes/Dominoes.csproj +2 -2
  33. data/tracks/csharp/exercises/dot-dsl/DotDsl.csproj +2 -2
  34. data/tracks/csharp/exercises/error-handling/ErrorHandling.csproj +2 -2
  35. data/tracks/csharp/exercises/etl/Etl.csproj +2 -2
  36. data/tracks/csharp/exercises/flatten-array/FlattenArray.csproj +2 -2
  37. data/tracks/csharp/exercises/food-chain/FoodChain.csproj +2 -2
  38. data/tracks/csharp/exercises/forth/Forth.csproj +2 -2
  39. data/tracks/csharp/exercises/gigasecond/Gigasecond.csproj +2 -2
  40. data/tracks/csharp/exercises/go-counting/GoCounting.csproj +2 -2
  41. data/tracks/csharp/exercises/grade-school/GradeSchool.csproj +2 -2
  42. data/tracks/csharp/exercises/grains/Grains.csproj +2 -2
  43. data/tracks/csharp/exercises/grep/Grep.csproj +2 -2
  44. data/tracks/csharp/exercises/hamming/Hamming.csproj +2 -2
  45. data/tracks/csharp/exercises/hangman/Hangman.csproj +2 -2
  46. data/tracks/csharp/exercises/hello-world/HelloWorld.csproj +2 -2
  47. data/tracks/csharp/exercises/house/House.csproj +2 -2
  48. data/tracks/csharp/exercises/isogram/Isogram.csproj +2 -2
  49. data/tracks/csharp/exercises/kindergarten-garden/KindergartenGarden.csproj +2 -2
  50. data/tracks/csharp/exercises/largest-series-product/LargestSeriesProduct.csproj +2 -2
  51. data/tracks/csharp/exercises/leap/Leap.csproj +2 -2
  52. data/tracks/csharp/exercises/ledger/Ledger.csproj +2 -2
  53. data/tracks/csharp/exercises/linked-list/LinkedList.csproj +2 -2
  54. data/tracks/csharp/exercises/list-ops/ListOps.csproj +2 -2
  55. data/tracks/csharp/exercises/luhn/Luhn.csproj +2 -2
  56. data/tracks/csharp/exercises/markdown/Markdown.csproj +2 -2
  57. data/tracks/csharp/exercises/matrix/Matrix.csproj +2 -2
  58. data/tracks/csharp/exercises/meetup/Meetup.csproj +2 -2
  59. data/tracks/csharp/exercises/minesweeper/Minesweeper.csproj +2 -2
  60. data/tracks/csharp/exercises/nth-prime/NthPrime.csproj +2 -2
  61. data/tracks/csharp/exercises/nucleotide-count/NucleotideCount.csproj +2 -2
  62. data/tracks/csharp/exercises/ocr-numbers/OcrNumbers.csproj +2 -2
  63. data/tracks/csharp/exercises/palindrome-products/PalindromeProducts.csproj +2 -2
  64. data/tracks/csharp/exercises/pangram/Pangram.csproj +2 -2
  65. data/tracks/csharp/exercises/parallel-letter-frequency/ParallelLetterFrequency.csproj +2 -2
  66. data/tracks/csharp/exercises/pascals-triangle/PascalsTriangle.csproj +2 -2
  67. data/tracks/csharp/exercises/perfect-numbers/PerfectNumbers.csproj +2 -2
  68. data/tracks/csharp/exercises/phone-number/PhoneNumber.csproj +2 -2
  69. data/tracks/csharp/exercises/pig-latin/PigLatin.csproj +2 -2
  70. data/tracks/csharp/exercises/poker/Poker.csproj +2 -2
  71. data/tracks/csharp/exercises/pov/Pov.csproj +2 -2
  72. data/tracks/csharp/exercises/prime-factors/PrimeFactors.csproj +2 -2
  73. data/tracks/csharp/exercises/protein-translation/ProteinTranslation.csproj +2 -2
  74. data/tracks/csharp/exercises/proverb/Proverb.csproj +2 -2
  75. data/tracks/csharp/exercises/pythagorean-triplet/PythagoreanTriplet.csproj +2 -2
  76. data/tracks/csharp/exercises/queen-attack/QueenAttack.csproj +2 -2
  77. data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipher.csproj +2 -2
  78. data/tracks/csharp/exercises/raindrops/Raindrops.csproj +2 -2
  79. data/tracks/csharp/exercises/react/React.csproj +2 -2
  80. data/tracks/csharp/exercises/rectangles/Rectangles.csproj +2 -2
  81. data/tracks/csharp/exercises/rna-transcription/RnaTranscription.csproj +2 -2
  82. data/tracks/csharp/exercises/robot-name/RobotName.csproj +2 -2
  83. data/tracks/csharp/exercises/robot-simulator/RobotSimulator.csproj +2 -2
  84. data/tracks/csharp/exercises/roman-numerals/RomanNumerals.csproj +2 -2
  85. data/tracks/csharp/exercises/rotational-cipher/RotationalCipher.csproj +2 -2
  86. data/tracks/csharp/exercises/run-length-encoding/RunLengthEncoding.csproj +2 -2
  87. data/tracks/csharp/exercises/saddle-points/SaddlePoints.csproj +2 -2
  88. data/tracks/csharp/exercises/say/Say.csproj +2 -2
  89. data/tracks/csharp/exercises/scale-generator/ScaleGenerator.csproj +2 -2
  90. data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.csproj +2 -2
  91. data/tracks/csharp/exercises/secret-handshake/SecretHandshake.csproj +2 -2
  92. data/tracks/csharp/exercises/series/Series.csproj +2 -2
  93. data/tracks/csharp/exercises/sgf-parsing/SgfParsing.csproj +2 -2
  94. data/tracks/csharp/exercises/sieve/Sieve.csproj +2 -2
  95. data/tracks/csharp/exercises/simple-cipher/SimpleCipher.csproj +2 -2
  96. data/tracks/csharp/exercises/simple-linked-list/SimpleLinkedList.csproj +2 -2
  97. data/tracks/csharp/exercises/space-age/SpaceAge.csproj +2 -2
  98. data/tracks/csharp/exercises/strain/Strain.csproj +2 -2
  99. data/tracks/csharp/exercises/sublist/Sublist.csproj +2 -2
  100. data/tracks/csharp/exercises/sum-of-multiples/SumOfMultiples.csproj +2 -2
  101. data/tracks/csharp/exercises/tournament/Tournament.csproj +2 -2
  102. data/tracks/csharp/exercises/transpose/Transpose.csproj +2 -2
  103. data/tracks/csharp/exercises/tree-building/TreeBuilding.csproj +2 -2
  104. data/tracks/csharp/exercises/triangle/Triangle.csproj +2 -2
  105. data/tracks/csharp/exercises/twelve-days/TwelveDays.csproj +2 -2
  106. data/tracks/csharp/exercises/two-bucket/TwoBucket.csproj +2 -2
  107. data/tracks/csharp/exercises/two-fer/TwoFer.csproj +1 -1
  108. data/tracks/csharp/exercises/variable-length-quantity/VariableLengthQuantity.csproj +2 -2
  109. data/tracks/csharp/exercises/word-count/WordCount.csproj +2 -2
  110. data/tracks/csharp/exercises/word-search/WordSearch.csproj +2 -2
  111. data/tracks/csharp/exercises/wordy/Wordy.csproj +2 -2
  112. data/tracks/csharp/exercises/zebra-puzzle/ZebraPuzzle.csproj +2 -2
  113. data/tracks/csharp/exercises/zipper/Zipper.csproj +2 -2
  114. data/tracks/csharp/generators/Generators.csproj +4 -4
  115. data/tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js +5 -0
  116. data/tracks/elixir/config.json +11 -0
  117. data/tracks/elixir/exercises/binary-search-tree/README.md +52 -0
  118. data/tracks/elixir/exercises/binary-search-tree/binary_search_tree.exs +27 -0
  119. data/tracks/elixir/exercises/binary-search-tree/binary_search_tree_test.exs +103 -0
  120. data/tracks/elixir/exercises/binary-search-tree/example.exs +29 -0
  121. data/tracks/elixir/exercises/protein-translation/README.md +4 -4
  122. data/tracks/go/exercises/phone-number/.meta/description.md +34 -0
  123. data/tracks/go/exercises/phone-number/.meta/metadata.yml +4 -0
  124. data/tracks/go/exercises/phone-number/README.md +9 -1
  125. data/tracks/javascript/.gitignore +2 -0
  126. data/tracks/javascript/README.md +2 -2
  127. data/tracks/javascript/config.json +14 -1
  128. data/tracks/javascript/exercises/change/README.md +36 -0
  129. data/tracks/javascript/exercises/change/change.spec.js +73 -0
  130. data/tracks/javascript/exercises/change/example.js +204 -0
  131. data/tracks/lua/config/maintainers.json +5 -5
  132. data/tracks/swift/exercises/allergies/Tests/AllergiesTests/AllergiesTests.swift +7 -1
  133. metadata +11 -2
@@ -10,9 +10,9 @@ Codons: `"AUG", "UUU", "UCU"`
10
10
  => which become a polypeptide with the following sequence =>
11
11
 
12
12
  Protein: `"Methionine", "Phenylalanine", "Serine"`
13
-
13
+
14
14
  There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. If it works for one codon, the program should work for all of them.
15
- However, feel free to expand the list in the test suite to include them all.
15
+ However, feel free to expand the list in the test suite to include them all.
16
16
 
17
17
  There are also four terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated.
18
18
 
@@ -20,7 +20,7 @@ All subsequent codons after are ignored, like this:
20
20
 
21
21
  RNA: `"AUGUUUUCUUAAAUG"` =>
22
22
 
23
- Codons: `"AUG", "UUU", "UCU", "UAG", "AUG"` =>
23
+ Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` =>
24
24
 
25
25
  Protein: `"Methionine", "Phenylalanine", "Serine"`
26
26
 
@@ -39,7 +39,6 @@ UGU, UGC | Cysteine
39
39
  UGG | Tryptophan
40
40
  UAA, UAG, UGA | STOP
41
41
 
42
-
43
42
  Learn more about [protein translation on Wikipedia](http://en.wikipedia.org/wiki/Translation_(biology))
44
43
 
45
44
  ## Running tests
@@ -83,4 +82,5 @@ see the [help page](http://exercism.io/languages/elixir).
83
82
  Tyler Long
84
83
 
85
84
  ## Submitting Incomplete Solutions
85
+
86
86
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,34 @@
1
+ Clean up user-entered phone numbers so that they can be sent SMS messages.
2
+
3
+ The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda. All NANP-countries share the same international country code: `1`.
4
+
5
+ NANP numbers are ten-digit numbers consisting of a three-digit Numbering Plan Area code, commonly known as *area code*, followed by a seven-digit local number. The first three digits of the local number represent the *exchange code*, followed by the unique four-digit number which is the *subscriber number*.
6
+
7
+
8
+ The format is usually represented as
9
+ ```
10
+ (NXX)-NXX-XXXX
11
+ ```
12
+ where `N` is any digit from 2 through 9 and `X` is any digit from 0 through 9.
13
+
14
+ Your task is to clean up differently formated telephone numbers by removing punctuation and the country code (1) if present.
15
+
16
+ For example, the inputs
17
+ - `+1 (613)-995-0253`
18
+ - `613-995-0253`
19
+ - `1 613 995 0253`
20
+ - `613.995.0253`
21
+
22
+ should all produce the output below from a Number() function.
23
+
24
+ `6139950253`
25
+
26
+ Additionally, a Format() function should produce the output
27
+
28
+ `(613) 995-0253`
29
+
30
+ and an AreaCode() function should output
31
+
32
+ `613`
33
+
34
+ **Note:** As this exercise only deals with telephone numbers used in NANP-countries, only 1 is considered a valid country code.
@@ -0,0 +1,4 @@
1
+ ---
2
+ blurb: "Clean up user-entered phone numbers so that they can be sent SMS messages."
3
+ source: "Event Manager by JumpstartLab"
4
+ source_url: "http://tutorials.jumpstartlab.com/projects/eventmanager.html"
@@ -21,10 +21,18 @@ For example, the inputs
21
21
  - `1 613 995 0253`
22
22
  - `613.995.0253`
23
23
 
24
- should all produce the output
24
+ should all produce the output below from a Number() function.
25
25
 
26
26
  `6139950253`
27
27
 
28
+ Additionally, a Format() function should produce the output
29
+
30
+ `(613) 995-0253`
31
+
32
+ and an AreaCode() function should output
33
+
34
+ `613`
35
+
28
36
  **Note:** As this exercise only deals with telephone numbers used in NANP-countries, only 1 is considered a valid country code.
29
37
 
30
38
  ## Running the tests
@@ -6,3 +6,5 @@ tmp
6
6
  bin/configlet
7
7
  bin/configlet.exe
8
8
  .idea
9
+
10
+ *.js~
@@ -1,4 +1,4 @@
1
- # xJavaScript [![Build Status](https://travis-ci.org/exercism/xjavascript.svg?branch=master)](https://travis-ci.org/exercism/xjavascript)
1
+ # JavaScript [![Build Status](https://travis-ci.org/exercism/javascript.svg?branch=master)](https://travis-ci.org/exercism/javascript)
2
2
 
3
3
  Exercism exercises in JavaScript
4
4
 
@@ -8,7 +8,7 @@ To run the tests, you'll need NodeJS and Jasmine. For information about how to i
8
8
 
9
9
  ## Running Unit Test Suite
10
10
 
11
- The following commands assume that you are in the 'xjavascript' directory:
11
+ The following commands assume that you are in the 'javascript' directory:
12
12
 
13
13
  ### All Assignments
14
14
 
@@ -1029,6 +1029,19 @@
1029
1029
  "unlocked_by": "linked-list",
1030
1030
  "uuid": "c21ab6e8-b845-49d0-a2f6-1c89c7a07626"
1031
1031
  },
1032
+ {
1033
+ "core" : false,
1034
+ "difficulty" : 8,
1035
+ "slug" : "change",
1036
+ "topics": [
1037
+ "Algorithms",
1038
+ "Mathematics",
1039
+ "Performance",
1040
+ "Searching"
1041
+ ],
1042
+ "unlocked_by": "prime-factors",
1043
+ "uuid" : "910fe904-7e3c-11e7-bb31-be2e44b06b34"
1044
+ },
1032
1045
  {
1033
1046
  "deprecated": true,
1034
1047
  "slug": "nucleotide-count",
@@ -1043,4 +1056,4 @@
1043
1056
  "foregone": [],
1044
1057
  "language": "JavaScript",
1045
1058
  "test_pattern": ".*[.]spec[.]js$"
1046
- }
1059
+ }
@@ -0,0 +1,36 @@
1
+ # Change
2
+
3
+ Correctly determine the change to be given using the least number of coins.
4
+
5
+ The solution will need to accept a value of change to be given and an array of
6
+ coin denominations. The program returns the array of coin denominations to
7
+ produce the correct amount of change. For example, if change for 37 cents
8
+ is required from coins with the denominations of 1, 5, 10 and 25 then the
9
+ result is an array with the values: 1, 1, 10 and 25.
10
+
11
+ ## Setup
12
+
13
+ Go through the setup instructions for JavaScript to
14
+ install the necessary dependencies:
15
+
16
+ http://exercism.io/languages/javascript
17
+
18
+ ## Making the Test Suite Pass
19
+
20
+ Execute the tests with:
21
+
22
+ jasmine <exercise-name>.spec.js
23
+
24
+ Replace `<exercise-name>` with the name of the current exercise. E.g., to
25
+ test the Hello World exercise:
26
+
27
+ jasmine hello-world.spec.js
28
+
29
+ In many test suites all but the first test have been skipped.
30
+
31
+ Once you get a test passing, you can unskip the next one by
32
+ changing `xit` to `it`.
33
+
34
+
35
+ ## Submitting Incomplete Solutions
36
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,73 @@
1
+
2
+
3
+
4
+ var Change =require('./change');
5
+
6
+ describe('Change', function() {
7
+
8
+ it('change for 1 cent',function() {
9
+ var change= new Change();
10
+ var result = change.calculate([1,5, 10, 25],1);
11
+ expect(result).toEqual([1]);
12
+ });
13
+
14
+ xit('return a single coin',function() {
15
+ var change= new Change();
16
+ var result = change.calculate([1,5, 10, 25, 100],25);
17
+ expect(result).toEqual([25]);
18
+ });
19
+
20
+ xit('multiple coins coin',function() {
21
+ var change= new Change();
22
+ var result = change.calculate([1,5, 10, 25, 100],15);
23
+ expect(result).toEqual([5, 10]);
24
+ });
25
+
26
+ xit('test with Lillipution Currency where a greedy algorithm fails',function() {
27
+ // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
28
+ var change= new Change();
29
+ var result = change.calculate([1, 4, 15, 20, 50],23);
30
+ expect(result).toEqual([4,4,15]);
31
+ });
32
+
33
+ xit('test with lower Elbonian Currency where a greedy algorithm fails',function() {
34
+ // https://en.wikipedia.org/wiki/Change-making_problem#Greedy_method
35
+ var change= new Change();
36
+ var result = change.calculate([1, 5, 10, 21, 25],63);
37
+ expect(result).toEqual([21, 21, 21]);
38
+ });
39
+
40
+ xit('test large amount of change',function() {
41
+ var change= new Change();
42
+ var result = change.calculate([1, 2, 5, 10, 20, 50 , 100], 999);
43
+ expect(result).toEqual([2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100]);
44
+ });
45
+
46
+ xit('test zero change',function() {
47
+ var change= new Change();
48
+ var result = change.calculate([1, 5, 10, 21, 25], 0);
49
+ expect(result).toEqual([]);
50
+ });
51
+
52
+ xit('test less than the smallest currency represented',function() {
53
+ var change= new Change();
54
+ var message = 'The total 3 cannot be represented in the given currency.';
55
+ var test=function(){return change.calculate([5,10],3);};
56
+ expect(test).toThrowError(Error,message);
57
+ });
58
+
59
+ xit('test a large value that the currency cannot represent',function() {
60
+ var change= new Change();
61
+ var message ='The total 94 cannot be represented in the given currency.';
62
+ var test=function(){return change.calculate([5,10], 94);};
63
+ expect(test).toThrowError(Error,message);
64
+ });
65
+
66
+ xit('negative change is rejected',function() {
67
+ var change= new Change();
68
+ var message = 'Negative totals are not allowed.';
69
+ var test = function(){return change.calculate([1,2,5],-5);};
70
+ expect(test).toThrowError(Error, message);
71
+ });
72
+
73
+ });
@@ -0,0 +1,204 @@
1
+ "use strict"
2
+
3
+
4
+ var Change = function()
5
+ {
6
+
7
+
8
+ }
9
+
10
+ module.exports=Change;
11
+
12
+
13
+ //data structure to hold each candidate solution that is generated
14
+ var Candidate = function()
15
+ {
16
+
17
+ var searched=false;
18
+ var coins=[];
19
+
20
+ this.Searched =function()
21
+ {
22
+ searched=true;
23
+ }
24
+
25
+ this.isSearched = function()
26
+ {
27
+ return searched;
28
+ }
29
+
30
+ this.getCoins = function()
31
+ {
32
+ return coins;
33
+ }
34
+
35
+ this.addCoin = function(coin)
36
+ {
37
+ function sortNum(a,b)
38
+ {
39
+ return a-b;
40
+ }
41
+
42
+ coins.push(coin);
43
+ coins.sort(sortNum);
44
+
45
+ }
46
+
47
+ this.getCoinCount=function()
48
+ {
49
+ return coins.length;
50
+ }
51
+
52
+ this.getSum=function()
53
+ {
54
+ function getSum(total, num){return total+num;}
55
+ return coins.reduce(getSum);
56
+ }
57
+
58
+
59
+ }
60
+
61
+ Change.prototype.calculate=function(coinArray, target)
62
+ {
63
+
64
+ var candidates=[];
65
+ //fill the array with 0 to start
66
+ candidates[target]=0;
67
+ candidates.fill(0);
68
+
69
+ //validation checks up front
70
+ if(target==0)return [];
71
+
72
+ if(target<0)
73
+ {
74
+ throw new Error( 'Negative totals are not allowed.');
75
+ }
76
+
77
+ if(target<Math.min.apply(null,coinArray))
78
+ {
79
+ throw new Error('The total '+ target +' cannot be represented in the given currency.');
80
+ }
81
+
82
+
83
+ initialize();
84
+ //printAll();
85
+
86
+
87
+ //process the arrange until everything is searched
88
+ while(isDone()==false)
89
+ {
90
+ let candidate=getNext();
91
+ branch(candidate);
92
+ candidate.Searched();
93
+ }
94
+ //printAll();
95
+
96
+
97
+ //print the result
98
+ if(typeof(candidates[target])!='number')
99
+ return candidates[target].getCoins();
100
+ else throw new Error('The total '+ target +' cannot be represented in the given currency.');
101
+
102
+
103
+ //print the candidate array
104
+ function printAll()
105
+ {
106
+ for(let j=0; j< candidates.length; j++)
107
+ {
108
+ if(typeof(candidates[j])=='object')
109
+ {
110
+ console.log('index: ' + j + ' ' + candidates[j].getCoins() + ' searched: ' + candidates[j].isSearched());
111
+ }
112
+ else
113
+ {
114
+ console.log('index: ' + j + ' is empty ' + typeof(candidates[j]));
115
+ }
116
+ }
117
+ }
118
+
119
+ //initialize the candidate array with the given coins only
120
+ function initialize()
121
+ {
122
+ for(let j=0; j<coinArray.length; j++)
123
+ {
124
+ let temp= coinArray[j];
125
+ let candidate = new Candidate();
126
+ candidate.addCoin(temp);
127
+ saveCandidate(candidate);
128
+
129
+ }
130
+ }
131
+
132
+ //is everthing searched?
133
+ function isDone()
134
+ {
135
+ let done=true;
136
+ for (let i=0; i<candidates.length; i++)
137
+ {
138
+ let temp=candidates[i];
139
+ if(typeof(temp)!='number')
140
+ {
141
+ if(temp.isSearched()==false)
142
+ {
143
+ done=false;
144
+ break;
145
+ }
146
+ }
147
+ }
148
+ return done;
149
+ }
150
+
151
+ //get the next unsearched member of the candidate array
152
+ function getNext()
153
+ {
154
+ for(let i=0; i< candidates.length; i++)
155
+ {
156
+ let temp= candidates[i];
157
+ if (typeof(temp)!='number' &&
158
+ temp.isSearched()==false)return temp;
159
+ }
160
+ return null;
161
+
162
+ }
163
+
164
+ //save a new candidate to the candidate array
165
+ function saveCandidate(candidate)
166
+ {
167
+ let sum=candidate.getSum();
168
+
169
+ if( candidate.getSum()<=target &&
170
+ typeof(candidates[sum])!='number' &&
171
+ candidates[sum].getCoinCount()>candidate.getCoinCount())
172
+ {
173
+ candidates[sum]=candidate;
174
+ }
175
+
176
+ if(candidate.getSum()<=target &&
177
+ typeof(candidates[sum])=='number')
178
+ {
179
+ candidates[sum]=candidate;
180
+ }
181
+ }
182
+
183
+
184
+ //for the candidate, generate another candate for each of the possible coins
185
+ function branch(current)
186
+ {
187
+ for(let j=0; j<coinArray.length; j++)
188
+ {
189
+
190
+ //make a new Candidate for coin type
191
+ let candidate= new Candidate();
192
+
193
+ //copy the curent coins into it and add the new coin type
194
+ for(var i=0; i< current.getCoins().length; i++)candidate.addCoin(current.getCoins()[i]);
195
+
196
+ candidate.addCoin(coinArray[j]);
197
+
198
+ saveCandidate(candidate);
199
+ }
200
+
201
+ }
202
+
203
+ }
204
+