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*

8
  • 1
    \$\begingroup\$ This is a quine-like challenge, without input or reading your source code (suppose it is n characters long), you need to print n random characters. Where the probability of a symbol c being chosen is equal to (number of times c occurs in your solution) / n. \$\endgroup\$ Commented Sep 8, 2016 at 16:05
  • \$\begingroup\$ So more like this? exec("""s = 'from random import choice; print "".join([choice(s) for c in s])'; exec(s)""") \$\endgroup\$ Commented Sep 8, 2016 at 16:23
  • \$\begingroup\$ You haven't included the single quotes yet, and you don't need the square brackets within the join. \$\endgroup\$ Commented Sep 8, 2016 at 16:36
  • \$\begingroup\$ Thanks - and right, I got a little caught up in the rush of nudging closer to the solution \$\endgroup\$ Commented Sep 8, 2016 at 16:37
  • 1
    \$\begingroup\$ Here you go: s='''from random import*;print"".join(choice(s)for c in s+"s='';''exec s''")''';exec s. I wish I'd thought of that. \$\endgroup\$ Commented Sep 8, 2016 at 16:41