26
Multiprocessing with Python
Filed Under (Development, Parallel / Distributed) by on 26-03-2009
Tagged Under : Python
Available here
26
Available here
25
Problem #1 in the Project Euler series is:
Add all the natural numbers below one thousand that are multiples of 3 or 5.
A few of the more interesting/elegant solutions I’ve seen are listed below.
C#
1 2 | List<int> Numbers = (Enumerable.Range(0, upperLimit)).ToList(); int Result = (from n in Numbers where n % 3 == 0 || n % 5 == 0 select n).Sum(); |
F#
1 2 3 4 5 6 7 8 9 | #light let rec sum_mul xs = match xs with | [] -> 0 | y::ys when y % 3 = 0 || y % 5 = 0 -> y + sum_mul ys | y::ys -> sum_mul ys let sum = sum_mul [1 .. 999] print_any sum |
Ruby (from csLife)
1 | puts (1...1000).select { |n| n % 3 == 0 or n % 5 == 0 }.inject { |sum, n| sum + n } |
Haskell
1 | sum [n | n <- [1..1000-1], n 'mod' 5 == 0 || n 'mod' 3 == 0] |
Erlang
1 2 3 4 5 | -module(euler_1). -export([start/0,solve_euler_1/1]). start() -> io:format("~w~n",[solve_euler_1(1000)]). solve_euler_1(N) -> lists:sum([X || X <- lists:seq(1,N-1), (X rem 3 == 0) or (X rem 5 == 0)]). |
23
I was recently reminded of Project Euler.Taken from the web site:
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.
I’m going to start a new goal in order to brush up my own skills and perhaps develop some unique insights. As with all of my goals, I’m going to be shooting high so that even if I fall a bit short I’ll have completed something worthwhile. What’s the new goal?
Should be fun and challenging. And, in all honesty, it’s really the best way for me to get a solid grasp of the functional languages
09
Has anyone noticed how impatient everyone is these days? I would describe it as ridiculous.
Just as an example, this morning I had some one write a blog post. At the moment of publishing, they assumed that this post should propagate itself across the internet through all feeds and caching. Did it appear in 5 seconds? No. Did it appear in less than a minute? Yes.
How about a little patience in the digital age?