Перейти к содержимому

Автоматизация функционального тестирования
онлайн, начало 13 декабря
Python для начинающих
онлайн, начало 18 декабря
Погружение в тестирование. Jedi point
онлайн, начало 16 декабря
Школа Тест-Аналитика
онлайн, начало 18 декабря
Фотография

MegaSUDOKU killer


  • Авторизуйтесь для ответа в теме
Сообщений в теме: 32

#21 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 05 Декабрь 2009 - 14:46

3 Sudoku: Very hard + Level-3 + Level-4: total time = 5 seconds:

Source (line, sudoku_str) as 
(
select 1, '000680790'
  from sysibm.sysdummy1
union all
select 2, '076009000'
  from sysibm.sysdummy1
union all
select 3, '030002804'
  from sysibm.sysdummy1
union all 
select 4, '020000040'
  from sysibm.sysdummy1
union all 
select 5, '501000203'
  from sysibm.sysdummy1
union all
select 6, '080000010'
  from sysibm.sysdummy1
union all
select 7, '408300050'
  from sysibm.sysdummy1
union all
select 8, '000800470'
  from sysibm.sysdummy1
union all
select 9, '017045000'
  from sysibm.sysdummy1
)

Line 1: | 2 | 4 | 5 | 6 | 8 | 3 | 7 | 9 | 1 |
Line 2: | 8 | 7 | 6 | 4 | 1 | 9 | 5 | 3 | 2 |
Line 3: | 1 | 3 | 9 | 5 | 7 | 2 | 8 | 6 | 4 |
Line 4: | 9 | 2 | 3 | 1 | 5 | 8 | 6 | 4 | 7 |
Line 5: | 5 | 6 | 1 | 7 | 9 | 4 | 2 | 8 | 3 |
Line 6: | 7 | 8 | 4 | 2 | 3 | 6 | 9 | 1 | 5 |
Line 7: | 4 | 9 | 8 | 3 | 2 | 7 | 1 | 5 | 6 |
Line 8: | 3 | 5 | 2 | 8 | 6 | 1 | 4 | 7 | 9 |
Line 9: | 6 | 1 | 7 | 9 | 4 | 5 | 3 | 2 | 8 |



Source (line, sudoku_str) as 
(
select 1, '700020003'
  from sysibm.sysdummy1
union all
select 2, '020467090'
  from sysibm.sysdummy1
union all
select 3, '000000800'
  from sysibm.sysdummy1
union all 
select 4, '004000002'
  from sysibm.sysdummy1
union all 
select 5, '000090000'
  from sysibm.sysdummy1
union all
select 6, '200003600'
  from sysibm.sysdummy1
union all
select 7, '003000000'
  from sysibm.sysdummy1
union all
select 8, '080719030'
  from sysibm.sysdummy1
union all
select 9, '602030001'
  from sysibm.sysdummy1
)

Line 1: | 7 | 5 | 1 | 9 | 2 | 8 | 4 | 6 | 3 |
Line 2: | 3 | 2 | 8 | 4 | 6 | 7 | 1 | 9 | 5 |
Line 3: | 9 | 4 | 6 | 3 | 5 | 1 | 8 | 2 | 7 |
Line 4: | 8 | 3 | 4 | 1 | 7 | 6 | 9 | 5 | 2 |
Line 5: | 5 | 6 | 7 | 2 | 9 | 4 | 3 | 1 | 8 |
Line 6: | 2 | 1 | 9 | 5 | 8 | 3 | 6 | 7 | 4 |
Line 7: | 1 | 7 | 3 | 6 | 4 | 2 | 5 | 8 | 9 |
Line 8: | 4 | 8 | 5 | 7 | 1 | 9 | 2 | 3 | 6 |
Line 9: | 6 | 9 | 2 | 8 | 3 | 5 | 7 | 4 | 1 |



Source (line, sudoku_str) as 
(
select 1, '000000000'
  from sysibm.sysdummy1
union all
select 2, '703100065'
  from sysibm.sysdummy1
union all
select 3, '010689000'
  from sysibm.sysdummy1
union all 
select 4, '008002700'
  from sysibm.sysdummy1
union all 
select 5, '250000083'
  from sysibm.sysdummy1
union all
select 6, '006400000'
  from sysibm.sysdummy1
union all
select 7, '000346070'
  from sysibm.sysdummy1
union all
select 8, '300000501'
  from sysibm.sysdummy1
union all
select 9, '000000000'
  from sysibm.sysdummy1
)

