<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace V5 Site Server v5.13.166 (http://www.squarespace.com) on Wed, 19 Jun 2013 06:42:04 GMT--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Home</title><link>http://andrewtubman.com/home/</link><description></description><lastBuildDate>Sat, 25 Aug 2012 05:53:50 +0000</lastBuildDate><copyright></copyright><language>en-US</language><generator>Squarespace V5 Site Server v5.13.166 (http://www.squarespace.com)</generator><item><title>What happens when you play Cypress Hill through a squid’s fin</title><category>Science</category><category>cypress hill</category><category>music</category><category>squid</category><category>video</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Fri, 24 Aug 2012 20:34:54 +0000</pubDate><link>http://andrewtubman.com/home/2012/8/24/what-happens-when-you-play-cypress-hill-through-a-squids-fin.html</link><guid isPermaLink="false">280107:2837536:25103205</guid><description><![CDATA[<p><iframe width="640" height="360" src="http://www.youtube.com/embed/G-OVrI9x8Zs" frameborder="0" allowfullscreen></iframe></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-25103205.xml</wfw:commentRss></item><item><title>Reggie Watts</title><category>Music</category><category>connon</category><category>music</category><category>reggie watts</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Wed, 06 Jun 2012 14:13:07 +0000</pubDate><link>http://andrewtubman.com/home/2012/6/6/reggie-watts.html</link><guid isPermaLink="false">280107:2837536:16600460</guid><description><![CDATA[<p><iframe width="560" height="315" src="http://www.youtube.com/embed/a2DXfKosT3s" frameborder="0" allowfullscreen></iframe></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16600460.xml</wfw:commentRss></item><item><title>Kodomo - Concept 1</title><category>Music</category><category>concept 1</category><category>kodo</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Sat, 02 Jun 2012 14:45:23 +0000</pubDate><link>http://andrewtubman.com/home/2012/6/2/kodomo-concept-1.html</link><guid isPermaLink="false">280107:2837536:16538492</guid><description><![CDATA[<p><iframe width="560" height="315" src="http://www.youtube.com/embed/o3evFq3dDg8" frameborder="0" allowfullscreen></iframe></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16538492.xml</wfw:commentRss></item><item><title>Project Euler - Problem 5</title><category>Problem 5</category><category>Programming</category><category>Programming</category><category>Project Euler</category><category>Python</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Wed, 09 May 2012 21:06:32 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/9/project-euler-problem-5.html</link><guid isPermaLink="false">280107:2837536:16199623</guid><description><![CDATA[<h3><span>What is the smallest positive number that is&nbsp;</span><dfn title="divisible with no remainder">evenly divisible</dfn><span>&nbsp;by all of the numbers from 1 to 20?</span></h3>
<p>This was a neat question could be brute forced easily but that would be very slow. There is a table method which exploits the properties of prime numbers to find least common multiple of a set of numbers. The exact method can be found on the least common multiple <a href="http://en.wikipedia.org/wiki/Least_common_multiple">wikipedia page</a></p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
import copy 

def dividable(x,divisor):
    if x%divisor==0:
        return x/divisor
    else:
        return x
    
def addRows(lis,multiple):
    prevRow=lis[len(lis)-1]
    newRow = [dividable(elem,multiple) for elem in prevRow]  
    while prevRow!=newRow:     
        lis.extend([newRow])
        prevRow = newRow
        newRow = [dividable(elem,multiple) for elem in prevRow]  
    return lis  

#inital values
factors = [[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]]
primes = [2,3,5,7,11,13,17,19]
multipleCount = [0]*len(primes)

#use table to work out prime factor counts
table = copy.deepcopy(factors)
prevLen = 1
for i in range(0,len(primes)):
    table = addRows(table,primes[i])
    multipleCount[i] = len(table) - prevLen
    prevLen = len(table)

#compute solution using prime factors    
solution=1
for i in range(0,len(primes)):
    solution*=primes[i]**multipleCount[i]

print "Solution: The least common multiple of %s is: %d" % (factors,solution)
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16199623.xml</wfw:commentRss></item><item><title>Project Euler - Problem 4</title><category>Programming</category><category>Project Euler</category><category>Python</category><category>problem 4</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Sat, 05 May 2012 15:00:39 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/5/project-euler-problem-4.html</link><guid isPermaLink="false">280107:2837536:16137214</guid><description><![CDATA[<h3><span>Find the largest palindrome made from the product of two 3-digit numbers.</span></h3>
<p>A palindrome is a string which reads the same forwards and backwards for example 98789. The isPalinedrome(x) method checks if x is a palindrome by checking if x equals x in reverse. The n[::-1] call returns the reverse of n. The stride notation lets you filter in a interval of elements in a list. For example the call n[::2]&nbsp;for n = [1,2,3,4] &nbsp; would return [2,4]. Then a nested for loop is used to find the biggest palindrome made of the product 3 digit integers.</p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
import math

def isPalindrome(x):
    n = str(x)
    if n==n[::-1]:
        return True
    else:
        return False
        
        
biggest = 0
for i in range(999,100,-1):
    for k in range(999,100,-1):
        if (i*k)>biggest and isPalindrome(i*k):
            biggest=i*k

print "Solution: %s " % biggest
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16137214.xml</wfw:commentRss></item><item><title>RIP Adam 'MCA' Yauch of the Beastie Boys</title><category>Adam Yauch</category><category>Beastie Boys</category><category>MCA</category><category>Music</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Fri, 04 May 2012 20:36:38 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/4/rip-adam-mca-yauch-of-the-beastie-boys.html</link><guid isPermaLink="false">280107:2837536:16129952</guid><description><![CDATA[<p>Pretty bummed about lossing MCA today. Been a fan for as long as I can remember. There's pretty much always been a Beastie Boys album in my rotation from Hello Nasty to the Mix Up. Here's a homage to sabotage that me and some friends made while finishing up highschool.</p>
<p><iframe src="http://player.vimeo.com/video/1115316" width="600" height="400" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16129952.xml</wfw:commentRss></item><item><title>Project Euler - Problem 3</title><category>Learning Python</category><category>PProject Euler</category><category>Problem 3</category><category>Programming</category><category>Python</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Wed, 02 May 2012 12:52:38 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/2/project-euler-problem-3.html</link><guid isPermaLink="false">280107:2837536:16093258</guid><description><![CDATA[<h3><span>What is the largest prime factor of the number 600851475143 ?</span></h3>
<p>This problem is a little tricky the solution looks simple but there&nbsp;are a few key things that let it run quickly. First we take the square root of 600851475143 and start searching from that value to zero. We can look in this range because any factor greater than the square root would have a multiple below it and thus not be prime. The second thing to note is the if statement which checks if we have found a solution. We check if it is factor before checking if it is prime. This cuts down on the number of expensive prime checks because they are only done after confirming that a value is a factor of 600851475143. This is because the 'and' statement returns false after the first operand is checked and doesn't waste time computing the second one (the prime test)</p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
import math
def isPrime(x):
    m=2
    while m<x:
        if x%m==0:
            return False
        m+=1
    return True

val = 600851475143
fact=int(math.floor(math.sqrt(val)))
while fact>0:
    fact-=1
    if val%fact==0 and isPrime(fact):
        break

print "Solution: %s" % fact
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16093258.xml</wfw:commentRss></item><item><title>Project Euler - Problem 2</title><category>Learning Python</category><category>Problem 2</category><category>Programming</category><category>Project Euler</category><category>Python</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Tue, 01 May 2012 13:47:34 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/1/project-euler-problem-2.html</link><guid isPermaLink="false">280107:2837536:16078525</guid><description><![CDATA[<h3><span>By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.</span></h3>
<p><span>Problem 2 of project euler is another simple one. The next value in the fibonacci sequence is the sum of the previous 2 values. As we produce the next value in the fibonacci sequnece we sum up the even values.</span></p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
x=1
y=1
cur=2
sum=0
while cur<=4000000:
    if cur%2==0:
        sum+=cur
    tmp=cur
    cur+=y
    x=y
    y=tmp
print "Solution: %s" % sum
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16078525.xml</wfw:commentRss></item><item><title>Project Euler - Problem 1</title><category>Learning Python</category><category>Problem 1</category><category>Programming</category><category>Programming</category><category>Project Euler</category><category>Python</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Tue, 01 May 2012 13:21:45 +0000</pubDate><link>http://andrewtubman.com/home/2012/5/1/project-euler-problem-1.html</link><guid isPermaLink="false">280107:2837536:16078277</guid><description><![CDATA[<h3>Find the sum of all the multiples of 3 or 5 below 1000.</h3>
<p>First problem starts off pretty simple. For each of the numbers 1 through 1000 we check if they are divisable by 3 or 5 and sum up the values that are. Checking if a interger is divisable is done using the <a href="http://en.wikipedia.org/wiki/Modulo_operation">modulo</a> operator &nbsp;% which returns the remainder of a division. If the remainder is 0 then the two operands divide evenly.</p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
sum=0
for i in range(1,1000):
    if i%3==0 or i%5==0:
        sum+=i
print "Solution: %s" % sum
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16078277.xml</wfw:commentRss></item><item><title>Lets Blog About Code</title><category>Aptana Studio</category><category>Dive Into Python</category><category>Eclipse</category><category>Learn Python the Hard Way</category><category>Programming</category><category>Project Euler</category><category>Python</category><category>Syntax Highlighter</category><dc:creator>Andrew Tubman</dc:creator><pubDate>Mon, 30 Apr 2012 13:28:48 +0000</pubDate><link>http://andrewtubman.com/home/2012/4/30/lets-blog-about-code.html</link><guid isPermaLink="false">280107:2837536:16063687</guid><description><![CDATA[<h3>Learning Python</h3>
<p>During my undergrad I spent a lot of time programming in Java, C and C++. I also played with Scheme and Prolog for a semester or 2. I've decided to branch out and learn Python a lanaguage whos passionate fanbase has lead me to believe it is made from unicorn farts and fairy dust. It seems like a very versitile language with a nice crisp syntax. I'm also looking to learn web development skills which makes Python a nice fit.</p>
<p>Since I have programming experience under my belt I've chosen <a href="http://www.diveintopython.net/">Dive Into Python</a>&nbsp;as my primary resource. I'm about 50 pages in and so far seems like the right book for me. It has a good pace and assumes readers have prior programming experience. I also looked into&nbsp;<a href="http://learnpythonthehardway.org/">Learn Python the Hard Way</a>&nbsp;which looks like a fantastic way for a beginer to get into programming and learn Python. Both these resources are free to view online.</p>
<p>The IDE I've gone with is&nbsp;<a href="http://www.aptana.com/">Aptana Studio</a>&nbsp;which is based off of Eclipse my favourite Java programming enviroment. It's geared towards web development and has the PyDev python plugin for eclipse built in. Worth checking out.</p>
<p>I'll be completing <a href="http://projecteuler.net">Project Euler</a>&nbsp;problems using Python and posting my solutions here as I go. Not aiming for the 100% most efficient solutions just trying to learn the Python syntax and its in and outs.</p>
<p>Lastly I've finally gotten around to adding <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a>&nbsp;to this blog so I can post nicely formated code snippits. Example with a little prime number generator I wrote earlier today below.</p>
<p><script type="syntaxhighlighter" class="brush: py"><![CDATA[
def genPrimes(max):
    """generates primes from 2 to max 
       using a sieve of eratosthenes
    """
    x = range(2,max+1)
    primes = []
    while len(x)>0:
        primes.append(x[0])
        x=removeMultiples(x,x[0])
    return primes
    
def removeMultiples(lis,x):
    for i in lis:
        if i%x==0:
            lis.remove(i)
    return lis  
print genPrimes(120)
]]></script></p>]]></description><wfw:commentRss>http://andrewtubman.com/home/rss-comments-entry-16063687.xml</wfw:commentRss></item></channel></rss>