Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Generator
Message
From
23/01/2001 14:46:11
 
 
To
22/01/2001 22:34:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00467103
Message ID:
00467506
Views:
13
>A fun one. I want to code for a random number from 0 to 35. The challenge is to get that code in less than 6 lines (seven for a tie) as a friend of mine has demonstrated in our other language LINC. Any help will win me a beer!

Ok, here are the smart ass one liners

VFP7
?EXECSCRIPT("=rand(-1)" + CHR(13) + CHR(10) + "lcString = ''" + CHR(13) + CHR(10) + "for lnI = 1 to 20" + CHR(13) + CHR(10) + "lnNumber = int(rand() * 36)" + CHR(13) + CHR(10) + "lcString = lcString + iif(lnNumber < 10, tran(lnNumber), chr(lnNumber + 55))" + CHR(13) + CHR(10) + "endfor" + CHR(13) + CHR(10) + "return lcString")
VFP6

?sys(2015)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform