CHALLENGE
This is a fastest-code challenge.
Count how many n-dimensional hypercubes with n=1,2,3,4 exist, with vertices labeled with either 1 or 0, such that there does not exist any rectangle formed by 4 vertices such that one diagonal is 1-1 and the other diagonal is 0-0. To be more clear, the forbidden rectangles have the form:
10 or 01
01 10
Note that we are talking about all rectangles, not just the faces of the hypercube. For example in the cube:
0*---1*
/| /|
0----0 |
| 0--|-0
|/ |/
1*---0*
there is an invalid rectangle formed by the four vertices marked with a star (*), although all faces are valid.
The list of all known expected results is at OEIS A000609. This is actually a conjecture, but a probable one. For more information and some "hints", see the BACKGROUND section.
The count for n=1,2,3,4 must be repeated in a loop 40 times (just to have more resolution on the measured time), and the results for n=1,2,3,4 (4,14,104,1882 respectively) printed on the first round of the loop only.
You should provide a link for tio.run.
Here is my best in C (about 30 s).
BACKGROUND (optional)
I have asked a question related to this challenge at mathoverflow. See the links within that question and especially the one related to the generation of the rectangles.
Another possible idea is using the inclusion-exclusion principle: see this question.
SCORE
I will make a first rough placement list based on the time shown in the tio.run link provided, in the "Debug" section, "User time". Some time later a more precise one with times tested on my machine, since performance on tio.run may vary over time.
RECORDS
There will be another record list if someone is able to compute the case n = 5 or more in a reasonable time (let's say less than 10 minutes for n = 5 and 3 days for n = 6). In this case it may be that I won't double check, so I will trust your claim. I personally computed the case n = 5 in about 5 minutes with a slightly modified version of the above linked C software (which took 8 minutes).
STANDINGS
FASTEST CODE | USER | LANGUAGE | BEST TIME ON MY MACHINE |
---|---|---|---|
1 | 138 Aspen | Rust | 0.1364747 s |
2 | gsitcia | Python | 0.1462836 s |
3 | user1502040 | Python | 1.0249261 s |
4 | Level River St | Ruby | 1.3259241 s |
5 | Me | C | 25.888948 s |
"n RECORD" | USER | LANGUAGE | RECORD and TIME MY PC |
---|---|---|---|
1 | gsitcia | Python | n = 7 in 1h 19m 26s |
2 | gsitcia | Python | n = 6 in 1.946 s |
3 | 138 Aspen | Rust | n = 6 in 2h 45m 24s |
4 | user1502040 | Python | n = 6 in 22h 6m |
5 | gsitcia | Python | n = 5 in 0.156 s |
6 | 138 Aspen | Rust | n = 5 in 1.947 s |
7 | user1502040 | Python | n = 5 in 25.372 s |
8 | Level River St | Ruby | n = 5 in 27.900 s |
9 | Me | C | n = 5 in ~480 s |
The time for "n RECORD" is for a single computation of the specified value for n.
fastest-code
andfastest-algorithm
. According to your description, the winning criterion isfastest-code
. \$\endgroup\$