web analytics

Something to chew on for the weekend…

Okay, this is kind of neat. Project Euler is a website that hosts series of individual, discrete math problems (currently 344 of them) that each require a short computer program to solve. Individual problems builds on concepts in previous ones, so the idea is that you quietly learn both math and programming as you go along.

To be honest, if I had run across this on my own, I’d’ve been all “yuck, math! Ew gross, programming!” but I read this article in the Atlantic that made it sound like a lot of fun and…it kind of is. I’ve done five and I enjoy it — when I have a CLUE where to start.

I cheated on Problem 3. I was looking for methods and accidentally found the actual answer, but I was floundering anyhow. I still don’t understand why my answer wasn’t right. But, hey, turns out I independently invented the Sieve of Eratosthenes trying to figure it out, so I worked out something a chiton-wearing olive-slurping boo-boo knew two thousand years ago. Yay me, I guess.

Hard to believe my grandma was an algebra teacher.

Good weekend, everyone!


Comment from Uncle Badger
Time: July 29, 2011, 10:14 pm

Weasel maths: one runny babbit, two runny babbits….er, yay! lots of runny babbits!

Humiliatingly, I am no better. Come out to dinner with us and offer to do the maths on splitting the bill. You could skin us alive and we’d be none the wiser!

Cunning but wholly innumerate.

Comment from Mark Matis
Time: July 29, 2011, 10:16 pm

Let me assure you that MOST products of the US public education system not only wouldn’t be able to work something like that out, they wouldn’t even have a clue as to what a prime number was!

Comment from S. Weasel
Time: July 29, 2011, 10:32 pm

To be honest, Mark, I’ve always had problems with primes. I know it’s a simple concept, but I can only hold it in my head with fairly small numbers. I was floundering on that question.

I find math attractive. I’ve tried several times as an adult to catch up with the bits I missed as a kid (I managed to avoid a lot of High School math with creative transcripting). But I really am missing something important in the brainal department.

Comment from S. Weasel
Time: July 29, 2011, 10:35 pm

I did better on geometry and trigonometry — things that are visual. The Sieve of Eratosthenes is basically a graph, isn’t it? I worked it out by drawing a picture.

But a classic word problem can make me cry with frustration.

Comment from Armybrat
Time: July 30, 2011, 12:57 am

I love and understand biology, hence, I entered a medical field. My baby sister actually liked math. She speaks your language. I pay people to do math for me.

Comment from grasshopper
Time: July 30, 2011, 1:17 am

Any problem with the word “Find” in it made my math book magically grow wings and FLY across the room, especially with Algebra. If *you* lose the solution that completely, why should *I* have to “find” it?

Comment from JuliaM
Time: July 30, 2011, 5:49 am


*runs away screaming*

Comment from Rich Rostrom
Time: July 30, 2011, 8:43 am

I see you’re doing the problems in perl… (if the illo is a screen cap of your work).

Me too, that being the most convenient programming bench available to me.

I’ve done 1 through 3 so far…

#1 doesn’t require a program though.

n(n+1)/2 is the sum of the numbers 1…n. Call it F(n).

The answer to #1 is

F(int(999/3))*3 + F(int(999/5))*5 – F(int(999/15))*15

Comment from S. Weasel
Time: July 30, 2011, 10:37 am

Yep, it’s perl. The most word-y and least math-y of the languages. I always thought it would be right up my alley, but I never got proficient.

I used to joke that I’d programmed “hello, world!” in fifty languages — mostly proprietary scripting languages associated with graphics programs. I started in C, which is way too strict for my sloppy ass. But I struggled horribly with programming and only ever did the minimum necessary to get my Flash thingy or Director doo-dah in the can.

And the snippet in the graphic is #1, which I most certainly do need a program for, even in you nice, neat formulation.

Comment from Uncle Badger
Time: July 30, 2011, 11:58 am

Weasel, is this your revenge for us discussing gardening the other day?

Pingback from Around the Moronosphere 7/29/2011 « doubleplusundead
Time: July 30, 2011, 1:39 pm

[…] Sweasel – Project Euler, torturing the math impaired since 2001 […]

Comment from Pupster
Time: July 30, 2011, 2:16 pm

These are kinda cool:


Not maths related.

