Monday, December 10, 2018

Fibonacci

The Fibonacci series is a series of numbers where fib(n) is the sum of fib(n-2) and fib(n-1).
When you find it in an interview question it is usually an opportunity to talk about recursion.

Recursion has these requirements.
    It must have a base state.
    It must change its state.
    It must call itself to move towards its base state.

The base state for fibonacci is 1. It helps to remember that this calculation is meant to plot
a line. A line length of zero is not really meaningful; thus, fib(0) is simply 0. Fib(1) doesn’t
have enough operands to calculate using fib(n) = (fib(n-2) + fib(n-1)) so we can take it at
face value too. At fib(2) we can start working: fib(2) = fib(2-2) + fib(2-1). You can see from
this that we will need to make sure we have return values for fib(0) and fib(1) to calculate
fib(2) correctly.

fib(0) = 0
fib(1) = 1
fib(2) 0 + 1 = 1
fib(3) 1 + 1 = 2
fib(4) 1 + 2 = 3
fib(5) 2 + 3 = 5

Use caution when you code this up. It doesn’t take long to get into really big numbers. You
shouldn’t use values of N higher than 35 or so without bringing a sandwich. Stay tuned for
test results on what happens with really big numbers. Theoretically the program will fill the
available physical ram, then consume paged ram (ram that is written to hard disk) until it
finds the answer or hitting the wall on how much RAM the OS is willing to give up. I am
guessing that the kernel will panic before the heat death of the universe with really, really
big numbers, but I am not going to bet the farm on it. I tried a value of 200 for N and got
bored before getting anything other than a pegged CPU.

Here is my Fibonacci function:
def fib(num):
   If num <= 1:
       return num
   else:
       return (fib(num-1) + fib(num-2))

Thursday, July 10, 2014

Desolation and Gray canyons; Green River, UT


A seemingly tranquil scene.

We drove through the night, paused for some reminiscing and a nap and made the putin. (No, not that Putin. The place where we launch the boats. Stoopid auto-correct.) 

We got in the day before launch. We were greeted by a hungry hoard of tiny blood sucking monsters. These horrific little winged terrors would slowly drive me insane due to my inability to find my bug spray. The rest of the group, my crew of merry blood donors, kindly shared with me and assured me that the citronella candle that I brought was working. In my week willed state I clung to that placebo with a desperate white knuckled grip. Luckily the team lead had the foresight to reserve a bug hut or sleep would have been impossible. 


The cliffs below Sand Wash.
There is something about sandstone cliffs. The sharp angles and square peaks are so different from the rain washed forests I have chosen as my home. The vitamin D deficiency developed by nine months of rain a year will keep me coming back to the desert even as I remember why I left. Sure is pretty..... AaaaghH!!!1! Fucking mosquitos! 

We pushed hard on launch day and managed to get 18 miles in. The BLM guy, who told us the bugs weren't bad this year, also told us that it would be better in the canyon. I lit my candle and ,thankfully, found my bug spray. I then leaned on the oars and tried not to compare the bugs here to all of the other rivers I have ever been on. I did well enough with the first, but the second proved the bigger challenge. 


It sure is pretty though.

This trip had lots of hikes up into side canyons along the way. A lot of people have made this canyon home over the years. The native peoples who lived here left long before the first white people showed up. They managed to write a few notes that would last though. The notes are called petroglyphs. In some cases they seemed to point the way to dinner. Something that would be a great help to people living here without the modern tools that I take for granted. In others they seemed fanciful and inscrutable. 

A map of the canyon. Note the "you are here" circle at the bottom and the branch in the canyon above.

Petroglyphs are glyphs carved into sandstone that has had a natural oil seep above it. The oil stains the sandstone and the ancient artists use rocks to break the top oiled layer of stone revealing the lighter unoiled stone. Imagine if your post-its lasted a millennia or two. 

I imagine the top of the picture showing that you can take lone, or very young animals with a rock, but will need a bow for groups or adults.

There are times during the trip that I wondered how anyone could live here. It's pretty clear that it's the only place in the area that anyone could live.

There is only a tiny strip of green next to the water. Everything else is a barren brown.

This was clearly where someone slept in the past. 

More postits. It's less clear what the message was.

Mushroom rock is a major landmark. It's where the last two pictures were taken.


Some did a bit more than just live. At least one person set up a moonshining operation. He had a little spring behind his cabin. I am not sure what was used for wort. Maybe cactus, or maybe sugar or grain was brought in.

