Quest Wars II - New Frontiers: Win a pass for jPrime 2017

20 Apr 2017

As a supporter of the local Java community we are giving away a ticket for the third jPrime conference that will take place on 30th and 31th May in Sofia Tech Park. The conference is organized by the Bulgarian Java User Group and features a combination of great international speakers along with the best local lecturers.

How to get a pass? By taking part in our Quest Wars 2 and helping us solve the Solar System problem.

The challenge

Following the successful launch of our store on Endor last year we have decided to expand to the rest of the Endor Solar System - to deliver fresh fruit, meat, fish and any other food they need wherever they live.

 

In the solar system each planet takes a circular journey centered around the midpoint of the systems two suns (Endor I and Endor II). Each planet takes speed number of days to perform a full orbit at a distance distanceFromCenter from the middle of these suns and at time = 0 the planet is startDegrees degrees around from the starting location.

questwars2.png

Given a Set of Planet values to calculate the most efficient sequence of planets to visit taking off from the innermost planet to visit all of the planets - we need to calculate the optimal sequence of planets. Using our fleet of high tech vehicles we can safely navigate close to the sun so we can ignore them during our planning, we also have come up with a way to instantly accelerate the ship to shipVelocity km per day, additionally we can assume that the landing and launch site are in the middle of the planet and finally we can assume that we take no time to drop off our cargo at each planet that we visit.

The best code solutions (idea, performance, code clarity, etc) will win a free ticket to jPrime! The lucky winner will be announced on May 25th.

Starting point


class Planet {

  public int getSpeed(); //days per orbit

  public float getStartDegrees(); //degrees at time = 0

  public int getDistanceFromCenter(); //in km

}

class Optimiser {

  List<Planet> optimiseRoute(Set<Planet> planets, int launchDay, int shipVelocity) {

  …

  }

}


You can add methods to both the Planet and the Optimiser as you see fit.