Skip to content

Instantly share code, notes, and snippets.

@oshea00
oshea00 / miu.py
Created November 5, 2023 17:18
MIU prover from Escher, Godel, Bach
import sys
def addU(s):
if s[-1] == 'I':
return [f'{s}U']
else:
return []
def dupMx(s):
if s[0] == 'M':
Parity of 0123 permutations:
- 4! = 24 sequences
Rules:
- a shift left changes parity
- sequence reversal is the same parity
- single swap changes parity
0123 even 3210 even
1230 odd 0321 odd
# Type declaration
variable "users" {
type = map(object({
role = string
}))
default = {
"mike" = { "role" = "admin" }
"steve" = { "role" = "user" }
"joe" = { "role" = "admin" }
}
use std::fmt;
use std::cmp::Ordering;
#[derive(Debug)]
struct Trade {
shares: f64,
price: f64
}
impl Trade {
use std::{io::{self, Write}, str::FromStr};
fn main() {
let name = input("What's your name? ");
let number: f64 = input_num("What's your favorite number? ");
println!("{name}'s favorite number is {number:.2}.");
}
fn input(prompt: &str) -> String {
let mut line = String::new();
@oshea00
oshea00 / quantaexoplanetpuzzle.cs
Created March 25, 2023 19:17
Calculates hyperspace jump paths for the Quanta magazine exoplanet puzzle
const int HOMEPLANET = 9;
const int MINTRIP = 5;
void Main()
{
var exoplanets = new List<int> { 3,4,8,4,7,8,6,2 };
var jumps = getFirstTwo(exoplanets);
var tripsHome = new Dictionary<string,List<int>>();
while (jumps.Count > 0)
@oshea00
oshea00 / openLifts.ah
Created April 18, 2022 00:25
jq example using AWS partiQL
#!/bin/bash
aws dynamodb execute-statement --statement \
"SELECT * FROM SkiLifts" | \
# Json Output
#jq -c '.Items[] | select(.LiftStatus.S=="Open") | { Lift:.Lift.S, LiftStatus:.LiftStatus.S }'
# CSV Values Output
jq -r -c '.Items[] | select(.LiftStatus.S=="Open") | [.Lift.S, .LiftStatus.S ] | @csv'
@oshea00
oshea00 / UpdateFile.ps1
Created April 19, 2021 02:59
Update an existing file - see comments
# This script assumes it is being run from powershell "run as administrator" prompt.
#
# The script will check if it has already been run (FileBackupTo already exists),
# otherwise it will backup the target FileToUpdate and replace it with the $NewFile.
# It sets the updated file to "read only"
# The following paths must be updated as needed:
# The current assumption is $NewFile is in the same directory as this script,
$FileToUpdate = "C:\Program Files\ATT Metrology\LTASWpf\LTAS30Block20.xit64"
provider "aws" {
region = "us-west-2"
}
data "aws_canonical_user_id" "current_user" {}
resource "aws_s3_bucket" "deployment_bucket" {
bucket = "limpidfox-lambdas-dev"
acl = "private"
server_side_encryption_configuration {
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
public class Graph<T> {
Dictionary<T,List<T>> vertices;
Dictionary<T,bool> marked;
Dictionary<T,int> componentIds;
Dictionary<T,bool> color;