View Single Post
  #120 (permalink)  
Old 03-19-10, 11:16
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Cool Friday Level-4 Sudoku

Friday Level-4 Sudoku < 15 sec >:

Code:
select max(sd_id) from final table
(insert into Sd_Source  
select ifnull(max(sd_id), 0) + 1, 1, '800000000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())       
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 2, '600319000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 3, '000500090'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all 
select ifnull(max(sd_id), 0) + 1, 4, '302000800'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 5, '090205070'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 6, '008000004'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 7, '064003000'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 8, '000920007'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
union all
select ifnull(max(sd_id), 0) + 1, 9, '000000005'
     , ifnull(max(sd_id), 0) + 1, timestamp(generate_unique())
  from Sd_Source 
);
Result:

Quote:
Line 1: | 8 | 4 | 9 | 6 | 7 | 2 | 5 | 1 | 3 |
Line 2: | 6 | 2 | 5 | 3 | 1 | 9 | 7 | 4 | 8 |
Line 3: | 1 | 3 | 7 | 5 | 4 | 8 | 6 | 9 | 2 |
Line 4: | 3 | 1 | 2 | 4 | 9 | 7 | 8 | 5 | 6 |
Line 5: | 4 | 9 | 6 | 2 | 8 | 5 | 3 | 7 | 1 |
Line 6: | 7 | 5 | 8 | 1 | 3 | 6 | 9 | 2 | 4 |
Line 7: | 2 | 6 | 4 | 7 | 5 | 3 | 1 | 8 | 9 |
Line 8: | 5 | 8 | 3 | 9 | 2 | 1 | 4 | 6 | 7 |
Line 9: | 9 | 7 | 1 | 8 | 6 | 4 | 2 | 3 | 5 |
Lenny
Reply With Quote