Pasted


SUBMITTED BY: strafepvpz

DATE: July 15, 2016, 8:20 a.m.

FORMAT: Text only

SIZE: 1.1 kB

HITS: 476

  1. #Persistent
  2. InputBox, MAX, Lotto, Please enter the MAXIMUM numbers in the lottery., , ,
  3. InputBox, N, Lotto, Please tell me how many numbers to generate.`nThis will work for up to 11 numbers.`nSelection will be Between 1 and %MAX%, , ,
  4. ;N := 7
  5. MIN := 1
  6. ;MAX := 45
  7. If (MAX - MIN + 1 < N)
  8. {
  9. MsgBox Cannot have %N% different numbers between %MIN% and %MAX%
  10. return
  11. }
  12. generate_numbers:
  13. Loop %N%
  14. {
  15. i := A_Index
  16. loop
  17. {
  18. Random R, %MIN%, %MAX% ; R = random number
  19. j := Index_%R% ; get value from Indexes
  20. If j is number
  21. If j between 1 and % i - 1
  22. If (R_%j% = R)
  23. continue ; repetition found, try again
  24. Index_%R% := i ; store index
  25. R_%i% := R ; store in R_1, R_2...
  26. break ; different number
  27. }
  28. }
  29. MsgBox,5,Below are your random numbers,Below are your %N% Numbers`n`n%R_1%`n%R_2%`n%R_3%`n%R_4%`n%R_5%`n%R_6%`n%R_7%`n%R_8%`n%R_9%`n%R_10%`n%R_11%`n`nUse CTRL+C to copy
  30. IfMsgBox Cancel
  31. Exitapp
  32. else
  33. goto generate_numbers
  34. Return

comments powered by Disqus