Instantly share code, notes, and snippets.

View Recursive Find Max Val of Any N Ints
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>
View Namespace Venezia (C++)
namespace Venezia
class Utils
template<typename T>
static T* SelectionSort(T arr[], int size)
for (int i = 0; i < size - 1; i++)
SELECT mov_title, mov_year FROM movie WHERE mov_year BETWEEN 1999 and 2000
GROUP BY mov_year;
UPDATE movie SET mov_title="The American Beauty" WHERE mov_title="American Beauty";
DELETE FROM movie WHERE mov_year="1999";
View (Python) def LowestRootPwr()
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:
View (C++) Airline Seat Reservation System
#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',
View (C++) Duelist Simulator
#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.
View (C++) Namespace VenzMisc
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;
View (C#) FogFXManager.cs
using UnityEngine;
public class FogFXManager : MonoBehaviour
#region Const Member Variables
const int NUM_FOG_SYSTEMS = 4;
#region Public Member Variables
public ParticleSystem widePrefab;
View (C#) ShieldPowerUp.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShieldPowerUp : MonoBehaviour {
#region Member Variables
public static ShieldPowerUp instance;
View (C++) Parsing Ints
#include <sstream>
#include <vector>
#include <iostream>
using namespace std;
vector<int> parseInts(string str) {
istringstream iss(str);
string item;
char delim = ',';
vector<int> ints;