This file contains 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
#redirect all traffic to https over ssl with Sinatra | |
configure :production do | |
# us a simple before filter to redirect all requests in production to https | |
# before do | |
# unless (@env['HTTP_X_FORWARDED_PROTO'] || @env['rack.url_scheme'])=='https' | |
# redirect "https://#{request.env['HTTP_HOST']}#{request.env["REQUEST_PATH"]}" | |
# end | |
# end |
This file contains 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
// Backtracking solution to Knight's Tour problem http://en.wikipedia.org/wiki/Knights_tour | |
#include<stdio.h> | |
#include<string.h> | |
#include<stdlib.h> | |
// Constraint: MAXX should be greater than or equal to MAXY | |
#define MAXX 5 | |
#define MAXY 5 | |
typedef enum {FALSE, TRUE} bool; | |
int n = 0; | |
bool treaded_blocks[MAXX][MAXY]; |
This file contains 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
# LETS GET READY TO RECURSE!!!!!! | |
# | |
# Tower of Hanoi | |
# | |
# You have 4 discs which vary in size from small to large | |
# There are 3 pegs, A, B, C, respectively | |
# | |
# The discs are all currently on peg A, with the largest disc on the bottom, | |
# and the smallest disc on the top. | |
# |
This file contains 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
# A knight’s tour is a sequence of moves of a knight on a chessboard such that | |
# the knight visits every square only once. If the knight ends on a square that | |
# is one knight’s move from the beginning square (so that it could tour the board | |
# again immediately, following the same path), the tour is closed, otherwise it is open. | |
class KnightTour | |
def initialize(n) | |
@n = n | |
@path = 0 | |
@board = Array.new(n) { Array.new(n, 0) } |