Have you ever dream of quantum state? If that's true for you, you are probably weird...
Anyway, I came up with an idea: what if we make a quantum in code?
class, anything that can be put in a condition.
You can redefine anything as long as it’s infront of the other code( or the testcase I mean)
or you can make another file, and take the code as input, output the run result, but that will count as compiler/transpiler
What should it do:
(def your thing here, I'll name it "X" for now, you can also redefine “if”, or anything else, as long as it’s in this part of code and it doesn’t change the text of code(which count as transpiler i suppose)) if X: part a else: part b
part a and b should both be executed, although the chance of which being first should be 50/50.
if X: a=5 else: a=10 b=5
a should have 50% chance to be
b will always be
x can be different everytime mention, or always the same on parallel universe
if X: part a else if X: part b else: part c
a 50% being first execute,
b,c 25% each.(second X and first X both being quantum)
In this case
a will never be the second one executed.
a,b,c a,c,b b,c,a c,b,a
/ a True 50% init / b True 25% \ a False \ b False - c 25% First X Second X
X True for
X False for
b will never be executed.
/ X True - a init \ X False - c
you code should not work on non-quantum condition.
if True: if X: part a else: part b else: part c
c should never be executed no matter what
X as your submit
if X: # or X() print(1) else: print(2)
X can even just be a marker for your function to indicate where it need to rerun or change.
as long as you specify your variable name( please don't inject whole code into it)
You can specific to always have else after if, since doing nothing in else will make it identical to normal if.
A whole compiler/transpiler (changing code to fit in quantum state) is allowed, but will compete on it's own(with other compiler style anwser).
- Standard rules.
golf your quantum as smaller as possible!