About

Take a tour of my mind.

Search for content

The fastest autofocus.

The fastest autofocus.

~ Rough Solo Cut - Tim Madorma & Preetam D'Souza

I wanted to share a little collaboration with one of my dad’s colleagues, Tim Madorma. This is a *VERY* rough mix of just the solo section I laid down for his song. I’ll put up a link to the final product whenever Tim puts everything together and polishes it.

I spent a bit of time recording this solo today…check it out.

P.S. I love the unlimited possibilities that digital recording offers the modern artist. How cool is it to work on a track with different people in totally different places? All you have to do is record your own parts and share.

The Best Valentine’s Day Gift?

I just came across this quote from an editorial (published in the Surgery News, you can view the whole thing here) by Lazar Greenfield, head of the American College of Surgeons, in the latest Scientific American:

As far as humans are concerned, you may think you know all about sexual signals, but you’d be surprised by new findings. It’s been known since the 1990s that heterosexual women living together synchronize their menstrual cycles because of pheromones, but when a study of lesbians showed that they do not synchronize, the researchers suspected that semen played a role. In fact, they found ingredients in semen that include mood enhancers like estrone, cortisol, prolactin, oxytocin, and serotonin; a sleep enhancer, melatonin; and of course, sperm, which makes up only 1%-5%. Delivering these compounds into the richly vascularized vagina also turns out to have major salutary effects for the recipient. Female college students having unprotected sex were significantly less depressed than were those whose partners used condoms (Arch. Sex. Behav. 2002;31:289-93). Their better moods were not just a feature of promiscuity, because women using condoms were just as depressed as those practicing total abstinence. The benefits of semen contact also were seen in fewer suicide attempts and better performance on cognition tests.

So there’s a deeper bond between men and women than St. Valentine would have suspected, and now we know there’s a better gift for that day than chocolates.

In case you were wondering, he resigned shortly afterwards. Seems like the medical community is still a bit uptight about these things…but hey, I like to keep an open mind.

Sudoku Challenge: Ruby Version!

As I promised, I have the Ruby version of my sudoku solver written up. I have a couple of things to say about this one, as well as a few pieces of knowledge I picked up along the way:

  • It is significantly more concise. My old solver was 180 lines but this one is 112 lines (and it has more functionality).
  • It is much faster. Most of the speedup can be attributed to my inclusion of an additional constraint programming algorithm (taken from Peter Norvig’s solution…reference below), but there was a lot of messy checking in my old solver that was virtually eliminated. Essentially, I can solve roughly 62 “hardest” level puzzles per second with an average solution time of 0.016s! See benchmarks below for more details.
  • Dealing with multiple copies of a data structure (like in a backtracking search) can bite you in the ass. Each branch of the game tree requires a new copy of my “choices” list (which describes the possible number choices for each cell in the grid given the other cells), and I ran into several outlandish errors until I realized that Ruby’s Object#clone method only makes shallow copies…turns out that there is no deep copy in Ruby, unlike Python. This brings me to my next point.
  • In order to get around the lack of deep copy in Ruby, you need to implement it yourself. Doing a few searches on the net, I found that the typical deep copy idiom is Marshal::load(Marhsal.dump(obj_to_be_copied)). Although this is a general solution it is SLOW. If you have a relatively simple object, like a list of lists, do your code a favor and do recursive copies: list.map {|x| x.clone}
  • For some strange reason, my code seems to run faster with list.map {|x| x*1} instead of using Object#clone. I ran a separate benchmark test and it seems that x.clone should be a little bit faster…weird.
  • When creating a new array with a default object (like another array or hash) make sure you are using the correct Array#new form. If you do something like Array.new(10, Hash.new) or even Array.new(10) {object_ref} you will get 10 copies of the same object. Use Array.new(10) {Hash.new} or Array.new(10) {object_ref.clone}. Again, frequent Ruby users know this but it can easily trip up a beginner to the language like me.
  • Features in Ruby I found useful: statement modifiers, the new 1.9 lambda syntax, the “unless” keyword, blocks in general, array functions (map, select, inject, &, -), ranges, and the built-in regex pattern matching.
  • Features I wish Ruby had: a deep copy function, list comprehension (a la Python), and the “in” keyword.

Alright, enough of my ramblings…here is the code and sample output. I tested my code with 50 easy, 95 hard, and 11 hardest puzzles from Peter Norvig’s Sudoku Page. For those of you who don’t know him, he is the Director of Research at Google and has “possibly the best compsci job on the planet” according to my high-school AI professor. His sudoku page is a great resource for anyone who wants to learn about constraint programming and searching. (Anyone who wants to learn Python idioms, please look at his sudoku solver…it is quite clever).

“Bullets” for Alternate Picking

