• [ENDED] (Results Soon) Code Golf - The Reboot #2 4 4

Author Topic: [ENDED] (Results Soon) Code Golf - The Reboot #2  (Read 42529 times)

0 Members and 1 Guest are viewing this topic.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Code Golf - The Reboot #2
« Reply #75 on: June 14, 2015, 08:14:47 pm »
Actually, c4ooo is up next, then Juju.
Yep, gotta wait until next week for mine :P

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline lirtosiast

  • LV3 Member (Next: 100)
  • ***
  • Posts: 44
  • Rating: +1/-0
    • View Profile
Re: Code Golf - The Reboot #2
« Reply #76 on: June 14, 2015, 11:56:43 pm »
Here are some of my attempts at this contest, in chronological order, along with explanations.
Spoiler For 40 byte solution:
While 1
If Ans

This was my first real (after working for an hour or so) solution once I fixed key repeat by using WASD instead of arrow keys. I had tried using two separate variables, but it seemed that using the complex plane would be smaller, even considering the two-byte cost of the real( and imag( tokens, because raising i to a power eliminates the cost of looking up the cursor change corresponding to a particular key. You can see that up, left, down, and right correspond to W, A, S, and D keys, which are key codes 85, 41, 81, and 51 respectively.

Spoiler For 33 byte solution:
While 1
If Ans

I began thinking about the fact that we could assume WASD are the only pressed keys, and found I could abuse it here. The WASD key codes are all different modulo 7, so taking i to that power would give 1, i, -1, and -i; luckily, they came in the right order.

Spoiler For 31 byte solution:
While 1
If Ans

Same sort of idea as the previous solution, but I used a "randomizer" function, because I knew the cosines of large interger numbers would be unpredictable. I basically searched through every token and every multiplier in the book, and finally found one that worked. These changes saved one byte in the Y-modifying line, and one from not needing to negate the imag(.

I started to think I was done golfing, but then I saw that, with a mathematical way to ignore a getKey value of zero, I could eliminate the If Ans line, and if I only used one getKey, I could include it in the algorithm and also store the cursor position in Ans instead of Y, saving five bytes.

Spoiler For 27 byte solution:
While 1

This one is honestly just magic.

Spoiler For 26 byte "solution":
If it weren't for rounding errors causing the cursor to move to the side every trillion keypresses, I would be able to eliminate the iPart(:

26 bytes:
While 1

And of course replacing the While 1 with recursion would save another two bytes, but crash after a few seconds.

The 1070 57-byte solutions I had in mind were all the 26-byte one (before I knew it was invalid), but with the 1 in While 1 replaced with length("[some 30-byte string], of which there are about 245^30 because there are about 245 printable one-byte tokens.

EDIT: I wonder if we'll ever get the results.
« Last Edit: June 16, 2015, 11:09:52 pm by lirtosiast »