# Programming Theory

Best practices, structuring of code, dissecting algorithms and talking about the “Why?”

## Let the Carnage Begin! Josephus Solution in C++

It was a dark stormy night, the staff of DIC had been running all night up this steep mountain trying to avoid the hordes of newbies asking for solutions. "Run for the cave!" yelled supersloth. So the crew ran into the cave hoping to elude the beasts that will not let a programming master sleep. Shortly after the 10 staffers made it safely inside... "BOOM POW CRASH!" the cave entrance ...

## Problems with Brute Force in Programming

"Damn! This solution just won't work! I have tried everything and all I get is a bunch of mush! Stupid programming I hate it!" Does this sound like you? Do you feel like one of those people on TV at the beginning of some paid television commercial? Many times the newbie and the expert alike finds themselves in the situation where a project just seems to stall. As human beings, ...

## Euclidean, Bezout, and Coprime Oh My!

Occasionally a programmer loves to play with numbers. Some like to stick gum in their sister's hair, but that is besides the point. At the heart of some programming is the heart of mathematics and especially number theory. One of the great theoretical algorithms out there is the Extended Euclidean algorithm which is used to find the Greatest Common Divisor (GCD). The GCD is a number which divides both of ...

## BozoSort Definitive (C++, C#, VB.NET, Java, PHP)

WARNING: PLEASE USE WITH EXTREME CAUTION! CONTENTS MAY BE FUNNY BUT NOT FOR PRODUCTION USE. Programmer Discretion is Advised! Hey you bozos out there, now there is a sort even for you! For those who don't know, a Bozo Sort is a joke sorting algorithm that actually sorts but at horrible timing and is very inefficient. It is good to see it at work from a theoretical stand point but it ...

## Stair-step Table Access in VB.NET

There are various methods to access information in a table "lookup" structure. Indexed access, sequential access, etc but the type of access you go with always depends on the data. Many times on the board I have noticed people asking about setting up some type of scale. Most of them are usually working on a grading program of some sort. How does someone determine if the student got an A ...

## Timezone Arithmetic With Classic ASP

As a casual reader of my blog, you may know I like to do an occasionally weird post that I stick in my "General Discussion" category just for kicks. I figure that programming doesn't always have to be a chore. It can be fun if you want it to, playing around with certain features. In this entry I play around with time zones and how you can find out a ...