Skip to content

Instantly share code, notes, and snippets.

View JohnathanWeisner's full-sized avatar

Johnathan Weisner JohnathanWeisner

View GitHub Profile
class Sudoku
def initialize board
@board = board
end
def solve!
num_index = @board.index('0')
return true unless num_index
('1'..'9').each do |possibility|
@board[num_index] = possibility
require 'artoo'
connection :arduino, adaptor: :firmata, port: '/dev/cu.usbmodem1421' # linux
device :board, :driver => :device_info
device :serv, :driver => :servo, :pin => 5 # pin must be a PWM pin
work do
puts "Firmware name: #{board.firmware_name}"
puts "Firmata version: #{board.version}"
@JohnathanWeisner
JohnathanWeisner / peter-norvig_11-hardest-puzzles.txt
Last active August 29, 2015 14:04
Simple Sudoku Solver with backtracking
850002400720000009004000000000107002305000900040000000000080070017000000000036040
005300000800000020070010500400005300010070006003200080060500009004000030000009700
120040000005069010009000500000000070700052090030000002090600050400900801003000904
000570030100000020700023400000080004007004000490000605042000300000700900001800000
700152300000000920000300000100004708000000060000000000009000506040907000800006010
100007090030020008009600500005300900010080002600004000300000010040000007007000300
100034080000800500004060021018000000300102006000000810520070900006009000090640002
000920000006803000190070006230040100001000700008030029700080091000507200000064000
060504030100090008000000000900050006040602070700040005000000000400080001050203040
700000400020070080003008079900500300060020090001097006000300900030040060009001035
#left-column {
height: 600px;
width: 48%;
float: left;
margin: 16px 1% 0 2%;
background-color: blue;
}
#center-nav, #right-column {
height: 600px;
require 'snoo'
require 'json'
config = {
export_file_name: 'comments_for_ginger',
subreddit: 'askreddit'
}
class RedditParser
attr_accessor :subreddit
@JohnathanWeisner
JohnathanWeisner / jquery_example.html
Last active August 29, 2015 13:57 — forked from dbc-challenges/jquery_example.html
Intro to jQuery for Phase 0
<!DOCTYPE html>
<html>
<head>
<title>DOM manipulation with jQuery</title>
<!-- Add a link to jQuery CDN here script here -->
<script type="text/javascript" src="jquery_example.js"></script>
</head>
<body>
@JohnathanWeisner
JohnathanWeisner / 0.2.1-boggle_class_from_methods.rb
Created January 29, 2014 00:43 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1boggle class challenge
class BoggleBoard
attr_reader :num_rows, :num_cols
def initialize(board)
@board = board
@num_rows = @board.count
@num_cols = @board[0].count
end
def create_word(*coords)
@JohnathanWeisner
JohnathanWeisner / 0.2.1-boggle_class_from_methods.rb
Created January 29, 2014 00:43 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
#your code here
end
dice_grid = [["b", "r", "a", "e"],
["i", "o", "d", "t"],
["e", "c", "l", "r"],