The front view of the moonshiner's house. He built it under and overhang in the rock. A trail leads around to the back where a spring was flowing.

This old gas tank was part of the still. 

The wood burning stove and the inside of the "cabin."

The front window and various artifacts.

The biggest panel of petroglyphs was at rock creek ranch. It was also where I got poison Ivy. Karen is right about me. I am not a good noticer. 

You can tell these are really old by the way the oil has started darkening the lines.


Desolation canyon is aptly named. It beautiful, but inhospitable.






Good bye Desolation canyon.
We saw SOME wildlife on the trip; two bears, a beaver, and some mountain goats. I was only able to get pics of the goats though.

Can you spot the goats?

Grey canyon has a bit of a different feel than Deso. The rocks were different, and the water picked up the pace. We saw all of our big rapids there.







This plateau marks the end of the trip. 

Eight days was a long time to spend in this canyon. I had plenty of beer and whiskey, but not enough ice. We did come up with an invention or two out of the experience though. I'll save that for the "grand" unveiling and another post.

Keep the rubber side down my friends. 

Wednesday, November 2, 2011

Manfred takes a trip


Farmer: "Who's there?"

Manfred: "Me, who else would come all the way out here in the middle of the night?"

Farmer: "Just making sure"

Manfred: "Why the added security?"

Farmer: "..." 

Farmer: "You really don't know?"

Manfred: "No, if I did I wouldn't ask"

Farmer: "..." 

Farmer: "You must have pulled the hole you crawled in after you."

Manfred: "I figured I had to after this job"

Farmer: "Yeah, you really stirred the ant hill."

Manfred: "Heh, you been on the farm too long. Where'd a city boy pick up a saying like that?"

Farmer: "D'you know how long I've been out here now?"

Manfred: "...I try not to think about it."

Farmer"Yeah..."

Farmer: "Do you ever think about them?

Manfred: "..." 

Manfred: "You mean her?"

Farmer: "Yeah"

Manfred: "..." 

Manfred: "Why do you ask?"

Farmer: "Shit"

Manfred: "What?"
Farmer: "I'll tell you later" Manfred: "What?" Farmer: "I Said. I would tell you later. 

Manfred: "..." 

Farmer: "Word is, you got what you were sent for."

Manfred: "Yeah, I am not happy about that. There wasn't supposed to be word."

Farmer: "Some will say you should have killed the kid"

Manfred: "Some'd, better say it soft then. If I hear it, I'm likely tae be annoyed."
 
Farmer: "I can hear home in your voice when you get mad."

Manfred: "..."

Farmer: "Don't want you to think I'm getting soft out here staring at ant piles."
Farmer: "..."

Manfred: "Here. It should stay dry in there as long as the wax stays whole."

Farmer: "I'll send it along."

Manfred: "Now. Tell me. 

Farmer: "..." 

Manfred: "Tell. Me."

Farmer: "She's dead"

Manfred: "... Danni... "

Farmer: "... She was killed at her post."

Manfred: "... Of course she was... "

Manfred: "Who?"

Farmer: "The coup fell apart and the participants were routed in the field. James took Lord Fowler's banner. He made Fowler swear and he now keeps the kings coffers full. He won't let you touch them."

Manfred: "Fowler."

Farmer: "Don't think I'll forget why I'm all the way out here."

Manfred: "She's the reason I haven't gone home to pay him a visit."

Farmer: "Going back will finalize your exile; with Fowler feeling the heel of his majesty's boot... He might call us back."

Manfred: "Not after Word gets to him"

Farmer: "... I'm glad you didn't kill the kid."

Manfred: "Yeah."

Manfred: "..."

Farmer: "You're going."

Manfred: "Yeah"
 
Farmer: "... If you time it right. ... He may give you a head start when he gets this."

Manfred: "That was my thought."

Farmer: "... Good bye, old friend"

Friday, October 14, 2011

Percival gets a pony

The crowded streets remained indifferent to Percival as he lumbered down the muddy walks that bordered the cobblestone lane. At least he was making a valiant effort at lumbering. As much as anyone can be said to lumber who comes "knee high to my grandam's bum" as the sergeant-at-arms said in response to Percival's stated intent to join the Royal Marines. "I dare say you'd be safe behind a great shield, but you need to be able to see over it from time to time." said the gruff mound of brined soldier. This is not what Percival had expected to hear. You see, Percival had two assets that all good psychopaths need. He was short -- though he would likely be of a height with sergeant Grove's grandmum. He also, as you may have noticed, had a very unfortunate name. So lumber he did. Despite, or maybe because, no one noticed.

