{"id":29225895,"url":"https://github.com/rohitpaulk/befunge-ruby","last_synced_at":"2025-07-03T07:38:46.478Z","repository":{"id":62554091,"uuid":"53718191","full_name":"rohitpaulk/befunge-ruby","owner":"rohitpaulk","description":"A befunge interpreter written in Ruby","archived":false,"fork":false,"pushed_at":"2017-05-02T17:07:45.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T12:09:36.438Z","etag":null,"topics":["interpreter","readability","ruby","rubygem"],"latest_commit_sha":null,"homepage":"http://www.rubydoc.info/github/rohitpaulk/befunge-ruby/master","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rohitpaulk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-12T06:59:41.000Z","updated_at":"2021-07-13T08:17:27.000Z","dependencies_parsed_at":"2022-11-03T05:00:28.715Z","dependency_job_id":null,"html_url":"https://github.com/rohitpaulk/befunge-ruby","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rohitpaulk/befunge-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohitpaulk%2Fbefunge-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohitpaulk%2Fbefunge-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohitpaulk%2Fbefunge-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohitpaulk%2Fbefunge-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohitpaulk","download_url":"https://codeload.github.com/rohitpaulk/befunge-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohitpaulk%2Fbefunge-ruby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263284387,"owners_count":23442533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interpreter","readability","ruby","rubygem"],"created_at":"2025-07-03T07:38:28.962Z","updated_at":"2025-07-03T07:38:46.457Z","avatar_url":"https://github.com/rohitpaulk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Befunger\n\nBefunge (without the 'r' at the end!) is a two-dimensional esoteric programming language invented in 1993 by Chris Pressey with the goal of being as difficult to compile as possible. (Source: [esolangs.org](https://esolangs.org/wiki/Befunge))\n\nBefunger is an interpreter for Befunge written in Ruby. I wrote this as an answer to [this Kata on codewars](https://www.codewars.com/kata/befunge-interpreter).\n\n### Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'befunger'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install befunger\n\n## Usage\n\n```\nrequire 'befunger'\n\nBefunge.run(code)\n```\n\n## Specification\n\nThis is the [original problem statement](https://www.codewars.com/kata/befunge-interpreter) I wrote this for:\n\nYour task is to write a method which will interpret Befunge-93 code! Befunge-93 is a language in which the code is presented not as a series of instructions, but as instructions scattered on a 2D plane; your pointer starts at the top-left corner and defaults to moving right through the code. Note that the instruction pointer wraps around the screen! There is a singular stack which we will assume is unbounded and only contain integers. While Befunge-93 code is supposed to be restricted to 80x25, you need not be concerned with code size. Befunge-93 supports the following instructions\n\n- `0-9` Push this number onto the stack.\n- `+` Addition: Pop a and b, then push a+b.\n- `-` Subtraction: Pop a and b, then push b-a.\n- `*` Multiplication: Pop a and b, then push a*b.\n- `/` Integer division: Pop a and b, then push b/a, rounded down. If a is zero, push zero.\n- `%` Modulo: Pop a and b, then push the b%a. If a is zero, push zero.\n- `!` Logical NOT: Pop a value. If the value is zero, push 1; otherwise, push zero.\n- `` ` `` Greater than: Pop a and b, then push 1 if b\u003ea, otherwise push zero.\n- `\u003e` Start moving right.\n- `\u003c` Start moving left.\n- `^` Start moving up.\n- `v` Start moving down.\n- `?` Start moving in a random cardinal direction.\n- `_` Pop a value; move right if value = 0, left otherwise.\n- `|` Pop a value; move down if value = 0, up otherwise.\n- `\"` Start string mode: push each character's ASCII value all the way up to the next \".\n- `:` Duplicate value on top of the stack. If there is nothing on top of the stack, push a 0.\n- `\\` Swap two values on top of the stack. If there is only one value, pretend there is an extra 0 on bottom of the stack.\n- `$` Pop value from the stack and discard it.\n- `.` Pop value and output as an integer.\n- `,` Pop value and output the ASCII character represented by the integer code that is stored in the value.\n- `#` Trampoline: Skip next cell.\n- `p` A \"put\" call (a way to store a value for later use). Pop y, x and v, then change the character at the position (x,y) in the program to the character with ASCII value v.\n- `g` A \"get\" call (a way to retrieve data in storage). Pop y and x, then push ASCII value of the character at that position in the program.\n- `@` End program.\n- ` ` (i.e. a space) No-op. Does nothing.\n\nHere's an example:\n\n```\n\u003e987v\u003e.v\nv456\u003c  :\n\u003e321 ^ _@\n```\n\nwill create the output `123456789`.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rohitpaulk/befunge-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohitpaulk%2Fbefunge-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohitpaulk%2Fbefunge-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohitpaulk%2Fbefunge-ruby/lists"}