¥Ù¥ë¥¯¡¦¥«¥Ã¥Ä¥§
ÏÈ/Ãå½ç¤Îɽ¤òºî¤ê¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤òÄɵ­¤·¤Æ¤¤¤¯¤È¡¢A¤Ï3ÏÈ5Ãå¤Ë¤Ê¤ê¤Þ¤·¤¿¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 0:06:08¡¡¡¡ ¡¡¡¡51449
¤à¤é¤«¤ß
3°Ì¤Î¢®¢®¢®¢®¢®¢®¢®¢®¤¬»ä¤Î¤è¤¦¤Êµ¤¤¬¤·¤Þ¤¹¡£
¤½¤Î¸å¤ËÁ÷¤ê¤Ê¤ª¤·¤¿Ì¾Á°¤Ï¤¦¤Þ¤¯È¿±Ç¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 0:07:45¡¡¡¡ ¡¡¡¡51450
¤·¤È¤ª
»ä¤âɽ¤òÉÁ¤­¤Þ¤·¤¿¡£¾¯¤·¤º¤Äɽ¤¬Ëä¤Þ¤Ã¤Æ¤¤¤¯¤Î¤¬µ¤»ý¤Á¤è¤¯¤Æ³Ú¤·¤«¤Ã¤¿¤Ç¤¹¤Í
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 0:13:41¡¡¡¡ ¡¡¡¡51451
Mr.¥À¥ó¥Ç¥£
¥Ù¥ë¥¯¡¦¥«¥Ã¥Ä¥§¤µ¤ó¤Î¡¡#51449¤ÈƱÍͤˤ·¤Þ¤·¤¿¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 0:14:17¡¡¡¡ ¡¡¡¡51452
»ç¤Îé¬é¯¤Î¿Í
£µ¡ß£µ¤Îɽ¤òºî¤Ã¤Æ²ò¤­¤Þ¤·¤¿¡£
³Æ¹Ô³ÆÎó¤Ë¤Ï¡¢£Á¡Á£Å¤¬°ì¤Ä¤·¤«Æþ¤é¤Ê¤¤¤Î¤Ç¡¢½ù¡¹¤Ë²ò¤±¤Æ¤¤¤­¤Þ¤¹¡£

£±Ãå¡¡£´ÏÈ¡¡£Ã
£²Ãå¡¡£²ÏÈ¡¡£Â
£³Ãå¡¡£±ÏÈ¡¡£Å
£´Ãå¡¡£µÏÈ¡¡£Ä
£µÃå¡¡£³ÏÈ¡¡£Á
¤Ë¤Ê¤ê¤Þ¤·¤¿¡£

¤À¤«¤é¡¢Åú¤¨¤Ï¡Ö3,5¡×
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 0:20:21¡¡¡¡ ¡¡¡¡51453
¡Ö¿ô³Ø¡×¾®Î¹¹Ô
ÉÔ²Äǽ¤Ê½çÎó¤ò¾Ã¤·¤Æ¤¤¤¯¤È¹Ê¤ì¤Þ¤·¤¿¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 1:23:29¡¡¡¡ ¡¡¡¡51454
Sunachu
5x5x5¤ÎΩÊýÂΤǹͤ¨¤¿¤é´Êñ¤Ç¤·¤¿¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 9:30:36¡¡¡¡ ¡¡¡¡51456
ÃæDA
Ëͤâ5¡ß5¤Îɽ¤ò»È¤Ã¤Æ²ò¤­¤Þ¤·¤¿¡£
A¤ÎÃå½ç¤¬ºÇ½é¤Ëµá¤Þ¤ê¤Þ¤·¤¿¡£
¡¡¡¡ 4·î21Æü¡ÊÌÚ¡Ë 20:43:11¡¡¡¡ ¡¡¡¡51457
SECOND
!¤³¤ó¤ÊÌäÂê¤ò¥×¥í¥°¥é¥à¤Ç²ò¤¯¤Ë¤Ï¡¢¤É¤¦¤¹¤ì¤Ð¤è¤¤¤«¡©¡©¡¡ÆñÂê¤Ç¡¢¡¢»ÅÊý¤Ê¤¤¡¢
!½çÎó P(5,5)=120 ¤Î£²¾è¡¢14400Ä̤ꡢÁ´¤Æ¤Î¥±¡¼¥¹¤ò¸¡ºº¤·¤¿¡££±Ä̤ê¤À¤±¤Ç¾¤Ë¤Ï̵¤¤¡£
!¿Í¤Îů³ØŪ²òË¡¤ò¡¢Âå¹Ô¤µ¤»¤ë¤Ë¤Ï¡¢¤É¤¦¤¹¤ì¤Ð¤è¤¤¤À¤í¤¦¡¦¡¦

!ok= 0 1
!ok= 0 2
!ok= 0 3
!¡¡¡¡¡¡ (
!¡¡¡¡¡¡¡¡)
!ok= 0 6220
!ok= 1 6221

! - - E - -
! - B - - -
! - - - - A
! C - - - -
! - - - D -

