keyboard can be written as k6d, key5, k3o2d or 8, or left as it is.
The rules for a short form short:
- a number stands for a non-empty run of letters and has no leading zeros (so 0 and 05 are not allowed);
- every digit run is read as a single number, so k33d means 33 skipped letters, not 3 and 3;
- each letter in the short form must match the word's letter at that position.
Given word and short, return True if short is a correct short form of word, and False otherwise.word="keyboard", short="k3o2d" → True
k, then 3 skipped letters eyb, then o, 2 more letters ar, and d.
word="river", short="r3" → False
Only 3 letters are skipped after r, but 4 remain.
word="tea", short="t02" → False
A number may not start with a zero.
word consists of lowercase English lettersshort consists of lowercase English letters and digitsshort is less than 2³¹word="keyboard", short="k3o2d"
True
Run checks the first 3 tests in your browser. Submit checks all 181 tests on the server, hidden ones included.