Skip to content

Instantly share code, notes, and snippets.

View vladymir's full-sized avatar

Vladymir Bezerra vladymir

View GitHub Profile
@vladymir
vladymir / gist:2476510
Created April 24, 2012 04:47
Integracao de funcao por trapézios - MSN 2012.1
# Exercicio 2 - MSN
# Professor: Antao Moura
# Aluno: Vladymir Bezerra
# Integracao por trapezios.
import math, numpy
## f(x) = e^x * x
def funcao(x):
return math.exp(x) * x
@vladymir
vladymir / projeto.py
Created May 18, 2012 16:21
Resolução de problema de programação linear.
##
# Universidade Federal de Campina Grande
# Departamento de Sistemas e Computacao
# Professor: Antao Moura
# Grupo: Rafael Figueiredo
# Raul Correia
# Vladymir Bezerra
#
# == Projeto Final de MSN ==
# Descricao: O objetivo deste script e' maximizar o lucro de uma empresa
@vladymir
vladymir / form.html
Created July 31, 2012 01:12
Formulário com field dinâmico
<html>
<h1> Formulario Dinamico</h1>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#mais').click(function(){
var next = $('#lista tbody').children('tr').length + 1;
$('#lista tbody').append('<tr>' +
'<td class="linha-left"><input type="text" name="item' + next + '" /></td>' +
import datetime
dias = ['segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado', 'domingo']
meses = ['', 'janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro']
startdate = datetime.date(2012,1,1)
while(startdate.year == 2012):
if startdate.weekday() in [5,6]:
print "%s %d %s" % (meses[startdate.month],startdate.day,dias[startdate.weekday()])
startdate += datetime.timedelta(1)
package monoids;
public abstract class Monoid<T> {
public abstract T combine(T one, T other);
public abstract T identity();
public T fold(Iterable<T> elements) {
T result = identity();
for (T i : elements) {
###########################
## JOGO DA VELHA ##
## IFCE - Boa Viagem ##
###########################
# Copyright: Vladymir Bezerra
# O Jogo todo é representado apenas por funcoes. Cada funcao tem uma funcionalidade
# bastante específicas. As funcoes devem ser pequenas e devem fazer apenas UMA coisa.
def menu():
opt = -1
while opt != 4:
print(""" ##########################################################
## ##
## Escolha um Menu: ##
## 1 ) Menu 1 ##
## 2 ) Menu 2 ##
## 3 ) Menu 3 ##
## 4 ) Sair ##
@vladymir
vladymir / bfs.py
Created December 18, 2017 18:11
BFS and DFS
from collections import deque
from math import inf
# BFS (Breadth-First Search) implementado em Python3
# Prof. Vladymir Bezerra
#chamar BFS(grafo1, 2)
grafo1 = [[1], [0,2], [1,3], [2,4,5], [3,5,6,7], [3,4,6], [4,5,7], [4,6]]

Fecho Transitivo e Reflexivo

Seja um conjunto A = {a,b,c} e R uma relação em A onde R = {(a,b), (b,c)}, o fecho transitivo deve conter a tupla (a,c), uma vez que (a,b) e (b,c) pertencem à R, então, por transitividade, (a,c) deve estar na nova relação: R+ = {(a,b),(b,c),(a,c)} Já o fecho reflexivo de R resulta em {(a,b),(b,c),(a,a),(b,b),(c,c)} O fecho transitivo-reflexivo será {(a,b),(b,c),(a,c),(a,a),(b,b),(c,c)}

Já a função flatten, o exemplo é o seguinte: seja A uma lista A=[1,[2,[3,[4]]]], flatten(A) = [1,2,3,4] (obs. não importando a profundidade do aninhamento das listas, a função deve sempre retornar uma lista plana)

Flatten

@vladymir
vladymir / banco1.sql
Last active November 13, 2019 20:30
Exemplo para aula de BD
CREATE TABLE Pessoa (
id_pessoa int NOT NULL AUTO_INCREMENT,
nome VARCHAR(255) NOT NULL,
PRIMARY KEY(id_pessoa));
CREATE TABLE Gato (
id_gato int NOT NULL AUTO_INCREMENT,
nome VARCHAR(255) NOT NULL,
id_pessoa int,
PRIMARY KEY(id_gato),