

Challenging Programming Exercises Published Weekly - krat0sprakhar
http://programmingpraxis.com

======
jschulenklopper
Obligatory link to a nice and long-running initiative: Project Euler:
<http://projecteuler.net/>.

"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."

~~~
chii
its interesting that all of these are programming "in the small" problems.

Is there a site that gives you common/difficult programming "in the large"
problems?

~~~
sillysaurus
Here are several "real-world" projects in order of increasing difficulty:
[http://shawnpresser.blogspot.com/2010/10/how-to-become-
game-...](http://shawnpresser.blogspot.com/2010/10/how-to-become-game-
programmer.html)

I've thought about making this into a series.

------
eddington
Complete solution to today's problem in one line of python

def gen(univ, n=5): return univ if n == 1 else [x+y for y in gen(univ,n-1) for
x in univ if all([(x+y)[start:start+upto] != (x+y)[start+upto:start+upto*2]
for start in range(len(x+y)) for upto in range(1,(len(x+y)-start+2)/2)])]

... god that looks ugly. Call it with

>>> gen(["1", "2", "3"], 5) ['13121', '23121', '21321', '31321', '12321',
'12131', '32131', '21231', '31231', '13231', '13212', '23212', '21312',
'12312', '32312', '12132', '32132', '23132', '21232', '31232', '31213',
'13213', '23213', '12313', '32313', '32123', '13123', '23123', '21323',
'31323']

~~~
peteretep
And in some rather nicer Perl:

    
    
        sub solutions {
        	my ( $target_length, $alphabet, $head ) = @_;
        	$head //= '';    
    
        	# Base Case our head is the right length
        	return $head if (length $head) == $target_length;
    
        	# General Case
        	return
        		map  { generate( $target_length, $alphabet, $_ ) }    
        		grep { ! /(.{2})\1/ }
        		map  { $head . $_ }
        		@$alphabet;
        }
    

eg:

    
    
        my @solutions = solutions( 5, [1..3] );

~~~
JasonFruit
That's quite pretty Perl. You've lessened my prejudice against the language by
writing code that can be read.

------
jbranchaud
Great resource, I just added this to my list of programming puzzle resources
-- [http://joshbranchaud.wordpress.com/2011/07/09/my-somewhat-
co...](http://joshbranchaud.wordpress.com/2011/07/09/my-somewhat-
comprehensive-list-of-programming-problems/)

~~~
jcl
You might also want to check out SPOJ, an enormous collection of problems from
programming contests, with an online solution evaluator:

<http://www.spoj.com/problems/classical/>

~~~
jbranchaud
Thanks for the pointer, that is jam packed!

------
new_test
Another similar excellent resource: <http://www.reddit.com/r/dailyprogrammer/>

~~~
jbranchaud
Any idea where so many daily programming problems come from?

~~~
new_test
<http://www.reddit.com/r/dailyprogrammer_ideas>

------
gryphonic
For more math oriented challenges (more project euler like), check out the
monthly IBM 'I ponder this'. These are usually quite challenging, but the
problems are interesting and solutions are posted at the end of the month.
[http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/pages/in...](http://domino.research.ibm.com/Comm/wwwr_ponder.nsf/pages/index.html)

------
sillysaurus
I used Mathematica to give the solution to Wirth's Problem
(<http://programmingpraxis.com/2012/12/07/wirth-problem-15-12/>).

Screenshot: <https://dl.dropbox.com/u/315/math/problems/wirth/wirth.png>

Output:
[https://dl.dropbox.com/u/315/math/problems/wirth/wirth_outpu...](https://dl.dropbox.com/u/315/math/problems/wirth/wirth_output.png)

Notebook: <https://dl.dropbox.com/u/315/math/problems/wirth/wirth.nb>

Mathematica code turns out to be surprisingly readable.

------
VMG
Looks interesting.

Some suggestions:

* The font needs to be larger

* The color scheme could use a little more contrast

* Pasting source code needs to be easier

~~~
Surio
Agree with OP on all three points. Please look into this.

------
bduerst
This is awesome.

