Day8/day8.2.py
def translate_to_num(string, permutation):
    '''
    Assuming that the permutation is correct, return the translation of "string"
    to a decimal number. Otherwise, raise a ValueError
    '''
    A, B, C, D, E, F, G = permutation
    # Assume a 7 segment display with following segments:
    #   AAAA
    # B     C
    # B     C
    #   DDDD
    # E     F
    # E     F
    #   GGGG

    # Try to make sense of what digit does the "string" show on the 7 segment display
    chars = (A, B, C, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 9
    chars = (A, B, C, D, E, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 8
    chars = (A, C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 7
    chars = (A, B, D, E, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 6
    chars = (A, B, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 5
    chars = (B, D, C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 4
    chars = (A, C, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 3
    chars = (A, C, D, E, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 2
    chars = (C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 1
    chars = (A, C, F, G, E, B)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 0

    # No valid digit could be seen on the 7 segment display for "string"
    raise ValueError

    Assuming that the permutation is correct, return the translation of "string"
    to a decimal number. Otherwise, raise a ValueError
    
Assuming that the permutation is correct, return the translation of "string"
to a decimal number. Otherwise, raise a ValueError
Assuming that the permutation is correct return the translation of " string " to a decimal number . Otherwise raise a ValueError
def translate_to_num(string, permutation):
    A, B, C, D, E, F, G = permutation
    chars = (A, B, C, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 9
    chars = (A, B, C, D, E, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 8
    chars = (A, C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 7
    chars = (A, B, D, E, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 6
    chars = (A, B, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 5
    chars = (B, D, C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 4
    chars = (A, C, D, F, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 3
    chars = (A, C, D, E, G)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 2
    chars = (C, F)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 1
    chars = (A, C, F, G, E, B)
    if all(i in string for i in chars) and len(string) == len(chars):
        return 0
    raise ValueError
def translate_to_num ( string , permutation ) : A , B , C , D , E , F , G = permutation chars = ( A , B , C , D , F , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 9 chars = ( A , B , C , D , E , F , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 8 chars = ( A , C , F ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 7 chars = ( A , B , D , E , F , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 6 chars = ( A , B , D , F , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 5 chars = ( B , D , C , F ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 4 chars = ( A , C , D , F , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 3 chars = ( A , C , D , E , G ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 2 chars = ( C , F ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 1 chars = ( A , C , F , G , E , B ) if all ( i in string for i in chars ) and len ( string ) == len ( chars ) : return 0 raise ValueError
Assuming that the permutation is correct, return the translation of "string"
to a decimal number.
Assuming that the permutation is correct return the translation of " string " to a decimal number .
'''
    Assuming that the permutation is correct, return the translation of "string"
    to a decimal number. Otherwise, raise a ValueError
    ''' # Assume a 7 segment display with following segments: #   AAAA # B     C # B     C #   DDDD # E     F # E     F #   GGGG # Try to make sense of what digit does the "string" show on the 7 segment display # No valid digit could be seen on the 7 segment display for "string"
string
permutation