8.26.2011

Arch Linux Installation

After Ubuntu's Unity fiasco, Linux Mint has become my distro of choice. It is everything I remembered about Ubuntu (without Unity and some of the bloat), plus some great new features.

I recently had some issues with the graphics and decided that instead of fixing Mint, I decided to make the best of the situation and start a fresh install of a new distro.

I think I want a distro that gives me more control and really lets me get elbow deep. After researching a little bit I decided on Arch Linux due to its rolling release platform and helpful user base.

I will be following the Arch installation guide found here: https://wiki.archlinux.org/index.php/Beginners%27_Guide

Let's get started!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I downloaded UNetbootin (http://unetbootin.sourceforge.net/) and downloaded and extracted the Arch Linux netinstall image to a flash drive. After backing up my .home folder from my previous Linux Mint install. After a reboot I'm greeted with a simple UnetBootin boot screen and several boot options. I chose Default and Arch Linux was soon loaded and boot to a command prompt.

/arch/setup
to run the installation

I won't go into very much detail on the installation as the Arch Linux install guide is an excellent source of information when installing. It covers just about every option you have.


Preparing the Hard Drives
I gave the following sizes to my partitions:
/boot - 200 mb
swap - 4000 mb
/ - 30000 mb
/home - 42000 (the rest of the hard drive)

I also chose for / and /home to be ext4

Select Packages
I chose the grub bootloaders as that is what I have experience with
For package groups I chose base and base-devel (as I do a lot of programming)
Extra Packages Installed:
links, ncurses, openssh, sudo
The installation will now download and install the selected packages if you have the netinstall version. If you are installing from core you won't have to wait for the packages to download.

Once the download / installation is finished it will update with a couple statistics. Select continue to... continue. If there is a bit of lag after selecting, be patient. I thought it had frozen for a little while but popped up with the menu again after a minute or so.

Configure System
There may be several things in here you wish to configure. I'm only going to set the root password. If you edit any of the other files they will open with your preferred text editor from earlier.

You're so close to being done! Exit out of the installation to find yourself at the command prompt. Type
reboot
to restart your computer.

If it was successful you should find yourself at the Arch Linux boot loader. Select Arch Linux from the menu and enjoy your new system (albeit command line only.)

Thanks, and Happy Coding!

8.03.2011

Programming Practice - Problem 1

I recently found the website Project Euler (pronounced like oiler) and have been slightly addicted to it.

Basically Project Euler is a website filled with fun math problems that you can either solve by coding or through pen and paper. It isn't like other programming practice problem websites that require you to submit code to an online judge using standard input and output. Project Euler is simple: they give you a problem and a text box to put the answer in. Once you figure it out you click submit and check if you found the correct answer.

As a basic example I'm going to walk through the first practice problem.
Problem 1 from PE states:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

My solution used the following java Code.

class p1
{
public static void main(String [] args)
{
int sum=0;
for(int i = 0; i < 1000; i++) { if(i%3 == 0 || i%5 == 0) { sum = sum + i; System.out.println(i); } } System.out.println("\n\nThe total is: " + sum); } }


I solved this problem using the basics of divide and conquer programming. Wikipedia defines this as-
In computer science, divide and conquer (D&C) is an important algorithm design paradigm based on multi-branched recursion. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem.

Basically we split the problem into two "subproblems."
1. Find the sum of numbers below 1000.
2. Determine whether a number is a multiple of 3 or 5

For the first part we simply add for(int i = 0; i< 1000; i++) , which lets us walk through the values of 1:1000. Inside of this for loop we test each integer with if(i%3 == 0 || i%5 == 0) to see if it is a multiple of 3 or 5. If it is, we add our number "i" to our variable keeping track of the sums.

Using this method we get the correct answer of: 233168

That wasn't too difficult, now was it? Give Project Euler a try and happy coding!