Line 1: | 6 | 2 | 9 | 7 | 5 | 3 | 8 | 1 | 4 |
Line 2: | 7 | 8 | 3 | 1 | 2 | 4 | 9 | 6 | 5 |
Line 3: | 4 | 1 | 5 | 6 | 8 | 9 | 3 | 2 | 7 |
Line 4: | 1 | 4 | 8 | 5 | 3 | 2 | 7 | 9 | 6 |
Line 5: | 2 | 5 | 7 | 9 | 6 | 1 | 4 | 8 | 3 |
Line 6: | 9 | 3 | 6 | 4 | 7 | 8 | 1 | 5 | 2 |
Line 7: | 5 | 9 | 1 | 3 | 4 | 6 | 2 | 7 | 8 |
Line 8: | 3 | 6 | 2 | 8 | 9 | 7 | 5 | 4 | 1 |
Line 9: | 8 | 7 | 4 | 2 | 1 | 5 | 6 | 3 | 9 |



Lenny
  • 0

#22 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 13 Декабрь 2009 - 19:14

From Long query to short select from view

--- This one you have to execute if you want to change table ---
drop table Sd_Source;

--- Execute this one time when you create the table, or if you want recreate table ---
--- 1---.

create table Sd_Source 
(sd_id	integer	not null,
 sd_Lnum  integer	not null,
 sd_SLine Varchar(9) not null, 
 get_id  integer,
 ins_tms timestamp not null with default);

--- 2---.
CREATE UNIQUE INDEX IX_Source 
ON Sd_Source (sd_id ASC, sd_Lnum asc) CLUSTER;

--- Don't need if you don't want to change the view ---
drop view SDVW_SOLUTION;

--- Now you have to create view (don't worry if you have warning message) (Code in attachment): ---
create view SDVW_Solution 
(Sudoku_Solution, Source_id, Source_line) as
with.... (get from attachment)....


These operations are required any time when you add the new Sudoku which you want to solve:

--- Any time when you add the new sudoku puzzle to the Sd_Source table
you can use following query, or any query which you can create, for insert into Sd_Source : ---


select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '080100920' 
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000005000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '024000380'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '091003000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '060000040'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '000800290'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '035000760'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '000500000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '079006010'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source
);

--- If you want to solve sudoku with sd_id = K <= max(sd_id) you have to: ---

update Sd_Source  
   set get_id = K
where ins_tms = (select max(ins_tms) from Sd_Source);

---If Sd_Source table is not empty you can get sudoku solution from the view, using this: ---
select sudoku_solution from SDVW_SOLUTION

--- or with query
select * from SDVW_SOLUTION

Lenny

P.S. All logics and P/L code you can get from attachment....

Прикрепленные файлы


  • 0

#23 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 16 Январь 2010 - 16:14

NY Post Sudoku Difficult #1400 << 1 sec >> :crazy:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '000000000' 
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '204705308'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '060308010'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '003000500'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '950000036'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '006000700'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '080103050'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '407809601'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '000000000' 
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

Line 1: | 3 | 1 | 8 | 2 | 4 | 6 | 9 | 7 | 5 |
Line 2: | 2 | 9 | 4 | 7 | 1 | 5 | 3 | 6 | 8 |
Line 3: | 7 | 6 | 5 | 3 | 9 | 8 | 2 | 1 | 4 |
Line 4: | 8 | 7 | 3 | 9 | 6 | 1 | 5 | 4 | 2 |
Line 5: | 9 | 5 | 2 | 4 | 8 | 7 | 1 | 3 | 6 |
Line 6: | 1 | 4 | 6 | 5 | 3 | 2 | 7 | 8 | 9 |
Line 7: | 6 | 8 | 9 | 1 | 2 | 3 | 4 | 5 | 7 |
Line 8: | 4 | 3 | 7 | 8 | 5 | 9 | 6 | 2 | 1 |
Line 9: | 5 | 2 | 1 | 6 | 7 | 4 | 8 | 9 | 3 |


Lenny
  • 0

#24 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 06 Февраль 2010 - 19:37

Friday Level-4 Sudoku from "AMNY" <5 sec>:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '030006080' 
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000000900'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '700020000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '201070500'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '007000600'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '005060801'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '000740009'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '008000200'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '070500030'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

