repeat
set chemindef to ((path to desktop folder as text) & "liste 70.txt") as text
set bigList to {}
set bigListRef to a reference to bigList
set numItems to 70
repeat with n from 1 to numItems -- rempli la liste avec numero de 1 à 70
copy n to the end of bigListRef
end repeat
set laliste to {}
set impossible to 0
repeat with i from 1 to 70
tell application "Finder"
repeat
set place to random number from 1 to (count of bigListRef) as integer
set choix to item place of bigListRef as string
if choix - i > 2 then exit repeat
if i - choix > 2 then exit repeat
if i > 67 then
set impossible to 1
exit repeat
end if
end repeat
if place = 1 then
set bigListRef to rest of bigListRef
else
if place = (count of bigListRef) then
set bigListRef to items 1 thru -2 of bigListRef
else
set bigListRef to items 1 thru (place - 1) of bigListRef & items (place + 1) thru -1 of bigListRef --efface le numero choisi de la liste
end if
end if
set end of laliste to choix
end tell
end repeat
repeat with j from 1 to 70
set control to item j of laliste
set le2 to j as string
set le3 to item control of laliste as string
if le3 = le2 then
set impossible to 1
exit repeat
end if
end repeat
if impossible = 0 then
exit repeat
end if
end repeat
repeat
set bigList to {}
set bigListRef to a reference to bigList
set numItems to 70
repeat with n from 1 to numItems
copy n to the end of bigListRef
end repeat
set laliste2 to {}
set impossible to 0
repeat with i from 1 to 70
tell application "Finder"
repeat
set ecart to 0
set place to random number from 1 to (count of bigListRef) as integer
set choix to item place of bigListRef as string
set test to choix - i
if test < 0 then set test to test * -1
if test < 3 then set ecart to 1
if ecart = 1 then
if i > 67 then
set impossible to 1
set ecart to 0
end if
end if
set letest to item i of laliste
set test to choix - letest
if test < 0 then set test to test * -1
if test < 3 then set ecart to 1
if ecart = 1 then
if i > 67 then
set impossible to 1
set ecart to 0
end if
end if
set lenum to i as string
if ecart = 0 then exit repeat
end repeat
if place = 1 then
set bigListRef to rest of bigListRef
else
if place = (count of bigListRef) then
set bigListRef to items 1 thru -2 of bigListRef
else
set bigListRef to items 1 thru (place - 1) of bigListRef & items (place + 1) thru -1 of bigListRef
end if
end if
set end of laliste2 to choix
end tell
end repeat
repeat with j from 1 to 70
set control to item j of laliste
set control2 to item j of laliste2
set le2 to j as string
set le3 to item control of laliste as string
set le4 to item control2 of laliste2 as string
if le3 = le2 then
set impossible to 1
exit repeat
end if
if le4 = le2 then
set impossible to 1
exit repeat
end if
end repeat
if impossible = 0 then
exit repeat
end if
end repeat
repeat with i from 1 to 70
set l1 to i as integer
set l2 to item i of laliste as integer
set l3 to item i of laliste2 as integer
repeat with tri from 1 to 3
if l1 > l2 then
set tmp to l2
set l2 to l1
set l1 to tmp
end if
if l2 > l3 then
set tmp to l3
set l3 to l2
set l2 to tmp
end if
end repeat
set le1 to l1 as string
set le2 to l2 as string
set le3 to l3 as string
set lefichier to open for access chemindef with write permission
write le1 & (ASCII character 9) & le2 & (ASCII character 9) & le3 & return to lefichier starting at eof
close access lefichier
end repeat
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell
set le1 to l1 as string
set le2 to l2 as string
set le3 to l3 as string
set le1 to items -2 thru -1 of ("0" & l1) as string
set le2 to items -2 thru -1 of ("0" & l2) as string
set le3 to items -2 thru -1 of ("0" & l3) as string
repeat -- au cas ou a la fin il ne reste que 1,2,3 ou 4 nombres impossibles
set chemindef to ((path to desktop folder as text) & "liste KENO 70.txt") as text -- defini le chemin pour creer fichier texte
set bigList to {} --ceer une liste
set bigListRef to a reference to bigList
set numItems to 70
repeat with n from 1 to numItems -- rempli la liste avec numero de 1 à 70
copy n to the end of bigListRef
end repeat
set laliste to {}
set impossible to 0 -- pour test fin
repeat with i from 1 to 70
tell application "Finder"
repeat
set place to random number from 1 to (count of bigListRef) as integer -- un nombre au hasard entre 1 et x contenu dans la liste
set choix to item place of bigListRef as string --recupere le numero situé a la position du choix
if choix - i > 3 then exit repeat -- si superieur a 4 OK
if i - choix > 3 then exit repeat -- Si inferieur a 4 OK
if i > 66 then -- si reste impossible
set impossible to 1
exit repeat
end if
end repeat
-- routine pour effacer de la liste le nombre choisi
if place = 1 then
set bigListRef to rest of bigListRef
else
if place = (count of bigListRef) then
set bigListRef to items 1 thru -2 of bigListRef
else
set bigListRef to items 1 thru (place - 1) of bigListRef & items (place + 1) thru -1 of bigListRef --efface le numero choisi de la liste
end if
end if
set end of laliste to choix
my ecriture(i, choix, chemindef) -- appelle la routine ecriture dans le fichier texte
end tell
end repeat
-- test si paire double si mettre impossible à 1
repeat with j from 1 to 70
set control to item j of laliste
set le2 to j as string
set le3 to item control of laliste as string
if le3 = le2 then
set impossible to 1
exit repeat
end if
end repeat
if impossible = 0 then -- si fini
exit repeat
end if
do shell script "rm " & quoted form of POSIX path of chemindef -- impossible efface le fichier et recommence
end repeat
-- routine ecriture dans fichier texte
on ecriture(i, lenum, chemindef)
set num to i as string
set lefichier to open for access chemindef with write permission
write num & (ASCII character 9) & lenum & return to lefichier starting at eof
close access lefichier
end ecriture
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell
repeat -- au cas ou a la fin il ne reste que 1,2,3 ou 4 nombres impossibles
set chemindef to ((path to desktop folder as text) & "liste KENO 70.txt") as text -- defini le chemin pour creer fichier texte
set bigList to {} --ceer une liste
set bigListRef to a reference to bigList
set numItems to 70
repeat with n from 1 to numItems -- rempli la liste avec numero de 1 à 70
copy n to the end of bigListRef
end repeat
set laliste to {}
set impossible to 0 -- pour test fin
repeat with i from 1 to 70
tell application "Finder"
repeat
set place to random number from 1 to (count of bigListRef) as integer -- un nombre au hasard entre 1 et x contenu dans la liste
set choix to item place of bigListRef as string --recupere le numero situé a la position du choix
if choix - i > 3 then exit repeat -- si superieur a 4 OK
if i - choix > 3 then exit repeat -- Si inferieur a 4 OK
if i > 66 then -- si reste impossible
set impossible to 1
exit repeat
end if
end repeat
-- routine pour effacer de la liste le nombre choisi
if place = 1 then
set bigListRef to rest of bigListRef
else
if place = (count of bigListRef) then
set bigListRef to items 1 thru -2 of bigListRef
else
set bigListRef to items 1 thru (place - 1) of bigListRef & items (place + 1) thru -1 of bigListRef --efface le numero choisi de la liste
end if
end if
set end of laliste to choix
my ecriture(i, choix, chemindef) -- appelle la routine ecriture dans le fichier texte
end tell
end repeat
-- test si paire double si mettre impossible à 1
repeat with j from 1 to 70
set control to item j of laliste
set le2 to j as string
set le3 to item control of laliste as string
if le3 = le2 then
set impossible to 1
exit repeat
end if
end repeat
if impossible = 0 then -- si fini
exit repeat
end if
do shell script "rm " & quoted form of POSIX path of chemindef -- impossible efface le fichier et recommence
end repeat
-- routine ecriture dans fichier texte
on ecriture(i, lenum, chemindef)
set num to i as string
set num to items -2 thru -1 of ("0" & num) as string
set lenum to items -2 thru -1 of ("0" & lenum) as string
set lefichier to open for access chemindef with write permission
write num & (ASCII character 9) & lenum & return to lefichier starting at eof
close access lefichier
--display dialog num & " " & lenum
end ecriture
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell