Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

18
  • 9
    \$\begingroup\$ What is it with these [code-golf] + [restricted-time] challenges lately.. They are complete opposites imho. Anyway, as for the actual challenge, if we are to output huge test cases with k=18 and n between \$10^{17}\$ and \$10^{18}\$ within 10 seconds, you may want to add some test cases for those. \$\endgroup\$ Commented May 1, 2019 at 8:16
  • 2
    \$\begingroup\$ @KevinCruijssen It's a combination I really like :) Basically the challenge is to write compact code that is not too naive/brute force. I will try to add some more test cases.If anyone comes up with any first, please post them in the comments and I will add them to the question. \$\endgroup\$ Commented May 1, 2019 at 8:19
  • 3
    \$\begingroup\$ Also, a test case where k is larger than the length of n would be good as well, since we have to do exactly k swaps instead of up to k swaps. Can't really think of a good test case for this, but I think we might need to do an inefficient swap first sometimes in order to get to the maximum in exactly k swaps. \$\endgroup\$ Commented May 1, 2019 at 8:19
  • 1
    \$\begingroup\$ Can we take input n as a list of digits? \$\endgroup\$ Commented May 1, 2019 at 12:45
  • 3
    \$\begingroup\$ @MagicOctopusUrn Not necessary, since n=501, k=2 would become 510 in the first iteration, but then should be swapped back to 501 as our result. \$\endgroup\$ Commented May 1, 2019 at 20:08