How to disable caps lock in Linux
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"
- My programming projects
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 -
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.
Continue reading ‘Numerical solution of the stationary advection diffusion equation.’
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 of files of format .rar, .r00, .r01 etc and with a .sfv file.
Continue reading ‘Bash script for SFV and uncompressing of .r00 files’
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
def sort(A):
if len(A) <= 1:
return A
small = []
middle = []
big = []
temp = int((A[0][0]+A[len(A)-1][0])/2)
for x in A:
if x[0] < temp:
small.append(x)
elif x[0] == temp:
middle.append(x)
elif x[0] > temp:
big.append(x)
A = sort(small)
A.extend(middle)
A.extend(sort(big))
return A
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.
For example,
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:
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,5,10
15: 1,3,5,15
21: 1,3,7,21
28: 1,2,4,7,14,28
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.
Continue reading ‘To tankser som har brutt sammen, og det eneste som fungerer er kanonene’