!ok= 0 6222
!¡¡¡¡¡¡ (
!¡¡¡¡¡¡¡¡)
!ok= 0 14399
!ok= 0 14400

DIM m(120,5), z(5), h$(5,5)
DATA 1,2,3,4,5
MAT READ z
CALL perm20(1) !z(5)=1,2,3,4,5 ¤Î½çÎó P(5,5) ¤ÎŸ³«¤ò m(120,5)¤ËºîÀ®
!
FOR y=1 TO 120
FOR x=1 TO 120
MAT h$="-"& NUL$ !h$(ÏÈ,Ãå½ç) ¤ò ¶õ¥Þ¡¼¥¯"-"¤ÇËä¤á¤ë
FOR i=1 TO 5
LET h$(m(y,i),m(x,i))=CHR$(i+64) !P(5,5)^2=14400Ä̤ê¤Î (ÏÈ,Ãå½ç)¥±¡¼¥¹¤ò h$(5,5) ¤Ë½ç¼¡ºîÀ®
NEXT i
CALL check !´ÑµÒ¥¢¡Á´ÑµÒ¥­¤Î¾ò·ï¡¢¸¡ºº
LET n=n+1
PRINT "!ok=";ok;n
IF ok=1 THEN
PRINT
MAT PRINT USING "! # # # # #" :h$
PRINT
pause
END IF
NEXT x
NEXT y

!-------------------------------------------
! ÇÛÎó h$(1~5ÏÈ,1~5Ãå½ç) ¤ÎÃæÌ£ ABCDE ¤Î¸¡ºº
!-------------------------------------------
SUB check
LET ok=0
!--------------------
!´ÑµÒ¥¢¡¡£Ã¤Ï£´ÏȤ«¡¼¡£
!--------------------
FOR i=1 TO 5
IF h$(4,i)="C" THEN EXIT FOR
NEXT i
IF 5< i THEN EXIT SUB
!--------------------
!´ÑµÒ¥¤¡¡£Å¤Ï¡¢£µÏȤÎÇϤè¤ê¤ÏÀèÃ夷¤¿¤è¡£
!--------------------
FOR i=1 TO 5
IF h$(5,i)<>"-" THEN EXIT FOR
NEXT i
FOR j=1 TO i-1
FOR w=1 TO 4
IF h$(w,j)="E" THEN EXIT FOR
NEXT w
IF w<=4 THEN EXIT FOR
NEXT j
IF i<=j THEN EXIT SUB
!--------------------
!´ÑµÒ¥¦¡¡£±ÏȤÎÇÏ¡¢£³Ãå°Ê²¼¤À¤Í¡£
!--------------------
IF h$(1,1)<>"-" OR h$(1,2)<>"-" THEN EXIT SUB
!--------------------
!´ÑµÒ¥¨¡¡£Â¤Ï£²Ã夫¡¼¡¢Àˤ·¤¤¤Ê¤¡¡£
!--------------------
FOR i=1 TO 5
IF h$(i,2)="B" THEN EXIT FOR
NEXT i
IF 5< i THEN EXIT SUB
!--------------------
!´ÑµÒ¥ª¡¡£³ÏȤÎÇÏ¡¢£µÃå¤À¤Ã¤¿¤è...¡£
!--------------------
IF h$(3,5)="-" THEN EXIT SUB
!--------------------
!´ÑµÒ¥«¡¡£²ÏȤÎÇϤϡ¢£±Ãå¤Ë¤Ï¤Ê¤ì¤Ê¤«¤Ã¤¿¤«¡£
!--------------------
IF h$(2,1)<>"-" THEN EXIT SUB
!--------------------
!´ÑµÒ¥­¡¡£Ä¤Ï¡¢£±Ãå¤ÎÇϤè¤ê³°Â¦¤ÎÏÈ¡ÊÃí¡§ÏȤÎÈֹ椬Â礭¤¤¤È¤¤¤¦¤³¤È¡Ë¤À¤Ã¤¿¤Ê¡¼¡£
!--------------------
FOR i=1 TO 5
IF h$(i,1)<>"-" THEN EXIT FOR
NEXT i
FOR i=i+1 TO 5
FOR j=2 TO 5
IF h$(i,j)="D" THEN EXIT FOR
NEXT j
IF j<=5 THEN EXIT FOR
NEXT i
IF 5< i THEN EXIT SUB
!--------------------
LET ok=1
END SUB

!-----------------------------------------------------
! z(5)=1,2,3,4,5 ¤Î ½çÎó P(5,5)¤ò¡¢m(120,5) ¤Ë³ÊǼ¤¹¤ë
!-----------------------------------------------------
SUB perm20(k) !start CALL perm20(1)
local i
IF k<=5 THEN
FOR i=k TO 5
swap z(k),z(i)
CALL perm20(k+1)
swap z(k),z(i)
NEXT i
ELSE
LET p=p+1
FOR i=1 TO 5
LET m(p,i)=z(i)
NEXT i
END IF
END SUB