Line 1: | 1 | 3 | 2 | 4 | 9 | 6 | 7 | 8 | 5 |
Line 2: | 6 | 5 | 4 | 3 | 8 | 7 | 9 | 1 | 2 |
Line 3: | 7 | 8 | 9 | 1 | 2 | 5 | 3 | 4 | 6 |
Line 4: | 2 | 6 | 1 | 8 | 7 | 3 | 5 | 9 | 4 |
Line 5: | 8 | 4 | 7 | 9 | 5 | 1 | 6 | 2 | 3 |
Line 6: | 3 | 9 | 5 | 2 | 6 | 4 | 8 | 7 | 1 |
Line 7: | 5 | 2 | 3 | 7 | 4 | 8 | 1 | 6 | 9 |
Line 8: | 4 | 1 | 8 | 6 | 3 | 9 | 2 | 5 | 7 |
Line 9: | 9 | 7 | 6 | 5 | 1 | 2 | 4 | 3 | 8 |



Lenny
  • 0

#25 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 25 Март 2010 - 03:20

Level-3 Sudoku < 0 sec >:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '140007200'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '300020001'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '000900070'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '016000000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '008105300'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '000000060'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '020009000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '601070008'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '009500040'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

Line 1: | 1 | 4 | 5 | 8 | 3 | 7 | 2 | 9 | 6 |
Line 2: | 3 | 9 | 7 | 4 | 2 | 6 | 8 | 5 | 1 |
Line 3: | 8 | 6 | 2 | 9 | 5 | 1 | 4 | 7 | 3 |
Line 4: | 5 | 1 | 6 | 3 | 4 | 2 | 7 | 8 | 9 |
Line 5: | 9 | 7 | 8 | 1 | 6 | 5 | 3 | 2 | 4 |
Line 6: | 2 | 3 | 4 | 7 | 9 | 8 | 1 | 6 | 5 |
Line 7: | 4 | 2 | 3 | 6 | 8 | 9 | 5 | 1 | 7 |
Line 8: | 6 | 5 | 1 | 2 | 7 | 4 | 9 | 3 | 8 |
Line 9: | 7 | 8 | 9 | 5 | 1 | 3 | 6 | 4 | 2 |



Lenny
  • 0

#26 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 25 Апрель 2010 - 16:27

Friday Apr 23 2010 Sudoku:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '640900030'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000000010'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '000400200'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '010000005'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '000067004'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '500030090'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '007004000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '030000000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '090000827'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source );


Result:

Line 1: | 6 | 4 | 1 | 9 | 7 | 2 | 5 | 3 | 8 |
Line 2: | 9 | 7 | 2 | 3 | 8 | 5 | 4 | 1 | 6 |
Line 3: | 8 | 5 | 3 | 4 | 1 | 6 | 2 | 7 | 9 |
Line 4: | 7 | 1 | 8 | 2 | 4 | 9 | 3 | 6 | 5 |
Line 5: | 3 | 2 | 9 | 5 | 6 | 7 | 1 | 8 | 4 |
Line 6: | 5 | 6 | 4 | 8 | 3 | 1 | 7 | 9 | 2 |
Line 7: | 1 | 8 | 7 | 6 | 2 | 4 | 9 | 5 | 3 |
Line 8: | 2 | 3 | 5 | 7 | 9 | 8 | 6 | 4 | 1 |
Line 9: | 4 | 9 | 6 | 1 | 5 | 3 | 8 | 2 | 7 |



Lenny
  • 0

#27 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 22 Май 2010 - 23:11

Level-4 Sudoku. AMNY 05/21/2010 <5 sec>:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '790030400'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '058000200'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '000000006'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '900010008'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '000987000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '200050007'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '300000000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '029000840'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '006020059'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

Result:

Line 1: | 7 | 9 | 2 | 6 | 3 | 8 | 4 | 1 | 5 |
Line 2: | 6 | 5 | 8 | 1 | 4 | 9 | 2 | 7 | 3 |
Line 3: | 4 | 1 | 3 | 5 | 7 | 2 | 9 | 8 | 6 |
Line 4: | 9 | 6 | 7 | 2 | 1 | 4 | 5 | 3 | 8 |
Line 5: | 1 | 3 | 5 | 9 | 8 | 7 | 6 | 2 | 4 |
Line 6: | 2 | 8 | 4 | 3 | 5 | 6 | 1 | 9 | 7 |
Line 7: | 3 | 4 | 1 | 8 | 9 | 5 | 7 | 6 | 2 |
Line 8: | 5 | 2 | 9 | 7 | 6 | 3 | 8 | 4 | 1 |
Line 9: | 8 | 7 | 6 | 4 | 2 | 1 | 3 | 5 | 9 |



