Bitify
View as PDFBitify is a music streaming platform launching a new service that lets users identify songs by inputting a snippet.
Rather than searching through every song in its entirety for a perfect match, they've found an ingenious solution: every song is converted into a digit fingerprint consisting of digits
, inclusive.
Build a program that compares the fingerprint of the user-inputted song to those of shortlisted ones and outputs whichever one shares the most digits at the same indices.
Bitify's algorithm is set up so only one candidate has the highest matching score.
Input Specification
The first line contains
, representing the number of digits in every fingerprint.
The second line contains
, representing the number of songs you'll be searching through to find a match.
The third line contains , a string with
digits representing the fingerprint of the user-inputted song.
The next lines contain a single-word song name and a fingerprint with
digits representing each shortlisted comparable track separated by a whitespace
.
Output Specification
Return the name of the song whose fingerprint matches the greatest number of digits at the same indices as that of the user-inputted track.
Sample Input 1
5
3
12345
Planets 11873
Found 12397
Tenet 54321
Sample Output 1
Found
Explanation of Sample 1
The user's fingerprint is 12345.
Planets (11873) matches 1 digit in the same position.
Found (12397) matches 3 digits in the same positions.
Tenet (54321) contains all the same digits as the user's hash code, but none appear in the same positions, so it matches 0 digits.
Since Found has the highest number of matching digits, its name is outputted.
Comments