-
Notifications
You must be signed in to change notification settings - Fork 30
/
solar_doomsday.java
59 lines (39 loc) · 2.33 KB
/
solar_doomsday.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Solar Doomsday
==============
Who would've guessed? Doomsday devices take a LOT of power. Commander Lambda wants to supplement the LAMBCHOP's quantum
antimatter reactor core with solar arrays, and she's tasked you with setting up the solar panels.
Due to the nature of the space station's outer paneling, all of its solar panels must be squares. Fortunately, you have
one very large and flat area of solar material, a pair of industrial-strength scissors, and enough MegaCorp Solar Tape(TM)
to piece together any excess panel material into more squares. For example, if you had a total area of 12 square yards of
solar material, you would be able to make one 3x3 square panel (with a total area of 9). That would leave 3 square yards,
so you can turn those into three 1x1 square solar panels.
Write a function answer(area) that takes as its input a single unit of measure representing the total area of solar panels
you have (between 1 and 1000000 inclusive) and returns a list of the areas of the largest squares you could make out of
those panels, starting with the largest squares first. So, following the example above, answer(12) would return [9, 1, 1, 1].
Languages
=========
To provide a Python solution, edit solution.py
To provide a Java solution, edit solution.java
Test cases
==========
Inputs:
(int) area = 12
Output:
(int list) [9, 1, 1, 1]
Inputs:
(int) area = 15324
Output:
(int list) [15129, 169, 25, 1]
Use verify [file] to test your solution and see how it does. When you are finished editing your code, use submit [file] to submit your answer. If your solution passes the test cases, it will be removed from your home folder.
foobar:~/solar_doomsday guest$ cat constraints.txt
Java
====
Your code will be compiled using standard Java 7. It must implement the answer() method in the solution stub.
Execution time is limited. Some classes are restricted (e.g. java.lang.ClassLoader). You will see a notice if you use a restricted class when you verify your solution.
Third-party libraries, input/output operations, spawning threads or processes and changes to the execution environment are not allowed.
Python
======
Your code will run inside a Python 2.7.6 sandbox.
Standard libraries are supported except for bz2, crypt, fcntl, mmap, pwd, pyexpat, select, signal, termios, thread, time, unicodedata, zipimport, zlib.
*/