Sudoku Level: Hard Metro NY 05/21/2010 <0 sec>:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '002059100'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '140080000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '003004008'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '200093080'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '008000500'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '050720003'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '500400600'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '000060041'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '006930800'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

Result:

Line 1: | 8 | 7 | 2 | 3 | 5 | 9 | 1 | 6 | 4 |
Line 2: | 1 | 4 | 5 | 6 | 8 | 7 | 3 | 9 | 2 |
Line 3: | 9 | 6 | 3 | 2 | 1 | 4 | 7 | 5 | 8 |
Line 4: | 2 | 1 | 7 | 5 | 9 | 3 | 4 | 8 | 6 |
Line 5: | 3 | 9 | 8 | 1 | 4 | 6 | 5 | 2 | 7 |
Line 6: | 6 | 5 | 4 | 7 | 2 | 8 | 9 | 1 | 3 |
Line 7: | 5 | 8 | 1 | 4 | 7 | 2 | 6 | 3 | 9 |
Line 8: | 7 | 3 | 9 | 8 | 6 | 5 | 2 | 4 | 1 |
Line 9: | 4 | 2 | 6 | 9 | 3 | 1 | 8 | 7 | 5 |



Lenny
  • 0

#28 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 04 Июль 2010 - 13:52

Level: "Hard" Sudoku from "Metro", NY: :victory:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '304701500'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())	   
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000000070'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '000005803'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '000850109'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '005127300'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '801039000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '602900000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '070000000'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '009608207'
	 , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;

Result:

Line 1: | 3 | 9 | 4 | 7 | 8 | 1 | 5 | 6 | 2 |
Line 2: | 2 | 5 | 8 | 3 | 6 | 4 | 9 | 7 | 1 |
Line 3: | 7 | 1 | 6 | 2 | 9 | 5 | 8 | 4 | 3 |
Line 4: | 4 | 3 | 7 | 8 | 5 | 6 | 1 | 2 | 9 |
Line 5: | 9 | 6 | 5 | 1 | 2 | 7 | 3 | 8 | 4 |
Line 6: | 8 | 2 | 1 | 4 | 3 | 9 | 7 | 5 | 6 |
Line 7: | 6 | 8 | 2 | 9 | 7 | 3 | 4 | 1 | 5 |
Line 8: | 1 | 7 | 3 | 5 | 4 | 2 | 6 | 9 | 8 |
Line 9: | 5 | 4 | 9 | 6 | 1 | 8 | 2 | 3 | 7 |



Lenny
  • 0

#29 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 14 Август 2010 - 13:05

Why Friday's Sudoku ?

Because on Friday "AM" NY usually publish Level-4 Sudoku, any other levels for My Solver like sunflower seeds for elephant.
:victory:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '000000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '020508030'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '030090004'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '800305062'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '000800000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '570904008'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '600050070'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '080701050'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '400000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;

Result:

Line 1: | 7 | 6 | 8 | 1 | 4 | 3 | 2 | 9 | 5 |
Line 2: | 9 | 2 | 4 | 5 | 6 | 8 | 7 | 3 | 1 |
Line 3: | 1 | 3 | 5 | 2 | 9 | 7 | 6 | 8 | 4 |
Line 4: | 8 | 4 | 1 | 3 | 7 | 5 | 9 | 6 | 2 |
Line 5: | 3 | 9 | 2 | 8 | 1 | 6 | 5 | 4 | 7 |
Line 6: | 5 | 7 | 6 | 9 | 2 | 4 | 3 | 1 | 8 |
Line 7: | 6 | 1 | 3 | 4 | 5 | 2 | 8 | 7 | 9 |
Line 8: | 2 | 8 | 9 | 7 | 3 | 1 | 4 | 5 | 6 |
Line 9: | 4 | 5 | 7 | 6 | 8 | 9 | 1 | 2 | 3 |


Lenny
  • 0

#30 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 09 Сентябрь 2010 - 01:21

