You're on a 8 day streak!
Python 2, 60 bytes
lambda n:'a'+'n'[:`n`[0]=='8'or`n`[:2]in len(`n`)%3/2*'118']
An anonymous function. Adds an n
if either:
- The first digit is 8
- The first two digits are 11 or 18, and the length is 2 modulo 3.
Pyth, 23 bytes
<>n\8hz}hjsz^T3,hT18"an
This selects how many letters to slice off the end of "an"
by checking whether the first letter is not an 8
and that the first digit of the number when considered in base 1000 is neither 11 nor 18. The resulting boolean is the number of characters to slice of the end.
GNU Sed, 32
Score includes +1 for -E
option to sed.
s/^8.*|^1[18](...)*$/an/
t
ca
:
Try it online.
- Remove groups of 3 digits from the end of each number until there is only 1 to 3 digits left
- Match any number starting with 8 or exactly 11 or 18 and change to
an
- Change all other numbers to
a
Thanks to @MartinBüttner for his retina approach that saved 10 bytes.