array-symmetries 0.0.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 +7 -0
- data/lib/array.rb +23 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 49ea03047cf748c0cfad24e2d2c98bad6aeeac841b7ee7c10a5a3eba9bd858dc
|
|
4
|
+
data.tar.gz: 76db02d721b3a571879bd29acc277e058da00c00c6c422aba056809fb6e3ee95
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d08b9adeb7cb6f908641ee19c5b5226423efca083e2cfecbe5f2ac0820141af14cea2187753ac416499fa247cb7e03815f6b7305ab8631d055df2abf12f652d6
|
|
7
|
+
data.tar.gz: 60cd51edae458292160236c50d6750c69932a84b2a2bb5f97fedbefd02b4e3c5214d325493fcc92435eb2897be2d2412a15ff0ca89ac7760b860ca83d53d95b8
|
data/lib/array.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Array # yeah it's a monkey patch
|
|
2
|
+
def square?
|
|
3
|
+
all? {|e| e.length == length}
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
# see https://en.wikipedia.org/wiki/Examples_of_groups#The_symmetry_group_of_a_square:_dihedral_group_of_order_8
|
|
7
|
+
|
|
8
|
+
def b
|
|
9
|
+
raise ArgumentError unless square?
|
|
10
|
+
reverse
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def a
|
|
14
|
+
raise ArgumentError unless square?
|
|
15
|
+
b.transpose
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def symmetries
|
|
19
|
+
raise ArgumentError unless square?
|
|
20
|
+
[self, b, a, a.a, a.a.a, a.b, a.a.b, a.a.a.b]
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: array-symmetries
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Lorraine Lee
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: The group of symmetries of the square, applied to Ruby arrays of n elements
|
|
14
|
+
that are arrays of n elements, for some value of n.
|
|
15
|
+
email: lori@astoundingteam.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/array.rb
|
|
21
|
+
homepage: https://gitlab.com/n8chz/array-symmetries
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.7.6
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Generate symmetries of a square array.
|
|
45
|
+
test_files: []
|