/* Any time when you add the new sudoku puzzle to the Sd_Source table
you have to use following query, or any query which you want to use for insert
After insert into table, you can select sudoku_solution from SDVW_SOLUTION
*/
:diablo:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '060030008'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000060040'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '029000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '008200100'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '500040006'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '001008700'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '004000380'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '030000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '700090025'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;

Result:

Line 1: | 4 | 6 | 7 | 9 | 3 | 2 | 5 | 1 | 8 |
Line 2: | 1 | 5 | 3 | 8 | 6 | 7 | 2 | 4 | 9 |
Line 3: | 8 | 2 | 9 | 4 | 1 | 5 | 6 | 7 | 3 |
Line 4: | 6 | 9 | 8 | 2 | 7 | 3 | 1 | 5 | 4 |
Line 5: | 5 | 7 | 2 | 1 | 4 | 9 | 8 | 3 | 6 |
Line 6: | 3 | 4 | 1 | 6 | 5 | 8 | 7 | 9 | 2 |
Line 7: | 9 | 1 | 4 | 5 | 2 | 6 | 3 | 8 | 7 |
Line 8: | 2 | 3 | 5 | 7 | 8 | 4 | 9 | 6 | 1 |
Line 9: | 7 | 8 | 6 | 3 | 9 | 1 | 4 | 2 | 5 |



Lenny :good:
  • 0

#31 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 09 Октябрь 2010 - 10:58

The Query found 283576 solutions for this simple input.
The Query had worked for 2 hrs 3min 26 sec:
:diablo:

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '123000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '456000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '789000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '000123000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '000456000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '000789000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '000000123'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '000000456'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '000000789'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;

Results:

Line 1: | 1 | 2 | 3 | 5 | 4 | 7 | 6 | 9 | 8 |
Line 2: | 4 | 5 | 6 | 2 | 9 | 8 | 3 | 1 | 7 |
Line 3: | 7 | 8 | 9 | 3 | 6 | 1 | 2 | 4 | 5 |
Line 4: | 5 | 9 | 7 | 1 | 2 | 3 | 8 | 6 | 4 |
Line 5: | 2 | 3 | 8 | 4 | 5 | 6 | 9 | 7 | 1 |
Line 6: | 6 | 1 | 4 | 7 | 8 | 9 | 5 | 3 | 2 |
Line 7: | 8 | 6 | 5 | 9 | 7 | 4 | 1 | 2 | 3 |
Line 8: | 9 | 7 | 1 | 8 | 3 | 2 | 4 | 5 | 6 |
Line 9: | 3 | 4 | 2 | 6 | 1 | 5 | 7 | 8 | 9 |

Line 1: | 1 | 2 | 3 | 5 | 4 | 7 | 6 | 9 | 8 |
Line 2: | 4 | 5 | 6 | 2 | 9 | 8 | 3 | 1 | 7 |
Line 3: | 7 | 8 | 9 | 3 | 6 | 1 | 2 | 4 | 5 |
Line 4: | 5 | 9 | 7 | 1 | 2 | 3 | 8 | 6 | 4 |
Line 5: | 2 | 3 | 8 | 4 | 5 | 6 | 9 | 7 | 1 |
Line 6: | 6 | 1 | 4 | 7 | 8 | 9 | 5 | 3 | 2 |
Line 7: | 9 | 6 | 5 | 8 | 7 | 4 | 1 | 2 | 3 |
Line 8: | 8 | 7 | 1 | 9 | 3 | 2 | 4 | 5 | 6 |
Line 9: | 3 | 4 | 2 | 6 | 1 | 5 | 7 | 8 | 9 |

.................................................. ..........................
................ 283572 other solutions ............................
.................................................. ..........................

Line 1: | 1 | 2 | 3 | 9 | 7 | 8 | 6 | 4 | 5 |
Line 2: | 4 | 5 | 6 | 3 | 1 | 2 | 9 | 7 | 8 |
Line 3: | 7 | 8 | 9 | 6 | 4 | 5 | 3 | 1 | 2 |
Line 4: | 9 | 7 | 8 | 1 | 2 | 3 | 5 | 6 | 4 |
Line 5: | 3 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 7 |
Line 6: | 6 | 4 | 5 | 7 | 8 | 9 | 2 | 3 | 1 |
Line 7: | 8 | 9 | 4 | 5 | 6 | 7 | 1 | 2 | 3 |
Line 8: | 2 | 3 | 7 | 8 | 9 | 1 | 4 | 5 | 6 |
Line 9: | 5 | 6 | 1 | 2 | 3 | 4 | 7 | 8 | 9 |

