Skip to content

Instantly share code, notes, and snippets.

View willamesoares's full-sized avatar

Will Soares willamesoares

View GitHub Profile
@willamesoares
willamesoares / Derivada
Created February 2, 2014 15:55
Calculating the derivative of a polynomial function.
/*
Name: Derivada
Copyright:
Author: Soares Barroso, Willame
Date: 27/10/13 21:17
Description: Calculation of the derivative of a polynomial function
*/
#include <stdlib.h>
#include <stdio.h>
@willamesoares
willamesoares / BSTNode.py
Last active November 22, 2015 17:05 — forked from stummjr/BSTNode.py
BSTNode.py - Binary Search Tree
# -*- encoding:utf-8 -*-
#from __future__ import print_function
class BSTNode(object):
def __init__(self, key, value=None, left=None, right=None):
self.key = key
self.value = value
self.left = left
self.right = right
@willamesoares
willamesoares / README.md
Last active January 17, 2018 15:55
Hufman's Algorithm

HUFFMAN'S CODE IMPLEMENTATION - PYTHON 2.7

HOW DOES IT WORK?

  • In this specific implementation, the correctness of the code generated can be prooved manually by following the workflow of the algorithm, described below:
  1. A dictionary in Python was used as the primary data structure. In order to deal with all the characters and calculate their frequencies, each character given in the message is added to this dictionary and the values for each key (character) represents its frequency. Due to that, the caracters within the dictionary are automatically sorted in alphabetical order.
  2. In every step, an auxiliar array is generated with sorted items from the dictionary, but this time they are sorted by the values for each key.
  3. With that, the first two items are summed in order to get the frequency for a new node, that represents those characters union.
  4. A
# Configurar Seller, Marketplace, bucket e nome da planilha
seller_id = 923
marketplace = MarketPlace.b2w
bucket = "aleap-willsoares"
sheet_name = "millevine.xls"
# Buscar Seller e AchieveLeap Seller no Marketplace correspondente
s = Seller.find seller_id
as = AchieveLeap::Seller.new s, market_place: marketplace

Git Cheat Sheet

Unstage tracked files

$ git reset HEAD [file]

Undo last commit (keeping changes)

$ git reset --soft HEAD^
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
#string para identificar quando ESC for pressionado
ESCAPE = '\033'
RETURN = '\r'
angle = 45
fAspect = 1
@willamesoares
willamesoares / sudover.py
Last active February 5, 2018 00:05
Sudoku solver using recursive backtracking
import sys
# initial sudoku matrix
V = [
0, 0, 0, 2, 6, 0, 7, 0, 1,
6, 8, 0, 0, 7, 0, 0, 9, 0,
1, 9, 0, 0, 0, 4, 5, 0, 0,
8, 2, 0, 1, 0, 0, 0, 4, 0,
0, 0, 4, 6, 0, 2, 9, 0, 0,
0, 5, 0, 0, 0, 3, 0, 2, 8,
@willamesoares
willamesoares / settings.json
Created January 17, 2018 14:31
VS Code settings
{
"workbench.startupEditor": "newUntitledFile",
"window.zoomLevel": 1,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/vendor": true
},
function revert (arr) {
const len = arr.length
if (len === 1) {
return arr
}
const last = arr.splice(-1,1)
return last.concat(revert(arr))
@willamesoares
willamesoares / recursive_asd.rb
Created March 11, 2018 15:28
Compilers - Recursive Predictive Parser in Ruby
#!/usr/bin/env ruby
require 'pry'
require 'terminal-table'
DELIM = '$'
def get_next_token(input)
@token = input[@counter]
@counter += 1