Skip to content

Instantly share code, notes, and snippets.

View rendon's full-sized avatar
🧑‍🔬
Trying new things out.

Rafael Rendón rendon

🧑‍🔬
Trying new things out.
View GitHub Profile
@rendon
rendon / equal.cpp
Created August 3, 2017 05:48
Equal from Hacker Rank
/* Copyright 2017 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
@rendon
rendon / AhoCorasickv2.cpp
Last active August 3, 2017 03:48
A new implementation of the Aho-Corasick algorithm.
/* Copyright 2017 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
const double kEps = 10e-8;
const int kMax = 1000;
const int kInf = 1 << 30;
const int kFail = -1;
@rendon
rendon / threads_excercise.txt
Created July 6, 2017 01:49
Thread excercise
You have a list of numbers, each number is in the range [1,1,000,000], you want
to find the prime factors of all of them. As usual you want to process the list
in the least amount of time, that's why you will will try to parallelize the process.
Implement an algorithm to process the list using threads, at any point you should have at most 8 threads running.
@rendon
rendon / interview_question.txt
Created July 4, 2017 03:35
Interview problem
Implement a LRU (Least Recent Used) cache.
Your system queries a database for every request from your clients, you want to
serve your clients as fast as possible, in order to that you will implement a
cache on top of the database, this cache can store up to 100,000 results and
the eviction policy is LRU, that is, when the cache is full, you will remove
the least-recent used record.
You're implementation should be as efficient as possible because this will be a
critical component of our system.
@rendon
rendon / TableCleaner.java
Created May 6, 2017 17:21
DynamoDB: Truncates table, handy in testing and debugging.
import java.util.Iterator;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.services.dynamodbv2.document.spec.ScanSpec;
import com.amazonaws.services.dynamodbv2.document.ItemCollection;
import com.amazonaws.services.dynamodbv2.document.ScanOutcome;
import com.amazonaws.services.dynamodbv2.document.Item;
@rendon
rendon / TableReaper.java
Created May 2, 2017 21:12
Delete a list of tables, handy in testing and debugging.
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
@rendon
rendon / homework.cpp
Created March 30, 2017 05:07
Uva Homework solution
/* Copyright 2017 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
#include <queue>
#include <map>
@rendon
rendon / frequent_values.cpp
Created March 23, 2017 04:47
Frequent values
/* Copyright 2017 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
#include <queue>
#include <map>
@rendon
rendon / tanques.cpp
Last active February 9, 2017 04:48
Tanques Omegaup DP
/* Copyright 2017 Rafael Rendón Pablo <[email protected]> */
// region Template
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
@rendon
rendon / Main.java
Last active September 30, 2017 19:45
My CF settings
/** Built using CHelper plug-in, Actual solution is at the top. */
//region
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;