Sudoku game: Jack's notes

using suduku_4.txt as an example

bare_tex_output()

this is an easy one, only convert suduku_4.txt to tex file.


image.png

forced_tex_output()

look at box 1 first:

  • c(4, 1) force that 1 can not be in row 1
  • c(8, 2) force that 1 can not be in row 2
  • c(3, 5) force that 1 can not be in column 3

therefore, in box 1, 1 only can be in c(2, 3)


image.png

similarly, we can fill 9 in c(2, 6)


image.png

marked_tex_output()

this is quite straightforward, taking c(1,1) for example.

  • column 1: 3, 9, 5
  • row 1: 1
  • box 1: 1, 3, 9

therefore , c(1,1) can only be fill with numbers other than (1, 3, 5, 9), which are (2, 4, 6, 7, 8)


image.png

worded_tex_output()

1. we can find preemptive set in column:

  • there are 3 cells, calculate their union: c(3, 4) U c(8, 4) U c(9, 4) = (2, 3, 6)
  • the number of integers in set (2, 3, 6) is 3, which is equal to the number of cells

therefore, c(3, 4), c(8, 4) , c(9, 4) is a preemptive set

image.png

we can cross (2, 3, 6) in other cells in column 4


image.png

2. we can find preemptive set in box:

  • there are 3 cells in box 3, calculate their union: c(1, 7) U c(9, 1) U c(9, 2) = (1, 2, 6)
  • the number of integers in set (1, 2, 6) is 3, which is equal to the number of cells

therefore, c(1, 7), c(9, 1) , c(9, 2) is a preemptive set

image.png

we can cross (1, 2, 6) in other cells in box 3

image.png

3. we can find preemptive set in row:

which is similar to finding preemptive set in column and box

4. combine with other method:

Every time after we use preemptive set to change the table, we should use the methods which described in forced_tex_output() and marked_tex_output() again.
After that, we should try to find preemptive again, until nothing need to be changed.

All preemptive set in sudoku_3:

there is no preemptive set in sudoku_3

All preemptive set in sudoku_4:

which may different depend on your algrithm

