trackler 2.0.8.9 → 2.0.8.10

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: 75ec4d39c8404045c3da176d93716bc5cf367589
4
- data.tar.gz: 8d17aded91294036f476f3a855aa5fdc64bd1396
3
+ metadata.gz: 9dceda62cf5804961190a45bdb1674e22beb903a
4
+ data.tar.gz: 1591edf17af892e711aecb9d1b2cabc1b472a5cc
5
5
  SHA512:
6
- metadata.gz: f37eaab777c5319aba8d031584ca08b2d2607c8d00c676a57f79f391dea404f8e59a0e4acd3b06e3661804c0cf89bc0908675ea41bec0130b8e94f763b0f1c6d
7
- data.tar.gz: bdc3fa7c2353b15319cd5090877b00a8fe54c72e9bef99444add6f6fc7fbf181219659976ed5ce857d5db1339436bab959b7dca63fbc0ea0fd8acd27b4e2e5d4
6
+ metadata.gz: abe7d5a9af5ae04d307b468618acb433fda74fb9266d8df78a6ca015cdcec513b95f47e39d584c8228f4785607b60bf4defcc3a08fa1569f9ffc069883a82a8f
7
+ data.tar.gz: 9294b813acecd5b4831e7585e3d7ce271b13da1cf49259b79a9ff188505c01820c2f8dea5c28ce0705ffa7a6d6df657a0012485bbd7841d453e4f400393b9789
@@ -36,6 +36,12 @@
36
36
  "target": 999,
37
37
  "expected": [2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100]
38
38
  },
