So I thought that porting a Game Boy Advance (GBA) console emulator written in JavaScript to Killa would be fun, boy I was wrong... All because I wanted to play with this:
Showing posts with label algorithms. Show all posts
Showing posts with label algorithms. Show all posts
Sunday, November 4, 2012
Thursday, November 1, 2012
Dynamic programming
An n×n grid of squares contains n^2 ants, one ant per square.
All ants decide to move simultaneously to an adjacent square
(usually 4 possibilities, except for ants on the edge of the grid or at the corners).
We define f(n) to be the number of ways this can happen without any ants ending on
the same square and without any two ants crossing the same edge between two squares.
You are given that f(4) = 88. Find f(10).
Labels:
algorithms,
euler,
javascript,
puzzles
Sunday, September 16, 2012
Combinatorial explosion and Project Euler 393
Last week I found a nice video about algorithmic combinatorial explosion. It was very interesting but it's a bit sad to see the big sister throwing away her life in order to teach her little students the perils of trying to compute combinatorial problems that grow very fast. The problem they studied didn't seem to be hard, just enumerate all the ways you can go from one corner to the opposite corner in a rectangular grid without passing the same node twice. Deceptively simple, for a 1x1 grid there are only 2 ways, for a 2x2 grid there are 12 ways:
Labels:
algorithms,
euler,
javascript,
killa,
puzzles
Wednesday, February 9, 2011
Solving the Tic-Tac-Toe game, finally...
The simple game that has been always after me laughing at my programming incompetence.
The very first time I tried to make a program that could play perfectly the game was in the university, after taking my very first course in Programming Languages (I learned Pascal). It was holidays and I was visiting my cousin and got the nice surprise of him getting a personal computer. It was a powerful 286 with a monochrome amber monitor. I couldn't find anything similar but for you to get the idea, games were played like this in those computers:
The very first time I tried to make a program that could play perfectly the game was in the university, after taking my very first course in Programming Languages (I learned Pascal). It was holidays and I was visiting my cousin and got the nice surprise of him getting a personal computer. It was a powerful 286 with a monochrome amber monitor. I couldn't find anything similar but for you to get the idea, games were played like this in those computers:
Labels:
algorithms,
AS3,
games,
minimax
Sunday, August 8, 2010
Solving the Princess in a Box Puzzle
We can solve the puzzle of my last post using a Breadth-first search (BFS) algorithm. The key idea is to realize than the problem is just a Shortest Path problem where the graph, even when it is not completely known at the beginning (because we don't have the graph's adjacency list or adjacency matrix), can be built joining the states the board takes after every movement. The image below can help to understand this. It shows some of the states the board cab take after some movements starting from the beginning.
Labels:
algorithms,
puzzles
Subscribe to:
Posts (Atom)