one_factorization 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/one_factorization/array.rb +4 -8
- data/lib/one_factorization/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f7192118dfc70a0868a0a9890eb13a14bac5b0f
|
4
|
+
data.tar.gz: 00ccaa705f2a197feaa1bb12081e1bfb491c936d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24c47a47493c42b18f464f4a389049178e92ba92ecb43253101e55618746307ce515c3f2a464e6d1673e32cde476d735eb0772f4635e84f2da97def493d51f6e
|
7
|
+
data.tar.gz: 172b6a48444fc6b13a670a5d32b1ae1aa9e93c10a3e9c4e08b5c72b02f541b1d57cb3372cc311e50e995c3ba15a5ca01ed36912d75aa5bd1932a34aa076b3109
|
data/.gitignore
CHANGED
@@ -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,
|
7
|
-
|
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(
|
15
|
-
|
10
|
+
fail OneFactorization::InvalidLengthError.new(result) if length.odd?
|
11
|
+
result
|
16
12
|
end
|
17
13
|
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.
|
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-
|
12
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|