https://www.duolingo.com/Beth743129

Suggestion for DuoLingo web coders

Dear DuoLingo web coders,

I was sent and email saying, "Daily Welsh Reminder Hi Beth, you are on a 18 day streak! Use Duolingo today to make it 19."

Considering that DuoLingo is a language learning website and correct grammar is important, may I suggest that you modify your code so that

if Streak = {8, 11, 18, 8*}

<pre> print "you are on an {Streak} day streak!" </pre>

else

<pre> print "you are on a {Streak} day streak!" </pre>

endif

Sorry if there are mistakes in my suggested code (it's too long since I've been a computer programmer!), but you know what I mean!

Happy coding,

Beth

1 year ago

12 Comments


https://www.duolingo.com/somelauw
somelauw
  • 17
  • 13
  • 10
  • 10
  • 10
  • 10
  • 6
  • 5
  • 5
  • 5
  • 4
  • 3
  • 2

an for 8, 11, 18, 88, 800-899, 1800-1899 (depends on pronunciation), 8000-8999, 18000-18999, 80000-89999, 800000-900000, 1800000-1899999 (depends on pronunciation) etc.

a for everything else

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

Great finding. I planned to create a computer programming running through all the possibilities, but this should do the job I think.

1 year ago

https://www.duolingo.com/Beth743129

Hi somelauw,

You forgot 80-87 and 89. I don't know anyone who says 18 hundred. And 11 thousand days is almost 30 years, so that will probably not be an issue! I think Streak = {8*, 11, 18} does the job.

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

A more general solution would be to

1) Convert the given number to its word representation

E.g. input 1 gives output 'one'

E.g. input 2 gives output 'two'

..

E.g. input 8 gives output 'eight'

..

E.g. input 18 gives output 'eighteen'

..

E.g. input 800 gives output 'eight hundred'

..

E.g. input 1000 gives output 'thousand'

..

2) Then getting the first character of that word representation

E.g. input 'one' gives output 'o'

E.g. input 'two' gives output 't'

..

E.g. input 'eight' gives output 'e'

..

E.g. input 'eighteen' gives output 'e' ...

E.g. input 'eight hundred' gives output 'e'

..

E.g. input 'thousand' gives output 't'

..

  1. Then if that first character is one of this vowel (sounds) (a, e, o, i) then output 'an' else output 'a'.

[edited]

1 year ago

https://www.duolingo.com/juryrigging
juryrigging
  • 15
  • 12
  • 7
  • 7
  • 3
  • 3

One uses 'a', because it isn't a vowel sound. The only numbers in English that should take 'an' start with the digit 8, with the exception of 11 and 18, so Beth's solution is more elegant.

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

Agreed, in afterthought it is a more elegant and minimal (Occam's razor) solution if that is the case. As indeed (then) only the first digit(s) 8, 11, 18 are relevant, what other digits follows after is not relevant for the issue so should not be e.g. checked or generated, so only checking the verbatim digits should be enough.

8* can then also be dropped (here the asterisk meaning 0 or more) because if you find a first digit 8 it is already a hit for 'an', so what follows is not relevant.

1 year ago

https://www.duolingo.com/Beth743129

Hi Knud,

I think it's only if Streak = {8*, 11, 18}, because remember that, for example, 110 starts with the digits 11, but 110 is spoken as "one hundred and ten" starting with the English "w" sound, so it would take an "a" not an "an".

Coding is the same sort of fun as learning a language, isn't it? With all its pattern matching and attention to detail. Love it!

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

> 110

Agreed

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

> Coding is the same sort of fun as learning a language, isn't it? With all its pattern matching and attention to detail. Love it!

Yes, agreed. But coding is more complex and encompassing many more fields. Learning a natural language is kind of a much smaller 'sub set' of coding and as such much easier.

1 year ago

https://www.duolingo.com/benny_ns
benny_ns
  • 19
  • 16
  • 10
  • 8
  • 6

I believe this one requires more computational power than Beth's solution and it's also harder to read when in code.

1 year ago

https://www.duolingo.com/knudvaneeden
knudvaneeden
  • 18
  • 17
  • 10
  • 10
  • 9
  • 8
  • 7
  • 7
  • 7
  • 6
  • 6
  • 6
  • 6
  • 5
  • 5
  • 5
  • 5
  • 3
  • 3
  • 3
  • 3
  • 3
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2

After some more thinking, the easiest, minimal solution, requiring no further computation at all is just adding 3 fixed non-changing characters in the source code:

(n)

Thus instead of printing 'a' they should print 'a(n)'.

E.g.

you are now on a(n) 2 day streak.

you are now on a(n) 3 day streak.

you are now on a(n) 8 day streak.

you are now on a(n) 11 day streak.

you are now on a(n) 18 day streak.

...

Thus in the source replace something like:

print "you are on a {Streak} day streak!"

with

print "you are on a(n) {Streak} day streak!"

1 year ago

https://www.duolingo.com/Beth743129

Thank you everyone for participating in my discussion. I'll be leaving it here. I want to go and get on with some language learning. Have fun with your coding and language studies. Kind regards, Beth.

1 year ago
Learn a language in just 5 minutes a day. For free.