Thursday, January 26, 2012

The future of education begins today (UDACITY)

After the success of the "Introduction to Artificial Intelligence" course (www.ai-class.org), Sebastian Thrun and a team of professors, engineers, designers, etc want to turn upside down higher education as we understand it today.

UDACITY is an open online university. Imagine the possibilities of a world with billions of educated humans. How many new ideas that could make our live better get lost because some genious does not have access to education.

Say hello today to the future of education.

Saturday, January 21, 2012

Find all the pairs in an array of integers which sum X (in C)

/*
* main.c
*
* Created on: Jan 21, 2012
* Author: julio
*/
#include

void findPairsAdding(int array[], int size, int sum){

// Assuming the array is sorted
int i = 0, j = size -1;
while(i < j){
if(array[i] + array[j] == sum){
// We have found a pair, now let's take care of duplicates
int k = i, l = j;
// From i to k duplicated values of the lower value
while(k < l && array[k] == array[k +1])
k++;
// from k to l duplicated values of the higher value
while(k < l && array[l] == array[l -1])
l--;
int aux1 = i, aux2 = j;
for(aux1 = i ; aux1 <= k ; aux1++){
for(aux2 = j; aux2>=l; aux2--){
printf("i: %d, j: %d, (%d, %d) = %d\n",aux1,aux2,
array[aux1],array[aux2],sum);
}
}
i = aux1-1;
j = aux2+1;
}
if(array[i] + array[j] > sum)j--;
else i++;
}
}

int main(int argc, char ** argv){
int a[] = {1,2,8,9};
findPairsAdding(a,4,10);
return 0;
}

Sunday, January 15, 2012

Is your machine little or big endian? Find it out!!

Little endian is a multibyte hardware storage scheme where the most significant byte (the one whose bits contribute a bigger amount to the resulting number) is stored in the lower address. For instance, if an integer is represented with 4 bytes, the number 1 will be represented as:

memory address 0 1 2 3
Value 00000000 00000000 00000000 00000001
Big endian stores the most significant byte in the highest address. So, again our integer with decimal value 1 will be stored as the following binary number:

memory address 0 1 2 3
Value 00000001 00000000 00000000 00000000

Do you want to know if your machine stores numbers in Little or Big endian? The following C code will give you the answer:
#include

int isLittleEndian(){
// Create an integer with the least significant byte set to 1
int x = 0x0001;
// Get a pointer to the integer, interpret it as a byte, and see
// what it contains. So we are giving a look to the contents of the
// lowest memory address. If it contain the LSB then it is not
// little endian
if(*(char*)(&x)==1) return 0;
else return 1;
}

int main(){
printf("Is Little Endian: %s",(isLittleEndian())?"True":"False");
return 0;
}

Again, do not forget that endianness is a characteristic of the hardware.

Sunday, January 08, 2012

"Private" corporation's space age

Sending things to the space is an extremely expensive business (around 8000$/Kg), and one of the reasons maybe the fact that economies of scale don't apply. As more and more activity takes place in low Earth orbit, the costs tend to decrease, but the reduction is slow if there is no competition between private corporations.

Next February the 7th an amazing milestone is going to be achieved; the first ever private spaceship is going to be launched to the International Space Station. It is an unmanned vehicle that will bring a few supplies to our fellow humans whose residence lays in the boundaries of our home Earth. The mission and type of vehicle brings to mind the European Space Agency's ETV missions. Once more our American fellows are much more dynamic and innovative (and probably cheaper). The unmanned Dragon capsule has been designed and built by SpaceX, and will be launched by a Falcon 9 booster, also designed and built by SpaceX, from Cape Canaveral space center in Florida.




I truly believe that paving the way for private capital and profit based research and engineering into the space industry will accelerate its development, and that we will see much more activity our there in the near future than we are used to. Now, these things don't come without risks.Thus, if a company is granted permission to mine the moon, control mechanisms have to be put in place, otherwise we as humans will end up destroying yet another celestial object.

Exciting times ahead of us!!!!

Wednesday, January 04, 2012

Perpetual Motion :)