A Pixel World is a PNG image where gravitational, electromagnetic, and nuclear forces no longer exist. Special forces known as "pixel forces" are all that remain. We define this force as
Fp->q = a * (p * q) / (r * r) * r̂
Fis the pixel force that
ais Adams' constant, defined as
a = 4.2 * 10 ^ 1
qare charges on two pixels
ris the distance from
r̂is the direction of r in radians, measured counterclockwise* from the positive x-axis
*There are infinitely many acceptable values for any given direction. For example, 6.28, 0, -6.28, and -12.57 radians are all equivalent, and would all be accepted.
Three types of pixels exist:
- A red pixel holds a charge of positive one
- A black pixel holds a charge of negative one
- A white pixel holds a charge of zero
The bottom left pixel of pixel world is located at
(0, 0). The positive y axis falls up the page, and the positive x axis falls to the right. The total force on a pixel is simply the vector sum of all forces exerted upon that pixel. Like charges repel, and opposite charges attract.
Given a file path to a Pixel World, as well as two integers
y, output the total force exerted on the pixel at location
(x, y) in the format
<magnitude>\n<direction>. Output must be accurate to at least 2 decimal places, but you may output more if you want. Direction must be output in radians. The integers
y are guaranteed to be within the world boundary.
You must include a program, and a command that can be used to run your program. Two examples:
python AbsolutelyPositive.py "C:\Pixtona.png" 50 40
java UltimateAttraction "C:\Jupix.png" 30 30
In the image below, there is a black pixel at
This output does not correspond to the above input.
Need help getting started?
I wrote some example code here. I haven't tested it, so use it at your own risk.