Hard Puzzle Game Solver

-10

There is an app called Hard Puzzle which is a game where there is a red circle, and you have to fill all of the surface area with five smaller white circlesThe Challenge

it may seen easy, but it's harder than it looks (it just takes a while to figure out). The circle dimensions change from device to device in the image above the red circles area is 41990 pixels although on my device it is 40496 pixels this is not important though.

So the challenge is to create the fastest algorithm (in any language) that solves this puzzle, by outputting the coordinates of where each white circle should be. Puzzle info: Red circle area = 40496 pixels. each white circle's area = 15656 pixels (38.661% of red circle)

Your time starts now there is 3 days for completion of the task

GO!!

flint

Posted 2015-08-20T12:15:34.177

Reputation: 1

Question was closed 2015-08-20T15:06:23.757

2Can you specify the input and output of the program? Are the circle sizes fixed? If there is one optimal solution, would it be sufficient to write a program that outputs that solution? – agtoever – 2015-08-20T12:34:06.720

@agtoever the sizes are fixed and the program outputs the solution – flint – 2015-08-20T13:37:28.217

@flint In what format should the solution be output? Graphical, or a list of coordinates of circle centers? If graphical, does every pixel need to be correct? If textual, what's to keep us from just hardcoding the points? What counts as an "algorithm"? – lirtosiast – 2015-08-20T14:41:10.217

@flint Note that GolfScript, being a code golf language (not even the best one, but that's besides the point) is designed for concise code, not speed, so it would easily lose to almost any general-purpose language; also note that disallowing a specific language in any challenge is frowned upon. – lirtosiast – 2015-08-20T14:46:10.997

@ThomasKwa the output is list of coordinates. – flint – 2015-08-20T14:53:53.693

Answers

3

Python 2.7, runs almost instantly (0.02 seconds on my laptop)

import math, cProfile

def optimize():
    _WHITE_SURFACE = 15656
    white_radius = math.sqrt(_WHITE_SURFACE/math.pi)
    print "Assuming the red circle has its centre at (0,0), place the white circles at (x,y):"
    for i in range(5):
        print "   * Circle {0}: ({1:.5f}, {2:.5f})".format(i+1, white_radius*math.cos(i*math.pi/2.5), white_radius*math.sin(i*math.pi/2.5))

cProfile.run("optimize()")

agtoever

Posted 2015-08-20T12:15:34.177

Reputation: 2 661