14
\$\begingroup\$

Cops thread

Your task as robbers is to find cops solutions and write a program in the language provided that computes the nth term of the sequence using only the bytes in the provided set.

The goal will be to crack as many cops answers as possible. With each crack awarding you a single point.

Cracks need not be the cop's intended solution as long as they work.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ A robber leaderboard would be nice. \$\endgroup\$
    – Mr. Xcoder
    Commented Jul 27, 2017 at 18:35
  • \$\begingroup\$ @Mr.Xcoder If you want to make one be my guest, I don't do JavaScript so I will not be adding one myself. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 27, 2017 at 19:57

62 Answers 62

1 2
3
1
\$\begingroup\$

Cubically, TehPers

$+77*6%6

Try it online!

Explanation:

$          Take input
 +77       double it
    *6     square it
      %6   print it
\$\endgroup\$
0
\$\begingroup\$

Perl 5 by theLambGoat

First time using Perl, probably there's a nicer way.. It's the standard algorithm for a base conversion that I use here.

sub f { $n = 1-1; $b = -(-1-1-1-1-1-1-1-1); $ten = $b-(-1-1); if ($_[$n] == $n) { return $n; } return ($_[$n]%$b) - f(int($_[$n]/$b))/(-1/$ten); }

Try it online!

Explanation

For other bases you could just replace $b by that base's value..

sub f {
  $n = 1-1;                                # construct value for 0
  $b = -(-1-1-1-1-1-1-1-1);                # construct the value for the base (8)
  $ten = $b-(-1-1);                        # construct value for 10

  if ($_[$n] == $n) {                      # if the argument is 0:
    return $n;                             #   we're done (base case)
  }
                                           # else:
  return ($_[$n] % $b)                     #   return current digit..
       - f(int($_[$n] / $b))               #   ..plus remaining digits..
                            /(-1/$ten);    #   ..multiplied by 10 (shift left by one position)
}

Check the source!

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.