GithubHelp home page GithubHelp logo

fresh_repo's Introduction

Befunge Interpreter Prototype

Resources

v >$>  v <>0v
4>|v?v#?#^?8v
4!8123    9 1
g-4>>>># >>1v
:**v <4>5^v<+
84-p 4^?6^\9:
>^&& 4 >7^%58
v:<< ^+*  <^<
>." si",,,-:v
v"correct!"<!
8>"wol ",,v|<
2|,,,"too"  <
9 >:#,_@#:<`!
\> "hgih "^>^
>#^/#p*#44#4_

Instructions

Write a Befunge-93 interpreter createBefungeApplication in JavaScript that will, given an initial string of Befunge source code, return a function that will run the Befunge code every time it is called, with the parameters acting as the program's input.

  • Keep in mind that Befunge applications can modify their own source code, which stays modified for successive program executions.
function createBefungeApplication(originalSourceCode){ /* ... */ }

const guessingGameSource = 'v >$>  v <>0v\n4>|v?v#?#^?8v\n4!8123    9 1\ng-4>>>># >>1v\n:**v <4>5^v<+\n84-p 4^?6^\9:\n>^&& 4 >7^%58\nv:<< ^+*  <^<\n>." si",,,-:v\nv"correct!"<!\n8>"wol ",,v|<\n2|,,,"too"  <\n9 >:#,_@#:<`!\n\> "hgih "^>^\n>#^/#p*#44#4_';

const makeGuess = createBefungeApplication(guessingGameSource);

console.log(makeGuess(5)); // 5 is too low
console.log(makeGuess(8)); // 8 is too high
console.log(makeGuess(7)); // 7 is correct!

console.log(makeGuess(7)); // 7 is too high
console.log(makeGuess(3)); // 7 is too high
console.log(makeGuess(1)); // 7 is correct!

//  ... and so on

fresh_repo's People

Contributors

timelikeclosure avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.