Decoding

View as PDF

Submit solution

Points: 20
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Python

Xyene had a dream about a hard problem last night, and this morning he's decided to see if anyone can solve it.

Xyene has some code that does some funky stuff with a secret x, and stores it into a variable y.

def foo():
   x = <some secret value you do not know>
   y = <some expression involving x you do not know>
   def magic(n):
       <does something with n>
   magic(y)

<your submission code goes here>

Your task is simple: print y!

As an added bonus, your solution should not use exec or eval, nor should it import or open files.


Comments


  • 1
    GeeTransit  commented on Dec. 26, 2019, 10:18 p.m. edited

    Do we print y after it's been (possibly) modified by magic or do we print its initial value?


    • 0
      GeeTranzit  commented on May 10, 2021, 8:36 p.m. edit 2

      Yes. Yes. (Looks like it isn't mutated so it doesn't matter.)


  • 1
    Togohogo1  commented on Dec. 10, 2019, 2:00 a.m.

    Does this function magic(n) return anything or are there other tricks in magic(n)


    • 1
      Xyene  commented on Dec. 10, 2019, 2:43 a.m. edited

      Yes, it returns something. All functions in Python return something, even if that something is None.

      >>> import dis
      >>> def magic(n):
      ...     return n
      ... 
      >>> dis.dis(magic)
        2           0 LOAD_FAST                0 (n)
                    3 RETURN_VALUE        
      >>> def magic(n):
      ...     pass
      ... 
      >>> dis.dis(magic)
        2           0 LOAD_CONST               0 (None)
                    3 RETURN_VALUE
      

  • 2
    nathanl3  commented on March 9, 2017, 1:40 p.m.

    Are x and y assumed to be numerical values?


    • 3
      quantum  commented on Feb. 25, 2018, 7:26 a.m.

      Hint: it doesn't matter. Your task is to print it. Who cares what you are printing? print doesn't, so why should you?