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
| 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 |
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> | |
| 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++) | |
| { |
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> | |
| #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; | |
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> | |
| #include <stdlib.h> | |
| /* | |
| * Tower of Hanoi problem | |
| * | |
| * T(n)=2T(n-1)+1 => T(n)=2^n-1 | |
| */ | |
| static int steps=0; |
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
| /* | |
| * 堆排序的C++实现 | |
| */ | |
| #include <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <deque> | |
| #include <stack> |
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 <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <deque> | |
| #include <stack> | |
| #include <bitset> | |
| #include <algorithm> | |
| #include <functional> | |
| #include <numeric> |
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 <vector> | |
| #include <list> | |
| #include <map> | |
| #include <set> | |
| #include <deque> | |
| #include <stack> | |
| #include <bitset> | |
| #include <algorithm> | |
| #include <functional> | |
| #include <numeric> |
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> | |
| #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; |
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
| class CartesianProduct | |
| include Enumerable | |
| def initialize(arr1,arr2) | |
| @a=arr1 | |
| @b=arr2 | |
| end | |
| def each | |
| @a.each do |i| |
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
| package main | |
| import ( | |
| "net/http" | |
| "net/url" | |
| "log" | |
| "io/ioutil" | |
| "regexp" | |
| "fmt" | |
| //"net/http/httputil" |