Giter Club home page Giter Club logo

a-sexual-genetic-algorithm's Introduction

a-sexual-genetic-algorithm

a-sexual genetic algorithm for solving an Alex Bellos math puzzle

A real mutant of a genetic algorithm in #p5js that solves a math puzzle, much more easily solved in #python. Alex Bellos published two math puzzles on Monday April 20, in honor of John Horton Conway, the legendary British mathematician, who died earlier this month. One of them was: The Ten Divisibilities

I have a ten digit number, abcdefghij. Each of the digits is different, and

a is divisible by 1

ab is divisible by 2

abc is divisible by 3

abcd is divisible by 4

abcde is divisible by 5

abcdef is divisible by 6

abcdefg is divisible by 7

abcdefgh is divisible by 8

abcdefghi is divisible by 9

abcdefghij is divisible by 10

What’s my number?

I could not solve it with paper and pen. But used #python itertools to permutate around 3.9 million numbers and use list comprehension to keep making the list smaller until The unique number is found.

However this seemed too easy to me. So I tried a genetic algorithm.

My genetic algorithm has numimal (number+animal) class that keeps track of its DNA, a string of 10 digits and, a fitness score starting at zero.

I create an initial population with 1000 numimals.

the ones that pass the fitness test (being divisible evenly as the rules state) survive the others die.

The ones that survive go through a sort of a-sexual reproduction where they produce an identical copy and a slightly mutated copy (two numbers have swapped places); The populations rise and fall and it gets an answer messy as it is.

a-sexual genetic algorithm

a-sexual-genetic-algorithm's People

Contributors

greggelong avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.