According to the positional values word
MANGO = 13, 1, 14, 7, 15
Differences of successive numbers = 12, 13, 7, 8
Minimum difference is 7, hence the code.
Similarly for MIRACLE (13, 9, 18, 1, 3, 12, 5)
Differences are 4, 9, 17, 2, 9, 7
Minimum difference is 2, hence the code.