twisty_puzzles 0.0.26 → 0.0.30
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0921468026dd18bfa906d172939b0856c6d98081eff7fe2013e168daa66f090
|
4
|
+
data.tar.gz: 91ef593d14bc93213d6703d508c392ba0ca24d05cd20bfc6936391f0afb7a2ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5be09b84d72b7c36723fa4003fdb3ec7a8f068ae5c95e6e10956468f74c3730acb22de0e06b388a42b34c2b2af04bf62bf3cdedd5cf5d472fca70750f7735dd6
|
7
|
+
data.tar.gz: a842caaa9cebd5cdadc38cbf60c22439b49b1d923682fbfdd06a69ea92ccf3916c45bbe4c6c317f9fcc6b37d8d41fe81e9443717cf45c009548f474ad2c00142
|
@@ -4,7 +4,7 @@ module TwistyPuzzles
|
|
4
4
|
# Base class for directions.
|
5
5
|
class AbstractDirection
|
6
6
|
include Comparable
|
7
|
-
POSSIBLE_DIRECTION_NAMES = [[''], ['2', '2\''], ['\'', '3', '’']].freeze
|
7
|
+
POSSIBLE_DIRECTION_NAMES = [[''], ['2', '2\''], ['\'', '3', '’', '‘', '´', '`']].freeze
|
8
8
|
SIMPLE_DIRECTION_NAMES = (['0'] + POSSIBLE_DIRECTION_NAMES.map(&:first)).freeze
|
9
9
|
POSSIBLE_SKEWB_DIRECTION_NAMES = [['', '2\''], ['\'', '2']].freeze
|
10
10
|
SIMPLE_SKEWB_DIRECTION_NAMES = (['0'] + POSSIBLE_SKEWB_DIRECTION_NAMES.map(&:first)).freeze
|
data/lib/twisty_puzzles/cube.rb
CHANGED
@@ -72,6 +72,11 @@ module TwistyPuzzles
|
|
72
72
|
true
|
73
73
|
end
|
74
74
|
|
75
|
+
def self.exists_on_cube_size?(cube_size)
|
76
|
+
cube_size >= min_cube_size && cube_size <= max_cube_size &&
|
77
|
+
(cube_size.even? ? exists_on_even_cube_sizes? : exists_on_odd_cube_sizes?)
|
78
|
+
end
|
79
|
+
|
75
80
|
def num_incarnations(_cube_size)
|
76
81
|
1
|
77
82
|
end
|
@@ -478,10 +483,6 @@ module TwistyPuzzles
|
|
478
483
|
4
|
479
484
|
end
|
480
485
|
|
481
|
-
def self.exists_on_odd_cube_sizes?
|
482
|
-
false
|
483
|
-
end
|
484
|
-
|
485
486
|
def self.max_parseable_face_symbols
|
486
487
|
FACES + 1
|
487
488
|
end
|
@@ -17,16 +17,19 @@ module TwistyPuzzles
|
|
17
17
|
|
18
18
|
RAW_DATA_RESERVED = [' ', '(', ')'].freeze
|
19
19
|
|
20
|
-
def initialize(parts)
|
20
|
+
def initialize(parts, twist = 0)
|
21
21
|
raise ArgumentError if parts.empty?
|
22
|
+
raise TypeError unless twist.is_a?(Integer)
|
23
|
+
raise ArgumentError if twist.negative?
|
22
24
|
|
23
25
|
check_types(parts, Part)
|
24
26
|
check_type_consistency(parts)
|
25
27
|
|
26
28
|
@parts = parts
|
29
|
+
@twist = twist
|
27
30
|
end
|
28
31
|
|
29
|
-
attr_reader :parts
|
32
|
+
attr_reader :parts, :twist
|
30
33
|
|
31
34
|
def eql?(other)
|
32
35
|
self.class.equal?(other.class) && @parts == other.parts
|
@@ -79,6 +82,21 @@ module TwistyPuzzles
|
|
79
82
|
end.min
|
80
83
|
end
|
81
84
|
|
85
|
+
# Note that this returns the same answer for all rotations of one part.
|
86
|
+
def contains?(part)
|
87
|
+
@parts.any? { |p| p.turned_equals?(part) }
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns an equivalent cycle that starts with the given part.
|
91
|
+
# Raises an error if the cycle doesn't contain the given part.
|
92
|
+
def start_with(part)
|
93
|
+
raise ArgumentError unless contains?(part)
|
94
|
+
|
95
|
+
index = @parts.find_index { |p| p.turned_equals?(part) }
|
96
|
+
map_rotate_by_number = @parts[index].rotations.index(part)
|
97
|
+
rotate_by(@parts.length - index).map_rotate_by(map_rotate_by_number)
|
98
|
+
end
|
99
|
+
|
82
100
|
def equivalent?(other)
|
83
101
|
self == other || canonicalize == other.canonicalize
|
84
102
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twisty_puzzles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernhard F. Brodowsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|