Uncategorized

Mew

A merciful end to an otherwise merciless day.

Trivial Code; Unexpected Output

I recently read an old post about a guy who taught himself how to write computer programs after failing at it a number of times before. Midway through the article he points to the kind of problem that really got him started on his path to learning:

My struggle to become a hacker finally saw a breakthrough late in my freshman year of college, when I stumbled on a simple question:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6, and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

What’s especially neat about it is that someone who has never programmed — someone who doesn’t even know what a program is — can learn to write code that solves this problem in less than three hours. I’ve seen it happen. All it takes is a little hunger. You just have to want the answer.

It took me about three minutes, not hours (see below). Then again, I first learned to program computers about thirty years ago. What held my interest in the article, and this question especially, was it got me to thinking how, if I were the teacher and using this example to teach somebody how to program, how I might extend the problem a little by asking the student to make the program more flexible — extend it to let the user input any two numbers (not just 3 and 5), and any ceiling value (not just 1000). That’s what I did in the trivial example below.

What I didn’t expect, however, were the outputs when I repeatedly ran the program with values of ceiling 10 times greater than the previous one (10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000). It’s not intuitive to me that each successive sum would be a little over 100 times greater (not exactly) than the previous one. Not 10 times greater, which might appeal to your intuition (but still wouldn’t be obvious to me).

I have an email in to my brainy friend on the east coast asking for an explanation. I was told by a another friend of ours he got a perfect score on the SAT.

public class Quiz {

public static void main(String [] args) {

int firstNumber;
firstNumber = Integer.parseInt(args[0]) ;

int secondNumber;
secondNumber = Integer.parseInt(args[1]) ;

int ceiling ;
ceiling = Integer.parseInt(args[2]) ;

long sum = 0 ;

for(int i=1; i<ceiling; i++) {

if( ( i%firstNumber ) == 0 || ( i%secondNumber ) == 0 ) {

sum += i ;

}

}

System.out.println( “Sum: ” + sum ) ;

}

}

————-Output————-

>java Quiz 3 5 10
Sum: 23

>java Quiz 3 5 100
Sum: 2318

>java Quiz 3 5 1000
Sum: 233168

>java Quiz 3 5 10000
Sum: 23331668

>java Quiz 3 5 100000
Sum: 2333316668

>java Quiz 3 5 1000000
Sum: 233333166668

>java Quiz 3 5 10000000
Sum: 23333331666668

>java Quiz 3 5 100000000
Sum: 2333333316666668

Hmm

Driving to the barber shop the other day it felt like the driver’s side back wheel was ready to come off. I pulled into the lot, parked, looked everything over. Nothing appeared out of sorts.

Hmm.

These days it takes about as long to cut my hair (eyebrows included) as it does to comb it. Imagine dragging a rake through a desert. I still comb out of habit, not necessity. Actually, anymore I use a brush — Happy Wife’s. The bristles are closer together on a brush, I get more purchase, making me feel like the effort actually improved my appearance. It still costs me $17.00 for a haircut. Flat rate. Doesn’t matter. Hell, it could be Howard Stern in that chair. He could walk in, sit down, and say “Make me look like Jesse Ventura.” Wouldn’t matter — $17.00.

Lehi, my barber, always shows me his work in a mirror before I leave the chair, “How’s that. Think the missus will let you back in the house now?” It’s one of few narcissistic moments it’s okay to enjoy. Someone holds a mirror to your face and asks you to appraise your appearance. I look at myself and think, “Maybe save the selfie for another day?” It’s not that 55 years has devastated me, it’s just not a visage I think needs to be pixelated and preserved for posterity.

Some day, just to get my money’s worth, I’m going to have Lehi cut it all off. That oughta give Happy Wife a jolt.

I hand him a twenty and wave goodbye. He appreciates my business, is always grateful for the tip.

Turns out the wheel was about to fall off. Driving home after the haircut the noise and shaking got much worse. I slowed to make the u-turn a block from our driveway when the driver behind me honked. Which annoyed me at that instant — WTF, can’t I make a u-turn for God’s sake?!

Probably he/she was just trying to warn me was all.

Pulled in the driveway, got out of the car and looked at the wheel. 3 of 5 lugs gone, the pins sheared off. The two remaining lugs were loose.

Who would want to kill me?

Turns out it was probably me. The last time the wheel was removed was when I flatted on the Denali Highway, back in June when Happy Wife and I took off for an impromptu vacation. I must not have tightened the lugs properly. Although I do have a memory that I took special care to do so.

Hmm.

And to think they’ve been working themselves loose all this time. Yikes.

HW is back to sleeping in a tent in the backyard at night. Too warm in the house. Supposed to remain miserable through Friday, mid to high 70’s and sunny, and by Saturday turn nice again, low 60s and rain.

She’s doing the best she can under these difficult circumstances

Chez

Came home from work today. Pedaled my bike to and from. 75 and sunny.

Happy Wife says, “Welcome Home!” (She’s off Fridays).

“What did you do today?” I asked.

Not much

  • 3 loads of laundry
  • Weeded and watered vegetable garden
  • Shopped at Costco & Fred Meyer
  • Vacuumed & mopped all floors
  • Dusted all furniture, upstairs & down
  • Cleaned 3 bathrooms — toilets, sinks, & fixtures
  • Got gas for lawn mower, and propane for grill
  • Mowed & trimmed front and backyard lawns
  • Planted 2 new perennials
  • Mulched

Oh, and I have a surprise for you…out on the deck.

