very_ants 0.2.0 → 0.3.0

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: 97401c26760ed09adb9b24e2dd32c546f7da2ba0
4
- data.tar.gz: 01d46cabf2cbc9973a8421fae1039ac98534c317
3
+ metadata.gz: 21569d770867c68daa13130062d46471732495d3
4
+ data.tar.gz: 74d2390b9a12084c6098dbf87c851d237d1fd92f
5
5
  SHA512:
6
- metadata.gz: ec27c3409dd52f91d2e1fc5ad817d5f3a2a0660e0d8911539c66b3efb4d2f2f09dbc7f0565b1e14d65444a5804e96960da1119833c08e0cccf4a9862ab75d26e
7
- data.tar.gz: bee5af01387721d1f039df9e11d423453b96b15e88239eb0335bf3db898e8689b9a4175911910b551c9e1ae1452892d13de00c95c1c88c9003d0623f2addab18
6
+ metadata.gz: 459ce72aa7e054879724c8d193ad4582d72805d3c6a09e4ce9d1358ab9e6cf884e8ab2cf194ff9695a0447b4824a202f5899d0d7d55da040d6d6d01b467fc651
7
+ data.tar.gz: bb4748c3bc2cb53f25bc73a860dcd01f76b1b3efe561125aa55fd76ff49466fd936c86ec1c4aff5ec9af2479fc56da4646f0b9054ad88bc791304ea7d076c9b3
data/README.md CHANGED
@@ -7,20 +7,20 @@ each operation. For instance, given a constant `c`, arithmetic `x + y` is
7
7
  defined as:
8
8
 
9
9
  ```
10
- sum := 0, chance := 1 / c
10
+ sum := x, chance := 1 / c
11
11
 
12
12
  (c * y) times do
13
13
  r := [new random number between 0 and 1]
14
14
 
15
15
  if r < chance
16
- sum := sum + x
16
+ sum := sum + 1
17
17
 
18
18
  return sum
19
19
  ```
20
20
 
21
- So for `c = 3`, `x = 5`, `y = 2`, you start with `0`, and have a `1/3` chance
22
- of adding `5` to it six different times. On average, this would occur twice,
23
- which would give you 10, the correct answer. Another nice property is that for
21
+ So for `c = 3`, `x = 5`, `y = 2`, you start with `x`, and have a `1/3` chance
22
+ of adding `1` to it six different times. On average, this would occur twice,
23
+ which would give you 7, the correct answer. Another nice property is that for
24
24
  `c = 1`, addition works completely normally.
25
25
 
26
26
  All of the other arithmetic operators (`-`, `*`, `/`, `%`) have the same
data/lib/very_ants/int.rb CHANGED
@@ -23,7 +23,6 @@ module VeryAnts
23
23
  private
24
24
 
25
25
  def helper(init, incr, y, c)
26
- init = init
27
26
  chance = Rational(1, c)
28
27
  real_mult(c, y).times { init = real_plus(init, incr) if rand < chance }
29
28
  init
@@ -1,3 +1,3 @@
1
1
  module VeryAnts
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/very_ants.rb CHANGED
@@ -2,7 +2,7 @@ require "very_ants/int"
2
2
  require "very_ants/version"
3
3
 
4
4
  class Fixnum
5
- include VeryAnts::Int
5
+ extend VeryAnts::Int
6
6
 
7
7
  @@c = 1
8
8
 
@@ -15,22 +15,22 @@ class Fixnum
15
15
  end
16
16
 
17
17
  def +(other)
18
- plus(self, other, @@c)
18
+ Fixnum::plus(self, other, @@c)
19
19
  end
20
20
 
21
21
  def -(other)
22
- minus(self, other, @@c)
22
+ Fixnum::minus(self, other, @@c)
23
23
  end
24
24
 
25
25
  def *(other)
26
- mult(self, other, @@c)
26
+ Fixnum::mult(self, other, @@c)
27
27
  end
28
28
 
29
29
  def /(other)
30
- divide(self, other, @@c)
30
+ Fixnum::divide(self, other, @@c)
31
31
  end
32
32
 
33
33
  def %(other)
34
- mod(self, other, @@c)
34
+ Fixnum::mod(self, other, @@c)
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: very_ants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saghm Rossi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-21 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler