Skip to content

Instantly share code, notes, and snippets.

View pvsousalima's full-sized avatar
💭
(sometimes) I may be slow to respond.

Pedro Victor pvsousalima

💭
(sometimes) I may be slow to respond.
View GitHub Profile
@pvsousalima
pvsousalima / gnomes.tcl
Created October 7, 2014 21:34
Missouri's State CSC-333 Warmup to Project 1 using TCL language
set comment {
PROBLEM B: GNOME SEQUENCING
In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be
bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three,
ordered by the length of their beards. The gnomes, being of different physical heights,
vary their arrangements to confuse the goblins. Therefore, the goblins must actually measure the beards
in centimeters to see if everyone is lined up in order.
Your task is to write a program to assist the goblins in determining whether or not
the gnomes are lined up properly, either from shortest to longest beard or from longest to shortest.
@pvsousalima
pvsousalima / primo.c
Last active August 29, 2015 14:04
Módulo de Kernel do Linux que calculo números primos a partir de um device montado no /dev/primo e imprime o resultado na entrada /proc/primo
/* Necessary includes for device drivers */
#include <linux/module.h> /* modulo de kernel */
#include <linux/kernel.h> /* printk() */
#include <linux/slab.h> /* kmalloc() */
#include <linux/types.h> /* size_t */
#include <linux/proc_fs.h> /* /proc */
#include <linux/miscdevice.h>
#include <linux/seq_file.h> // for sequence files
#include <asm/uaccess.h> /* copy_from_user e copy_to_user */
@pvsousalima
pvsousalima / HUE.py
Last active August 29, 2015 13:59
This python script generates a lot of zueira
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
tips:
- If you're BR respond "BR"
- Else, repond HUE.
'''
@pvsousalima
pvsousalima / main.c
Last active December 15, 2015 02:49
/*
* File: main.c
* Author: pedro
*
* Created on 18 de Março de 2013, 10:10
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 20
typedef struct Nodo {
int inteiro;
struct Nodo *pProximo;
} Nodo;
#include<stdio.h>
#include<stdlib.h>
int binaria(int elem, int v[], int tam, int* contador) {
(*contador)++;
int inicio = 0, meio = 0, fim = tam - 1, k = -1;
while ((inicio <= fim) && (k == -1)) {
meio = ((inicio + fim) / 2);
if (elem == v[meio]) {
k = meio;
int TentaAVL(Arvore Raiz){
if(Raiz==NULL){
return;
} else {
int Balanceamento = altura(Raiz->direita) - altura(Raiz->esquerda);
if ((Balanceamento>=2)||(Balanceamento<=-2)){
return 0;
}
TentaAVL(Raiz->direita);
TentaAVL(Raiz->esquerda);
@pvsousalima
pvsousalima / RemoveNode.c
Created December 18, 2012 01:29
A method for remove a specific node from a Binary Search Tree. By pvsousalima.
void Remove(int key, Tree *MyTree) {
if (*MyTree == NULL) {
printf("Not found.\n");
} else if ((*MyTree)->REG.number > key) {
Remove(key, &(*MyTree)->left);
} else if ((*MyTree)->REG.number < key) {
Remove(key, &(*MyTree)->right);
} else {
if ((*MyTree)->right == NULL && (*MyTree)->left == NULL) {
printf("%d deleted.\n", (*MyTree)->REG.number);
@pvsousalima
pvsousalima / BubbleSort.c
Created November 15, 2012 00:51
Ordena valores Matriz (BubbleSort)
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define LINHA 5
#define COLUNA 6
int MatrizBubble[LINHA][COLUNA];
inline void troca(int* a, int* b){
int aux = *a;