powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / Генератор лотерейных номеров (Lottery Numbers Random Generator)
2 сообщений из 2, страница 1 из 1
Генератор лотерейных номеров (Lottery Numbers Random Generator)
    #36453839
Lkhiger
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Russian Lottery - Gosloto: Russia's New Lotto

Gosloto is Russia's new lottery; it started in October of 2008 with a 6/45 game. The odds of winning the jackpot in a 6/45 game are 1 in 8,145,060. Albert Begrakyan managed to beat the odds and won 100 million rubles ($2,968,372 USD) in April of 2009.

Albert Begrakyan's win was the biggest ever in Gosloto's short history. He was so afraid of somebody finding out that he won the lottery that he hired bodyguards to travel with him to Moscow to claim his prize. But he got his money and is now safe and sound with the money in the bank.

Russia's lottery is way different than lotteries, say, in North America. Canadian and American lotteries are government run, whereas Russia's new Gosloto is run by a private businessman. His name is Sandor Demjan. This is crazy. As most people probably know, lotteries generate billions in profit. And, it is usually a government monopoly as private businesses are prohibited from creating a lottery. Giving a private businessman the opportunity to create a lottery is like him winning the lottery himself. But instead of winning millions, he wins billions. Having the only lottery franchise in a country like Russia is like starting the most lucrative business ever - with absolutely no risk whatsoever. It really is crazy.

Now, Sandor Demjan does have to give a percentage of all lottery sales from Gosloto to government programs. We couldn't find out the exact percentage, but we still think this situation is crazy.


Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
with Goslotto_tickets (tickets, R, K, Lsw, L1, L2, L3, L4, L5, L6) as
(select int( 77 ),int( 0 ),int( 0 ), 'N',
		char('',  2 ), char('',  2 ), char('',  2 ),   
		char('',  2 ), char('',  2 ), char('',  2 )		
   from sysibm.sysdummy1 
union all
select tickets, R +  12 , 
	K + case when M1 > '00' and M2 > '00' and M3 > '00' and 
				  M4 > '00' and M5 > '00' and M6 > '00' 
			 then  1 
			 else  0 
		end,
case when M1 > '00' and M2 > '00' and M3 > '00' and 
		  M4 > '00' and M5 > '00' and M6 > '00' 
	 then 'Y'
	 else 'N'
end,
M1, M2, M3, M4, M5, M6 
from Goslotto_tickets lt,
table (
select max(L1) M1, max(L2) M2, max(L3) M3, 
	   max(L4) M4, max(L5) M5, max(L6) M6  
from table 
(select  L1, L2, L3, L4, L5, L6 
from table 
(select  L1, L2, L3, L4, L5, L6 
from table
(select 
substr(char(rand(R)),		 3 ,   1 )	   ||  
substr(char(rand(R +  1 )),   4 ,   1 )  L1, 
		substr(char(rand(R +  2 )),   5 ,   1 ) ||  
substr(char(rand(R +  3 )),   6 ,   1 )  L2, 
		substr(char(rand(R +  4 )),   7 ,   1 ) ||  
substr(char(rand(R +  5 )),   8 ,   1 )  L3, 
		substr(char(rand(R +  6 )),   9 ,   1 ) ||  
substr(char(rand(R +  7 )),   10 ,  1 )  L4,
		substr(char(rand(R +  8 )),   10 ,  1 ) ||  
substr(char(rand(R +  9 )),   11 ,  1 )  L5,
		substr(char(rand(R +  10 )),  12 ,  1 ) ||  
substr(char(rand(R +  11 )),  13 ,  1 )  L6	
		 
from sysibm.sysdummy1 ) rd1
where 
L1 between '01' and '45' and
L2 between '01' and '45' and
L3 between '01' and '45' and
L4 between '01' and '45' and
L5 between '01' and '45' and
L6 between '01' and '45'  
) rd2 
Where 
L1 not in (L2, L3, L4, L5, L6) and
L2 not in (L1, L3, L4, L5, L6) and
L3 not in (L1, L2, L4, L5, L6) and
L4 not in (L1, L2, L3, L5, L6) and
L6 not in (L1, L2, L3, L4, L5) 
union all
select '00' L1, '00' L2, '00' L3, '00' L4, '00' L5, '00' L6 
from sysibm.sysdummy1 ) rd3 ) rdm
where K <= tickets -  1 
) 
select distinct L1, L2, L3, L4, L5, L6   
  from Goslotto_tickets 
   where Lsw = 'Y'

L1 L2 L3 L4 L5 L6

