> for some words, we use an. For example, an apple.

The rule is fairly simple as it was taught to me - if the word (apple) begins with a vowel sound, use “an” to avoid cacophony. Same way one uses “o” (means “or” in Spanish) but “u” if the next word begins with a vowel.

What matters is the sound though, not the character - so it’s not as trivial to algorithmize. Eg. A hammock, an hour.

This is covered exactly in the post right under that sentence. Why just restate it?