A bash script to verify the integrity of files on Linux. Simple file verification (SFV) is file format to store CRC32 checksums. If the checksums is correct, then the script will uncompress the files. The script can be used at files of format .rar, .r00, .r01 etc and with a .sfv file. This is a new version, but here is the old one.
If you have a server with a dynamical ip address. You can use this script to get the ip address to your mail box. Maybe you have to change the smtp-server to your ISP’s smtp-server. Run “sudo crontab -e” and add “00 * * * * ~/scripts/ip” to get an email every hour.
If you want to disable the caps lock. Open the ~/.bashrc file and add:
# Disables the caps lock button xmodmap -e "remove lock = Caps_Lock"
Code::Blocks is a great IDE for C++. Here is a guide to install Code::Blocks in Linux.
Open a Terminal (Applications -> Accessories), and wright:
sudo gedit /etc/apt/sources.list
add these lines to the end of the file:
deb http://lgp203.free.fr/ubuntu/ gutsy universe
deb http://apt.wxwidgets.org/ gutsy-wx main
In the Terminal:
wget -q http://lgp203.free.fr/public.key -O- | sudo apt-key add -
wget -q http://apt.wxwidgets.org/key.asc -O- | sudo apt-key add -
sudo apt-get update
Installing the packages:
sudo apt-get install libcodeblocks0 codeblocks libwxsmithlib0 codeblocks-contrib
You will now receive updates automatically.
You will find Code::Blocks at Applications -> Programming.
Here is my .emacs file. Copy it to ~/ and it will modify your emacs.
The stationary advection diffusion equation solved with the finite difference method.
A bash script to verify the integrity of files on Linux. Simple file verification (SFV) is file format to store CRC32 checksums. If the checksums is correct, then the script will uncompress the files. The script can be used at files of format .rar, .r00, .r01 etc and with a .sfv file.
Steepest Descent Iteration , written in Matlab to solve the Advection-diffusion equation. The matrix A (in A x= b) is a block pentadiagonal matrix.
Successive over-relaxation (SOR), written in Matlab to solve the Advection-diffusion equation. The matrix A (in A x= b) is a block pentadiagonal matrix.
Quick sort in Python
if len(A) <= 1:
small = 
middle = 
big = 
temp = int((A+A[len(A)-1])/2)
for x in A:
if x < temp:
elif x == temp:
elif x > temp:
A = sort(small)
Nim is a two-player game in which players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object. The player who take the last object loses.
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.
44 -> 32 -> 13 -> 10 -> 1 -> 1
85 -> 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89
Therefore any chain that arrives at 1 or 89 will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at 1 or 89.
How many starting numbers below ten million will arrive at 89?
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44
As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.
Starting in the top left corner of a 2*2 grid, there are 6 routes (without backtracking) to the bottom right corner.
How many routes are there through a 20*20 grid?
The following iterative sequence is defined for the set of positive integers:
n ->n/2 (n is even)
n ->3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, …
Let us list the factors of the first seven triangle numbers:
We can see that the 7th triangle number, 28, is the first triangle number to have over five divisors.
Which is the first triangle number to have over five-hundred divisors?
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below one million.
A Pythagorean triplet is a set of three natural numbers, a<b<c, for which,
a² + b² = c²
For example, 3² + 4² = 9 + 16 = 25 = 5².
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10001st prime number?
The sum of the squares of the first ten natural numbers is,
1² + 2² + … + 10² = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + … + 10)² = 55² = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 317584931803?
Each new term in the Fibonacci sequence
is generated by adding the previous two terms.
By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …
Find the sum of all the even-valued
terms in the sequence which do not exceed one million.
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.
Continue reading ‘Project Euler - Problem 001′
Opprinnelig skrevet 03.05.2007:
Ja, da var endelig javaspillet vårt ferdig. Etter mye jobbing er det morsomt å se et resultat i hvert fall jeg er fornøyd med.