mmcs_urm 0.1.0 → 0.1.2
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/CODE_OF_CONDUCT.md +1 -1
- data/README.md +4 -6
- data/lib/urm/coder.rb +10 -2
- data/lib/urm/version.rb +1 -1
- data/lib/urm.rb +0 -41
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8b82cee990393ce4994c2a5f7a1448fbe56eea50e2145c0b284c9c290e42a29
|
4
|
+
data.tar.gz: e5150e25302a4922835275ea74f860c269eff12c140ee17a6d8bc43c543e2e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91ea58efd3e0ece356455a1cf0719a47876bade9920b443a622055cf6d59e1f2bdfcf762cc99a5dea6ba972347df124704d6e2ff49e943e9bef7a6b608b89ab
|
7
|
+
data.tar.gz: 609e13dcb9835127b96c7a28a49bc00508175fea1a00067f88ed5f883f5761940b4d3572921bc0bdd8b10d46e4c624401d06f7a996e12d3e1e774e2a482ebe7e
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -60,7 +60,7 @@ representative at an online or offline event.
|
|
60
60
|
|
61
61
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
62
|
reported to the community leaders responsible for enforcement at
|
63
|
-
|
63
|
+
kudriavtsiev2004@gmail.com.
|
64
64
|
All complaints will be reviewed and investigated promptly and fairly.
|
65
65
|
|
66
66
|
All community leaders are obligated to respect the privacy and security of the
|
data/README.md
CHANGED
@@ -4,15 +4,13 @@ This gem is designed for convenient and fast construction and verification of UR
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
8
|
-
|
9
7
|
Install the gem and add to the application's Gemfile by executing:
|
10
8
|
|
11
|
-
$ bundle add
|
9
|
+
$ bundle add mmcs_urm
|
12
10
|
|
13
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
12
|
|
15
|
-
$ gem install
|
13
|
+
$ gem install mmcs_urm
|
16
14
|
|
17
15
|
## Usage
|
18
16
|
|
@@ -26,7 +24,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
24
|
|
27
25
|
## Contributing
|
28
26
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/YBarsukova/URM. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/YBarsukova/URM/blob/master/CODE_OF_CONDUCT.md).
|
30
28
|
|
31
29
|
## License
|
32
30
|
|
@@ -34,4 +32,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
34
32
|
|
35
33
|
## Code of Conduct
|
36
34
|
|
37
|
-
Everyone interacting in the DemoGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
35
|
+
Everyone interacting in the DemoGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/YBarsukova/URM/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/urm/coder.rb
CHANGED
@@ -10,10 +10,18 @@ module Urm
|
|
10
10
|
# into unique numerical representations and back. The primary methods available in this class are:
|
11
11
|
#
|
12
12
|
# - `self.code_single_instruction`: Encodes a single URM instruction into a Godel number.
|
13
|
-
# - `self.code_machine`: Encodes an entire URM machine
|
13
|
+
# - `self.code_machine`: Encodes an entire URM machine into an array of Godel numbers.
|
14
14
|
# - `self.godel_code`: Encodes an array of integers into a single Godel number.
|
15
|
+
# - `self.decode_single_instruction`: Decodes a Godel number back into a single URM instruction.
|
16
|
+
# - `self.decode_machine`: Decodes an array of Godel numbers back into a URM machine.
|
17
|
+
# - `self.extract_exponents`: Extracts the exponents from a Godel number.
|
15
18
|
#
|
16
|
-
#
|
19
|
+
# The class supports the following instruction types:
|
20
|
+
# - :set => [1, label, register, value]
|
21
|
+
# - :inc => [2, label, register]
|
22
|
+
# - :dec => [3, label, register]
|
23
|
+
# - :if => [4, label, register, label_true, label_false]
|
24
|
+
# - :stop => [5, label]
|
17
25
|
class Coder
|
18
26
|
def self.code_single_instruction(instruction)
|
19
27
|
code = case instruction.type
|
data/lib/urm/version.rb
CHANGED
data/lib/urm.rb
CHANGED
@@ -14,46 +14,5 @@ require "urm/machine_tester"
|
|
14
14
|
# and stopping the machine. It also provides methods to parse instructions from
|
15
15
|
# strings and convert them back to their string representations.
|
16
16
|
module Urm
|
17
|
-
class Error < StandardError; end
|
18
17
|
|
19
|
-
# Машина для умножения
|
20
|
-
multiplication_machine = Urm::Machine.new(2)
|
21
|
-
|
22
|
-
multiplication_instructions = [
|
23
|
-
"1. if x3 == 0 goto 9 else goto 2", # if x3 == 0 goto 9 else 2
|
24
|
-
"2. x3 = x3 - 1", # x3 = x3 - 1
|
25
|
-
"3. x4 = x2", # x4 = x2
|
26
|
-
"4. if x4 == 0 goto 8 else goto 5", # if x4 == 0 goto 8 else 5
|
27
|
-
"5. x1 = x1 + 1", # x1 = x1 + 1
|
28
|
-
"6. x4 = x4 - 1", # x4 = x4 - 1
|
29
|
-
"7. if x4 == 0 goto 8 else goto 5", # if x4 == 0 goto 8 else 5
|
30
|
-
"8. if x3 == 0 goto 9 else goto 2", # if x3 == 0 goto 9 else 2
|
31
|
-
"9. stop" # stop
|
32
|
-
]
|
33
|
-
|
34
|
-
# Добавляем массив строк с парсингом
|
35
|
-
multiplication_machine.add_all(multiplication_instructions)
|
36
|
-
|
37
|
-
MachineTester.assert_range(multiplication_machine, 0, 100, ->(x, y) { x * y })
|
38
|
-
|
39
|
-
# Машина для деления
|
40
|
-
division_machine = Urm::Machine.new(2)
|
41
|
-
|
42
|
-
division_instructions = [
|
43
|
-
Urm::Instruction.if(1, 2, 10, 2), # 1. if x2 == 0 goto 10 else 2
|
44
|
-
Urm::Instruction.copy(2, 4, 3), # 2. x4 = x3
|
45
|
-
Urm::Instruction.dec(3, 2), # 3. x2 = x2 - 1
|
46
|
-
Urm::Instruction.dec(4, 4), # 4. x4 = x4 - 1
|
47
|
-
Urm::Instruction.if(5, 2, 6, 7), # 5. if x2 == 0 goto 6 else 7
|
48
|
-
Urm::Instruction.if(6, 4, 8, 10), # 6. if x4 == 0 goto 8 else 10
|
49
|
-
Urm::Instruction.if(7, 4, 8, 3), # 7. if x4 == 0 goto 8 else 3
|
50
|
-
Urm::Instruction.inc(8, 1), # 8. x1 = x1 + 1
|
51
|
-
Urm::Instruction.if(9, 2, 10, 2), # 9. if x2 == 0 goto 10 else 2
|
52
|
-
Urm::Instruction.stop(10) # 10. stop
|
53
|
-
]
|
54
|
-
|
55
|
-
# Добавляем массив инструкций
|
56
|
-
division_machine.add_all(division_instructions)
|
57
|
-
|
58
|
-
MachineTester.assert_range(division_machine, 1, 100, ->(x, y) { x / y })
|
59
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mmcs_urm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LSN
|
@@ -42,8 +42,8 @@ licenses:
|
|
42
42
|
- MIT
|
43
43
|
metadata:
|
44
44
|
homepage_uri: https://github.com/YBarsukova/urm_dev
|
45
|
-
source_code_uri: https://github.com/YBarsukova/
|
46
|
-
changelog_uri: https://github.com/YBarsukova/
|
45
|
+
source_code_uri: https://github.com/YBarsukova/urm
|
46
|
+
changelog_uri: https://github.com/YBarsukova/urm
|
47
47
|
rubygems_mfa_required: 'true'
|
48
48
|
post_install_message:
|
49
49
|
rdoc_options: []
|