82
12
Duolingo, the language learning app, has a lot of things going for it, but there is one major issue that drives me crazy. It tells me how many days in a row I've used the app with a message like You're on a 7 day streak! Setting aside hyphenation and whether the number should be spelled out, this works fine for most numbers, but is indisputably wrong when it says You're on a 8 day streak! I'm not using it to learn English but this is still unfortunate behavior for a language app.
You're going to help out the Duolingo team by writing a complete program or function that figures out whether a given number should be preceded by a or an. A number is preceded by a if its pronunciation in spoken English begins with a consonant or semivowel sound, and preceded by an if its pronunciation begins with a vowel sound. Thus the only numbers preceded by an are those whose pronunciation begins with eight, eleven, eighteen, or eighty.
Presumably the Duolingo dev team left this bug in because they ran out of space for more source code in the app, so you need to make this code as short as possible in the hopes they can squeeze it in.
Your code must take an integer from 0 to 2,147,483,647 and output a
or an
. A trailing newline is optional. For the purposes of this challenge, 1863 is read as one thousand eight hundred and sixty-three, not eighteen hundred and sixty-three.
Test cases:
0 → a
8 → an
11 → an
18 → an
84 → an
110 → a
843 → an
1111 → a
1863 → a
8192 → an
11000 → an
18000 → an
110000 → a
180000 → a
1141592 → a
1897932 → a
11234567 → an
18675309 → an
1I thought this would be really easy... then I noticed
218
uses the 8's letter, not the 2's. – Cyoce – 2015-12-17T05:07:17.30331Is this endorsed by Duolingo? If not, you should get them to pay us for improving the language on a language learning site. – Arc676 – 2015-12-17T07:38:52.137
10Is 1100 (an) eleven hundred or (a) one thousand and one hundred? – user3819867 – 2015-12-17T08:04:01.497
11Bilbo would disagree with some of your test cases. :) – Martin Ender – 2015-12-17T09:26:02.927
@user3819867: Wasn't it, it has to be the word's first non silent letter the article is refering to is an a, e, i, o or u so it is an "an"? This confuses me, why it isn't in that case an one thousand and one hundred? is the "one" not considered to be part of the number? would be strange in my eyes too. Or did I just miss something when we had this topic in school? :x – Zaibis – 2015-12-17T09:56:10.187
9@Zaibis: "one" here is pronounced like "wun", which has a consonant sound. Hence, "a one thousand and one hundred day streak". – El'endia Starman – 2015-12-17T10:26:46.373
@El'endiaStarman: oh yeah.... you are right. I never realized that. I had to speak out loud 3 times "one" and "wun" to notice that its actually some thing kinda close to w but definetly not an o.... really never realized. ok now its clear. – Zaibis – 2015-12-17T10:42:12.470
31They probably left this bug because they thought no one would reach a 8 day streak. – PNDA – 2015-12-17T11:36:19.050
@user3819867 Just like one thousand eight hundred, we're treating it as one thousand one hundred (see the eighth test case.) – Luke – 2015-12-17T13:17:19.230
Wow, that is just sad, an app for teaching language and it has a grammatical error. Good catch @Luke. – Ashwin Gupta – 2015-12-18T04:05:51.020
https://www.duolingo.com/comment/12400979. Okay, I posted on their forums, they may fix it if it gets noticed. – Ashwin Gupta – 2015-12-18T04:08:15.470
2@AshwinGupta Here you go! ♦ A hard earned lingot. – wizzwizz4 – 2015-12-18T14:23:15.103
6"Thus the only numbers preceded by an are those whose pronunciation begins with eight, eleven, eighteen, or eighty." You just made Undecillion cry... I hope you're happy – corsiKa – 2015-12-18T23:54:22.937
1@PandaLion98: an 8 day streak. – Jost – 2015-12-19T08:31:01.617
You do know how long we have to wait to get a 2,147,483,647-day streak, right? I'll be back in 5.8 million years to see how we're getting on... – Toby Speight – 2018-05-24T14:29:05.653