one_factorization 0.1.0 → 0.1.1

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: 9b599cdb22f50e70e8fb5832508fab77d242c465
4
- data.tar.gz: 925090896f71aa300fce94f9b3db38034c77360d
3
+ metadata.gz: 7f7192118dfc70a0868a0a9890eb13a14bac5b0f
4
+ data.tar.gz: 00ccaa705f2a197feaa1bb12081e1bfb491c936d
5
5
  SHA512:
6
- metadata.gz: e454a0f42f5200a0ff01bbde3290f93db24b975718c75db108fcb8e0feba011fbc1ce705237efb1114f4f4c70c40bf543b272bff6ae6916cc401ff2a3512e813
7
- data.tar.gz: 3e4f2e4228b5ba24199a6e081a74d87b9fffc6c69c6a46b30db523c569b8037677b4f7688b0c7758416ad29aa22283b077a6584e5649ab98c669145ea002a4ff
6
+ metadata.gz: 24c47a47493c42b18f464f4a389049178e92ba92ecb43253101e55618746307ce515c3f2a464e6d1673e32cde476d735eb0772f4635e84f2da97def493d51f6e
7
+ data.tar.gz: 172b6a48444fc6b13a670a5d32b1ae1aa9e93c10a3e9c4e08b5c72b02f541b1d57cb3372cc311e50e995c3ba15a5ca01ed36912d75aa5bd1932a34aa076b3109
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
@@ -1,17 +1,13 @@
1
1
  class Array
2
2
  def one_factorize
3
3
  number_pairs = length / 2
4
- set = []
5
4
  first, *rest = *self
6
- rest.each_with_index do |person, index|
7
- pairs = []
8
- pairs << [first, person]
9
- (1..number_pairs-1).each do |offset|
5
+ result = rest.each_with_index.inject([]) do |set, (person,index)|
6
+ set << (1..number_pairs-1).inject([[first, person]]) do |pairs, offset|
10
7
  pairs << [rest[(index-offset)%rest.length], rest[(index+offset)%rest.length]]
11
8
  end
12
- set << pairs
13
9
  end
14
- fail OneFactorization::InvalidLengthError.new(set) if length.odd?
15
- set
10
+ fail OneFactorization::InvalidLengthError.new(result) if length.odd?
11
+ result
16
12
  end
17
13
  end
@@ -1,3 +1,3 @@
1
1
  module OneFactorization
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one_factorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Joseph
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-11-13 00:00:00.000000000 Z
12
+ date: 2015-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler