Tuesday 15 April 2014

dc: how do I pop (and discard) the top number of the stack? -


In DC, how do I pop and remove a number from the top of the heap? With a stack of two items ( 2 3 ) with three items ( 1 2 3 ), a stack should be created. Currently I am sending the number to the second stack (SJ), but it seems lame.

This is an interesting puzzle! Through an DC manual, one systematically shows that only commands (such as + ) and not printed (like n ) C , i , o , and k . I played with c but it could not work, so that i , o , and k

These commands only accept numbers in a certain range (for example i and o accepting a number between only 2 and 16 ), So the puzzle becomes one of the changes in a number of arbitrary values ​​(for example, a string) in a number.

Then I command XXKrkk :

  1. stops the first X and the number of partial digits in the POPED value Push to, or 0 if the stack's top string was note that the pushed value is always an integer.
  2. The second stops the X and since it is an integer, it suppresses 0.
  3. Call P this value pushing current .
  4. Swaps the top two values ​​on the r stack (hence we now have 0 and p next).
  5. Popes up k 0 and gives zero accuracy.
  6. k pops the value P and sets it just right before everything started.

    If you know that the accuracy is zero (which is by default), then you can use it in XXk . If you know additional that the value at the top of the stack is an integer, then you can only use Xk .

No comments:

Post a Comment