Skip to content

Instantly share code, notes, and snippets.

View MM-coder's full-sized avatar
:shipit:
Hunting them bugs

Mauro M. MM-coder

:shipit:
Hunting them bugs
View GitHub Profile
amigos = {}
lines = open("picnic.txt").readlines()
for line in lines:
line = line.split()
amigo = line[0]
amigos[amigo] = {}
i = 1
while i < len(line):
import statistics
notas = {}
lines = open("notas.txt", encoding = 'utf-8').readlines()
for line in lines:
proc = line.split()
notas[proc[0]] = statistics.mean([int(proc[1]), int(proc[2]), int(proc[3]), int(proc[4])])
treasure_numb = 0 # Start tresures on 0
info = input()
info_list = info.split(" ")
numb_chests = int(info_list[0])
init_pos = int(info_list[1])
instruction_numb = int(info_list[2])
locations = str(input())
@MM-coder
MM-coder / median_of_maximum_row.py
Created November 2, 2019 11:53
Get median of matrix line using python
a = [[5,9,19,0,3,-45,7,3,-20],
[-19,2,3,-8,3.5,18.9, 24,3.12,42,9],
[51,9.7,-9,-20,38,-4.5,17,103,-2.8],
[-9,322,33,18,387.5,9018.9,3,0, 2214],
[25,900,-19,10,31,-435,75,34,-240],
[-2.19,2,3,-8,3.5,18.9, 28,32,2]]
import numpy as np
def median(lista: list):
@MM-coder
MM-coder / order_list.py
Created November 2, 2019 11:11
Order list without using sort() or sum() in python
a = [5,9,19,0,3,-45,7,3,-20] # Conjunto de dados aribrários
nova_lista = []
def ordernar_lista(lista: list):
while lista:
minimo = lista[0]
for i in lista:
if minimo > i:
minimo = i
nova_lista.append(minimo)
@MM-coder
MM-coder / soma.py
Created November 2, 2019 10:58
Get the sum of a list without using the sum() function
a = [5,9,19,0,3,-45,7,3,-20]
b = [-19,2,3,-8,3.5,18.9, 24]
def soma(lista: list):
soma = 0
for i in lista:
soma += 1
return soma
@MM-coder
MM-coder / pos_minimo.py
Created November 2, 2019 10:58
Get the position of the minimum number in a dataset without using min()
a = [5,9,19,0,3,-45,7,3,-20]
b = [-19,2,3,-8,3.5,18.9, 24]
def pos_minimo(lista: list):
minimo = lista[0]
for i in lista:
if minimo > i:
minimo = i
return lista.index(minimo)
@MM-coder
MM-coder / media.py
Created November 2, 2019 10:57
Get the mean of a dataset without mean()
a = [5,9,19,0,3,-45,7,3,-20]
b = [-19,2,3,-8,3.5,18.9, 24]
def media(lista: list):
soma = 0
for i in lista:
soma += i
media = round(soma / len(lista), 1)
return media
@MM-coder
MM-coder / maximo.py
Created November 2, 2019 10:56
Get the max of a list without using the inbuilt max() function
a = [5,9,19,0,3,-45,7,3,-20]
b = [-19,2,3,-8,3.5,18.9, 24]
def maximo(lista: list):
maximo = lista[0]
for i in lista:
if maximo < i:
maximo = i
return maximo
@MM-coder
MM-coder / pong.py
Created October 26, 2019 10:45
Pythonic implementation of classic arcade game Pong
# Interactive @ http://www.codeskulptor.org/#user46_IEOQH6HNJcnPhI2_1.py
# Implementation of classic arcade game Pong
import simplegui
import random
# initialize globals - pos and vel encode vertical info for paddles
WIDTH = 600
HEIGHT = 400
BALL_RADIUS = 20