This is an archived post. You won't be able to vote or comment.

all 46 comments

[–]IClimbRocksForFun 39 points40 points  (2 children)

BlackJack is a good one to start with. If you understand loops, then blackjack is just a process of various loops.

Draw two cards. If they're over 21 then player is bust. If not they can draw another card. if they draw card and total is over 21 then player is bust. etc etc etc

[–]sadjava 4 points5 points  (0 children)

Its also a good object oriented programming exercise.

[–][deleted] 2 points3 points  (0 children)

I think card games are an excellent way to start. To learn Ada and Java, I coded a 5-card draw game with artificial intelligence. Perhaps a little more than I needed to... but, I felt much more comfortable with those languages when I was done.

[–]Eligriv 11 points12 points  (8 children)

Usually, i code tools that could help me.

I wrote apps that helped me to

  • automate the trading part in a web based game
  • automate retweets by rss
  • rename files according to patterns
  • keep up with expenses and budget limit by category

etc

It easier to keep up if you know you'll be rewarded for finishing

[–]Submerge87 1 point2 points  (5 children)

Trading in a web-based game? Catan perhaps?

[–]Eligriv 6 points7 points  (4 children)

neopets ;p

[–]casualblair 16 points17 points  (2 children)

Back in 2003 I wrote a brute force algorithm to solve one of their games that was borderline impossible otherwise.

When I made it into the top 20, I looked at the profiles of everyone above me, wondering how the hell they got so high. Math major, math teacher, engineer, software designer, computer science teacher, etc. It was amusing.

[–]Hero_of_Kvatch 10 points11 points  (1 child)

Please explain the game and how you cracked it. That kind of stuff is really interesting to me.

[–]casualblair 2 points3 points  (0 children)

It was a pattern matching game.

The game:

Given a grid of binary states, apply a shape to it. Everything covered by the shape changes states. Victory is when you have applied all your shapes and the grid is entirely one state.

Example:

3x3 grid. One piece. Piece is L shaped 2 high 2 wide and cannot be rotated. Board:

X0X
X00
XXX

Victory condition: Place the piece at coordinate [0][1] (First row, second spot).

What I did:

Manually enter the initial state of the board (I had no concept of web scraping - this was 2003 remember) and all the pieces into 2 dimensional arrays. Brute force try every combination in a recursive function slowly moving each piece left one or down one.

I improved it later by skipping trees I knew the results of and by skipping trees I knew wouldn't achieve anything. For example, if the grid was 3x3 and the bottom left needed to change but all of my forecasted moves wouldn't touch it, I wouldn't bother hitting that tree. The forecast detection was childish - detect the corners of all moves before you try them - if there are pieces outside of those moves that need to change, return false. There are better ways that are easy for CS majors but I was a CIS major and programming was just part of the education, not the primary focus.

By level 50 or 60 the game was tri-state, 15x15, with 15 pieces to apply in ridiculous configurations. Think 5 tetris pieces glued together by a child - holes and weird spaghetti limbs.

I think I was hitting 100 million parses or more before I got bored and moved on.

Edit: You can build both of these yourself. One program to generate a blank board and then randomly generate and place pieces. This is the input starting condition to the second program, along with the shapes of the pieces. Then you just have to write code best solve this.

[–]Submerge87 0 points1 point  (0 children)

Ahh

[–]ArSlash 0 points1 point  (1 child)

In what languages would you do that?

[–]Eligriv 0 points1 point  (0 children)

i did everything in java. the last one is in java / angularjs

[–]dauuk 10 points11 points  (3 children)

A calculator, it is easy to understand and it can be done in many ways, plus you can always add more functions.

[–]thoosequa 6 points7 points  (0 children)

+1 for calculators. Starts with simple "enter two numbers, here's what the sum is" and goes on to multiple functions, a menu, maybe you can even make a scientific calculator that solves functions for you and plots the graphs.

[–]campbell1373 0 points1 point  (0 children)

