Skip to content

Instantly share code, notes, and snippets.

@2m
2m / day1.markdown
Created December 8, 2019 12:42 — forked from runarorama/day1.markdown
Advent of Code (Unison Edition), day 1

Advent of Code 2019, in Unison

Spoilers for Advent of Code 2019 follow.

Day 1: The Tyranny of the Rocket Equation

Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.

This describes a simple function. There seems to be an oversight in the problem statement that modules with very low mass have a negative fuel requirement. I'm going to assume that's not right, and that instead of integer subtraction, we want natural number subtraction (sometimes called "monus"). In Unison, we can use the Nat type instead of integers, so we don't have to consider negatives. The subtraction operation is called drop:

@2m
2m / build.sbt
Last active September 6, 2019 05:48
add the following file to ~/.sbt/1.0/plugins/ to disable coursier plugin on sbt 1.3
libraryDependencies ++= {
if (!sbtVersion.value.startsWith("1.3")) {
val sbtV = (sbtBinaryVersion in pluginCrossBuild).value
val scalaV = (scalaBinaryVersion in update).value
Seq(Defaults.sbtPluginExtra("io.get-coursier" % "sbt-coursier" % "2.0.0-RC3-3", sbtV, scalaV))
}
else Seq.empty
}
In file included from /usr/include/string.h:494,
from /home/martynas/.cache/yay/openswan-git/src/openswan-git/programs/tncfg/tncfg.c:19:
In function ‘strncpy’,
inlined from ‘main’ at /home/martynas/.cache/yay/openswan-git/src/openswan-git/programs/tncfg/tncfg.c:233:4:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘main’ at /home/martynas/.cache/yay/openswan-git/src/openswan-git/programs/tncfg/tncfg.c:236:4:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 12 equals destination size [-Werror=stringop-truncation]
Permissions Size User Group Date Modified Name
lrwxrwxrwx 0 root root 26 Jun 19:59 card0-eDP-1 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1
lrwxrwxrwx 0 root root 26 Jun 20:01 card1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1
lrwxrwxrwx 0 root root 26 Jun 20:01 card1-DP-2 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-2
lrwxrwxrwx 0 root root 26 Jun 20:01 card1-DP-3 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-3
lrwxrwxrwx 0 root root 26 Jun 20:01 card0 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0
lrwxrwxrwx 0 root root 26 Jun 20:01 card1-DP-1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-DP-1
lrwxrwxrwx 0 root root 26 Jun 20:01 card1-HDMI-A-1 -> ../../devices/pci0000:00/0000:00:01.0/0000:01:00.0/drm/card1/card1-HDMI-A-1
lrwxrwxrwx 0 root root 26 Jun 20:21 renderD128 -> ../../devices/pci0000:00/0000:00:02.0/drm/renderD128
lrwxrwxrwx
PID: 14386 (sway)
UID: 1000 (martynas)
GID: 1000 (martynas)
Signal: 7 (BUS)
Timestamp: Wed 2019-06-26 20:40:31 EEST (2min 45s ago)
Command Line: build/sway/sway -d --verbose
Executable: /home/martynas/projects/sway/build/sway/sway
Control Group: /user.slice/user-1000.slice/session-1.scope
Unit: session-1.scope
Slice: user-1000.slice
From f85aaa886354012a8d9feb30e052e5a03f6e142b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= <self@2m.lt>
Date: Tue, 20 Nov 2018 19:39:44 +0200
Subject: [PATCH] Update to 0.10-RC1
---
PKGBUILD | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git PKGBUILD PKGBUILD
From 6e138eaffb0064f4c74e6373449ee7cd6ee64031 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= <self@2m.lt>
Date: Wed, 17 Oct 2018 11:56:31 -0400
Subject: [PATCH] Prepend shebang
---
PKGBUILD | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git PKGBUILD PKGBUILD
From 1afb41c9453dc1bbd0110d4c78962bf2014ec7cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martynas=20Mickevi=C4=8Dius?= <self@2m.lt>
Date: Wed, 17 Oct 2018 11:38:23 -0400
Subject: [PATCH] Update to 1.2.1
---
PKGBUILD | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git PKGBUILD PKGBUILD
Current Filetype: rust
Available Linters: ['cargo', 'rls', 'rustc']
Enabled Linters: ['cargo']
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'rustfmt' - Fix Rust files with Rustfmt.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_rust_cargo_avoid_whole_workspace = 1
201801 201802 201803
akka-stream-alpakka-amqp_2.11 216 338 220
akka-stream-alpakka-amqp_2.12 662 795 1867
akka-stream-alpakka-awslambda_2.11 62 69 65
akka-stream-alpakka-awslambda_2.12 76 76 75
akka-stream-alpakka-azure-storage-queue_2.11 50 49 34
akka-stream-alpakka-azure-storage-queue_2.12 51 50 33
akka-stream-alpakka-cassandra_2.11 317 335 543
akka-stream-alpakka-cassandra_2.12 4690 4570 8285