Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

The longest initializer ever!


  • Please log in to reply
4 replies to this topic

#1 Aereshaa

Aereshaa

    CC Devotee

  • Just Joined
  • PipPipPipPipPipPip
  • 638 posts

Posted 18 December 2009 - 01:34 PM

Check out this initializer from my tetris implementation:
typedef struct {struct {int x,y;} block[4];} piece;
piece deck[7]={{{{4,0},{5,0},{6,0},{7,0}}},{{{4,0},{5,0},{6,0},{4,1}}},{{{4,0},{5,0},{6,0},{5,1}}},{{{4,0},{5,0},{6,0},{6,1}}},{{{6,0},{5,0},{5,1},{4,1}}},{{{4,0},{5,0},{5,1},{6,1}}},{{{4,0},{5,0},{5,1},{4,1}}}};
//ILTJSZO
Do you think it could be longer? ;)
  • 0
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#2 frenchy

frenchy

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 19 December 2009 - 02:08 PM

I reckon perhaps, if you expand to 3D tetris.

Enjoy
  • 0

#3 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 22 December 2009 - 04:31 PM

Dude...this is horrendous. At least break it up a bit:
typedef struct {
    struct {
        int x, y;
    } block[4];
} piece;

piece deck[7]={
    {
        {
            {4,0},
            {5,0},
            {6,0},
            {7,0}
        }
    },
    {
        {
            {4,0},
            {5,0},
            {6,0},
            {4,1}
        }
    },
    {
        {
            {4,0},
            {5,0},
            {6,0},
            {5,1}
        }
    },
    {
        {
            {4,0},
            {5,0},
            {6,0},
            {6,1}
        }
    },
    {
        {
            {6,0},
            {5,0},
            {5,1},
            {4,1}
        }
    },
    {
        {
            {4,0},
            {5,0},
            {5,1},
            {6,1}
        }
    },
    {
        {
            {4,0},
            {5,0},
            {5,1},
            {4,1}
        }
    }
};


  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#4 jwxie518

jwxie518

    Speaks fluent binary

  • Senior Member
  • PipPipPipPipPipPip
  • 517 posts

Posted 22 December 2009 - 05:11 PM

While there is no law that forbit you from doing that, your professor / boss will fail you with that code you have in the first place.
What is the very first rule of software engineering?
1. Readability

LOL
  • 0

#5 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 22 December 2009 - 05:16 PM

Virtues of a Programmer:

#1: Laziness :D
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download