Skip to content

Instantly share code, notes, and snippets.

💭
It's probably about Segment Trees

Juan Lopes juanplopes

💭
It's probably about Segment Trees
Block or report user

Report or block juanplopes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:93e687e65dca1eeb44640c122dbdcb0d
(async () => {
var get = async(url, prop, dataless) => {
var data = (await (await fetch(url)).json());
if (!dataless) data = data.data;
var result = {};
data.forEach(element => {
result[element[prop]] = element;
});
return result;
View 1579.cpp
#include <iostream>
using namespace std;
int X[200];
int trucks(int P, int maximum) {
int count = 0, current = 0;
for(int i=0; i<P; i++) {
if (X[i] > maximum) return 10000000;
if (current + X[i] > maximum) {
View LazyOutputStream.java
import java.io.IOException;
import java.io.OutputStream;
public class LazyOutputStream<T extends OutputStream> extends OutputStream {
private final Factory<T> factory;
private T stream;
public LazyOutputStream(Factory<T> factory) {
this.factory = factory;
}
View B.cpp
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int T[][501] = {{0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,
@juanplopes
juanplopes / mvngithub.py
Last active May 19, 2018
Python 2 script that asks github for new application token and saves it on .m2/settings.xml
View mvngithub.py
#!/usr/bin/env python
import httplib, getpass, base64, json, datetime, sys, socket, xml.etree.ElementTree as ET, os.path as path, os
NS = {'n':'http://maven.apache.org/SETTINGS/1.0.0'}
DEFAULT_REPO_KEY = 'your-repo-key'
def make_auth(username, password):
return base64.b64encode('{}:{}'.format(username, password))
def make_token(repokey, username, password, token2fa):
View test.py
def cnt(v):
x, y, z, u, w = bool(v&1), bool(v&2), bool(v&4), bool(v&8), bool(v&16)
return ("T" if
(x or y or w) and (z or not w or v) and (not z or not w or not v) and
len(set([x, y, w])) == 2 and
len(set([z, not w, v])) == 2 and
len(set([not z, not w, not v])) == 2
else "F")
View expect_palindrome.py
import sys
def kmp_init(P):
F = [0] * (len(P)+1)
i, j = 1, 0
while i<len(P):
if P[i] == P[j]:
i += 1; j += 1; F[i] = j
elif j == 0:
i += 1; F[i] = 0
View prime_factors.py
def primes_up_to(N):
sieve = N*[True]
for i in range(2, N):
if not sieve[i]: continue
yield i
for j in range(i*i, N, i):
sieve[j] = False
def primeFactors(N):
answer = ''
View keybase.md

Keybase proof

I hereby claim:

  • I am juanplopes on github.
  • I am juanplopes (https://keybase.io/juanplopes) on keybase.
  • I have a public key ASAbnYPzQC3kur2g1skku3Eodfvw_egjtxXfetmlGRTC-wo

To claim this, I am signing this object:

@juanplopes
juanplopes / fighting_the_zombie.cpp
Created Jan 10, 2017
Hacker Cup 2017 solutions
View fighting_the_zombie.cpp
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
int DD[6] = {4, 6, 8, 10, 12, 20};
double D[6][25][500];
You can’t perform that action at this time.