I call it Chez Nibbe. Wine & appetizers. Whatya think?

All of a sudden,  a Raven happened by, bearing berries.

And then dinner was served… Scallops in Chipolte Orange Sauce on a bed of Polenta. Brilliant!

I feel wonderful because I see
The love-light in your eyes.
And the wonder of it all
Is that you just don’t realize how much I love you.

-Eric Clapton

Lactic Acid

Happy Wife led Dumpy Husband up a hideously steep climb to what she estimated was 1/3rd of the way to the summit of Mt. Alice. A young lady at the trail head, maybe half our age, mentioned to me that only a few people have ever made it to the summit. “Some have died trying,” she added.

Death? Like No Tomorrow?

Kids these days.

“Have a great day!” she said. And just like that she, her boyfriend (?), and their alacritous dog bounded up the trail and we never saw them again. By the time HW and I reached our turnaround point I was feeling the start of sewing machine leg. Which I knew was only going to get worse on the descent.

Here we were at our turnaround

And from Seward later the same day, the arrow marks our turnaround. The summit of Mt. Alice looms to the left.

Boo!

I got snail mail a few days ago from a journal editor letting me know my story had not been accepted for publication. No biggie, right, add it to the pile. Except this story… I’d sent it in three years ago. Talk about your long wait time. It’s a story about a young man who was betrayed by his friend and mentor, with a tragicomic end. I rather like the story, but I agree with others who read it that it’s a bit long for a short story. I think it may work better as a book chapter.

Imagine, you’ve drifted off into a luxurious sleep. When all of a sudden, you’re awakened by this

It happened to me. July 4th. I’d checked out of the party early (being the wimp that I am), tended to my ablutions, chased my statin and two Ibuprofen with a cold glass of water, slipped beneath the covers and, well, like I said, drifted off into a luxurious sleep. Sometime later, I’m guessing maybe an hour, these five pushed open the bedroom door and woke me up. Even though I was groggy I had the presence of mind to snap a photo. Damn good thing I keep my phone bedside. Positively Hitchcockian.

The one far right was our guest from England. He’s leaving Anchorage tonight to fly to Chicago, a seven hour layover, and then on to Heathrow. Seven hours to Chicago, another nine to Heathrow. Ugh. One thing I love working for an Alaskan company is I no longer have to fly for work. We’re going to miss our friend from England. We didn’t get to know him well, but what we did get to know we liked very much.

He showed me how to root my phone! Encouraged me to keep at it with the guitar (even suggested a novel method for accelerated learning). Praised my latest software at work, and was a most gracious guest as we showed him all we could of this wondrous place we call home.

Oh yeah, and he liked my martinis,

Summer is holding on. Back into the 70s this week. (Speaking of luxurious). Along with our guest from across the Pond we had family visit us for a few days — thoroughly enjoyable. And now, this weekend, it’s just me and Happy Wife at our Nest, taking a breather, until more guests arrive in August. And then come September — Ta Da! — we are Wisconsin bound. Not saying where, exactly, but if you find yourself in front of a tv come 9/28 (hint: Monday Night), tune in to this, you may spot us!

Super Human

A grand 4th it was! Although, as I feared, this year it was not a day marked by American Exceptionalism. Take for instance the Mount Marathon race. The course record for women was demolished by Miss Forsberg, a French woman who hails from Calais, France.

I caught her cruising to the finish line, her hair barely mussed from the effort, like she’d just come from the bathroom after freshening up

To be fair, a young Alaskan woman who finished second, her first year competing as an adult, also beat the course record by a few seconds. She will be one to watch in future years.

In the men’s race, a Spaniard, from Spain — nothing gets by me! — also set a course record. Nobody in sight behind him either as he also cruised to the finish

If you think this a race only for the young, think again. I captured this old timer as he approached the base of the climb. Must’ve been 65 or older. Alone in his thoughts I’m sure. Clearly he’s not in it to win. It’s about bragging rights if I had to venture a guess. Or something he does every year because of a promise he made long ago, probably to himself. Whatever it is he had a long time to think about it. That’s a steep mountain to get up and down.

 

Another one of the men approaching the start of the climb

Some return a lot more beaten and ragged than when they left

Here’s a look at the summit from near the finish, should you be thinking, “What’s So Hard, It’s Half Downhill.” Less than 42 minutes up and down? These people are not human

Pow! Bang! Zowie!

“May I have my Latte now please.”

Stat Dear!

That was earlier in the week. Now the long weekend begins. We are headed to Seward, the busiest weekend of the year down there by far owing to the Mount Marathon race. We’ve invited along a man I met at work who’s here from the UK doing some contract work. The irony of celebrating our nation’s independence from Great Britain with him has not escaped me. Maybe a little reenactment, sir? Haha.

By the way, why is it called Great Britain? You never hear Great Egypt, or Great Brazil, Great United States, or Great India. I was told by our guest that in fact it was a matter that had stirred a lively national debate. When put to a vote, Great narrowly edged out Fantastic and Amazing. I don’t need to remind you of the all the dangers of an excessive national pride.

And here I sit, as I type, eating an English muffin and listening to a woman on the radio with a heavy British accent go on about something or another. This is what happens when you let your guard down. The proverbial Camel’s nose under the tent. The seemingly innocent day-to-day things that become established in our lives may in fact be the harbingers of tyranny.

Gotta run. Many Honey-Dos to tend to before we can depart Anchorage. Supposed to be warm and sunny throughout the weekend. This pleases me greatly. Enjoy he Holiday!