for everybody showing up looking for the code segments. my plugin that handles code has been updated and apparently something changed, so for right now code samples are probably all screwed up.
Please be patient I’m working on resolving this.
for everybody showing up looking for the code segments. my plugin that handles code has been updated and apparently something changed, so for right now code samples are probably all screwed up.
Please be patient I’m working on resolving this.
Posted in General | Comments (0)
Acer Timeline AS3810T-6415 13.3 Specifications:
Processor: Intel Core 2 Duo SU9400 (1.4GHz, 800 MHz FSB)
Graphics: Intel GMA 4500MHD (shared system memory)
Display: 13.3inch HD LED LCD
RAM: 4GB ddr3
Hard Drive: 500 GB Toshiba MK5055GSX
Networking: Gigabit Ethernet, blue-tooth, 802.11 a/b/g/draft-n
First of all for all I must say the battery life on this computer is absolutely amazing, even when programming in visual studio or taking notes for class or watching you-tube videos, it definitely lives up to its 8 hour batter claims. I’ve managed to run highly resource intensive programs (brute force project euler solutions) that took around 4 hours to run and kept one of the cores at 100% utilization for the whole duration and after the program finished I still had the battery life to look at the results and verify them and start working on the next challenge.
The 3810t came with Windows Vista Home Premium, and claims a 3.2 in the Windows Experience Index due to the graphics card. Over all it is quit usable, with vista performing as smoothly as one can expect vista to run and only slowing slightly on intensive multitasking.
As for the Linux side of things, there are a few problems with suspend/resume, the Ethernet card, and sound. I tried both jaunty and jaunty with kernel 2.6.30 and both had issues. Powertop claims that the battery will last 7 hours under Linux. Hopefully these will be resolved in the next few days.
There are also several cheaper versions available, but I wouldn’t recommend a single core processor/vista combo.
So if it sounds like something you’d be interested in click here to check out the amazon page.
Posted in General | Comments (0)
Problem #43 says:
The number, 1406357289, is a 0 to 9 pandigital number because
it is made up of each of the digits 0 to 9 in some order, but it also
has a rather interesting sub-string divisibility property.
Let d_(1) be the 1^(st) digit, d_(2) be the 2^(nd) digit, and so on.
In this way, we note the following:
* d_(2)d_(3)d_(4)=406 is divisible by 2
* d_(3)d_(4)d_(5)=063 is divisible by 3
* d_(4)d_(5)d_(6)=635 is divisible by 5
* d_(5)d_(6)d_(7)=357 is divisible by 7
* d_(6)d_(7)d_(8)=572 is divisible by 11
* d_(7)d_(8)d_(9)=728 is divisible by 13
* d_(8)d_(9)d_(10)=289 is divisible by 17
Find the sum of all 0 to 9 pandigital numbers with this property.
This Problem along with problem #41 were done as battery test for my new computer and use a brute force method to solve the problem with little or no optimization. Therefor they take a long time to run. I will probably return at some point and see if i cannot speed things up. Until then Solution in C#/mono.
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace ProjectEuler
{
class Program
{
static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
sw.Start();
long Answer = 0;
long Stepper = 1000000000;
long Max = 9999999999;
while (Stepper <= Max)
{
if (CheckNum(Stepper))
{
Answer += Stepper;
}
if (Stepper % 5000000 == 0)
{
Console.WriteLine(Stepper.ToString() +
" :: " + (((float)Stepper / (float)Max) * (float)100).ToString());
}
Stepper++;
}
Console.WriteLine(Answer);
sw.Stop();
Console.WriteLine(sw.Elapsed);
Console.ReadLine();
}
static bool CheckNum(long num)
{
if (num.ToString().Length != 10)
{
return false;
}
if (IsPandigital(num) != 1)
{
return false;
}
string Num = num.ToString();
int d1 = int.Parse(Num[0].ToString());
int d2 = int.Parse(Num[1].ToString());
int d3 = int.Parse(Num[2].ToString());
int d4 = int.Parse(Num[3].ToString());
int d5 = int.Parse(Num[4].ToString());
int d6 = int.Parse(Num[5].ToString());
int d7 = int.Parse(Num[6].ToString());
int d8 = int.Parse(Num[7].ToString());
int d9 = int.Parse(Num[8].ToString());
int d10 = int.Parse(Num[9].ToString());
if (((d2 * 100) + (d3 * 10) + d4) % 2 != 0)
{
return false;
}
if (((d3 * 100) + (d4 * 10) + d5) % 3 != 0)
{
return false;
}
if (((d4 * 100) + (d5 * 10) + d6) % 5 != 0)
{
return false;
}
if (((d5 * 100) + (d6 * 10) + d7) % 7 != 0)
{
return false;
}
if (((d6 * 100) + (d7 * 10) + d8) % 11 != 0)
{
return false;
}
if (((d7 * 100) + (d8 * 10) + d9) % 13 != 0)
{
return false;
}
if (((d8 * 100) + (d9 * 10) + d10) % 17 != 0)
{
return false;
}
return true;
}
static long IsPandigital(long i)
{
char[] I = i.ToString().ToCharArray();
long[] counters = new long[9] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
foreach (char c in I)
{
switch (c)
{
case '1':
counters[0] += 1;
break;
case '2':
counters[1] += 1;
break;
case '3':
counters[2] += 1;
break;
case '4':
counters[3] += 1;
break;
case '5':
counters[4] += 1;
break;
case '6':
counters[5] += 1;
break;
case '7':
counters[6] += 1;
break;
case '8':
counters[7] += 1;
break;
case '9':
counters[8] += 1;
break;
}
}
foreach (long Check in counters)
{
if (Check > 1)
return -1;
if (Check == 0)
return 0;
}
return 1;
}
}
}
Posted in General | Comments (0)
Alrighty people. I know that I haven’t updated in a few days. I’ve been busy with school (getting ready for finals) and playing with new python tech’s (python storm for example). So yeah the sites probably not going to be updated all that frequently for a while.
On the other hand, I have several projects in the works (including several project euler solutions). So once things lighten up I’ll probably have a lot of stuff to post.
So in short, I’m not dead, neither is the site, etc, etc.
Next time I post I’ll have something more interesting to say.
Posted in General | Comments (0)
It was pointed out to me that my previous Radix sort on my site would lose items from its list to sort so I’m posting it here with that bug fixed and with a huge improvement in performance (2x the performance when sorting 1 million 1-3 digit numbers)
So here it is in C#/Mono.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace RadixSort
{
class Program
{
static void Main(string[] args)
{
System.Random rand = new Random(System.DateTime.Now.Millisecond);
int items = 1000000; //Convert.ToInt32(args[0]);
Queue Items = new Queue();
int c = 0;
while (c <= items)
{
Items.Enqueue(rand.Next(0, 999));
c++;
}
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
Items = RadixSort(Items, 3);
sw.Stop();
Console.WriteLine("Sorted in :: " + sw.Elapsed.ToString());
Console.ReadLine();
}
static Queue RadixSort(Queue Items, int Digits)
{
int Digit = Digits - 1;
while (Digit >= 0)
{
Queue Zero = new Queue();
Queue One = new Queue();
Queue Two = new Queue();
Queue Three = new Queue();
Queue Four = new Queue();
Queue Five = new Queue();
Queue Six = new Queue();
Queue Seven = new Queue();
Queue Eight = new Queue();
Queue Nine = new Queue();
int UpperLimit = Items.Count;
int counter = 1;
while (counter <= UpperLimit)
{
int i = Convert.ToInt32(Items.Dequeue());
counter++;
switch (i.ToString().PadLeft(Digits, '0')[Digit])
{
case '0':
Zero.Enqueue(i);
continue;
case '1':
One.Enqueue(i);
continue;
case '2':
Two.Enqueue(i);
continue;
case '3':
Three.Enqueue(i);
continue;
case '4':
Four.Enqueue(i);
continue;
case '5':
Five.Enqueue(i);
continue;
case '6':
Six.Enqueue(i);
continue;
case '7':
Seven.Enqueue(i);
continue;
case '8':
Eight.Enqueue(i);
continue;
case '9':
Nine.Enqueue(i);
continue;
}
}
Items = new Queue();
foreach (int i in Zero)
{
Items.Enqueue(i);
}
foreach (int i in One)
{
Items.Enqueue(i);
}
foreach (int i in Two)
{
Items.Enqueue(i);
}
foreach (int i in Three)
{
Items.Enqueue(i);
}
foreach (int i in Four)
{
Items.Enqueue(i);
}
foreach (int i in Five)
{
Items.Enqueue(i);
}
foreach (int i in Six)
{
Items.Enqueue(i);
}
foreach (int i in Seven)
{
Items.Enqueue(i);
}
foreach (int i in Eight)
{
Items.Enqueue(i);
}
foreach (int i in Nine)
{
Items.Enqueue(i);
}
Digit--;
}
return Items;
}
}
}
I’ll probably keep updating this periodically as new improvements come to me. That and quite a few people seem to find my site looking for a radix sort on google.
Posted in General | Comments (1)