Skip to content

Instantly share code, notes, and snippets.

View dcbriccetti's full-sized avatar

Dave Briccetti dcbriccetti

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dcbriccetti
dcbriccetti / relays.ino
Created March 25, 2022 03:12
Fun with Relays
#include <Arduino.h>
int pins[] = {2, 3, 4, 5};
int numPins = sizeof pins / sizeof pins[0];
void setup() {
for (int i = 0; i < numPins; ++i)
pinMode(pins[i], OUTPUT);
}
for n in range(10):
print('hello')
print('world!')
for n in range(1, 11):
print(n)
# Display the integers from -2 to 2
for n in range(-2, 3):
print(n)
for n in range(1, 11):
print(n)
# Display -5 to +5
for n in range(-5, 6, 1):
print(n)
# Display even numbers from -2 to 6
# Experiment with that 3rd argument
import pathlib
# Really old way
wf2 = open('words.txt')
lines = wf2.readlines()
wf2.close()
# Old way, closes file automatically
with open('words.txt') as words_file:
package examples.maps;
import java.util.Arrays;
import java.util.stream.IntStream;
public class HashMap<K, V> {
public static class Bucket<K, V> {
public static class KeyAndValue<K, V> {
public K key;
public V value;
package com.davebsoft
import scala.collection.mutable
import scala.io.Source
import scala.util.Using
case class FieldRanges(line: String) {
private val re = "([\\w ]+): (\\d+)-(\\d+) or (\\d+)-(\\d+)".r
private val m = re.findFirstMatchIn(line).get
val name: String = m.group(1)
@dcbriccetti
dcbriccetti / aoc14.rs
Created December 16, 2020 00:29
Advent of Code 2020 Day 14 Part 1 Solution in Rust
use std::collections::HashMap;
use regex::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let mut memory: HashMap<u64, u64> = HashMap::new();
let mut or_mask: u64 = 0;
let mut and_mask: u64 = 0;
let rx_mask = Regex::new(r"mask = ([X10]{36})").unwrap();
public class HasTeen {
public static boolean hasTeen(int a, int b, int c) {
return (a >= 13 && a <= 19) || (b >= 13 && b <= 19) || (c >= 13 && c <= 19);
}
public static void main(String[] args) {
assert hasTeen(13, 20, 10);
assert hasTeen(20, 19, 10);
assert hasTeen(20, 10, 13);
assert !hasTeen(20, 10, 10);
void setup() {
size(1024, 768, P2D);
background(0);
}
void draw () {
stroke(255, 0, 0);
line(0, 0, mouseX, mouseY);
}