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 characters
const generateHintFunc = (() => { | |
/*let board = Array.from({ length: 9 }, () => Array(9).fill(0)); | |
board[0][0] = 1; | |
board[2][2] = 2; | |
board[0][1] = 3; | |
board[1][0] = 4; | |
*/ | |
let board = [ |
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 characters
(async () => { | |
const requireScript = async src => new Promise((onload, onerror) => document.getElementsByTagName('head')[0].appendChild(Object.assign(document.createElement('script'), {src, onload, onerror}))); | |
const requireDependencies = async deps => Promise.all(deps.filter(url=>performance.getEntriesByName(url, 'resource').length==0).map(requireScript)); | |
await requireDependencies([`https://unpkg.com/[email protected]/dist/twemoji.min.js`]); | |
const style = `img.emoji { height: 1em; width: 1em; margin: 0 .05em 0 .1em; vertical-align: -0.1em; }`; | |
await attachStylesheet(style); | |
const opts = {ext: '.svg', folder: 'svg'}; | |
twemoji.parse(document.querySelector('.controls-info'), opts); | |
const textNodes = document.querySelectorAll('#svgrenderer text'); | |
for(const node of textNodes) if([...node.innerHTML].length === 1 && node.innerHTML.length !== 1) { |
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 characters
(()=>{ | |
const p20 = (()=>{ | |
const F=[1,1,2,6,24,120,720,5040,40320,362880]; | |
const chrLUT = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_~', encNum = n=>chrLUT[n], decNum = c=>chrLUT.indexOf(c); | |
const sizeMap = [9,6,6,6,6,6,6,6,6,6,3,3,3], bitMap = [19,10,10,10,10,10,10,10,10,10,3,3,3], reBitMap = new RegExp(bitMap.map(n=>`(.{${n}})`).join('')); | |
const N9 = [...Array(9).keys()], boxLUT = N9.map(b=>N9.map(n=>(~~(b/3)*27+b*3%9)+~~(n/3)*9+n%3)), rowLUT = N9.map(r=>N9.map(c=>r*9+c)), colLUT = N9.map(c=>N9.map(r=>r*9+c)); | |
const getLc = (perm,s=[...perm.keys()])=>perm.map((n,_,a,i=s.indexOf(n))=>(s.splice(i,1),i)); | |
const fromLc = (code,s=[...code.keys()])=>code.map((i,_,a,e=s[i])=>(s.splice(i, 1),e)); | |
const lcToInt = (lc,l=lc.length)=>lc.reduce((int,n,i)=>int+n*F[l-i-1],0); | |
const intToLc = (int,z=9)=>[...Array(z)].map((_,i,a,c=F[z-i-1],n=Math.floor(int/c))=>(int%=c,n)); |
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 characters
// ==UserScript== | |
// @name SudokuPad Screenshot & Replay Recorder | |
// @namespace https://svencodes.com/ | |
// @version 0.6 | |
// @downloadURL https://gist.github.com/killroy42/5f78381f3994ae5f4e460fd31e7101f0/raw/sudokupad-screenshot&replay.user.js | |
// @updateURL https://gist.github.com/killroy42/5f78381f3994ae5f4e460fd31e7101f0/raw/sudokupad-screenshot&replay.user.js | |
// @supportURL https://svencodes.com | |
// @description Puzzle screenshots and replay GIF recording for Sven's SudokuPad | |
// @author [email protected] | |
// @match https://*.sudokupad.app/* |
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 characters
// ==UserScript== | |
// @name Fpuzzles-Solution | |
// @namespace http://tampermonkey.net/ | |
// @version 1.6 | |
// @description Can input a solution to a puzzle | |
// @author Rangsk | |
// @match https://*.f-puzzles.com/* | |
// @match https://f-puzzles.com/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none |
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 characters
// Exmaples to convert f-puzzles URL to CTC url and extract CTC JSON | |
// Paste in console on ctc app site to load libraries | |
await (async () => { | |
// f-puzzles URL to CTC JSON | |
const fpuzzlesUrlToCtcJson = async url => JSON.parse(PuzzleZipper.unzip(await loadFPuzzle(url.replace(/.*?fpuzzles(.*)/, '$1')))); | |
// f-puzzles URL to CTC URL | |
const fpuzzlesUrlToCtcUrl = async url => `https://sudokupad.app/ctc${loadFPuzzle.compressPuzzle(await loadFPuzzle(url.replace(/.*?fpuzzles(.*)/, '$1')))}`; |
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 characters
Randomly generated Classic, X-Sudoku and Windoku (and mixed) puzzles from a twitter bot: | |
Puzzle source: | |
https://twitter.com/sudokuSolverNL | |
Bookmarklet: | |
javascript:(function()%7B((%5B%2Cv%2Cp%5D)%3D>window.open('%2F%2Fsudokupad.app%2Fscf'%2Bp.replace(%2F.0%7B0%2C5%7D%2Fg%2Cd%3D>String.fromCharCode((d%3D%2Bd%5B0%5D%2B10*d.length)%2B(d<20%3F38%3Ad<46%3F45%3A51)))%2B(%7Bxsudoku%3A'x'%2Cfoursquare%3A'w'%2Cx4square%3A'wx'%7D%5Bv%5D%7C%7C'')))('undefined'!%3Dtypeof angular%3F((%7Bpuzzle%3Ap%2Cvariant%3Av%7D)%3D>%5B%2Cv%2Cp%5D)(angular.element(document.body).scope().queryParams)%3A%5B...document.querySelectorAll('a%5Btarget%3D"_blank"%5D')%5D.map(a%3D>a.textContent.match(%2Fpuzzle%5C%2F(%3F%3A(%5B%5E%5C%2F%5D%2B)%5C%2F)%3F(%5B0-9%5D%2B)%2F)).filter(_%3D>_)%5B0%5D)%7D)() | |
Description: | |
Bookmarklet will find the first tweet on the page with puzzle data and open it on sudokuepad.app. It will also open puzzles on https://sudokusolver.nl/ |
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 characters
/* | |
Basic rules for length measurements: | |
- Same function name as original, but reasonably short | |
- Terminate in ";" | |
- No "var", "const", "let", etc | |
- Same input/output | |
- May make certain assumptions, for example, input is only 0-9, etc | |
*/ |
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 characters
; Ever since I saw TINYFIRE.ASM by Rex Deathstar I desired | |
; to write a fire routine which is not only small but fast | |
; and in full color as well. | |
; | |
; Well, here it is: | |
; - 192 shades of red and yellow set at run-time | |
; - 160 by 100 resolution for higher speed | |
; - limited screen area based at the bottom of the screen | |
; - NO Memory variables used | |
; - LESS THAN 200 bytes! (186 in July 1997) |
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 characters
(function(scope) { | |
var Fcb = Function.call.bind, Apt = Array.prototype; | |
var slice = Fcb(Apt.slice); | |
var concat = Fcb(Apt.concat); | |
var forEach = Fcb(Apt.forEach); | |
//var setT = XS['set_Timeout']; | |
// async | |
var queue = []; | |
function async(callback) { |
NewerOlder