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
# fibonacci | |
h = Hash.new { |hash,key| hash[key] = hash[key-1] + hash[key-2] } | |
h[1] = 0 | |
h[2] = 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
#!/bin/bash | |
at $2 << !! | |
say $1 | |
osascript -e 'tell app "System Events" to display dialog "Reminder: $1"' | |
!! | |
exit 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<iostream> | |
#include<vector> | |
using namespace std; | |
typedef long long ll; | |
struct Tree { | |
vector<ll> tree; | |
ll n; |
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> | |
using namespace std; | |
typedef long long ll; | |
ll n; | |
vector<int> numbers; | |
struct Tree { |
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> | |
using namespace std; | |
int main() | |
{ | |
int sought = 4e8; | |
vector<int> vec; | |
for(size_t i = 0; i < sought + 20; 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
## | |
# Host Database | |
# | |
# localhost is used to configure the loopback interface | |
# when the system is booting. Do not change this entry. | |
## | |
127.0.0.1 localhost | |
255.255.255.255 broadcasthost | |
::1 localhost | |
fe80::1%lo0 localhost |
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<cstring> | |
using namespace std; | |
string s1, s2; | |
int n; | |
int lcs() | |
{ |
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 Bayes | |
def initialize | |
@frequency = {} | |
@categories = Hash.new 0 | |
end | |
# Prob(Category|Features) = Prob(Category) Prob(Features|Category) | |
def probability(features, category) | |
features_probability(features, category) * category_probability(category) | |
end |
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
s = gets.strip | |
m = { | |
?L => ->(z) { z + z.real }, | |
?R => ->(z) { z + Complex(z.real, z.real) }, | |
?P => ->(z) { z }, | |
?* => ->(z) { m[?L][z] + m[?R][z] + z } | |
} | |
z = s.reverse.each_char.inject(Complex(1)) { |z, c| m[c][z] } |
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<complex> | |
#include<cmath> | |
#include<iostream> | |
using namespace std; | |
typedef complex<double> Point; | |
#define x imag() | |
#define y real() |