Comment from Stateler & Waldorf
Time: July 30, 2011, 2:25 pm

Least “mathy” language has to be Ruby. I found this a few years back and it changed my thinking.

There are so many ways to solve all these “Eulerian” issues in Excel that I was not able to focus on learning Ruby at first because I kept seeing ready formulas…

very well worth a click, and no, I am not Pine.

Comment from bad cat robot
Time: July 31, 2011, 3:08 am

Ruby is indeed less “mathy”. It also has a charming, childlike faith that the Programmer Knows Best and won’t try to do things to an integer that are only allowed for a string, and vice versa. As an added bonus, you won’t know you committed indecencies with a variable until you run the whole damn program because it doesn’t use a compiler. Can you tell I’m forced to write a LOT of Ruby? (Deep computer-geek sigh)

I blame the math situation on piss-poor teaching methods. I thought math was one long death march of timed drills and flashcards until some friends persuaded me to join them in the advanced geometry class. There, to my astonishment, I discovered it was fun and got progressively into the harder stuff until one day I woke up in the gutter clutching a math minor. BTW O Stoaty, Physics is one long word problem. It’s why I twitch. Well, that and grabbing the live wire a few too many times.

Comment from Oceania
Time: July 31, 2011, 8:07 am

Look People.

Get yourself Matlab … one of the cracked newer versions … write your own Mfiles – or download them, and modify them … to your needs.

Comment from Statler & Waldorf, LLP
Time: July 31, 2011, 2:15 pm


Comment from S. Weasel
Time: July 31, 2011, 4:27 pm

That’s awesome, S&W! Is it a homebrew? Did you do the label?

Comment from Statler & Waldorf, LLP
Time: July 31, 2011, 7:01 pm

Your Stoatliness,

I’ll be the last to shy away from claiming credit whether earned or not.
My contribution on this occasion is limited to driving to the local Trader Joe’s (traitor jose) at Penn Ave and 25th street. I usually buy their store brand dark beer in 32 oz size (less than $2) but as soon as I saw the six pack I knew where this illo would end. Believe paid $6 and change for 6×12 oz.

The beer tastes like Guinness would if it came out of a dry packet that you’d mix with water to obtain instant beer. A strong yet not overwhelming tinge of graphite, with full head of C-4685 hops alkaloid and fake burlee.

I am eventually going to invest in a beer making kit but my true love is 80 proof and higher. I try not to drink because it’s a downer and that moneys would be best spents elsewheres but as I paint the condo I drinks.

Keep on rockin in a Brit world.

Since this blog is so full of wildlife that one half expects Sir David Attenborough to start telling us about prehensile penises of howler monkeys and mating habits of free-range foxes, I respectfully include this anthem of British territory.

Comment from James the lesser
Time: August 1, 2011, 4:21 am

badcatrobot, in what branch of physics do they make you program in ruby?

Comment from Oceania
Time: August 1, 2011, 6:07 am

Who has been feeding those rabbits Ectasy?

Comment from bad cat robot
Time: August 1, 2011, 3:14 pm

James the <: I had to leave physics research some time ago (no jobs …) so I now haunt the software development world. In physics I used QuickBasic! (lots of the experimental electronics had QuickBasic support for data acquisition) Ah, the old days…

Comment from Ric Locke
Time: August 1, 2011, 10:23 pm

Physical scientists think they’re mathematicians, mathematicians think they’re programmers, and programmers think they’re engineers. The minority who are correct change professions…

The reason the climate scientists won’t release their modeling code is that they know the simultaneous cries of “WTF?” from the SlashDot crowd would be audible world-wide.


Comment from Rich Rostrom
Time: August 2, 2011, 12:42 am

Ric Locke: The reason the climate scientists won’t release their modeling code is that they know the simultaneous cries of “WTF?” from the SlashDot crowd would be audible world-wide.

Eric S. Raymond, a major guru of the Open Source/Free Software movement, has commented at length (and scathingly) on this very subject (especially after the CRU revelations in 2009).

See Open-Sourcing the Global Warming Debate.

Also “Hiding the Decline: Prologue”, “Hiding the Decline: Part 1 – The Adventure Begins”, “Facts to fit the theory, and “Hiding the facts in plain sight”.

