summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorn1c00o <git.n1c00o@gmail.com>2021-10-15 20:36:03 +0200
committern1c00o <git.n1c00o@gmail.com>2021-10-15 20:36:03 +0200
commit9fc3ad046be744e565497983b7832132d4723f3f (patch)
treee9bf4de574d4590e56789ba6617056fa1e15f01f
parent93f018c0f25cac9f0e900b87d2a0ee716e76a2b7 (diff)
disorderly-escape
-rw-r--r--disorderly-escape/Solution.java5
-rw-r--r--disorderly-escape/constraints.txt21
-rw-r--r--disorderly-escape/n1c00o/solution.py2
-rw-r--r--disorderly-escape/readme.txt84
-rw-r--r--disorderly-escape/solution.py2
5 files changed, 114 insertions, 0 deletions
diff --git a/disorderly-escape/Solution.java b/disorderly-escape/Solution.java
new file mode 100644
index 0000000..a382692
--- /dev/null
+++ b/disorderly-escape/Solution.java
@@ -0,0 +1,5 @@
+public​ ​class​ ​Solution​ ​{
+​ ​​ ​​ ​​ ​public​ ​static​ ​String​ ​solution(int​ ​w,​ ​int​ ​h,​ ​int​ ​s)​ ​{
+​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​//​ ​Your​ ​code​ ​here
+​ ​​ ​​ ​​ ​}
+}
diff --git a/disorderly-escape/constraints.txt b/disorderly-escape/constraints.txt
new file mode 100644
index 0000000..f201987
--- /dev/null
+++ b/disorderly-escape/constraints.txt
@@ -0,0 +1,21 @@
+Java
+====
+Your code will be compiled using standard Java 8. All tests will be run by calling the solution() method inside the Solution class
+
+Execution time is limited.
+
+Wildcard imports and some specific classes are restricted (e.g. java.lang.ClassLoader). You will receive an error when you verify your solution if you have used a blacklisted class.
+
+Third-party libraries, input/output operations, spawning threads or processes and changes to the execution environment are not allowed.
+
+Your solution must be under 32000 characters in length including new lines and and other non-printing characters.
+
+Python
+======
+Your code will run inside a Python 2.7.13 sandbox. All tests will be run by calling the solution() function.
+
+Standard libraries are supported except for bz2, crypt, fcntl, mmap, pwd, pyexpat, select, signal, termios, thread, time, unicodedata, zipimport, zlib.
+
+Input/output operations are not allowed.
+
+Your solution must be under 32000 characters in length including new lines and and other non-printing characters.
diff --git a/disorderly-escape/n1c00o/solution.py b/disorderly-escape/n1c00o/solution.py
new file mode 100644
index 0000000..f9b0b7b
--- /dev/null
+++ b/disorderly-escape/n1c00o/solution.py
@@ -0,0 +1,2 @@
+def solution(w, h, s):
+ # Your code here
diff --git a/disorderly-escape/readme.txt b/disorderly-escape/readme.txt
new file mode 100644
index 0000000..704d91a
--- /dev/null
+++ b/disorderly-escape/readme.txt
@@ -0,0 +1,84 @@
+Disorderly Escape
+=================
+
+Oh no! You've managed to free the bunny workers and escape Commander Lambdas exploding space station, but Lambda's team of elite starfighters has flanked your ship. If you dont jump to hyperspace, and fast, youll be shot out of the sky!
+
+Problem is, to avoid detection by galactic law enforcement, Commander Lambda planted the space station in the middle of a quasar quantum flux field. In order to make the jump to hyperspace, you need to know the configuration of celestial bodies in the quadrant you plan to jump through. In order to do *that*, you need to figure out how many configurations each quadrant could possibly have, so that you can pick the optimal quadrant through which youll make your jump.
+
+There's something important to note about quasar quantum flux fields' configurations: when drawn on a star grid, configurations are considered equivalent by grouping rather than by order. That is, for a given set of configurations, if you exchange the position of any two columns or any two rows some number of times, youll find that all of those configurations are equivalent in that way -- in grouping, rather than order.
+
+Write a function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a star grid w blocks wide and h blocks tall where each celestial body has s possible states. Equivalency is defined as above: any two star grids with each celestial body in the same state where the actual order of the rows and columns do not matter (and can thus be freely swapped around). Star grid standardization means that the width and height of the grid will always be between 1 and 12, inclusive. And while there are a variety of celestial bodies in each grid, the number of states of those bodies is between 2 and 20, inclusive. The solution can be over 20 digits long, so return it as a decimal string. The intermediate values can also be large, so you will likely need to use at least 64-bit integers.
+
+For example, consider w=2, h=2, s=2. We have a 2x2 grid where each celestial body is either in state 0 (for instance, silent) or state 1 (for instance, noisy). We can examine which grids are equivalent by swapping rows and columns.
+
+00
+00
+
+In the above configuration, all celestial bodies are "silent" - that is, they have a state of 0 - so any swap of row or column would keep it in the same state.
+
+00 00 01 10
+01 10 00 00
+
+1 celestial body is emitting noise - that is, has a state of 1 - so swapping rows and columns can put it in any of the 4 positions. All four of the above configurations are equivalent.
+
+00 11
+11 00
+
+2 celestial bodies are emitting noise side-by-side. Swapping columns leaves them unchanged, and swapping rows simply moves them between the top and bottom. In both, the *groupings* are the same: one row with two bodies in state 0, one row with two bodies in state 1, and two columns with one of each state.
+
+01 10
+01 10
+
+2 noisy celestial bodies adjacent vertically. This is symmetric to the side-by-side case, but it is different because there's no way to transpose the grid.
+
+01 10
+10 01
+
+2 noisy celestial bodies diagonally. Both have 2 rows and 2 columns that have one of each state, so they are equivalent to each other.
+
+01 10 11 11
+11 11 01 10
+
+3 noisy celestial bodies, similar to the case where only one of four is noisy.
+
+11
+11
+
+4 noisy celestial bodies.
+
+There are 7 distinct, non-equivalent grids in total, so solution(2, 2, 2) would return 7.
+
+Languages
+=========
+
+To provide a Java solution, edit Solution.java
+To provide a Python solution, edit solution.py
+
+Test cases
+==========
+Your code should pass the following test cases.
+Note that it may also be run against hidden test cases not shown here.
+
+-- Java cases --
+Input:
+Solution.solution(2, 3, 4)
+Output:
+ 430
+
+Input:
+Solution.solution(2, 2, 2)
+Output:
+ 7
+
+-- Python cases --
+Input:
+solution.solution(2, 3, 4)
+Output:
+ 430
+
+Input:
+solution.solution(2, 2, 2)
+Output:
+ 7
+
+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.
diff --git a/disorderly-escape/solution.py b/disorderly-escape/solution.py
new file mode 100644
index 0000000..f9b0b7b
--- /dev/null
+++ b/disorderly-escape/solution.py
@@ -0,0 +1,2 @@
+def solution(w, h, s):
+ # Your code here