This file contains 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
// Reference: https://en.wikipedia.org/wiki/Base64 | |
#include <bits/stdc++.h> | |
using namespace std; | |
const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
int getValue(char c) { | |
int len = strlen(alphabet); | |
for (int i = 0; i < len; i++) { | |
if (c == alphabet[i]) { return i; } |
This file contains 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
// ==UserScript== | |
// @name LeetCode Helper | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Facilitate interactions with the LeetCode website. It adds one button on the top-left to easily copy the problem ID and problem URL. | |
// @author Rafael Rendon Pablo | |
// @match https://leetcode.com/problems/*/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com | |
// @run-at document-idle | |
// @grant none |
This file contains 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
// ==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/* |
This file contains 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 <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]; |
This file contains 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 <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; |
This file contains 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 <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; | |
} |
This file contains 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 <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"; | |
} | |
} |
This file contains 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
// 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(); |
This file contains 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 <bits/stdc++.h> | |
using namespace std; | |
int const kInf = 1 << 29; | |
struct edge { | |
int node; | |
int cost; | |
}; | |
struct state { |
This file contains 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
#!/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 |
NewerOlder