Monday, December 13, 2010

Rules:

    Never believe a friend who says the microphone that he left at your house last year won’t work without special software.
   A fair warning, I intend to bombard you with videos and italics today. So to start it out, I’ll engage in some narcissism. On a side note, is the act of having a blog and talking to a non-existent audience as narcissistic as it gets?

Probably.                                                                         [get to the code, bro]


   Anyhow, here's me playing with the new microphone:


(note: this will sound shitty on laptop speaks)

   SUCHH a better sound quality. This is good, because I’ve been looking for a way to showcase some of my favorite drum rudiments (wink).


   Speaking of narcissism, is it just me or is the current political atmosphere kind of like a Broadway musical? As Americans, we are led to believe that we inherently have a right to behave like momma grislys, defending our children from the evils of obamocracy, etc, etc… And though the previous two sentences have little technical substance, I will proceed with my case and point:


   Consider these two videos for a moment, which in my mind sum up our farcical world: who is making sense here? On one hand, we have “The Punk Patriot,” solving the economy for us. Now, is this man actually a cobbler? We will never know… Personally, I will continue to believe that he spends his days sweating in a boot factory, thinking about the global (or geo-, if you will) political atmosphere. Perhaps, while making a repair to the sole of an unsatisfactory moccasin he will look up to address his cobbler colleagues: “guy’s,” he will say “men,” correcting himself, “don’t you understand that our labor is what makes this company? We’re paid precisely peanuts and we are the working class! We must demand higher wages, benefits for the poor and so on…” To which no one responds, silently working, hammering on their own soles, thinking “no, The Punk Patriot, your but a man with his head in the clouds.”
   But in a moment of sincerity, and despite his supposed profession, his desperate need for aesthetic categorization, could ThePunkPatriot be on to something? Would Diogenes
be using Youtube to make fun of Plato and his empty cup? John Boner (apparently pronounced bay-ner. anyone? Anyone?) on the other hand… Well, let’s just say that he’s no Punk Patriot. But seriously? This is the man replacing Nanci Pelosi, becoming Speaker of the FUCKING House. What, did you trip acid and watch too many episodes of Glenn Beck? And that’s another thing, what’s up with all of these cry-baby conservatives? The GOP used to be about being a real man, not these sissy boys. More like the Gay-OP (if you’re offended stop reading now).
   And this is what I mean by Broadway Musical. It’s all kind of stupid, yet there are millions of followers. Every once and while you forget why you hate it so much, thinking “What the hell, I’ll take another look. There’s got to be something I missed.” But there isn’t. There never is…


___


   After solving seven problems on PE, I’ve decided to take a break. The next problem seems relatively easy to solve:
  
            { Find the greatest product of five consecutive digits in the 1000-digit number:  [stupid long number] }


  I’ll get around to it eventually. But, under the guidance of problem seven’s pdf reference file, I now have a pretty good prime number generator. Here’s what I used to solve the problem:


@primefile = File.new('Prime Numbers', 'w')
def prime_of?(n)
     primes = [2]
     is_prime = true
     number = 1
     while primes[n] == nil
           number += 1
           is_prime = true
           primes.each do |e|
                if number % e == 0
                     is_prime = false
                end            
           end
          
           if is_prime == true
                primes.push(number)
                @primefile.puts number
           end
               
     end
     return primes[-2]
end   

   I know, totally ridicules right? I don’t even know how long it took, I just typed prime_of?(10001)  and took a shower. Which brings me to the second rule of the day, the big problem here is that I totally forgot about the square root of n. This should be a lesson to everybody, if you are ever confronted by cameramen in a rendition of some skit resembling that of JAY-WALKING, always remember that a number (n) can only have one prime factor greater than the square root of n (itself, duh!). By the way, @primefile exists because I wanted to have a file with a large quantity of prime numbers in it… just in case.
   But that’s beside the point. Here’s my new prime generator, and yes I know that Ruby has a prime generator that is blahblahblah, I don’t care:
#Generate some primes
def is_prime?(n)
certainly_prime = [2,3,5,7]
     return false if n == 1
     certainly_prime.each {|e| return true if n == e}
     return false if n % 2 == 0
     if n % 3 == 0
           return false
     else
           floor = Math.sqrt(n)
           f = 5
           while f <= floor
                return false if n % f == 0
                return false if n % (f + 2) == 0
                f = (f + 6)
           end
           return true
     end
end
def generate_prime(limit)
     position, number = 1, 1
     primes = []
     while position != limit
           number += 2
           if is_prime?(number)
                position += 1
     end
     return number
end

   It’s decently fast. I got the 100,000’th prime fairly quick (1,299,709). Prime number one million will remain unknown to me, as it took too long… and I am a very busy man.

2 comments:

The Punk Patriot said...

I am in fact actually a cobbler.

David said...

Awesome, what kind of boots do you make? I need a new pair.