Skip to content

Instantly share code, notes, and snippets.

View henriqueblang's full-sized avatar

Henrique Barcia Lang henriqueblang

View GitHub Profile
@henriqueblang
henriqueblang / rle.py
Last active June 13, 2020 03:04
RLE zigzag
def RLE_zigzag_encoder(data, rows, columns):
encoding = []
prev = data[0][0]
count = 1
go_down = None
change_direction = True
next_position = [0, 1]
@henriqueblang
henriqueblang / greedy_search.py
Created March 10, 2020 17:55
Greedy Algorithm to solve Sliding Puzzle
import heapq
class GreedySearch(object):
'''
This class implements the greedy search algorithm.
'''
def __init__(self, problem):
'''
Constructor
@henriqueblang
henriqueblang / image.py
Created November 7, 2019 19:50
Image manipulation
import numpy as np
import matplotlib.pyplot as plt
img = plt.imread("gabriel.jpg")
gray = np.zeros(np.shape(img))
for i in range(img.shape[0]):
for y in range(img.shape[1]):
pixel = img[i, y, :]
@henriqueblang
henriqueblang / beiju_text.cpp
Last active August 30, 2019 01:42
(URI) 1451 - Teclado Quebrado
// (URI) 1451 - Teclado Quebrado
#include <iostream>
#include <string.h>
int main()
{
bool writeOnHome;
std::string inputString;
@henriqueblang
henriqueblang / insert_front.cpp
Last active June 8, 2019 02:01
Insert a value at front for deque data structure
/** Inserting value at first index of vector and push the others to the right
* @vector - vector
* @size - vector total size
* @value - value to be added
*/
void insertAtFront(int vector[], int size, int value)
{
int aux_1, aux_2 = value;
for(int i = 0; i < size; i++)
@henriqueblang
henriqueblang / projeto_E209.c
Last active June 11, 2019 21:21
Código do projeto de E209 (microcontroladores)
#include <msp430g2553.h>
#include <stdio.h>
/* Constantes, variáveis e protótipos de funções */
#define BUTTON BIT3
#define SENSOR1 BIT4
#define SENSOR2 BIT5
#define S_MOTOR BIT7
@henriqueblang
henriqueblang / RoundButton.java
Created June 5, 2019 19:27
Round Button java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gui;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;