preemptive set: {2, 3, 6} on column 4 , [[9, 4], [3, 4], [8, 4]]
preemptive set: {1, 2, 6, 9} on column 9 , [[1, 9], [2, 9], [6, 9], [7, 9]]
preemptive set: {1, 2, 6} on box 3 , [[1, 7], [2, 9], [1, 9]]
preemptive set: {1, 9} on box 5 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 7, 8} on box 5 , [[6, 5], [6, 6], [5, 6], [5, 5], [4, 5], [4, 6]]
preemptive set: {1, 3, 4, 9} on box 9 , [[7, 8], [7, 9], [8, 8], [9, 8]]
preemptive set: {6, 7} on column 7 , [[9, 7], [8, 7]]
preemptive set: {1, 9} on box 5 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 7, 8} on box 5 , [[6, 5], [6, 6], [5, 6], [5, 5], [4, 5], [4, 6]]
preemptive set: {6, 7} on box 9 , [[9, 7], [8, 7]]
preemptive set: {1, 3, 4, 9} on box 9 , [[7, 8], [7, 9], [8, 8], [9, 8]]
preemptive set: {8, 2} on column 3 , [[3, 3], [4, 3]]
preemptive set: {3, 4, 5} on column 3 , [[5, 3], [8, 3], [9, 3]]
preemptive set: {1, 9} on column 4 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 6} on column 4 , [[3, 4], [8, 4], [9, 4]]
preemptive set: {2, 6} on column 9 , [[1, 9], [2, 9]]
preemptive set: {1, 9} on box 5 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 7, 8} on box 5 , [[6, 5], [6, 6], [5, 6], [5, 5], [4, 5], [4, 6]]
preemptive set: {3, 4, 5, 9} on box 7 , [[7, 2], [9, 3], [7, 1], [8, 3]]
preemptive set: {2, 3, 4, 5, 7, 9} on box 7 , [[9, 3], [9, 2], [7, 2], [9, 1], [7, 1], [8, 3]]
preemptive set: {6, 7} on box 9 , [[9, 7], [8, 7]]
preemptive set: {1, 3, 4, 9} on box 9 , [[7, 8], [7, 9], [8, 8], [9, 8]]
preemptive set: {1, 9} on row 6 , [[6, 9], [6, 4]]
preemptive set: {2, 3, 4, 5} on row 6 , [[6, 1], [6, 2], [6, 5], [6, 6]]
preemptive set: {3, 4} on row 8 , [[8, 3], [8, 8]]
preemptive set: {2, 6, 7} on row 8 , [[8, 4], [8, 6], [8, 7]]
preemptive set: {2, 3, 4, 6} on row 8 , [[8, 3], [8, 4], [8, 6], [8, 8]]
preemptive set: {2, 7} on row 9 , [[9, 1], [9, 2]]
preemptive set: {8, 2} on column 3 , [[3, 3], [4, 3]]
preemptive set: {3, 4, 5} on column 3 , [[5, 3], [8, 3], [9, 3]]
preemptive set: {1, 9} on column 4 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 7} on column 6 , [[3, 6], [4, 6], [5, 6], [6, 6], [8, 6]]
preemptive set: {2, 6} on column 9 , [[1, 9], [2, 9]]
preemptive set: {1, 9} on column 9 , [[6, 9], [7, 9]]
preemptive set: {2, 6, 7, 8} on box 1 , [[1, 1], [3, 2], [3, 1], [3, 3]]
preemptive set: {2, 6} on box 2 , [[3, 4], [2, 5]]
preemptive set: {1, 9} on box 5 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 7, 8} on box 5 , [[6, 5], [6, 6], [5, 6], [5, 5], [4, 5], [4, 6]]
preemptive set: {2, 7} on box 7 , [[9, 2], [9, 1]]
preemptive set: {3, 4, 5, 9} on box 7 , [[9, 3], [7, 2], [7, 1], [8, 3]]
preemptive set: {4, 5} on box 8 , [[7, 5], [9, 5]]
preemptive set: {2, 6} on box 8 , [[8, 6], [8, 4]]
preemptive set: {2, 6, 8, 9} on row 4 , [[4, 2], [4, 3], [4, 5], [4, 8]]
preemptive set: {1, 9} on row 6 , [[6, 9], [6, 4]]
preemptive set: {2, 3, 4, 5} on row 6 , [[6, 1], [6, 2], [6, 5], [6, 6]]
preemptive set: {3, 4} on row 8 , [[8, 3], [8, 8]]
preemptive set: {2, 6} on row 8 , [[8, 4], [8, 6]]
preemptive set: {2, 7} on row 9 , [[9, 1], [9, 2]]
preemptive set: {4, 5} on row 9 , [[9, 3], [9, 5]]
preemptive set: {2, 4, 5, 7} on row 9 , [[9, 1], [9, 2], [9, 3], [9, 5]]
preemptive set: {2, 6, 7} on column 1 , [[1, 1], [3, 1], [9, 1]]
preemptive set: {3, 4, 5, 9} on column 1 , [[2, 1], [5, 1], [6, 1], [7, 1]]
preemptive set: {8, 2} on column 3 , [[3, 3], [4, 3]]
preemptive set: {3, 4, 5} on column 3 , [[5, 3], [8, 3], [9, 3]]
preemptive set: {2, 6} on column 4 , [[3, 4], [8, 4]]
preemptive set: {1, 9} on column 4 , [[5, 4], [6, 4]]
preemptive set: {4, 5} on column 5 , [[9, 5], [7, 5]]
preemptive set: {2, 3, 6, 8} on column 5 , [[2, 5], [4, 5], [5, 5], [6, 5]]
preemptive set: {2, 6} on column 9 , [[1, 9], [2, 9]]
preemptive set: {4, 5} on box 1 , [[2, 1], [2, 2]]
preemptive set: {2, 6, 7, 8} on box 1 , [[1, 1], [3, 2], [3, 1], [3, 3]]
preemptive set: {1, 9} on box 5 , [[5, 4], [6, 4]]
preemptive set: {2, 3, 5, 6, 8} on box 5 , [[6, 5], [6, 6], [5, 6], [5, 5], [4, 5]]
preemptive set: {2, 7} on box 7 , [[9, 2], [9, 1]]
preemptive set: {3, 4, 5, 9} on box 7 , [[9, 3], [7, 2], [7, 1], [8, 3]]
preemptive set: {4, 5} on box 8 , [[7, 5], [9, 5]]
preemptive set: {2, 6} on box 8 , [[8, 6], [8, 4]]
preemptive set: {3, 4, 5} on column 1 , [[2, 1], [5, 1], [6, 1]]
preemptive set: {4, 5} on column 5 , [[9, 5], [7, 5]]
preemptive set: {2, 5} on column 6 , [[5, 6], [6, 6]]
preemptive set: {4, 5} on box 1 , [[2, 1], [2, 2]]
preemptive set: {3, 5} on box 4 , [[5, 3], [5, 1]]
preemptive set: {2, 5} on box 5 , [[5, 6], [6, 6]]
preemptive set: {4, 5} on box 7 , [[9, 3], [7, 2]]
preemptive set: {2, 7} on box 7 , [[9, 2], [9, 1]]
preemptive set: {2, 4, 5, 7} on box 7 , [[9, 2], [7, 2], [9, 1], [9, 3]]
preemptive set: {4, 5} on row 7 , [[7, 2], [7, 5]]
preemptive set: {4, 5} on row 9 , [[9, 3], [9, 5]]

