## 'Twas the Night Before Christmas! (I)

Here I will post a series of (mostly) simple challenges to amuse you in the run-up to Christmas. I'll try to post one each weekday.
DDRM
Posts: 398
Joined: Mon 02 Apr 2018, 18:04

### 'Twas the Night Before Christmas! (I)

Determine the letter frequency distribution for this famous verse (text below, so we all use the same version), and give the top 12 results. Ignore all punctuation /non-alphabetic characters. How does it compare with the classic “etaoinshrdlu”?

Bonus: calculate the root mean square difference of etaoinshrdlu from your result (i.e. if 10 of these letters come in the same places, 1 is 3 places away and 1 is 4 places away, this would be SQR( (10 x 0) + (1 x 9) + (1 x 16) ) = SQR(25) = 5). Yes, I know that example is impossible, but it’s mathematically simple! (Actually, thinking about it, it's not impossible...)

Hints: save the poem as a .txt file. In BBC BASIC you will be able to read it in as a single string (look up GET\$# BY and EXT# for some hints!), which is then easy to process. Don’t forget to allow for upper and lower case letters!

’Twas the night before Christmas, when all through the house
Not a creature was stirring, not even a mouse;
The stockings were hung by the chimney with care
In hopes that St. Nicholas soon would be there;

The children were nestled all snug in their beds,
While visions of sugar-plums danced in their heads;
And mamma in her kerchief, and I in my cap,
Had just settled our brains for a long winter’s nap,

When out on the lawn there arose such a clatter,
I sprang from the bed to see what was the matter.
Away to the window I flew like a flash,
Tore open the shutters and threw up the sash.

The moon on the breast of the new-fallen snow
Gave the lustre of mid-day to objects below,
When, what to my wondering eyes should appear,
But a miniature sleigh, and eight tiny reindeer,

With a little old driver, so lively and quick,
I knew in a moment it must be St. Nick.
More rapid than eagles his coursers they came,
And he whistled, and shouted, and called them by name:

"Now, Dasher! Now, Dancer! Now, Prancer and Vixen!
On, Comet! On, Cupid! On, Donner and Blitzen!
To the top of the porch! To the top of the wall!
Now dash away! Dash away! Dash away all!"

As dry leaves that before the wild hurricane fly,
When they meet with an obstacle, mount to the sky;
So up to the house-top the coursers they flew,
With the sleigh full of toys, and St. Nicholas too.

And then, in a twinkling, I heard on the roof
The prancing and pawing of each little hoof.
As I drew in my head, and was turning around,
Down the chimney St. Nicholas came with a bound.

He was dressed all in fur, from his head to his foot,
And his clothes were all tarnished with ashes and soot;
A bundle of Toys he had flung on his back,
And he looked like a peddler just opening his pack.

His eyes - how they twinkled! His dimples how merry!
His cheeks were like roses, his nose like a cherry!
His droll little mouth was drawn up like a bow,
And the beard of his chin was as white as the snow;

The stump of a pipe he held tight in his teeth,
And the smoke it encircled his head like a wreath;
That shook when he laughed, like a bowlful of jelly.

He was chubby and plump, a right jolly old elf,
And I laughed when I saw him, in spite of myself;
A wink of his eye and a twist of his head,