Skip to content

Instantly share code, notes, and snippets.

View hellow554's full-sized avatar
💭
/(°□°)/ ︵ ┻━┻

Marcel Hellwig hellow554

💭
/(°□°)/ ︵ ┻━┻
  • Hamburg, Germany
View GitHub Profile
import React, { useMemo } from "react";
import ReactDOM from "react-dom";
import useLocalStorage from "@rehooks/local-storage";
import { grams, kilograms } from "@buge/ts-units/mass";
function App() {
const [value, setValue, deleteValue] = useLocalStorage("hello", kilograms(0));
const [v1, v2] = useMemo(
() => [value.amount ?? "<null>", value.unit?.symbol ?? "<null>"],
[value]
use std::cmp::Ordering;
const INPUT: &str = include_str!("../input");
type Num = u64;
fn check_it(arr: &[Num], number: Num) -> bool {
arr.iter()
.enumerate()
.flat_map(|(i, a)| arr[i + 1..].iter().map(move |b| (a, b)))
use std::collections::BTreeSet;
const INPUT: &str = include_str!("../input");
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Opcode {
Acc,
Jmp,
Nop,
}
#![feature(or_insert_with_key, option_unwrap_none)]
use std::collections::HashMap;
use petgraph::graph::{DiGraph, NodeIndex};
use petgraph::visit::{self, IntoNeighborsDirected, IntoNodeIdentifiers};
use petgraph::Direction;
use regex::Regex;
const INPUT: &str = include_str!("../input");
use std::collections::HashMap;
use petgraph::{algo, Directed, Direction, Graph, Undirected};
const INPUT: &str = include_str!("../input");
type MyGraph = Graph<String, (), Directed>;
type MyUnGraph = Graph<String, (), Undirected>;
fn parse_directed(s: &str) -> MyGraph {
@hellow554
hellow554 / day05.rs
Last active December 6, 2019 07:19
day05
use intcode::IntCode;
const INPUT: &str = include_str!("../input");
fn parse(s: &str) -> Vec<i32> {
s.split(',').map(|x| x.parse().unwrap()).collect()
}
fn main() {
let input = parse(INPUT);
use std::mem;
use std::ops::Range;
const INPUT: &str = "307237-769058";
struct ExtractConsecutive<'a> {
string: &'a str,
}
impl<'a> Iterator for ExtractConsecutive<'a> {
use std::collections::{HashMap, HashSet};
const INPUT: &str = include_str!("../input");
#[derive(Clone)]
enum Movement {
Up,
Down,
Left,
Right,
const INPUT: &str = include_str!("../input");
fn parse(s: &str) -> Vec<u32> {
s.split(',').map(|x| x.parse().unwrap()).collect()
}
fn solve_a(memory: &mut [u32]) {
const OPS: &[fn(u32, u32) -> u32] = &[
|_, _| panic!("unsupported opcode"),
|a, b| a + b,
@hellow554
hellow554 / day01.rs
Last active December 2, 2019 11:54
2019
const INPUT: &str = include_str!("../input");
fn parse(s: &str) -> Vec<u32> {
s.lines().map(|x| x.parse().unwrap()).collect()
}
fn required_fuel(st: u32) -> Option<u32> {
(st / 3).checked_sub(2)
}
fn solve_a(v: &[u32]) -> u32 {