I love alternate picking. That being said, I would say that precise alternate picking is the hardest (lead guitar) technique to master. Master alternate picking and you can play all those great picking lines by Malmsteen, Gilbert, Petrucci, etc. Recently I’ve been working on two-note-per-string licks a la Rhoads and Wylde. Hopefully I’ll be able to put up a cover of the lead section from “No More Tears” soon…those are some bloody fast sextuplets. 

I spent some time learning “Bullets” by Creed today as it randomly popped up on iTunes and that distorted intro riff is oh-so-catchy (it’s in D Phrygian for all you music theorists). I found that playing the riff up to speed is a great way to practice elementary alternate picking on two strings. Here is the riff I’m talking about (tablature stolen from http://tabs.ultimate-guitar.com/c/creed/bullets_tab.htm):

e-----------------------------------------------------------------
b-----------------------------------------------------------------
g-----------------------------------------------------------------
d-----------------------------------------------------------------
a-----------------15--------------13------------------------------
d-13-12-0-12-0-12----12-0-12-0-12----12-0-12-0-0-13-12-0-10-12-0--

The verse riff has a slight tail variation and is played with all notes palm-muted (incorrect in above tab link, the version below is correct):

e-----------------------------------------------------------------
b-----------------------------------------------------------------
g-----------------------------------------------------------------
d-----------------------------------------------------------------
a-----------------15--------------13------------------------------
d-13-12-0-12-0-12----12-0-12-0-12----12-0-12-0-0-13-0-10-0-12-0---

This isn’t too difficult for guys who have been playing for a couple years but I think its a great intro exercise. The switch from open strings to muted strings with the intro->verse change is excellent for developing flexibility and control in the right hand.

Go learn it!

Creed - Bullets

helvetebrann:

We just morphed old beliefs into new religions.

helvetebrann:

We just morphed old beliefs into new religions.


(via helvetebrann)

Ruby Quiz: LCD Numbers

In my quest to uncover those dusty layers of Ruby knowledge stored somewhere in my brain, I came across http://rubyquiz.com/ (thanks to my dad). This place runs weekly quizzes in Ruby and presents submitted solutions for each quiz. It’s a great place to test your programming abilities, and moreover, learn how others think and code. Here is a little quote from Peter Seibel, author of “Coders at Work”, that illustrates how difficult it is to learn the art from others:

Programming is an unusually obscure craft; programmers usually work alone or in small groups and the most interesting parts of what they do happen in their heads where no one can see what is really going on. Then the artifact programmers produce—code—is chewed up by a machine to produce runnable programs whose behavior is the only window most people will ever have into the programmers’ work.

Anyways, I decided to try out one of the problems myself and compare/contrast my solution with others. Basically, write a program to output a number chosen by the user in a 7 segment display format to standard out. Seems like a simple problem, but a concise solution requires a concrete strategy. I came up with two versions of my solution: one is (hopefully) partially understandable and my official solution, the other was an attempt to write the shortest solution I could think of. (My shortest solution is 379 bytes long…the shortest recognized solution I could find on the site is ~300 bytes. That one is 6 lines long and a mindfuck). Here they are:

UPDATE: Shortened lcd_min.rb to 335 bytes!

This has been dominating my main monitor for a while. Recording and mixing takes time, but it is immensely satisfying when you have the final product. This one is tentatively “Stranger in Yggdrasill”. Lots more fine-tuning still needs to be done—but I’m quite happy with the audio quality in comparison to previous work.

This has been dominating my main monitor for a while. Recording and mixing takes time, but it is immensely satisfying when you have the final product. This one is tentatively “Stranger in Yggdrasill”. Lots more fine-tuning still needs to be done—but I’m quite happy with the audio quality in comparison to previous work.

The Sudoku Challenge

I’ve decided to stop being lazy and finally start learning the intricacies of several programming languages that I have always been interested in. A little background: I would say that I have a strong knowledge of C, Java, and Python. Although I have used Ruby back in high school, I feel that I have lost touch with it. There are also various new features in Ruby 1.9 that I would like to try. Aside from imperative languages, I really want to delve into the new functional programming paradigm.

So what is the Sudoku Challenge? Well, I happened to stumble upon a sudoku solver I wrote in Python in my AI class in high school. It uses a graph coloring algorithm and forward checking heuristic to solve any standard Sudoku in no time (it solves so called “Evil” puzzles in a tenth of a second with I/O overhead included).

Here is the unadulterated source for sudoku.py:

Although this is clearly fast enough (just ran at 0.135s), I would like to try to write this solver as cleanly and efficiently as possible in several other languages. In the process, I hope to utilize unique aspects of the chosen language to clarify and speed up my code. I will post detailed runtime analysis comparisons and file length counts in order to see which version is the fastest/shortest. If I can write a blazing fast solver in a language, chances are that I understand its nuances.

Up next is the Ruby version…

Insane multi-tasking with some cool riffs! Anyone else notice that cool spiraling chromatic pattern in the bass on the piano??