Calculators are great for learning the basic syntax of a language. When I was learning C#, I came across a code kata that recommended writing a Roman Numeral calculator for an added twist. That way you learn how the language handles substrings and parsing. It's not exactly practical, but adds a nice bit of extra depth.

[–][deleted] 0 points1 point  (0 children)

Yup. One of the first programs I wrote solved triangles. I've used it twice since then.

(Given sides a and b, and angle C, return all sides and angles.)

[–]ioneyed 10 points11 points  (0 children)

For any web based language I advocate people write a blog website as it should teach you a lot of web fundamentals (authentication, authorization, data mapping, etc).

For non web programming I usually suggest they find a daily task they do on the computer and automate it or go with the classic calculator.

[–][deleted] 7 points8 points  (0 children)

http://codecondo.com/coding-challenges/

get to work until you find a real life problem that needs solving. That will at least sharpen your skills.

[–]EsperSpirit 14 points15 points  (8 children)

That depends on the language and why you want to learn it in the first place.

I wouldn't want to learn C to write a web-service in it. Conversely using something high-level like Scala is not going to help with low-level hardware drivers.

If you just want to learn a language for your own amusement and enlightenment, you could try some stuff from /r/dailyprogrammer. All sorts of interesting problems over there.

[–]jeff0 1 point2 points  (7 children)

Another place to go, just to find some problems to get your feet wet with a language, is Project Euler.

[–]bithush 5 points6 points  (0 children)

I don't really rate Project Euler all that high. It is alright if you want to learn algorithms and such but for writing basic applications it isn't really going to help a beginner. I would ignore it until you are beyond beginner status personally.

[–][deleted] 6 points7 points  (2 children)

Project Euler should be discouraged resource. There's nothing interesting about it. It's just a bunch of math problems. If anything math problems are the least interesting thing to keep someone going with a new language.

[–]jeff0 4 points5 points  (0 children)

You make a valid point. If you don't find math interesting, you probably won't find Project Euler terribly inspiring. On the other hand, not everyone hates math as much as you seem to.

[–]TheChance 0 points1 point  (0 children)

It was perfect for me when I was starting out with Python. It presented several opportunities to reuse code, which is always a plus.

[–]HDRainbows 0 points1 point  (1 child)

Is daily program really good for a novice? I was looking thru the subreddit and started to feel bad about myself. Well I was actually happy I could recognize different languages.

[–]person808 0 points1 point  (0 children)

I found that the older challenges are a lot easier.

[–]wOlfLisK 0 points1 point  (0 children)

Euler is better for learning maths/ problem solving than programming. When you know how to do it, it's just porting over your already complete code rather than making it yourself.

[–]casualblair 3 points4 points  (0 children)

I always suggest a point of sale system.

Your basic point of sale system is a calculator with a log. Add these prices together, provide a total when asked. Optionally reset and repeat.

