Skip to content

Instantly share code, notes, and snippets.

View mikebsg01's full-sized avatar
📚
Creativity Is Intelligence Having Fun!

Michael Serrato mikebsg01

📚
Creativity Is Intelligence Having Fun!
View GitHub Profile
@mikebsg01
mikebsg01 / FunctionLanguageAutomaton.py
Last active November 25, 2023 02:55
First Automaton in Python - Deterministic Finite Automaton (DFA)
mergeDict = lambda a, b: {**a, **b}
listaDeLetras = [chr(x) for x in range(97, 123)]
listaDeNumeros = [str(x) for x in range(0, 10)]
listaDeOperadores = ['=', '+', '-', '*', '/']
listaDeSeparadores = [';']
evalLetraDeclaracion = {x: 'Declaracion' for x in listaDeLetras}
evalNumeroDeclaracion = {n: 'Declaracion' for n in listaDeNumeros}
evalNumero = {n: 'Numero' for n in listaDeNumeros}
@mikebsg01
mikebsg01 / oop-with-accessors-lamborghini-example.rb
Created October 18, 2022 17:23
OOP with Accessors in Ruby - Lamborghini Example
# Useful content: https://stackoverflow.com/questions/4370960/what-is-attr-accessor-in-ruby
class MyObject
attr_reader :model
def initialize arg
puts "This is an object"
puts "Argument obtained: #{arg}"
@model = arg
end
@mikebsg01
mikebsg01 / Exam1.cu
Last active May 23, 2020 00:09
Parallel programming - Exam #1 - By: Michael Serrato
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
/**
* @author Michael Serrato
@mikebsg01
mikebsg01 / VectorSum_by_MichaelSerrato.cu
Last active March 9, 2020 20:53
Vector Sum in CUDA C++ - By: Michael Serrato
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
/**
* @author Michael Serrato
@mikebsg01
mikebsg01 / client.py
Created February 4, 2020 05:23
Chat with Sockets in Python 3
import socket, threading, sys, pickle
class Client():
def __init__(self, host: str = '127.0.0.1', port: int = 5000, nickname: str = None, buffer_recv: int = 4096):
self.buffer_recv = buffer_recv
self.nickname = nickname
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((host, port))
@mikebsg01
mikebsg01 / IntervalProduct.cpp
Created January 29, 2019 07:08
12532 - Interval Product
#include <bits/stdc++.h>
using namespace std;
int N,K;
int List[100002]={0};
int BIT1[100002]={0};
int BIT2[100002]={0};
void update(int* A, int idx, int val){
while(idx<=N){
A[idx]+=val;
idx += (idx&(-idx));
@mikebsg01
mikebsg01 / LinearPascalWithPrimeModulo.cpp
Created November 19, 2018 21:07
Pascal (Linear Complexity) with Prime Modulo (Extended GCD)
#include <bits/stdc++.h>
#define optimize_io ios_base::sync_with_stdio(0);cin.tie(0);
#define dd(x) cout << #x << ": " << x << endl;
#define MAXN ((int)(1e6+5))
#define MOD ((int)(1e9+7))
#define NOT_DEFINED -1
using namespace std;
typedef unsigned long long int ulli;
typedef long long int lli;
@mikebsg01
mikebsg01 / DP-Pascal-Triangle-with-Bitmasks.cpp
Created October 23, 2018 07:30
Pascal's Triangle with Bitmasks (DP Solution)
#include <bits/stdc++.h>
#define dd(x) cout << #x << ": " << x << endl;
#define MAXN 1000003
#define MOD 1000000007
using namespace std;
typedef long long int lli;
int N;
lli dp[2][MAXN];
@mikebsg01
mikebsg01 / TopoSort.cpp
Created October 19, 2018 21:41
Topological Sort
#include<iostream>
#include <list>
#include <stack>
using namespace std;
// Class to represent a graph
class Graph
{
int V; // No. of vertices'
@mikebsg01
mikebsg01 / Dijkstra.cpp
Created November 27, 2017 10:02
Problem: Printing the Shortest Path with Dijkstra Algorithm - By: Michael Serrato
/*
* ALGORITHM: Dijkstra
*
* @author Michael Serrato <mikebsg01@gmail.com>
*/
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <map>