TWC: Punting to MJD and Showing Q&D Geometry
I'm always doing other things and then Sunday comes and I start thinking, "How much time do I have before it's midnight in London?"
When "The Perl Challenge" first started, I was happy to just ponder the problems. Then came the pandemic and I thought that I would use some of my then copious free time to contribute. Then time got not-so-copious. And more people started contributing to TWC, some people much more talented than me, it turns out.
So I'll take a stab at things when I can and I'll still try to write a stand-alone script the way (I wish) I would at work, but my threatened laxness in writing things up will be more of a promise: Light banter to cast a veneer of confidence on the correctness of my results, anything else is extra.
Higher Order Perl, Chapter 6, "Infinite Streams," Section 6.4, "The Hamming Problem"
How's that for being lazy? ;-)
I've been on a geometry kick recently, so am just going to free-form the approach to the answer. This is also the first time I've written up a review prior to writing the code. But I see the way forward:
From the four given points:
- Create six line segments, then
- Sort the line segments by length, then
- If the first and the fourth line segments are of equal length, and
- If the fifth and sixth line segments are of equal length, then
- You have a square!
Oh, and one thing to do, whenever you compare floating point numbers, you need to decide what your tolerance for equality is. Me? I think it's 0.0001 today.
Okay, it's time to go write the sucker. It's just after 11pm in London, so better get cracking.
Submitted ten minutes past midnight in London Town! I'm not as quick as I thought I'd be :-(
Mohammad works hard and deserves his sleep, so I like to think that he is shutting down the old laptop at 12:00:01 am, or (00:00:01 for you 24-hour clockers). I'll just sit in the back of the auditorium like all the rest who shuffle in late....