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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3add01a35c88d8001cd82b2548555e8823686167
4
- data.tar.gz: e703f137d82640832dade1cddc55e327578eda3c
3
+ metadata.gz: b393a3f3971ef38672888997726641c90d072831
4
+ data.tar.gz: 0b56ff2a8bf0b701a51ad9ab86e82d2749686e83
5
5
  SHA512:
6
- metadata.gz: d8e31f46ac56d4e4f3303363947078e53f307060c4c31359ac95e7c7b80c951db44cf2b4f81acf734a1beaad371f87d4009fe61bcc8ca196d60058349ded7f80
7
- data.tar.gz: 07cdad5666f6fb71decfb1bdb304a9fd16cb7b9fe9d0c4ee211959927d98e04f2d41f837fdb7c6c641805a781197a1448f6f6ba00176411bb80d2ebbe4dfb858
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(STDIN.gets)
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
@@ -1,3 +1,3 @@
1
1
  module CongruenceSolver
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  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.0
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-08 00:00:00.000000000 Z
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