Saturday, October 11, 2014

Project Euler memo: Problem 497

Problem 497: Easy problem. It had been nearly two years for me to solve a unsolved problem. 30 seconds in Python.
---
(update 10/12/2014)
1.5 seconds in Go. Struggled with integer overflow.

Saturday, September 27, 2014

go language

I have been looking for a replacement for the C language. I like its speed but it does not have some important data structures such as list and associative array. I feel C++ and Java are somewhat ugly. I read a little bit of the code of docker by chance, which is written in the go language, then I thought it looks good to learn. 

So I read through "An introduction to Programming in Go", I actually bought the book for Kindle, and I went through from the problem 1 to 7 of Project Euler. This is not the first time for me to use the language, but I think the command was little different when I used it 4 years ago. Did it have "go run" option? Anyway I learned how to create a package today. I put my functions like Gcd and Is_prime in my new package. I needed to struggle with GOPATH value but the package is working now.

Saturday, June 07, 2014

Problem 49

Problem 49: Prime permutations. 0.2 seconds in Python. One liner however one minute in Haskell.

Sunday, June 01, 2014

redoing a problem: 47

Problem 47: Distinct prime factors. Two seconds in Python, which is about the same as the previous code.


Friday, May 02, 2014

redoing problems: 48, 50

Problem 48: Self powers.  One line in both Python and Haskell.

Problem 50: Consecutive prime sum. Two lines in both Python and Haskell. One second and 30 seconds respectively.

Thursday, May 01, 2014

redoing problems: 44, 45, 46

Problem 44: Pentagon numbers. I actually read the forum and learned. 3 seconds in Haskell.

Problem 45: Triangular, pentagonal and hexagonal. 3 minutes in Haskell.

Problem 46: Goldbach"s other conjecture. Less than a second with one line in Haskell.

Sunday, April 27, 2014

redoing a problem: 96

Problem 96: Sudoku. It"s 30 lines in Python. I wrote in Haskell also. It"s 27 lines. The Python code runs in 18 seconds for the 50 problems and the Haskell code runs in 78 seconds.

Sunday, February 23, 2014

redoing a problem: Problem 42

Problem 42:  Coded triangle numbers. Rewrote the original python code and wrote a new Haskell code.

Saturday, January 04, 2014

problem 43

Problem 43: Sub-string divisibility. Six seconds in Haskell.

Wednesday, January 01, 2014

redoing a problem: 41

Problem 41: Pandigital Prime. Brute force with Haskell in half a second. You can skip all permutations other than 4 and 7 digits because all of them can be divisible by 3.