Archive for the ‘Insights’ Category

Eight Queens

Saturday, January 14th, 2006

There are ninety-two ways to place eight queens on a standard chess board such that no queen can take any other queen, but what are they? This is the question that I have spent the last three days pondering. I surely could have ran to google crying, but what fun is in that? Being the weirdo that I am, I took it upon myself to think up a fairly good algorithm and then put it to code. If you value your sanity, you should skip reading the rest of this post…

The algorithm I decided to use is a simple breadth-first search algorithm. It begins in the first column of the chessboard, by placing a queen in the first available row. In each subsequent column, a queen is placed in the first available row. When a column that doesn’t have any ‘available’ spaces is encountered, the queen in the previous column is moved to the next available row. When a queen is successfuly placed in the eigth column, the column is cleared and the queen in the (n-1)th column is moved to the next available row. When the first column is reached, and a queen cannot be placed (because there are no rows left to test), all of the solutions have been found. The bit of PHP I threw together to do this for me can successfuly find all ninety-two solutions to the eight queens problem in .27 seconds. It took me five periods to find the first one by hand…

And now for that anecdote I said I might include. Josephus and forty other jewish people were trapped in a cave surrounded by romans. Rather than give themselves up to the romans, all but Josephus and one other man resolved to committ suicide. Josephus proposed that this be done in an orderly fashion: they were to stand in a circle and kill every third person. The remaining person would then committ suicide. Josephus lived to tell the story…

