Skip to content

Instantly share code, notes, and snippets.

init_1 = 94 * len
init_2 = 218 + 106 * (len - 1)
if file > "2GB":
if other_file >= 2GB:
j+=150
elif other_file > 2045222520:
j+=134
else:
j+=106
@sandes
sandes / us_states.py
Created March 28, 2019 03:59
A python tuple of tuples with all US states
class UnitedStates:
states = (
('AL','Alabama'),
('AK','Alaska'),
('AS','American Samoa'),
('AZ','Arizona'),
('AR','Arkansas'),
('CA','California'),
('CO','Colorado'),
('CT','Connecticut'),
#include <iostream>
using namespace std;
int *miny(int *v,int n){
int x=v[0],jmin=0;
for (int i=0; i<n; i++){
if(v[i]<x){
jmin=i;
x=v[jmin];
}
#include <iostream>
#include <list>
using namespace std;
int ascendente(list<int>&L,list<list<int>>&LL){
auto p = L.begin();
while(p!=L.end()){
auto q=p;
q++;
list<int>tmp;
@sandes
sandes / oauth_instagram.py
Created January 16, 2015 14:40
Get access token instagram
import pycurl,urllib
try:
# python 3
from urllib.parse import urlencode
except ImportError:
# python 2
from urllib import urlencode
curl = pycurl.Curl()
curl.setopt(pycurl.URL,"https://api.instagram.com/oauth/access_token")
#include <iostream>
#include <vector>
using namespace std;
void inssort(vector<int> &a){
int n = a.size();
for(int j=1; j<n; j++){
int x = a[j];
int k=j;
while(--k>=0 && x<a[k])
#include <iostream>
#include <list>
#include <map>
using namespace std;
/*show list of integers with C++ standard 1998*/
void display_98(list<int> &L){
list<int>::iterator p = L.begin();
while(p!=L.end()){
cout << *p << ' ';
#include <iostream>
#include <list>
#include <map>
using namespace std;
/*NOTA: es necesario compilar con -std=c++11 (standard 2011)*/
/*
-Si una clave key esta contenida en A o B pero no en ambos, entonces C no debe contener dicha clave.
-Si una clave key esta contenida en A y B a la vez, entonces C debe contener dicha clave y su valor
#include <iostream>
#include <map>
using namespace std;
typedef map<int,int> map_p;
bool areinverse(map_p M1, map_p M2){
if(M1.size()!=M2.size()) return false;
map_p::iterator p = M1.begin();
while(p!=M1.end()){
if(M2.find(p->second)!=M2.end()){
@sandes
sandes / expand.cpp
Created November 27, 2014 13:47
Aviso: compilar con gcc-> g++ -std=c++11 -o program.bin expand.cpp
#include <iostream>
#include <list>
using namespace std;
list<int> crear_expand(int n,int m){
list<int> l; int sum=0;
while(sum<n){
if((sum+m)>n){
sum+=1;
l.push_back(1);