trackler 2.2.1.132 → 2.2.1.133

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e478de20af389be52d781a2d47847e675fcb3445
4
- data.tar.gz: 1b158116931fb875e127102199db876edf2cfc56
3
+ metadata.gz: 823d7cfe149655bf74ac3093c3948cd9e385e612
4
+ data.tar.gz: 42596817dd6559ca7642e6eb9ceb543dc9055751
5
5
  SHA512:
6
- metadata.gz: ba89ba4b7f07e6c582a4950ffdac818fa16e2831613d22b06de2ef46bfc0bf8c9369b591afeb1ffea22438bcd123df033d87f68f9559fe084049c20849ac470b
7
- data.tar.gz: d00499a417f38ad4e78668e656faf9e262173f951a3ee7addd50906a4f5c707fb609a6ab43e2b781e05375d64bdbf36d9e710d7d801e99a54b6a27d9e296bdf3
6
+ metadata.gz: d07624593c2464b858dbf6c2f6bf7c78d38451b1f0a579d8321e9a8a3a3e2632bd5f127d09f3c96e4125603e43193260d8e7c2612001b14b9f319f3e34835ece
7
+ data.tar.gz: 20c3e8d8037e8fb4130997771cc0886c83f214c94a7a0060870af86d9e5ba18d449e7d56430bfa29c96404f0d0c4e890ca208165cd573c9ed32e9169ffac104a
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.132"
2
+ VERSION = "2.2.1.133"
3
3
  end
@@ -26,6 +26,19 @@
26
26
  "unlocked_by": null,
27
27
  "uuid": "4bcfd789-dee6-4dd9-8524-076508504eda"
28
28
  },
