Jump to content

The longest initializer ever!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
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? ;)
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

    Newbie

  • Members
  • Pip
  • 2 posts
I reckon perhaps, if you expand to 3D tetris.

Enjoy

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
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}
        }
    }
};


sudo rm -rf /

#4
jwxie518

jwxie518

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,180 posts
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

#5
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
Virtues of a Programmer:

#1: Laziness :D
sudo rm -rf /