ClosestSum 1.0.0-universal-linux → 1.1.0-universal-linux

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ClosestSum.rb +7 -4
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73a1a35c10fe80ea85a4dae42cb1072fabd2b8ef
4
- data.tar.gz: 5f0d2000bd22f8291e3299fd145b0980a649bbb6
3
+ metadata.gz: d682f216b3324060a57b1dbce50d994077a83052
4
+ data.tar.gz: 757ccf8a8c79ab64256b8a5418e5ae0620918da1
5
5
  SHA512:
6
- metadata.gz: e73eb16348576b76b869adec3c287b2674d09044a462263c594719cf53849dbf464eeb7a536f906a12df76304512e56c97df99e0c47a84cd3effa177451bb91e
7
- data.tar.gz: 731f0c1378e9a1df73fa62909117be1559531430d41660fb187c29ebf75574039377798211676d86646183f25f3f3495997a202b8daa72bb74214c847694ace8
6
+ metadata.gz: f7e681c0475b06520415617ec1a02b009228ac55e9c7bbb8df8c38cac4fd4e90543e9ccc72f8c5d58ec97b0ea4682c445d9f274e8d6596675ee0f220ab8eddf4
7
+ data.tar.gz: b77e8f9a111f61433f8433a333ad4eea1c349119143e27f01f27e30e22076dd0c2dffaecb8b092b6a88d0b9f4adae5bea20046d2e75d04af805fe42756a58b8b
data/lib/ClosestSum.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # Algorithm --
8
8
  # 20) Sort the hash as per the largest to the smallest.
9
9
  # 40) Check if adding the next entity (i.e. the 1st entity for the 1st run) to the current 'final list' will exceed the first argument. If so move to 60, otherwise 50.
10
- # 50) Add the entity to final list and move to 40 if 'final list' total size != the first argument, otherwise exist program.
10
+ # 50) Add the entity to final list and move to 40 if 'final list' total size != the first argument, otherwise exit program.
11
11
  # 60) Skip to the next entity if it exists. If it does not, return final list and exit program.
12
12
 
13
13
  # Variable list --
@@ -40,14 +40,17 @@ module ClosestSum
40
40
  inputHash = inputHash.sort_by {
41
41
  |x, y|
42
42
  y
43
- }.reverse
43
+ }.reverse
44
44
  totalCurrentSize = totalSize(finalList)
45
45
  inputHash.each {
46
46
  |key, value|
47
47
  if finalList[key] == nil
48
- finalList[key] = value if totalCurrentSize + value <= targetSize
48
+ if totalCurrentSize + value <= targetSize
49
+ finalList[key] = value
50
+ totalCurrentSize += value
51
+ end
49
52
  end
50
53
  }
51
54
  finalList
52
55
  end
53
- end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ClosestSum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: universal-linux
6
6
  authors:
7
7
  - dE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-30 00:00:00.000000000 Z
11
+ date: 2017-11-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Given a hash of keys and numeric values and another integer value (target
14
14
  size), this module will select the largest keys from the given hash such that the
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  version: '0'
41
41
  requirements: []
42
42
  rubyforge_project:
43
- rubygems_version: 2.5.2
43
+ rubygems_version: 2.2.2
44
44
  signing_key:
45
45
  specification_version: 4
46
46
  summary: Given a list of names/paths and the corresponding numeric value, will select