An Implementation of Dawkin's Weasel
April 09, 2016
On a scale of 0 to 9, with 9 being critically important for your success in the technology industry, and 0 being not important at all, I'd rate Dawkin's Weasel a shaky 2. But, that's not what programming is about, right? We just want to have fun with computers, and what could be more fun than simulating evolution?! Rated in terms of pure endorphen-releasing power, Dawkin's Weasel is a solid 11.
Following with the pattern of these challenges being conceptually simple to grasp, we'll outline how Dawkin's Weasel works in just five steps (edited, originally from Wikipedia):
- Start with a random string of characters (to make it easier, match the length to your target length).
- Make copies of the string (the more the merrier).
- For each character in each of the copies, with a probability of P%, replace (mutate) the character with a new random character.
- Compare each new string with the target string, and give each a fitness score (the number of characters in the string that are correct).
- If any of the new strings has a perfect score, break. Otherwise, take the highest scoring string, and go to step 2.
- INPUT: a string, to be used as the target string
- OUTPUT: the best string from each generation, and the match, once it's found
- OBJECT: have fun with more-or-less pointless computing, and practice creating code from a very brief prompt
- RESTRICTIONS: None! Do it up!
Training in unusual ways will lead to a
more expansive knowledge of any subject.
Welcome to 2Cat Studios' digital library of developer challenges! Here you'll find our ever-expanding arsenal of mental-training-dummies, cerebral-sparring-partners, cognative-combatants, and phrenic-punching-bags. We use these to stay sharp while we're busy working on our other projects, but you're welcome to use them too!
As a matter of fact, if you do decide to delve into our devious arena, and you come out unscathed, send us an email, and we'll add you to our leaderboards (with an * by your name)! Please include a link to your source files so we can testify to your genius, and designate whether you want us to share your work with the world, or keep it hidden in a bushel. Do note that we'll assume any project submitted without a license is open source, and will not, as a policy, promote projects which do not allow for distribution and modification.
Finally, please refrain from contacting us for assistance on these challenges; you're welcome to study the provided source code if you're stuck, but working through your confusion is the best way to build a solid understanding of any a given topic. Finding an error is another story, however, namely, one which does involve you emailing us. If the erroneous project is from a third-party, we'll give them the tip, but either way, you'll have our thanks. That's it for the fine-print, just sign here: ____________________ . Great, now get out there and train!
Table of Contents
Code and Concepts
Programming can easily become an exercise in looking up information on Stack Overflow, and while being resourceful is good, having a more comprehensive and flexible knowledge of your craft will never hurt. The goal of these programming challenges is to build a familiarity between developers and their language by putting the two in less routine situations, in which the best of both will hopefully become beautifully apparent.
An Implementation of Pascal's Triangle
March 05, 2016
Understanding Pascal's Triangle is critical to it's successful implementation in code, thankfully however, the concept is very simple. We'll basically be iterating our way to a maximum number, assigning values to an array as we go. If that doesn't seem hard enough, don't worry: to provide more opportunities for learning something new, and to make this more interesting, our challenge requires that we use exclusively 1D arrays.
Altering the way we think about one-dimensional data structures will allow us to be more efficient programmers, more creative with our variables, and perhaps better philosophers.
- INPUT: an integer to be used as the triangle size
- OUTPUT: a correct, formatted Pascal's Triangle
- OBJECT: work with 1D/flfattened arrays in 2D space, and get used to translating a mathematical concepts into working code.
- RESTRICTIONS: one-dimensional arrays only
- [05/03/16] Michael, Source on GitHub
An Implementation of The Sieve of Eratosthenes
February 25, 2016
Eratosthenes' Sieve is a very manageable way to find prime numbers, and an excellent example of how mathematics and programming can blend together.
The general concept behind the sieve is that if we eliminate all composite numbers, whatever's left must be prime. This simplicity makes the Sieve of Eratosthenes a fantastic place for us to begin our programming challenges, as it lets us focus on translating logic and existing formulas into working code– a very important skill for programmers.
- INPUT: an integer to be used as the maximum number
- OUTPUT: all prime numbers smaller than input
- OBJECT: efficiently calculate prime numbers, and get used to translating a mathematical or pseudocode concepts into working code.
- RESTRICTIONS: none
- [24/02/16] Michael, Source on GitHub
- [25/02/16] *"Adnurshalf", Source Provided by Email
If you see any issues with this page, drop us an email at email@example.com!