Skip to content

Instantly share code, notes, and snippets.

View eduardoklosowski's full-sized avatar

Eduardo Klosowski eduardoklosowski

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eduardoklosowski
eduardoklosowski / advent-of-code-2022-dia-08-parte1.py
Created December 8, 2022 20:14
Advent of Code 2022 - Dia 08
entrada = [[int(b) for b in a.rstrip()] for a in open('8/input')]
visivel = set()
for i in range(len(entrada)):
m = -1
for j in range(len(entrada[i])):
a = entrada[i][j]
if a > m:
visivel.add((i, j))
m = a
if m == 9:
@eduardoklosowski
eduardoklosowski / advent-of-code-2022-dia-06.py
Created December 8, 2022 17:17
Advent of Code 2022 - Dia 06
window = 14
for line in open(0):
chars = [-1 for _ in range(256)]
equal = -1
for i, c in enumerate(ord(c) for c in line):
if chars[c] > equal:
equal = chars[c]
else:
if i - equal == window:
print(i + 1)
@eduardoklosowski
eduardoklosowski / Makefile
Last active October 26, 2022 03:01
Análise de desempenho de um código iterativo e recursivo para percorrer uma árvore binária
CC=gcc
CFLAGS=-O3
.PHONY: all clean
all: dados.csv
numeros.txt: numeros.py
python3 $<
dados.csv: run.sh numeros.txt iterativo recursivo
@eduardoklosowski
eduardoklosowski / analise.ipynb
Created July 8, 2022 11:37
Comparação dos loops do asyncio e do uvloop no cPython 3.10 e PyPy 3.9-7.3.9
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eduardoklosowski
eduardoklosowski / violino.ly
Last active February 4, 2020 03:47
Estrutura de arquivo do LilyPond para violino - https://www.hacklily.org/
\version "2.18.2"
\language "portugues"
\header {
dedication = ##f
title = "Escala de Dó Maior"
subtitle = ##f
subsubtitle = ##f
instrument = ##f
composer = ##f
#!/usr/bin/env python3
'''
http://dojopuzzles.com/problemas/exibe/matriz-espiral/
'''
from enum import Enum
from math import log10
from os import linesep
@eduardoklosowski
eduardoklosowski / dados.csv
Last active November 29, 2017 13:45
Processamento de tabela em R
x y
20 1.79
41.5 3.49
100 5.99
110 4.99
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
# Entrada
lado = int(raw_input('Lado: '))
if lado % 2 == 0 or lado <= 0:
import System.Environment
import Data.List
type Elemento = String
type Par = (Elemento, Elemento)
type Custo = Int
type Aresta = (Par, Custo)
type Grafo = [Aresta]