Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 [2] 3 4 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 90975 times)

Mephansteras

  • Bay Watcher
  • Forger of Civilizations
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #15 on: May 17, 2010, 11:32:22 am »

Haven't done much with AJAX, personally. That might be an interesting project to look into.

Oh, as for a perl resource, this is required: http://www.cpan.org/

cpan is the giant library of perl modules for, well, just about everything. One of the things that keeps perl useful as a language is the giant amount of open source libraries available for it.
Logged
Civilization Forge Mod v2.80: Adding in new races, equipment, animals, plants, metals, etc. Now with Alchemy and Libraries! Variety to spice up DF! (For DF 0.34.10)
Come play Mafia with us!
"Let us maintain our chill composure." - Toady One

alfie275

  • Bay Watcher
    • View Profile
Logged
I do LP of videogames!
See here:
http://www.youtube.com/user/MrAlfie275

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #17 on: May 17, 2010, 12:39:10 pm »

Thanks for the push to better myself!
I've figured out how to do basic text file inputs!

"Party House" now sucks in a text list as possible conversation topics.

EDIT:

Here is the first problem:

I have a char array which is currently holding the values of "1" and "0" which represent "10".

I need that to be an int representing 10.

How do I convert a char to an int.
I don't want the values of the characters, but the value they represent.
So I don't want my int to have a 1 in it or a 0, but a 10.
« Last Edit: May 17, 2010, 01:42:53 pm by Outcast Orange »
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Bricks

  • Bay Watcher
  • Because you never need one brick.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #18 on: May 17, 2010, 02:28:38 pm »

You could loop through the character array backwards and add (the character's integer representation)*10^(the counter on the loop) to a dummy variable, which would eventually be your output.  Without knowing what functions are available in C++, however (I'm guessing that is what you are using), there may be an easier way.  Most languages I have worked with have a string -> integer function.

I might try challenge 1, since it's basically a problem of representing a nonstandard numbering system and making all of the relevant operations work on it - addition, subtraction, and printing for sure.  Multiplication wouldn't be too bad; division would take some serious thought.  I think I understand how to set it up in python, but there are certain challenges and special cases there that I'm not prepared for.  Challenge 3 would be good practice, too, for a general parser.  I once wrote a program for rotating certain functions on my graphing calculator.  It had the exciting property of sometimes working.  The math involved for challenge 3 would be largely trivial when using the quadratic formula, but there are special cases like "3/2*x^2" which would require special parsing and handling to make sure that the fraction is not treated as a float.  I *think* python has a fraction class...
Logged
EMPATHY - being able to feel other peoples' stuff.

Dave Mongoose

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #19 on: May 17, 2010, 03:01:59 pm »

Here is the first problem:

I have a char array which is currently holding the values of "1" and "0" which represent "10".

I need that to be an int representing 10.

How do I convert a char to an int.
I don't want the values of the characters, but the value they represent.
So I don't want my int to have a 1 in it or a 0, but a 10.

This kind of conversion is called 'parsing'. There's a variety of solutions given here:

http://stackoverflow.com/questions/194465/how-to-parse-a-string-to-an-int-in-c