710 :(

Wednesday, November 30th, 2005

I know. I’m pathetic. I should stop expecting perfection, but…

National: 94
The national percentile for your math score indicates that you did better than 94% of the national group of college-bound seniors.

State: 97
The state percentile for your math score indicates that you did better than 97% of college-bound seniors in your state.


Number Right:
50, Number Wrong: 4, Number Omitted: 0, Total Number of Questions: 54, Raw Score: 50

Like… Umm… STUPID BELLCURVE! Can’t I get bonus points of having a fairly good understanding of the statistical process that makes that score???

x is an element of: {3x}U{4x}\{6x}

Wednesday, November 9th, 2005

In case anyone was wondering, the 79th natural number that is divisible by 3 or 4 but not 6 is 236. Don’t ask me why, but it clearly isn’t an accident that (3)(79) = 237…

Another DD rant…

Wednesday, September 21st, 2005

Johnny walks in to a Dunkin Donuts and orders a ’small coffee’. What does he get? Well, that all depends on what the date is. Is it late spring, summer, or early fall, or are we into the cold months? Depeding on the time of year, johnny will get either a hot coffee or an iced coffee, without explicitly specifying either. Again without explicitly specifying his preferences, Johnny will get sugar and cream in his coffee. He neither ordered ice, nor cream, nor sugar, but he ended up with all three. Poor Johnny. All he wanted was a ‘Small coffee no cream; no sugar; no ice’. How was he supposed to know that he had to take all of those away? The moral of the story is that when in a Dunkin Donuts store, you should describe your coffee with as many words as possible.

In Google Search query language, johnny’s order might look something like:

small coffee -cream -sugar -ice

Even more fun than the query form of the order is the mathematical equation form:


small coffee = ground_coffee + hot + water + 2*cold + cream + sugar

cold = -hot

small_coffee = ground_coffee + cold + water + cream + sugar
Johnny_wants = ground_coffee + hot + water
Johnny_wants = small_coffee + 2*hot - cream - sugar

Looking at the equation form clearly demonstrates that Johnny must order postivie hot, negative cream, and negative sugar.

The whole point of the story is that I disagree with the way that evil corporation does things. When I walk into a Dunkin Donut store and order a ‘Small Coffee’, I am looking for a small amount of (crushed coffee beans+hot water). Even iced coffee starts hott. Icing the coffee is an extra step that should not be implied…

Hello, I’ll have a small Coffee plus heat, minus the quantity cream plus sugar.

Google Knows Algebra

Saturday, September 10th, 2005

I just switched to dvorak. Thank god this post is prefabricated…

Google first started dishing out more megabytes to Gmail users in April this year. Each time I have logged into one of my Gmail accounts, I have seen the wonderful storage counter they have on the Gmail homepage. I always figured it would be nice to know how much space they’re dishing out and over what time period, but it was never very high on my to do list. I just happened to have an essay due on Wednesday, and Gmail turned out to be the perfect catalyst for procrastination. Procrastination always gets the best of me. How can a report for English be more important than random mathematical endeavors anyway? Whilst I should have been weaving a story of world conquest, I was busy pouring through the Javascript that makes that hott counter run. The first code of note I came across was a definition of the a multidimensional array:


var CP = [
[ 1122879600000, 2450 ],
[ 1125558000000, 2550 ],
[ 1136102400000, 2950 ]
];

Being a *nix user and programmer with nothing better to do, I quickly realized that the three large numbers were dates written as the number of milliseconds after the Unix epoch. (1st January, 1970). It then follows that the second number in each sub array is the number of megabytes of storage Gmail users will have by the corresponding dates. Content with my time findings for the time being, I proceeded to play around with these numbers. This is where the linear algebra comes in. To find the rate of change between any two ‘installments’ of storage, one must compute the value ‘rise over run’, or similarly, ‘change in Megabytes over Change in time’.

Before continuing it is important to note that the first date is July 1st, 2005, the second is August 1st, 2005, and the third is January 1st 2006. We are currently in between the second and third installments. The rate of expansion between the second and third installments is given as:

Rate = (1136102400000-1125558000000)/(2950-2550) = (1 MB)/(26361000 ms)

Let t be the time, in seconds, since the Unix Epoch. The space available to Gmail users on any given date is then given as:

S=((t-1125558000000 ms))*((1 MB)/(26361000 ms)) + 2550

To be sure of this result and because I had nothing more exciting to do, I decied to write a PHP script to test the theory, which was of course correct. Writing that in PHP failed to waste a sufficient amount of time, so I decided a C++ version was in store… Let’s not go into that. ( C++ version )

Curious to see how Google approached the problem, I continued reading deeper into the source code. They used an equally effective part over whole method.

S=(t-1125558000000)/(1136102400000)*(2950-2550) + 2550

The real question here is: How much space will I have on October 4th, 2005 at 1533:27 EDT? ( Unix time: 1128454527)

S=(1128454527000-1125558000000 ms)*((1 MB)/(26361000 ms))+ 2550 = 2659.879253...MB

We shall see if I am right. In the meantime, it looks like I have quite a lucrative careerer in the field of insanity.

The leaning ladder. (POW)

Friday, March 4th, 2005

If this affects you, don’t read it. If you do, you can’t say I didn’t tell you not to…

A seven foot ladder rests against a wall and also rests against a cubical box ( length of side 1 foot ) which is sitting at the base of the wall and flush against it. If the ladder touches higher up the wall than it sticks out along the floor, where does teh ladder touch the wall?

When initially looking at that, I see/think:

  • Three similar triangles given such that no sides correspond
  • Three right triangles with missing sides
  • The possibility of solving with inequalities by limiting the range of possible answers
  • The frightening possibility of high degree polynomials ( like 5-6 )
  • An opportunity to befriend coordinates

There being similar triangles, I used them. There being missing sides in right triangles, I used the pythagorean theorem. Let the height of the ladder on the wall be y and let x be the distance of the bottom of the ladder from the base of the wall. Clearly, x2+y2=72, thus y=sqrt{49-x2}. Setting up a proportion between the large triangle ( whole ladder as hypotenuse )and the right most triangle ( height of 1 ) gives: y/x=1/(x-1), therefore y=x/(x-1)>. The range of the possible answers can be greatly narrowed by noting that: the height has to be greater than it would be were the triangle isosceles and: the base must be greater than 1. Taking these inequalities into account, the interssection in this narrowed domain and range is the answer I obtained. This leaves my weekend free to find other, possibly eaiser, possibly more interesting ways to solve this.

I finally made a style changer button thinga. Its in the upper right. now, maybe I should finish starbucks..

nothing….

Thursday, February 10th, 2005

I last posted foreverago. This infrequent posting doesn’t pay off. Me:posting::me homework. I procrasitnate at posting to a journal, that is just pathetic. I am pathetic. If My memory serves me correctly… Ok, it doesn’t. I’ll have to cut out some days in this post.

Last weekend, I worked at that klondike derby thing… enough about that… more about soap operas… no, don’t like them either. I like pi. Pi is good. Apparently, some 8th grader knows more digits of pi than me… that is just not right!!!! I have to go memorize more ( currently at 69 ) as soon as I finish this post. This post had no point…

Factorials, Permutations, Etc.

Friday, January 28th, 2005

Today, I partially rewrote a program which I initially wrote last year. The program, written in c++, deals with combinations for a combination lock. It has several different modes available, allowing one to make one number constant, or display only combinations containing a given number, or numbers. Naturally, I had to check the programs work, so, for the hell of it, I will post that here. ( yeah, I know, I am weird. )

mode 1: list all possible combinations.
. No digits are allowed to repeat, so this is simply (50)(49)(48), or 50!/47!

Mode 2: list all possibilities where the xth number is constant.
This one is a little bit harder, but still, not all that hard. It is given as: (50)(49), or 50!/48!.

Mode 3: list all combinations containing x
This one is a little bit harder. 3!(50)(49)(1)/2!. The three factorial comes from the fact that the three numbers can be permuted three ways. The 2! there is because we are dealing with combinations. (all digits unique)

That was really poorly written… I’ll post something less educational tomorrow…

The quadratic Formula…

Monday, December 13th, 2004

On friday, I had a quiz in one of my math classes. For the sake of annoying the teacher, I used an alternate form of the quadratic formula, given by: x=(2*c)/(-b +- sqrt{b^2 - 4*a*c}). Apparently, the teacher did not know that form ( she does now! ). She never even bothered to look through the work and see that it gave the correct answer… She gave me half credit on 3 questions and accused me of using the sovlve function on my calculator… I didn’t expect to fail the quiz due to my little scheme… but I did. Needless to say, that is being sorted out as she toils through the process of proving that the form of the quadratic formula I used is inded valid. According to mathworld, this form is better than the normal form because in certain cases where b^2 >> 4ac, the standard form can yield an incorrect result for one of the roots.

Enter the matrix!

Saturday, November 20th, 2004

Last year, my history teacher was “way to the right”, and he taught as such. Now, this year, my history teacher is “way to the left”, and he teaches as such. He can’t go five minutes without belittling bush, or bringing up Iraq. He even brought up the nuclear thing once. Is it too much to ask to just be taught without having views forced upon you? Being in that class gives me a headache; I just can’t stand to listen to all the hollow arguments, and feeble attempts at converting us all, though perhaps they aren’t so feeble. He probably has most of the class going! ugh!

So, we did matricies in school this week! More interestingly, we went over hill block ciphers. Penis gave me the idea to write a program to do them… So, I did. I made a matrix class in php, it is about 200 lines, including classes multiplication, addition and subtraction which extend matrix. ( I haven’t gotten around to inverse :( ). The arithmetic functions all work very well, but something seems to be going wrong in the cipher algorithm. Whenever I give it an enciphered string and the inverse matrix, it doesn’t completely decode it…. But I will get to that. It probably has something to do with how I am using the php chr() and ord() functions ( they deal with ASCII characters ).

Once again, a POW in geometry. They have all been pretty easy so far, and it is rather annoying me. Mr. Horne seemed kind of disappointed and shocked when I asked him if my answer was correct, before leaving school on friday. What, does he expect me to spend my whole week on it??? Is that why they call them Problems of the week? I always seem to mock that , and turn them into problems of the day! We should have one everyday, that would mean less time doing nothing.