Small program ideas

M

Mitya Sirenef

Any small program ideas? I would prefer to stick to command line ones. Thanks.

How about these two:

- simulation of a street crossing with green/red lights allowing cars
and pedestrians to pass in one direction then another

- simulation of an elevator in a building: buttons on each floor to
call the elevator, buttons inside to go to a particular floor,
multiple floors can be selected at the same time, creating a queue
of floors to go to.

-m
 
E

eli m

How about these two:



- simulation of a street crossing with green/red lights allowing cars

and pedestrians to pass in one direction then another



- simulation of an elevator in a building: buttons on each floor to

call the elevator, buttons inside to go to a particular floor,

multiple floors can be selected at the same time, creating a queue

of floors to go to.



-m

Could i make these text and not visual? That is what i am trying to do.
 
E

eli m

How about these two:



- simulation of a street crossing with green/red lights allowing cars

and pedestrians to pass in one direction then another



- simulation of an elevator in a building: buttons on each floor to

call the elevator, buttons inside to go to a particular floor,

multiple floors can be selected at the same time, creating a queue

of floors to go to.



-m

Could i make these text and not visual? That is what i am trying to do.
 
M

Mitya Sirenef

Could i make these text and not visual? That is what i am trying to do.


Of course - just think up some textual representation before starting on
the code. -m
 
D

Dave Angel

Thank you guys for the suggestions. Any more?

There are all kinds of things you could do. First, consider something
that might be useful.

1) checksum all the files in a directory tree, using various checksum
algorithms.

2) Convert one kind of file to another.

3) Calculate time between two dates

4) Write some part of a backup system. For example, copy files from a
directory tree into a specified directory, stopping when the size totals
N.N gig, and keeping track of which files have been so processed, so
that after burning that directory to DVD, you can repeat the process.
As a bonus, add a utility & datafile to the top of that directory, so
that the DVD can be self-checking.

Then try something interesting:

1) find the nth prime, for example the 1000th prime

2) Find all perfect numbers under a trillion

3) solve the puzzles on http://projecteuler.net

4) Build a spell checker, using a combination of a standard
dictionary-list and custom entries. Bonus question - Make it smart
enough to only spell-check comments and literal strings, when applied to
files with an extension of .py
 
V

Vytas D.

Hello,

Some more ideas:

1. Implement sin(), cos(), tan() etc. The accuracy could be supplied as a
parameter to the program. The correctness can be checked very easily with
implemented versions.

2. Read a string/file and look for palindromes (the group of words that can
read from both ends: A toyota, Madam in Eden, I'm Adam...)

3. Read a string/file and draw that string on the screen in a whirlpool
way. Counter-clockwise sample of the string: "abigsnake":
sgi
nab
ake

4. Print first n Fibonacci numbers.

5. Calculate Pi value for the specified accuracy. From wiki: "...
irrational number, including ð, can be represented by an infinite series of
nested fractions...". So it won't be very complicated to implement.

6. Implement dos2unix/unix2dos

7. Calculator, that gets a string, put data into a tree and after
calculates the value.

Vytas D.
 
M

Matej Cepl

Thank you guys for the suggestions. Any more?

1) Clone git repository from https://github.com/mcepl/html2text
2) Switch to fix_tests branch
3) Fix all tests running the testsuite with python3.3

You will help a good thing, contribute to the Aaron Swartz memory (yes,
*that* Aaron Swartz is the original author of the module), and learn
about python more than by any silly simple demos (hint: pdb is your
friend).

It is not difficult, just time consuming.

Best,

Matěj
 
E

eli m

There are all kinds of things you could do. First, consider something

that might be useful.



1) checksum all the files in a directory tree, using various checksum

algorithms.



2) Convert one kind of file to another.



3) Calculate time between two dates



4) Write some part of a backup system. For example, copy files from a

directory tree into a specified directory, stopping when the size totals

N.N gig, and keeping track of which files have been so processed, so

that after burning that directory to DVD, you can repeat the process.

As a bonus, add a utility & datafile to the top of that directory, so

that the DVD can be self-checking.



Then try something interesting:



1) find the nth prime, for example the 1000th prime



2) Find all perfect numbers under a trillion



3) solve the puzzles on http://projecteuler.net



4) Build a spell checker, using a combination of a standard

dictionary-list and custom entries. Bonus question - Make it smart

enough to only spell-check comments and literal strings, when applied to

files with an extension of .py

How hard would it be to change one file to another and would it be a small-medium sized program?
 
E

eli m

There are all kinds of things you could do. First, consider something

that might be useful.



1) checksum all the files in a directory tree, using various checksum

algorithms.



2) Convert one kind of file to another.



3) Calculate time between two dates



4) Write some part of a backup system. For example, copy files from a

directory tree into a specified directory, stopping when the size totals

N.N gig, and keeping track of which files have been so processed, so

that after burning that directory to DVD, you can repeat the process.

As a bonus, add a utility & datafile to the top of that directory, so

that the DVD can be self-checking.



Then try something interesting:



1) find the nth prime, for example the 1000th prime



2) Find all perfect numbers under a trillion



3) solve the puzzles on http://projecteuler.net



4) Build a spell checker, using a combination of a standard

dictionary-list and custom entries. Bonus question - Make it smart

enough to only spell-check comments and literal strings, when applied to

files with an extension of .py

How hard would it be to change one file to another and would it be a small-medium sized program?
 
J

Joshua Landau

How hard would it be to change one file to another and would it be a
small-medium sized program?

How do you want to change it? Like rename a file (os.rename)?
 
E

eli m

How hard would it be to change one file to another and would it be a small-medium sized program?


How do you want to change it? Like rename a file (os.rename)?

I want to change the file type.
 
E

eli m

How hard would it be to change one file to another and would it be a small-medium sized program?


How do you want to change it? Like rename a file (os.rename)?

I want to change the file type.
 
D

Dave Angel

How hard would it be to change one file to another and would it be a small-medium sized program?

Depends on the kinds of the two files. To convert an Excel spreadsheet
file to a csv file might be a lot of work, thousands of lines, not to
mention having to dig up the docs. But to convert a DOS text file (with
lines ending cr/lf) into a Unix text file (with lines ending lf) would
be a dozen lines, shrinkable to 3 with lots of experience. (And I'd
probably prefer the dozen line version)

Other conversions might be somewhere in between. You could do data
compression, like bzip, using the modules in the standard library.

Note that utility commands may exist, but it can be instructive to do it
"by hand" anyway, to learn how.

Look at the following libraries, and see how you could write the glue to
make them into useful file conversion utilities. Then test them against
the standard equivalents, to make sure your code really work.
alib, gzip, bz2, zipfile, tarfile, csv, ConfigParser, robotparser, ...
 
C

Chris Angelico

But to convert a DOS text file (with lines ending cr/lf) into a Unix text
file (with lines ending lf) would be a dozen lines, shrinkable to 3 with
lots of experience. (And I'd probably prefer the dozen line version)

Code golf!

open("outfile","wb").write(open("infile","rb").read().replace("\r",""))

No particular reason, and I'd probably prefer a 3-6 line version of
it, but it's fun to do it as one :)

ChrisA
 
P

PMT

Em sábado, 16 de fevereiro de 2013 03h22min41s UTC, eli m escreveu:
Any small program ideas? I would prefer to stick to command line ones. Thanks.

What about this one?

Do you know how to do the elevator simulation?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top