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 | |
{ | |
public: | |
template<typename T> | |
static T* SelectionSort(T arr[], int size) | |
{ | |
for (int i = 0; i < size - 1; i++) | |
{ |
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; | |
#endregion | |
#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++) Delete Duplicates
//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 |