Question: In this assignment, you will read multiple lines of text from STDIN. The number of lines to be input is not specified. Read all input
In this assignment, you will read multiple lines of text from STDIN. The number of lines to be input is not specified. Read all input until EOF (ctrl-d for keyboard input.) Each line will have one entry or be blank. Ignore blank lines on input. Each entry will be a 32-digit binary value. Each entry will be compared to a list of binary values, and you will output the index of the pattern (0-31) that is the closest match to the input patterns.
PROGRAM DETAILS AND OTHER REQUIREMENTS
To keep things simple, you many input and treat the entries as Strings. How close an entry is to a matching pattern in the list is defined as the number of characters (bits) that differ in the two patterns. No difference (zero bits/characters difference) is the closest possible match. Seven characters difference is the largest possible difference that still counts as a match.
In this project you are required to modularize your code into several functions to handle the primary tasks of the program. One function must take two entries as parameters and return a count of the number of bits/characters that differ. Another function must compare the paramter string to each of the patterns in the list, returning the index (0-31) of the closest (within seven, as above) match. If none of the patterns match, return -1 and print an error message that includes the pattern and the number of differences to the closest pattern. Refer to the sample run below to see how to format output.
LIST OF 32 PATTERNS IN ORDER
00000000000000000000000000000000 01010101010101010101010101010101 00110011001100110011001100110011 01100110011001100110011001100110 00001111000011110000111100001111 01011010010110100101101001011010 00111100001111000011110000111100 01101001011010010110100101101001 00000000111111110000000011111111 01010101101010100101010110101010 00110011110011000011001111001100 01100110100110010110011010011001 00001111111100000000111111110000 01011010101001010101101010100101 00111100110000110011110011000011 01101001100101100110100110010110 00000000000000001111111111111111 01010101010101011010101010101010 00110011001100111100110011001100 01100110011001101001100110011001 00001111000011111111000011110000 01011010010110101010010110100101 00111100001111001100001111000011 01101001011110011001011010010110 00000000111111111111111100000000 01010101101010101010101001010101 00110011110011001100110000110011 01100110100110011001100101100110 00001111111100001111000000001111 01011010101001011010010101011010 00111100110000111100001100111100 01101001100101101001011001101001
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
