Skip to content

Instantly share code, notes, and snippets.

View Samu31Nd's full-sized avatar
🍃
Studying 24/7

Samuel Leyva Samu31Nd

🍃
Studying 24/7
  • Mexico City
  • 06:24 (UTC -06:00)
View GitHub Profile
@Samu31Nd
Samu31Nd / protocol.go
Created January 6, 2025 05:24
GBN with Files
package main
const (
ErrorCommunication int = iota - 1
StartCommunication
ContinueCommunication
EndCommunication
SizeOfParts = 900 //since the header adds some space, we reduce the size of the file content
)
@Samu31Nd
Samu31Nd / Receiver.go
Last active December 22, 2024 00:55
GBN in Go - example
package main
//SERVER
import (
"encoding/json"
"fmt"
"log"
"net"
"strconv"
"time"
@Samu31Nd
Samu31Nd / EjercicioResuelto.js
Last active October 11, 2024 15:36
Practica 5 - Logica de primer orden
//EjercicioPropuesto
import { round } from "https://deno.land/x/[email protected]/round.ts";
import { sqrt } from "https://deno.land/x/[email protected]/sqrt.ts";
/**
* Funcion que aplica un predicado en cada uno de los elementos
* y tiene que cumplirse en todos para devolver true.
* @param {Function} predicate predicado
* @param {Array<Number>} arr arreglo
* @returns Number
@Samu31Nd
Samu31Nd / palindromo.c
Created January 6, 2024 02:44
Programa del palindromo hecho en C. Para ver el resultado, se checa el archivo output.txt dejado en el mismo directorio.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//GLOBAL VARIABLES
char numAux;
int n;
int size;
char *palindromo();
@Samu31Nd
Samu31Nd / Main.java
Last active June 13, 2023 01:27
[Programación dinamica] Problema de los billetes
import java.util.*;
public class Main {
static Scanner read = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("Enter the amount of change to get: ");
int change = read.nextInt();
utilsBill algorithm = new utilsBill(new int[]{1,4,6}, change);
algorithm.fillTables();
@Samu31Nd
Samu31Nd / Main.java
Created May 14, 2023 22:26
Max Subarray using Divide and Conquer and Kadane algorithm
import java.util.Random;
public class Main {
public static void main(String[] args) {
int [] arr1 = {13,-3,-25,20,-3,-16,-23,18,20,-7,12,-5,-22,15,-4,7};
kadane.max_sum(arr1);
algorithm.init(arr1);
int [] arr2 = algorithm.aleatoryArray(25);
algorithm.init(arr2);
@Samu31Nd
Samu31Nd / Main.java
Last active May 7, 2023 21:49
Square Matrix Multiply w/Strassen Method
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Insert the length of the matrix: ");
int n = scanner.nextInt();
@Samu31Nd
Samu31Nd / QuickSortExplained.c
Created April 1, 2023 15:14
Quick Sort with Partition Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#define VAL_MAX 500
#define SPACING 8
#define MAX_SHOWING 50
#define N_VALUES 8
@Samu31Nd
Samu31Nd / QuickSort.c
Created March 30, 2023 05:18
Quick Sort [with and without randomized element]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#define VAL_MAX 500
#define SPACING 8
#define MAX_SHOWING 50
@Samu31Nd
Samu31Nd / algorithmComplexity.c
Last active March 24, 2023 07:45
Algorithms Complexity
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#define VAL_MAX 500
#define SPACING 8
#define MAX_SHOWING 50