Giter Site home page Giter Site logo

game-of-codes-2017's Introduction

Game of Codes 2017 (Casumo Submission)

In this repository, you'll find Kyle Pullicino's (@KPull) submission, representing Casumo, for the Game of Codes 2017 programming competition held in February 2017 by the University of Malta ICTSA.

You will find the problem statement attached as a PDF file in the repository. You can also build the solution using gradle by typing in,

./gradlew build

After building, run the solution as follows,

java -jar build/libs/journey-1.0-SNAPSHOT.jar input.rds output.rt

Solution Overview

The program in Solution.java is a solution which always gives the optimal path (provided it doesn't crash due to memory constraints) as follows:

  1. Construct a graph containing every pair of town/time unit possible except for the destination (there is only one destination node).
    • Let's say there is a town called "Zebbug", and the maximum time limit is 1000, then the graph will contain nodes, Zebbug@0, Zebbug@1, Zebbug@2 and so on until Zebbug@1000.
  2. For every possible connection described in the input file, have an edge between the relevant town (at the relevant time). Assign a weight to the edge depending on the time it takes to travel that road at that particular time.
    • An exception: don't create edges for anything that will exceed the time limit.
  3. For coffee stops, create edges of weight 1 which stay at the same town.
    • For example, if a coffee stop exists at *SanGwann, we will have edges from *SanGwann@0 to *SanGwann@1 which in turn is connected SanGwann@2 and so on.
    • Exception: The coffee edges at our home town will have edge weight of 0!
  4. Use Dijkstra's algorithm to find the shortest path from the home town at time 0 to the destination town.
  5. Choose the shortest path which wins tiebreakers.

You can see the graph constructed for the example problem in the specification document below:

Example graph

Note: there is a better, more efficient way to use Dijkstra to also find the path which wins tiebreakers if you encode all the necessary information into the edge weights.

Disclaimer

Since the competitors have a time limit to make their submission, there was no attempt to make the code look good. Please do not use the code in this repository as an example of how to build good, readable, maintainable software. Otherwise, feel free to discuss the solution and ask questions!

game-of-codes-2017's People

Watchers

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