All preemptive set in sudoku_5:

preemptive set: {4, 7} on row 2 , [[2, 1], [2, 9]]
preemptive set: {2, 4, 9} on row 4 , [[4, 4], [4, 6], [4, 7]]
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末拿霉,一起剝皮案震驚了整個濱河市奖磁,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌腐螟,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,290評論 6 491
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件徙歼,死亡現(xiàn)場離奇詭異王暗,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)殉簸,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,107評論 2 385
  • 文/潘曉璐 我一進(jìn)店門闰集,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人般卑,你說我怎么就攤上這事武鲁。” “怎么了蝠检?”我有些...
    開封第一講書人閱讀 156,872評論 0 347
  • 文/不壞的土叔 我叫張陵沐鼠,是天一觀的道長。 經(jīng)常有香客問我蝇率,道長迟杂,這世上最難降的妖魔是什么刽沾? 我笑而不...
    開封第一講書人閱讀 56,415評論 1 283
  • 正文 為了忘掉前任,我火速辦了婚禮排拷,結(jié)果婚禮上侧漓,老公的妹妹穿的比我還像新娘。我一直安慰自己监氢,他們只是感情好布蔗,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,453評論 6 385
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著浪腐,像睡著了一般纵揍。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上议街,一...
    開封第一講書人閱讀 49,784評論 1 290
  • 那天泽谨,我揣著相機(jī)與錄音,去河邊找鬼特漩。 笑死吧雹,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的涂身。 我是一名探鬼主播雄卷,決...
    沈念sama閱讀 38,927評論 3 406
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼蛤售!你這毒婦竟也來了丁鹉?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,691評論 0 266
  • 序言:老撾萬榮一對情侶失蹤悴能,失蹤者是張志新(化名)和其女友劉穎揣钦,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體搜骡,經(jīng)...
    沈念sama閱讀 44,137評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡拂盯,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,472評論 2 326
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了记靡。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片谈竿。...
    茶點(diǎn)故事閱讀 38,622評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖摸吠,靈堂內(nèi)的尸體忽然破棺而出空凸,到底是詐尸還是另有隱情,我是刑警寧澤寸痢,帶...
    沈念sama閱讀 34,289評論 4 329
  • 正文 年R本政府宣布呀洲,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏道逗。R本人自食惡果不足惜兵罢,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,887評論 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望滓窍。 院中可真熱鬧卖词,春花似錦、人聲如沸吏夯。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,741評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽噪生。三九已至裆赵,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間跺嗽,已是汗流浹背战授。 一陣腳步聲響...
    開封第一講書人閱讀 31,977評論 1 265
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留抛蚁,地道東北人陈醒。 一個月前我還...
    沈念sama閱讀 46,316評論 2 360
  • 正文 我出身青樓惕橙,卻偏偏與公主長得像瞧甩,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子弥鹦,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,490評論 2 348

推薦閱讀更多精彩內(nèi)容