Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View manonthemat's full-sized avatar

Matthias Sieber manonthemat

View GitHub Profile
@manonthemat
manonthemat / stack.cpp
Last active August 29, 2015 14:14
simple stack data structure in C++
#include <iostream>
using namespace std;
class Stack_overflow {};
class Stack_underflow {};
class Stack {
public:
Stack(int sz) : sz{sz}, top{-1}, elem {new int[sz]} {};
@manonthemat
manonthemat / roman.cpp
Created January 19, 2015 19:59
first draft of a simple roman calculator
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <regex>
#include <sstream>
using namespace std;
puts' ______________________________ '
puts'< What\'s wrong with this food? >'
puts' ------------------------------ '
puts' \ ^__^'
puts' \ (oo)\_______'
puts' (__)\ )\/\''
puts' ||----w |'
puts' || ||'
@manonthemat
manonthemat / base.hs
Created May 21, 2014 18:28
simple math fun with haskell - custom number base systems
import Data.Char (digitToInt)
numberToBaseString :: Int -> Int -> String
numberToBaseString n base
| n < base = show n
| otherwise = numberToBaseString ((n - (n `mod` base)) `div` base) base ++ show (n `mod` base)
baseStringToValue :: String -> Int -> Int
baseStringToValue n base
| n == [] = 0
@manonthemat
manonthemat / gist:9938961
Created April 2, 2014 17:32
Example of a simple algorithm with a running time that grows proportional to the input size
def find_max(data):
"""Return the maximum element from a nonempty Python list."""
biggest = data[0]
for val in data:
if val > biggest:
biggest = val
return biggest