Every noun (cat, dog, boy, girl, etc.) in Norwegian has a grammatical gender (unrelated to any actual gender that the noun-object might be).
Strictly speaking there are three grammatical genders in Norwegian:
(m) masculine - hankjønn (male gender) - en gutt
(f) feminine- hunkjønn (female gender) - ei jente
(n) neuter- intetkjønn (no gender) - et barn
However, since practically every feminine (f) noun can also be used as a masculine (m) noun, language courses often blend masculine (m) and feminine (f) into what is called felleskjønn (common gender). Duolingo sometimes uses the three-gender system, and other times it uses the two-gender system.
common gender - en gutt - en jente
neuter - et barn
So that said: You use
en with masculine nouns
ei with feminine nouns
et with neuter nouns
en with common gender nouns (a merge of masculine and feminine nouns)
et with neuter nouns
The grammatical gender of the noun will determine how the noun looks when it is in plural, or how the English "the" will translate (or in other words how to inflect the noun). It will also change how pronouns (I, you, he, she, it, etc...) and adjectives (red, blue, good, bad, easy, confusing, etc...) and adverbs (slowly, quickly, etc...) will look. So you need to remember the noun's grammatical gender.
Unfortunately the grammatical gender of a noun is something you just have to memorize (there are some complex rules with a lot of exceptions in each case, but a proper grammar book is your best bet if you are really curious), so instead of thinking "boy" is "gutt" and "girl" is "jente" and "child" is "barn", memorize them with the gender article in front.
So think and memorize it as "en gutt", "ei jente", "et barn", "et eple", and so on.
If you really can't remember the gender and have to guess, guess en and you will be correct majority of the time.
Yes, the non-turtle version didn't enunciate enough for my taste but the turtle is there to help. The more we surround ourselves with Norwegian, the better our ears will become at differentiating similar sounds.
You ears haven't forsaken you! When r comes before d, t, s, n and l regardless whether it's touching them or not, it's pushed to the back of the throat becoming a so-called retroflex approximant "ɻ". In the case of barn, to make the pronunciation of the following letter easier, r also pulls the "n" backwards so it becomes the velar nasal "ŋ" (otherwise, it sounds as the alveolar nasal "n").
Follow this link and click on ɻ and ŋ to hear these particular sounds.
"En" is the masculine version of a/an. "Ei" is the Feminine version. "Et" is the neuter version. However, sometimes there is something, such as "a book" which is "en bok", where a book doesn't have a gender, but still uses the male version. So, if you ever have to guess at which one to use, choose "en". In most cases, "ei" can be swapped for "en".
I have some things to add to your answer.
Every noun in Norwegian is assigned one of the three genders which means you won't find rebels in this division. Bok is of feminine gender (link to a dictionary page) which means it can take the feminine indefinite article ei, or the masculine en and still be considered correct. All feminine nouns can be treated as if they were of masculine gender. The advice on guessing is sound.
As to whether a pattern exists, the answer is a solid no although there are some rules that mostly pertain to loanwords. Take a look at this recent forum post to learn more.
Also, ett is the cardinal number one  which is used with neuter nouns like in Jeg har ett eple (I have one apple) and not the indefinite article.
@HIM97, you should have read @noko_heilt_anna's comment thoroughly as it would have given you all the answers.
P.S. In the future, read all the comments before asking similar questions in order to keep the discussion page easier to navigate and, thus, more effective in helping others.