Skip to content

Instantly share code, notes, and snippets.

View ranisalt's full-sized avatar

Ranieri Althoff ranisalt

View GitHub Profile
@ranisalt
ranisalt / blefe.py
Created March 22, 2015 06:08
OBI 2014 F2N2 Blefe
conj, seq = [int(i) for i in input().split()]
A = [int(i) for i in input().split()][:conj]
jogadas = [int(i) for i in input().split()][:seq]
B = []
for jogada in range(0, len(jogadas)):
if jogadas[jogada] in A:
B.append(jogadas[jogada])
elif len(B) == 0:
@ranisalt
ranisalt / tapetes.py
Created March 22, 2015 04:57
OBI 2014 F2N2 Tapetes
compr, qtd = [int(i) for i in input().split()]
print((compr - qtd + 1) ** 2 + qtd - 1)
@ranisalt
ranisalt / notas.py
Created March 22, 2015 04:38
OBI 2014 F2N2 Notas
qtd_notas = int(input())
notas = [int(nota) for nota in input().split()]
freq, top = {}, (0, 0)
for i in range(0, qtd_notas):
if notas[i] not in freq:
freq[notas[i]] = 0
freq[notas[i]] += 1
for key in freq:
$("a").each(function(c,a){"PDF"==a.innerHTML&&$.get(a.href,function(a){$(a).find("a").each(function(a,b){"Baixar este arquivo PDF"==b.innerHTML&&window.open(b.href,null)})})});
@ranisalt
ranisalt / automount
Last active August 29, 2015 14:16
automount usb
#!/usr/bin/bash
# /usr/local/bin/automount
label=$(blkid -o value -s LABEL $1)
if [[ "x${label}" == "x" ]]; then
label=$(blkid -o value -s UUID $1)
fi
if [[ "x${label}" != "x" ]]; then
dest="/media/${label}"
mkdir -p ${dest}
from builtins import KeyError
import string
class Steckerbrett:
def __init__(self, *args):
self.map = {}
for arg in args:
if arg[0] in self.map or arg[1] in self.map:
@ranisalt
ranisalt / quicksort.py
Created November 3, 2014 17:03
Quicksort funcional
def quicksort(l):
if len(l) == 0:
return l
pivot = l.pop()
return quicksort([x for x in l if x < pivot]) + [pivot] + quicksort([x for x in l if x >= pivot])
@ranisalt
ranisalt / indenter.lua
Created October 23, 2014 02:45
Lua stuff
function cleanPreviousIndentation(line)
return line:gsub("^%s+", ""):gsub("%s+$", "")
end
function escapeString(str)
return str:gsub("[()]", "%%%1")
end
function string:split(delimiter)
local array = {}
#!/usr/bin/env php
<?php
require 'simple_html_dom.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
function cleanPreviousIndentation(line)
return line:gsub("^%s+", ""):gsub("%s+$", "")
end
function escapeString(str)
return str:gsub("[()]", "%%%1")
end
function string:split(delimiter)
local array = {}