Skip to content

Instantly share code, notes, and snippets.

View trueskawka's full-sized avatar

Alicja Laszuk trueskawka

View GitHub Profile

Take-home functional programming interview

This document is licensed CC0.

These are some questions to give a sense of what you know about FP. This is more of a gauge of what you know, it's not necessarily expected that a single person will breeze through all questions. For each question, give your answer if you know it, say how long it took you, and say whether it was 'trivial', 'easy', 'medium', 'hard', or 'I don't know'. Give your answers in Haskell for the questions that involve code.

Please be honest, as the interviewer may do some spot checking with similar questions. It's not going to look good if you report a question as being 'trivial' but a similar question completely stumps you.

Here's a bit more guidance on how to use these labels:

Keybase proof

I hereby claim:

  • I am trueskawka on github.
  • I am trueskawka (https://keybase.io/trueskawka) on keybase.
  • I have a public key whose fingerprint is FB50 AD8C 7DDC 538D E585 4D00 93DB 3D63 245C 9B75

To claim this, I am signing this object:

@trueskawka
trueskawka / decode.cpp
Last active January 30, 2017 14:06
Decoding a message in C++
#include <cstdio>
int decode_number(int number, int mode)
{
char characters[] = { '!', '?', ',', '.', ' ', ';', '"', '\'' };
char letter;
if (mode == 0) {
number %= 27;
letter = 'A' + number - 1;
@trueskawka
trueskawka / checksum.cpp
Created January 27, 2017 18:36
checksum in C++
#include <cstdio>
#include <utility>
int get_sum(int num)
{
num *= 2;
int sum = 0;
// if (num < 10) sum = num; else sum = num % 10 + 1;
defmodule BF do
def new do
%{
tape: %{},
ptr: 0,
output: "",
stack: [],
code: []
}
end
@trueskawka
trueskawka / imvalue.py
Created October 15, 2016 09:46
infinite matrix brain teaser
def summation(n):
return ((n**2 + n)/2) + 1
def imvalue(i, j):
if ((j + i - 1) % 2 == 0):
return summation(j + i - 1) - i
else:
return summation(j + i - 1) - j
#edges that are starts of streams
@trueskawka
trueskawka / mergesort.py
Last active October 10, 2016 04:13
algorithms course - assignment 1
array = open("integerarray.txt")
number_list = array.read()
number_list = number_list.strip()
number_list = [int(i) for i in number_list.split('\n')]
def mergesort(splits, array):
array_length = len(array)
if array_length > 1:
middle = array_length//2
left_side = array[:middle]
@trueskawka
trueskawka / pairs.elm
Last active September 28, 2016 02:40
import Html exposing (text)
import Set
import List
main =
-- text (toString (List.sum (pairs [1, 5, 3, 4, 2] 2)))
text (toString (List.sum (pairs [363374326, 364147530, 61825163, 1073065718, 1281246024,
1399469912, 428047635, 491595254, 879792181, 1069262793]
1)))
n_guesses = 6
guesses = set()
word = "never graduate"
game_over = False
def print_game_state():
global game_over
correct = [c for c in guesses if c in word]
incorrect = [c for c in guesses if c not in word]
#piggy - pig latin
#piggy("This is a string, yeah?")
#"Isthay isay a ingstray, eahyay?"
#separate words
#check if the first letter is capitalized
#regex - find first consonant group - from the start
#if there is one - move it to the back
#add "ay"
#capitalize if it was capitalized