- 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
A34 frist
Missed
Admin
Anybody else noticed that about halfway, there's a Tx in one cell, and an empty field ",," slightly further down the line?
Admin
TRWTF is the page source. Look at the markup for that grid of T's and x's.
Admin
Tool generated markup. We tried some JavaScript-based solutions, but they don't play nice with many RSS tools, and a lot of our readers use RSS.
Admin
Well, if you don't like a table like that, don't look at the XBM or XPM formats.
Admin
Noticed, think that it could be a hint of a "file-not-foundian logic"...
Admin
{x,x,x,x,x,x,x,x,x,xT,T,T,T,T,T,T,T,T,T,,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…},
Admin
{x,x,x,T,T,T,filenotfound,x,x,T}
Admin
Actually, TRWTF is that we check the page source for Remy's comments.
Admin
Refactored it a bit, given that T and x are boolean constants for true and false:
bool[,] set = { {T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,T,T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,T,!T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,T,T,T,T,T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,T,T,T,T,!T,…}, {!T,!T,!T,!T,T,T,T,T,T,T,T,T,T,T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,T,!T,!T,!T,!T,!T,!T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,!TT,T,T,T,T,T,T,T,T,T,,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,!T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, {!T,T,!T,T,!T,T,!T,T,!T,T,!T,T,!T,T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,!T,…}, … }
Admin
if you squint your eyes it looks like the BOFH with an evil grin oon his face.
Admin
Can't tell if trolling... you write that as if you think someone actually wrote the markup and didn't use a code highlighter script.
Admin
bool[,] set = { {T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,x,…}, {x,x,x,x,x,x,x,x,x,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,T,T,T,x,…}, {x,x,x,x,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,T,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,…}, {x,x,x,x,x,x,x,x,x,x,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,T,T,T,T,FILE_NOT_FOUND,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,T,x,T,x,T,x,T,x,T,x,T,x,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, … }
Fixed.
Admin
Admin
Admin
In the era of IDEs, long code blocks feel unreadable without some highlighting. I admit, this one doesn't really need highlighting, but many of them do.
Admin
True or false? The developer wrote this way so he could hide an obscene diagram in the boolean grid.
Admin
And then he got fired for changing things up, right?
Admin
Why has noone done "FRIST" in x/T pixels yet? Are you all too lazy (like me), or was it deleted already?
Admin
Admin
TRWTF is that the could have used a switch statement.
Admin
I use a userscript. Drag this (in a .js file) into your Chrome extensions page (or install it on your other browser however you do that there).
Note: code is based on a previous comment on TDWTF.
Admin
Not Enterprisey enough?
Admin
Look, if you really understand computers you'd know that deep inside this is all there is. Massive acreage of Trues and Falses. OK maybe this guy represented them funny, with T and x instead of 1 and 0, but those are just symbols, not the actual bits, so it really doesn't matter what symbol you use as long as you are consistent.
If you can't grok a mass of bits you really should be in some other line of work.
Admin
i remember using a similar method of true&false table to encode messages during the war
Admin
Honestly, this may be the better alternative. If the matching of magic numbers is mostly arbitrary, this approach can be more “readable” than a long condition whose meaning is not obvious.
Rule of thumb: if you have to draw the table to derive the boolean equation, you're probably better off just using the table.
Admin
Someone once had the brainwave when implementing the standard library, that a vector of bool should not actually be a vector of bools at all but should be implemented internally as a bitset to save a few bytes.
It breaks all sort of generic C++ code though to do that.
The implementation here to store a static table isn't great but at least they didn't try to use a bitset.
Admin
That looks like it was synthesised from a HDL like Verilog or VHDL. Really shouldnt be in a software application. :)
Admin
bool[,] set = { {T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,x,…}, {x,x,x,x,x,x,x,x,x,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,T,T,T,T,x,…}, {x,x,x,x,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,T,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,…}, {x,x,x,x,x,x,x,x,x,x,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,x,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,x,x,x,x,x,x,x,…}, {x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,…}, {x,T,x,T,x,T,x,T,x,T,x,T,x,T,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,Thats it}, … }
Admin
I ran the array through a parser and it decodes to "Drink more Ovaltine!" He should have stored this array in a database.
Admin
Welcome, Barry, to The Matrix...
Admin
Admin
Admin
All there is? Uh, no. "Deep inside" there are wires, resistors and transistors. All of these things implement logical functions like AND or OR, none of them implement logical values. One could make the tendentious claim that f(x) = true is the same thing as 'true', but you didn't, and it's not. The "trues" and "falses" only exist as potential differences on the wires, capacitance in DRAM cells, or magnetic polarity in storage, that is, they are hardly there at all.
And if you grokked Boolean algebra, you'd realize that any first-order logic function can be expressed as a truth table (which is what the T's and x's are) and which itself is just a simple rendering of a sum of products expression. The submitter probably just reduced that to a straightforward expression using a Karnaugh map, or possibly common sense.
Admin
The code is (theoretically) good in that it works, which is the main goal of any software. But the downfall is that it's not maintainable. It fails the test of documenting itself. If you write code that other people look at, and have no idea what the business rules are behind it, you're probably doing something wrong. And with a huge amount of "magic booleans", this code is definitely a WTF.
Admin
What is game of battleship?
Admin
Admin
Brilliant! He invented binary flags!
Admin
Hey! You sunk my TTTTTTTTT
Admin
Admin
I know for a fact that Coco/R generates exactly such code, down to the name of the variable. If that is the source, I don't see any WTF, it's just some unreadable generated code.
However, if someone actually wrote this by hand, run...
Admin
this->GetCommentText();
Admin
Reminds me of the old game-select matrices in Atari game manuals.
Admin
Howard Wolowitz: C-7 Raj Koothrappali: Miss Howard Wolowitz: How can that be a miss? C-6 was a it. C-8 was a hit. Part of your starship has to be on C-7. Raj Koothrappali: Not if it has a hole in the middle. Howard Wolowitz: What kind of space ship has a hole in the middle? Raj Koothrappali: A... Romulan battle bagel?
Admin
Yeah, the kind of thing that was really useful when we had teeny-tiny amounts of RAM, and probably useful in the early 8-bit PC days, depending on hardware, but very much less useful now.
Memory is cheap, so it matters little if a Boolean is a bit, a byte, or a full 64-bit word and I recall it being (not that I've really thought about it in years) more expensive to do all the bit-twiddling than to read an aligned word.
I really can't figure out a good reason for magic numbers offhand. Maybe if I sat and thought about it for a while I could, but generally reading and setting preferences is a small part of your computational time, and file size isn't really a concern, we've moved to XML for so much and it's very wordy.
Security doesn't make any sense either.
Admin
Actually, scratch that. It doesn't make sense regardless. With more then four billion bytes of memory in most computers, we can afford to waste some just so the code we make is maintainable* (For both ourselves and others).
If you want to code with bits, do something in assembly or machine code.
Admin
(a little difficult to discern, alas, but...anyone willing to care?)
Admin
Reading/writing binary file formats or protocols, of course.
And big data. For single Boolean variables, or even small and medium-sizes arrays, storing them in bytes or words makes things easier and often faster. But for large arrays (containing significant numbers of Booleans) compact storage can still matter. It's not only main memory size, there's also cache misses, storage capacity, network speed etc. So, depending on your needs, you may have barriers at various orders of magnitude with direct influence on speed, cost or even feasibility.
For such cases, the infamous vector<bool> may actually be useful, but since they're rare, it should have been a separate type rather than a specialization of a common template, indeed.
Admin
He should have represented his table with 1's, and 0's, with scattered l's and O's for fun.
Throw in a little mean-state logic, and we move up to nightmare**2. For example for evaluating each character we might use this:
Admin
You can manage faux poor English for a post, but in the age of Google claiming ignorance of something that can be discovered in a simple search, such as http://en.wikipedia.org/wiki/Battleships_(game), just proves it's an act.