Skip to content

Instantly share code, notes, and snippets.

View AsadR's full-sized avatar

Asad Rehman AsadR

  • Seattle, WA
  • 03:39 (UTC -07:00)
View GitHub Profile
# @param {Integer} n
# @return {String[][]}
def solve_n_queens(n)
return [] if n <= 0
result = []
initial_board = Array.new(n) { Array.new(n) { '.' } }
backtrack(n, initial_board, result)
result
end
@AsadR
AsadR / Board.java
Created March 10, 2012 20:15
Dumb Eight Queen Solution in Java
/* Board.java
*
* Part of the Eight Queen puzzle solver by Asad ur Rehman <asad.rehman@gmail.com>
*
*/
public class Board {
private int n;
private byte[][] values;
private int num_queens;
@AsadR
AsadR / eightqueen.c
Created March 10, 2012 20:08
Dumb Eight Queen Solution in C
/*
* 8-Queen problem solution in C
* written by Asad ur Rehman <asad.rehman@gmail.com>
*
* gcc -O3 -fomit-frame-pointer -fstrict-aliasing -momit-leaf-frame-pointer -fno-tree-pre -falign-loops -funroll-loops queen.c -o queen
*
* real 0m0.445s
* user 0m0.279s
* sys 0m0.165s
*
@AsadR
AsadR / eightqueen.py
Created March 10, 2012 20:07
Dumb Eight Queen Solution in Python
#!/usr/bin/env python2.7
# Solving the 8-queen problem.
# Written by Asad ur Rehman <asad.rehman@gmail.com>
#
# Slight optimizations with the help of @jibz and @atharhameed
#
# real 0m23.248s
# user 0m21.840s
# sys 0m0.085s
@AsadR
AsadR / HelloWorldLayer.h
Created August 17, 2011 19:44
Cocos2D bug
//
// HelloWorldLayer.h
// CocosTest
//
// Created by Asad ur Rehman on 8/10/11.
//
// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"
@AsadR
AsadR / SpritePositioning.h
Created July 22, 2011 17:09
Cocos2D helper class to position sprites "by hand"
//
// SpritePositioning.h
//
//
// Created by Asad ur Rehman
//
#import "cocos2d.h"
@interface SpritePositioning : CCSprite <CCTargetedTouchDelegate, NSCoding> {
@AsadR
AsadR / HTML5 Canvas
Created October 23, 2010 23:22
That anonymous function won't get the value of "i". Naughty little bugger.
<canvas id="e" width="800" height="600"></canvas>
<script>
var canvas = document.getElementById("e");
var context = canvas.getContext("2d");
var images = [];
var k = 0;
for( i = 0; i < 10; i++ ) {
var cat = new Image();
cat.src = "closed.png";