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
$> gcc -o fib -O3 fib.c | |
$> time ./fib_num | |
165580141 | |
real 0m1.452s | |
user 0m1.448s | |
sys 0m0.000s | |
$> javac FibNum.java | |
$> time java -server FibNum |
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
abstract class Shape { | |
} | |
class Rectangle extends Shape { | |
} | |
class Square extends Shape { | |
} |
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
class Person | |
{ | |
private String name; | |
public Person(String name) { | |
this.name = name; | |
} | |
public Person() { | |
} |
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
int missing(int a[], int n) { | |
double num = n + 1; | |
double ideal_sum = (num * (num + 1)) / 2; | |
int sum = 0; | |
int i; | |
for (i = 0; i < n; i++) { | |
sum += a[i]; | |
} |
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
int get_max_range(int a[], int n, int *start, int *end) | |
{ | |
int temp_sum = 0, sum = 0, found = -1; | |
int i, j; | |
for (i = 0; i < n - 1; i++) { | |
temp_sum = a[i]; | |
*start = i; | |
for (j = i;j < n; j++) { | |
temp_sum = a[j]; |
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
'''Read an html file from a file like object, parse(possibly selective) it and give back the data to the callback for processing. | |
''' | |
import urllib2 | |
import re | |
import sys | |
from BeautifulSoup import BeautifulSoup | |
from BeautifulSoup import SoupStrainer | |
# Inline configs. |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
int equi(int a[], int n ) { | |
int i, j; | |
long int sum = 0; | |
int **sum_list = calloc(sizeof *sum_list, n); | |
assert(sum_list != NULL); | |
for (i = 0; i < n; i++) { |
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 <stdio.h> | |
double fib(int num) | |
{ | |
if (num <= 1) | |
return 1; | |
else | |
return fib(num-1) + fib(num-2); | |
} |
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
public class FibNum { | |
public static void main(String args[]) { | |
System.out.printf("%.0f\n", fib(Integer.parseInt(args[0]))); | |
} | |
public static double fib(int n) { | |
if (n <= 1) | |
return 1; | |
else | |
return fib(n-1) + fib(n-2); | |
} |
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
$> gcc -o fib fib_num.c | |
$> time ./fib | |
165580141 | |
real 0m3.606s | |
user 0m3.604s | |
sys 0m0.000s |
OlderNewer