39
+ {
40
+ "description": "possible change without unit coins available",
41
+ "coins": [2, 5, 10, 20, 50],
42
+ "target": 21,
43
+ "expected": [2, 2, 2, 5, 10]
44
+ },
39
45
  {
40
46
  "description": "no coins make 0 change",
41
47
  "coins": [1, 5, 10, 21, 25],
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.8.9"
2
+ VERSION = "2.0.8.10"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  if !System.get_env("EXERCISM_TEST_EXAMPLES") do
2
- Code.load_file("example.exs", __DIR__)
2
+ Code.load_file("all-your-base.exs", __DIR__)
3
3
  end
4
4
 
5
5
  ExUnit.start
@@ -109,24 +109,22 @@ func (b board) startCoords(cf colorFlags) []coord {
109
109
  if cf.color == white {
110
110
  coords := make([]coord, b.width)
111
111
  for i := 0; i < b.width; i++ {
112
- coords[i] = coord{x: i, y: 0}
113
- }
114
- return coords
115
- } else {
116
- coords := make([]coord, b.height)
117
- for i := 0; i < b.height; i++ {
118
- coords[i] = coord{x: 0, y: i}
112
+ coords[i] = coord{x: i}
119
113
  }
120
114
  return coords
121
115
  }
116
+ coords := make([]coord, b.height)
117
+ for i := 0; i < b.height; i++ {
118
+ coords[i] = coord{y: i}
119
+ }
120
+ return coords
122
121
  }
123
122
 
124
123
  func (b board) isTargetCoord(c coord, cf colorFlags) bool {
125
124
  if cf.color == white {
126
125
  return c.y == b.height-1
127
- } else {
128
- return c.x == b.width-1
129
126
  }
127
+ return c.x == b.width-1
130
128
  }
131
129
 
132
130
  func (b board) evaluate(c coord, cf colorFlags) bool {
@@ -9,9 +9,6 @@ import (
9
9
  // opens a resource, calls Frob(input) and closes the resource
10
10
  // (in all cases). The function should properly handle errors,
11
11
  // as defined by the expectations of this test suite.
12
- //
13
- // Also define a testVersion with a value that matches
14
- // the targetTestVersion here.
15
12
 
16
13
  const targetTestVersion = 2
17
14
 
@@ -27,8 +24,6 @@ func (mr mockResource) Close() error { return mr.close() }
27
24
  func (mr mockResource) Frob(input string) { mr.frob(input) }
28
25
  func (mr mockResource) Defrob(tag string) { mr.defrob(tag) }
29
26
 
30
- // If this test fails and you've properly defined testVersion the requirements
31
- // of the tests have changed since you wrote your submission.
32
27
  func TestTestVersion(t *testing.T) {
33
28
  if testVersion != targetTestVersion {
34
29
  t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
@@ -69,9 +64,8 @@ func TestKeepTryOpenOnTransient(t *testing.T) {
69
64
  if nthCall < 3 {
70
65
  nthCall++
71
66
  return mockResource{}, TransientError{errors.New("some error")}
72
- } else {
73
- return mr, nil
74
67
  }
68
+ return mr, nil
75
69
  }
76
70
  inp := "hello"
77
71
  err := Use(opener, inp)
@@ -90,9 +84,8 @@ func TestFailOpenOnNonTransient(t *testing.T) {
90
84
  if nthCall < 3 {
91
85
  nthCall++
92
86
  return mockResource{}, TransientError{errors.New("some error")}
93
- } else {
94
- return nil, errors.New("too awesome")
95
87
  }
88
+ return nil, errors.New("too awesome")
96
89
  }
97
90
  inp := "hello"
98
91
  err := Use(opener, inp)
@@ -33,3 +33,25 @@ func TestHelloWorld(t *testing.T) {
33
33
  t.Fatalf("HelloWorld() = %v, want %v", observed, expected)
34
34
  }
35
35
  }
36
+
37
+ // BenchmarkHelloWorld() is a benchmarking function. These functions follow the
38
+ // form `func BenchmarkXxx(*testing.B)` and can be used to test the performance
39
+ // of your implementation. They may not be present in every exercise, but when
40
+ // they are you can run them by including the `-bench` flag with the `go test`
41
+ // command, like so: `go test -bench .`
42
+ //
43
+ // You will see output similar to the following:
44
+ //
45
+ // BenchmarkHelloWorld 2000000000 0.46 ns/op
46
+ //
47
+ // This means that the loop ran 2000000000 times at a speed of 0.46 ns per loop.
48
+ //
49
+ // While benchmarking can be useful to compare different iterations of the same
50
+ // exercise, keep in mind that others will run the same benchmarks on different
51
+ // machines, with different specs, so the results from these benchmark tests may
52
+ // vary.
53
+ func BenchmarkHelloWorld(b *testing.B) {
54
+ for i := 0; i < b.N; i++ {
55
+ HelloWorld()
56
+ }
57
+ }
@@ -1,12 +1,7 @@
1
- // Leap stub file
2
-
3
- // The package name is expected by the test program.
4
1
  package leap
5
2
 
6
- // testVersion should match the targetTestVersion in the test file.
7
3
  const testVersion = 3
8
4
 
9
- // It's good style to write a comment here documenting IsLeapYear.
10
5
  func IsLeapYear(int) bool {
11
6
  // Write some code here to pass the test suite.
12
7
  }
@@ -2,10 +2,8 @@ package leap
2
2
 
3
3
  import "testing"
4
4
 
5
- // Define a function IsLeapYear(int) bool.
6
- //
7
- // Also define a testVersion with a value that matches
8
- // the targetTestVersion here.
5
+ // Define a function with the following signature:
6
+ // IsLeapYear(int) bool
9
7
 
10
8
  const targetTestVersion = 3
11
9
 
@@ -78,7 +78,7 @@ func (c *counter) addBytes(n int) {
78
78
  c.mutex.Lock()
79
79
  defer c.mutex.Unlock()
80
80
  c.bytes += int64(n)
81
- c.ops += 1
81
+ c.ops++
82
82
  }
83
83
 
84
84
  func (c *counter) count() (int64, int) {
@@ -5,27 +5,12 @@ import (
5
5
  "testing"
6
6
  )
7
7
 
8
- const targetTestVersion = 1
9
-
10
- func TestTestVersion(t *testing.T) {
11
- if testVersion != targetTestVersion {
12
- t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
13
- }
14
- }
15
-
16
8
  // In the separate file frequency.go, you are given a function, Frequency(),
17
9
  // to sequentially count letter frequencies in a single text.
10
+ //
18
11
  // Perform this exercise on parallelism using Go concurrency features.
19
12
  // Make concurrent calls to Frequency and combine results to obtain the answer.
20
13
 
21
- func TestConcurrentFrequency(t *testing.T) {
22
- seq := Frequency(euro + dutch + us)
23
- con := ConcurrentFrequency([]string{euro, dutch, us})
24
- if !reflect.DeepEqual(con, seq) {
25
- t.Fatal("ConcurrentFrequency wrong result")
26
- }
27
- }
28
-
29
14
  var (
30
15
  euro = `Freude schöner Götterfunken
31
16
  Tochter aus Elysium,
@@ -35,6 +20,7 @@ Deine Zauber binden wieder
35
20
  Was die Mode streng geteilt;
36
21
  Alle Menschen werden Brüder,
37
22
  Wo dein sanfter Flügel weilt.`
23
+
38
24
  dutch = `Wilhelmus van Nassouwe
39
25
  ben ik, van Duitsen bloed,
40
26
  den vaderland getrouwe
@@ -43,6 +29,7 @@ Een Prinse van Oranje
43
29
  ben ik, vrij, onverveerd,
44
30
  den Koning van Hispanje
45
31
  heb ik altijd geëerd.`
32
+
46
33
  us = `O say can you see by the dawn's early light,
47
34
  What so proudly we hailed at the twilight's last gleaming,
48
35
  Whose broad stripes and bright stars through the perilous fight,
@@ -53,6 +40,22 @@ O say does that star-spangled banner yet wave,
53
40
  O'er the land of the free and the home of the brave?`
54
41
  )
55
42
 
43
+ const targetTestVersion = 1
44
+
45
+ func TestTestVersion(t *testing.T) {
46
+ if testVersion != targetTestVersion {
47
+ t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
48
+ }
49
+ }
50
+
51
+ func TestConcurrentFrequency(t *testing.T) {
52
+ seq := Frequency(euro + dutch + us)
53
+ con := ConcurrentFrequency([]string{euro, dutch, us})
54
+ if !reflect.DeepEqual(con, seq) {
55
+ t.Fatal("ConcurrentFrequency wrong result")
56
+ }
57
+ }
58
+
56
59
  func BenchmarkSequentialFrequency(b *testing.B) {
57
60
  for i := 0; i < b.N; i++ {
58
61
  Frequency(euro + dutch + us)
@@ -4,6 +4,14 @@ import "testing"
4
4
 
5
5
  var _ error = ErrOnlyPositive
6
6
 
7
+ const targetTestVersion = 1
8
+
9
+ func TestTestVersion(t *testing.T) {
10
+ if testVersion != targetTestVersion {
11
+ t.Fatalf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
12
+ }
13
+ }
14
+
7
15
  func TestGivesPositiveRequiredError(t *testing.T) {
8
16
  if _, err := Classify(0); err != ErrOnlyPositive {
9
17
  t.Errorf("Expected error %q but got %q", ErrOnlyPositive, err)
@@ -31,11 +39,3 @@ func TestClassifiesCorrectly(t *testing.T) {
31
39
  }
32
40
  }
33
41
  }
34
-
35
- const targetTestVersion = 1
36
-
37
- func TestTestVersion(t *testing.T) {
38
- if testVersion != targetTestVersion {
39
- t.Errorf("Found testVersion = %v, want %v.", testVersion, targetTestVersion)
40
- }
41
- }
@@ -60,9 +60,8 @@ func (s rankCountSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
60
60
  func (s rankCountSlice) Less(i, j int) bool {
61
61
  if s[i].count != s[j].count {
62
62
  return s[i].count < s[j].count
63
- } else {
64
- return s[i].rank < s[j].rank
65
63
  }
64
+ return s[i].rank < s[j].rank
66
65
  }
67
66
 
68
67
  // The strength of a hand in a way that's easily comparable.
@@ -86,17 +85,15 @@ func (hv handValue) Compare(other handValue) ordering {
86
85
  if hv.discrs[i] != other.discrs[i] {
87
86
  if hv.discrs[i] < other.discrs[i] {
88
87
  return lessThan
89
- } else {
90
- return greaterThan
91
88
  }
89
+ return greaterThan
92
90
  }
93
91
  }
94
92
  return equalTo
95
93
  } else if hv.kind < other.kind {
96
94
  return lessThan
97
- } else {
98
- return greaterThan
99
95
  }
96
+ return greaterThan
100
97
  }
101
98
 
102
99
  func BestHand(hands []string) ([]string, error) {
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.0.8.9
4
+ version: 2.0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip