Posts

Showing posts from September, 2011

Exploring Common Lisp: Project Euler Number 8 in Common Lisp (Neophyte Version)

There isn't really much I can add about this example. The goal is to find the largest product of any consecutive digits given a 1000 digit number. I implemented the first approach that came to mind; I went with a large loop to iterate through the 1000 digits and then an inner loop to extract that digits we are going to use in our calculation. The key built-in lisp functions are "loop" and "reduce". If you are not used to a lisp programming language, a C version of this solution is provided. ;; ;; euler8.lisp (modify to find the "correct" solution) ;; Find the greatest product of five ;; consecutive digits in the 1000-digit number ;; ;; [1] http://www.unixuser.org/~euske/doc/cl/loop.html ( defparameter *large-num* "73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843" ) ( defun find-great-product () "Use reduce to find the product of a list of 5 digits out of the larger 1

Revisiting Self Replicating Molecules in an Artificial Chemistry Automaton

Image
Introduction   This blog entry describes an artificial chemistry simulation implemented through a cellular automaton. We show that basic rules can be used to produce complex behavior through simulated artificial chemical reactions. The chemical simulation exists on a fixed size two dimensional grid of cells.  Each active cell is represented by an artificial atom element, these atoms may collide with other atoms to produce a chemical reaction.  Strong chemical bonds will form if the chemical reaction is allowed by system.  Clusters of strong bonded atoms form molecule strings.   We show that self replicating molecule string patterns emerge from the artificial simulation.  This analysis is based on Timothy Hutton's artificial chemistry model from Squirm3.  It it is a basic model but a necessary step for analyzing and recreating similar natural systems.  Self-replication and self-organization is fundamental to all biological life.  Engineers use scientific knowledge to solve real-