-1
1
for
loops are useful in python in many ways, but one of the most common usages associated with a for
loop is it's ability to repeat a certain amount of times. Like this:
for times in range(50):
print "I'm repeating this 50 times..."
The challenge I propose to you is to make a for
repeat forever. If you can find a way to do it without using a recursion, kudos to you. You can use any major version of Python. Just specify which one you are using. The goal is to do this in the smallest file size you can get, and a method that won't "break" after a while. Good luck!
perl6 -e 'for 0..* {print "$_\r"}'
only 11 required characters, orperl6 -e 'print "$_\r" for 0..*'
only 10 chars required ( there has to be something beforefor
separated by whitespace0 for 0..*
) – Brad Gilbert b2gills – 2015-10-18T01:14:09.780I didn't know you had time for code-golfing, M. Putin. – coredump – 2015-11-04T19:17:24.863
9
Ewwww, language-specific challenges. (See http://meta.codegolf.stackexchange.com/a/234/3 for my stance on this.) (This is unrelated to the reason why I closed the question, which is a site rule and not just a personal opinion.)
– Chris Jester-Young – 2014-06-20T13:18:33.6802@ChrisJester-Young I personally think it's fair for programming-puzzles, as they usually tend to work around some feature of a specific language. You could have told the OP though, that your closing the question has nothing to do with your not liking language-specific challenges. So, @ Some Guy, the question is closed because you did not indicate who (among several correct solutions) you will pick the winner of the challenge. Votes? Code-length? Something else? – Martin Ender – 2014-06-20T13:32:19.700
1@m.buettner There, I edited my comment to say that now. Thanks! :-) – Chris Jester-Young – 2014-06-20T13:35:00.753
Befunge will surely win if this is non-language-specific code-golf. – jimmy23013 – 2014-06-20T13:58:06.743
1
@user23013 Of course. It was the winning entry in my stack overflow code golf. ;-)
– Chris Jester-Young – 2014-06-20T13:59:10.467@ChrisJester-Young I have added basic criteria to help decided a winner. This probably isn't enough to re-open the question though... Sorry to the users who answered this question before I added goals in order to choose a winner. – Vladimir Putin – 2014-06-20T14:47:45.067
@SomeGuy Thank you. I have retagged the question as a code golf since the winning criterion is shortest code. – Chris Jester-Young – 2014-06-20T14:57:11.443
3Here's an idea to make this non-language-specific: "implement a foreach loop that repeats forever" – Justin – 2014-06-20T16:00:30.603
2@TheRare Changing the accepted answer is absolutely legitimate if a new winner comes along (by the specified criteria). Therefore, the currently accepted answer isn't even the correct one, actually. – Martin Ender – 2014-06-20T18:36:45.720
@m.buettner Well then, I take your word on that. – seequ – 2014-06-20T18:59:41.117
Wait... is this [tag:code-golf] or [tag:popularity-contest]? I'm confused. – Iszi – 2014-06-22T02:19:46.497
@Iszi Pop contest. – Vladimir Putin – 2014-06-22T02:36:41.547
The question and one tag state that it's code-golf. The previous comment and another tag state that it's pop-con. It can't be both. – Peter Taylor – 2014-06-22T07:58:29.907
It's code golf, but it would have been far better as an underhanded popularity contest. – nyuszika7h – 2014-07-05T12:09:52.983
@ChrisJester-Young Eww, here's another language-specific challenge. Doesn't look like it's getting hate for that.
– DatEpicCoderGuyWhoPrograms – 2014-07-07T16:00:53.6971@DatEpicCoderGuyWhoPrograms King-of-the-Hill contests are a special exception, to make concessions for OPs who want to test out the entries and not have to install many language runtimes in order to do so. However, there are still ways to run language-independent KotH contests (e.g., using virtual machines), and I still encourage people to do it. – Chris Jester-Young – 2014-07-08T00:53:34.357