6 kyu

Broken 7-segment display - reversed segments

Description:

Task

There is a single-digit seven segment display. The display has a problem: there can be from 0 to 7 (all) "reversed" segments. A reversed segment is on when it should be off, and off when it should be on.

The display shows numbers from 0 to 9 (inclusive). If there are reversed segments, numbers may look strange.

How numbers appear on a correctly working display:       0-5 with top segment reversed:
  _         _    _         _    _    _    _    _                _              _
 | |    |   _|   _|  |_|  |_   |_     |  |_|  |_|         | |    |   _|   _|  |_|  |_
 |_|    |  |_    _|    |   _|  |_|    |  |_|   _|         |_|    |  |_    _|    |   _|

Given some numbers as they appear on display, try to determine which segments are reversed.

Segment names

Note: in this kata segment names are lowercase, "dp" is not used.

Input

display [list of strings]

Each element of the list is a 11-chars string that represents a number shown on display. Format: (3 rows, 3 chars per row) a fgb edc (the 1st and 3rd chars of the first row are always spaces). Each segment is represented by a char:

  • off: space (' ')
  • on: '_' (a,d,g) or '|' (b,c,e,f)

Examples:

8: ' _ \n|_|\n|_|'
```\
 _ 
|_|
|_|'''
4: '   \n|_|\n  |'
```\
   
|_|
  |'''

All inputs are valid; there is always at least one string.

Output

  • [string] or None

If the set of reversed segments can be determined:

  • a lowercase string containing the names of reversed segments in alphabetical order (e.g. '', 'a', 'ceg', 'abcdefg');

otherwise:

  • None

Examples

       _ 
 |_|  | |
 |_     |

Input: [' \n|_|\n|_ ', ' _ \n| |\n |']
Output: None (it could be 2,1 with a,f reversed, or 1,2 with c,d,e,f,g reversed)

  _    _
 |_|  |    | | 
 |_|  |_|    | 

Input: [' _ \n|_|\n|_|', ' _ \n| \n|_|', ' \n| |\n |']
Output: 'g' (0,6,4 with g reversed, no other options)

Logic
Fundamentals

More By Author:

Check out these other kata created by mauro-1

Stats:

CreatedJan 4, 2023
PublishedJan 5, 2023
Warriors Trained235
Total Skips10
Total Code Submissions146
Total Times Completed41
Python Completions41
Total Stars12
% of votes with a positive feedback rating97% of 19
Total "Very Satisfied" Votes18
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • mauro-1 Avatar
  • dfhwze Avatar
Ad