This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
struct entry { | |
std::string data; | |
int value; | |
entry * next; | |
}; | |
unsigned int hash(std::string s, int hash_size) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdlib> | |
#include <ctime> | |
void sort(int * a, size_t n) { | |
if (n < 2) | |
return; | |
int p = a[n/2]; | |
int *l = a; | |
int *r = a + n-1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <pthread.h> | |
#include <unistd.h> | |
typedef struct { | |
int thread_num; | |
} data_t; | |
void *task (void * data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os | |
from optparse import OptionParser | |
import Tkinter as tk | |
# tell python where to find mavlink so we can import it | |
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../mavlink')) | |
from pymavlink import mavutil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os, socket, pickle | |
from time import time | |
from optparse import OptionParser | |
UDP_IP = "127.0.0.1" | |
UDP_PORT = 31200 | |
# tell python where to find mavlink so we can import it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#define DIM 5 | |
void swap(int s[DIM][DIM], int i, int j, int k, int l) { | |
char c = s[i][j]; | |
s[i][j] = s[k][l]; | |
s[k][l] = c; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void build_histogram(std::string s, int * m) { | |
size_t len = s.length(); | |
for(int i = 0; i < len; ++i) | |
m[s[i]] +=1; | |
} | |
bool check_permutation(std::string s1, std::string s2) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os | |
from optparse import OptionParser | |
# tell python where to find mavlink so we can import it | |
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../mavlink')) | |
from pymavlink import mavutil | |
def handle_heartbeat(msg): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <map> | |
#include <algorithm> | |
#include <climits> | |
// using STL MAP | |
bool duplicate_check_maphist(std::string s) | |
{ | |
std::map<char, int> h; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef unsigned int UINT; | |
// does not handle overflow or negative numbers | |
UINT divide_naive(UINT a, UINT b) | |
{ | |
UINT result; | |
while (b < a) { | |
UINT k=0, b2k = b; | |
while(b2k << 1 < a) |