Challenge: Validate a code - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: QbasicNews.Com (http://qbasicnews.com/newforum/forum-3.html) +--- Forum: Challenges (http://qbasicnews.com/newforum/forum-10.html) +--- Thread: Challenge: Validate a code (/thread-1599.html) |
Challenge: Validate a code - Moneo - 07-28-2003 BLITZ AND ANTONI, I compiled your original programs using BC with /ah option, and now they run fine. BLITZ: Excellent, yours runs perfectly. Later you can explain what the 2 dimeensional array is all about. ANTONI: Very good, also runs well. One very minor problem, you do not alllow the user to specify a code or zero nor a code of 99999, which are within the defined limits. ***** Challenge: Validate a code - Moneo - 07-28-2003 ANTONI, Your "bit array" is exactly my preferred solution. See my program below with a slightly simpler bit handling than yours, that is, no need for a pwrsof2 array. Code: REM Code validation program by Edward F. Moneo Challenge: Validate a code - Antoni Gual - 07-28-2003 Blitz: OK, you won! Moneo: I use the array of Pwrsof2 just for speed. In this case this is not an issue but when doing real time graphics (p.e. scaling a font) it is. Challenge: Validate a code - Moneo - 07-28-2003 Ok, Antoni, what you say makes sense for speed. Once you learn to do something considering speed, you get in the habit of always doing it that way. P.S.: It's hard to consider Blitz as having won. His last posted program is incomplete. Also, he abandoned his original approach and adopted yours. ***** Challenge: Validate a code - Blitz - 07-28-2003 Eh, that was my orginal aproatch. My original one used a huge array of integers which had 100,000 elements. The one antoni wrote the second time was the same as mine but with a bit array instead. My second one same as my first, except with a bit array. So i don't see how it is ME who has abboned their original aproach. The two dimensional array is bascially the same principal as real mode memory. It's split up into segments. In this case each segment is 16384 integers. That times 13 gives us over 100,000 elements to work with. To calculate the element index as a two dimensional array we do this indxa = element \ 16384, indxb = element mod 16384. Challenge: Validate a code - Moneo - 07-28-2003 Ok, sorry, Blitz. It's just that you've posted several versions including benchmark versions, so I'm a little confused as to which is your lastest working version. Would you please post your latest, running version so I can try it again. ***** Challenge: Validate a code - Agamemnus - 07-29-2003 i'm gonna try this, now that Moneo has explained what it's all about. And, stop spamming, Blitzilla. Challenge: Validate a code - Moneo - 07-29-2003 Aga, Your right, I didn't explain everything up front this time, like I usually do. If I do too much explaining, then I get accused of posting a challenge with too many "constraints". I'm damned if I do, and damned if I don't. Ok, so go ahead and try this one out, now that you know. ***** I decided to do something a little different. - Meg - 07-29-2003 How's this for cramming the codes into as little memory as possible? No arrays (this outta be good for a laugh, at least!) Code: DECLARE FUNCTION GetCode& () *peace* Meg. Challenge: Validate a code - Antoni Gual - 07-29-2003 Fine idea, Meg! This reminds me old times. I once used screen memory to run an assembler program in a Sinclair ZX Spectrum, back in 1985.... The idea was to leave all conventional memory to load a game (from an audio cassette), then my program made an (illegal) copy of it.. |