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
#include <bits/stdc++.h>
using namespace std;
class Solution {
private:
vector<int> primes;
unordered_map<int, vector<int>> factors;
unordered_map<int, vector<size_t>> revFactors;
void computePrimes(int max) {
@rendon
rendon / fb_challenge.cpp
Last active November 29, 2019 01:29
A FB challenge
// Compile with C++ 17
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long int64;
@rendon
rendon / scaler.sh
Last active July 5, 2021 16:13
A script to scale images using ImageMagick
#!/usr/bin/env bash
SOURCE_DIRECTORY=$1 # Provide absolute path
TARGET_DIRECTORY=$2 # Provide absolute path
if [ ! -d $SOURCE_DIRECTORY ]
then
echo "Source directory ${SOURCE_DIRECTORY} does not exist"
exit 1
fi
#include <bits/stdc++.h>
using namespace std;
int const kInf = 1 << 29;
struct edge {
int node;
int cost;
};
struct state {
// NOTE: Code from my early beginnings (circa 2010).
#include<iostream>
#include <cstdio>
#define MAX_V 1001
#define INFINITO 1000000 //Cualquier valor mas grande que los pesos que usemos
void InicializaArreglos();
void Dijkstra(int NodoInicial);
int AunEncolado(int nodo);
int DevuelveMinimo();
#include <bits/stdc++.h>
using std::vector;
void printAnswer(int frequency, int station) {
if (frequency < station) {
std::cout << "adelante " << station - frequency << "\n";
} else if (frequency > station) {
std::cout << "atras " << frequency - station << "\n";
}
}
#include <bits/stdc++.h>
using std::vector;
bool cycleIsIncomplete(vector<int> const & sequence, int a, int b, int idx) {
unsigned m = sequence.size();
int aa = sequence[(idx-2+m)%m];
int bb = sequence[(idx-1+m)%m];
return aa != a || bb != b;
}
#include <bits/stdc++.h>
using std::vector;
int main() {
int N;
std::cin >> N;
vector<bool> sieve(N);
int a = 1, b = 1;
sieve[a] = true;
sieve[b] = true;
#include <bits/stdc++.h>
using std::vector;
using std::pair;
using std::set;
using std::unordered_map;
using std::unordered_set;
void updateIndex(vector<int> const& ballot, int& index, unordered_set<unsigned> const& losers, int C) {
while (index < C) {
int candidate = ballot[index];
@rendon
rendon / Merriam-WebsterHelper.js
Last active March 17, 2024 22:13
A script that add the saved status to the Word of the Day page so you don't have to click on the "See the entry" link, thus saving you a few precious seconds
// ==UserScript==
// @name Merriam-Webster Helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description A tiny script that makes merriam-webster.com/ work nicely with Vimium, namely, it removes the focus from the search bar so that you can use the vim commands to move around.
// @author Rafael Rendon Pablo
// @run-at document-idle
// @match https://www.merriam-webster.com/
// @match https://www.merriam-webster.com/word-of-the-day
// @match https://www.merriam-webster.com/word-of-the-day/*