01 04 24 15 12 08
01 29 30 17 07 24
01 32 39 26 45 19
04 18 45 36 17 07
04 26 35 06 31 24
04 28 21 29 03 41
05 11 26 15 28 42
05 15 45 14 32 39
05 22 35 39 43 08
06 10 17 41 01 13
06 40 34 12 44 03
07 21 24 18 32 11
07 26 28 12 19 30
08 18 25 28 12 09
08 31 19 06 39 11
09 07 02 45 36 33
09 10 25 12 04 36
09 14 12 29 31 01
09 18 19 07 15 38
09 22 30 36 23 21
09 33 21 25 20 14
10 06 31 24 21 34
10 37 07 01 24 03
10 38 26 27 34 08
11 35 21 08 28 02
12 15 37 21 01 03
13 35 11 25 31 45
14 39 34 05 30 40
14 41 07 36 22 05
15 34 07 01 18 33
15 38 23 21 39 09
16 20 10 23 45 07
16 38 26 32 11 30
17 15 03 22 21 28
18 01 10 44 25 40
18 03 31 20 08 37
18 09 13 32 42 33
18 42 41 20 11 21
18 44 30 02 37 16
19 13 11 16 14 34
19 22 05 14 37 43
20 12 23 29 14 27
20 12 42 35 28 14
20 18 15 39 42 23
21 18 12 01 25 37
21 44 32 45 10 02
24 06 25 05 43 23
25 09 37 01 22 29
25 22 17 09 15 18
26 11 22 34 03 45
27 02 33 04 25 38
27 24 42 41 15 11
28 12 25 27 07 36
29 35 30 38 34 15
29 41 17 24 13 33
29 42 15 06 32 09
30 12 03 45 07 01
30 17 28 12 41 15
30 37 01 17 15 40
31 34 04 41 19 25
32 07 36 27 02 33
33 37 31 10 43 22
34 12 19 14 08 44
34 22 26 04 36 25
35 24 30 06 42 32
37 14 06 09 30 07
37 42 07 16 23 02
38 05 16 25 39 32
39 09 08 05 37 33
39 14 26 37 42 30
41 08 39 14 01 44
41 33 02 10 36 11
42 16 13 27 15 43
42 21 17 35 10 43
42 32 33 13 25 28
45 23 20 02 38 08
45 34 10 28 21 07

Lenny
...
Рейтинг: 0 / 0
Генератор лотерейных номеров (Lottery Numbers Random Generator)
    #36481558
Lkhiger
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Кстати, вы можете заметить что результаты выдаются не сортированными: " 01 04 24 15 12 08 ", и так далее.

Небольшое изменение кода позволит нам выводить результат в сортированном виде .

Замечу только, что это приведёт к значительному увеличению времени получения номеров.

Вам остаётся только выбрать какой код для вас более приемлем.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
with Goslotto_tickets (tickets, R, K, Lsw, L1, L2, L3, L4, L5, L6) as
(select int( 77 ),int( 0 ),int( 0 ), 'N',
        char('',  2 ), char('',  2 ), char('',  2 ),   
        char('',  2 ), char('',  2 ), char('',  2 )        
   from sysibm.sysdummy1 
union all
select tickets, R +  12 , 
    K + case when M1 > '00' and M2 > '00' and M3 > '00' and 
                  M4 > '00' and M5 > '00' and M6 > '00' 
             then  1 
             else  0 
        end,
case when M1 > '00' and M2 > '00' and M3 > '00' and 
          M4 > '00' and M5 > '00' and M6 > '00' 
     then 'Y'
     else 'N'
end,
M1, M2, M3, M4, M5, M6 
from Goslotto_tickets lt,
table (
select max(L1) M1, max(L2) M2, max(L3) M3, 
       max(L4) M4, max(L5) M5, max(L6) M6  
from table 
(select  L1, L2, L3, L4, L5, L6 
from table 
(select  L1, L2, L3, L4, L5, L6 
from table
(select 
substr(char(rand(R)),         3 ,   1 )       ||  
substr(char(rand(R +  1 )),   4 ,   1 )  L1, 
        substr(char(rand(R +  2 )),   5 ,   1 ) ||  
substr(char(rand(R +  3 )),   6 ,   1 )  L2, 
        substr(char(rand(R +  4 )),   7 ,   1 ) ||  
substr(char(rand(R +  5 )),   8 ,   1 )  L3, 
        substr(char(rand(R +  6 )),   9 ,   1 ) ||  
substr(char(rand(R +  7 )),   10 ,  1 )  L4,
        substr(char(rand(R +  8 )),   10 ,  1 ) ||  
substr(char(rand(R +  9 )),   11 ,  1 )  L5,
        substr(char(rand(R +  10 )),  12 ,  1 ) ||  
substr(char(rand(R +  11 )),  13 ,  1 )  L6    
         
from sysibm.sysdummy1 ) rd1
where 
L1 between '01' and '45' and
L2 between '01' and '45' and
L3 between '01' and '45' and
L4 between '01' and '45' and
L5 between '01' and '45' and
L6 between '01' and '45'  
) rd2 

Where 
L1 <L2 and
L2 <L3 and
L3 <L4 and
L4 <L5 and
L5 <L6 

Union All
select '00' L1, '00' L2, '00' L3, '00' L4, '00' L5, '00' L6 
from sysibm.sysdummy1 ) rd3 ) rdm
where K <= tickets -  1 
) 
select distinct L1, L2, L3, L4, L5, L6   
  from Goslotto_tickets 
   where Lsw = 'Y'

Lenny
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / IBM DB2, WebSphere, IMS, U2 [игнор отключен] [закрыт для гостей] / Генератор лотерейных номеров (Lottery Numbers Random Generator)
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]