February 26, 2008

  •  Attended a "Skills for New Programmers" workshop at uni today. Was surprised at how often programming can be applied in real life events.

    Even a game of Tic-Tac-Toe can be written into a detailed program. Well, obviously, everyone knows how to play this game but when the explanation on how to play it becomes more technical, things get a lot more complicated. For example, this game's program can be written as follows:

    Draw grid 3 x 3
    Symbols X + O are used
    One symbol per space, each player taking a turn
    If 3 identical symbols in a row, wins the game 
       Else
    Continue placing symbol at empty space
    If there are no 3 identical symbols in a row and grid is full,
       Then becomes a draw.

    Yep, this sounds alright but what about this situation:

    An online store decides to give 10% discount on items under $100 and 20% for items above $100. A shipping fee of $6.50 will be charged for items under $100.

    A more numerical problem but nevertheless, easier than many other programming problems. This situated can be programmed this way:

    Read amount, y
    If y<$100, then y - ( y x 0.1) + 6.5
       Else
    y - (y x 0.2)

    It's pretty interesting about how programming can help ease our daily lives. Though, from the looks of it, I realise that there's still a lot I need to learn from where I start off at high school last time. There is indeed no finish line.

     

Recent Posts

Categories