If you've ever tried adding labels to a really dense plot, then you'll realise that sometimes labels will overlap one another, making them hard to read. We're going to do something similar but in 1D.
Input will be a sequence of
(label, x-coordinate) pairs, and output will be the result of drawing each point and label, in the given order. An asterisk
* representing the point should be placed at the given x-coordinate and the label should follow. Any existing characters will be overwritten.
For instance, if the input was
Hello 0 World 8 Fizz 3 Buzz 5 PPCG 16 X 9
Then the following would happen:
*Hello *Hello *World *He*Fizz*World *He*F*Buzzorld *He*F*Buzzorld *PPCG *He*F*Buz*Xrld *PPCG
The final line should then be outputted.
Input may consist of any number of pairs. Each label will only consist of uppercase and lowercase letters, and label lengths will be at most 127 chars. Each x-coordinate will be between 0 and 127 inclusive.
Input may be in any convenient list or string format such that the pairs are unambiguous and labels/x-coordinates alternate in the input. For example, a format like
[("Hello", 0), ("World", 8) ...]or
[0 "Hello" 8 "World" ...]is fine. However, you may not assume two separate lists of labels and x-coordinates.
Functions and full programs are both okay.
Any spots not covered by a label should be represented with a space. However, there may not be any extraneous leading or trailing whitespace aside from a single optional trailing newline.
Heathrow 0 Edinburgh 2 London 4 Liverpool 6 Oxford 8
alpha 20 beta 4 gamma 57 delta 3 epsilon 22 zeta 32 eta 53 theta 27
*delta *a*epsi*thetazeta *eta*gamma
abc 5 d 5 abc 10 ABCDEFGHIJKLMNOPQRSTUVWXYZ 127
*dbc *abc *ABCDEFGHIJKLMNOPQRSTUVWXYZ
Note that labels and/or x-coordinates may be repeated.