Comment from Statler & Waldorf, LLP
Time: August 2, 2011, 6:17 pm

The hilarious part is that global warmenists claim that the weather data are proprietary or something. That’s why, you unwashed commoner with no credentials cannot see them, but it’s for your own good.

Only a fool would deny a rapid climate change. Why, a paltry 5 months ago we were wading up to our kneecaps in snow. Now, snow here and on the barren slopes of Kilimanjaro is gone. With an average memory span of the voter not exceeding a half of soccer season the climate defenders are in no danger of running out of sweet, sweet government milk.

Climate change is absolutely man made. Data is man-manufactured, why would not the conclusions? and every wretched owner of assets can and should be taxed to be taught a lesson.

Comment from David Gillies
Time: August 2, 2011, 8:48 pm

I got myself an Arduino UNO. It’s based on a an 8-bit Atmel AVR ATmega328P microcontroller and it hooks up to a programming interface on Mac, Windows or Linux. It is so much fun I can’t describe it. Blinky lights, stepper motors, servos, xBee transmitters, Ethernet – you name it. Here’s a demo I made of it talking to a remote control. The language is basically C++ with bells on. If you wanted a toy for a technically-minded teenager, it would be ideal. They should hand them out like Smarties in schools since they’re only about $25 a pop.

Comment from Statler & Waldorf, LLP
Time: August 2, 2011, 9:01 pm

The lucky teenage recipient of this monstrosity is assured to remain a celibate virgin until age of 57.

I half expected a Dalek to roll in at any moment.

Comment from S. Weasel
Time: August 2, 2011, 9:29 pm

Wow, David. I think your accent just gave me a paper cut.

Comment from David Gillies
Time: August 2, 2011, 9:31 pm

For problem #1, using Mathematica (which totally is a programming language, so nyah) we get Plus@@Select[Range[999],Mod[#,3==0||Mod[#,5]==0&] for a value of 233168. You can do one-liners in Mathematica more easily than in any other language I know (this program here is a form of functional programming using Mathematica’s pure-function syntax).

S&W: software engineers make good money, and good money gives you an edge in the dating game. And unless you want to spend the rest of your life saying, “would you like fries with that?” while the decent jobs have been outsourced to Bangalore, learning to code is a good idea.

Stoaty: why? What do I sound like?

Comment from Statler & Waldorf, LLP
Time: August 2, 2011, 10:44 pm

You sound like Jacques Francois Kerry, the haughty French looking doofus who by the way served in da ‘Nam.

The type of female attracted to high disposable income is fortunately for you quite abundant. While you pat your back pocket for the wad of 20s, be sure to look up a set of basic phrases and positions.

It is always 99% of coders who give the rest a bad name.

Comment from David Gillies
Time: August 3, 2011, 2:21 am

S&W: that’s rather rude. I sound nothing like John Kerry.

Comment from Statler & Waldorf, LLP
Time: August 3, 2011, 1:18 pm

The quote I was looking for was “You know, education, if you make the most of it, if you study hard and you do your homework, and you make an effort to be smart, uh, you, you can do well. If you don’t, you get stuck in Iraq.”

So, a path to better dating by learning to code. An idea so bizarre that it is truly Kerryesque.

There are plenty of non-coders whose dating life is very good.

Comment from David Gillies
Time: August 3, 2011, 4:23 pm

But it’s also a stereotype that all software engineers are socially inept doofuses who couldn’t get laid inn a brothel. All else being equal, in a world with an increasingly knowledge-based economy, knowing a technical skill is likely to increase your life potential (including the non-monetary things). Kerry was an ass to say that; modern soldiers are among the most tech-savvy people out there. Things like the Euler project and open-source, cheap, fast-feedback things such as Arduino are great for teaching people problem-solving skillsets.

Comment from S. Weasel
Time: August 3, 2011, 5:11 pm


Comment from Can’t hark my cry
Time: August 3, 2011, 5:14 pm

You know, I’ve been wondering why David was letting an improvisational comedy troupe composed of law students bait him. . .

Comment from Statler & Waldorf, LLP
Time: August 3, 2011, 6:27 pm

These are the drones you are looking for, Can’t Hark:


Making fun of IT personnel has been one of our longtime guilty pleasures. It is preposterously easy. It is almost perfect victimless crime.

