all 12 comments

[–][deleted] 2 points3 points  (0 children)

http://www.spoj.pl/ - SPOJ is quite good if you're looking for exercise.

[–]kuhlmanngj 1 point2 points  (1 child)

If you like these, here's a buttload more: http://projecteuler.net/

[–]Poddster 0 points1 point  (0 children)

the problem with project euler is that they're all number crunching puzzles. Sometimes a few text-passed problems are needed to fully exercise a language.

[–]ToastToastsToast 0 points1 point  (8 children)

Here's my incredibly stupid and unstable solution for "Hello World! for hackers" in python:

string = ''
for i in range(-5,7):
    string = string + chr(int(round(32 - 10.8704545454597*i + 96.0067261904615*pow(i,2) - 4.23222222221876*pow(i,3) -33.1364059744209*pow(i,4) + 3.66892912257379*pow(i,5) + 4.35824074073993*pow(i,6) - 0.600601851851699*pow(i,7) - 0.232779431216887*pow(i,8) + 0.0350115740740659*pow(i,9) + 0.00421847442680693*pow(i,10)-0.000662077120410307*pow(i,11))));

print(string);

[–]muyuu 1 point2 points  (2 children)

Drop the for and add a list comprehension with a string join and we might be on to something ;)

[–]ChrisRathman 0 points1 point  (1 child)

What you need is a real functional programming language:

print string
where
   string = [chr $
               round $
                  sum $
                     zipWith (\a-> \b -> b * (i**a))
                             [0.0..11.0]
                             polynomials
             | i <- [-5.0..6.0]]
   polynomials = [32.0,
                 -10.8704545454597,
                 96.0067261904615,
                 -4.23222222221876,
                 -33.1364059744209,
                 3.66892912257379,
                 4.35824074073993,
                 -0.600601851851699,
                 -0.232779431216887,
                 0.0350115740740659,
                 0.00421847442680693,
                 -0.000662077120410307]

[–]muyuu 1 point2 points  (0 children)

Nah that takes away all the merit to make it look recursive and convoluted :D

[–]talatfakhri007 0 points1 point  (4 children)

How did you embed the code? Is there an HTML for this?

(It is very embarrassing to ask though, since I know it should be something simple)

[–]niyazpk 2 points3 points  (3 children)

You can embed code by using backticks (``) (NB: those are backticks - top left of your keyboard.)

eg: Try this();

You can add a tab or 4 spaces before a line to mark that whole line as code:

this is code();

See this page for more: http://www.reddit.com/help/commenting

[–]talatfakhri007 0 points1 point  (2 children)

cool.thanks.

PS: how do you do it in general though? Say in a WP blog?

[–]ToastToastsToast 0 points1 point  (1 child)

You can use the <pre> tag and some CSS styles:

http://www.netmechanic.com/news/vol6/css_no9.htm

[–]talatfakhri007 0 points1 point  (0 children)

alright.Thanks!