Percival had fallen on hard times. His short temper had always been a problem. He was constantly being scolded, punished and finally jailed for his inability to overlook even the smallest of perceived slights. When released at the end of his two month sentence for his role as the sole combatant on one side of a taproom brawl, he was told to "Find a use for all that passion." This was a last act of kindness offered as he was escorted to the edge of the town by the constable. "Join the military, or sign on as a guard in a caravan."the kindly man had said. "Just don't come back here. You know they let you off easy in memory of your mother, bless her soul."

Percival hadn't started the day out lumbering. He had started the day with what approached a spring in his step. He had thought that today was the day he would get to take some "passion" out on someone who really deserved it. All he'd managed so far was to get a great head of passion boiling away without the slightest notion of who really deserved to be on the business end of it. Three overland shipping companies, four private guard companies, a pair of mercenary outfits and now the lowest of the low. The Royal bleeding Marines. Most people had sense enough to know that you didn't need to get on a ship before getting a chance to die for your country. You could do that well enough serving in the army. They had turned him away yesterday. So, all Percival had to show for coming to the great port city was some extra wear on his boots.

Percival had run out of options. He had tried everywhere with no luck. "No luck but bad" he thought glumly as he pushed through a tight ring of screaming men. He was so absorbed in his own troubles that he didn't notice the sounds  of unarmed combat. The crowd had gathered to watch as a group of men were squaring off against a loan figure. The figure was bruised and battered. Blood from multiple cuts on his face dripped on to the muddied cobbles. His knuckles were torn and there were scrapes up and down his small frame. He stood, however, unflinching in front of a woman huddled around her torn clothing spewing forth a string of profanities that would send a pious man into a coma.  The only thing that the figure seemed more unimpressed with than he was with his antagonists was the amount of damage he had taken. There was simply no give visible in his small frame.

"Fuck off, Runt!" a voice sounded from behind Percival as he was taking in the scene. "This is a private matter." The blow that caught him in the back of his head was sharp and well delivered, but didn't have the affect the speaker hoped for. If it had been aimed at a Jack, or William, or even a Tom, it may have sent the recipient running for cover. But, as we have established, a Percival would not be treated in such a dismissive manor. This Percival was even less willing to "fuck off." This Percival was having a very bad day and this seemed like a great opportunity for him to use his passion.

Percival spun just in time to see the follow up to the earlier dismissal. He slipped to the side of the meaty fist as it passed through the space he had previously occupied, grabbed it firmly in both hands and started climbing the arm attached to it. Swinging one leg over a shoulder and locking the other around the barrel chested man who had taken the roll of negotiator had the affect of freeing Percival's hands for other activities. The activities he chose to pursue with his newly idle hands can be summed up with the words pummeling, poking and gouging. The negotiator, thrown off balance by his being used as an impromptu ladder, fell backwards in his attempt to escape the devilment produced by Percival's not-so-idle hands.

A flashing glimpse of the figure defending the maiden showed him being pressed by three of the six assailants. A further scan revealed the remaining two unoccupied thugs closing on Percival and their beleaguered  spokesman. The fists and boots began raining down on Percival with the force of hammers. Before he knew it he was curled up on the ground next to the figure trying vainly to protect himself from the furry of the negotiator and his neckless cohorts. He looked over at the figure and was surprised to see a wide grin spreading across his face. Percival didn't know what there was to be happy about. The blows had taken on a surreal kind of pattern almost like hoof beats. In fact Percival was hearing sounds exactly like hoof beats and cutting through them the sound of the figure's voice, strangely cultured, thanking him and naming him friend.

"Stop in the name of the king!" This was accompanied by the unmistakable sound of swords being pulled from scabbards. The hoofbeats, heard earlier, were produced by a company of horsemen in full armor. "Sergeant, take these men into custody!" Orders were shouted and men detailed to take charge of the negotiator's party. One of the horsemen nudged his horse in Percival's direction, but was brought up short by the figure's cultured words. "Hold on Scotty. Leave this one to me." The figure then reached for and was handed Scotty's sword. Percival was still stunned and trying to rise up from his knees when the figure asked him his name. Upon reply the figure lightly touched him on both shoulders and said "Rise, Sir Percival, and accept my thanks for your aid in defending her highness, the princess who I hope has learned her lesson about sneaking out of the palace without a guard."

Wednesday, October 12, 2011

First Post

Here is where I will be posting my reflections. Politics, Religion, Economics, Technology. Nothing is out of bounds. All things cast a reflection.