Skip to content

Instantly share code, notes, and snippets.

View Marceeaax's full-sized avatar
🙃
just living life

Marcelo Aguayo Marceeaax

🙃
just living life
View GitHub Profile
@Marceeaax
Marceeaax / transitivityoperations.py
Last active September 16, 2021 01:18
This program shows all the operations performed when calculating the transitivity of a fuzzy relation
C = [[1, 0.8,0.9], [0.8, 1,0.9],[0.9, 0.9,1]]
def operations(i,j,k,X):
print("X[" + str(j) + "]" + "[" + str(k) + "] >= max(X[" + str(j) + "]" + "[" + str(k) + "],min(X[" + str(j) + "]" + "[" + str(i) + "],X[" + str(i) + "]" + "[" + str(k) + "]))")
print(str(X[j][k]) + " >= max(" + str(X[j][k]) + ",min(" + str(X[j][i]) + "," + str(X[i][k]) + "))")
print(str(X[j][k]) + " >= max(" + str(X[j][k]) + "," + str(min(X[j][i],X[i][k])) + ")")
print(str(X[j][k]) + " >= " + str(max(X[j][k],min(X[j][i],X[i][k]))))
print("----------------")
def transitive(X):
@Marceeaax
Marceeaax / fuzzyrelationgenerator.py
Last active September 8, 2021 20:36
An algorithm that generates a transitive, symmetric and reflexive fuzzy relation using random generated numbers. A better approach is required since for N > 3 the algorithm becomes extremely slow
import random
def reflexive(X):
firstvalue = X[0][0]
if(firstvalue != 1):
return False
else:
for i in range(1,len(X)):
if(X[i][i] != firstvalue):
return False
@Marceeaax
Marceeaax / fuzzyrelationscompositions.py
Created September 3, 2021 16:26
In this snippet, I made a function that calculates the max-min and min-max composition of two fuzzy relations. If you use it in a Jupyter Notebook, there's no need to import the numpy and Ipython libraries
import numpy as np
from IPython.display import display, Markdown
def maxmincomposition(X,Y):
C = np.zeros((X.shape[0],Y.shape[1]))
# Iterar a traves de las filas de A
for i in range(len(X)):
# Iterar a traves de las columnas de B
for j in range(len(Y[0])):
@Marceeaax
Marceeaax / Duolingo hack.ahk
Created March 8, 2021 19:11
How to earn xp easily and quickly (you also need the DuoHacker extension)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
!j::
Loop, 1414
{
MouseClick, left, 527, 440
MouseClick, left, 913, 700
@Marceeaax
Marceeaax / programacionlineal.r
Last active February 22, 2021 21:38
Un problema de programación lineal resuelto por el método gráfico utilizando el lenguaje de programación R
# Definir restricciones
restriccion.1 <- function(x) 30 - x
# restriccion.2 x1 = 10 (Se dibuja usando geom_vline)
# restriccion.3 x2 = 10 (Se dibuja usando geom_vline)
# restriccion.4 x1 = 0 (Eje de abscisas)
# restriccion.4 x2 = 0 (Eje de ordenadas)
# Importar ggplot2 paquete
library(ggplot2)
#Python script that renames files by removing a specific common pattern among them
import os
for every in os.scandir(): #loop through all files in current directory
if every.name.startswith('y2mate'): #if file matches the pattern
os.rename(every.name,every.name.replace('y2mate.com - ', '')) #rename file
print(every.name) #shows filenames
input("Archivos renombrados !!!") #this command prevents python from closing immediately