Giter VIP home page Giter VIP logo

piworks's Introduction

Very intelligent and somewhat slow algorithm to do the following.

You will have an orthogonal triangle input from a file and you need to find the maximum sum of the numbers according to given rules below;

  1. You will start from the top and move downwards to an adjacent number as in below.
  2. You are only allowed to walk downwards and diagonally.
  3. You can only walk over NON PRIME NUMBERS.
  4. You have to reach at the end of the pyramid as much as possible.
  5. You have to treat your input as pyramid.

According to above rules the maximum sum of the numbers from top to bottom in below example is 24.

   *1
  *8 4
 2 *6 9
8 5 *9 3

As you can see this has several paths that fits the rule of NOT PRIME NUMBERS; 1>8>6>9, 1>4>6>9, 1>4>9>9 1 + 8 + 6 + 9 = 24. As you see 1, 8, 6, 9 are all NOT PRIME NUMBERS and walking over these yields the maximum sum. Works with negative numbers as well.

According to above rules the maximum sum of the numbers from top to bottom in below example is 4.

   *1
  6 *1
 4 2 *1
2 2 2 *1

Though the sum on the left-most arm is 1+6+4 = 11 it is not considered as the deserved path since there is a longer path in the pyramid. So longer path is prior to greater sum.


To run the jar file please write "java -jar ./PIWORKS.jar < input.txt" to console in the same directory with jar file.

Remember to check your java PATH variable whether it is correctly set.

piworks's People

Contributors

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