Skip to content

Instantly share code, notes, and snippets.

View LinuxMercedes's full-sized avatar
🐔
chicken

lm LinuxMercedes

🐔
chicken
View GitHub Profile

Keybase proof

I hereby claim:

  • I am linuxmercedes on github.
  • I am linuxmercedes (https://keybase.io/linuxmercedes) on keybase.
  • I have a public key ASDa5MDDyBeo1db0m8VrKfnIUJZe8e1lQqOXSxoIgV3wrgo

To claim this, I am signing this object:

trait DoStuff {
fn stuff(&mut self, thing: i32) -> bool;
}
struct Thing1 {
yup: i32,
}
impl DoStuff for Thing1 {
fn stuff(&mut self, thing: i32) -> bool {
@LinuxMercedes
LinuxMercedes / size.cpp
Last active August 26, 2016 15:31
Size of various C++ types
#include<iostream>
using namespace std;
#define ps(x) cout << #x << ":\t" << sizeof(x) << endl
int main() {
ps(short);
ps(int);
ps(long);
ps(long long);
from DictHeap import DictHeap
from step import step
from solution import solution
# Loop-based A*GS algorithm
def search(edges, sidelen, start, goal, heuristic):
frontier = DictHeap()
explored = {}
# Add the start state to the frontier
@LinuxMercedes
LinuxMercedes / astar.cpp
Created August 27, 2015 03:00
Ooooooooooold A* code
#include "astar.h"
void findPath(coord start, coord end, short steps, vector<coord> & path)
{
//if we are going to where we are
if(start == end)
{
path.front() = end;
return;
}
@LinuxMercedes
LinuxMercedes / longest_palindrome.rb
Created July 17, 2015 15:07
Find the longest palindrome substring in a string
require "set"
def create_idxs(str)
# TODO: rewrite with inject or something
ret = Hash.new { |hash,key| hash[key] = SortedSet.new }
str.chars.each_index { |i|
ret[str[i]] << i
}
return ret;
#include<stdio.h>
int main() {
int a = 5;
int b = 3;
(a > b ? a : b) = 6;
printf("a: %i b: %i\n", a, b);
return 0;
@LinuxMercedes
LinuxMercedes / case.cpp
Created April 22, 2015 03:55
Is if-else more efficient than switch-case?
#include<iostream>
using namespace std;
int switch_case(int x) {
switch(x) {
case 1:
return -1;
case 5:
return 3;
case -7:
@LinuxMercedes
LinuxMercedes / fizzbuzz.py
Created October 27, 2014 05:28
Fizzbuzz with no conditionals or loops
def die(i, m):
return
three = [
'fizz',
''
]
five = [
'buzz',
@LinuxMercedes
LinuxMercedes / Makefile
Last active August 29, 2015 14:06
CS 5500 Makefile
TESTDIR=tests
TESTFILES=$(wildcard $(TESTDIR)/*.txt)
OUTFILES=$(TESTFILES:.txt=.result)
.PHONY: all lexer parser clean test cleantest
all: lexer
lex.yy.c: mipl.l