Skip to content

Instantly share code, notes, and snippets.

View st3fan's full-sized avatar

Stefan Arentz st3fan

View GitHub Profile
@st3fan
st3fan / day20.c
Created November 14, 2021 23:20
Advent of Code - 2015 Day 20
/* Advent of Code - 2015 Day 20 */
#include <stdio.h>
#include <dispatch/dispatch.h>
int number_of_presents(int house) {
int n = 0;
for (int elf = 1; elf <= house; elf++) {
if ((house % elf) == 0) {
n += (10 * elf);
//
// ContentView.swift
// WhatIsMyIP
//
// Created by Stefan Arentz on 02/10/2021.
//
import SwiftUI
struct Address {
#!/bin/sh
set -x
env CGO_CFLAGS="-mmacosx-version-min=10.15" CGO_LDFLAGS="-mmacosx-version-min=10.15" CGO_ENABLED=1 GOARCH=amd64 go build -installsuffix argussh_amd64 -o argussh-amd64.a -buildmode=c-archive
env CGO_CFLAGS="-mmacosx-version-min=10.15" CGO_LDFLAGS="-mmacosx-version-min=10.15" CGO_ENABLED=1 GOARCH=arm64 go build -installsuffix argussh_arm64 -o argussh-arm64.a -buildmode=c-archive
mv ./argussh-amd64.h ./argussh.h
lipo -create argussh-amd64.a argussh-arm64.a -output argussh.a
import Vapor
import Redis
struct Counter: Content {
let id: UUID
let name: String
let value: Int
}
import Dispatch
import Foundation
import NIO
import NIOSSH
let LocalHost = "127.0.0.1"
let LocalPort = 10080
import Foundation
import NIO
private let newLine = "\n".utf8.first!
/// Very simple example codec which will buffer inbound data until a `\n` was found.
(ns advent-of-code.day13
(:require [advent-of-code.util :as util]
[clojure.string :as string]))
(defn parse-mask [s]
[(Long/parseLong (-> s (string/replace #"0" "T") (string/replace #"[1X]" "1") (string/replace #"T" "0")) 2)
(Long/parseLong (-> s (string/replace #"1" "T") (string/replace #"[1X]" "0") (string/replace #"T" "1")) 2)])
(defn parse-line [line]
(if-let [matches (re-matches #"mask = ([X10]{36})" line)]
@st3fan
st3fan / day3.clj
Last active December 3, 2020 16:03
(ns advent-of-code.day3
(:require [advent-of-code.util :as util]))
(defn load-map []
(let [input (doall (util/load-input 3 seq))]
{:data input
:width (count (first input))
:height (count input)}))
(defn at-bottom [map y]
(defn create-int-computer [program]
{:memory program
:pc 0})
(defn current-instruction [computer]
(nth (:memory computer) (:pc computer)))
(defn first-arg [computer]
(nth (:memory computer) (+ (:pc computer) 1)))