- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Of course, the answer is:
i++++++++++++++++++++++;
[:P]
Admin
i+++++++++++;
Admin
Although, I should have used prefix notation...
Admin
duh ... all you need is a recursive function, XML, and javascript and you are off and running !
Admin
ROFL
Admin
More readable:
for (int j = 0; j < 11; j++)
i++;
Admin
WTF, of course you've got to use a loop, yes? And, I'd do it in Java
int j=0;
for (int i=0; i<11; i++)
{
j++;
}
or better yet
int j=0;
for (int i=0; i<11; i=i+1)
{
j = j +1;
}
but personally, I'd use
int j;
.
.
.
j +=11;
but what do I know, I just been doing this stuff since Moses. - Mac
Admin
Ha, ha! That's not more readable at all. Somehow my post got garbbled.
Admin
I know. You need to put it in a while loop!
while (i < (i+11))
{
i++;
}
Admin
How about assembly, it workes better than javascript! Something to the effect of this, it has been awhile!
pusha
mov ax, i
mov bx, Bh
add ax, bx
mov i, ax
popa
Admin
You guys call yourselves programmers? The way to do this is
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
<FONT color=#000080>++i;</FONT>
Admin
i beg to differ you should just overload the ++ operator
public static Complex operator ++(Complex c1)
{
return new Complex(c1 += 11);
}
Admin
How can you read that?!?! It has to be all on one LINE!!!
++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;++i;
Admin
for (; i < 11 ; ++i );
Admin
I can just see it now!
int toAdd = 5;
for(int i = 1; i<=11; i++)
toAdd++;
Console.WriteLine(toAdd);
LMFAO! That was hilarious!
Admin
why not mix it up a little
++i;i++;++i;i++;++i;i++;++i;i++;++i;i++;++i;
Admin
c'mon...use OO, it's simpler:
private void button1_Click(object sender, System.EventArgs e)
{
Incrementer i = new Incrementer(0);
i.OnTooFar += new Incrementer.TooFarHandler(number_OnTooFar);
i = IncrementBy11(i);
MessageBox.Show(i.Value.ToString());
}
private bool _isTooFar = false;
public Incrementer IncrementBy11(Incrementer number)
{
while(!_isTooFar)
{
number.Value++;
}
return number;
}
public class Incrementer
{
private int _value;
public Incrementer(int value)
{
_value = value;
}
public int Value
{
get {return _value;}
set
{
_value = value;
OnTooFar(new TooFarArgs(_value));
}
}
public event TooFarHandler OnTooFar;
public delegate void TooFarHandler(TooFarArgs args);
public class TooFarArgs
{
public int HowMuch = 0;
public TooFarArgs(int howMuch)
{
HowMuch = howMuch;
}
}
}
private void number_OnTooFar(FP.Member.TestApp.SqlBuilder.Incrementer.TooFarArgs args)
{
_isTooFar = args.HowMuch > 10;
}
Admin
<FONT face=Arial size=2>For such exotic applications of the increment operator you will actually have to do it a little something like this:</FONT>
<FONT face="Courier New" size=2>using System;</FONT>
<FONT face="Courier New" size=2>namespace W.T.F
{
class ThisIsHowToDoIt
{
static void Main()
{
MyInt x = 31;
x++;
Console.WriteLine(" x = {0}", x);
}
}
class MyInt
{
private int _value;
private MyInt(int value)
{
this._value = value;
}
public static implicit operator int(MyInt a)
{
return a._value;
}
public static implicit operator MyInt(int a)
{
return new MyInt(a);
}
public static MyInt operator++(MyInt a)
{
return a += 11;
}
}
}</FONT>
<FONT face=Arial size=2>Of course, if Nathan wants to increment by twelve we have to come up with a completely different beast...</FONT>
Admin
Even without the forum software mangling the post this is my favorite.
FYI this is how it really reads:
(reposted from firefox, becuase the forum software is too stupid to strip unnecessary HTML from the post when within a preformatted text block, and too stupid to allow an IE user the pleasure of the HTML button that the firefox version inexplicably has.)
Admin
too funny I like the loop, let the compiler unroll that baby! and self documenting too!
Admin
Um, won't i always be less than i + 11 if you keep incrementing it?
Admin
I'd say you definitely need a function for that, something like
public int incrementBy11(ref int j)
{
for (int i=0; i<11; i++)
{
j++;
}
return j;
}
in turn you simply [;)] use
int k=0;
.
.
incrementBy11(ref k);
nice!
Admin
Everyone's missing the point... this guy doesn't just want any plain old incrementer. He wants one that goes to eleven!
Admin
and that is why I like it [;)]
<font size="1">(steps away and starts grumbling something about forum software, again...)</font>
Admin
while(i++<11) { }
Admin
He's probably looking for
i += 11;
Admin
Oh, you want to do it again? No problem, just add a new event handler:
private void number_OnTooFarAgain(FP.Member.TestApp.SqlBuilder.Incrementer.TooFarArgs args)
{
_isTooFar = args.HowMuch > 21;
}
Admin
You're right! I know how to fix it.
int j = 0;
while (i < (i+11))
{
i++;
j++;
if (j == 11)
{
break;
}
}
Admin
I'll leave it as an exercise to the reader to implement <FONT face="Courier New" size=2>MyInt.ToString()</FONT>... [:$]
Admin
Winner! ROFLMAO
Admin
Aw, now you've gone ahead and ruined the surprise. :)
Admin
Ok, this one truly hurts my eyes above all else, gawd 2 integers to increment one around what is already a worthless loop.....heck why don't we put this in VB.NET, and declare them all as objects too :-p while we have unlimited memory to spare...
Admin
template< class T >
class Adder
{
public:
T Increment( T &nOp, T nSize )
{
if ( nSize == 0 )
return nOp;
if ( nSize > 0 )
return Increment( ++nOp, nSize-1 );
else
return Increment( --nOp, nSize+1 );
}
};
int main(int argc, char* argv[])
{
int n = 0;
Adder< int > *pAdder = new Adder< int >;
pAdder->Increment( n, 11 );
return n;
}
Admin
// increment by eleven
while(i != i + 11) {
i++;
}
Admin
Save trees! Use less space!
while(i++ < i + 11) {}
[6]
Admin
At which point does Natan realise he's asked a stupid question? How can people like this sleep at night calling themselves programmers?
These, and many more question on WWTF news at 9
Admin
Hahahaha ... these are great!!
Admin
I was waiting for someone to make that joke. :)
Admin
I think a case statement will be the most efficient, unfortunately you can only increment positive numbers.
void add11(int* i) {
if (*i > 11) {
int j = *i -11;
add11(&j);
*i = 11 + j;
}
else {
switch (*i) {
case 0: *i = 11;
break;
case 1: *i = 12;
break;
case 2: *i = 13;
break;
case 3: *i = 14;
break;
case 4: *i = 15;
break;
case 5: *i = 16;
break;
case 6: *i = 17;
break;
case 7: *i = 18;
break;
case 8: *i = 19;
break;
case 9: *i = 20;
break;
case 10: *i = 21;
break;
case 11: i = 22;
break;
/ DON'T WANT THIS TO HAPPEN */
default: exit();
}
}
}
Admin
Damn it, I forgot this ain't Slashdot and this board doesn't thread the messages for you, so I didn't quote. Everyone ignore the idiot in the corner...
Admin
Many people here are making the same WTFs! Look at this one closely. i will never be equal to i+11!
Admin
Sorry, forgot to quote the one I was talking about.
Admin
So, is lamecoder the only one here besides me who got the Spinal Tap reference?
Admin
Not necessarily. Eventaully, i will overflow (if I have too much [B] :P) and then it will be significantly more that i+11 - to be exact, if it's a signed 32-bit int, i will be 2147483637 and i+11 will be -2147483638.
Of course, there might be slightly easier, faster and clearer ways of setting i to 2147483637, but that would hardly be in the spirit of this WTF, would it? :-)
Admin
I personally like this one:
i++; ++i; i++; ++i;
i++; ++i; i++; ++i;
i++; --i; i--; i++;
i++; ++i; ++i;
Admin
++++++++++++i++++++++++++++;
Admin
Damn you and your crazy posting interface, that "[B]" was meant to be the glass of beer from the smilies :-/
Admin
Yes! Good spinal Tap reference!
I also love the "incrementor" class library, that will be really handy.
Also, it's pretty funny how a few posts in this thread are people who don't get the joke(s)....
Admin
What amazes me is the number of people here who are posting code that would just set i to 11, rather than to i + 11, or is that just another deliberate wtf?
Admin
OMFG!!! stop it! you're killing me!! hahahahaha!