Can You Make This More Obfuscated?

This is a discussion on Can You Make This More Obfuscated? within the C++ Programming forums, part of the General Programming Boards category; Collatz Conjecture 1 liner: Code: #include <iostream> int main(){for(unsigned int i = 2;i <= 100;i++)for(volatile unsigned int j = i;j ...

  1. #1
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Collatz Conjecture 1 liner:

    Code:
    #include <iostream>
    int main(){for(unsigned int i = 2;i <= 100;i++)for(volatile unsigned int j = i;j > 1 && (true, (std::cout << j << " ")) ? true : (false, (std::cout << std::endl)) == false; (j % 2 == 0) ? j /= 2 : j = 3 * j + 1);return 0;}
    Actually, I take that back. A one liner with statement ending semicolons isn't a one liner, but you get the idea.

    Code:
    #include <iostream>
    int main()
    {
         for(unsigned int i = 2;i <= 100;i++)
              for(volatile unsigned int j = i;j > 1 && (true, (std::cout << j << " ")) ? true : (false, (std::cout << std::endl)) == false; (j % 2 == 0) ? j /= 2 : j = 3 * j + 1);
         return 0;
    }
    Last edited by User Name:; 03-17-2011 at 10:30 PM.

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Code Indentation???
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    I could make it considerably more obfuscated.

    1): use digraphs and trigraphs instead
    2): use template class recursion with specialization for the outer loop
    3): use template class recursion with specialization for the inner loop
    4): use template specialization to control the alternating update of the inner loop
    5): use global statics masquerading as members with constructors to generate the output
    6): use a meaningless nested table with a switch to control what the constructor should do
    7): use partial macro implementation with recursion to confound the logic of everything
    8): profit???

    Seriously, is there a reason that this thread exists beyond "Can you do this better than me?"? I fine with that. People post projects and stuff all the time. But if that is all this is you should consider asking an administrator to move it. So, if that is the case, do I win?

    Soma

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Mr.777 View Post
    Code Indentation???
    Doesn't that defeat the point of obfuscation? Maybe you understand what obfuscation is, but you don't know how to use it. Hm?


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Quote Originally Posted by quzah View Post
    Doesn't that defeat the point of obfuscation? Maybe you understand what obfuscation is, but you don't know how to use it. Hm?


    Quzah.
    He really means obfuscated not badly indented....
    First, I think you should stop being personal.
    Second, know what really obfuscation means.
    I don't care if someone doesn't like me, i was not put on earth to entertain everyone.

    No King, no Queen, I am the ACE of battle.

  6. #6
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Obfuscated code isn't necessarily indented.

    In fact, people take the opportunity to draw stuff, sometimes. The winning entry here spelled HELLO WORLD in block letters.

    There's a program that estimates pi that's a big circle floating around the internet, too.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    What on earth is that 'volatile' doing in there?!
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,415
    The winning entry here spelled HELLO WORLD in block letters.
    Wow. Beautiful. I've certainly seen more obfuscated code, but it is stunning. Well done jEssYcAt, wherever you may be.

    Yea, I realize it is a very old post, but it still deserves the recognition.

    What on earth is that 'volatile' doing in there?!
    *tsk*

    That is obvious; that's how you know it is obfuscated.

    Soma

  9. #9
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Quote Originally Posted by iMalc View Post
    What on earth is that 'volatile' doing in there?!
    I put it there while writing it in an attempt to make sure the compiler doesn't consider any of those calls extraneous, but have since changed it so that it is not necessary. I just forgot to get rid of it.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Mr.777 View Post
    He really means obfuscated not badly indented....
    First, I think you should stop being personal.
    Second, know what really obfuscation means.
    That sound you just heard was my post going over your head.


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Quote Originally Posted by Mr.777 View Post
    Code Indentation???
    Relevant Comments???

    Would anyone be interested in making this a competition? Collatz programs, that is. Or, if you would prefer it, number theory programs.

    I want to see how many are interested, if 5+, I'll get a mod to move to contests section.
    Last edited by User Name:; 03-18-2011 at 04:17 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  2. "Cannot make pipe"
    By crepincdotcom in forum C Programming
    Replies: 5
    Last Post: 08-16-2004, 01:43 PM
  3. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 05:19 AM
  4. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 02:05 PM
  5. Replies: 6
    Last Post: 04-20-2002, 07:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21