Skip to content

Instantly share code, notes, and snippets.

@Biazus
Biazus / main.cpp
Created September 14, 2014 21:29
Desafios: Bicoloring
#include <iostream>
using namespace std;
int matrix[199][199]; //maximo eh 200
int gr[199];
int x[199];
bool isBicolorable;
void f(int n){
@Biazus
Biazus / main.cpp
Last active February 14, 2023 17:11
Desafios: Let Me Count The Ways
#include<cstdio>
#include<iostream>
//Fácil - Let Me Count The Ways
using namespace std;
int main() {
long ways[30001] = {0}; //se nao colocar double da valor negativo
@Biazus
Biazus / tacalepau.c
Last active August 29, 2015 14:07
Etapa 5 Compiladores
#include "tacalepau.h"
#include<stdlib.h>
TAC* makeBinOp(int type, TAC* code0, TAC* code1);
TAC* makeIf(TAC* code0, TAC* code1);
TAC* tacCreate(int type, HASH_NODE *res, HASH_NODE *op1, HASH_NODE *op2){
TAC* newtac = 0;
newtac = (TAC*) calloc(1,sizeof(TAC));
@Biazus
Biazus / hash.c
Last active August 29, 2015 14:07
Etapa 5 Compiladores - hash
HASh_NODE *makeTemp(void)
{
static int nextTemp = 0;
static char tempName[256];
sprintf(tempName,"myStrangeeTemp%d", nextTemp++);
return hashInsert(HASH_VARIABLE, tempName);
}
HASh_NODE *makeLabel(void)
@Biazus
Biazus / medium.cpp
Created November 21, 2014 13:09
10297 - Beavergnaw
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<cmath>
#include <iomanip>
#define PI 3.14159265
using namespace std;
@Biazus
Biazus / easy.cpp
Created November 21, 2014 13:10
11227 - The silver bullet
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <cstdlib>
using namespace std;
const int MAX = 120;
struct position {double x,y;};
@Biazus
Biazus / MonitorTester.java
Created March 26, 2015 13:12
Monitores em Java
import java.util.Random;
class MyMonitor {
private int data = 0;
private int turn = 1;
public synchronized void update(int id) throws InterruptedException {
while(turn != id)
@Biazus
Biazus / main.c
Created January 21, 2017 01:02
Deque-STL Solution (without deque) - https://www.hackerrank.com/challenges/deque-stl
#include <iostream>
#include <algorithm> // std::sort
#include <map>
using namespace std;
void printKMax(int arr[], int n, int k){
vector<pair<int,int> > d;
for(int i=0; i<n;i++){
d.push_back(make_pair(arr[i],i));
}
sort(d.rbegin(),d.rend());
@Biazus
Biazus / context_manager.py
Last active February 14, 2023 17:18
Context Manager to override django settings
from django.conf import settings
class OverrideSetting(object):
"""
Enable the temporary change of a setting. Useful for disabling settings when testing or creating fixtures on dev
environment.
CAUTION: Do not use it to change production settings.
"""
@Biazus
Biazus / abstract_factory_azion.py
Last active March 12, 2020 18:32
Sample of abstract factory by Miller Biazus
#!/usr/bin/env python3
from abc import ABC, abstractmethod
class AbstractFunction(ABC):
@abstractmethod
def install_function(self):
pass