# Archive for November, 2011

## Problem solving in math class

Posted by Ed on November 27, 2011

Dan Meyer, a highschool teacher, gave a very interesting TED talk about problem solving in math class. He shows that current text books don’t teach problem solving at all but instead focus on plugging values into formulas.

Dan also suggests how to make the class much more interesting by incorporating real-life examples.

Dan Meyer also has a blog.

## Basic Algorithm 4b: Length of an integer (part 2)

Posted by Ed on November 23, 2011

Last time we dealt with this problem:

Write a function that takes an integer and returns the length of that integer, i.e. the number of digits.
Example: 2011 has length 4.
Test your function with the following integers:
a) 31415926
b) 1000
c) 5
d) 0

I already posted a solution last time but the following crossed my mind:
We can convert Read the rest of this entry »

## Increment operator: difference between ++i and i++

Posted by Ed on November 22, 2011

The increment operator raises the value of an integer by 1:
Example in C++:

```using namespace std;

int main(){
int i=5;

// increment
cout << "before: i=" << i << endl;
i++;
cout << "after: i=" << i << endl;

return 0;
}
```

The console output is:

```before: i=5
after: i=6
```

The result is the same if we Read the rest of this entry »

Posted in computer science | Tagged: , , , , , , | Leave a Comment »

## Basic Algorithm 4: Length of an Integer

Posted by Ed on November 22, 2011

Last time we talked about cutting a number. Today we have the following problem:

Write a function that takes an integer and returns the length of that integer, i.e. the number of digits.
Example: 2011 has length 4.
Test your function with the following integers:
a) 31415926
b) 1000
c) 5
d) 0
Bonus: Write a non-recursive and a recursive function.

Here is my solution in Read the rest of this entry »

Posted in computer science | Tagged: , , , , | 2 Comments »

## Basic Algorithm 3: cut the number

Posted by Ed on November 12, 2011

Last time we talked about calculating the sum of the integers from 1 to N. Today we deal with the following problem:

Given an integer, e.g. 31415926, produce the following output:
31415926
3141592
314159
31415
3141
314
31
3
So, you have to cut the number from right to left.

a) Write a function with a while loop that produces this output.
b) Write a function without a while loop producing the output (Hint: recursion).
Part b) is a little difficult if you don’t have experience with recursion.

Test your function with the following integers:
31415926, 1000, 5 and 0

Before I post my solution let me Read the rest of this entry »

Posted in computer science | Tagged: , , , , , | 1 Comment »

## Basic algorithm 2: Sum of integers

Posted by Ed on November 11, 2011

Last time we talked about finding the greatest integer in an array. Today we deal with the following problem:

Find the sum of the integers from 1 to 100 using:
a) a for loop
b) a while loop
c) the Gauss formula
d) without using “for” and “while” (Hint: recursive function)

Here is my solution Read the rest of this entry »

Posted in computer science | Tagged: , , | 1 Comment »

## Gamers help solving biochemistry problem

Posted by Ed on November 9, 2011

In biochemistry one wants to determine the structure of a protein which proves to be difficult. A new approach is the game foldit. You are given a protein with the goal of finding the structure with the lowest possible energy configuration. There is a score loaderboard that motivates players.

Here is a nice video of what has been achieved lately: msnbc report
A good article on foldit can be found on wired.com

And here’s a video of someone actually playing the game:

## Basic algorithm 1: Finding the minimum

Posted by Ed on November 8, 2011

I will write about a couple of basic algorithms that are handy for programming puzzles. Today we start with the following problem:

Given an array with integers, how do you determine the smallest number in the array?

Here is my solution in C++: Read the rest of this entry »

Posted in computer science | Tagged: , , , , | 1 Comment »