The Florida Lottery has never picked the same 6-winning number twice, so, can anyone make this lottery number generator skip numbers that I put in a database? Thank you!
AHK allows your program to be written in a much shorter form:
Code:
Loop 3
FileDelete Random_%A_Index%.txt
Loop, 60
Number_%A_Index% = 0
Loop, 5000
{
If (mod(A_Index,100)=0)
TrayTip,,%A_Index% ; Show the progress at the TRAY
Random, Num, 1, 60
Loop 5
{
Loop
{
Random, temp, 1, 60
If temp not in %Num%
Break
}
Num = %Num%,%temp%
}
StringSplit Num_, Num,`,
FileAppend, %Num_1%-%Num_2%-%Num_3%-%Num_4%-%Num_5%-%Num_6%`n, Random_1.txt
}
Loop, Read, Random_1.txt,
Loop, Parse, A_LoopReadLine, -
Number_%A_LoopField% += 1
Loop 60
{
temp := Number_%A_index%
FileAppend, %temp% = %A_index%`n, Random_2.txt
}
FileRead, Sort_List, Random_2.txt
Sort, Sort_List, N R
FileAppend, %Sort_List%, Random_3.txt
Having run that three times I got the following values in Random_3.txt:
Code:
562 = 7 557 = 32 552 = 54
541 = 13 551 = 54 536 = 28
534 = 44 537 = 25 534 = 24
530 = 12 533 = 49 531 = 50
528 = 41 530 = 52 528 = 16
526 = 32 527 = 16 526 = 35
523 = 53 526 = 59 524 = 41
522 = 15 525 = 42 523 = 26
520 = 42 521 = 9 523 = 7
519 = 49 521 = 14 521 = 46
519 = 19 520 = 20 519 = 44
518 = 35 518 = 48 516 = 59
518 = 33 515 = 23 515 = 53
518 = 31 514 = 3 514 = 60
517 = 56 513 = 58 514 = 45
516 = 14 513 = 38 512 = 15
515 = 43 512 = 5 512 = 13
514 = 50 512 = 30 511 = 6
514 = 27 511 = 27 509 = 34
511 = 57 511 = 28 509 = 9
511 = 34 510 = 31 508 = 37
510 = 26 508 = 60 507 = 43
510 = 36 507 = 40 506 = 25
508 = 58 507 = 46 505 = 3
507 = 38 506 = 24 505 = 22
507 = 23 506 = 45 503 = 40
505 = 45 505 = 41 503 = 4
502 = 48 501 = 1 503 = 39
502 = 17 500 = 2 502 = 21
502 = 6 500 = 13 501 = 38
500 = 54 500 = 57 500 = 18
498 = 29 499 = 4 499 = 57
493 = 11 499 = 39 499 = 47
493 = 3 496 = 22 498 = 2
493 = 20 496 = 37 496 = 5
492 = 60 494 = 29 496 = 32
490 = 5 494 = 56 496 = 29
489 = 40 492 = 15 495 = 14
487 = 21 492 = 10 494 = 51
487 = 1 491 = 55 494 = 12
486 = 25 489 = 12 492 = 48
486 = 24 489 = 35 491 = 58
486 = 46 487 = 7 489 = 30
485 = 9 486 = 43 489 = 31
484 = 28 485 = 21 488 = 20
483 = 4 484 = 44 488 = 49
483 = 51 483 = 6 487 = 56
482 = 18 479 = 47 486 = 27
482 = 30 478 = 50 485 = 42
480 = 55 478 = 17 482 = 23
478 = 37 478 = 19 481 = 19
478 = 2 477 = 11 475 = 33
476 = 39 475 = 51 474 = 17
474 = 16 471 = 8 473 = 36
473 = 8 470 = 34 471 = 55
473 = 22 465 = 33 470 = 52
470 = 52 465 = 26 469 = 1
468 = 59 465 = 53 462 = 10
463 = 47 463 = 36 459 = 11
459 = 10 463 = 18 450 = 8
I don't see anything wrong with these values. If you see always the same results, it could be, because you did not delete the files, just append the new results to the end.