This file contains 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
# http://www.logicgamesonline.com/lightsout/daily.php | |
def popcount(x) | |
b = 0 | |
while x > 0 | |
x &= x - 1 | |
b += 1 | |
end | |
b | |
end |
This file contains 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
# https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/signpost.html | |
# This should work on every single puzzle generated, | |
# because this solver uses the same reasoning as that used by the generator to check for solvability: | |
# check for cells with only a single possible successor or a single possible predecessor. | |
# | |
# There are other techniques that can be used: | |
# * Search with distance > 1, for example check which cell will eventually allow 24 to connect to 27. | |
# * Naked groups and hidden groups: | |
# * If N preds have N succs as their only possible succs, discard all other possible preds from those succs | |
# * If N succs have N preds as their only possible preds, discard all other possible succs from those preds |
This file contains 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
# https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/towers.html | |
# Should be able to do Hard, | |
# which is listed in latin.c as diff_set_0, | |
# handled by checking all permutations for all rows + columns, | |
# and can do Extreme, | |
# which is listed in latin.c as both diff_set_1 and diff_forcing, | |
# which are implemented as xwing and forcing_chain | |
# | |
# https://www.janko.at/Raetsel/Wolkenkratzer/index.htm | |
# Have not yet determined whether any puzzle on janko.at actually has diagonal labels, |
This file contains 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
approach: | |
it takes 0 jobs to print 0. | |
for each attendee count from 1 up to n: | |
for each square not larger than attendee count: | |
we can do it in 1 + jobs[attendee_count - square] | |
take the smallest of the above possibilities | |
time: | |
proportional to n * sqrt(n) |
This file contains 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
files, hints = ARGV.partition { |x| File.file?(x) } | |
hint = hints.join | |
dict_words = {} | |
hints = (files.empty? ? File.open('words_alpha.txt', ?r) : ARGF).each_line.map { |word| | |
dict_words[word.chomp.downcase] = true | |
} | |
non_letters = hint.chars.reject { |c| (?a..?z).cover?(c) }.uniq |
This file contains 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
VERBOSE = ARGV.delete('-v') | |
def lc4(key) | |
keyed_cipher('#_23456789abcdefghijklmnopqrstuvwxyz', key, marker_moves: true) | |
end | |
def ls47(key) | |
keyed_cipher("_abcdefghijklmnopqrstuvwxyz.0123456789,-+*/:?!'()", key, marker_moves: false) | |
end |
This file contains 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
require 'net/http' | |
require 'json' | |
require 'set' | |
require 'yaml' | |
REPEATS = true | |
LEVEL = 6 | |
test_all = ARGV.delete('-a') |
This file contains 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
alias Elt = Int32 | |
alias Count = Int32 | |
SPOTS = 4 | |
COLOURS = 6 | |
REPEATS = true | |
OPT = true | |
INTERACTIVE = ARGV.includes?("-i") || ARGV.includes?("--interactive") |
This file contains 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
1000 | |
5668137592934713102441324678542073232628021211352952834657990662080563989156194797022212756047286793446774589470677745088211552869413620590162331251809444529147879775001431595233001085455497658846273053988435137758831824174489016555551028952432382770343365256475301053130655210572847728724711590986746488551898866722597 | |
10000 | |
302669529812541170422608884660770639502536277197232986875137298025407684442895444028081551314183007929910187728205214188180336420042946217586843869909595752045864386118547444229863779633877539380779777189206033374459242954935816500440170965196410365414059489031105815025057687540084623895989944745185216200007560377828236971085502033017748749836090693164795523436819777444319230491066901927876983503441688873720350325322027957147468352440461421415495530179964036198655325256234685976439258185029842576578151300809548942649999578088645184924924030509833459994139919002177456748428928269786399145831490634691218139368719684999928952102474893451058277888843495254783378609260731391089662750735222 |
This file contains 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
0: 2 | |
1: 12 | |
3: 4 | |
5: 8 | |
7: 10 | |
9: 8 | |
11: 18 | |
13: 8 | |
15: 8 | |
17: 33 |
NewerOlder