Skip to content

Instantly share code, notes, and snippets.

View sicknarlo's full-sized avatar

Nick Sarlo sicknarlo

  • Philadelphia, PA
View GitHub Profile
""" Quicksort implementation """
def quicksort(arr):
""" Quicksort a list
:type arr: list
:param arr: List to sort
:returns: list -- Sorted list
"""

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@sicknarlo
sicknarlo / finddigits
Created December 17, 2014 15:26
[HackerRank] Find Digits
/* You are given an integer N. Find the digits in this number that exactly divide N and display their count.
For N = 24, there are 2 digits - 2 & 4. Both these digits exactly divide 24. So our answer is 2. */
#include<iostream>
#include<string>
using namespace std;
int main(){
@sicknarlo
sicknarlo / utopiantree
Created December 17, 2014 15:27
[HackerRank] Utopian Tree
/* The Utopian tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring,
when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian tree sapling is planted at the onset of the spring. Its height is 1 meter. Can you find the
height of the tree after N growth cycles? */
#include<iostream>
#include<vector>
using namespace std;
@sicknarlo
sicknarlo / altchar
Created December 17, 2014 15:28
[HackerRank] Alternating Characters
/* Shashank likes strings in which consecutive characters are different. For example,
he likes ABABA, while he doesn't like ABAA. Given a string containing characters A and
B only, he wants to change it into a string he likes. To do this, he is allowed to
delete the characters in the string.
Your task is to find the minimum number of required deletions. */
#include<iostream>
#include<string>
@sicknarlo
sicknarlo / sherlock
Created December 17, 2014 15:30
[HackerRank] *INCOMPLETE - TIMEOUT* Sherlock and Squares
/* Watson gives two integers A & B to Sherlock and asks if he can count the number
of square integers between A and B (both inclusive).
A square integer is an integer which is the square of any integer. For example, 1,
4, 9, 16 are some of the square integers as they are squares of 1, 2, 3, 4 respectively.
Input Format
First line contains T, the number of testcases. T test cases follow, each in a newline.
Each testcase contains two space separated integers denoting A and B.
@sicknarlo
sicknarlo / oddnum
Created December 17, 2014 15:42
[CodeEval] Odd Numbers
//Print the odd numbers from 1 to 99.
#include<iostream>
using namespace std;
int main(){
for (int i = 1; i < 100; i++){
@sicknarlo
sicknarlo / sumofint
Created December 17, 2014 15:45
[CodeEval] Sum of Integers From File
//Print out the sum of integers read from a file.
#include<iostream>
using namespace std;
int main(){
int sum = 0, n;
while (cin >> n){
@sicknarlo
sicknarlo / rollercoaster
Created December 17, 2014 19:30
[CodeEval] Roller Coaster
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int isLetter(int sasi);
//Tests to see if the character is a letter
int isUpper(int sasi);
@sicknarlo
sicknarlo / lowercase
Created December 17, 2014 19:32
[CodeEval] Lower Case
//Change all letters to lower case
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
string str;