Skip to content

Instantly share code, notes, and snippets.

@barreyro
barreyro / paintballs.js
Last active November 10, 2017 16:35
Paint balls and 1 dimensional walls
/*
Complete this JS class of a 1 dimensional wall for us to shoot random
paint balls at.
We want to be able to fire paint balls at a given position and ask the wall
if it has been 100% covered by paint.
You cannot change any code already written, you can only add to it. This
includes the constructor parameter, method names and method parameters.
*/
@barreyro
barreyro / findIntersection.js
Last active September 2, 2016 21:31
Algorithm Find Intersection
//Problem:
// -There are X columns
// -There are Y rows
// -People in different areas want to meet in 1 location
// -Input: array of points
// -Find an intersection which minimizes the total walking distance of all people
// -Data structure for output is an array
@barreyro
barreyro / Sudoku Solver
Last active August 29, 2015 14:22
After given a string that represents a sudoku puzzle, this Ruby class will solve the missing pieces. 0's are represented as empty cells. To try other examples, uncomment line 188/189.
class Sudoku
def initialize(board_string)
@board_string = board_string
@board = board_string.split("").map(&:to_i)
@blocks = [ @block_012 = [0, 1, 2], @block_345 = [3, 4, 5], @block_678 = [6, 7, 8] ]
end
# INPUT: index
# OUTPUT: two-coordinate array
def index_to_coord(index)
@barreyro
barreyro / Coin Determiner
Created May 23, 2015 23:25
Have the function CoinDeterminer(num) take the input, which will be an integer ranging from 1 to 250, and return an integer output that will specify the least number of coins, that when added, equal the input integer. Coins are based on a system as follows: there are coins representing the integers 1, 5, 7, 9, and 11. So for example: if num is 1…
def CoinDeterminer(num)
return num if num < 5
count = num / 11
if (num%11).even?
return count + 2
else
return count + 1
end
end
#Bubble Sort
def bubblesort(list)
0.upto(list.size - 2) do |current|
if list[current] > list[current+1]
list[current], list[current+1] = list[current+1], list[current]
end
end
list
end
$(document).ready(function() {
$("body").on("click", "#signup", function(event){
event.preventDefault();
$target = $(event.target);
$.ajax({
type: "GET",
url: "/signup",
}).done(function(response){
$(".container").replaceWith(response);
})