Skip to content

Instantly share code, notes, and snippets.

View arikrak's full-sized avatar

Ariel arikrak

View GitHub Profile
# Flattens an array of arbitrarily nested arrays into a flat array
def flatten(ar)
flat_ar = []
ar.each do |elem|
if elem.class == Array
flat_ar.concat flatten(elem)
else
flat_ar << elem
end
end
@arikrak
arikrak / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
def flatten(array)
return array.flatten
end
This is some **sample text** and code:
System.out.println("hi");
But when I add a div:
<div>first div</div>
**it breaks!***
@arikrak
arikrak / DistanceZ.java
Created November 10, 2013 22:48
An answer to the StackOverflow and Learneroo question: http://www.learneroo.com/courses/29/nodes/221
import java.util.*;
class DistanceZ {
static void minArray(int[][] square){
int w = square.length;
for(int times = 0; times<w; times++){
for(int i =0; i<w;i++){
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
void doStuff(int ar_size, int * ar) {
}
def insertion_sort(l):
m = input()
ar = [int(i) for i in raw_input().strip().split()]
do_stuff(ar)
print " ".join(map(str,ar))
import java.util.*;
class Solution {
static void doStuff(int[] ar){
}
static void printArray(int[] ar) {
# Matthew Jee's (mcjee) solution to the Mancala challenge on the HackerRank Back-to-School Hackathon
def printNextMove(player, player1Mancala, player1Marbles, player2Mancala, player2Marbles)
if player == 1
mymarbles = player1Marbles
opmarbles = player2Marbles
else
mymarbles = player2Marbles
opmarbles = player1Marbles
end
#adr2370's solution to Leibniz Challenge
#https://github.com/adr2370/HackerRankBackToSchool/blob/master/Leibniz.py
#193 characters
T=int(input())
for a in range(T):
n=int(input())
x=0.0
for i in range(n):
if i%2==0:
x+=1.0/(2*i+1)