(They're for C++, even though the link says "in-c")
Logged

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #20 on: May 17, 2010, 07:07:02 pm »

Thanks for the help, that page was really useful.

I've got all sorts of text files feeding my project now.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #21 on: May 17, 2010, 09:33:49 pm »

Thanks for the input.  Remember to keep suggesting things, posting solutions on a pastebin or sending them, sharing information and having fun while learning.

I have little time right now but I feel the need to write about a particular subject that many people might not know about and may come quite handy when debugging certain programs (Very useful for challenges with huge tests cases).

EDIT:  Thanks, qwertyuiopas:  "as a clarification, those are commands to your system(windows: command prompt. other OSs: probably terminal)."

To redirect the input means that data can be obtained by a different mean than the standard input, e.g.: A file.  If we assume we have a file called redir.cpp that allows data from the standard input, the following command would execute the program redir and it would obtain de input data from a file named fdata.in

Code: [Select]
redir < fdata.in
Likewise, redirecting the output means you're sending the results to a different mean than the standard output.  e.g.: A file.  Using the same example of redir.cpp, the following order would execute the redir program and write its results in a file named fdata.out

Code: [Select]
redir > fdata.out
You can also do both redirections at the same time:
e.g.:
Code: [Select]
redir < fdata.in > fdata.out
« Last Edit: May 18, 2010, 06:56:44 pm by Alexhans »
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #22 on: May 18, 2010, 06:23:13 am »

You can also redirect the output of one program to be the input of another.
Code: [Select]
program1 | program2
Logged
Eh?
Eh!

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #23 on: May 18, 2010, 01:14:46 pm »

Spoiler (click to show/hide)
Is that third redir the equivalent of the first two combined?
redir<fdata.in returns redir?

You can also redirect the output of one program to be the input of another.
Code: [Select]
program1 | program2
I see.
Is program1 outputting into program2, or vice-versa?
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #24 on: May 18, 2010, 03:10:47 pm »

Here's a site I found useful for splicing code together with other examples when learning the very beginning parts of DirectX 9 programming: http://www.directxtutorial.com/

Most of the stuff that is a bit further on is behind a paywall, but the free stuff can be useful, mostly because the explainations are clear and each page has the full source code from the program at the end. Keep in mind, one does have to beware of a few incompatibilities with other tutorials (namely, using FVFs, something which the book I was using did not). But when combined with lessons from the early chapters of Frank D Luna's book (Introdction to 3D game programming with directx 9.0c, a shader approach) and theForger's win32 tutorials, the code turned out workable at least.

As for me, I plan on getting through the rest of Luna's book before starting on an HSLS (shader language) book, with a bit of learning about learning algorithms on the side.

Also, does anyone know of a way to make a C++ program compile another C++ program w/o user input?
« Last Edit: May 18, 2010, 03:29:16 pm by alway »
Logged

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #25 on: May 18, 2010, 03:40:03 pm »

...
Is that third redir the equivalent of the first two combined?
redir<fdata.in returns redir?

...
I see.
Is program1 outputting into program2, or vice-versa?
Program1 outputting into program2.
The third is the first two combined.

However, as a clarification, those are commands to your system(windows: command prompt. other OSs: probably terminal).

If you use them often, the | one appears frequently as
Code: [Select]
| more
Logged
Eh?
Eh!

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #26 on: May 18, 2010, 06:43:05 pm »

I'd love something on templates some time, never really did get a good grasp on them.  Should go back and read through the learncpp.com article on them some time...

I'll contribute something later, been considering writing something really simple to help with file streams, particularly binary stuff.... 
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #27 on: May 18, 2010, 07:00:38 pm »

Thanks, qwertyuiopas.  I wasn't clear enough.

I edited that.

I'd love something on templates some time, never really did get a good grasp on them.  Should go back and read through the learncpp.com article on them some time...

I'll contribute something later, been considering writing something really simple to help with file streams, particularly binary stuff.... 
The learncpp articles on templates are pretty useful.  I could grab/make some challenges that involve their usage though.  You're welcome to add whatever you think might help.

I've been sick all morning (unlike me) so I'll just go back and rest it out.  See ya.

Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

winner

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #28 on: May 18, 2010, 07:42:48 pm »

I'm going to try exercise one with common lisp because I'm trying to learn it.
Logged
The great game of Warlocks!

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #29 on: May 20, 2010, 03:38:13 am »

hmmm, are there any irc clients that load into a web-broa

...
Is that third redir the equivalent of the first two combined?
redir<fdata.in returns redir?

...
I see.
Is program1 outputting into program2, or vice-versa?
Program1 outputting into program2.
The third is the first two combined.

However, as a clarification, those are commands to your system(windows: command prompt. other OSs: probably terminal).

If you use them often, the | one appears frequently as
Code: [Select]
| more

"However, as a clarification, those are commands to your system(windows: command prompt. other OSs: probably terminal)."
I have been doing C projects on my schools linux server. But it is good to know for certain.
BTW, I hear macs have alternate tools for managing this sort of interaction. Know anything interesting?
Logged
Pages: 1 [2] 3 4 ... 78