Through a little deduction, you should now be able to determine the remaining digits. Consider again the first example above:
acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf
After some careful analysis, the mapping between signal wires and segments only make sense in the following configuration:
dddd
e a
e a
ffff
g b
g b
cccc
So, the unique signal patterns would correspond to the following digits:
acedgfb: 8cdfbe: 5gcdfa: 2fbcad: 3dab: 7cefabd: 9cdfgeb: 6eafb: 4cagedb: 0ab: 1Then, the four digits of the output value can be decoded:
cdfeb: 5fcadb: 3cdfeb: 5cdbaf: 3Therefore, the output value for this entry is 5353.
Following this same process for each entry in the second, larger example above, the output value of each entry can be determined:
fdgacbe cefdb cefbgd gcbe: 8394fcgedb cgb dgebacf gc: 9781cg cg fdcagb cbg: 1197efabcd cedba gadfec cb: 9361gecf egdcabf bgf bfgea: 4873gebdcfa ecba ca fadegcb: 8418cefg dcbef fcge gbcadfe: 4548ed bcgafe cdgba cbgef: 1625gbdfcae bgc cg cgb: 8717fgae cfgab fg bagce: 4315Adding all of the output values in this larger example produces 61229.
For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values? Determine this in the following way:
search that takes the pathname (char*) of a text file containing your observations of the submarine displays. Each line of the file contains the following tokens, separated by spaces: ten unique signal patterns, a vertical bar (|) and four digit output values. The function must return the sum (int) of all output values.In this interactive session we assume the text files displays01.txt1 and displays02.txt2 to be located in the current directory.
> search("displays01.txt")
61229
> search("displays02.txt")
1070188