• linepro (unregistered)

    A34 frist

    Missed

  • (cs)

    Anybody else noticed that about halfway, there's a Tx in one cell, and an empty field ",," slightly further down the line?

  • (cs)

    TRWTF is the page source. Look at the markup for that grid of T's and x's.

  • (cs) in reply to mott555

    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.

  • Mike D. (unregistered)

    Well, if you don't like a table like that, don't look at the XBM or XPM formats.

  • lmollea (unregistered) in reply to steenbergh

    Noticed, think that it could be a hint of a "file-not-foundian logic"...

  • wtf? (unregistered)

    {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,…},

  • Trevel (unregistered)

    {x,x,x,T,T,T,filenotfound,x,x,T}

  • Peter (unregistered) in reply to mott555

    Actually, TRWTF is that we check the page source for Remy's comments.

    mott555:
    TRWTF is the page source. Look at the markup for that grid of T's and x's.
  • (cs)

    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,…}, … }

  • Rodnas (unregistered)

    if you squint your eyes it looks like the BOFH with an evil grin oon his face.

  • Röb (unregistered) in reply to mott555

    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.

  • Kryptus (unregistered)

    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.

  • bkDJ (unregistered) in reply to Peter
    Peter:
    Actually, TRWTF is that we check the page source for Remy's comments.
    I read this site on my iPad so I made a shitty JS bookmark let I can run and it shows comments and cornify links. I was surprised that it actually showed an extra (dupe) picture in Friday's Error'd. I can share it so you don't have to hunt through the source, if you want.
  • dpm (unregistered) in reply to Remy Porter
    Remy Porter:
    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.
    So the PRE tag isn't good enough any more?
  • (cs) in reply to dpm

    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.

  • XXXXXX (unregistered)

    True or false? The developer wrote this way so he could hide an obscene diagram in the boolean grid.

  • (cs)

    And then he got fired for changing things up, right?

  • foo (unregistered)

    Why has noone done "FRIST" in x/T pixels yet? Are you all too lazy (like me), or was it deleted already?

  • Unicorn #2816 (unregistered) in reply to steenbergh
    steenbergh:
    Anybody else noticed that about halfway, there's a Tx in one cell, and an empty field ",," slightly further down the line?
    I have a feeling no one else noticed that.
  • Meep (unregistered)

    TRWTF is that the could have used a switch statement.

    for(int i = 0; i < 32; i++) {
      for(int j = 0; j < 32; j++) {
        switch(i << 5 + j) {
        case 0:
           if(a == i && b == j)
             v = T;
           break;
        case 1:
           if(a == i && b == j)
             v = x;
           break;
        ...
        default:
           v = FILE_NOT_FOUND;
           break;
        }
      }
    }
    
  • (cs) in reply to bkDJ
    bkDJ:
    Peter:
    Actually, TRWTF is that we check the page source for Remy's comments.
    I read this site on my iPad so I made a shitty JS bookmark let I can run and it shows comments and cornify links. I was surprised that it actually showed an extra (dupe) picture in Friday's Error'd. I can share it so you don't have to hunt through the source, if you want.

    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.

    // ==UserScript==
    // @name	Show comments on The Daily WTF articles
    // @match	http://thedailywtf.com/Articles/*.aspx
    // ==/UserScript==
    
    (function(b) {
    	b.innerHTML = b.innerHTML
    		.replace(/<!--/g,'<span style="color:red;">')
    		.replace(/-->/g,'');
    })(document.querySelector('.ArticleBody')) 
    
  • Joe (unregistered) in reply to dpm
    dpm:
    Remy Porter:
    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.
    So the PRE tag isn't good enough any more?
    Yeah, if you want a web page to say "x,x,x,x,x,x,x,x,x,T,T,T,T,T,x,x,x,x" what's wrong with putting "x,x,x,x,x,x,x,x,x,T,T,T,T,T,x,x,x,x" as the content?

    Not Enterprisey enough?

  • Frank (unregistered)

    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.

  • Sebastian Buchanan (unregistered)

    i remember using a similar method of true&false table to encode messages during the war

  • (unregistered)

    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.

  • (cs)

    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.

  • Plasmab (unregistered)

    That looks like it was synthesised from a HDL like Verilog or VHDL. Really shouldnt be in a software application. :)

  • Dacer (unregistered)

    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}, … }

  • Zapp Brannigan (unregistered)

    I ran the array through a parser and it decodes to "Drink more Ovaltine!" He should have stored this array in a database.

  • (cs)

    Welcome, Barry, to The Matrix...

  • (cs) in reply to chubertdev
    chubertdev:
    Welcome, Barry, to The Matrix...
    I don't even see the code any more. I just see blonde, brunette, redhead...
  • (cs) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    chubertdev:
    Welcome, Barry, to The Matrix...
    I don't even see the code any more. I just see blonde, brunette, redhead...
    For that, shouldn't each line be more like "xxxTTAxxxxxxTTAxxxx..."
  • Meep (unregistered) in reply to Frank
    Frank:
    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.

    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.

  • (cs) in reply to Frank
    Frank:
    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.

    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.

  • (cs)

    What is game of battleship?

  • (cs)
    configurator:
    bkDJ:
    Peter:
    Actually, TRWTF is that we check the page source for Remy's comments.
    I read this site on my iPad so I made a shitty JS bookmarklet I can run and it shows comments and cornify links. I was surprised that it actually showed an extra (dupe) picture in Friday's Error'd. I can share it so you don't have to hunt through the source, if you want.

    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.

    (snip)

    Yeah I used that old comment as a starting base but it kind of ballooned. It makes comments green on black, makes

    actual linebreaks within comments and leaves other tags intact (hence why the [image] tag worked in friday's article). It also surrounds cornify links with unicorn faces and summarizes what it did at the top of the article. the code is probably inefficient because it's my first foray into JS but it gets the job done. Also the images and text may be kind of small because I use it on a retina iPad. Here it is: http://pastebin.com/d4zJBXgr

  • Anonymous Paranoiac (unregistered)

    Brilliant! He invented binary flags!

  • (cs)

    Hey! You sunk my TTTTTTTTT

  • the beholder (unregistered) in reply to PedanticCurmudgeon
    PedanticCurmudgeon:
    chubertdev:
    Welcome, Barry, to The Matrix...
    I don't even see the code any more. I just see frigate, cruiser, aircraft carrier...
    FTFY
  • ch (unregistered)

    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...

  • eVil (unregistered) in reply to WhiskeyJack
    WhiskeyJack:
    Hey! You sunk my TTTTTTTTT

    this->GetCommentText();

  • (cs)

    Reminds me of the old game-select matrices in Atari game manuals.

  • Pita (unregistered)

    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?

  • El Ka-Ben (unregistered) in reply to Anonymous Paranoiac
    Anonymous Paranoiac:
    Brilliant! He invented binary flags!

    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.

  • (cs) in reply to Frank
    Frank:
    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.

    I'm sure that a Boolean is a byte, not a bit (Atleast in C++). Bitwise analysis may make sense, but in this context it doesn't.

    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.

    • I'm almost certain there are legitimate exceptions to this (Ie, drivers), but not something 95% of coders would actually encounter
  • (cs) in reply to foo
    foo:
    Why has noone done "FRIST" in x/T pixels yet? Are you all too lazy (like me), or was it deleted already?
    bool[,] set = {
        {T,T,T,T,T,T,x,x,T,T,T,T,T,x,x,x,T,T,T,T,x,x,T,T,T,x,x,x,T,T,T,T,T,T,…},
        {T,T,T,T,T,T,x,x,T,T,T,T,T,T,x,x,T,T,T,T,x,T,T,x,T,T,x,x,T,T,T,T,T,T,…},
        {T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,x,T,T,x,x,T,T,x,x,x,x,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,x,T,T,x,x,T,T,x,x,x,x,x,x,x,T,T,x,x,…},
        {T,T,T,T,x,x,x,x,T,T,x,x,T,T,x,x,x,T,T,x,x,x,T,T,x,x,x,x,x,x,T,T,x,x,…},
        {T,T,T,T,x,x,x,x,T,T,x,T,T,x,x,x,x,T,T,x,x,x,x,T,T,x,x,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,T,T,x,x,x,x,x,T,T,x,x,x,x,x,T,T,x,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,x,T,T,x,x,x,x,T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,x,x,T,T,x,x,x,T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,T,T,T,T,x,T,T,x,T,T,x,x,x,x,T,T,x,x,…},
        {T,T,x,x,x,x,x,x,T,T,x,x,x,T,T,x,T,T,T,T,x,x,T,T,T,T,x,x,x,x,T,T,x,x,…},
        …
    }
    

    (a little difficult to discern, alas, but...anyone willing to care?)

  • foo (unregistered) in reply to Adanine
    Adanine:
    I'm sure that a Boolean is a byte, not a bit (Atleast in C++). Bitwise analysis may make sense, but in this context it doesn't.

    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.

    • I'm almost certain there are legitimate exceptions to this (Ie, drivers), but not something 95% of coders would actually encounter
    Sure, drivers and other code dealing with hardware.

    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.

  • (cs)

    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:

      truth = (ch & 0x1) != 0;
  • Iain (unregistered) in reply to Nagesh
    Nagesh:
    What is game of battleship?

    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.

Leave a comment on “Battleship Booleans”

Log In or post as a guest

Replying to comment #394716:

« Return to Article