Skip to content

Instantly share code, notes, and snippets.

View gameguy43's full-sized avatar
💭
Working on interviewcake.com!

Parker Phinney gameguy43

💭
Working on interviewcake.com!
View GitHub Profile
from collections import Counter
all_possible_results = []
for first_roll_result in range(1, 8):
for second_roll_result in range(1, 8):
for third_roll_result in range(1, 8):
for fourth_roll_result in range(1, 8):
for fifth_roll_result in range(1, 8):
@gameguy43
gameguy43 / a submission
Created September 26, 2016 20:23
translated to c by Maria Maltseva
#include <stdio.h>
#ifndef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
int getminElement(int [], int);
int getmaxElement(int [], int);
int highest_product_of_3(int[], int);
@gameguy43
gameguy43 / gist:c4bb482652d62e31d1bee9d09e331999
Last active October 23, 2016 20:48
code to translation for interview cake code translation job application
Please translate this code.
It's available below in Python, Ruby, Java, and JavaScript.
You can consult whichever version you like.
Then save your answer as a new gist and send me a link.
Thanks!
--Parker
import random
def rand7():
return random.randrange(1,8)
def rand5_mod():
return rand7() % 5 + 1
def rand5_recursive():
roll = rand7()
def binary_search(target, nums):
# see if target appears in nums
# the number /cannot/ be at floor_index or ceiling_index--
# floor and ceiling are "just outside" the range of possibilities
floor_index = -1
ceiling_index = len(nums)
# if there isn't at least 1 index between floor and ceiling,
# we've run out of guesses and the number must not be present
def get_best_profit_brute_force(stock_prices_yesterday):
max_profit = 0
# go through every time
for outer_time in xrange(len(stock_prices_yesterday)):
# for every time, go through every OTHER time
for inner_time in xrange(len(stock_prices_yesterday)):
class WordCloudData:
def __init__(self, input_string):
self.input_string = input_string
self.words_to_counts = {}
self.populate_hash()
def populate_hash(self):
#
current_word = ''
<div code-sample>
. ()
/ \
o o
/\ /\
o o o o
/ \ / \
o o o o
/ \ / \
o o o o
# InterviewCake (Beta Exercise 5)
# Brett Beutell
# June 17, 2014
import sys
# Let top_left be a 2-tuple
# E.g., top_left = (x,y)
# Create a rectangle class containing the top_left x and y coordinates, width, and height
def largest_product_of_3(array_of_ints):
greatest = array_of_ints[0]
smallest = array_of_ints[0]
greatest_product_of_two = array_of_ints[0] * array_of_ints[1]
smallest_product_of_two = array_of_ints[0] * array_of_ints[1]
greatest_product_of_three = array_of_ints[0] * array_of_ints[1] * array_of_ints[2]
for current_int in array_of_ints: