Skip to content

Instantly share code, notes, and snippets.

View erintherad's full-sized avatar

Erin Mahoney erintherad

View GitHub Profile
@erintherad
erintherad / turing_machine.js
Last active January 26, 2018 16:36
Advent of code: Day 25 - The Halting Problem
const rules = {
'A': [1, 1, 'B', 0, -1, 'C'],
'B': [1, -1, 'A', 1, 1, 'D'],
'C': [1, 1, 'A', 0, -1, 'E'],
'D': [1, 1, 'A', 0, 1, 'B'],
'E': [1, -1, 'F', 1, -1, 'C'],
'F': [1, 1, 'D', 1, 1, 'A']
}
class TuringMachine {
@erintherad
erintherad / data.js
Created October 5, 2017 16:52
Write some code that will change this data structure
// Given
var endorsements = [
{ skill: 'css', user: 'Bill' },
{ skill: 'javascript', user: 'Chad' },
{ skill: 'javascript', user: 'Bill' },
{ skill: 'css', user: 'Sue' },
{ skill: 'javascript', user: 'Sue' },
{ skill: 'html', user: 'Sue' }
];
@erintherad
erintherad / sumOfEachLine.js
Created September 20, 2017 00:03
A solved answer to a tech screen question
var text = "Today it's 80 degrees.\n\The weather this week was 80, 90, and 100 degrees.\n\It was really hot!\n\ \nTomorrow might be 90 or 91.";
var lineObj = {};
function sumOfEachLine(str) {
var lineArr= str.split('\n');
for(var i = 0; i < lineArr.length; i++) {
lineObj[i] = lineArr[i].replace(/\D/g, ' ').split(' ').filter(Number);
}
function add(a, b) {
@erintherad
erintherad / gist:b6f5d2261cd2b96da0bd2176f00483ec
Created August 24, 2017 20:13 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@erintherad
erintherad / gist:c7987e515cd4f9931e299521f5e5fc60
Created August 19, 2017 17:40 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@erintherad
erintherad / longestStr.js
Created August 18, 2017 13:43
A function that takes in two strings and returns a sorted and longest unique string from the two inputs.
function longest(s1, s2) {
var combined = s1 + s2;
var strArr = combined.split('').sort();
var result = [strArr[0]];
for(var i=1; i< strArr.length; i++) {
if(strArr[i] !== strArr[i-1]) {
result.push(strArr[i]);
}
}
return result.join('');
@erintherad
erintherad / appointmentsConflict.js
Created August 14, 2017 14:42
Create an appointment conflict function
function appointmentsConflict(appt1start, appt1end, appt2start, appt2end) {
var appt1start, appt1end, appt2start, appt2end;
for (var i=0; i < arguments.length; i++) {
parseInt(i);
}
if(appt1start < appt2start && appt1end < appt2start && appt1start < appt2start < appt1end) {
console.log("No conflict");
} else {
console.log("Conflict");
@erintherad
erintherad / whatswrongwiththis.js
Created August 14, 2017 14:41
What is wrong with this function?
let val = 0;
function runCommand(c) {
let words = c.split(' ');
let command = words[0];
let argument = words[words.length-1];
if(command == 'reset') {
val = 0;
} else if (command == "add") {
@erintherad
erintherad / example.js
Created August 9, 2017 23:49
example problem on infinite loading
Infinite Loading
1. Write the necessary logic to fetch posts from an API and append them to an existing DOM element on-scroll.
2. Only append them once the user has scrolled near the bottom of the page.
/**
* API Docs
* ---------
* /posts?page=0 => [
@erintherad
erintherad / Interview Questions
Last active August 7, 2017 18:15
Some typical interview questions using Javascript
// ARRAYS //
// Get average of an array
myArray = [1, 3, 5, 8];
myArray2 = [2, 56, 3, 41, 0, 4, 100, 23];
myArray3 = []
myArray4 = myArray.concat(myArray2)
function getAverage(arr) {
if (!arr.length) {return 0}