import sys from sage.all import * def rand_LS(n): m=LatinSquare(n) m[0,0]=randint(0,n-1) for i in range(0,n-1): for j in range(0,n-1): while true: m[i,j]=randint(0,n-1) if (m.is_completable()): break return m
1 | initial version |
import sys from sage.all import * def rand_LS(n): m=LatinSquare(n) m[0,0]=randint(0,n-1) for i in range(0,n-1): for j in range(0,n-1): while true: m[i,j]=randint(0,n-1) if (m.is_completable()): break return m
import sys from sage.all import * def rand_LS(n): m=LatinSquare(n) m[0,0]=randint(0,n-1) for i in range(0,n-1): for j in range(0,n-1): while true: m[i,j]=randint(0,n-1) if (m.is_completable()): break return m
Code:
import sys from sage.all import * def rand_LS(n): m=LatinSquare(n) m[0,0]=randint(0,n-1) for i in range(0,n-1): for j in range(0,n-1): while true: m[i,j]=randint(0,n-1) if (m.is_completable()): break return m
Code:
import sys
from sage.all import *
def rand_LS(n):
m=LatinSquare(n)
m[0,0]=randint(0,n-1)
for i in range(0,n-1):
for j in range(0,n-1):
while true:
m[i,j]=randint(0,n-1)
if (m.is_completable()):
break
return Code:
import sys
from sage.all import *
def rand_LS(n):
m=LatinSquare(n)
m[0,0]=randint(0,n-1)
for i in range(0,n-1):
for j in range(0,n-1):
while true:
m[i,j]=randint(0,n-1)
if (m.is_completable()):
break
return m