trackler 2.2.1.136 → 2.2.1.137
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/csharp/exercises/proverb/Example.cs +9 -11
- data/tracks/csharp/exercises/proverb/Proverb.cs +1 -6
- data/tracks/csharp/exercises/proverb/ProverbTest.cs +23 -17
- data/tracks/csharp/generators/DeprecatedExercise.cs +9 -0
- data/tracks/csharp/generators/ExerciseCollection.cs +5 -2
- data/tracks/csharp/generators/Exercises/Proverb.cs +16 -0
- data/tracks/csharp/generators/Input/ConfigFile.cs +11 -3
- data/tracks/nim/config.json +13 -0
- data/tracks/nim/exercises/allergies/README.md +47 -0
- data/tracks/nim/exercises/allergies/allergies_test.nim +68 -0
- data/tracks/nim/exercises/allergies/example.nim +24 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60bf2574faa34a60a9794b94d789c9e73fb4cbe1
|
4
|
+
data.tar.gz: 40a8dc9eaba4aae1b7dacc47d7f7df71c2ad0ef5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f84292883fa84fe0e3531f411e790247ea3f405a2ac4073b19e2330952b6e088598c41f900d47c79bf7ebb3445b624f639fd11b3a660e60c08d829afe223d71
|
7
|
+
data.tar.gz: 62435ae5728a1ff10a08382ea7a11c43985d97f5842a33ea1b27923c43c2a90fba640ccd42e3f71228a7a5ab9b1cf3b253260d93537d8f8201b7150b83991925
|
data/lib/trackler/version.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
using System
|
1
|
+
using System;
|
2
|
+
using System.Linq;
|
2
3
|
|
3
4
|
public static class Proverb
|
4
5
|
{
|
5
|
-
|
6
|
-
|
7
|
-
public static string Line(int line)
|
6
|
+
public static string[] Recite(string[] subjects)
|
8
7
|
{
|
9
|
-
|
10
|
-
{
|
11
|
-
return "And all for the want of a
|
12
|
-
|
8
|
+
Func<int, string> line = (lineIndex) =>
|
9
|
+
{
|
10
|
+
if (lineIndex == subjects.Length) return $"And all for the want of a {subjects[0]}.";
|
11
|
+
else return $"For want of a {subjects[lineIndex - 1]} the {subjects[lineIndex]} was lost.";
|
12
|
+
};
|
13
13
|
|
14
|
-
return
|
14
|
+
return Enumerable.Range(1, subjects.Length).Select(line).ToArray();
|
15
15
|
}
|
16
|
-
|
17
|
-
public static string AllLines() => string.Join("\n", Enumerable.Range(1, 7).Select(Line));
|
18
16
|
}
|
@@ -2,12 +2,7 @@
|
|
2
2
|
|
3
3
|
public static class Proverb
|
4
4
|
{
|
5
|
-
public static string
|
6
|
-
{
|
7
|
-
throw new NotImplementedException();
|
8
|
-
}
|
9
|
-
|
10
|
-
public static string AllLines()
|
5
|
+
public static string[] Recite(string[] subjects)
|
11
6
|
{
|
12
7
|
throw new NotImplementedException();
|
13
8
|
}
|
@@ -1,36 +1,42 @@
|
|
1
|
-
|
1
|
+
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
2
4
|
|
3
5
|
public class ProverbTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
8
|
+
public void Zero_pieces()
|
9
|
+
{
|
10
|
+
Assert.Empty(Proverb.Recite(new string[] { }));
|
11
|
+
}
|
12
|
+
|
13
|
+
[Fact(Skip = "Remove to run test")]
|
14
|
+
public void One_piece()
|
7
15
|
{
|
8
|
-
Assert.Equal("
|
16
|
+
Assert.Equal(new[] { "And all for the want of a nail." }, Proverb.Recite(new[] { "nail" }));
|
9
17
|
}
|
10
18
|
|
11
19
|
[Fact(Skip = "Remove to run test")]
|
12
|
-
public void
|
20
|
+
public void Two_pieces()
|
13
21
|
{
|
14
|
-
Assert.Equal("For want of a
|
22
|
+
Assert.Equal(new[] { "For want of a nail the shoe was lost.", "And all for the want of a nail." }, Proverb.Recite(new[] { "nail", "shoe" }));
|
15
23
|
}
|
16
24
|
|
17
25
|
[Fact(Skip = "Remove to run test")]
|
18
|
-
public void
|
26
|
+
public void Three_pieces()
|
19
27
|
{
|
20
|
-
Assert.Equal("And all for the want of a
|
28
|
+
Assert.Equal(new[] { "For want of a nail the shoe was lost.", "For want of a shoe the horse was lost.", "And all for the want of a nail." }, Proverb.Recite(new[] { "nail", "shoe", "horse" }));
|
21
29
|
}
|
22
30
|
|
23
31
|
[Fact(Skip = "Remove to run test")]
|
24
|
-
public void
|
32
|
+
public void Full_proverb()
|
25
33
|
{
|
26
|
-
|
27
|
-
|
28
|
-
"For want of a horse the rider was lost.\n" +
|
29
|
-
"For want of a rider the message was lost.\n" +
|
30
|
-
"For want of a message the battle was lost.\n" +
|
31
|
-
"For want of a battle the kingdom was lost.\n" +
|
32
|
-
"And all for the want of a horseshoe nail.";
|
34
|
+
Assert.Equal(new[] { "For want of a nail the shoe was lost.", "For want of a shoe the horse was lost.", "For want of a horse the rider was lost.", "For want of a rider the message was lost.", "For want of a message the battle was lost.", "For want of a battle the kingdom was lost.", "And all for the want of a nail." }, Proverb.Recite(new[] { "nail", "shoe", "horse", "rider", "message", "battle", "kingdom" }));
|
35
|
+
}
|
33
36
|
|
34
|
-
|
37
|
+
[Fact(Skip = "Remove to run test")]
|
38
|
+
public void Four_pieces_modernized()
|
39
|
+
{
|
40
|
+
Assert.Equal(new[] { "For want of a pin the gun was lost.", "For want of a gun the soldier was lost.", "For want of a soldier the battle was lost.", "And all for the want of a pin." }, Proverb.Recite(new[] { "pin", "gun", "soldier", "battle" }));
|
35
41
|
}
|
36
|
-
}
|
42
|
+
}
|
@@ -29,9 +29,12 @@ namespace Generators
|
|
29
29
|
|
30
30
|
private IEnumerable<Exercise> GetExercises()
|
31
31
|
{
|
32
|
-
foreach (var
|
32
|
+
foreach (var exercise in ConfigFile.GetExercises())
|
33
33
|
{
|
34
|
-
|
34
|
+
var exerciseName = exercise.Name;
|
35
|
+
if (exercise.Deprecated)
|
36
|
+
yield return new DeprecatedExercise(exerciseName);
|
37
|
+
else if (HasNoCanonicalData(exerciseName))
|
35
38
|
yield return new MissingDataExercise(exerciseName);
|
36
39
|
else if (IsNotImplemented(exerciseName))
|
37
40
|
yield return new UnimplementedExercise(exerciseName);
|
@@ -0,0 +1,16 @@
|
|
1
|
+
using Generators.Output;
|
2
|
+
|
3
|
+
namespace Generators.Exercises
|
4
|
+
{
|
5
|
+
public class Proverb : GeneratorExercise
|
6
|
+
{
|
7
|
+
protected override string RenderTestMethodBodyAssert(TestMethodBody testMethodBody)
|
8
|
+
{
|
9
|
+
if (testMethodBody.CanonicalDataCase.Properties["input"]["strings"] as string[] == null)
|
10
|
+
{
|
11
|
+
return TemplateRenderer.RenderInline("Assert.Empty(Proverb.Recite(new string[] { }));", new { });
|
12
|
+
}
|
13
|
+
return base.RenderTestMethodBodyAssert(testMethodBody);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
using System.IO;
|
3
3
|
using System.Linq;
|
4
4
|
using Newtonsoft.Json;
|
5
|
+
using Generators.Output;
|
5
6
|
|
6
7
|
namespace Generators.Input
|
7
8
|
{
|
@@ -9,11 +10,11 @@ namespace Generators.Input
|
|
9
10
|
{
|
10
11
|
private const string ConfigFilePath = "../config.json";
|
11
12
|
|
12
|
-
public static IEnumerable<
|
13
|
+
public static IEnumerable<ConfigExercise> GetExercises()
|
13
14
|
{
|
14
15
|
var jsonContents = File.ReadAllText(ConfigFilePath);
|
15
16
|
var config = JsonConvert.DeserializeObject<Config>(jsonContents);
|
16
|
-
return config.Exercises.
|
17
|
+
return config.Exercises.OrderBy(x => x.Name).ToArray();
|
17
18
|
}
|
18
19
|
|
19
20
|
private class Config
|
@@ -21,9 +22,16 @@ namespace Generators.Input
|
|
21
22
|
public ConfigExercise[] Exercises { get; set; }
|
22
23
|
}
|
23
24
|
|
24
|
-
|
25
|
+
public class ConfigExercise
|
25
26
|
{
|
27
|
+
public string Name => Slug.ToExerciseName();
|
26
28
|
public string Slug { get; set; }
|
29
|
+
public bool Core { get; set; }
|
30
|
+
public int Difficulty { get; set; }
|
31
|
+
public string[] Topics { get; set; }
|
32
|
+
public string Unlocked_By { get; set; }
|
33
|
+
public string UUID { get; set; }
|
34
|
+
public bool Deprecated { get; set; }
|
27
35
|
}
|
28
36
|
}
|
29
37
|
}
|
data/tracks/nim/config.json
CHANGED
@@ -158,6 +158,19 @@
|
|
158
158
|
"filtering",
|
159
159
|
"logic"
|
160
160
|
]
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"uuid": "58bb800a-5b64-44bc-8282-77972b71e615",
|
164
|
+
"slug": "allergies",
|
165
|
+
"core": true,
|
166
|
+
"unlocked_by": null,
|
167
|
+
"difficulty": 1,
|
168
|
+
"topics": [
|
169
|
+
"classes",
|
170
|
+
"mathematics",
|
171
|
+
"bitwise_operations",
|
172
|
+
"enumerations"
|
173
|
+
]
|
161
174
|
}
|
162
175
|
]
|
163
176
|
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Allergies
|
2
|
+
|
3
|
+
Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.
|
4
|
+
|
5
|
+
An allergy test produces a single numeric score which contains the
|
6
|
+
information about all the allergies the person has (that they were
|
7
|
+
tested for).
|
8
|
+
|
9
|
+
The list of items (and their value) that were tested are:
|
10
|
+
|
11
|
+
* eggs (1)
|
12
|
+
* peanuts (2)
|
13
|
+
* shellfish (4)
|
14
|
+
* strawberries (8)
|
15
|
+
* tomatoes (16)
|
16
|
+
* chocolate (32)
|
17
|
+
* pollen (64)
|
18
|
+
* cats (128)
|
19
|
+
|
20
|
+
So if Tom is allergic to peanuts and chocolate, he gets a score of 34.
|
21
|
+
|
22
|
+
Now, given just that score of 34, your program should be able to say:
|
23
|
+
|
24
|
+
- Whether Tom is allergic to any one of those allergens listed above.
|
25
|
+
- All the allergens Tom is allergic to.
|
26
|
+
|
27
|
+
Note: a given score may include allergens **not** listed above (i.e.
|
28
|
+
allergens that score 256, 512, 1024, etc.). Your program should
|
29
|
+
ignore those components of the score. For example, if the allergy
|
30
|
+
score is 257, your program should only report the eggs (1) allergy.
|
31
|
+
|
32
|
+
## Submitting Exercises
|
33
|
+
|
34
|
+
Note that, when trying to submit an exercise, make sure the solution is in the `$EXERCISM_WORKSPACE/nim/allergies` directory.
|
35
|
+
|
36
|
+
You can find your Exercism workspace by running `exercism debug` and looking for the line that starts with `Workspace`.
|
37
|
+
|
38
|
+
For more detailed information about running tests, code style and linting,
|
39
|
+
please see the [help page](http://exercism.io/languages/nim).
|
40
|
+
|
41
|
+
## Source
|
42
|
+
|
43
|
+
Jumpstart Lab Warm-up [http://jumpstartlab.com](http://jumpstartlab.com)
|
44
|
+
|
45
|
+
## Submitting Incomplete Solutions
|
46
|
+
|
47
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import unittest
|
2
|
+
|
3
|
+
import allergies
|
4
|
+
|
5
|
+
|
6
|
+
test "no allergies means not allergic":
|
7
|
+
let allergies = Allergies(score: 0)
|
8
|
+
check allergies.is_allergic_to("peanuts") == false
|
9
|
+
check allergies.is_allergic_to("cats") == false
|
10
|
+
check allergies.is_allergic_to("strawberries") == false
|
11
|
+
|
12
|
+
test "is allergic to eggs":
|
13
|
+
let allergies = Allergies(score: 1)
|
14
|
+
check allergies.is_allergic_to("eggs") == true
|
15
|
+
|
16
|
+
test "allergic to eggs in addition to other stuff":
|
17
|
+
let allergies = Allergies(score: 5)
|
18
|
+
check allergies.is_allergic_to("eggs") == true
|
19
|
+
check allergies.is_allergic_to("shellfish") == true
|
20
|
+
check allergies.is_allergic_to("strawberries") == false
|
21
|
+
|
22
|
+
test "no allergies at all":
|
23
|
+
let allergies = Allergies(score: 0)
|
24
|
+
check allergies.lst == newSeq[string](0)
|
25
|
+
|
26
|
+
test "allergic to just eggs":
|
27
|
+
let allergies = Allergies(score: 1)
|
28
|
+
check allergies.lst == @["eggs"]
|
29
|
+
|
30
|
+
test "allergic to just peanuts":
|
31
|
+
let allergies = Allergies(score: 2)
|
32
|
+
check allergies.lst == @["peanuts"]
|
33
|
+
|
34
|
+
test "allergic to just strawberries":
|
35
|
+
let allergies = Allergies(score: 8)
|
36
|
+
check allergies.lst == @["strawberries"]
|
37
|
+
|
38
|
+
test "allergic to eggs and peanuts":
|
39
|
+
let allergies = Allergies(score: 3)
|
40
|
+
check allergies.lst == @["eggs", "peanuts"]
|
41
|
+
|
42
|
+
test "allergic to more than eggs but not peanuts":
|
43
|
+
let allergies = Allergies(score: 5)
|
44
|
+
check allergies.lst == @["eggs", "shellfish"]
|
45
|
+
|
46
|
+
test "allergic to lots of stuff":
|
47
|
+
let allergies = Allergies(score: 248)
|
48
|
+
check allergies.lst == @[
|
49
|
+
"strawberries", "tomatoes", "chocolate", "pollen", "cats"
|
50
|
+
]
|
51
|
+
|
52
|
+
test "allergic to everything":
|
53
|
+
let allergies = Allergies(score: 255)
|
54
|
+
check allergies.lst == @[
|
55
|
+
"eggs", "peanuts", "shellfish", "strawberries", "tomatoes",
|
56
|
+
"chocolate", "pollen", "cats"
|
57
|
+
]
|
58
|
+
|
59
|
+
test "ignore non allergen score parts only eggs":
|
60
|
+
let allergies = Allergies(score: 257)
|
61
|
+
check allergies.lst == @["eggs"]
|
62
|
+
|
63
|
+
test "ignore non allergen score parts":
|
64
|
+
let allergies = Allergies(score: 509)
|
65
|
+
check allergies.lst == @[
|
66
|
+
"eggs", "shellfish", "strawberries", "tomatoes", "chocolate",
|
67
|
+
"pollen", "cats"
|
68
|
+
]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import sequtils
|
2
|
+
|
3
|
+
type
|
4
|
+
Allergies* = object
|
5
|
+
score*: int
|
6
|
+
|
7
|
+
var
|
8
|
+
allergiesList = [
|
9
|
+
"eggs",
|
10
|
+
"peanuts",
|
11
|
+
"shellfish",
|
12
|
+
"strawberries",
|
13
|
+
"tomatoes",
|
14
|
+
"chocolate",
|
15
|
+
"pollen",
|
16
|
+
"cats"
|
17
|
+
]
|
18
|
+
|
19
|
+
|
20
|
+
proc is_allergic_to*(allergies: Allergies, allergy: string): bool =
|
21
|
+
(allergies.score and 1 shl allergiesList.find(allergy)) != 0
|
22
|
+
|
23
|
+
proc lst*(allergies: Allergies): seq[string] =
|
24
|
+
allergiesList.filterIt(allergies.is_allergic_to(it))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.1.
|
4
|
+
version: 2.2.1.137
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -3155,6 +3155,7 @@ files:
|
|
3155
3155
|
- tracks/csharp/exercises/zipper/ZipperTest.cs
|
3156
3156
|
- tracks/csharp/generators/.gitignore
|
3157
3157
|
- tracks/csharp/generators/CustomExercise.cs
|
3158
|
+
- tracks/csharp/generators/DeprecatedExercise.cs
|
3158
3159
|
- tracks/csharp/generators/Exercise.cs
|
3159
3160
|
- tracks/csharp/generators/ExerciseCollection.cs
|
3160
3161
|
- tracks/csharp/generators/Exercises/Acronym.cs
|
@@ -3205,6 +3206,7 @@ files:
|
|
3205
3206
|
- tracks/csharp/generators/Exercises/PigLatin.cs
|
3206
3207
|
- tracks/csharp/generators/Exercises/Poker.cs
|
3207
3208
|
- tracks/csharp/generators/Exercises/PrimeFactors.cs
|
3209
|
+
- tracks/csharp/generators/Exercises/Proverb.cs
|
3208
3210
|
- tracks/csharp/generators/Exercises/QueenAttack.cs
|
3209
3211
|
- tracks/csharp/generators/Exercises/RailFenceCipher.cs
|
3210
3212
|
- tracks/csharp/generators/Exercises/Raindrops.cs
|
@@ -9792,6 +9794,9 @@ files:
|
|
9792
9794
|
- tracks/nim/docs/RESOURCES.md
|
9793
9795
|
- tracks/nim/docs/SNIPPET.txt
|
9794
9796
|
- tracks/nim/docs/TESTS.md
|
9797
|
+
- tracks/nim/exercises/allergies/README.md
|
9798
|
+
- tracks/nim/exercises/allergies/allergies_test.nim
|
9799
|
+
- tracks/nim/exercises/allergies/example.nim
|
9795
9800
|
- tracks/nim/exercises/anagram/README.md
|
9796
9801
|
- tracks/nim/exercises/anagram/anagram_test.nim
|
9797
9802
|
- tracks/nim/exercises/anagram/example.nim
|