Skip to content

Instantly share code, notes, and snippets.

@Beneboe
Beneboe / how-to-setup-verified-commits.md
Last active December 19, 2025 10:53
How to Setup Verified Commits on Github
@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 / 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 / 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