mmcs_urm 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8183b0ad83cedd32ee5aed3f06186b47a1131340e896ff153b9cc7b1ce91909
4
- data.tar.gz: 71151b0f5847bab6c78611071f78db1c4a4330578465c18cbce0ea2f3bbc05e8
3
+ metadata.gz: e8632539dc95c03935141693cf4b7182a1f58da6a2a4a0b90c6650b8cca8edf7
4
+ data.tar.gz: ddd42fdae6bb4b8c1870a3de479e3abba333705df822455a20f072d1263ccff6
5
5
  SHA512:
6
- metadata.gz: 6a061b01d25f881f5b8a9c9abe7e98a4744eb3779b53738bec4825838d609d7723c08ae3d22d302475ec51da8cc5a50706ff4df8dbee9122e17a5d6d2ab7d99c
7
- data.tar.gz: 7fc7950dc763f16b7b2749201617c4a9968eba5564d83515ca4654fd81c055be918344f4d3fb0fc6e303ff6bc2f52273562fc5cc6972ac1c4a2c96edd9b46d02
6
+ metadata.gz: fb14434386f79000ff2a2ec3ae227265fcd0e67a8f0347905f27a6c3d8db908531c10b983d7ffbc8bcda8ee98fdfe4f919058781f257a74c23322e2483d95acc
7
+ data.tar.gz: 8153c8952c4718c651cd5066913b0eb0873a6e75f123190eff256791fe303c76253347392ee06d9193af513a511581355b2f298db2baf065ebfeb303ed5404b9
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
- [INSERT CONTACT METHOD].
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
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/[USERNAME]/demo_gem. 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/[USERNAME]/demo_gem/blob/master/CODE_OF_CONDUCT.md).
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/[USERNAME]/demo_gem/blob/master/CODE_OF_CONDUCT.md).
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 (a sequence of instructions) into an array of Godel numbers.
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
- # TODO add about decoding
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Urm
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LSN