7/L Segment Display

Today I was troubleshooting a sensor that was giving an error code — but Error 52 “Over Voltage” was not what I expected… regardless I checked the voltage and it looked fine. About ten minutes later I realized that the display was mounted upside down and it was Error 25, “Programming Error” — duh.

 

Untitled2.jpg

Which one? Choose wisely

 

While this is totally my fault it is also avoidable. So if you are a company that makes things with important codes using a seven segment display AND your display can logically be upside down then don’t use any numbers that are also valid in either orientation.

 

614BPv1jPaL._SY355_-314x252-1.jpg

 

Here are the amount of numbers that satisfy that criteria:

Figure_1.png

To find this I used the criteria of a number having to be not a number upside down (because of a 7, 4 or 3) or be itself when upside down (96 -> 96).

1 Digit Numbers
2 Digit Numbers
3 Digit Numbers
4 Digit Numbers
5 Digit Numbers

 

Here is the code:

import matplotlib.pyplot as plt

def flip(num):
    flips = [
        ["0","0"],
        ["1","1"],
        ["2","2"],
        ["3","E_"],
        ["4","H_"],
        ["5","5"],
        ["6","9"],
        ["7","L_"],
        ["8","8"],
        ["9","6"]]

    new_num = ""
    for i in range(len(num)):
        new_num += flips[int(num[len(num)-1-i])][1]
    if new_num == num or len(new_num) > len(num): return num
    else: return

def find_all_digits(digits):
    valid_options = []
    for i in range(0,10**digits):
        val = str(i)
        val = "0"*(digits-len(val))+val
        if flip(val) is not None:
            valid_options.append(flip(val))
    return len(valid_options)

x,y = [],[]
for i in range(1,9):
    x.append(i)
    y.append(find_all_digits(i)/10**i)

fig = plt.figure()
ax = fig.add_subplot(111)
plt.scatter(x,y)
for i,j in zip(x,y):
    ax.annotate("("+str(i)[:4]+","+str(int(round(j*10**i)))+")",xy=(i-0.075*len(str(round(j*10**i))),j+0.01))
plt.title("Number of valid numbers that aren't confusing when upside down")
plt.xlabel("N\n Number of Digits Used")
plt.ylabel('Valid Entries / Total Possible Entries')
plt.show()

 

Advertisements

7 thoughts on “7/L Segment Display

  1. Pingback: Time For Some Abstract Math. Drink Up. - NewsCasper

  2. Pingback: Time For Some Abstract Math. Drink Up.

  3. Pingback: Time For Some Abstract Math. Drink Up. - FiveThirtyEight - Nevin Manimala

  4. Pingback: who else really gets Quizzes ? – Its Trivia Time

  5. Pingback: Important Post – Its Trivia Time

  6. Pingback: love the fanpage – Its Trivia Time

  7. Pingback: Anything related to this is so important – Its Trivia Time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s