Programming Challenge and Solutions

Muhammad Abubakar

Version Compatibility:

More information:
The author posted the challenge below as a programming contest:

Challenge: Write a single forward "For" loop with one and only one statement in it -- and no user-defined functions, no built-in functions, and no if-then statements -- that produces the following output:

0 1 2 3 4 5 6 6 5 4 3 2 1 0

The for-loop has to be instrumental in producing the output (In other words, this solution, suggested by one clever user is not correct: for x= 1 to 1: label1.caption = " 0 1 2 3 4 5 6 6 5 4 3 2 1 0": next)

There also can be no string concatenation., i.e., no solutions such as the following: for x = 0 to 13: label1.caption = whatever + label1.caption: next. This requirement was added after the challenge began (it was meant to be added originally, but forgotten), so people who submitted solutions with string concatenation before this requirement was added are acknowledged below.

The challenge was open on the site for two weeks. If you click the link below, you can download some of the correct solutions that were submitted. Below is a list of people who submitted correct solutions:

Lee Greco
Howard Hill
Germonprez Dries
Roy Low
Khawar Ashraf
David Lonsford
Michael Kinasz
Jody Gelowitz & Paul Hetherington
Garry Kelly
Darrek Kay
Scott Bingham
Duane Ferrell
Ricky Hammonds

Instructions: Copy the declarations and code below and paste directly into your VB project.



Instructions: Click the link below to download the code. Select 'Save' from the IE popup dialog. Once downloaded, open the .zip file from your local drive using WinZip or a comparable program to view the contents.