Skip to content

Instantly share code, notes, and snippets.

@georaldc
georaldc / factory-examples
Last active December 1, 2023 22:40
Factory examples
Factory examples
@georaldc
georaldc / EvaluateReversePolishNotation.php
Last active June 19, 2019 22:19
Random problems and solutions
<?php
function evaluateReversePolishNotation($expressionArray)
{
$operators = [];
$stack = new SplStack();
$answer = null;
foreach ($expressionArray as $v) {
if ($v === '+' || $v === '-' || $v === '*' || $v === '/') {
$operand2 = $stack->pop();
@georaldc
georaldc / Algorithms.php
Last active February 28, 2016 07:49
Some common algorithms
<?php
/**
* Bunch of algorithms including O analysis from the
* Khan Academy course on algorithms.
*
*/
class Algorithms
{