pairing_function 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/pairing_function.rb +13 -0
  3. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e26dd8e2275a1b8a20a1809b4bd500bdf2ccdfe9
4
+ data.tar.gz: 3edb386d0d320bf0febc4c8fa3f2bf34574f60b8
5
+ SHA512:
6
+ metadata.gz: ae0256c026843b092510a2525deb681dd50df8f9e1d6b44102bcb61e17a16c3917bd407a23a6d998b5e583194bd38512c59fd9deb09871b34ccff090651b7d06
7
+ data.tar.gz: a531f642e0416e9282c627f1ceabdb37f5dc864697f50d6576aa691ae67821d05c9d49f1cc23e3f62c3d3b53a0e0d3d523d2516fdf82927c43d58c08e4be8b20
@@ -0,0 +1,13 @@
1
+ class PairingFunction
2
+ def self.pair(x, y)
3
+ (((x + y)**2) + (3 * x) + y) / 2
4
+ end
5
+
6
+ def self.unpair(z)
7
+ c = (((Math.sqrt((8 * z) + 1)) - 1) / 2).floor
8
+ x = z - ((c * (c + 1)) / 2)
9
+ y = (c * (c + 3) / 2) - z
10
+
11
+ return x, y
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pairing_function
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Phaneendra Marisa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-04-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Any pairing function can be used in set theory to prove that integers
14
+ and rational numbers have the same cardinality as natural numbers.
15
+ email: phaneendra.marisa@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/pairing_function.rb
21
+ homepage: https://github.com/spmarisa/pairing_function
22
+ licenses:
23
+ - WTFPL
24
+ metadata:
25
+ source_code_uri: https://github.com/spmarisa/pairing_function
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.6.13
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: In mathematics, a pairing function is a process to uniquely encode two natural
46
+ numbers into a single natural number.
47
+ test_files: []