29
+ {
30
+ "core": true,
31
+ "difficulty": 1,
32
+ "slug": "armstrong-numbers",
33
+ "topics": [
34
+ "equality",
35
+ "integers",
36
+ "logic",
37
+ "strings"
38
+ ],
39
+ "unlocked_by": null,
40
+ "uuid": "4f650701-9568-4d95-9f72-be4bde2c90ec"
41
+ },
29
42
  {
30
43
  "core": true,
31
44
  "difficulty": 2,
@@ -0,0 +1,29 @@
1
+ # Armstrong Numbers
2
+
3
+ An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
4
+
5
+ For example:
6
+
7
+ - 9 is an Armstrong number, because `9 = 9^1 = 9`
8
+ - 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 2`
9
+ - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
10
+ - 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
11
+
12
+ Write some code to determine whether a number is an Armstrong number.
13
+
14
+
15
+ To run the tests:
16
+
17
+ ```sh
18
+ $ pub run test
19
+ ```
20
+
21
+ For more detailed info about the Dart track see the [help page](http://exercism.io/languages/dart).
22
+
23
+
24
+ ## Source
25
+
26
+ Wikipedia [https://en.wikipedia.org/wiki/Narcissistic_number](https://en.wikipedia.org/wiki/Narcissistic_number)
27
+
28
+ ## Submitting Incomplete Solutions
29
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,3 @@
1
+ class ArmstrongNumbers {
2
+ // Put your code here
3
+ }
@@ -0,0 +1,20 @@
1
+ import 'dart:math' show pow;
2
+
3
+ class ArmstrongNumbers {
4
+
5
+ /// The parameters and variables within the method that are set to final in order to prevent the accidentally modification of the value.
6
+ /// As those variables are not needed to be changed.
7
+ bool isArmstrongNumber(final int number) {
8
+ final String numberAsString = number.toString();
9
+ final int numOfDigits = numberAsString.length;
10
+ int sum = 0;
11
+
12
+ for (int count = 0; count < numOfDigits; count++) {
13
+ final String digitAsString = numberAsString.substring(count, count + 1);
14
+ final int digit = int.parse(digitAsString);
15
+ sum += pow(digit, numOfDigits);
16
+ }
17
+
18
+ return number == sum;
19
+ }
20
+ }
@@ -0,0 +1,3 @@
1
+ name: 'armstrong_numbers'
2
+ dev_dependencies:
3
+ test: '<0.13.0'
@@ -0,0 +1,48 @@
1
+ import "package:test/test.dart";
2
+ import "package:armstrong_numbers/armstrong_numbers.dart";
3
+
4
+ void main() {
5
+ final ArmstrongNumbers armstrongNumbers = new ArmstrongNumbers();
6
+
7
+ group("ArmstrongNumbers", () {
8
+ test("Single digit numbers are Armstrong numbers", () {
9
+ final bool result = armstrongNumbers.isArmstrongNumber(5);
10
+ expect(result, equals(true));
11
+ }, skip: false);
12
+
13
+ test("There are no 2 digit Armstrong numbers", () {
14
+ final bool result = armstrongNumbers.isArmstrongNumber(10);
15
+ expect(result, equals(false));
16
+ }, skip: true);
17
+
18
+ test("Three digit number that is an Armstrong number", () {
19
+ final bool result = armstrongNumbers.isArmstrongNumber(153);
20
+ expect(result, equals(true));
21
+ }, skip: true);
22
+
23
+ test("Three digit number that is not an Armstrong number", () {
24
+ final bool result = armstrongNumbers.isArmstrongNumber(100);
25
+ expect(result, equals(false));
26
+ }, skip: true);
27
+
28
+ test("Four digit number that is an Armstrong number", () {
29
+ final bool result = armstrongNumbers.isArmstrongNumber(9474);
30
+ expect(result, equals(true));
31
+ }, skip: true);
32
+
33
+ test("Four digit number that is not an Armstrong number", () {
34
+ final bool result = armstrongNumbers.isArmstrongNumber(9475);
35
+ expect(result, equals(false));
36
+ }, skip: true);
37
+
38
+ test("Seven digit number that is an Armstrong number", () {
39
+ final bool result = armstrongNumbers.isArmstrongNumber(9926315);
40
+ expect(result, equals(true));
41
+ }, skip: true);
42
+
43
+ test("Seven digit number that is not an Armstrong number", () {
44
+ final bool result = armstrongNumbers.isArmstrongNumber(9926314);
45
+ expect(result, equals(false));
46
+ }, skip: true);
47
+ });
48
+ }
@@ -24,5 +24,20 @@ void main() {
24
24
  final bool result = leap.leapYear(2000);
25
25
  expect(result, equals(true));
26
26
  }, skip: true);
27
+
28
+ test("is introduced every 4 years to adjust about a day before 400 A.D.", () {
29
+ final bool result = leap.leapYear(4);
30
+ expect(result, equals(true));
31
+ }, skip: true);
32
+
33
+ test("is skipped every 100 years to remove an extra day before 400 A.D.", () {
34
+ final bool result = leap.leapYear(300);
35
+ expect(result, equals(false));
36
+ }, skip: true);
37
+
38
+ test("is reintroduced every 400 years to adjust another day including 400 A.D.", () {
39
+ final bool result = leap.leapYear(400);
40
+ expect(result, equals(true));
41
+ }, skip: true);
27
42
  });
28
43
  }
@@ -30,6 +30,7 @@ install:
30
30
  - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 -o pack.tgz
31
31
  - tar xzf pack.tgz --wildcards --strip-components=1 -C ${HOME}/bin '*/stack'
32
32
  - stack --resolver ${RESOLVER} --install-ghc install hlint
33
+ - stack --version
33
34
 
34
35
  script:
35
36
  - "sh ./bin/ensure-readmes-are-updated.sh"
@@ -3,15 +3,18 @@ dist: trusty
3
3
 
4
4
  language: c
5
5
 
6
+ env:
7
+ - NIM_VERSION="0.18.0"
8
+
6
9
  install:
7
10
  - cd _test
8
- - wget http://nim-lang.org/download/nim-0.14.2.tar.xz
9
- - tar xf nim-0.14.2.tar.xz
10
- - cd nim-0.14.2
11
+ - wget https://nim-lang.org/download/nim-$NIM_VERSION.tar.xz
12
+ - tar xf nim-$NIM_VERSION.tar.xz
13
+ - cd nim-$NIM_VERSION
11
14
  - ./build.sh
12
15
  - cd ../..
13
16
 
14
- before_script: export PATH=$PATH:$PWD/_test/nim-0.14.2/bin
17
+ before_script: export PATH=$PATH:$PWD/_test/nim-$NIM_VERSION/bin
15
18
 
16
19
  script:
17
20
  - bin/fetch-configlet
@@ -9,7 +9,7 @@ proc isAnagramTo(a, b: TAnagram): bool {.noSideEffect, procVar.} =
9
9
  a.chars == b.chars and cmpIgnoreCase(a.word, b.word) != 0
10
10
 
11
11
  proc anagram(word: string): TAnagram =
12
- var chars = toSeq(word.toLower().items)
12
+ var chars = toSeq(word.toLowerAscii().items)
13
13
  sort(chars, cmp[char])
14
14
  (word, chars)
15
15
 
@@ -6,12 +6,14 @@ type TWordCount* = CritBitTree[int]
6
6
 
7
7
  iterator words(s: string): string =
8
8
  for word in s.split(AllChars - Letters - Digits - {'\0'}):
9
- yield toLower(word)
9
+ yield toLowerAscii(word)
10
10
 
11
11
  proc wordCount*(s: string): TWordCount {.noSideEffect.} =
12
12
  ## Returns a mapping from the words (alphanumeric sequences) in `s` to their
13
13
  ## respective counts.
14
14
  for word in words(s):
15
+ if word.len == 0:
16
+ continue
15
17
  if not result.hasKey(word):
16
18
  result[word] = 0
17
19
  result[word] = result[word] + 1
data/tracks/r/config.json CHANGED
@@ -253,7 +253,7 @@
253
253
  "control_flow_conditionals",
254
254
  "mathematics"
255
255
  ],
256
- "unlocked_by": "sum-of-multiples",
256
+ "unlocked_by": null,
257
257
  "uuid": "f3e93545-7466-4635-b508-7e02517fdf06"
258
258
  },
259
259
  {
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
6
6
 
7
7
  He answers 'Whoa, chill out!' if you yell at him.
8
8
 
9
+ He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
10
+
9
11
  He says 'Fine. Be that way!' if you address him without actually saying
10
12
  anything.
11
13
 
@@ -386,6 +386,20 @@
386
386
  "unlocked_by": "space-age",
387
387
  "uuid": "59d842b4-a804-4cd5-a388-983a22a70c9e"
388
388
  },
389
+ {
390
+ "core": false,
391
+ "difficulty": 4,
392
+ "slug": "house",
393
+ "topics": [
394
+ "control_flow_conditionals",
395
+ "control_flow_loops",
396
+ "strings",
397
+ "arrays",
398
+ "recursion"
399
+ ],
400
+ "unlocked_by": "bob",
401
+ "uuid": "9850a74a-1842-4db0-b3ed-5a53b4f25050"
402
+ },
389
403
  {
390
404
  "core": false,
391
405
  "difficulty": 5,
@@ -910,11 +924,11 @@
910
924
  "mathematics",
911
925
  "algorithms"
912
926
  ],
913
- "unlocked_by": "pascals-triangle",
927
+ "unlocked_by": null,
914
928
  "uuid": "4439ab9d-266b-483b-b5ca-3920c478fd62"
915
929
  },
916
930
  {
917
- "core": false,
931
+ "core": true,
918
932
  "difficulty": 5,
919
933
  "slug": "binary-search",
920
934
  "topics": [
@@ -1058,7 +1072,7 @@
1058
1072
  "loops",
1059
1073
  "transforming"
1060
1074
  ],
1061
- "unlocked_by": "two-bucket",
1075
+ "unlocked_by": "pangram",
1062
1076
  "uuid": "50050198-b5a3-4ab1-8b4b-0eadc8007ebb"
1063
1077
  },
1064
1078
  {
@@ -1078,4 +1092,4 @@
1078
1092
  "foregone": [],
1079
1093
  "language": "TypeScript",
1080
1094
  "test_pattern": ".*[.]test[.]ts$"
1081
- }
1095
+ }
@@ -0,0 +1,138 @@
1
+ # House
2
+
3
+ Recite the nursery rhyme 'This is the House that Jack Built'.
4
+
5
+ > [The] process of placing a phrase of clause within another phrase of
6
+ > clause is called embedding. It is through the processes of recursion
7
+ > and embedding that we are able to take a finite number of forms (words
8
+ > and phrases) and construct an infinite number of expressions.
9
+ > Furthermore, embedding also allows us to construct an infinitely long
10
+ > structure, in theory anyway.
11
+
12
+ - [papyr.com](http://papyr.com/hypertextbooks/grammar/ph_noun.htm)
13
+
14
+ The nursery rhyme reads as follows:
15
+
16
+ ```text
17
+ This is the house that Jack built.
18
+
19
+ This is the malt
20
+ that lay in the house that Jack built.
21
+
22
+ This is the rat
23
+ that ate the malt
24
+ that lay in the house that Jack built.
25
+
26
+ This is the cat
27
+ that killed the rat
28
+ that ate the malt
29
+ that lay in the house that Jack built.
30
+
31
+ This is the dog
32
+ that worried the cat
33
+ that killed the rat
34
+ that ate the malt
35
+ that lay in the house that Jack built.
36
+
37
+ This is the cow with the crumpled horn
38
+ that tossed the dog
39
+ that worried the cat
40
+ that killed the rat
41
+ that ate the malt
42
+ that lay in the house that Jack built.
43
+
44
+ This is the maiden all forlorn
45
+ that milked the cow with the crumpled horn
46
+ that tossed the dog
47
+ that worried the cat
48
+ that killed the rat
49
+ that ate the malt
50
+ that lay in the house that Jack built.
51
+
52
+ This is the man all tattered and torn
53
+ that kissed the maiden all forlorn
54
+ that milked the cow with the crumpled horn
55
+ that tossed the dog
56
+ that worried the cat
57
+ that killed the rat
58
+ that ate the malt
59
+ that lay in the house that Jack built.
60
+
61
+ This is the priest all shaven and shorn
62
+ that married the man all tattered and torn
63
+ that kissed the maiden all forlorn
64
+ that milked the cow with the crumpled horn
65
+ that tossed the dog
66
+ that worried the cat
67
+ that killed the rat
68
+ that ate the malt
69
+ that lay in the house that Jack built.
70
+
71
+ This is the rooster that crowed in the morn
72
+ that woke the priest all shaven and shorn
73
+ that married the man all tattered and torn
74
+ that kissed the maiden all forlorn
75
+ that milked the cow with the crumpled horn
76
+ that tossed the dog
77
+ that worried the cat
78
+ that killed the rat
79
+ that ate the malt
80
+ that lay in the house that Jack built.
81
+
82
+ This is the farmer sowing his corn
83
+ that kept the rooster that crowed in the morn
84
+ that woke the priest all shaven and shorn
85
+ that married the man all tattered and torn
86
+ that kissed the maiden all forlorn
87
+ that milked the cow with the crumpled horn
88
+ that tossed the dog
89
+ that worried the cat
90
+ that killed the rat
91
+ that ate the malt
92
+ that lay in the house that Jack built.
93
+
94
+ This is the horse and the hound and the horn
95
+ that belonged to the farmer sowing his corn
96
+ that kept the rooster that crowed in the morn
97
+ that woke the priest all shaven and shorn
98
+ that married the man all tattered and torn
99
+ that kissed the maiden all forlorn
100
+ that milked the cow with the crumpled horn
101
+ that tossed the dog
102
+ that worried the cat
103
+ that killed the rat
104
+ that ate the malt
105
+ that lay in the house that Jack built.
106
+ ```
107
+
108
+ ## Setup
109
+
110
+ Go through the setup instructions for TypeScript to
111
+ install the necessary dependencies:
112
+
113
+ http://exercism.io/languages/typescript
114
+
115
+ ## Requirements
116
+
117
+ Install assignment dependencies:
118
+
119
+ ```bash
120
+ $ yarn install
121
+ ```
122
+
123
+ ## Making the test suite pass
124
+
125
+ Execute the tests with:
126
+
127
+ ```bash
128
+ $ yarn test
129
+ ```
130
+
131
+
132
+
133
+ ## Source
134
+
135
+ British nursery rhyme [http://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built](http://en.wikipedia.org/wiki/This_Is_The_House_That_Jack_Built)
136
+
137
+ ## Submitting Incomplete Solutions
138
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,67 @@
1
+ const OBJECTS = [
2
+ 'house',
3
+ 'malt',
4
+ 'rat',
5
+ 'cat',
6
+ 'dog',
7
+ 'cow with the crumpled horn',
8
+ 'maiden all forlorn',
9
+ 'man all tattered and torn',
10
+ 'priest all shaven and shorn',
11
+ 'rooster that crowed in the morn',
12
+ 'farmer sowing his corn',
13
+ 'horse and the hound and the horn',
14
+ ]
15
+
16
+ const ACTIONS = [
17
+ 'Jack built',
18
+ 'lay in',
19
+ 'ate',
20
+ 'killed',
21
+ 'worried',
22
+ 'tossed',
23
+ 'milked',
24
+ 'kissed',
25
+ 'married',
26
+ 'woke',
27
+ 'kept',
28
+ 'belonged to',
29
+ ]
30
+
31
+ class House {
32
+ static verse(verseNumber: number) {
33
+ const lines = []
34
+ const totalLines = verseNumber
35
+ let itemIndex = verseNumber - 1
36
+ for (let lineNumber = 1; lineNumber <= totalLines; lineNumber += 1) {
37
+ let lineText = ''
38
+ if (lineNumber === 1) {
39
+ lineText += 'This is'
40
+ } else {
41
+ lineText += `that ${ACTIONS[itemIndex]}`
42
+ itemIndex -= 1
43
+ }
44
+
45
+ lineText += ` the ${OBJECTS[itemIndex]}`
46
+ if (lineNumber === totalLines) {
47
+ lineText += ` that ${ACTIONS[itemIndex]}.`
48
+ }
49
+ lines.push(lineText)
50
+ }
51
+ return lines
52
+ }
53
+
54
+ static verses(start: number, end: number) {
55
+ let lines: string[] = []
56
+ for (let i = start; i <= end; i += 1) {
57
+ const verseLines = House.verse(i)
58
+ lines = lines.concat(verseLines)
59
+ if (i < end) {
60
+ lines.push('')
61
+ }
62
+ }
63
+ return lines
64
+ }
65
+ }
66
+
67
+ export default House