24 Game

game: you are given 4 numbers. combine them all to make 24 using + * - / and ().

examples:

numbers: 3 3 7 8
solution: 3*3+7+8

numbers: 1 5 9 12
solution: (5-1)*9-12

numbers I was given to solve:

2,3,10,10
3,3,7,7

Try them, it's fun.

I wrote a Ruby program to brute force these. Then I wrote a second much more elegant one.

The first program does this:

find all the different ways to put the numbers in order. find all the different ways to put the operations (+,-,*,/) in order (but making sets of only 3 of them). then make all possible pairs of the numbers in an order and the operations in an order, and interleave them. so we get all ways to combine the 4 numbers in any order with operations between them. *then* we can't just evaluate those because order of operations is important. so we try evaluating in all possible orders. (do the first, second, or third operation. that leaves 3 numbers and 2 operations. try both orders).

ugh.

the second program is smarter. i realized that one step towards a solution consists of combining 2 numbers with an operation. if you think about it this way, you don't have to worry about order of operations. so just find all the ways to pick 2 numbers from whatever numbers you have left, then try all 4 operations. make sure to put the numbers in either order, b/c 7-3 and 3-7 are different. if you divide by zero, throw that out. once you do this, you now have 3 numbers. you replaced 2 numbers with one number. ok, great, we made progress. now do it again, and you find yourself with 2 numbers, then one. make sure to stop when you get to one. much better. as it goes, it keeps track of the history so if it finds an answer it can tell you what it did.

UPDATE:

I cleaned up my code enough to show the second search function. but the formatting comes out awful when i paste it here. if you ask i can email it.

Elliot Temple | Permalink | Messages (0)

A Problem With School

One of the problems with schools is that they don't have individual knowledge of each student, so they can't tailor assignments to their specific skills and abilities and knowledge. They also don't give everyone different assignments because of the labor involved.

That's pretty abstract. Here is a specific example. I learned a bit about matrices. Then I wrote a Ruby program that does some of the calculations I'd learned about. A school could not give out this assignment. The students in the math class might not know how to program. And the students in the programming class might not know about matrices. In general, schools can't explore cross-discipline work. Everyone has a major, and if a task doesn't fall entirely within it, it can't be assumed they know how to do all of it.

There is no obvious way to fix this. There isn't some little fact that schools are overlooking. It's just a problem with one-size-fits-all education. It's a shame. And it's a reason to prefer to learn at least some things outside of school.

Elliot Temple | Permalink | Messages (0)

Elliot Temple | Permalink | Messages (0)

Elliot Temple | Permalink | Messages (0)

Jealousy and Violence

http://www.lyricsandsongs.com/song/402609.html

NEXT CONTESTANT lyrics

I judge by what she's wearing
Just how many heads I'm tearing
Off of assholes coming on to her
Each night seems like it's getting worse
And I wish she'd take the night off
So I don't have to fight off
Every asshole coming on to her
It happens every night she works
They'll go and ask the DJ
Find out just what would she say
If they all tried coming on to her
Don't they know it's never going to work
They think they'll get inside her
With every drink they buy her
As they all try coming on to her
This time somebody's getting hurt

Here comes the next contestant

[CHORUS]
Is that your hand on my girlfriend?
Is that your hand?
I wish you'd do it again
I'll watch you leave here limping
I wish you'd do it again
I'll watch you leave here limping
There goes the next contestant

I even fear the ladies
They're cool but twice as crazy
Just as bad for coming on to her
Don't they know it's never going to work
Each time she bats an eyelash
Somebody's grabbing her ass
Everyone is coming on to her
This time somebody's getting hurt

Here comes the next contestant

[CHORUS]

I'm hating what she's wearing
Everybody here keeps staring
Can't wait 'til they get what they deserve
This somebody's getting hurt

Here comes the next contestant

[CHORUS]
I wish you'd do it again
Each night seems like it's getting worse
I wish you'd do it again
This somebody's getting hurt

There goes the next contestant

Elliot Temple | Permalink | Messages (0)

Apple's Thoughts On Music

http://www.apple.com/hotnews/thoughtsonmusic/

This is wonderful. Absolutely wonderful. It is the way of the future. Apple is changing the world with an *essay*. It's very persuasive. It's very public. It came out earlier today, and I independently found out about it in two places already. Neither involved any advertising.

Apple respects its customers and the public enough to present them with ideas and arguments. Not talking points or sound bytes, but genuine, serious explanations. Apple believes people will care. I am optimistic that Apple is right.

One day companies will settle a large proprotion of their disputes this way. They will publish their arguments, and the public will pass judgment. Defy customers at your peril. Our society has already made persuasion an integral part of many of its institutions, but it has plenty of room to grow.

This is lovely. I am happy.

Elliot Temple | Permalink | Messages (0)

Praise

http://nymag.com/news/features/27840/

This article is interesting for many reasons. Here are a few:

- It blames Nathaniel Brandon for the "self esteem is really really important" movement, which hates competition. I met him. Small world. You might think a libertarian would like competition more. Oh well. I didn't know it was his fault.

- In a study, young children act very differently in reaction to *one sentence* of praise. That's an amazing amount of flexibility to be able to change one's self-image so easily.

- Five year old children have daily math and phonics homework expected of them. Ugh!

- Parents say things like, "I can't stop praising my kid so much. He'll feel awful." But what actually happens when the parent tries to stop is that the *parent* feels bad. (Why limit praise? Because most of it was non-specific and said without regard for its truth.)

Elliot Temple | Permalink | Messages (0)

Elliot Temple | Permalink | Messages (0)