ac-library-rb 1.1.0 → 1.2.0
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/lib/ac-library-rb/version.rb +1 -1
- data/lib/core_ext/integer.rb +31 -0
- data/lib/deque.rb +3 -3
- data/lib_lock/ac-library-rb/core_ext/integer.rb +31 -0
- data/lib_lock/ac-library-rb/deque.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19c290e3ada0938fb7281031ac3cef77dde32f3f1200ca057ef132c132461c7b
|
4
|
+
data.tar.gz: dc224c10271238974e2b336776ba99128543b488e5d7386291d5b30dcb04a1b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c2ad9efa4fe5cb85bc3511a01ca04bc1886e63b123ab175153148cb8a456f60cf4defa896e9649e4f055931ba554ad842dc1545cee0a93b3ea3c1b5570c11df
|
7
|
+
data.tar.gz: 305147ce9a7a76ade5cb6b541a13f2fe9b31ac179381f21f96ad56963baa4b35355adf661d9a05826ff1218a6dd91eb6b0841e2a5eee486c1b1bed956ae67d7e
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "prime"
|
2
|
+
|
3
|
+
class Integer
|
4
|
+
# Returns the positive divisors of +self+ if +self+ is positive.
|
5
|
+
#
|
6
|
+
# == Example
|
7
|
+
# 6.divisors #=> [1, 2, 3, 6]
|
8
|
+
# 7.divisors #=> [1, 7]
|
9
|
+
# 8.divisors #=> [1, 2, 4, 8]
|
10
|
+
def divisors
|
11
|
+
if prime?
|
12
|
+
[1, self]
|
13
|
+
elsif self == 1
|
14
|
+
[1]
|
15
|
+
else
|
16
|
+
xs = prime_division.map{ |p, n| Array.new(n + 1){ |e| p**e } }
|
17
|
+
x = xs.pop
|
18
|
+
x.product(*xs).map{ |t| t.inject(:*) }.sort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Iterates the given block for each divisor of +self+.
|
23
|
+
#
|
24
|
+
# == Example
|
25
|
+
# ds = []
|
26
|
+
# 10.divisors{ |d| ds << d }
|
27
|
+
# ds #=> [1, 2, 5, 10]
|
28
|
+
def each_divisor(&block)
|
29
|
+
block_given? ? divisors.each(&block) : enum_for(:each_divisor)
|
30
|
+
end
|
31
|
+
end
|
data/lib/deque.rb
CHANGED
@@ -238,9 +238,9 @@ class Deque
|
|
238
238
|
end
|
239
239
|
|
240
240
|
def inspect
|
241
|
-
"Deque#{to_a}
|
242
|
-
|
243
|
-
|
241
|
+
"Deque#{to_a}"
|
242
|
+
# "Deque#{to_a}(@n=#{@n}, @buf=#{@buf}, @head=#{@head}, @tail=#{@tail}, "\
|
243
|
+
# "size #{size}#{' full' if __full?}#{' rev' if reversed?})"
|
244
244
|
end
|
245
245
|
|
246
246
|
private def __push(x)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "prime"
|
2
|
+
|
3
|
+
class Integer
|
4
|
+
# Returns the positive divisors of +self+ if +self+ is positive.
|
5
|
+
#
|
6
|
+
# == Example
|
7
|
+
# 6.divisors #=> [1, 2, 3, 6]
|
8
|
+
# 7.divisors #=> [1, 7]
|
9
|
+
# 8.divisors #=> [1, 2, 4, 8]
|
10
|
+
def divisors
|
11
|
+
if prime?
|
12
|
+
[1, self]
|
13
|
+
elsif self == 1
|
14
|
+
[1]
|
15
|
+
else
|
16
|
+
xs = prime_division.map{ |p, n| Array.new(n + 1){ |e| p**e } }
|
17
|
+
x = xs.pop
|
18
|
+
x.product(*xs).map{ |t| t.inject(:*) }.sort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Iterates the given block for each divisor of +self+.
|
23
|
+
#
|
24
|
+
# == Example
|
25
|
+
# ds = []
|
26
|
+
# 10.divisors{ |d| ds << d }
|
27
|
+
# ds #=> [1, 2, 5, 10]
|
28
|
+
def each_divisor(&block)
|
29
|
+
block_given? ? divisors.each(&block) : enum_for(:each_divisor)
|
30
|
+
end
|
31
|
+
end
|
@@ -239,9 +239,9 @@ module AcLibraryRb
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def inspect
|
242
|
-
"Deque#{to_a}
|
243
|
-
|
244
|
-
|
242
|
+
"Deque#{to_a}"
|
243
|
+
# "Deque#{to_a}(@n=#{@n}, @buf=#{@buf}, @head=#{@head}, @tail=#{@tail}, "\
|
244
|
+
# "size #{size}#{' full' if __full?}#{' rev' if reversed?})"
|
245
245
|
end
|
246
246
|
|
247
247
|
private def __push(x)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ac-library-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- universato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prime
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/ac-library-rb/version.rb
|
137
137
|
- lib/convolution.rb
|
138
138
|
- lib/core_ext/all.rb
|
139
|
+
- lib/core_ext/integer.rb
|
139
140
|
- lib/core_ext/modint.rb
|
140
141
|
- lib/crt.rb
|
141
142
|
- lib/deque.rb
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- lib_helpers/ac-library-rb/all.rb
|
160
161
|
- lib_lock/ac-library-rb/convolution.rb
|
161
162
|
- lib_lock/ac-library-rb/core_ext/all.rb
|
163
|
+
- lib_lock/ac-library-rb/core_ext/integer.rb
|
162
164
|
- lib_lock/ac-library-rb/core_ext/modint.rb
|
163
165
|
- lib_lock/ac-library-rb/crt.rb
|
164
166
|
- lib_lock/ac-library-rb/deque.rb
|