Skip to content

Instantly share code, notes, and snippets.

@macroxela
macroxela / CoinChangeWays.py
Created May 7, 2020 13:21
Find how many ways you can make change with infinite amount of coins c = [c1, c2, ..., cm] for change N
############################################################################
#Find how many ways you can make change with coins c = [c1, c2, ..., cm]
#for change N. Similar to the Subset Sum problem
#
############################################################################
#Dynamic Programming Solution
def cchange(Cents, coins):
#Initialize matrix to store values
matrix = [[0 for i in range(0, cents+1)] for j in range(0, len(coins)+1)]
@macroxela
macroxela / allPermutations.py
Created May 7, 2020 13:19
Function to find all permutations of a given string
#########################################################################
# Finds all permutations of a given string by using a tree-structure #
# It sets two counters, i and j with 0 < i <= j < length(string) #
# While keeping i fixed, iterates j through the remaining characters, #
# swapping each one with the character at i and adding it to a list #
# if the new string isn't on the list. Example shown below for 'abc' #
# #
# (abc) #
# | | | #
# | | | #
##########################################################################################################
# Balanced Brackets Verifier #
# • For the balanced parentheses problem, checks if any kind of brackets are balanced #
# Brackets can be mixed including () [] and {} #
# • Creates random sequences of brackets #
# #
# Alex Marroquin #
# 29 April 2020 #
# #
#############################################################
@macroxela
macroxela / Parser.h
Created October 2, 2017 18:42
A C++ string parser
#ifndef _PARSER_H
#define _PARSER_H
#include <string>
using namespace std;
void cutstring(string &input, int pos)
{
string dummy = "";
@macroxela
macroxela / PasswordHash.php
Created October 8, 2015 00:18
A Javascript code editor with teacher version and student version. Allows user to write Javascript code to solve a certain problem which the site then runs and states whether it is the correct solution or not. Developed in team of 2.
<?php
#
# Portable PHP password hashing framework.
#
# Version 0.3 / genuine.
#
# Written by Solar Designer <solar at openwall.com> in 2004-2006 and placed in
# the public domain. Revised in subsequent years, still public domain.
#
# There's absolutely no warranty.
@macroxela
macroxela / Matrix.h
Last active April 15, 2020 15:41
A matrix header file that allows for matrix addition, subtraction, and multiplication with method calls & operator overloading
#ifndef _MATRIX
#define _MATRIX
/*
Matrix Header File
Matrix library that allows creation, addition,
subtraction, and multiplication of matrices.
2 Dimensional matrices only
@macroxela
macroxela / Knapsack.cpp
Created October 20, 2014 23:56
Given a sequence of values/weights the program finds the collection of items which will lead to the largest value without going over the weight limit.
/**********************************************
Knapsack Problem
Alex Marroquin
12 March 2014
Given a sequence of problems and maximum weight
the objective is to find the collection of
items which will add up to the highest value
while remaining under the weight limit.
**********************************************/
@macroxela
macroxela / Clock.java
Created April 24, 2014 23:43
Final project for Object Oriented course, basically a mini version of a Zelda dungeon. Includes various enemies, mid level boss and final boss. Rooms have to be accessed sequentially to unlock them.
/*
Code From DaniWeb
http://www.daniweb.com/software-development/java/threads/162294/clock.java
*/
import java.util.*;
import java.text.*;
public class Clock
{
@macroxela
macroxela / Combatant.java
Created April 24, 2014 23:32
A simple turn based game with a Pokemon theme. The user selects which type to start off with and battles their way through. The player's Pokemon can level up, evolve and learn new moves.
import java.util.*;
public class Combatant {
double hp, attack, defense, speed;
String name, type, attribute;
Random ran = new Random();
Combatant()
{
name = "None";
@macroxela
macroxela / Cell.java
Created April 24, 2014 23:25
A randomly generated maze in which the player must escape from the computer. The computer calculates the shortest path every time the player moves using breadth first search (current implementation) or Djikstra's Algorithm (commented implementation)
import java.awt.*;
import javax.swing.*;
//A single cell in the game world
public class Cell
{
//walkable true means your a path, false means you're a wall
boolean walkable, marked, path;
int weight, distance;