Skip to content

Instantly share code, notes, and snippets.

@feiskyer
feiskyer / nth_prime.py
Created April 22, 2012 04:11 — forked from evansneath/nth_prime.py
Nth Prime
def nth_prime(n):
"""Finds the nth prime number.
Arguments:
n: The index of the saught after prime number.
Returns:
The value of the nth prime number.
"""
prime_table, counter = [], 2
prime_number, top, last = 0, 10000000, 0
@feiskyer
feiskyer / select_sort.c
Created May 20, 2012 05:20
select sort
#include <stdio.h>
void select_sort(int arr[], int len)
{
int j=0, i=0, temp=0,small=0;
for(j=0;j<len-2;j++)
{
small=j;
for(i=j+1;i<len-1;i++)
{
@feiskyer
feiskyer / merge_sort.c
Created May 20, 2012 05:21
Merge Sort
#include <stdio.h>
#include <stdlib.h>
void merge(int arr[], int p, int q, int r)
{
int *L=NULL, *R=NULL;
int n1=q-p+1;
int n2=r-q;
int i,j,k;
@feiskyer
feiskyer / Hanoi.c
Created May 20, 2012 05:36
Tower of Hanoi problem
#include <stdio.h>
#include <stdlib.h>
/*
* Tower of Hanoi problem
*
* T(n)=2T(n-1)+1 => T(n)=2^n-1
*/
static int steps=0;
/*
* 堆排序的C++实现
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
@feiskyer
feiskyer / counting_sort.cpp
Created May 20, 2012 08:25
Counting Sort
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
@feiskyer
feiskyer / count_of_inversion.c
Created May 22, 2012 00:57
Count of inversion numbers
#include <stdio.h>
#include <stdlib.h>
long long sum=0;
void merge(int arr[], int p, int q, int r)
{
int *L=NULL, *R=NULL;
int n1=q-p+1;
int n2=r-q;
@feiskyer
feiskyer / gist:2857186
Created June 2, 2012 07:52
CartesianProduct
class CartesianProduct
include Enumerable
def initialize(arr1,arr2)
@a=arr1
@b=arr2
end
def each
@a.each do |i|
@feiskyer
feiskyer / gist:4237860
Created December 8, 2012 00:42 — forked from fxsjy/gist:3550053
Bakup Weibo to Disk
package main
import (
"net/http"
"net/url"
"log"
"io/ioutil"
"regexp"
"fmt"
//"net/http/httputil"