Last active
July 20, 2022 11:45
Revisions
-
greymd revised this gist
Jan 26, 2020 . 1 changed file with 24 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,27 @@ ## https://twitter.com/hid_tori/status/1221415737375412224 ## https://twitter.com/hid_tori/status/1221415770795728898 cat sudoku | node -e 'console.log((f=>(u=>u(u))(x=>f(y=>x(x)(y))))(f=>a=>((a,b)=>a.map(x=>x[3]).includes("*")?f(a.map(x=>x[3]!=="*"?x:[...x.slice(0,4),[...Array(9)].map((v,i)=>String(i+1)).filter(y=>!b[0][x[0]].concat(b[1][x[1]]).concat(b[2][x[2]]).includes(y))]).map(x=>x.length===4?x:x[4].length===1?[x[0],x[1],x[2],x[4][0]]:x.slice(0,4))):a)(a,a.reduce((x,y)=>(x[0][y[0]].push(y[3]),x[1][y[1]].push(y[3]),x[2][y[2]].push(y[3]),x),[...Array(3)].map(x=>[...Array(9)].map(y=>[]))).map(x=>x.map(y=>y.filter(z=>z!=="*")))))(require("fs").readFileSync("/dev/stdin","utf8").trim().split("\n").map((v,i)=>[i,v]).map(x=>[x[0],[...x[1].split("").entries()]]).flatMap(x=>x[1].map(y=>[x[0],...y])).map(x=>[x[0],x[1],Math.floor(x[0]/3)%3*3+Math.floor(x[1]/3),x[2]])).reduce((x,y)=>(x[y[0]].push(y[3]),x),[...Array(9)].map(x=>[])).map(x=>x.join("")).join("\n"))' ## Example: # $ cat sudoku # ***8**15* # 9***2**** # **4*9*3** # 6*34****7 # *4*75**2* # **8236*91 # 2815479** # 53*98*274 # **736*815 # # $ cat sudoku | ... # 362874159 # 915623748 # 874195362 # 623419587 # 149758623 # 758236491 # 281547936 # 536981274 # 497362815 -
greymd revised this gist
Jan 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@ ## https://twitter.com/hid_tori/status/1221415737375412224 ## https://twitter.com/hid_tori/status/1221415770795728898 cat sudoku | node -e 'console.log((f=>(u=>u(u))(x=>f(y=>x(x)(y))))(f=>a=>((a,b)=>a.map(x=>x[3]).includes("*")?f(a.map(x=>x[3]!=="*"?x:[...x.slice(0,4),[...Array(9)].map((v,i)=>String(i+1)).filter(y=>!b[0][x[0]].concat(b[1][x[1]]).concat(b[2][x[2]]).includes(y))]).map(x=>x.length===4?x:x[4].length===1?[x[0],x[1],x[2],x[4][0]]:x.slice(0,4))):a)(a,a.reduce((x,y)=>(x[0][y[0]].push(y[3]),x[1][y[1]].push(y[3]),x[2][y[2]].push(y[3]),x),[...Array(3)].map(x=>[...Array(9)].map(y=>[]))).map(x=>x.map(y=>y.filter(z=>z!=="*")))))(require("fs").readFileSync("/dev/stdin","utf8").trim().split("\n").map((v,i)=>[i,v]).map(x=>[x[0],[...x[1].split("").entries()]]).flatMap(x=>x[1].map(y=>[x[0],...y])).map(x=>[x[0],x[1],Math.floor(x[0]/3)%3*3+Math.floor(x[1]/3),x[2]])).reduce((x,y)=>(x[y[0]].push(y[3]),x),[...Array(9)].map(x=>[])).map(x=>x.join("")).join("\n"))' -
greymd revised this gist
Jan 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,4 @@ ## https://twitter.com/hid_tori/status/1221415737375412224 ## https://twitter.com/hid_tori/status/1221415770795728898 cat sudoku | node -e 'console.log((f=>(u=>u(u))(x=>f(y=>x(x)(y))))(f=>a=>((a,b)=>http://a.map(x=>x[3]).includes("*")?f(http://a.map(x=>x[3]!=="*"?x:[...x.slice(0,4),[...Array(9)].map((v,i)=>String(i+1)).filter(y=>!b[0][x[0]].concat(b[1][x[1]]).concat(b[2][x[2]]).includes(y))]).map(x=>x.length===4?x:x[4].length===1?[x[0],x[1],x[2],x[4][0]]:x.slice(0,4))):a)(a,a.reduce((x,y)=>(x[0][y[0]].push(y[3]),x[1][y[1]].push(y[3]),x[2][y[2]].push(y[3]),x),[...Array(3)].map(x=>[...Array(9)].map(y=>[]))).map(x=>x.map(y=>y.filter(z=>z!=="*")))))(require("fs").readFileSync("/dev/stdin","utf8").trim().split("\n").map((v,i)=>[i,v]).map(x=>[x[0],[...x[1].split("").entries()]]).flatMap(x=>x[1].map(y=>[x[0],...y])).map(x=>[x[0],x[1],Math.floor(x[0]/3)%3*3+Math.floor(x[1]/3),x[2]])).reduce((x,y)=>(x[y[0]].push(y[3]),x),[...Array(9)].map(x=>[])).map(x=>x.join("")).join("\n"))' -
greymd revised this gist
Jan 26, 2020 . No changes.There are no files selected for viewing
-
greymd created this gist
Jan 26, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ## original: ## https://twitter.com/hid_tori/status/1221415626465349635 ## https://twitter.com/hid_tori/status/1221415683289780225 ## https://twitter.com/hid_tori/status/1221415737375412224 ## https://twitter.com/hid_tori/status/1221415770795728898 cat sudoku | node -e 'console.log((f=>(u=>u(u))(x=>f(y=>x(x)(y))))(f=>a=>((a,b)=>http://a.map(x=>x[3]).includes("*")?f(http://a.map(x=>x[3]!=="*"?x:[...x.slice(0,4),[...Array(9)].map((v,i)=>String(i+1)).filter(y=>!b[0][x[0]].concat(b[1][x[1]]).concat(b[2][x[2]]).includes(y))]).map(x=>x.length===4?x:x[4].length===1?[x[0],x[1],x[2],x[4][0]]:x.slice(0,4))):a)(a,a.reduce((x,y)=>(x[0][y[0]].push(y[3]),x[1][y[1]].push(y[3]),x[2][y[2]].push(y[3]),x),[...Array(3)].map(x=>[...Array(9)].map(y=>[]))).map(x=>http://x.map(y=>y.filter(z=>z!=="*")))))(require("fs").readFileSync("/dev/stdin","utf8").trim().split("\n").map((v,i)=>[i,v]).map(x=>[x[0],[...x[1].split("").entries()]]).flatMap(x=>x[1].map(y=>[x[0],...y])).map(x=>[x[0],x[1],Math.floor(x[0]/3)%3*3+Math.floor(x[1]/3),x[2]])).reduce((x,y)=>(x[y[0]].push(y[3]),x),[...Array(9)].map(x=>[])).map(x=>x.join("")).join("\n"))'