17
1
I have a combinatorics problem that I'd like to put on the OEIS—the problem is that I don't have enough terms. This code challenge is to help me compute more terms, and the winner will be the user with the submission containing the greatest number of terms.
The Problem
Suppose I give you a triangular array of light bulbs with side length \$n\$:
o
o o
o o o
o o o o
o o o o o
o o o o o o
1 2 ... n
I'm going to turn on three lightbulbs that form an "upright" equilateral triangle as in the following example:
o
o x
o o o
o o o o
o x o o x
o o o o o o
Before I turn on the lights, your job is to remove as many lightbulbs as possible from the array—without losing the ability to deduce the triangle of bulbs that has been turned on. To be clear, if a lightbulb has been removed, it is not lit up when its position is turned on.
For example, if you removed the following bulbs (marked by .
) you would only see the following two lights turn on (marked by x
), which is enough uniquely deduce the third (unlit) position:
. .
. o . x
. . o . . o
o o o . => o o o .
o o o o . o x o o . <- the third unlit position
o . . . o o o . . . o o
Let a(n)
be the maximum number of bulbs that can be removed without introducing any ambiguities.
Example
With a naive algorithm, I have checked values up to a triangle with side length 7, as seen below:
.
. . o
. . o o . o
. . . . . o . o o .
. . . . o o o o o . o o . o .
. . . . o o o o . o o o o o . o . o . o o
. . . o o . o o o o . . o o o . . . o o o . o . o o o
a(2) = 3 a(3) = 4 a(4) = 5 a(5) = 7 a(6) = 9 a(7) = 11
Scoring
The submission that computes the sequence [a(2), a(3), ..., a(n)]
for the largest n wins. If two submissions have identical sequences, then the one that was posted earlier wins.
Although not necessary for the submission, it would be instructive to me if you post a construction of the resulting triangluar arrays, as in the example above.
1Isn't this a code-challenge rather than fastest code? – Don Thousand – 2018-09-19T21:49:51.753
6I think you should pick a time limit (say, 60s) so the contest isn't about how long someone spent running their code. – dylnan – 2018-09-19T22:33:09.170
Nice problem. What do you mean by "upright" triangle? – Damien – 2018-09-21T15:18:26.880