This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//send to Alchemy | |
//send to Google Custom Search API | |
function | |
$.ajax({ | |
//API key and search engine id are embedded in url | |
//Process returns URL of first image result equal to face | |
url: "https://www.googleapis.com/customsearch/v1?key=AIzaSyBh1mbRlS0Mutavt8PuoIytqpn0Bsn_JIM&cx=013039004155227536814:lobto-0zlua&", | |
data: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void draw(int indentation) { //while | |
boolean shrinks = (topWidth > bottomWidth); | |
if(shrinks){ | |
for (int lineWidth = topWidth; lineWidth >= bottomWidth; lineWidth-= 2) { | |
int backgroundCharacterCount = (width - lineWidth)/2; | |
printLine(lineWidth, backgroundCharacterCount); | |
} | |
} else { | |
for (int lineWidth = topWidth; lineWidth <= bottomWidth; lineWidth+= 2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_avg(die_type, dice_count = 1) | |
rolls = 1_000_000 | |
avg = (1..rolls).inject(0.0) do |acc, _n| | |
dice_count.times do | |
roll = rand(die_type) | |
acc += ( (roll < 3) ? rand(die_type) : roll ) | |
end | |
acc | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pinput = <<-PUZ | |
# your input goes here | |
PUZ | |
sub = Submarine.new(pinput.split("\n")) | |
sub.go_brr | |
sub.where | |
class Submarine | |
attr_reader :aim, :horizontal_pos, :vertical_pos, :movements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_input = %w[00100 11110 10110 10111 10101 01111 00111 11100 10000 11001 00010 01010] | |
# puzzle_input <<-BIN | |
# # your puzzle input pasted here | |
# BIN | |
def most_common(list) | |
count = list.tally | |
if count.values.uniq.size == 1 # equal number of 1s and 0s | |
'1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# day 6 | |
test_input = [3, 4, 3, 1, 2] | |
input = test_input # set puzzle input here | |
@lantern_fish = Hash.new(0) | |
0.upto(input.max) do |counts| | |
@lantern_fish[counts] = input.count(counts) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"restaurants": [ | |
{ | |
"name": "Poppo's Cafe", | |
"menus": [ | |
{ | |
"name": "lunch", | |
"menu_items": [ | |
{ | |
"name": "Burger", |