Skip to content

Instantly share code, notes, and snippets.

View Twoody's full-sized avatar

Tanner Lee Woody Twoody

View GitHub Profile
@Twoody
Twoody / countingDuplicates.php
Created September 5, 2019 18:02
Code Wars counting duplicates challenge done in PHP
<?php
function duplicateCount($text) {
$ret = 0;
$a = [];
$t = str_split( strtolower( $text ) );
$l = count($t);
for($i=0; $i<$l; $i++){
$c = $t[$i];
if ( array_key_exists($c, $t) ){
if( $t[$c] === 1 )
@Twoody
Twoody / countTheSmileyFaces.php
Last active September 5, 2019 18:00
Code Wars Count the Smiley Faces Challenge done in PHP
<?php
function count_smileys($arr): int {
$r = 0;
$l = count($arr);
$validEyes = [":", ";"];
$validNoses = ["-", "~"];
$validMouths = [")", "D"];
for($i=0; $i<$l; $i++){
$t = str_split( $arr[$i] );
$onMouth = FALSE;
@Twoody
Twoody / camelCaseMethod.php
Created September 5, 2019 17:56
Code Wars Camel Case Method PHP Problem
<?php
function camel_case(string $s): string {
$items = explode(" ", $s);
$r = "";
for ($i=0; $i<count($items); $i++){
$r .= ucfirst(strtolower($items[$i]));
}//end i-for
return $r;
}
@Twoody
Twoody / BestTravel.php
Last active September 5, 2019 18:27
Code Wars Best Travel Problem with CLI testing
<?php
function getAllCombinations($in, $minLength = 1, $max = 2000) {
$count = count($in);
$members = pow(2, $count);
$ret = array();
for($i=0; $i<$members; $i++){
$b = sprintf("%0".$count."b", $i); //Build out binary representation
$out = [];
for($j=0; $j<$count; $j++){
if($b{$j} === '1'){
@Twoody
Twoody / avl_tree.py
Created October 28, 2018 20:03 — forked from girish3/avl_tree.py
AVL tree implementation in python
#import random, math
outputdebug = False
def debug(msg):
if outputdebug:
print (msg)
class Node():
def __init__(self, key):