Skip to content

Instantly share code, notes, and snippets.

Avatar

Said Aspen saidaspen

View GitHub Profile
@saidaspen
saidaspen / dialinglock.md
Last active Jan 26, 2021
Broken Dial Combination Safe
View dialinglock.md

You are in a locked room. A cell? A box, of some sort? Walls, ceiling and floor are all the same worn industrial metal. There is a small door, but it seems secured with some old kind of mechanism. One of those old safebox locks where you spin a knob alternatively left and right to get to the right sequence. "Who puts the lock on the inside of a cell?" you ponder. "It doesn't matter. I need to get out of here."
There are scribblings and scratching on the walls and on the floor. Mainly in one of the corners, the corner where you found yourself sitting just a while ago. Only one thing stands out; a long series of letters, your puzzle inputs.

As you examine the lock's mechanism, it is clear to you that it is ancient. It is covered by corrosion, and its dial only seems to go in one direction, to your right. Something in the lock seems broken, or loose inside of it, as there seem to be something stopping it from rotating to your left. The face of the dial has numbers on it, labelled 1 through 9.

@saidaspen
saidaspen / aoc202day09.kt
Created Dec 9, 2020
Advent of Code 2020 Day 9
View aoc202day09.kt
fun part1(): Long {
val prevFive = ArrayDeque<Long>()
prevFive.addAll(input.subList(0, 25))
for (i in 25 until input.size) {
val elem = input[i]
if (!prevFive.any { prevFive.contains(elem - it) }) return elem
prevFive.removeFirst()
prevFive.addLast(elem)
}
return -1
@saidaspen
saidaspen / main.rs
Created Sep 18, 2020
Type annotation?
View main.rs
#[post("/new")]
async fn new(req_body: String) -> impl Responder {
match serde_json::from_str(req_body.as_str()) {
Err(why) => HttpResponse::BadRequest().body(
json!({
"err": "Unable to parse input as request json",
})
.to_string(),
),
Ok(t) => HttpResponse::Ok().body(format!("{:?}", t)),
@saidaspen
saidaspen / Aoc2017D21.kt
Last active Aug 29, 2020
Advent of Code 2017 Day 21
View Aoc2017D21.kt
fun main() {
val input = java.io.File(ClassLoader.getSystemResource("201721").file).readText().trim()
println("Part 1: " + Day21().part1(input, 5))
println("Part 2: " + Day21().part1(input, 18))
}
typealias G = Grid<Char>
typealias P<A, B> = Pair<A, B>
class Day21 {
@saidaspen
saidaspen / 2017Day21Tests.kt
Created Aug 25, 2020
Advent of Code 2017 Day 21 Unit tests
View 2017Day21Tests.kt
package aoc207
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
internal class Day21Test {
@Test
fun p1() {
@saidaspen
saidaspen / 2017Day21.kt
Created Aug 25, 2020
Advent of Code 2017 Day21 - Does not work
View 2017Day21.kt
package aoc207
import java.io.File
fun main() {
val input = File(ClassLoader.getSystemResource("201721").file).readText()
println("Part 1: " + Day21(input).part1(5))
}
class Day21(input: String) {
View example.rs
let mut scores: HashMap<String, HashMap<String, u32>> = HashMap::new();
1 for repo in tracked_repos {
2 let contributions: Vec<Contribution> = gh
3 .get_contributors(&repo)
4 .expect("unable to get contributors for repo")
5 .iter()
6 .filter(|c| participants_set.contains(&c.login))
7 .cloned()
8 .collect();
9 for contrib in contributions {
@saidaspen
saidaspen / Aoc07.java
Last active Dec 7, 2019
AOC2019 07 Java
View Aoc07.java
package se.saidaspen.aoc2019.aoc07;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
import java.util.stream.IntStream;
@saidaspen
saidaspen / config.go
Last active Sep 17, 2018
Did configuration - Seems overly complex!
View config.go
// Config holds the properties and values used for configuration
type Config struct {
dateFormat string
}
// DefaultConfig is the set of configuration values used if none other is given.
var DefaultConfig = Config{"2006-01-02"}
// FromFile returns the configuration to use for did
func FromFile(path string) (c Config, e error) {
@saidaspen
saidaspen / to_learn_and_improve.md
Last active Jun 22, 2018
Things that I want to learn
View to_learn_and_improve.md

General work related skills

Communication

  1. Public speaking

Technology

Programming and scripting Languages

  1. Golang
  2. Python
  3. Rust