擅长:python、mysql、java
<p>这很有趣!禁止进口!在</p>
<p>问题是,我们需要一个硬币抛硬币,而不需要进口任何东西。听起来像是对<code><some random int> % 2 == 0</code>的测试。最难的部分是<code><some random int></code>。可能是堆上的指针?在</p>
<pre><code>input_list = ['a', 'b', 'c', 'd']
#you should empty this once and awhile
fill_my_heap = []
#nothing to see here
class Dummy():
pass
for x in range(0,10):
#give me a new pointer
foo = Dummy()
#prevent reuse of heap memory location
fill_my_heap.append(foo)
#get id of new class and strip its last digit because that was always even
ptr_int = int(str(id(foo))[:-1])
#test to see if this is even. Should be 50% of the time. Sort of... ;)
is_even = ptr_int%2==0
#split list
a = input_list[:len(input_list)/2]
b = input_list[len(input_list)/2:]
#and assemble output based on even-switch
if is_even:
output = a + b
else:
output = b + a
print(output)
</code></pre>
<p>给出:</p>
^{pr2}$