Tuesday, December 16, 2014

Project Euler memo: Problem 493

Problem 493: Combination of balls. Very easy but I misunderstood the problem at first. It runs almost immediately in Python.

Project Euler memo: Problem 461

Problem 461: First, I tried to solve this in Golang, and I wrote a terrible algorithm. After I finished it,   I saw the forum,  I tried to do the some thing others did, and I found that Golang consumes a lot of memory for Slice.  I wrote the new one in C++. 10 seconds.

Sunday, December 07, 2014

Project Euler memo: Problem 491

Problem 491: Counting the number of double pan-digital numbers divisible by 11. Easy, but I needed time to debug with a smaller case. Two seconds in Python.

Monday, December 01, 2014

Project Euler memo: Problem 463

Problem 463: An old style problem. Very easy. Less than 0.1 sec in Python.

Monday, November 24, 2014

Project Euler memo: Problem 451

Problem 451: Finding x^2=1 (mod n). I need to have more time to learn from the forum. My code  in Python runs in 50 minutes. Terrible.

(Update 11/30/2014)
With the same approach, in Golang, 14 minutes.

Monday, November 17, 2014

Project Euler memo: Problem 473

Problem 473: Hunting for easy problems. It was easy to program and it runs in one minute and half in Golang. How can you make it faster? I read the forum and felt ashamed. There is much better way.

Monday, November 10, 2014

Project Euler memo: Problem 487

Problem 487: Easy, but it took me one week to finish. 14 seconds in Golang.

Sunday, November 02, 2014

Project Euler memo: Problem 485

Problem 485: First my solution runs in 140 minutes! I learned in the forum how bad I was. Now it takes just 30 seconds. Written in Golang.

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.