Skip to content

Instantly share code, notes, and snippets.

View jakobrs's full-sized avatar

Jakob Rødal Skaar jakobrs

View GitHub Profile
def kombiner(Fam, Fa, Fbm, Fb):
Fbp = Fbm + Fb
return (Fam*Fbm + Fa*Fb, Fam*Fb + Fa*Fbp)
# funksjon som returnerer fibonaccitall n-1 og n
def nth_fibonacci(n):
if n == 1:
return (0, 1)
else:
@jakobrs
jakobrs / last.rs
Last active November 19, 2022 19:32
use std::ops::Range;
#[derive(Clone, Copy)]
enum Node<T> {
Empty,
Filled(T),
}
impl<T> Default for Node<T> {
fn default() -> Self {
#/*
import os
import fcntl
out = os.memfd_create("a.out")
fcntl.fcntl(out, fcntl.F_SETFD, 0) # remove FD_CLOEXEC
os.system(f"g++ {__file__} -o /proc/self/fd/{out}")
os.system(f"/proc/self/fd/{out}")
#include <cstdint>
#include <iostream>
#include <tuple>
#include <utility>
const std::size_t COUNT = 9;
const std::uint8_t primes[COUNT] = {2, 3, 7, 11, 13, 17, 19, 23, 29};
std::pair<int64_t, int64_t> extended_gcd(int a, int b) {
auto [old_r, r] = std::pair{a, b};
type StreamFrame<S> = (S, Option<<S as Stream>::Item>);
type StreamsUnorderedPollingFuture<S: Stream + Unpin> = impl Future<Output = StreamFrame<S>>;
pub struct StreamsUnordered<S: Stream + Unpin> {
streams: FuturesUnordered<StreamsUnorderedPollingFuture<S>>,
}
fn create_streams_unordered_polling_future<S: Stream + Unpin>(
mut stream: S,
) -> StreamsUnorderedPollingFuture<S> {
@jakobrs
jakobrs / document.md
Last active September 23, 2022 08:50
pandoc yaml header for school projects

geometry:

  • a4paper
  • margin=2.5cm
  • tmargin=3cm classoption:
  • 12pt lang: nb header-includes:
  • \usepackage{setspace}
def mult(m1, m2):
a = len(m1)
b = len(m2)
c = len(m2[0])
result = [[0] * c for _ in range(a)]
for i in range(a):
for j in range(c):
result[i][j] = 0
@jakobrs
jakobrs / main.py
Last active September 8, 2022 19:02
from typing import Optional, Tuple, List
import random
import sys
class UnionFind:
"""
Initialises a UnionFind collection with `size` items.
"""
@jakobrs
jakobrs / Lib.hs
Last active August 5, 2022 12:57
Code to build a tree from a list of tagsoup tags lazily
module Lib
( TagTree (..),
tagTree,
flattenTree,
parseTree,
renderTree,
)
where
import Text.StringLike (StringLike (..), fromString)
use gstreamer as gst;
use gstreamer_app as gst_app;
use gstreamer_video as gst_video;
use anyhow::Result;
use byte_slice_cast::*;
use gst::prelude::*;
use portal_screencast::ScreenCast;
fn main() -> Result<()> {