Um... How does that work?

Does it bother anyone else that some lawmakers don't know the law?  To me, it would make sense if the people who make laws (legislative branch of government) were people who actually have knowledge about the law (judicial branch of government).  If you somehow manage to pass a law that violates the constitution and the judicial system overturns the law citing them unconstitutional, you should be fired.  You're a moron that doesn't know what he/she is talking about.  You're clearly not qualified for the job.

Posted on 3/8/2008 10:13:00 PM by JSimpleton

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Post Secrets

I recently returned from a PostSecret event.  It was not as I had expected.  I expected a gallery showing of some of the most fascinating secrets sent in to Frank Warren.  Instead, what I actually saw was a lecture from Frank Warren himself about how and why he started PostSecret.  I was not entertained by the lecture, but what I did find out was that Warren did not intend to take PostSecret as far as it has gone.  He started with an idea for an art project (and is somewhat obssessed with secrets if you ask me) and the project took on a life of its own.  It was a good idea.  I'm still undecided on how to view him.  Would it be appropriate if I label him an "artist" despite the fact that he didn't design the cards or wrote most of the secrest himself?  Regardless, I believed he had a good idea and the courage to follow though with a plan, crazy as it might seem.

 

you can check his creation at postsecret.com

Posted on 2/26/2008 1:53:00 PM by JSimpleton

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Euler Problem 52

The problem is to find the smallest number n such that n, 2n, 3n, 4n, 5n, and 6n all contain the same digits. For those who know the 1/7 rule, that's wise of you. For the rest of us, brute force comes to rescue. Python can do it in a few lines:

 

n = 1
while not all( set(str(i*n))==set(str(n)) for i in [2,3,4,5,6] ):
      n+= 1	
print n

 The funny thing is if I change the all function slightly to:

     all( [ set(str(i*n))==set(str(n)) for i in [2,3,4,5,6] ] )

 the runtime increases by 4 times to 5 seconds. I am guessing all() is smart enough to employ short-circuit, but don't take my words for it.

Live and learn.

 

Posted on 2/23/2008 7:38:00 PM by Haoest

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Project Euler | Python

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Framed Humor

some funny stuff:

Posted on 2/19/2008 6:02:00 PM by Haoest

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: funny

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Project Euler Problem 50

This is by far one of the least elegant solutions to Problem 50 as posted on the Solutions Forum. It ran for about 400ms including Prime Sieve and Sift-Test, which is not too bad. The recursion is probably not necessary, but it works.

The problem asks:

Which prime, below one-million, can be written as the sum of the most consecutive primes?

The primeset collection is created for fast look up. Another way to do that is to have a Binary Search function. This is the solution in Python:

 

# find the longest prime chain
def genprime(n):  # adopted from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366178
    if n==2: return [2]
    elif n<2: return []
    s=range(3,n+1,2)
    mroot = n ** 0.5
    half=(n+1)/2-1
    i=0
    m=3
    while m <= mroot:
        if s[i]:
            j=(m*m-3)/2
            s[j]=0
            while j<half:
                s[j]=0
                j+=m
        i=i+1
        m=2*i+3
    return [2]+[x for x in s if x]
    
import time
ts = time.clock()
primes = genprime(10**6)
primeset = set(primes)
initsum = 0
for i in xrange(len(primes)):
    if initsum > 10**6:
        initsum -= primes[i-1]
        primes = primes[:i-1]
        break
    else:
        initsum+= primes[i]
    
def recursiveCount(cursum, curlen, ub):
    if cursum <= 2:    return 1
    global primeset, primes
    cur, lb, hasPrimeSum, oldub = cursum, 0, 0, ub
    for i in xrange(curlen):
        hasPrimeSum = cur in primeset
        if hasPrimeSum:
            break
        elif ub<len(primes)-1:
            cur += (-primes[lb] + primes[ub+1])
            lb, ub = lb+1, ub+1
    if hasPrimeSum:
        return cur
    else:
        return recursiveCount(cursum-primes[oldub], curlen+1, oldub-1)
        
