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
public class Link { | |
int value; | |
Link next; | |
public Link(int value) { | |
this.value = value; | |
this.next = null; | |
} | |
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
// given 3 points on plane (x1,y1,z1), (x2,y2,z2), (x3,y3,z3) | |
// get distance to (x,y,z) | |
double plane_exp_point_dist_3d ( double x1, double y1, double z1, double x2, | |
double y2, double z2, double x3, double y3, double z3, double x, double y, double z ) | |
{ | |
double a; | |
double b; | |
double c; | |
double d; | |
double dist; |
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
public class SimpleSolver { | |
static int eval(String q) { | |
int val = 0; | |
java.util.StringTokenizer st = new java.util.StringTokenizer(q, "*/+-", true); | |
while (st.hasMoreTokens()) { | |
String next = st.nextToken().trim(); | |
if (next.equals("+")) { | |
val += Integer.parseInt(st.nextToken().trim()); | |
} else if (next.equals("-")) { | |
val -= Integer.parseInt(st.nextToken().trim()); |
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
/* | |
* A solution for programming problem "wordEnds": | |
* http://codingbat.com/prob/p147538 | |
*/ | |
public String wordEnds(String str, String word) { | |
StringBuffer tmp = new StringBuffer(); | |
int ss=0, idx=-1; | |
while((idx = str.indexOf(word, ss)) >= 0) { | |
ss = idx + word.length(); | |
if(idx-1 >= 0) tmp.append(str.charAt(idx-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
#!/usr/bin/env python | |
from opencv import cv | |
from opencv import highgui | |
from datetime import datetime | |
capture = highgui.cvCreateCameraCapture(0) | |
for i in range(0, 15): | |
img = highgui.cvQueryFrame(capture) | |
filename = datetime.now().strftime("%Y-%m-%d %H:%M:%S.jpg") |
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 <ctime> | |
#include "cv.h" | |
#include "highgui.h" | |
int main(int argc, char** argv) { | |
// open camera | |
cv::VideoCapture cap(0); | |
if(!cap.isOpened()) |
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
<?php | |
$birth = strtotime('1902-01-01'); | |
$current = strtotime('2011-03-06'); | |
$days = round(abs($current-$birth)/86400); | |
?> |
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 <vector> | |
#include <algorithm> | |
using namespace std; | |
#define loop(ITER,FROM,TO) for(ITER=FROM;ITER<TO;ITER++) | |
int A[9][9]; | |
bool chk[9]; |
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 <vector> | |
#include <algorithm> | |
using namespace std; | |
/*----------------------------------------------------------------------------- | |
* Process the data | |
* | |
* input: | |
* v[i]: value of the ith object |
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
// this works! | |
for (RigidBodyList::const_iterator i = rigid_bodies.begin(), | |
end = rigid_bodies.end(); i != end; ++i) { | |
1+1; // do nothing | |
checkCollision(target_body, *i); | |
} | |
// this does not work. | |
for (RigidBodyList::const_iterator i = rigid_bodies.begin(), | |
end = rigid_bodies.end(); i != end; ++i) { |