END
¡¡¡¡ 4·î22Æü¡Ê¶â¡Ë 11:17:43¡¡¡¡ ¡¡¡¡51458
¤è¤ó¤Ò
python¡Ê¼ê½¬¤¤Ãæ¡Ë¤ÇÀ©Ìó¥×¥í¥°¥é¥ß¥ó¥°¤Ç²ò¤¤¤Æ¤ß¤Þ¤·¤¿¡£
Google Colab¾å¤Ç¡¢°Ê²¼¤Î¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¤È

UMA Chaku Waku
A 5 3
B 2 2
C 1 4
D 4 5
E 3 1

¤È¤¤¤¦·ë²Ì¤¬ÆÀ¤é¤ì¤Þ¤·¤¿¡£

------------------------

!pip install ortools

from ortools.sat.python import cp_model

class SolutionPrinter(cp_model.CpSolverSolutionCallback):
def __init__(self, u2c, u2w):
cp_model.CpSolverSolutionCallback.__init__(self)
self.__u2c = u2c
self.__u2w = u2w
self.__solution_count = 0

def solution_count(self):
return self.__solution_count

def on_solution_callback(self):
print('Solution %i,' % self.__solution_count)
self.__solution_count += 1

uma=['A','B','C','D','E']
print('UMA Chaku Waku')
for i in range(len(uma)):
print(f'{uma[i]} {self.Value(u2c[i])+1} {self.Value(u2w[i])+1}')
print()

m = cp_model.CpModel()
u2w=[m.NewIntVar(0,5-1,'u2w%i'% i) for i in range(5)]#ÇÏ¢ªÏÈ
w2c=[m.NewIntVar(0,5-1,'w2c%i'% i) for i in range(5)]#ÏÈ¢ªÃå
u2c=[m.NewIntVar(0,5-1,'u2c%i'% i) for i in range(5)]#ÇÏ¢ªÃå
m.AddAllDifferent(u2w)
m.AddAllDifferent(w2c)
m.AddAllDifferent(u2c)

for i in range(5):
m.AddElement(u2w[i],w2c,u2c[i])#ÇÏ¢ªÏÈ¢ªÃå¤ÈÇÏ¢ªÃ夬°ìÃ×

#£Ã¤Ï£´ÏȤ«¡¼¡£
m.Add(u2w[2]==3)
#£Å¤Ï¡¢£µÏȤÎÇϤè¤ê¤ÏÀèÃ夷¤¿¤è¡£
m.Add(u2c[4]<w2c[4])
#£±ÏȤÎÇÏ¡¢£³Ãå°Ê²¼¤À¤Í¡£
m.Add(w2c[0]>=2)
#£Â¤Ï£²Ã夫¡¼¡¢Àˤ·¤¤¤Ê¤¡¡£
m.Add(u2c[1]==1)
#£³ÏȤÎÇÏ¡¢£µÃå¤À¤Ã¤¿¤è...¡£
m.Add(w2c[2]==4)
#£²ÏȤÎÇϤϡ¢£±Ãå¤Ë¤Ï¤Ê¤ì¤Ê¤«¤Ã¤¿¤«¡£
m.Add(w2c[1]!=0)
#£Ä¤Ï¡¢£±Ãå¤ÎÇϤè¤ê³°Â¦¤ÎÏÈ¡ÊÃí¡§ÏȤÎÈֹ椬Â礭¤¤¤È¤¤¤¦¤³¤È¡Ë¤À¤Ã¤¿¤Ê¡¼¡£
c2w=[m.NewIntVar(0,5-1,'c2w%i'% i) for i in range(5)]#Ã墪ÏÈ
m.AddInverse(w2c,c2w)
m.Add(u2w[3]>c2w[0])

# Solve the model.
solver = cp_model.CpSolver()
solution_printer = SolutionPrinter(u2c,u2w)
solver.parameters.enumerate_all_solutions = True
solver.Solve(m, solution_printer)
¡¡¡¡ 4·î22Æü¡Ê¶â¡Ë 17:04:42¡¡¡¡ ¡¡¡¡51459
¤è¤ó¤Ò
¤³¤Î·Ç¼¨ÈĤϹÔƬ¤Î¥¹¥Ú¡¼¥¹¤¬¥È¥ê¥à¤µ¤ì¤Æ¤·¤Þ¤¦¤ó¤Ç¤¹¤Í¡£python¤Ï¥¹¥Ú¡¼¥¹¤Ëʸˡ¾å¤Î°ÕÌ£¤¬¤¢¤ë¤Î¤ÇÀµ¤·¤¯Æþ¤ì¤Ê¤¤¤È¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£
¶õ¹Ô¤ò½ü¤¤¤¿4,9,11,27¹ÔÌܤË1¤Ä
5-8,10,12-16,18¹ÔÌܤË2¤Ä
17¹ÔÌܤË3¤Ä¤Î
¹ÔƬ¤Î¥¹¥Ú¡¼¥¹¡Ê¤Þ¤¿¤Ï¥¿¥Ö¡Ë¤¬ÉÕ¤­¤Þ¤¹¡£
¡¡¡¡ 4·î22Æü¡Ê¶â¡Ë 18:09:37¡¡¡¡ ¡¡¡¡51460