Total Is Right - A Fun Programming Challenge

Michael Shepanski
August 9, 2012
Aug
9

While browsing around I saw a mini Python challenge to build a program that can find all solutions to the game "Total Is Right". The game has the following basic rules:

  • Pick a bunch of numbers in the set: 1-10,25,50,75.
  • Pick a goal in the range: 101-999.
  • Using each number once and operators +-*/, find a formula that results in the goal.
  • Only integer results and sub-results are valid.
    (3/2) * 6 is invalid because 3/2 is not an integer result.

For example: Suppose we have the numbers: 3,4,6,7 with a goal of 156. A valid result would be: 4*(3*(6+7)) = 156. Each number is only used once, and the result correctly equals our goal.


Use Dot Notation to Build Django Contexts

Michael Shepanski
February 5, 2012
Feb
5

One thing about Django views that I personally find a bit annoying is using dictionary notation when building the context to pass to my templates. I don't find this a big deal for smaller views, but sometimes I have quite a bit of variables to pass back to my template. Organization, readability and maintainability often do not come in the syntactic form of a large dictionary of random objects.


Multiple Arguments in a Django Filter

Michael Shepanski
January 29, 2012
Jan
29

Custom Django filters are an awesome thing. One downside however is they don't easily allow multiple arguments passed through. I am finding in my time with Django I am wanting multiple arguments more and more. For example, lets look at the simple replace filter below.


Django Decorator to Print SQL Queries

Michael Shepanski
November 27, 2011
Nov
27

Django's ORM is great for fast development, but it is sometimes all too easy to write inefficient queries in the language. There are a few options to help find rogue queries sucking all that process time. My favorite is of course Django Debug Toolbar. However, sometimes this is not a viable option, such as when writing AJAX processors, or for some reason DDTB is not available to you.

This simple decorator may help you alleviate some pain. It also becomes a useful tool to copy and paste the queries into an external query browser. My favorite for Linux is CrunchyFrog.


Fun with Simple Encryption

Michael Shepanski
November 20, 2011
Nov
20

Every programmer loves thinking they can come up with some crafty way to encrypt a string. Having no background in encryption, of course I think the same thing. The hard part is coming up with something that is also easily decryptable, but clever enough that the average joe can't figure it out. Here is my attempt.