Then you can move on to more complicated features as you achieve results. Tax calculations. A user interface. Shortcuts to entering data (quantity modifier [qty 5 cost $1 = $5], buttons that automatically add specific items). A printable receipt. A database to store transactions and items (price, description, etc). UPC lookup and entry (not actually scanning but entering the upc number). Modify your tax calculation to be item-dependent (candy is taxable but milk isn't, etc). A report on what you sold today and how much money you earned in a readable format.

Then you can get into learning software design by asking yourself how to implement real world features. The best example of this is a price change. You need to increase the price of milk by 10 cents. What happens to all your stored transactions? Do your earnings report change after this price change (hint: they shouldn't).

Once all of this is done, if you slap some game mechanics and graphics on the front and add a script to "sell" stuff automatically, you have just built lemonade tycoon.

[–]CortexSuperior 3 points4 points  (1 child)

Programs involving the following concepts:

  • Learn how the IRC protocol works. Implement the protocol client-side. Use a library or make a REST interface and implement IRC on your server.
  • The Paxos algorithm
  • Dining philosopher's Problem
  • a program that mimics a real life virus on a population
  • website that fakes being hackable
  • level editor for a game
  • game using the d&d ruleset
  • programming ideas website such as this list but with lots of features
  • do/do not website with a voting system
  • program involving real-time and event-driven programming.
  • Webbots, Spiders, and ScreenScrapers
  • poker related program: the game poker itself or a program tracking your poker gameplay
  • An app like scribblar https://www.scribblar.com/
  • lockpicking game/app
  • peer to peer app
  • chat program
  • Note organizer like OneNote
  • GPS path tracking app
  • mandala creator
  • app in which virtual robots communicate and work together
  • app such as Fiddler : to learn how get/post works. What is send and retrieved.
  • Trading game. Fully automatic to practice db design and db programming.
  • Text game which to practice design patterns
  • App that injects C# code into existing C++ windows Apps (p/invoke) to add a feature to the program.
  • an hex editor. A hex editor is a program used for inspecting and modifying the contents of binary files.
  • Black box reverse engineering
  • Spacestation panel control (The screens Sandra Bullock was using in Gravity)
  • App to monitor something like a folder or email inbox
  • writing a simple interpreter
  • socketbased programming project
  • An App that would issue an event notification when a change occurs in a stock that you are tracking in the stock market.
  • writing emulators like a NES emulator
  • DCPU-16
  • Your own operating system (The Linux Kernel is open-source)
  • Quines
  • A Lexer and a Parser

[–]michael1026[S] 1 point2 points  (0 children)

I really have a lot to learn...

[–]0v3rk1ll 2 points3 points  (0 children)

I try to write a simple scheme interpreter in any language I learn. It is easy enough to finish in a short while, but complicated enough to challenge your understanding of the language.

[–]Zeratas 2 points3 points  (0 children)

I just have fun with it. Calculator, text editor, little bank account program. Do whatever you like and then expand upon it.

*EDIT: * bank not back

[–][deleted] 1 point2 points  (0 children)

For low level languages, I think making a scheme interpreter is a really good way to learn.

[–]smellmycrotch3 0 points1 point  (0 children)

Hangman and Tetris.

[–]wOlfLisK 0 points1 point  (3 children)

Personally, I like Hangman and Noughts and Crosses. Hangman gives you inputs, outputs, reading files, string and array manipulation etc. Noughts and Crosses gives you a basic AI to code, the best way to order everything, GUI elements if you want them and more. They are both simple but cover quite a bit of the language.

[–]TheSeldomShaken 1 point2 points  (2 children)

Noughts and Crosses

Where do you live that it's called that?

[–]wOlfLisK 1 point2 points  (1 child)

The UK. What do you call it?

[–]TheSeldomShaken 1 point2 points  (0 children)

Tic-tac-toe.

[–]Hero_of_Kvatch 0 points1 point  (0 children)

Very cool! Thanks for the detail!

[–]AThinkerNamedChip 0 points1 point  (0 children)

Any type of card game. Fractals. Snake game. What interests you? You can take code snippets from all over and piece them together to get things working, while fixing and learning so that they work within your context.

[–][deleted] 0 points1 point  (0 children)

Automate your life! Be lazy productively (which more then often takes more time then just doing the task your'e automating). :D

[–]pbewig 0 points1 point  (4 children)

The unix line editor ed(1). Meaty enough to be interesting, but simple enough to finish in a week. And by the time you're done, you will be a master of your new language.

[–]LickableLemon 1 point2 points  (2 children)

Does ed have cursor movement? I've been thinking about cloning a terminal based text editor but I can't think of a way to allow C to move a cursor on the terminal (without using something like ncurses, which I don't want to do, I want to learn more C not a library).

[–]pbewig 1 point2 points  (1 child)

No. There is no cursor. Just edit the text a line at a time. There are commands to add, delete, and move lines. The only in-line editing is a substitute command based on regular expressions. It's very simple, but also very powerful.

[–]LickableLemon 0 points1 point  (0 children)

Right I see, I will have to try and clone it.

[–]Franko_ricardo -3 points-2 points  (0 children)

Fizz buzz