Giter Club home page Giter Club logo

exprgen's Introduction

Puzzle

Generate random arithmetic expressions, that have N literals, each literal is integer and does not exceed M in absolute value. Expression evaluation result should not exceed M in absolute value as well.

Allowed arithmetic operations: addition, subtraction, multiplication, division. Operations have usual precedence and left associativity.

Examples

N M Expression
6 100 (5+13)/(-2+1*(4-3))
10 20 (-4-4+3/(-4))/18*(-15)/(18*17/3-14)

Goals

  • Implementation should read N and M from file and/or command line arguments.
  • Expression should not contain redundant parentheses. For instance, ((5+(6*7)) should actually be 5+6*7, whereas 5*(-2) has no redundant parentheses.
  • Generation should be comprehensive.

How to run

  1. Install stack + ghc or libtinfo5

  2. Run stack install in project root to compile and copy binary file to stack local bin storage (by default: ~/.local/bin)

    Useful commands:

    • stack build - compile only
    • stack ghci - run REPL with project modules
    • stack test - run unit tests
  3. Run exprgen --help for further instructions

    Example: exprgen -n 10 -m 20 -s 1

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.