congruence_solver 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/csolve +9 -6
- data/lib/congruence_solver/version.rb +1 -1
- metadata +2 -3
- data/.gitmodules +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b393a3f3971ef38672888997726641c90d072831
|
4
|
+
data.tar.gz: 0b56ff2a8bf0b701a51ad9ab86e82d2749686e83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb1940852e5fd52a401c2930e7ec5c4618a4057f28db0f9fb5e5c82aa9afde7baa726eb5682c75192d05abac2ebba16a8735cf081f14661126e75b9047075f9e
|
7
|
+
data.tar.gz: 79e606771aa55a145f826da75acc1eda95bb546297001d7688c73c2d01b5a8b67de74095cf4fbbfb5c48bd2222bd6dab86898846e439da789bc1f1bd73337cb8
|
data/bin/csolve
CHANGED
@@ -5,10 +5,14 @@ require "polynomial_interpreter"
|
|
5
5
|
|
6
6
|
SOLVE_CONGRUENCE_BENCH_FILE = "../bench/solve_congruence_bm.rb"
|
7
7
|
|
8
|
-
|
9
|
-
if ARGV.pop == "bench"
|
8
|
+
if ARGV[0] == "bench"
|
10
9
|
require_relative SOLVE_CONGRUENCE_BENCH_FILE
|
11
10
|
exit(0)
|
11
|
+
elsif ARGV[0] == "-c"
|
12
|
+
congruence = ARGV[1]
|
13
|
+
else
|
14
|
+
puts "Congruence to solve:"
|
15
|
+
congruence = STDIN.gets
|
12
16
|
end
|
13
17
|
|
14
18
|
CONGRUENCE_FORMAT = "(lhs polynomial) = (rhs polynomial) mod (modulus)"
|
@@ -18,10 +22,9 @@ LHS_INVALID_MSG = "Left hand polynomial invalid: polynomials must be of form: #{
|
|
18
22
|
RHS_INVALID_MSG = "Right hand polynomial invalid: polynomials must be of form: #{POLYNOMIAL_FORMAT}"
|
19
23
|
MOD_INVALID_MSG = "Mod invalid: modulus must be an integer greater than 2"
|
20
24
|
|
21
|
-
puts "Congruence to solve:"
|
22
25
|
|
23
26
|
begin
|
24
|
-
coeffs, mod = PolynomialInterpreter.read_congruence(
|
27
|
+
coeffs, mod = PolynomialInterpreter.read_congruence(congruence)
|
25
28
|
rescue ArgumentError => e
|
26
29
|
if(e == PolynomialInterpreter::Errors::CONGRUENCE_INVALID)
|
27
30
|
STDERR.puts CONGRUENCE_INVALID_MSG
|
@@ -46,9 +49,9 @@ end
|
|
46
49
|
|
47
50
|
solutions = CongruenceSolver.lift(coeffs, mod).sort
|
48
51
|
|
49
|
-
if solutions.empty?
|
52
|
+
if solutions.empty?
|
50
53
|
puts "No solution."
|
51
54
|
else
|
52
55
|
puts "Solutions:"
|
53
56
|
solutions.each_with_index {|sol, i| puts "(#{i}) #{sol}"}
|
54
|
-
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: congruence_solver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,6 @@ extensions:
|
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
96
|
- ".gitignore"
|
97
|
-
- ".gitmodules"
|
98
97
|
- ".rspec"
|
99
98
|
- ".travis.yml"
|
100
99
|
- Gemfile
|
data/.gitmodules
DELETED
File without changes
|