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
┌──[desg@inb4troll]─[~/workspace] | |
└─$time ./tesprojecteuler | |
232792560 | |
real 0m0.998s | |
user 0m0.997s | |
sys 0m0.000s |
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
/*If we list all the natural numbers below 10 that are multiples of 3 or | |
5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000.*/ | |
#include <stdio.h> | |
int main(int argc, char **argv) | |
{ |
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
//The sum of the squares of the first ten natural numbers is, | |
//12 + 22 + ... + 102 = 385 | |
//The square of the sum of the first ten natural numbers is, | |
//(1 + 2 + ... + 10)2 = 552 = 3025 | |
/*Hence the difference between the sum of the squares of the first ten | |
natural numbers and the square of the sum is 3025 − 385 = 2640.*/ | |
/*Find the difference between the sum of the squares of the first one |
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
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1="\[\033[01;32m\]\u@\h {\[\033[01;34m\]\w\$(parse_git_branch)\[\033[01;32m\]} \[\033[01;34m\]\$\[\033[00m\] " |
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 <time.h> | |
int main() | |
{ | |
time_t now = time(0); | |
struct tm* tm = localtime(&now); |
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> | |
struct list { | |
int val; | |
struct list *next; | |
}; | |
list *map(list *list, int (*fn)(int)) | |
{ |
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> | |
typedef struct node { | |
int value; | |
struct node *next; | |
} node; | |
int increment(int); | |
int square(int); |
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
def map(list,func): | |
for list.len() in x | |
new_list = new_list.append(func(list[x])) | |
x = x + 1 | |
return new_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
def map(list,func): | |
x = 0 | |
for len(list) in x: | |
new_list = new_list.append(func(list[x])) | |
x += 1 | |
return new_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
rlist = zip( | |
[1000,900,500,400,100,90,50,40,10,9,5,4,1], | |
["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] | |
) | |
def int2roman(num): | |
answer = [] | |
for i, nm in rlist: | |
while num >= i: | |
answer.append(nm) |
OlderNewer