Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Code Puzzles

Discussion in 'General Discussion' started by jpthek9, Oct 27, 2015.

  1. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    GetObscured

    This is a forum game I thought of from stumbling upon IOCCC. The objective is to to make a script's GetObscured method return something resembling the word "Obscured". The challenge is that you can only modify the contents of a method, function, or property called Vulnerable.

    Solver rules:
    • Code is solved when the GetObscured method of the script returns a form of the word "Obscured"
    • Only the contents between the brackets of the Vulnerable method may be modified
    Puzzle rules:
    • The puzzle must have at least 1 method, function, or property called Vulnerable
    • Puzzle must have no more than 512 characters excluding whitespace
    • There must be an easily accessible method called GetObscured that returns a string. If this method returns something resembling "Obscured", the puzzle is solved.
    • There has to be a solution!
    Universal rules:
    • Code must be able to be compiled and run in the current version of Unity (5.2)
    • Code must be in C# or JavaScript
    • To prevent security risks, no contents of any namespace except System and System.Reflection may be used.
    Here's an example:

    Code (CSharp):
    1. public struct s{
    2.     public static string GetObscured () {
    3.         char[] l = new char[8];
    4.         new s(new s(), l);
    5.         string r = "";
    6.         foreach (char c in l) r += c;
    7.         return r;
    8.     }
    9.     int i;
    10.     static d f = (o) => {while(Vulnerable(o) >= 8) o.i -= 8; return Vulnerable(o);};
    11.     delegate int d (s o);
    12.     public s(s o, char[] l) {
    13.         i = o.i;
    14.         o.i = (o.i + 5) % 8;
    15.         l[f(this)] = o.i == 0 ? '0' :
    16.             o.i == 1 ? 'B' :
    17.                 o.i == 2 ? '5' :
    18.                 o.i == 3 ? 'C' :
    19.                 o.i == 4 ? 'U' :
    20.                 o.i == 5 ? 'R' :
    21.                 o.i == 6 ? '3' :
    22.                 o.i == 7 ? 'D' :
    23.                 'N'
    24.                 ;
    25.         if (i == 3) return;
    26.         this = new s(o,l);
    27.     }
    28.     static int Vulnerable (s o) {
    29.         return o.i + 43110;
    30.     }
    31. }
    When run like this, the GetObscured() returns "D0B5CUR3".

    After solving the puzzle...
    Code (CSharp):
    1. static int Vulnerable (s o) {
    2.     return o.i + 5;
    3. }
    0B5CUR3D!

    Good luck and happy brain throbbing!
     
    Last edited: Oct 27, 2015
  2. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Hm, I guess nobody likes code puzzles :c
     
  3. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    You already posted the solution, there was no puzzle!
     
  4. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    You're supposed to come up with one!
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I don't get the point. What's the exercise supposed to teach us?
     
  6. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    It teaches you how to write the messiest, most unmanageable code you can think of!
     
  7. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    I already do that every day.
     
  8. CaoMengde777

    CaoMengde777

    Joined:
    Nov 5, 2013
    Posts:
    813
    >< ... i try to stay away from maths me no so good wit de maths duurr

    i like the idea of code puzzles ... err. wait maybe not lol
    but this just sucks lol