14
2
Given a 7-segment display with some segments switched on and some off, find a sequence of digits (0-9), such that after toggling the corresponding segments for each digit, all segments are switched off.
Example
_
_ [3] => | [1] => [OFF]
_ |
Numbers and their corresponding segments:
_ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_|
|_| | |_ _| | _| |_| | |_| _|
Rules
Codegolf ⊨ shortest entry wins.
Input
A non-empty list of segments which are switched on, given as
A sequence of numbers. Segments are numbered from top to bottom, left to right; starting from 0 or 1. Numbers need not be in order.
A single 7-bit digit. MSB/LSB not specified (thus you can choose).
Non-numeric characters between numbers are allowed (but not required to be supported).
Eg. for number 7
: 136
or 1010010
or 0100101
Output
A sequence of numbers to be "applied" to the display. Not restricted in any way, such as order of the digits. Eg. for initial state corresponding to number 1
, valid outputs would be 1
, 111
, 010
, etc.
An alternative output is a 10-bit digit (again, MSB/LSB is your choice). Eg. for 1
as input, the output would be 1000000000
or 0000000001
.
Some combinations have several non-repetitive solutions, eg. segments corresponding to the uppercase letter H
can be switched off by 013
, but also 489
and 0258
.
If no solution exists (which I believe is not possible), the output is empty.
2This needs more specification. Which segments are included in each digit (for example, does 9 include the bottom segment?) Please draw all digits and indicate the numbers of the segments included in each. – Level River St – 2017-06-04T16:58:55.997
Also, what formats are allowed for input? Will the segment numbers be given in order? What do we do if there is no solution? – Level River St – 2017-06-04T17:00:09.180
"Some combinations have several non-repetitive solutions" Also, any permutation of a solution is another solution, right? (like
301
forH
). – Arnauld – 2017-06-04T17:01:16.490@Arnauld Yes, that's correct. – kyrill – 2017-06-04T17:09:12.153
Nice challenge, BTW. :-) – Arnauld – 2017-06-04T17:17:02.170
There are 1024 possible digit sets and 128 possible segment sets, so that makes 8 digit set solutions for each segment set. These can be obtained by a combination of set differences with three sets such as the following:
02468
,12358
,12369
. This means that it's possible to avoid considering up to three digits (although 7 is always necessary) when determining an answer. – Neil – 2017-06-04T19:38:06.197Looks like somebody likes Unicode :) – Esolanging Fruit – 2017-06-04T22:13:53.143
1Proof that a solution always exists: it suffices to find solutions for each individual segment. Solutions for the horizontal segments, from top to bottom, are
17
,08
, and1479
. Solutions for the upper vertical segments, left to right, are39
and59
. Solutions for the lower vertical segments, left to right, are56
and2389
. – Greg Martin – 2017-06-05T00:22:46.903@Neil: I see why 2 is necessary (it's the only way to get at the lower-right vertical segment); why is 7 necessary? – Greg Martin – 2017-06-05T00:25:06.983
1@GregMartin
2
isn't always necessary, because you can replace it with either0468
,1358
, or1369
, depending on whether you want a0
,8
or9
in your answer, but there's no way to eliminate7
at all, and I think you have to have at least one of1
and3
. – Neil – 2017-06-05T07:57:38.730@Challenger5 Did it display incorrectly in your browser? If so, which browser and system do you use? I'm using FF on Fedora and it looked OK, but then someone edited the Unicode part of my task description, saying he "fixed alignment". After that edit, the alignment was wrong in my browser. Alas, I guess we're not ready for Unicode yet... Or maybe I just don't know how to use it properly :-] – kyrill – 2017-06-06T08:47:44.770
You can also use the XOR space explorer to find out how many segment sets can be generated from a given set of digits.
– Neil – 2017-06-06T09:30:49.570