Skip to content

Instantly share code, notes, and snippets.

View torkiljohnsen's full-sized avatar

Torkil Johnsen torkiljohnsen

View GitHub Profile
@torkiljohnsen
torkiljohnsen / AdventOfCode.md
Created December 7, 2022 09:16
Advent of Code 7th December 2022. Solution from ChatGPT.

To solve this problem, we need to find all of the directories with a total size of at most 100000. This can be done by traversing the directory tree and keeping track of the total size of each directory.

To implement this, we can use a dictionary to store the total size of each directory. As we traverse the tree, we can update the total size of each directory in the dictionary. When we encounter a file, we can add its size to the total size of the current directory. When we encounter a directory, we can move into it and repeat the process until we reach the end of the tree.

Once we have calculated the total size of each directory, we can simply iterate through the dictionary and sum the sizes of all the directories with a total size of at most 100000.

Here is some pseudocode that outlines the steps to solve this problem:

# create an empty dictionary to store the total size of each directory
Luke is dead! ,ooo888888888888888oooo,
o8888YYYYYY77iiiiooo8888888o
8888YYYY77iiYY8888888888888888
[88YYY77iiY88888888888888888888]
88YY7iYY888888888888888888888888
[88YYi 88888888888888888888888888]
i88Yo8888888888888888888888888888i
i] ^^^88888888^^^ o [i
oi8 i o8o i 8io
,77788o ^^ ,oooo8888888ooo, ^ o88777,
@torkiljohnsen
torkiljohnsen / _nav--horizontal.scss
Last active December 14, 2015 08:49
Example of the issue at hand: .nav gets imported multiple times
@import 'nav'; // "Extending" .nav
.nav--horizontal {
/* horizontal nav is a variant of nav */
}
@torkiljohnsen
torkiljohnsen / dabblet.css
Created September 24, 2012 06:19
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
section {
background: gray;
max-width: 700px;
display: flex;
flex-flow: row wrap;
}
@torkiljohnsen
torkiljohnsen / vendors.php
Created January 22, 2012 14:45 — forked from mathiasverraes/deps.ini
vendors script, replaces git submodules and svn externals
#!/usr/bin/env php
<?php
/*
* Custom version of Symfony2's vendor script
* Put this file in /bin and make a deps.ini file in the root, looking like this:
*
* [some_name]
* git=REPO
* target=path/to/vendor/name
* version=COMMITISH
@torkiljohnsen
torkiljohnsen / SassMeister-input.scss
Created December 15, 2014 18:09
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
// sRGB GAMMA CORRECTION, per spec: https://en.wikipedia.org/wiki/SRGB
@function re-gamma($n) { @if $n <= 0.0031308 { @return $n * 12.92; } @else { @return 1.055 * pow($n,1/2.4) - 0.055; } }
@function de-gamma($n) { @if $n <= 0.04045 { @return $n / 12.92; } @else { @return pow((($n + 0.055)/1.055),2.4); } }
// sRGB BT-709 BRIGHTNESS