Project Euler – Java

In an attempt to keep my brain from rusting I decided to try and work through all the Project Euler problems. So far I have solved 72. Still have a lot to go, and I’m sure they will get much harder soon.

My current score :)


All problems can be found on my Github Page Here

For a full list of all the problems I’ve solved, solutions, and times visit my dedicated page: http://ken-soft.com/project-euler/

looks something like this:

Answer Time @Source
#1 233168 0.002ms Link
#2 4613732 0.002ms Link
#3 6857 0.002ms Link
#4 906609 0.033ms Link
#5 232792560 0.65ms Link
#6 25164150 0.0ms Link
#7 104743 0.027ms Link
#8 40824 0.001ms Link
#9 31875000 0.893ms Link
#10 142913828922 1.313ms Link

Please do not just copy/paste my answers as that would defeat the purpose of Project Euler, but instead try to solve them on your own first :)

Legend of Zelda – Java Game Engine

Zelda Game written in Java – Still a new project so it’s definitely a work in progress.
This is essentially my pet project to force me to finish my Java 2D Gaming Engine :)
You can follow the project’s status on GitHub: https://github.com/kennycason/legendofzelda

PHP – Currency Conversion

I can’t remember when I wrote this but I found this little snippet in my library and didn’t want it to go to waste.

It’s very simple and just uses Yahoo! Finance to get the quote. To use the Class simply use the below code:

1
2
  $currency = new Currency();
  print_r($currency->convert('USD', 'JPY', 100));

It should then echo out something like:

1
Array ( [currency] => USDJPY [rate] => 85.995 [date] => 12/28/2012 [time] => 5:55pm [value] => 85.995 )

I.e. 100 USD is now worth $85.995 in Japan, this is called 円高(endaka) in Japanese :)

Currency.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
 
class Currency {
 
    public function __construct() {
 
    }
 
    public function convert($from='USD', $to='GBP', $amount=null) {
 
        $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=' . $from . $to . '=X';
        $handle = @fopen($url, 'r');
        if ($handle) {
            $result = fgets($handle, 4096);
            fclose($handle);
        }
        $result = preg_replace('/"/', '', $result);
        $array = explode(',', $result);
 
        $ret = array('currency' => substr($array[0], 0, strlen($array[0]) - 2),
                    'rate' => $array[1],
                    'date' => $array[2],
                    'time' => $array[3]);
        if($amount != null) {
            $ret['value'] = $amount * ($array[1] / 100.0);
        }
        return $ret;
    }
 
}
 
//  $currency = new Currency();
//  print_r($currency->convert('USD', 'JPY', 100));
 
 
?>
Powered by WordPress | Designed by: WordPress Themes | Thanks to best wordpress themes, Find WordPress Themes and Themes Directory