A Pythagorean triplet is a set of three natural numbers, a
b
c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
Link to Problem 9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | def f(x): # Given: a²+b²=c² and a+b+c=1000 # then: c=1000-a-b :. # a²+b²=(1000-a-b)² :. # a²+b²=1000000-1000a-1000b-1000a-a²+ab-1000b+ab+b² :. # 0=1000000-2000a-2000b+2ab :. # a=(1000000-2000b)/(2000-2b) return (1000000.0-2000.0*x)/(2000.0-2.0*x) a=0 b=1.1 while b != int(b): a+=1 b=f(a) c=(a**2+b**2)**.5 print a*b*c |
This JavaScript game will display a block of numbers for a few seconds. Then you have to try and remember the order the numbers were in. Play this every day for a few weeks and you will really feel yourself improving. I hope to program several more games like this and wrap them together, but we’ll see if that happens. The code for this is entirely in JavaScript, so take a look at the source code.
This program is a complete abuse of HTML, CSS and JavaScript. Put bluntly, it is a bad idea and a disgrace to all programmers that I even tried to code it. That said it’s really cool. Explore
This demonstrates three simple particle effects using JavaScript and a canvas element. The green particles follow an attractor style pattern when the particle accelerates towards the point of interest, in this case the mouse. The blue particles are radiant. They start from the point of the interest and moves outward and a random speed and direction. The red particles are a sort of spark pattern. It starts out like blue, moving in a random speed and direction but has gravity applied so that it seems to fall.
This is a game I used to play a lot when I was younger. Try to guess a hidden pattern of colors. After each guess you will receive feedback tell you how many colors are correct and how many are in the right spot. The interface is pretty simple and it’s kind of fun. This program is also special to me because it was one of my first JavaScript projects. I have cleaned up the code over the years as I’ve learned more about JavaScript.