Thread: Xmas competitions

  1. #1
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656

    Xmas competitions

    It's almost December and it's time for some festive fun.

    Competition 1
    Draw a xmas tree using ASCII art, as demonstrated below.
    The input to the program will be a single command line argument indicating the order
    Eg. xmastree 7

    The judging will be based on the most elegant solution (whatever that means)
    But presentation, comments, layout, etc will score big

    Code:
    Order 0
       /\
    
    Order 1
       /\
      */\*
      /  \
    
    Order 2
       /\
      */\*
      /  \
     */  \*
     /    \
    /      \
    Closing date: Midnight 7/12/2003 (GMT)


    Competition 2
    http://www.night.net/christmas/12-Days.html
    Output the words to the 12 days of christmas
    The program has no command line, nor any input
    Eg. xmassong

    The judging will be based on the best obfuscation of the program.
    The most obscure and convoluted program wins, providing it actually
    produces the required output.
    It you want to centre-align each line, you can if you want, but left-aligned text will also be fine.

    Closing date: Midnight 14/12/2003 (GMT)


    Competition 3
    Santa has a lot of presents to put into his sleigh, and thus he needs
    to optimise how the presents are packed to minimise the wasted space.
    As he is very busy, he doesn't have a lot of time to come up with an answer.

    The following list is a list of dimensions of xmas presents, which must be
    placed into a 1 cubic metre box.
    50 50 50
    50 50 50
    50 50 50
    50 50 50
    The boxes are a list of width, height and depth sizes (in centimetres).
    This example fills the bottom half of the box with the 4 equally sized presents.

    Write a program which fits the presents in the box.

    Since orientation matters inside the box, the results consist of
    - box number
    - bottom-left-back corner (x,y,z)
    - top-right-front corner (x,y,z)

    The program accepts a single command line argument, which is the name
    of the file containing the list of presents (one present per line).
    Eg. xmasbox presentlist.txt

    The calculation function pack_presents() should be clearly identifiable, as I will
    be adding timing code around that function call. You can call it what you
    want, but you need to indicate where I need to add the timing code.
    Something like this is suggested.
    Code:
            /* START TIMER */
            pack_presents();
            /* END TIMER */
    The judging is solely on the time it takes pack_presents() to complete,
    so its generally in your interest to make it stick to the calculations only.
    So make all your input and output separate functions.

    There will be at most 20 presents to be fitted into the box.

    Three separate tests will be performed, which will result in
    - a partially filled box
    - a completely filled box
    - an overfilled box (choose most presents or least wasted space)

    Closing date: Midnight 30/12/2003 (GMT)



    All of these are to be written in ANSI-C or ANSI-C++ only (STL permitted for C++)
    I'll be using gcc/Linux to compile and test code.

    Submission details will follow shortly.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Question on #2. Do you mean to use complicated algorithms or to make the source code complicated to follow (i.o.w: unreadable)?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Do you mean to use complicated algorithms or to make the source code complicated to follow
    It's up to you to decide how best you want to make the code unreadable.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    The second contest ends on my birthday, does that mean my entry automatically wins ?
    Do not make direct eye contact with me.

  5. #5
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    I guess we can only use std c/c++, right?

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > I guess we can only use std c/c++, right?
    That is what it says at the bottom of the post
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Nov 2003
    Posts
    12
    Question for #2, can we output to a text file, seeing as printing all of it to screen would result in about 4/5 of it not being visible?

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > Question for #2, can we output to a text file
    I'll probably do
    xmassong > results
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Registered User glUser3f's Avatar
    Join Date
    Aug 2003
    Posts
    345
    Originally posted by Salem
    > I guess we can only use std c/c++, right?
    That is what it says at the bottom of the post
    hehe, sorry, didn't notice that, guess I was busy thinking how to solve the problems

  10. #10
    Registered User
    Join Date
    Nov 2003
    Posts
    12
    Thanks Salem Saves me a few lines of code. Although ironically I'll be making it horrifically odd and obscure.

  11. #11
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    For #3, Is it safe to assume that

    a. None of the boxes may stick out of the top

    b. None of the boxes have dimensions longer than 100cm

    ?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  12. #12
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Do the trees have to look exactly as show in your post?
    Do not make direct eye contact with me.

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    > a. None of the boxes may stick out of the top
    Correct

    > b. None of the boxes have dimensions longer than 100cm
    Correct

    > Do the trees have to look exactly as show in your post?
    Correct
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Send your submissions to salem - at - cprogramming.com
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Competition 1 question:
    does the amount of sections on the base of the tree equal the order?

    Code:
      /  \
     /    \
    for order 2
    
    and 
       /  \
      /    \
     /      \
    /        \
    for order 4

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Xmas Tree competition results
    By Salem in forum Contests Board
    Replies: 10
    Last Post: 12-30-2003, 05:26 AM
  2. Xmas
    By Stoned_Coder in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 12-25-2002, 04:58 AM
  3. Competitions
    By Shakespeare in forum C++ Programming
    Replies: 2
    Last Post: 03-11-2002, 05:00 AM