Looking back on our lives, we would not go to Hahvahd and become senior equity partners in policy/lobbying firm.
We’d go into franchising churches, and invest in plumbing/electrical services. Talk about moneys.
Nowadays, having built a substantial cushion at and below the waistline, we devote more time to sophisticated critique from the heights of the opera booth, tree stand, blog trolling, etc.

Be kind to Stoaty is thine First Commandment. Without her, all structure collapses.

There has to be a better way of fueling this oasis. We’re thinking of it.

Comment from Sporadic Small Arms Fire
Time: August 3, 2011, 6:46 pm

Hey David,

there are indeed numerous ways to impress Jodie Foster.

A line like the set below is almost certainly a low probability approach.

def Hello pretty miss proc1, proc2
Proc.new you smell nice |x|

def I built a self-reciprocating validation loop |object|
toggle self.each is_even = !is_even
puts double_then_square.call(3)

Bangalore, Lakshmistan is beautiful I hear. Especially the cathode lighting of communal cube workspace, it is so romantic.

Comment from Can’t hark my cry
Time: August 3, 2011, 7:48 pm

S&W: Never having been a television watcher, I was not familiar with /The Muppet Show/ (and what I know about it now I just learned from Wikipedia). I searched on the specific name you used, which naturally led to the organization I linked to. Given that the LLP as a form of business entity did not come into use in either the US or the UK until long after /The Muppet Show/ went off the air (and as there is no suggestion in the description of the two characters from that show suggesting they were in a formal business partnership), I don’t quite see how the reference could fairly be read as limited to the Muppet Show characters.

Comment from Statler & Waldorf, LLP
Time: August 3, 2011, 8:19 pm

Can’t Hark My Cry,
We have frequently opined that all sources of entertainment based on electricity are all new-fangled fads and one should not feel left out by choosing to leave this medium to the slothful.
By the same token, Alexander the Great and Julius Caesar did pretty well for themselves without ever firing a single rifle shot or bothering with West Point Military Academy.

If all one did was to google and click on top link, the conclusions could be far from accurate.


Comment from Statler & Waldorf, LLP
Time: August 3, 2011, 8:27 pm

Tree-shade wet-nosed web detectives, beware, not all that appears is the real McMustelid:


Comment from S. Weasel
Time: August 3, 2011, 9:16 pm

Morris dancers, I don’t think. I believe we’ve seen that troupe, or one like it, though. With the sticks and the raggedy coats and the blackface.

Comment from Gerbil Malodor
Time: August 4, 2011, 3:16 pm

No morris dance troupe is complete without bells on their footses. Maybe that’s a way to reduce alcohol intake (mandating the toe bells) without making a dent in morris dance tomfoolerie.


A troupe of Morris Dancers got their marching orders from a pub – because of the bells on their clogs.

The 15-strong Slubbing Billy’s were ordered to leave the Swan and Three Cygnets in Durham, reports The Mirror.

Duggs Carre, 45, a member of the Huddersfield-based outfit, said: “There was no room for argument – we were just kicked out.

“One of our group, in his Morris Dance gear, had just ordered a pint without any problems.

“But two female members came in with the bells on their shoes and a woman member of staff shouted: “No bells!” – and that was it.

“We were told in the strongest possible terms to leave. There were 15 of us all wanting a drink so they lost a fair bit of business. I wouldn’t mind but when you sit down, the bells don’t make any noise.”

Band member Jill Morris said the troupe had performed all over the UK, in Belgium, Holland and France, but never had a problem.

She added: “Apparently bells on our toes mean we will not have music wherever we go.”

The Swan is owned by the Samuel Smith brewery, which has a strict no music policy. A spokesman declined to comment.

Comment from Mark Matis
Time: August 4, 2011, 10:18 pm

Hey, S & W:
I don’t see any of the finest muppets on that page. What do y’all have against Scred, Ploobis, and the Mighty Favog???

Write a comment

(as if I cared)

(yeah. I'm going to write)

(oooo! you have a website?)

Beware: more than one link in a comment is apt to earn you a trip to the spam filter, where you will remain -- cold, frightened and alone -- until I remember to clean the trap. But, hey, without Akismet, we'd be up to our asses in...well, ass porn, mostly.

<< carry me back to ol' virginny