Giter Club home page Giter Club logo

project-euler's Introduction

project-euler

a place to hold some code inspired by projecteuler.net

code in python to solve the problems

code in p5js to visualize it in a more creative way.


Problem 1:

euler1.png

see it live here

Some fun with projecteuler.net. The site gives you “a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve.” I solved problem one in #python3 and entered the result, which is a 6 digit number, which I am not showing because they request that you don’t share. But in addition to just a text based solution I have also visualized problem 1 using #p5js. The problem: Find the sum of all the multiples of 3 or 5 below 1000. Here multiples of 3 are red, multiples of 5 are blue, multiples of both are purple, and white are not multiples. All this plotted on a grid that varies in size from 30 to 45. I didn’t visualize the sum. I think it makes a nice pattern.


Problem 9

euler9.png

see it animated live here

Another visualization of a projecteuler.net problem. In #p5js This is problem nine. “A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.” The solutions for triples that equal 1000 are the two yellow dots at the bottom right of the first picture. Why are there two solutions when it says there should be one? Well, I have plotted the ‘a’ and ‘b’ as ‘x’ and ‘y’ so my brute force included when the values of ‘a’ and ‘b’ are swapped. I first solved it in python using the Diophantus method which I read about in Ian Stewarts book “Cabinet of Mathematical Curiosities” the p5js version is just brute force with for loops. #creativecoding


Problem 10

Summation of Primes

sumPrimeEu10.png

see it live here


Problem 14

collatzcolor.png

see it live here

collatzbw.png

see it live here

Getting a little philosophical while continuing to solve and then visualize Project Euler problems. This is problem 14, Longest Collatz sequence for a number under 1 million. (Not giving the solution here). I solved it in Frankfurt airport waiting to board the plane to Shanghai where I have started a 14 day quarantine (Oct. 28th 2020), before continuing back to Beijing. I have visualized the problem in #p5js somewhat unoriginally but animated each branch. Some branches are winding this way and that. Others follow well worn paths pulsating with random colors. This reminds me of odd branches that this year took leaving us to live in Serbia for 8 months, and the bureaucratic puzzles we had to solve to get back to China. The visualisation looks a bit natural and yet artificial. This reminds me of the very natural environment I enjoyed in Serbia, which is very different from the manufactured environments of the megacities in China. What's more, there is the impression of order in chaos. The Collatz conjecture states that all numbers will reach 1 if subject to the operations, if even divide by 2, if odd multiply by 3 and add 1. As for me, what keeps the order in my life? There are similar operations of a few good habits, love and study which help my life’s path to converge to something good. #collatz There are some good #numberphile videos on the Collatz conjecture and a coding challenge on #thecodingtrain. I have approached the code a little differently than the coding train video. But the visualisation method is roughly the same.

project-euler's People

Contributors

greggelong avatar

Watchers

James Cloos 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.