Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
int gray_decode(int n) {
int p = n;
while (n >>= 1) p ^= n;
return p;
}
int main() {
int t, c;
def ncr(n, r)
a, b = r, n-r
a, b = b, a if a < b # a is the larger
numer = (a+1..n).inject(1) { |t,v| t*v } # n!/r!
denom = (2..b).inject(1) { |t,v| t*v } # (n-r)!
numer / denom
end
def ncrdigs_naive(n, r, base)
ncr(n, r).to_s(base).length
main() {
char c = getchar(), t, p = -1;
int freq[128] = {0};
while ( (t = getchar()) != '\n' ) {
if (p == c)
freq[t] ++;
p = t;
}
#define eq(X, a) ((X[0] == a[0]) && (X[1] == a[1]))
main() {
int t;
float tp, tn, fp, fn, p, r;
tp = tn = fp = fn = 0;
char c[3];
scanf("%d\n", &t);
while (t--) {
main() {
int n, m, k, t=0, i;
scanf("%d\n", &n);
int s[n][2];
for (i=0; i<n; i++)
scanf("%d %c\n", &s[i][0], &s[i][1]);
scanf("%d\n", &m);
#define classify(x) (((x) >= 0.5) ? '+' : '-')
float sigmoid(float x) {
return 1 / (1 + exp((double) -x));
}
main() {
int d, q, i, a, t;
scanf("%d %d\n", &d, &q);
int beta[d+1];
int fib(n) {
return n < 2 ? n : fib(n-1) + fib(n-2);
}
int main() {
int t, n;
scanf("%d\n", &t);
while (t--) {
scanf("%d\n", &n);
printf("%f\n", fib(n+2) / pow(2, n));
function readAnime(results) {
return _.map(results.anime, function(anime) {
anime.linked = {};
_.each(Object.keys(anime.links), function(rel) {
var relVal;
if (Array.isArray(anime.links[rel])) {
relVal = _.find(results.linked[rel], function(candidate) {
// return whether candidate.id is in anime.links[rel]
});
} else {
@vikhyat
vikhyat / gist:ec0f4c27ed21b092ca12
Last active August 29, 2015 14:12
Hummingbird Recurring Billing
Here's how it's going to look like from the end user perspective:
1 hour before my PRO membership ends, if I am on a recurring plan
Hummingbird will try to charge my credit card. If it succeeds
everything is good. If it fails my subscription will run out and
Hummingbird will try to charge my credit card again tomorrow, 3
days from now and 5 days from now. I will receive an email from
Hummingbird if the charge is successful, and a different email
every time charging my card fails.
test