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
<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"; |
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
// | |
// SpritePositioning.h | |
// | |
// | |
// Created by Asad ur Rehman | |
// | |
#import "cocos2d.h" | |
@interface SpritePositioning : CCSprite <CCTargetedTouchDelegate, NSCoding> { |
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
// | |
// 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" |
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
#!/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 |
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
/* | |
* 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 | |
* |
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
/* 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; |
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
# @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 |