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*

4
  • 1
    \$\begingroup\$ 146 bytes. \$\endgroup\$ Commented Jun 17, 2018 at 21:07
  • \$\begingroup\$ 140 bytes. \$\endgroup\$ Commented Jun 17, 2018 at 21:12
  • \$\begingroup\$ @bobrobbob: Welcome to PPCG! I'm not quite sure how your algorithm works (although it clearly does); but experimentally, it seems you can save some more bytes by replacing range(max(p,q)+1) with range(p+q). \$\endgroup\$ Commented Jun 18, 2018 at 3:46
  • 1
    \$\begingroup\$ You can save some more bytes by using {*a} instead of set(a). \$\endgroup\$ Commented Jun 18, 2018 at 9:18