Skip to content

Instantly share code, notes, and snippets.

View ultimania92's full-sized avatar

OrphineM ultimania92

  • Nashville, TN
View GitHub Profile
""" Task Description:
Please write a class in the language of your choice that contains the following two public methods:
aboveBelow
accepts two arguments
An unsorted collection of integers (the list)
an integer (the comparison value)
returns a hash/object/map/etc. with the keys "above" and "below" with the corresponding count of integers from the list that are above or below the comparison value
Example usage:
@ultimania92
ultimania92 / range_combos.php
Last active April 27, 2022 17:42
A readable form of a problem presented (given a start and end range as integers, return all numbers that are 'naturally' sorted and have at least one repeating number)
<?php
/*
Some notes;
solution takes 2 integers in a range; returns all numbers that are sorted naturally already (number never 'descends' mid-string);
Took about 35-40 minutes (5-10 on devising a solution, 20-25ish on writing code)
Also there are certainly more loop-based performance optimizations, but PHP is already pretty performant; I like preg_match.
*/
function sortNumberStringChars(string $string, bool $reverse=False): string {
$stringArray = str_split($string);