print recursiveCount(initsum, 1, len(primes)-1), " took %s seconds" % (time.clock() - ts) 

 

 

Posted on 2/19/2008 5:55:00 PM by Haoest

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories: Project Euler | Python

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Python is killer

In the era of software development where programmers don't really program anymore, there are still hang out spots on the web where you can pick up your old memories. I've been spending time solving riddles on ProjectEuler.net. It's been rediculously addictive. I am also taking this opportunity to learn Python, which is a modern dynamic language. Just to demostrate how slick it is, here's the code that reads in a list of words from a text file and counts the number of triangular words in it (Problem 42) :

 f = open("p42.txt").read().split(",")
words = [str.upper(str.strip( w.replace('"', ''))) for w in f]
val = [ sum( [ord(c)-64 for c in w]) for w in words]
trinums = [ (.5*n**2+.5*n) for n in xrange(1, max(val))]
print len( [ n for n in val if n in trinums])

 And this is the code that counts the product of the 10th, 100th, 1,000th, 10,000th, 100,000th, and 1,000,000th digits of an irrational decimal fraction (Problem 40.) Guess how long it is:

res = "".join([str(i) for i in xrange(10**6+1)])
print reduce(lambda x,y: x*y, [ int(res[10**i]) for i in xrange(1, 7)]) 

 Just looking at it gives me a boner.

 

 

 

Posted on 2/5/2008 7:45:00 PM by Haoest

Permalink | Comments (1) | Post RSSRSS comment feed |

Categories: Project Euler | Python

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

R3VOLUTION

Howdy,

Super Bowl is up next week. Yay. As it's one of the biggest events of the year, many of us are anticipating. Why not? More excitingly, Britney Spears is going mentally crazy, and her 16-year-old sister ran away from home to get married. Dramatic stuff. Sports, news, and the Internet are definitely entertaining. MySpace, Facebook and YouTube, don't we spend countless hours surfing?

I just want to bluff about how much fun it is to live. That's all.

Oh, before I go, i might as well bring up something that's way down the priority list: the primary election is coming up a few weeks ahead for many of our towns. I kind of want to suggest everyone to vote, but considering how busy we can be on the Internet or TV, I probably shouldn't.

Just in case your Internet is down, and TV is broadcasting your least favorite replays of Dr. Phil or Jerry Springer, you may want to swing by the voting booth. If you know who you like, great. If not, I have an idea: let's trade votes.

I happen to come to identify with this guy with two first-names: Ron Paul. If you can cast a vote for him this election, the next election in which I don't have a favorite candidate, tell me and I will vote him/her for you. Sounds good?

Alright, time for me to go back to World of Warcraft, m party is waiting. Peace.

 

Posted on 2/3/2008 8:04:00 AM by Haoest

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Politics

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Linkity links

Went on Reddit and I happen to findd some links to Ron Paul's Ad.  There's not very much mud-slinging, which is novel right now.  I disagree with him on many, many issues, but Hao seems to like him and so I present him with this link:

http://www.youtube.com/watch?v=uiSQ6_16O2s&NR=1

http://youtube.com/user/RonPaul2008dotcom

enjoy and may your politician not be ostracized more than he already is.

Posted on 1/29/2008 9:37:00 PM by JSimpleton

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories:

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Ron Paul

It is sad to see intelligent men like Ron Paul doing so bad in the polls, and courageous politicans like Denis Kucinich dropping out of the race. Before this topic gets too serious, check this out, Mr. McCain and Miss America Parody.

 

Posted on 1/26/2008 12:57:00 PM by Haoest

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: Politics

Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Definitely not your last stop

While the blog is fresh off the oven, I want to explain that this is where I whine, discuss intellectual online activities, and share my learning experience in web technologies, ETC. Mostly whining.

 To start the day...

 

Posted on 1/26/2008 12:12:00 PM by Haoest

Permalink | Comments (0) | Post RSSRSS comment feed |

Categories: funny

Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5