Skip to content

Instantly share code, notes, and snippets.

randrews / adam_puzzle.js
Created Oct 3, 2021
Adam's puzzle, the puzzle from Adam, the puzzle made specifically by Adam, that puzzle.
View adam_puzzle.js
const toNum = digits => Number.parseInt(digits.join(''))
const valid = digits => toNum(digits) % digits.length === 0
function solve(digits = []) {
if (digits.length === 9) { return toNum([...digits, 0]) }
for(var i = 1; i <= 9; i++) {
if (digits.indexOf(i) >= 0) { continue }
if (valid([...digits, i])) {
const soln = solve([...digits, i])
if (soln) { return soln }
use std::fs;
use std::collections::HashMap;
use serde::Deserialize;
use std::convert::TryFrom;
use std::fmt;
struct Room {
name: String,
description: String,
use std::io;
struct Stack(Vec<f32>);
fn main() -> io::Result<()> {
let stdin = io::stdin();
let mut stack = Stack::new();
let mut line = String::new();
'quit: loop {
View knob.lua
-- Set up an i2c interface. Using a hardware one, on "slow" speed.
-- If it works on slow it should work period.
local iface = i2c.HW0
i2c.setup(iface, 21, 22, i2c.SLOW)
-- Ask the IO expander what's up:
function query()
i2c.start(iface) -- Start a frame
i2c.address(iface, 0x20, i2c.RECEIVER) -- We're reading from 0x20, 1) -- Read one byte
View el.el
(defun ruby-tag (tagname)
(or (equal tagname "%")
(equal tagname "%=")
(equal tagname "%#")))
(defun property-tag (tagname)
(or (equal tagname "a")
(equal tagname "div")
(equal tagname "img")
(equal tagname "span")))
View el.el
(defun kill-all-buffers ()
(mapcar (lambda (b)
;; Don't blow away scratch, for reasons, and also because doing so screws up
;; default-directory, setting it to the last thing we tab-completed (!?). This
;; causes annoyance when you try to set a path in the minibuffer later, making
;; it try to cd to that directory and then complaining that it's not there.
(if (not (string= (buffer-name b) "*scratch*"))
(kill-buffer b)))
View wordy.js
function guess_fits(guess, clue) {
const guess_freq = frequency(guess)
const clue_freq = frequency(clue)
for (const ltr in clue_freq) {
if (ltr === '?') { continue }
if (!guess_freq[ltr]) { return false } // Clue has a letter the guess doesn't
if (guess_freq[ltr] < clue_freq[ltr]) { return false } // Clue has more of these than guess
guess_freq[ltr] -= clue_freq[ltr]
View mode13.cpp
// This will build and run on Borland Turbo C++ with the
// "small" memory model. The declaration of `screen` may
// need to be changed if you use a larger memory model.
// It also may need some changes to build under DJGPP;
// TC++ is... let's say "unique."
#include <conio.h>
#include <dos.h>
#include <mem.h>
View 4th.asm
.org 0x400 ; start here
jmp start
; Print a string of a certain length
nprint: ; ( addr len -- )
store24 nprint_len
push 0
store24 nprint_off
View status.txt
Ross' status for Winterfest '21:
Thursday evening 2/18:
- Power: been on since last night, supposed to start rolling again at some point but hasn't.
- Internet: tethering to my phone. AT&T's tower is down, I think, I'm getting terrible signal from them through the dish. Google will start throttling me at 22 gigs and I've already used 5 gigs.
- Propane: This morning I got the tank refilled, this is now fine.
- Water: pipes are still burst, plumber knows about it but I can't get him on the phone, this probably will not be fixed until next week at the earliest.
- Food: I have some food. Without water I can't do any dishes. Restaurants are still almost all closed.