2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,13 +1 @@
|
|||
public class HundredDoors {
|
||||
public static void main(String[] args) {
|
||||
boolean[] doors = new boolean[101];
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
for (int j = i; j <= 100; j++) {
|
||||
if(j % i == 0) doors[j] = !doors[j];
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
System.out.printf("Door %d: %s%n", i, doors[i] ? "open" : "closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
N.println(IntStream.rangeClosed(1, 100).filter(i -> Math.pow((int) Math.sqrt(i), 2) == i).boxed().join(", ", "Open Doors: ", ""));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue