Skip to content

Instantly share code, notes, and snippets.

View LVMBDV's full-sized avatar
:octocat:

Ata Kuyumcu LVMBDV

:octocat:
View GitHub Profile
#include <SPI.h>
#include <SD.h>
#define ADDRLO_PORT PORTA
#define ADDRHI_PORT PORTC
#define DATA_PORT PORTD
#define MREQ_PIN PB0
#define WR_PIN PB1
#define RD_PIN PB2
#define WAIT_PIN PB3
@LVMBDV
LVMBDV / playme.sh
Last active November 3, 2019 22:31
#!/usr/bin/env bash
# Copyright 2018 Ata Can Kuyumcu
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
@LVMBDV
LVMBDV / fizzbuzz.fnl
Created November 2, 2018 19:55
fizzbuzz, in fennel
(for [i 1 100]
(if (= 0 (% i 3))
(if (= 0 (% i 5))
(print "fizzbuzz")
(print "fizz"))
(= 0 (% i 5))
(print "buzz")
(print i)))
@LVMBDV
LVMBDV / thot.sh
Created May 27, 2018 19:59
A "The Oregon Trail" clone in space, in bash.
#!/bin/bash
FUEL_COST=5
FOOD_COST=2
START_FUEL=50
START_FOOD=70
START_PARTS=2
START_CREW_SIZE=4
#!/usr/bin/env python3
from sympy import lambdify
from itertools import count
n_decimal_digits = lambda value, n: format(value, ".%df" % (n+1))[:-1]
sign = lambda x: x / abs(x)
function = lambdify("x", input("Enter an expression to find a root for: "))
digit_target = int(input("Enter the number of digits to match: "))
#!/usr/bin/env python3
from sympy import lambdify
from itertools import count
function = lambdify("x", input("Enter a method to iterate with: "))
initial_value = float(input("Enter the initial value for the iteration: "))
target_diff = float(input("Enter the target value for the difference between iterations: "))
value = initial_value
(defn fib
([] (fib 1 1)) ; start with x = y = 1
([x y] (lazy-seq (cons x (fib y (+ x y)))))) ; x = y and y = x + y
(println (reduce + (filter even?
(take-while #(< % 4000000) (fib)))))
@LVMBDV
LVMBDV / euler2.cr
Last active February 23, 2018 17:12
sum, x, y, z = 0, 1, 2, 3
while z <= 4000000
z = x + y
x = y
y = z
sum += z if z.divisible_by? 2
end
puts sum
@LVMBDV
LVMBDV / euler1.cr
Last active February 23, 2018 17:11
sum = 0
(1..1000).each { |number|
if (number.divisible_by? 3) || (number.divisible_by? 5)
sum += number
end
}
puts sum
(println (reduce +
(filter #(= (* (mod % 3) (mod % 5)) 0)
(range 1 1000))))