twisty_puzzles 0.0.27 → 0.0.28

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: 50d977c5e137d9396e79e1cf39f6143e99b457549c0cd518ada8b2c4a35c428c
4
- data.tar.gz: f092b98630606b231ecb60c6020cd6528225d9e5771229147973afe4b3312b43
3
+ metadata.gz: 7843aac67563062698ede8d6de86b76153901bcccee07d3367863ef9e81096d4
4
+ data.tar.gz: 4fe82e4186f3c832c502279748b27310658da80b057c9ff99ce22f5b04c46308
5
5
  SHA512:
6
- metadata.gz: 210297dea0bf79343a405e3d3a0f8a7c7f7bc0c680302ad25535aaefcbea3fd7e4c84e0ea6a9bc05c76e45e897d9f1a69c1199d2b4aae0e5e291c2d000e80fa2
7
- data.tar.gz: 104110df13cf554e59e9c32cad74452869a0aa628565898df000e416eaf4ebf38b02d2df39f58dc2a508148d1f42fdbd59e08d9ff37859bce7a589efd3389fb5
6
+ metadata.gz: 1df3581ec635a06f6c0ef9221a518d5174fbfa4b30e7439f27e2c3ff1b185141d7dd5e86a979c9b66610af5b21d6564f61ae8b93909e43c7e2b79976f4c3333d
7
+ data.tar.gz: cc0899a42896b078a423fb511f61b63dc3f9a327824a0a68d9cfce17857cffaa7f5288a15629ab527e6c0ebb3257ce026c139028b008dec1699fcbdb61fa02ed
@@ -79,6 +79,21 @@ module TwistyPuzzles
79
79
  end.min
80
80
  end
81
81
 
82
+ # Note that this returns the same answer for all rotations of one part.
83
+ def contains?(part)
84
+ @parts.any? { |p| p.turned_equals?(part) }
85
+ end
86
+
87
+ # Returns an equivalent cycle that starts with the given part.
88
+ # Raises an error if the cycle doesn't contain the given part.
89
+ def start_with(part)
90
+ raise ArgumentError unless contains?(part)
91
+
92
+ index = @parts.find_index { |p| p.turned_equals?(part) }
93
+ map_rotate_by_number = @parts[index].rotations.index(part)
94
+ rotate_by(@parts.length - index).map_rotate_by(map_rotate_by_number)
95
+ end
96
+
82
97
  def equivalent?(other)
83
98
  self == other || canonicalize == other.canonicalize
84
99
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TwistyPuzzles
4
- VERSION = '0.0.27'
4
+ VERSION = '0.0.28'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twisty_puzzles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernhard F. Brodowsky