repl.it
@William33/

ComposedFirstArachnid

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import random

vetor = [1, 2, 3, 4, 5, 6, 7, 8, 9]

def magicsquare():
    return vetor[0]+vetor[1]+vetor[2]==\
           vetor[3]+vetor[4]+vetor[5]==\
           vetor[6]+vetor[7]+vetor[8]==\
           vetor[0]+vetor[3]+vetor[6]==\
           vetor[1]+vetor[4]+vetor[7]==\
           vetor[2]+vetor[5]+vetor[8]==\
           vetor[0]+vetor[4]+vetor[8]==\
           vetor[2]+vetor[4]+vetor[6]

while not magicsquare():
    random.shuffle(vetor)

print (vetor)
Fetching token
?