I write a batch file, with which it is possible to find all combinations of four Tangle pieces (2x2 pieces).
The versions differ only by the duplicate Tangle piece. In the batch file one of the duplicate Tangle piece is p25.
With the parameter /ALL all combinations are determined. The output here is to redirect to a file.
combinations of four Tangle pieces (2x2 pieces).
Code: Select all
@echo off
setlocal ENABLEEXTENSIONS enableDelayedExpansion
set viewmode=#
if /i "%1"=="/piece" set viewmode=#1
if /i "%1"=="/piece4" set viewmode=#4
if /i "%1"=="/piece9" set viewmode=#9
if /i "%1"=="/piece16" set viewmode=#16
if /i "%1"=="/piece25" set viewmode=#25
set letrun=no
for %%a in (/piece /piece4 /piece9 /piece16 /piece25 /TEST /ALL /SEARCH /RECOLOR /ROTATE /FINDCOLOR) do if /i "%1"=="%%a" set letrun=yes
if %letrun%==yes goto :anfang
:help
echo.
echo %0 - Overview of Tangle and solution for 2x2 pieces
echo.
echo %0 [ /TEST ^| /ALL ]
echo %0 /PIECE piece
echo %0 /PIECE4 piece piece piece piece
echo %0 /PIECE9 piece piece piece piece piece piece piece piece piece
echo %0 /PIECE16 piece ... piece
echo %0 /PIECE25 piece ... piece
echo %0 /SEARCH LEFT^|RIGHT^|BOTTOM^|UPPER cords^|piece
echo %0 /FINDCOLOR piece1 piece2
echo %0 /RECOLOR code piece [piece ... piece]
echo %0 /ROTATE area 1^|2^|3 piece [piece ... piece]
echo.
echo /TEST tested only one piece in all four orientations
echo /ALL all pieces in all orientations; not used p25a, p25b, p25c, p25d
echo /PIECE view a Tangle piece in one orientation
echo /PIECE4 view four Tangle pieces ^(2x2 pieces^)
echo /PIECE9 view nine Tangle pieces ^(3x3 pieces^)
echo /PIECE16 view 16 Tangle pieces ^(4x4 pieces^)
echo /PIECE25 view 25 Tangle pieces ^(5x5 pieces^)
echo piece letter p, two digits, one letter ^(a, b, c, d^)
echo p01a, p01b, p01c, p01d, p02a, p02b ... p25a, p25b, p25c, p25d
echo /SEARCH searches color coding or piece on one side of the Tangle piece
echo cords one of these values: YG YR YB GY GR GB RY RG RB BY BR BG
echo /FINDCOLOR find the color code that change piece1 to piece2
echo /RECOLOR change the color code of pieces;
echo in the result are not present: p25a, p25b, p25c or p25d
echo code color code ^(example: BRYG^); result of /FINDCOLOR
echo /ROTATE rotate area not clockwise 90 degrees, 180 degrees or 270 degrees
echo area one of this following value: 2x2, 3x3, 4x4, 5x5
echo.
echo Also possible are the pieces: p00a, p00b, p00c and p00d
goto :eof
:anfang
rem 34 # 13 # 42 # 12 # Tangle piece and each orientations.
rem 2 1 # 4 4 # 3 1 # 2 3 # The orientation of the first Tangle piece is shown that the cord that passes straight from top to bottom on the right side.
rem 1 3 # 3 2 # 1 2 # 4 4 #
rem 24 # 21 # 43 # 31 #
rem Arrangement of the cords on Tangle piece for each orientations.
set basic=34 13 24 21 # 13 42 21 43 # 42 12 43 31 # 12 34 31 24
for /l %%n in (1 1 25) do (
if %%n lss 10 (set p0%%n=%basic%) else set p%%n=%basic%
)
rem piece 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
rem 1234 1243 1324 1342 1423 1432 2134 2143 2314 2341 2413 2431 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321
rem color YGRB YGBR YRGB YRBG YBGR YBRG GYRB GYBR GRYB GRBY GBYR GBRY RYGB RYBG RGYB RGBY RBYG RBGY BYGR BYRG BGYR BGRY BRYG BRGY
rem Tangle_1 M C E F V I T Q H L O D+S J G W A R B P U X Y N L
rem Tangle_2 U V R S B O T K G M J N P H+I L F E Q X W A D C Y
rem Tangle_3 Q N R E A Y G H D X O L V B C+T J S I W K F M P U
rem Tangle_4 W B R U X I J E A V C P Y Q M L G N H S T K O D+F
rem Sets for each position one letter; Yellow, Green, Red, Blue
for %%a in (01 02 03 04 05 06) do set p%%a=!p%%a:1=Y!
for %%a in (07 08 09 10 11 12) do set p%%a=!p%%a:1=G!
for %%a in (13 14 15 16 17 18) do set p%%a=!p%%a:1=R!
for %%a in (19 20 21 22 23 24) do set p%%a=!p%%a:1=B!
for %%a in (07 08 13 14 19 20) do set p%%a=!p%%a:2=Y!
for %%a in (01 02 15 16 21 22) do set p%%a=!p%%a:2=G!
for %%a in (03 04 09 10 23 24) do set p%%a=!p%%a:2=R!
for %%a in (05 06 11 12 17 18) do set p%%a=!p%%a:2=B!
for %%a in (09 11 15 17 21 23) do set p%%a=!p%%a:3=Y!
for %%a in (03 05 13 18 19 24) do set p%%a=!p%%a:3=G!
for %%a in (01 06 07 12 20 22) do set p%%a=!p%%a:3=R!
for %%a in (02 04 08 10 14 16) do set p%%a=!p%%a:3=B!
for %%a in (10 12 16 18 22 24) do set p%%a=!p%%a:4=Y!
for %%a in (04 06 14 17 20 23) do set p%%a=!p%%a:4=G!
for %%a in (02 05 08 11 19 21) do set p%%a=!p%%a:4=R!
for %%a in (01 03 07 09 13 15) do set p%%a=!p%%a:4=B!
rem double Tangle piece: Tangle_1 = 12 (D+S); Tangle_2 = 14 (H+I); Tangle_3 = 15 (C+T); Tangle_4 = 24 (D+F)
rem Here double Tangle piece Tangle_1.
set p25=%p12%
rem Any Tangle piece with each orientations.
for %%n in (01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25) do (
(set p%%na=!p%%n:~0,11!) & (set p%%nb=!p%%n:~14,11!) & (set p%%nc=!p%%n:~28,11!) & (set p%%nd=!p%%n:~42,11!)
)
rem Dummy Tangle piece; can use in view mode
(set p00a=xx xx xx xx) & (set p00b=xx xx xx xx) & (set p00c=xx xx xx xx) & (set p00d=xx xx xx xx)
rem View Tangle piece
if %viewmode%==#1 (
rem Test if 1 pieces available
if "%2"=="" goto :help3
if not "%3"=="" goto :help3
(set pset=%2) & (set test=%2###) & (set test=!test:~0,4!)
if "!test!" neq "!pset!" goto :help3
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
set view=%2
for %%t in (!view!) do set test=!%%t!
echo.
echo +---!test:~0,1!--!test:~1,1!---+
echo ^| ^|
echo !test:~9,1! !test:~3,1!
echo ^| !view! ^|
echo !test:~10,1! !test:~4,1!
echo ^| ^|
echo +---!test:~6,1!--!test:~7,1!---+
echo.
goto :eof
)
rem View four Tangle pieces
if %viewmode%==#4 (
rem Test if 4 pieces available
for /f "tokens=1*" %%a in ("%*") do set "pset=%%b"
rem Reduces max four spaces to one space and test pieces
(set pset=!pset: = !) & (set pset=!pset: = !) & (set test=!pset!###) & (set test=!test:~0,19!)
if "!test!" neq "!pset!" goto :help3
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
(set view1=%2) & (set view2=%3) & (set view3=%4) & (set view4=%5)
(for %%t in (!view1!) do set test1=!%%t!) & (for %%t in (!view2!) do set test2=!%%t!) & (for %%t in (!view3!) do set test3=!%%t!) & (for %%t in (!view4!) do set test4=!%%t!)
echo.
echo +---!test1:~0,1!--!test1:~1,1!---+ +---!test2:~0,1!--!test2:~1,1!---+
echo ^| ^| ^| ^|
echo !test1:~9,1! !test1:~3,1! !test2:~9,1! !test2:~3,1!
echo ^| !view1! ^| ^| !view2! ^|
echo !test1:~10,1! !test1:~4,1! !test2:~10,1! !test2:~4,1!
echo ^| ^| ^| ^|
echo +---!test1:~6,1!--!test1:~7,1!---+ +---!test2:~6,1!--!test2:~7,1!---+
echo.
echo +---!test3:~0,1!--!test3:~1,1!---+ +---!test4:~0,1!--!test4:~1,1!---+
echo ^| ^| ^| ^|
echo !test3:~9,1! !test3:~3,1! !test4:~9,1! !test4:~3,1!
echo ^| !view3! ^| ^| !view4! ^|
echo !test3:~10,1! !test3:~4,1! !test4:~10,1! !test4:~4,1!
echo ^| ^| ^| ^|
echo +---!test3:~6,1!--!test3:~7,1!---+ +---!test4:~6,1!--!test4:~7,1!---+
echo.
goto :eof
)
rem View nine Tangle pieces
if %viewmode%==#9 (
rem Test if 9 pieces available
for /f "tokens=1*" %%a in ("%*") do set "pset=%%b"
rem Reduces max four spaces to one space and test pieces
(set pset=!pset: = !) & (set pset=!pset: = !) & (set test=!pset!###) & (set test=!test:~0,44!)
if "!test!" neq "!pset!" goto :help3
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
for /f "tokens=2-10" %%A in ("%*") do (set view1=%%A) & (set view2=%%B) & (set view3=%%C) & (set view4=%%D) & (set view5=%%E) & (set view6=%%F) & (set view7=%%G) & (set view8=%%H) & (set view9=%%I)
(for %%t in (!view1!) do set test1=!%%t!) & (for %%t in (!view2!) do set test2=!%%t!) & (for %%t in (!view3!) do set test3=!%%t!)
(for %%t in (!view4!) do set test4=!%%t!) & (for %%t in (!view5!) do set test5=!%%t!) & (for %%t in (!view6!) do set test6=!%%t!)
(for %%t in (!view7!) do set test7=!%%t!) & (for %%t in (!view8!) do set test8=!%%t!) & (for %%t in (!view9!) do set test9=!%%t!)
echo.
echo +---!test1:~0,1!--!test1:~1,1!---+ +---!test2:~0,1!--!test2:~1,1!---+ +---!test3:~0,1!--!test3:~1,1!---+
echo ^| ^| ^| ^| ^| ^|
echo !test1:~9,1! !test1:~3,1! !test2:~9,1! !test2:~3,1! !test3:~9,1! !test3:~3,1!
echo ^| !view1! ^| ^| !view2! ^| ^| !view3! ^|
echo !test1:~10,1! !test1:~4,1! !test2:~10,1! !test2:~4,1! !test3:~10,1! !test3:~4,1!
echo ^| ^| ^| ^| ^| ^|
echo +---!test1:~6,1!--!test1:~7,1!---+ +---!test2:~6,1!--!test2:~7,1!---+ +---!test3:~6,1!--!test3:~7,1!---+
echo.
echo +---!test4:~0,1!--!test4:~1,1!---+ +---!test5:~0,1!--!test5:~1,1!---+ +---!test6:~0,1!--!test6:~1,1!---+
echo ^| ^| ^| ^| ^| ^|
echo !test4:~9,1! !test4:~3,1! !test5:~9,1! !test5:~3,1! !test6:~9,1! !test6:~3,1!
echo ^| !view4! ^| ^| !view5! ^| ^| !view6! ^|
echo !test4:~10,1! !test4:~4,1! !test5:~10,1! !test5:~4,1! !test6:~10,1! !test6:~4,1!
echo ^| ^| ^| ^| ^| ^|
echo +---!test4:~6,1!--!test4:~7,1!---+ +---!test5:~6,1!--!test5:~7,1!---+ +---!test6:~6,1!--!test6:~7,1!---+
echo.
echo +---!test7:~0,1!--!test7:~1,1!---+ +---!test8:~0,1!--!test8:~1,1!---+ +---!test9:~0,1!--!test9:~1,1!---+
echo ^| ^| ^| ^| ^| ^|
echo !test7:~9,1! !test7:~3,1! !test8:~9,1! !test8:~3,1! !test9:~9,1! !test9:~3,1!
echo ^| !view7! ^| ^| !view8! ^| ^| !view9! ^|
echo !test7:~10,1! !test7:~4,1! !test8:~10,1! !test8:~4,1! !test9:~10,1! !test9:~4,1!
echo ^| ^| ^| ^| ^| ^|
echo +---!test7:~6,1!--!test7:~7,1!---+ +---!test8:~6,1!--!test8:~7,1!---+ +---!test9:~6,1!--!test9:~7,1!---+
echo.
goto :eof
)
rem View 16 Tangle pieces
if %viewmode%==#16 (
rem Test if 16 pieces available
for /f "tokens=1*" %%a in ("%*") do set "pset=%%b"
rem Reduces max four spaces to one space and test pieces
(set pset=!pset: = !) & (set pset=!pset: = !) & (set test=!pset!###) & (set test=!test:~0,79!)
if "!test!" neq "!pset!" goto :help3
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
for /f "tokens=2-17" %%A in ("%*") do (
(set view1=%%A) & (set view2=%%B) & (set view3=%%C) & (set view4=%%D) & (set view5=%%E) & (set view6=%%F) & (set view7=%%G) & (set view8=%%H)
(set view9=%%I) & (set view10=%%J) & (set view11=%%K) & (set view12=%%L) & (set view13=%%M) & (set view14=%%N) & (set view15=%%O) & (set view16=%%P)
)
(for %%t in (!view1!) do set test1=!%%t!) & (for %%t in (!view2!) do set test2=!%%t!) & (for %%t in (!view3!) do set test3=!%%t!) & (for %%t in (!view4!) do set test4=!%%t!)
(for %%t in (!view5!) do set test5=!%%t!) & (for %%t in (!view6!) do set test6=!%%t!) & (for %%t in (!view7!) do set test7=!%%t!) & (for %%t in (!view8!) do set test8=!%%t!)
(for %%t in (!view9!) do set test9=!%%t!) & (for %%t in (!view10!) do set test10=!%%t!) & (for %%t in (!view11!) do set test11=!%%t!) & (for %%t in (!view12!) do set test12=!%%t!)
(for %%t in (!view13!) do set test13=!%%t!) & (for %%t in (!view14!) do set test14=!%%t!) & (for %%t in (!view15!) do set test15=!%%t!) & (for %%t in (!view16!) do set test16=!%%t!)
echo.
echo +---!test1:~0,1!--!test1:~1,1!---+ +---!test2:~0,1!--!test2:~1,1!---+ +---!test3:~0,1!--!test3:~1,1!---+ +---!test4:~0,1!--!test4:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo !test1:~9,1! !test1:~3,1! !test2:~9,1! !test2:~3,1! !test3:~9,1! !test3:~3,1! !test4:~9,1! !test4:~3,1!
echo ^| !view1! ^| ^| !view2! ^| ^| !view3! ^| ^| !view4! ^|
echo !test1:~10,1! !test1:~4,1! !test2:~10,1! !test2:~4,1! !test3:~10,1! !test3:~4,1! !test4:~10,1! !test4:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test1:~6,1!--!test1:~7,1!---+ +---!test2:~6,1!--!test2:~7,1!---+ +---!test3:~6,1!--!test3:~7,1!---+ +---!test4:~6,1!--!test4:~7,1!---+
echo.
echo +---!test5:~0,1!--!test5:~1,1!---+ +---!test6:~0,1!--!test6:~1,1!---+ +---!test7:~0,1!--!test7:~1,1!---+ +---!test8:~0,1!--!test8:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo !test5:~9,1! !test5:~3,1! !test6:~9,1! !test6:~3,1! !test7:~9,1! !test7:~3,1! !test8:~9,1! !test8:~3,1!
echo ^| !view5! ^| ^| !view6! ^| ^| !view7! ^| ^| !view8! ^|
echo !test5:~10,1! !test5:~4,1! !test6:~10,1! !test6:~4,1! !test7:~10,1! !test7:~4,1! !test8:~10,1! !test8:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test5:~6,1!--!test5:~7,1!---+ +---!test6:~6,1!--!test6:~7,1!---+ +---!test7:~6,1!--!test7:~7,1!---+ +---!test8:~6,1!--!test8:~7,1!---+
echo.
echo +---!test9:~0,1!--!test9:~1,1!---+ +---!test10:~0,1!--!test10:~1,1!---+ +---!test11:~0,1!--!test11:~1,1!---+ +---!test12:~0,1!--!test12:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo !test9:~9,1! !test9:~3,1! !test10:~9,1! !test10:~3,1! !test11:~9,1! !test11:~3,1! !test12:~9,1! !test12:~3,1!
echo ^| !view9! ^| ^| !view10! ^| ^| !view11! ^| ^| !view12! ^|
echo !test9:~10,1! !test9:~4,1! !test10:~10,1! !test10:~4,1! !test11:~10,1! !test11:~4,1! !test12:~10,1! !test12:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test9:~6,1!--!test9:~7,1!---+ +---!test10:~6,1!--!test10:~7,1!---+ +---!test11:~6,1!--!test11:~7,1!---+ +---!test12:~6,1!--!test12:~7,1!---+
echo.
echo +---!test13:~0,1!--!test13:~1,1!---+ +---!test14:~0,1!--!test14:~1,1!---+ +---!test15:~0,1!--!test15:~1,1!---+ +---!test16:~0,1!--!test16:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo !test13:~9,1! !test13:~3,1! !test14:~9,1! !test14:~3,1! !test15:~9,1! !test15:~3,1! !test16:~9,1! !test16:~3,1!
echo ^| !view13! ^| ^| !view14! ^| ^| !view15! ^| ^| !view16! ^|
echo !test13:~10,1! !test13:~4,1! !test14:~10,1! !test14:~4,1! !test15:~10,1! !test15:~4,1! !test16:~10,1! !test16:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test13:~6,1!--!test13:~7,1!---+ +---!test14:~6,1!--!test14:~7,1!---+ +---!test15:~6,1!--!test15:~7,1!---+ +---!test16:~6,1!--!test16:~7,1!---+
echo.
goto :eof
)
rem View 25 Tangle pieces
if %viewmode%==#25 (
rem Test if 25 pieces available
for /f "tokens=1*" %%a in ("%*") do set "pset=%%b"
rem Reduces max four spaces to one space and test pieces
(set pset=!pset: = !) & (set pset=!pset: = !) & (set test=!pset!###) & (set test=!test:~0,124!)
if "!test!" neq "!pset!" goto :help3
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
for /f "tokens=2-26" %%A in ("%*") do (
(set view1=%%A) & (set view2=%%B) & (set view3=%%C) & (set view4=%%D) & (set view5=%%E) & (set view6=%%F) & (set view7=%%G) & (set view8=%%H)
(set view9=%%I) & (set view10=%%J) & (set view11=%%K) & (set view12=%%L) & (set view13=%%M) & (set view14=%%N) & (set view15=%%O) & (set view16=%%P)
(set view17=%%Q) & (set view18=%%R) & (set view19=%%S) & (set view20=%%T) & (set view21=%%U) & (set view22=%%V) & (set view23=%%W) & (set view24=%%X)
(set view25=%%Y)
)
(for %%t in (!view1!) do set test1=!%%t!) & (for %%t in (!view2!) do set test2=!%%t!) & (for %%t in (!view3!) do set test3=!%%t!) & (for %%t in (!view4!) do set test4=!%%t!)
(for %%t in (!view5!) do set test5=!%%t!) & (for %%t in (!view6!) do set test6=!%%t!) & (for %%t in (!view7!) do set test7=!%%t!) & (for %%t in (!view8!) do set test8=!%%t!)
(for %%t in (!view9!) do set test9=!%%t!) & (for %%t in (!view10!) do set test10=!%%t!) & (for %%t in (!view11!) do set test11=!%%t!) & (for %%t in (!view12!) do set test12=!%%t!)
(for %%t in (!view13!) do set test13=!%%t!) & (for %%t in (!view14!) do set test14=!%%t!) & (for %%t in (!view15!) do set test15=!%%t!) & (for %%t in (!view16!) do set test16=!%%t!)
(for %%t in (!view17!) do set test17=!%%t!) & (for %%t in (!view18!) do set test18=!%%t!) & (for %%t in (!view19!) do set test19=!%%t!) & (for %%t in (!view20!) do set test20=!%%t!)
(for %%t in (!view21!) do set test21=!%%t!) & (for %%t in (!view22!) do set test22=!%%t!) & (for %%t in (!view23!) do set test23=!%%t!) & (for %%t in (!view24!) do set test24=!%%t!)
(for %%t in (!view25!) do set test25=!%%t!)
echo.
echo +---!test1:~0,1!--!test1:~1,1!---+ +---!test2:~0,1!--!test2:~1,1!---+ +---!test3:~0,1!--!test3:~1,1!---+ +---!test4:~0,1!--!test4:~1,1!---+ +---!test5:~0,1!--!test5:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo !test1:~9,1! !test1:~3,1! !test2:~9,1! !test2:~3,1! !test3:~9,1! !test3:~3,1! !test4:~9,1! !test4:~3,1! !test5:~9,1! !test5:~3,1!
echo ^| !view1! ^| ^| !view2! ^| ^| !view3! ^| ^| !view4! ^| ^| !view5! ^|
echo !test1:~10,1! !test1:~4,1! !test2:~10,1! !test2:~4,1! !test3:~10,1! !test3:~4,1! !test4:~10,1! !test4:~4,1! !test5:~10,1! !test5:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test1:~6,1!--!test1:~7,1!---+ +---!test2:~6,1!--!test2:~7,1!---+ +---!test3:~6,1!--!test3:~7,1!---+ +---!test4:~6,1!--!test4:~7,1!---+ +---!test5:~6,1!--!test5:~7,1!---+
echo.
echo +---!test6:~0,1!--!test6:~1,1!---+ +---!test7:~0,1!--!test7:~1,1!---+ +---!test8:~0,1!--!test8:~1,1!---+ +---!test9:~0,1!--!test9:~1,1!---+ +---!test10:~0,1!--!test10:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo !test6:~9,1! !test6:~3,1! !test7:~9,1! !test7:~3,1! !test8:~9,1! !test8:~3,1! !test9:~9,1! !test9:~3,1! !test10:~9,1! !test10:~3,1!
echo ^| !view6! ^| ^| !view7! ^| ^| !view8! ^| ^| !view9! ^| ^| !view10! ^|
echo !test6:~10,1! !test6:~4,1! !test7:~10,1! !test7:~4,1! !test8:~10,1! !test8:~4,1! !test9:~10,1! !test9:~4,1! !test10:~10,1! !test10:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test6:~6,1!--!test6:~7,1!---+ +---!test7:~6,1!--!test7:~7,1!---+ +---!test8:~6,1!--!test8:~7,1!---+ +---!test9:~6,1!--!test9:~7,1!---+ +---!test10:~6,1!--!test10:~7,1!---+
echo.
echo +---!test11:~0,1!--!test11:~1,1!---+ +---!test12:~0,1!--!test12:~1,1!---+ +---!test13:~0,1!--!test13:~1,1!---+ +---!test14:~0,1!--!test14:~1,1!---+ +---!test15:~0,1!--!test15:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo !test11:~9,1! !test11:~3,1! !test12:~9,1! !test12:~3,1! !test13:~9,1! !test13:~3,1! !test14:~9,1! !test14:~3,1! !test15:~9,1! !test15:~3,1!
echo ^| !view11! ^| ^| !view12! ^| ^| !view13! ^| ^| !view14! ^| ^| !view15! ^|
echo !test11:~10,1! !test11:~4,1! !test12:~10,1! !test12:~4,1! !test13:~10,1! !test13:~4,1! !test14:~10,1! !test14:~4,1! !test15:~10,1! !test15:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test11:~6,1!--!test11:~7,1!---+ +---!test12:~6,1!--!test12:~7,1!---+ +---!test13:~6,1!--!test13:~7,1!---+ +---!test14:~6,1!--!test14:~7,1!---+ +---!test15:~6,1!--!test15:~7,1!---+
echo.
echo +---!test16:~0,1!--!test16:~1,1!---+ +---!test17:~0,1!--!test17:~1,1!---+ +---!test18:~0,1!--!test18:~1,1!---+ +---!test19:~0,1!--!test19:~1,1!---+ +---!test20:~0,1!--!test20:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo !test16:~9,1! !test16:~3,1! !test17:~9,1! !test17:~3,1! !test18:~9,1! !test18:~3,1! !test19:~9,1! !test19:~3,1! !test20:~9,1! !test20:~3,1!
echo ^| !view16! ^| ^| !view17! ^| ^| !view18! ^| ^| !view19! ^| ^| !view20! ^|
echo !test16:~10,1! !test16:~4,1! !test17:~10,1! !test17:~4,1! !test18:~10,1! !test18:~4,1! !test19:~10,1! !test19:~4,1! !test20:~10,1! !test20:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test16:~6,1!--!test16:~7,1!---+ +---!test17:~6,1!--!test17:~7,1!---+ +---!test18:~6,1!--!test18:~7,1!---+ +---!test19:~6,1!--!test19:~7,1!---+ +---!test20:~6,1!--!test20:~7,1!---+
echo.
echo +---!test21:~0,1!--!test21:~1,1!---+ +---!test22:~0,1!--!test22:~1,1!---+ +---!test23:~0,1!--!test23:~1,1!---+ +---!test24:~0,1!--!test24:~1,1!---+ +---!test25:~0,1!--!test25:~1,1!---+
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo !test21:~9,1! !test21:~3,1! !test22:~9,1! !test22:~3,1! !test23:~9,1! !test23:~3,1! !test24:~9,1! !test24:~3,1! !test25:~9,1! !test25:~3,1!
echo ^| !view21! ^| ^| !view22! ^| ^| !view23! ^| ^| !view24! ^| ^| !view25! ^|
echo !test21:~10,1! !test21:~4,1! !test22:~10,1! !test22:~4,1! !test23:~10,1! !test23:~4,1! !test24:~10,1! !test24:~4,1! !test25:~10,1! !test25:~4,1!
echo ^| ^| ^| ^| ^| ^| ^| ^| ^| ^|
echo +---!test21:~6,1!--!test21:~7,1!---+ +---!test22:~6,1!--!test22:~7,1!---+ +---!test23:~6,1!--!test23:~7,1!---+ +---!test24:~6,1!--!test24:~7,1!---+ +---!test25:~6,1!--!test25:~7,1!---+
echo.
goto :eof
)
set tangleset=p01a p02a p03a p04a p05a p06a p07a p08a p09a p10a p11a p12a p13a p14a p15a p16a p17a p18a p19a p20a p21a p22a p23a p24a p25a
set tangleset=%tangleset% p01b p02b p03b p04b p05b p06b p07b p08b p09b p10b p11b p12b p13b p14b p15b p16b p17b p18b p19b p20b p21b p22b p23b p24b p25b
set tangleset=%tangleset% p01c p02c p03c p04c p05c p06c p07c p08c p09c p10c p11c p12c p13c p14c p15c p16c p17c p18c p19c p20c p21c p22c p23c p24c p25c
set tangleset=%tangleset% p01d p02d p03d p04d p05d p06d p07d p08d p09d p10d p11d p12d p13d p14d p15d p16d p17d p18d p19d p20d p21d p22d p23d p24d p25d
rem num01_r: right side - num01_l: left side - num01_b: bottom side (lower side) - num01_u: upper side
rem _r=%num01:~3,2% _l=%num01:~9,2% _b=%num01:~6,2% _u=%num01:~0,2%
if /i %1==/SEARCH (
if "%2"=="" goto :help1
if "%3"=="" goto :help1
set test=#
for %%t in (left right bottom upper) do if /i %%t==%2 set test=##
if !test!==# goto :help1
set test=#
rem Test if parameter %3 is color code or piece
for %%t in (YG YR YB GY GR GB RY RG RB BY BR BG) do if /i %%t==%3 set test=1##
if !test!==1## set hvar=%3
for %%t in (%tangleset%) do if /i %%t==%3 set test=2##
if !test!==# goto :help1
rem Find color code in piece
if !test!==2## (
set hvar2=!%3!
if /i "%2"=="left" set hvar=!hvar2:~3,2!
if /i "%2"=="right" set hvar=!hvar2:~9,2!
if /i "%2"=="bottom" set hvar=!hvar2:~0,2!
if /i "%2"=="upper" set hvar=!hvar2:~6,2!
)
set hvar2=#
if /i "%2"=="left" (
for %%A in (%tangleset%) do (
set help=!%%A:~9,2!
if /i "!hvar!"=="!help!" set hvar2=!hvar2! %%A
)
)
if /i "%2"=="right" (
for %%A in (%tangleset%) do (
set help=!%%A:~3,2!
if /i "!hvar!"=="!help!" set hvar2=!hvar2! %%A
)
)
if /i "%2"=="bottom" (
for %%A in (%tangleset%) do (
set help=!%%A:~6,2!
if /i "!hvar!"=="!help!" set hvar2=!hvar2! %%A
)
)
if /i "%2"=="upper" (
for %%A in (%tangleset%) do (
set help=!%%A:~0,2!
if /i "!hvar!"=="!help!" set hvar2=!hvar2! %%A
)
)
echo !hvar2:~2!
goto :eof
)
if /i %1==/RECOLOR (
if "%2"=="" goto :help2
if "%3"=="" goto :help2
rem Delete piece p25 from the variable TANGLESET, but not from the pieces
(set tangleset=!tangleset: p25a=!) & (set tangleset=!tangleset: p25b=!) & (set tangleset=!tangleset: p25c=!) & (set tangleset=!tangleset: p25d=!)
for /f "tokens=2*" %%a in ("%*") do (
set color=%%a
set pieceset=%%b
)
set test=OK
for %%a in (!color!) do echo #YGRB#YGBR#YRGB#YRBG#YBGR#YBRG#GYRB#GYBR#GRYB#GRBY#GBYR#GBRY#RYGB#RYBG#RGYB#RGBY#RBYG#RBGY#BYGR#BYRG#BGYR#BGRY#BRYG#BRGY# | find /i "#%%a#">nul || set test=notOK
if /i !test!==notOK goto :help2
call :TestPieces "!pieceset!" TestOK
if /i !TestOK!==notOK goto :help3
set num=#
for %%A in (!pieceset!) do (
set test=!%%A!
(set test=!test:Y=1!) & (set test=!test:G=2!) & (set test=!test:R=3!) & (set test=!test:B=4!)
for /f "tokens=1-4" %%E in ("!color:~0,1! !color:~1,1! !color:~2,1! !color:~3,1!") do (
(set test=!test:1=%%E!) & (set test=!test:2=%%F!) & (set test=!test:3=%%G!) & (set test=!test:4=%%H!)
)
set hvar=FALSE
for %%z in (!tangleset!) do (
set nump=!%%z!
if /i "!nump!"=="!test!" (set num=!num! %%z) & (set hvar=TRUE)
)
if !hvar!==FALSE set num=!num! %%A
)
echo !num:~2!
goto :eof
)
if /i %1==/FINDCOLOR (
if "%2"=="" goto :help3
if "%3"=="" goto :help3
call :TestPieces "%2 %3" TestOK
if /i !TestOK!==notOK goto :help3
rem Rotate the pieces in orientation pxxa
(set test=%2) & (set test=!test:~0,-1!a) & for %%A in (!test!) do set test1=!%%A!
(set test=%3) & (set test=!test:~0,-1!a) & for %%B in (!test!) do set test2=!%%B!
rem Changes the color code from piece 1 in a numerical code
(set test1=!test1:Y=1!) & (set test1=!test1:G=2!) & (set test1=!test1:R=3!) & (set test1=!test1:B=4!)
rem Addiction cords with the numbers 1 to 4 and takes over the color code of piece 2
rem The tokens correspond to the cord types: %%a = wave, %%b = rippon, %%c = bow, %%d = straight line
for /f "tokens=1-4" %%a in ("!test1:~10,1! !test1:~9,1! !test1:~0,1! !test1:~1,1!") do (
(if %%a==1 set color=!test2:~10,1!) & (if %%b==1 set color=!test2:~9,1!) & (if %%c==1 set color=!test2:~0,1!) & (if %%d==1 set color=!test2:~1,1!)
(if %%a==2 set color=!color!!test2:~10,1!) & (if %%b==2 set color=!color!!test2:~9,1!) & (if %%c==2 set color=!color!!test2:~0,1!) & (if %%d==2 set color=!color!!test2:~1,1!)
(if %%a==3 set color=!color!!test2:~10,1!) & (if %%b==3 set color=!color!!test2:~9,1!) & (if %%c==3 set color=!color!!test2:~0,1!) & (if %%d==3 set color=!color!!test2:~1,1!)
(if %%a==4 set color=!color!!test2:~10,1!) & (if %%b==4 set color=!color!!test2:~9,1!) & (if %%c==4 set color=!color!!test2:~0,1!) & (if %%d==4 set color=!color!!test2:~1,1!)
)
echo Color code: !color!
goto :eof
)
if /i %1==/ROTATE (
for /f "tokens=2,3*" %%a in ("%*") do (
set area=%%a
set rotcount=%%b
set "pset=%%c"
)
rem Reduces max four spaces to one space and test pieces
(set pset=!pset: = !) & (set pset=!pset: = !)
call :TestPieces "!pset!" TestOK
if /i !TestOK!==notOK goto :help3
set test=#
for %%a in (2x2 3x3 4x4 5x5) do if "%%a"=="!area!" set test=##
if !test!==# goto :help
set test=#
for %%a in (1 2 3) do if "%%a"=="!rotcount!" set test=##
if !test!==# goto :help
rem Changes the position of the pieces
if !area!==2x2 (
set test=!pset!###
set test=!test:~0,19!
if "!test!" neq "!pset!" goto :help3
if !rotcount!==1 set pset2=!pset:~5,4! !pset:~15,4! !pset:~0,4! !pset:~10,4!
if !rotcount!==2 set pset2=!pset:~15,4! !pset:~10,4! !pset:~5,4! !pset:~0,4!
if !rotcount!==3 set pset2=!pset:~10,4! !pset:~0,4! !pset:~15,4! !pset:~5,4!
)
if !area!==3x3 (
set test=!pset!###
set test=!test:~0,44!
if "!test!" neq "!pset!" goto :help3
if !rotcount!==1 set pset2=!pset:~10,4! !pset:~25,4! !pset:~40,4! !pset:~5,4! !pset:~20,4! !pset:~35,4! !pset:~0,4! !pset:~15,4! !pset:~30,4!
if !rotcount!==2 set pset2=!pset:~40,4! !pset:~35,4! !pset:~30,4! !pset:~25,4! !pset:~20,4! !pset:~15,4! !pset:~10,4! !pset:~5,4! !pset:~0,4!
if !rotcount!==3 set pset2=!pset:~30,4! !pset:~15,4! !pset:~0,4! !pset:~35,4! !pset:~20,4! !pset:~5,4! !pset:~40,4! !pset:~25,4! !pset:~10,4!
)
if !area!==4x4 (
set test=!pset!###
set test=!test:~0,79!
if "!test!" neq "!pset!" goto :help3
if !rotcount!==1 (
set pset2=!pset:~15,4! !pset:~35,4! !pset:~55,4! !pset:~75,4! !pset:~10,4! !pset:~30,4! !pset:~50,4! !pset:~70,4!
set pset2=!pset2! !pset:~5,4! !pset:~25,4! !pset:~45,4! !pset:~65,4! !pset:~0,4! !pset:~20,4! !pset:~40,4! !pset:~60,4!
)
if !rotcount!==2 (
set pset2=!pset:~75,4! !pset:~70,4! !pset:~65,4! !pset:~60,4! !pset:~55,4! !pset:~50,4! !pset:~45,4! !pset:~40,4!
set pset2=!pset2! !pset:~35,4! !pset:~30,4! !pset:~25,4! !pset:~20,4! !pset:~15,4! !pset:~10,4! !pset:~5,4! !pset:~0,4!
)
if !rotcount!==3 (
set pset2=!pset:~60,4! !pset:~40,4! !pset:~20,4! !pset:~0,4! !pset:~65,4! !pset:~45,4! !pset:~25,4! !pset:~5,4!
set pset2=!pset2! !pset:~70,4! !pset:~50,4! !pset:~30,4! !pset:~10,4! !pset:~75,4! !pset:~55,4! !pset:~35,4! !pset:~15,4!
)
)
if !area!==5x5 (
set test=!pset!###
set test=!test:~0,124!
if "!test!" neq "!pset!" goto :help3
if !rotcount!==1 (
set pset2=!pset:~20,4! !pset:~45,4! !pset:~70,4! !pset:~95,4! !pset:~120,4! !pset:~15,4! !pset:~40,4! !pset:~65,4!
set pset2=!pset2! !pset:~90,4! !pset:~115,4! !pset:~10,4! !pset:~35,4! !pset:~60,4! !pset:~85,4! !pset:~110,4! !pset:~5,4!
set pset2=!pset2! !pset:~30,4! !pset:~55,4! !pset:~80,4! !pset:~105,4! !pset:~0,4! !pset:~25,4! !pset:~50,4! !pset:~75,4! !pset:~100,4!
)
if !rotcount!==2 (
set pset2=!pset:~120,4! !pset:~115,4! !pset:~110,4! !pset:~105,4! !pset:~100,4! !pset:~95,4! !pset:~90,4! !pset:~85,4!
set pset2=!pset2! !pset:~80,4! !pset:~75,4! !pset:~70,4! !pset:~65,4! !pset:~60,4! !pset:~55,4! !pset:~50,4! !pset:~45,4!
set pset2=!pset2! !pset:~40,4! !pset:~35,4! !pset:~30,4! !pset:~25,4! !pset:~20,4! !pset:~15,4! !pset:~10,4! !pset:~5,4! !pset:~0,4!
)
if !rotcount!==3 (
set pset2=!pset:~100,4! !pset:~75,4! !pset:~50,4! !pset:~25,4! !pset:~0,4! !pset:~105,4! !pset:~80,4! !pset:~55,4!
set pset2=!pset2! !pset:~30,4! !pset:~5,4! !pset:~110,4! !pset:~85,4! !pset:~60,4! !pset:~35,4! !pset:~10,4! !pset:~115,4!
set pset2=!pset2! !pset:~90,4! !pset:~65,4! !pset:~40,4! !pset:~15,4! !pset:~120,4! !pset:~95,4! !pset:~70,4! !pset:~45,4! !pset:~20,4!
)
)
rem Changes the orientation of the pieces
(set pset2=!pset2:a=e!) & (set pset2=!pset2:b=f!) & (set pset2=!pset2:c=g!) & (set pset2=!pset2:d=h!)
if !rotcount!==1 ((set pset2=!pset2:e=b!) & (set pset2=!pset2:f=c!) & (set pset2=!pset2:g=d!) & (set pset2=!pset2:h=a!))
if !rotcount!==2 ((set pset2=!pset2:e=c!) & (set pset2=!pset2:f=d!) & (set pset2=!pset2:g=a!) & (set pset2=!pset2:h=b!))
if !rotcount!==3 ((set pset2=!pset2:e=d!) & (set pset2=!pset2:f=a!) & (set pset2=!pset2:g=b!) & (set pset2=!pset2:h=c!))
echo !pset2!
goto :eof
)
if /i %1==/TEST for %%z in (p01a p01b p01c p01d) do call :pierce_ %%z
(set tangleset=!tangleset: p25a=!) & (set tangleset=!tangleset: p25b=!) & (set tangleset=!tangleset: p25c=!) & (set tangleset=!tangleset: p25d=!)
if /i %1==/ALL for %%z in (%tangleset%) do call :pierce_ %%z
goto :eof
rem Find all combinations of a Tangle piece.
rem The arrangement of the parts: num01 num02
rem num03 num04
rem Output to the file or screen: num01 num02 num03 num04
:pierce_
rem Color code from piece 1 - right: %num01_r% - bottom: %num01_b%
(set num01_=%1) & (set num01=!%1!)
set num01_r=%num01:~3,2%
set num01_b=%num01:~6,2%
(set test1=%num01_%) & (set test1=!test1:~0,3!)
rem Search piece 2 - left: %num01_r%
set num02=#
for %%A in (%tangleset%) do (
set help=!%%A:~9,2!
(set test2=%%A) & (set test2=!test2:~0,3!)
if %num01_r% equ !help! set num02=!num02! %%A
)
set num02=%num02:~1%
rem Search piece 3 - up: %num01_b%
set num03=#
for %%A in (%tangleset%) do (
set help=!%%A:~0,2!
(set test3=%%A) & (set test3=!test3:~0,3!)
if %num01_b% equ !help! set num03=!num03! %%A
)
set num03=%num03:~1%
rem Piece 4 is a combination of 'piece 2 - buttom' and 'piece 3 - right'
for %%B in (%num02%) do for %%R in (%num03%) do (
set num02_b=!%%B:~6,2!
set num03_r=!%%R:~3,2!
(set num04=#) & (set test2=%%B) & (set test2=!test2:~0,3!) & (set test3=%%R) & (set test3=!test3:~0,3!)
for %%s in (%tangleset%) do (
set help1=!%%s:~0,2!
set help2=!%%s:~9,2!
(set test4=%%s) & (set test4=!test4:~0,3!)
if !num02_b! equ !help1! if !num03_r! equ !help2! (
rem Output to the file or screen
echo %num01_% %%B %%R %%s
)
)
)
goto :eof
:TestPieces
setlocal
set "hvar= %~1 "
(set hvar=!hvar:a = !) & (set hvar=!hvar:b = !) & (set hvar=!hvar:c = !) & (set hvar=!hvar:d = !) & (set hvar=!hvar: p= !)
set test=OK
for %%a in (%hvar%) do echo #00#01#02#03#04#05#06#07#08#09#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25# | find "#%%a#">nul || set test=notOK
endlocal & set %2=%test%
exit /B
:: goto :eof
:help1
echo.
echo %0 - ERROR
echo.
echo %0 /SEARCH LEFT^|RIGHT^|BOTTOM^|UPPER cords^|piece
echo.
echo In the following example, a Tangle piece is wanted that color combination YR
echo should have on the left side.
echo The color combinations are two letters ^(Yellow, Green, Red, Blue^).
echo.
echo +---R--B---+ +---x--x---+
echo ^| ^| ^| ^| %0 /SEARCH LEFT YR
echo G Y Y x %0 /SEARCH LEFT p01a
echo ^| p01a ^| ^| p??? ^|
echo Y R R x
echo ^| ^| ^| ^| Easy to remember: LEFT is YR
echo +---G--B---+ +---x--x---+ LEFT is P01A
echo.
goto :eof
:help2
echo.
echo %0 - ERROR
echo.
echo %0 /RECOLOR code piece [piece ... piece]
echo.
echo The color code is one of this value:
echo YGRB YGBR YRGB YRBG YBGR YBRG GYRB GYBR GRYB GRBY GBYR GBRY
echo RYGB RYBG RGYB RGBY RBYG RBGY BYGR BYRG BGYR BGRY BRYG BRGY
echo.
goto :eof
:help3
echo.
echo %0 - ERROR
echo.
echo Any pieces are definated as: letter p, two digits, one letter ^(a, b, c, d^)
echo p01a, p01b, p01c, p01d, p02a, p02b ... p25a, p25b, p25c, p25d
echo Also possible are: p00a, p00b, p00c and p00d
echo.
echo For some parameters, a specific number of pieces needed.
echo 1 piece /PIECE
echo 2 pieces /FINDCOLOR
echo 4 pieces /PIECE4 and /ROTATE 2x2
echo 9 pieces /PIECE9 and /ROTATE 3x3
echo 16 pieces /PIECE16 and /ROTATE 4x4
echo 25 pieces /PIECE25 and /ROTATE 5x5
echo 1 or more pieces /RECOLOR
echo.
echo Use no more than four spaces between the pieces.
echo.
goto :eof
In the FOR loop, the same values were used for both variables here, because both have Tangle pieces on the left side the color combination RG (Red, Green).
The examples show only one of the combinations.
With the expansion of 2x2 to 4x2 there are 56 combinations. I think the extension to 2x4 will come to a similar number of combinations.
There are many combinations to consider.