Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help?
Message
De
21/08/1997 09:21:25
Matt Mc Donnell
Mc Donnell Software Consulting
Boston, Massachusetts, États-Unis
 
 
À
21/08/1997 08:46:03
Larry Long
ProgRes (Programming Resources)
Georgie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00044834
Message ID:
00046103
Vues:
45
>>> >>Feminine intuition? Dumb luck? Years of experience? Alzheimers? I
>>> LOVE SQL. It's like those grid-based logic puzzles you find in supermarket
>>> magazines!
>>> >>
>>> >>Barbara
>>> >Barbara...change of subject to your gaming side...
>>> >
>>> >Find 3, three digit numbers such that the sum of the first two yeilds the
>>> third, and all three numbers have the same digits.
>>> >For example 213+132=312 (of course it doesnt). There are no tricks, all
>>> normal addition rules apply...
>>> >
>>> >Have fun,
>>> >Larry //:^)
>>>
>>> Larry,
>>>
>>> Of course you know, I'm gonna have to kill you now. B/C until I solve
>>> this, I won't be able to do anything.
>>>
>>> ;)
>>Matt,
>>
>>Try a little programming for a change :)
>>
>>for x= 0 to 9
>> for y= 0 to 9
>> for z= 0 to 9
>> if z= x+y and
>> 109x -89y + 91 z = 0
>> exit
>> endif
>> next z
>> next y
>>next x
>>
>>HTH,
>>
>>Marc
>Where does 109 89 and 91 come from?

I couldn't get that to work anyway.

but here's my answer and how I did it. There's probably a better way but:
ll_cont = .T.

lnSeed = 110

DO WHILE ll_cont and lnSeed<999
  
  lnSeed = lnSeed + 1
  
  lc1 = LEFT(STR(lnSeed,3,0),1)
  lc2 = SUBSTR(STR(lnSeed,3,0),2,1)
  lc3 = RIGHT(STR(lnSeed,3,0),1)
  
  lnNum1 = MakeNum(lc1,lc2,lc3)
  ll_cont2 = .T.
  
  lc4 = lc1
  lc5 = lc2
  lc6 = lc3
  
  lnCount = 1
  
  DO WHILE ll_cont2
    
    lcNum = STR(lnNum1 - MakeNum(lc4,lc5,lc6),3,0)
    lc_1 = LEFT(lcNum,1)
    lc_2 = SUBSTR(lcNum,2,1)
    lc_3 = RIGHT(lcNum,1)
    
    IF lc1$lcNum AND lc2$lcNum AND lc3$lcNum AND ;
      INLIST(lc_1,lc1,lc2,lc3) AND INLIST(lc_2,lc1,lc2,lc3) AND INLIST(lc_3,lc1,lc2,lc3) 
      ? PADL(ALLT(str(lnnum1-val(lcNum),3,0)),3,'0') + " + " + lcNum + " = " + STR(lnnum1,3,0)
    ENDIF
     
      DO CASE
        CASE lnCount = 1
          lc5 = lc3
          lc6 = lc2

        CASE lnCount = 2
          lc4 = lc2
          lc6 = lc1
          
        CASE lnCount = 3
          lc5 = lc1
          lc6 = lc3
          
        CASE lnCount = 4
          lc4 = lc3
          lc6 = lc2
          
        CASE lnCount = 5
          lc5 = lc2
          lc6 = lc1
          
      ENDCASE
      lnCount = lnCount + 1 
      
      ll_cont2 = (lnCount<6)
        
  ENDDO
    
ENDDO
  
FUNC MakeNum(tc1,tc2,tc3)
  RETURN VAL(tc1)*100+VAL(tc2)*10+VAL(tc3)
  
ANSWERS (although the 1st two don't really count)
045 + 405 = 450
054 + 450 = 504

495 + 459 = 954

Thanks Larry for killing an hour for me....lol
Matt McDonnell
...building a better mousetrap with moldy cheese...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform