The Last-to-First array, denoted LastToFirst(i), answers the following question: given a symbol at position i in the last column of a Burrow-Wheeler matrix, what is its position in first column?

Assignment

Implement the last_to_first_mapping method which takes a string containing a '$' and an index in the last column, returning the index of that symbol in the first column.

Example

>>> last_to_first_mapping('T$GACCA', 3)
1
>>> last_to_first_mapping('CAAGCGGTTAGCAACTGCATGCCACCAGGGTTTCTTCCATGAGTAACTACTTTCTACGTACTGGCCCGCTGGGCCGGGTAGAGTCGCTAAACCAGCCTGGGACCGATGTTGATCCGCCCACCCAAAACTGTGTACCGTGGCACCGAACTGGCGAACAAAAGGACATCGCTTACCCCTGAACATTGACCACGGCATGGCCATTCTCCCTGAATACGCGAAAACCTATTTGACGGGACCTAACAAGCACATACTCGTACTTATCGAGTCCTCGGCTAGTGACTTTTGTCTTCTAGATCGGGGTGTCGGGGGATGGGGGATTTCGGTATGCGGCACCTCGGCGTGCTTGAACTGTAGGAACCACAGATTCTCCAAACTAAATTGTTATCCTTTTACAGACGGGACACACGTGTCCAGGAGTAAATCGGGTCACTCAGCACGCATTTCGCTATCGTATTTCCCCGAATCCTTAACAAAACTGAGGTAGTAGGGAGCCCTCTGTCGTAGATTGATAACAGCGTCAGTCGAGTGCCCGAGATGTGCACCATGACGCTTTTGTGATATTGACTAATGGTGGCGGTACAGGGCCATGACCTCTATCCTCTAAATACGCGATACTAATGAAGGTTCCTCGGTGGGATGGTCGTGACTTTGCAACCGTTCCTCGCCAAGGGGGGACGAAGCTCCAGTGTGATTCTTACTTCTAACAGCCGGGTGTCGGACGCCTACCGGTCCTCTTAGTGGATGCGTGACATGTGCTTATTTACGGTCGACTGATAGTAAGGCCGGACTTGGTTATCAATTCACAACAGTTTGGTGTACGCCTTGTACAGAGCTGTTTAGAAATAGTGACAGTTTCGAACCATATAGCGACTGGCTAACCTGAATCAATAGATGCAAAAGGACGACTACTACTGATATGAGTGGGCTTTAAGTACACTGAGAG$', 235)
304