Line 1: | 1 | 2 | 3 | 9 | 7 | 8 | 6 | 4 | 5 |
Line 2: | 4 | 5 | 6 | 3 | 1 | 2 | 9 | 7 | 8 |
Line 3: | 7 | 8 | 9 | 6 | 4 | 5 | 3 | 1 | 2 |
Line 4: | 9 | 7 | 8 | 1 | 2 | 3 | 5 | 6 | 4 |
Line 5: | 3 | 1 | 2 | 4 | 5 | 6 | 8 | 9 | 7 |
Line 6: | 6 | 4 | 5 | 7 | 8 | 9 | 2 | 3 | 1 |
Line 7: | 8 | 9 | 7 | 5 | 6 | 4 | 1 | 2 | 3 |
Line 8: | 2 | 3 | 1 | 8 | 9 | 7 | 4 | 5 | 6 |
Line 9: | 5 | 6 | 4 | 2 | 3 | 1 | 7 | 8 | 9 |


Lenny :ok:
  • 0

#32 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 22 Октябрь 2010 - 12:35

High Level Sudoku

/* Any time when you add the new sudoku puzzle to the Sd_Source table
you have to use following query, or any query which you want to use for insert
After insert into table, you can select sudoku_solution from SDVW_SOLUTION
*/

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '700800060'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '000000001'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '508609000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '300700049'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '000000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '980006003'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '000501906'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '600000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '170403005'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;

Result:

Line 1: | 7 | 9 | 3 | 8 | 1 | 4 | 5 | 6 | 2 |
Line 2: | 2 | 4 | 6 | 3 | 5 | 7 | 8 | 9 | 1 |
Line 3: | 5 | 1 | 8 | 6 | 2 | 9 | 3 | 7 | 4 |
Line 4: | 3 | 5 | 1 | 7 | 8 | 2 | 6 | 4 | 9 |
Line 5: | 4 | 6 | 7 | 9 | 3 | 5 | 1 | 2 | 8 |
Line 6: | 9 | 8 | 2 | 1 | 4 | 6 | 7 | 5 | 3 |
Line 7: | 8 | 2 | 4 | 5 | 7 | 1 | 9 | 3 | 6 |
Line 8: | 6 | 3 | 5 | 2 | 9 | 8 | 4 | 1 | 7 |
Line 9: | 1 | 7 | 9 | 4 | 6 | 3 | 2 | 8 | 5 |


  • 0

#33 LKhiger

LKhiger

    Активный участник

  • Members
  • PipPip
  • 76 сообщений
  • ФИО:Леонид Хигер
  • Город:NY

Отправлено 23 Февраль 2011 - 02:17

/*
Any time when you add the new sudoku puzzle to the Sd_Source table
you have to use following query, or any query which
you want to use for insert start numbers of your Sudoku puzzle.
After insertion into the table performed, you can run
select sudoku_solution from SDVW_SOLUTION view.
*/

select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '007206800'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '006500010'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '803000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '000060350'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '070000080'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '052000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '000000703'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '960003100'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '005401900'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);

select sudoku_solution from SDVW_SOLUTION;


Result:

Line 1: | 5 | 1 | 7 | 2 | 9 | 6 | 8 | 3 | 4 |
Line 2: | 4 | 9 | 6 | 5 | 3 | 8 | 2 | 1 | 7 |
Line 3: | 8 | 2 | 3 | 1 | 4 | 7 | 5 | 9 | 6 |
Line 4: | 1 | 4 | 8 | 7 | 6 | 2 | 3 | 5 | 9 |
Line 5: | 6 | 7 | 9 | 3 | 1 | 5 | 4 | 8 | 2 |
Line 6: | 3 | 5 | 2 | 9 | 8 | 4 | 6 | 7 | 1 |
Line 7: | 2 | 8 | 1 | 6 | 5 | 9 | 7 | 4 | 3 |
Line 8: | 9 | 6 | 4 | 8 | 7 | 3 | 1 | 2 | 5 |
Line 9: | 7 | 3 | 5 | 4 | 2 | 1 | 9 | 6 | 8 |


Lenny
  • 0




Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных

Яндекс.Метрика
Реклама на портале