User avatar
jackokring
Posts: 818
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Potentially useful things to program

Tue Aug 14, 2012 5:23 am

A an array of number together and find an average
Been done, and not really that useful.

Construct a binary power series evaluation of cosine
(Ref:DCT and Cosine Transform) The cosine power series has important uses. It has more symmetrical properties compared to sine. The power series only has even powers in it. This has the potential to be evaluated using one square, followed by many multiplications of this square. The interesting question is can the sixth power term be eliminated, and the eight term being a square of a square, and the sixteenth, and the 256th term etc, be used to calculate an accurate cosine? This means not using non-squared powers.

Any more interesting software learning projects should be added to this thread.

Cheers Jacko
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Potentially useful things to program

Tue Aug 14, 2012 8:34 am

  • The n-body problem can be simulated relatively well if the sample period is small. Can you dock with the ISS?
  • A roulette game can be easily simulated and then various betting strategies can be tried. (Hint: the house always wins.)
  • Interface an LCD screen, and produce a set of graphics functions to plot lines and circles.
  • Produce composite video on the GPIO port using software. (It should be just possible; you may need a kernel mode driver.)
  • Put a high-power servo and a strain-gauge on the GPIO port and teach the Pi to play yo-yo.

PaulBuxton
Posts: 57
Joined: Tue Jan 10, 2012 11:38 am

Re: Potentially useful things to program

Tue Aug 14, 2012 9:01 am

Some general computer science type algorithms are useful
  • Searching and sorting algorithms.
    Trees and graphs
    Calculate Pi (multiple ways of doing it, perhaps most intuitive/fun way is to plot random points within a square of size NxN and then work out the ratio of points that fall within the circle whose diameter is N, knowing that the area of a circle if Pi*R*R and that R=N/2 you can work out a value for Pi. Try visualising it by drawing the points as they are plotted and seeing how the accuracy of the result improves over time.

    What methods can you find for visualising the things above so that you can see and understand the algorithms?
For talking to hardware
  • Writing / reading GPIO
    Communicate with an external device (e.g. gyroscope) using I2C/SPI
Other things could possibly include

Scrape data from a web page and do something with it. This would involve fetching the data (wget) and then parsing it in some way, and then do something based on that (perhaps light some LED's when someone sends you a tweet!).

User avatar
ripzay
Posts: 28
Joined: Thu Jul 19, 2012 9:32 am

Re: Potentially useful things to program

Tue Aug 14, 2012 9:06 am

Not sure what level of programmer this thread is aimed at but...

To aid youngsters in getting their heads around looping (and when to escape from a loop) in programs there are various algorithms which i learnt when doing pure mathematics back in college which are deffinitely worthy of 'first challenges' (because they can be applied to things that children will understand) and often come up in real-world programming, including:
  • The Chinese Postman Problem
  • The Travelling Salesman Problem - Dijkstra's algorythm / Bellman-Ford algorithm
  • Bubble Sorting
  • Binary Sorting

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: Potentially useful things to program

Wed Aug 15, 2012 5:44 am

Lots of interesting challenges on Project Euler and the Sphere Online Judge (SPOJ).

Code: Select all

while not self.asleep():
    sheep += 1

PaulBuxton
Posts: 57
Joined: Tue Jan 10, 2012 11:38 am

Re: Potentially useful things to program

Wed Aug 15, 2012 2:34 pm

BlackJack wrote:Lots of interesting challenges on Project Euler and the Sphere Online Judge (SPOJ).
Had a quick look at the Project Euler site, looks interesting, although I couldn't tell if they have any way of determining how good your solution is, which would make it more interesting.

For example one of the first problems is to find the largest palindrome of two 3 digit numbers multiplied together. I would expect an initial step to be to produce a brute force search with two nested for loops counting up from 100 to 999 which store the last value to be a palindrome.
Next step I would want to see is someone recognizing that if you start counting from the other end you will probably find the largest palindrome sooner and potentially bail out before calculating every combination.
Then I would want to see if there are other ways of looking at it,
perhaps produce a list of large palindromes first and then look for integer factors.

When we set coding problems in job interviews this is the sort of problem solving behaviour we like to see, we don't expect someone to jump right into the best solution to something, they should be able to look for simple solutions (simple is always something worth trying for anyway), and then if needed look for refinements or sometimes just stepping back and examining the problem in a different way.

User avatar
r4049zt
Posts: 113
Joined: Sat Jul 21, 2012 1:36 pm
Contact: Website

Re: Potentially useful things to program

Sun Aug 19, 2012 7:08 pm

If you are looking into nice coding, "Numerical Recipes in C" is an old classic textbook with example code for the sort of tasks which got mentioned here. How about computing a 256 colour image according to the number of iterations before leaving the boundary radius of 2 around the Mandlebrot set?
The 16 colour version took four hours on a BBC micro, but I expect the Pi will be a bit quicker.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Potentially useful things to program

Sun Aug 19, 2012 9:21 pm

We had a Mandelbrot program that was much faster than that. Maybe we used Pascal, which was compiled, instead of BBC Basic.

Here's an interesting task that is fascinating, challenging, and will blow your mind. It may not be much use, or it may be related to Fast Fourier transforms.

Put a square image on the screen where the size is a power of 2, 1024x1024 for example.

Split it into four almost identical pictures in the four quarters of the screen thus:
-- take each 4x4 square of pixels and put the top left pixel in the top left quarter, the top right pixel in the top right quarter and so on.
There's an algorithm so you don't have to have a separate copy of the image, you can do it using just the pixels on the screen. Or these days you could just throw memory at it.

Then do the same thing again, you now have 16 pictures.

Keep going until each picture is 1 pixel. What happens then is truly astonishing.

User avatar
TideMan
Posts: 274
Joined: Fri Jun 22, 2012 8:08 am
Location: ChCh, NZ

Re: Potentially useful things to program

Mon Aug 20, 2012 4:37 am

Write a program that calculates the times of the phases of the Moon.

The student will need to find the relationships using an ephemeris.
An interesting/challenging part will be programming the transfer from hours or days from a datum (1/1/1900, usually) to dates like 12-Jan-2012.

Part 2 is to calculate the times of lunar perigee and apogee and the distances.

An elegant website that does it using Javascript can be found here:
http://www.fourmilab.ch/earthview/pacalc.html
If you wish in this world to advance, your merits you're bound to enhance.
You must stir it and stump it and blow your own trumpet, or trust me you haven't a chance.
Ruddigore, G&S

Return to “General programming discussion”