GithubHelp home page GithubHelp logo

beltex's Introduction

Beltex Combinations

I wrote this code as I was playing Beltex in order to find the right combinations to get to a number.

Usage

cargo build --release
./target/release/beltex [--base=<base>] <target>

For more information :

./target/release/beltex --help

Problem

The problem was to get to a number from a limited set of a numbers and some operations.

The available operations are addition, substraction and multiplication.

For example, if your base set of a number is [1, 2, 3, 4, 5, 6], if you want to get to 26 in the least amount of steps, you can do :

  • 1 + 5 * 5
  • 2 + 4 * 6
  • 5 * 6 - 4
  • 6 + 4 * 5

Algorithm

The algorithm I made up works in iterations.

Each iteration tries every new combinations available of numbers and store their result along with their complexity (i.e. the number of steps to get to it) into two HashMap.

So if you want to get to a number, you can just iterate until a combination has been found for the number.

beltex's People

Contributors

adambrutsaert 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.