very_ants 0.2.0 → 0.3.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/README.md +5 -5
- data/lib/very_ants/int.rb +0 -1
- data/lib/very_ants/version.rb +1 -1
- data/lib/very_ants.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21569d770867c68daa13130062d46471732495d3
|
4
|
+
data.tar.gz: 74d2390b9a12084c6098dbf87c851d237d1fd92f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 :=
|
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 +
|
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 `
|
22
|
-
of adding `
|
23
|
-
which would give you
|
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
data/lib/very_ants/version.rb
CHANGED
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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|