Giter VIP home page Giter VIP logo

countdown's Introduction

Countdown

A player is given 100 random 1 digit numbers and a random 4 digit target. They must create an arithmetic expression involving all 100 numbers using [+, -, x, /] that produces a result as close to the target as possible. The operations are applied in order so you should ignore order of operations and just evaluate everything in order of appearance. e.g. 1+2*6 = (1+2)6 = 18 NOT: 26+1 For instance, in a simpler game involving 3 numbers and a 2 digit target: Numbers=[2,5,9] Target: 1 Solution: ((5)*2)-9 = 1

I have implemented a random-restart hill climbing algorithm that attempts to find the expression that is as close as possible to the target using:-

  1. swap(n1,n2) - swaps the position of the number at index n1 with the one at index n2
  2. change(s1,op) - changes the operator at s1 to op

Using the same example above but cast as local search: Given:((5)+9)-2 (a random starting state) Target: 1 Swap(2,3): ((5)+2)-9 Change(1,*): ((5)*2)-9 Solution: ((5)*2)-9 = 1

countdown's People

Contributors

patelherat avatar

Stargazers

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