This file contains 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
from random import choice | |
candidates = ('Chipotle', 'Panda Express', 'Burger King', 'Gentle Ben\'s', 'Miss Saigon') | |
print choice(candidates) |
This file contains 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
import codecs | |
import re | |
f = codecs.open('freq.txt', 'r', 'utf-8') | |
data = f.read() | |
f.close() | |
freq = {} | |
for word in re.findall(r'\w+', data, re.UNICODE): | |
if not word in freq: |
This file contains 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
from numpy import inv, transpose | |
def pseudoinverse(U): | |
return inv(transpose(U) * U) * transpose(U) |
This file contains 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 <list> | |
using namespace std; | |
template <class T> | |
list<T> filter(bool (*f)(T x), list<T>* l) { | |
list<T> result; | |
typename list<T>::iterator it = l->begin(); | |
while(it != l->end()) { |
This file contains 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 <iterator> | |
#include <list> | |
using namespace std; | |
list<int> map(int (*f)(int x), list<int>* l) { | |
list<int> result; | |
list<int>::iterator it = l->begin(); | |
This file contains 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
unsorted_list = [5, 8, 1, 2, 4, 9, 7, 6, 3] | |
sorted_list1 = [2, 3, 5, 7, 11, 13, 17, 19] | |
sorted_list2 = [2, 4, 8, 10, 12, 14, 16, 18] | |
def min(list) | |
# Google for 'ruby ternary operator' | |
return list.reduce { |x, y| x < y ? x : y } | |
end | |
def max(list) |
This file contains 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
import java.util.Arrays; | |
import java.util.List; | |
/** | |
* This is a basic Java programming exercise. Fill out all unimplemented class | |
* methods. | |
* | |
* @author Sumin Byeon <[email protected]> | |
* | |
*/ |
This file contains 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 re | |
import sys | |
content = sys.stdin.read() | |
for p in re.findall(r"(\d+.\d+.\d+.\d+)\s+(\d+)", content): | |
print "http://%s:%s" % p |
This file contains 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
@Override | |
protected void onResume() { | |
super.onResume(); | |
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); | |
MediaPlayer mp = MediaPlayer.create(this, alert); | |
mp.start(); | |
} |
This file contains 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
# | |
# Example from: http://warnercnr.colostate.edu/~gwhite/fw663/BinomialLikelihood.PDF | |
# | |
from math import factorial | |
# Number of flips | |
n = 11 | |
# Number of heads |
OlderNewer