Skip to content

Instantly share code, notes, and snippets.

View mvenezia's full-sized avatar

Matt Venezia mvenezia

View GitHub Profile
#include "stdafx.h"
#include <iostream>
#include <utility>
using namespace std;
void FillSeatArray(pair<char, bool> arr[][4], int sizeDim1);
// Precondition: arr is a two dimensional array of type pair<char, bool>[4].
// sizeDim1 is the size of the first array dimesion.
// Postcondition: Each four element array of type pair<char, bool> is assigned values
// representing seats. The pair at index 0 is assigned 'A', 1 is assigned 'B',
@mvenezia
mvenezia / Recursive Find Max Val of Any N Ints
Last active January 10, 2019 18:18
This is a solution I came up with while trying to find a unique, extensible way to find the greatest value in a collection of integers. The real cool stuff here exists in the function get_greatest. I could have used a sorting algorithm and then returned the greatest value, but finding a recursive solution was a lot of fun. Very roughly speaking,…
/*
This is a solution I came up with while trying to find a unique, extensible way to find the greatest value in a collection of integers.
The real cool stuff here exists in the function get_greatest.
I could have used a sorting algorithm and then returned the greatest value, but finding a recursive solution was a lot of fun.
Very roughly speaking, the time complexity estimate is between O(n) and O(n^2).
Really the function runs as follows (each term is a new recursive scope): n + (n - 1) + (n - 2) + ... + (n - (n - 2)).
For example if n is 5: 5 + 4 + 3 + 2 = 14.
*/
#include <iostream>
namespace Venezia
{
class Utils
{
public:
template<typename T>
static T* SelectionSort(T arr[], int size)
{
for (int i = 0; i < size - 1; i++)
{
@mvenezia
mvenezia / (C++) Delete Duplicates
Last active July 28, 2018 19:29
This program demonstrates an algorithm for deleting duplicate values of type char in an array.
//This program demonstrates an algorithm for deleting duplicate values of type char in an array.
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::endl;
void DeleteRepeats(char a[], int& numberUsed);
//Precondition: numberUsed is <= declared size of a. a[0] through a[numberUsed - 1] have values of type char.
//Postcondition: All duplicate values in a have been deleted, and numberUsed has been adjusted to reflect
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShieldPowerUp : MonoBehaviour {
#region Member Variables
public static ShieldPowerUp instance;
using UnityEngine;
public class FogFXManager : MonoBehaviour
{
#region Const Member Variables
const int NUM_FOG_SYSTEMS = 4;
#endregion
#region Public Member Variables
public ParticleSystem widePrefab;
namespace VenzMisc
{
// Precondition: prob is between 0.0 and 1.0 inclusive.
// Returns: generates random probability between 0.0 and 1.0 and returns true if randomProb
// is <= prob, else false. Each invocation of this function has a (prob*100.0) percent chance
// of returning true.
bool Probability(float prob)
{
float randomProb = (RAND_MAX - rand()) / static_cast<float>(RAND_MAX);
return (randomProb <= prob) ? true : false;
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <string>
#include <map>
using namespace std;
bool Probability(float prob);
// Precondition: prob is between 0.0 and 1.0 inclusive.
def LowestRootPwr():
'''
This function prompts the user to enter an int.
Returns: Tuple of two ints, root and pwr, such that
root**pwr == userInput, while adhering to the
constraints: 0 < pwr < 6,
root and pwr have the smallest
possible absolute values.
'''
while True: