Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coding puzzle 3
Message
 
 
To
06/06/2002 06:33:53
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00665235
Message ID:
00665343
Views:
22
>Hi Nadya,
>
>Instead of relying on SQL, here a faster method.
>
>
>CREATE CURSOR Invert (un I)
>SELECT t1
>nLow = 0
>INDEX ON Un TAG un && Only neccesary when the order is not right yet
>SCAN
>	FOR nT = nLow+1 TO Un-1
>		INSERT INTO Invert VALUES (nT)
>	ENDFOR
>	nLow=un
>ENDSCAN
>
>Walter,

Yep, it's the most obvious and simple solution. I bet, it would be faster, than another suggested solution, but needs experimenting...

>
>>Hi everybody,
>>
>>Ok, I was inspired by Peter. Here is a very simple problem, but neverless, let's find out the most elegant solution.
>>
>>There is a table with some sequence unique numbers:
>>
>>1
>>3
>>4
>>8
>>15
>>...
>>
>>No pattern. Your goal would be to find out all missing numbers (of course, only whole numbers).
>>
>>For more advanced, I would make the task more difficult: find out all missing simple (? oops, what's the correct math term?) numbers. The latest problem seems complicated and I don't know solution myself yet...
One amendement: nLow = un (we probably want to start from the first number in the table, if it's 6, we don't want to insert 1,2,3,4,5)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform