Skip to content

Instantly share code, notes, and snippets.

@Beneboe
Beneboe / scombinator.md
Created October 16, 2021 10:55
The connection between the apply function and the s combinator

The Connection between Apply and S combinator

I recently came across a video (https://youtu.be/UogkQ67d0nY?t=703) that looked at a problem and compared the solutions in Scala and Haskell.

The scala solution:

def maximumDifference(nums: Array[Int]): Int =
    nums.scanLeft(Int.MaxValue)(_ min _)
        .tail
@Beneboe
Beneboe / to_roman.py
Last active February 28, 2021 09:49
Convert to roman numeral
def to_roman(n):
r = ''
r = 'I' * ((n // 1) % 5) + r
r = 'V' * ((n // 5) % 2) + r
r = 'X' * ((n // 10) % 5) + r
r = 'L' * ((n // 50) % 2) + r
r = 'C' * ((n // 100) % 5) + r
r = 'D' * ((n // 500) % 2) + r
r = 'M' * (n // 1000) + r
@Beneboe
Beneboe / Bracket Parser.py
Created August 19, 2020 14:44
Bracket Parser
# expression := term operator term
# term := literal
# term := "(" expression ")"
# 0 - bracket open
# 1 - bracket close
# 2 - number
# 3 - operator
tokens = [
@Beneboe
Beneboe / how-to-setup-verified-commits.md
Last active March 20, 2024 18:20
How to Setup Verified Commits on Github
@Beneboe
Beneboe / treetraversal.fs
Created May 8, 2019 19:52
F# Tree traversal Test
open System
// printfn "Hello, world!"
type Tree<'a> =
| Node of Tree<'a> * Tree<'a>
| Leaf of 'a
let rec travelTree tree =
match tree with

Komplexität

Kostenanalyse

Unser Vorgehen: dominante Operation auswählen und Kosten grob ausrechnen

Problemgröße: präzise Beschreibung des Umfangs der zu verarbeitenden Daten, von dem Zeit- bzw. Speicherverhalten von Lösungsalgorithmen maßgeblich beeinflusst wird.

Kostenmaß: legt fest, in welchem Maße Operationen bei der Aufwandsbestimmung berücksichtigt werden

@Beneboe
Beneboe / Erzeugung eines Turnierplans
Created January 13, 2014 19:32
Erzeugung eines Turnierplans
def range(start, stop, step = 1):
x = start
while True:
if x >= stop: return
yield x
x += step
# Erzeugung eines Turnierplans mit n Teilnehmern
# Eingabe von n
\[\033[0;36m\]\A \[\033[0;37m\][ \[\033[0;34m\]\u@\h\[\033[1;34m\] \W \[\033[0;37m\]]\$\[\033[00m\]
@Beneboe
Beneboe / index.html
Created February 24, 2013 15:00
makes labels go inside an input tag
<form action="/message">
<p>
<label for="user_tel">Telephone:</label>
<input type="text" id="user_tel"><br />
</p>
<p>
<label for="user_msg">Message:</label>
<textarea name="" id="user_msg" cols="30" rows="10">
</textarea><br />
@Beneboe
Beneboe / timer classes and more.js
Created February 12, 2013 12:26
testing in js
console.log("\n");
var i = 10;
function writeD(d){
document.write(d);
}
function fixDecimal(num) {
return Math.round(num * 10) / 10;
}
function Timer (milisecs, callback) {
var t;