Visualizing Problem 15 of Project Euler

I’ve been working through Project Euler as a coding / math exercise. Problem 15 asks to find the amount of paths that exist between the top-left and bottom-right points of a 20×20 grid, without backtracking. I decided to visualize it, because just running a command line program and waiting can be boring.

Of course, this problem is silly to brute force, but by watching the visualization and working on a pad of paper, I came up with a much faster solution to solving the problem.

The code is available on github. It’s Ruby and Tk. Some Ruby installs don’t compile with Tk, so if the script doesn’t load the tk requirement, Google around for the solution.

Also note, this is a quick hack. It leaks memory, it’s buggy, it might eat your processor and will run for a very long time.

Visualizing Problem 15 of Project Euler

Git Switch

I have a need to change my git profile depending on what I’m working on. I created a simple script that I could run in the shell to switch between my profiles.

#!/bin/bash

case "$1" in  
'place1')  
git config --global user.name "Your Name"  
git config --global user.email foo@bar.com  
;;  
*)  
git config --global user.name "Your Other Name"  
git config --global user.email bar@baz.com  
;;  
esac

git config --global user.name  
git config --global user.email

If you put this script in your PATH, you can then run git switch place, where place is the profile you would like to use. In the script above, place1 is your first profile and anything else is the second profile. This allows you to run git switch, which just switches to the last, default profile.

The magic of git is that if you run git something, it looks for the command git-something in your path and runs it. If you save the above script as git-switch in your PATH and make it executable, you can execute the command as if it were apart of your git tool chain.

Git Switch