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
use std::collections::VecDeque; | |
use std::env; | |
use std::fmt::{Display, Formatter}; | |
use std::ops::{Index, IndexMut}; | |
use rand::RngCore; | |
use crate::Dir::*; | |
fn main() { | |
let args: Vec<_> = env::args().collect(); | |
let dimension = if args.len() < 2 { |
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
use std::env; | |
use std::fmt::{Display, Formatter}; | |
use std::ops::{Index, IndexMut}; | |
use rand::RngCore; // cargo add rand | |
use crate::Dir::*; | |
fn main() { | |
let args: Vec<_> = env::args().collect(); | |
let dimension = if args.len() < 2 { | |
println!("No dimension, defaulting to 20"); |
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
use std::arch::aarch64::float32x4x4_t; | |
use std::f32::consts::PI; | |
use std::thread::sleep; | |
use std::time::Duration; | |
use pixels::{Pixels, PixelsBuilder}; | |
use pixels::wgpu::TextureFormat; | |
use raqote::{DrawOptions, DrawTarget, Path, PathBuilder, SolidSource, Source}; | |
use winit::dpi::LogicalSize; | |
use winit::event::{Event, WindowEvent}; | |
use winit::event_loop::{ControlFlow, EventLoop}; |
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
use std::f32::consts::PI; | |
use pixels::{Pixels, PixelsBuilder}; | |
use pixels::wgpu::TextureFormat; | |
use raqote::{DrawOptions, DrawTarget, Path, PathBuilder, SolidSource, Source}; | |
use winit::dpi::LogicalSize; | |
use winit::event::{Event, WindowEvent}; | |
use winit::event_loop::{ControlFlow, EventLoop}; | |
use winit::window::WindowBuilder; | |
fn main() -> ! { |
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
Three arguments: dest, src, mode | |
Mode is a word of three bytes, separated into three one-byte sub-args | |
The sub-args are: | |
- High byte: mode arg | |
- Mid / low bytes are a 16-bit limit arg | |
- (Some end modes only use the low byte) | |
Mode arg is three fields: | |
- how the src is interpreted / incremented |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>You Have A Sword!</title> | |
<script type="text/javascript"> | |
const $ = s => document.querySelector(s) | |
const $$ = s => document.querySelectorAll(s) |
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
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 } |
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
use std::fs; | |
use std::collections::HashMap; | |
use serde::Deserialize; | |
use std::convert::TryFrom; | |
use std::fmt; | |
#[derive(Deserialize)] | |
struct Room { | |
name: String, | |
description: String, |
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
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 { |
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
-- 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 | |
i2c.read(iface, 1) -- Read one byte |
NewerOlder