Skip to content

Commit 96218d9

Browse files
committed
Improved triple
1 parent 9c13c16 commit 96218d9

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

batch/triple.bat

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
@ECHO OFF
2-
3-
FOR /L %%c IN (1, 1, 40) DO CALL :FIRST %%c
4-
GOTO :END
5-
6-
:FIRST
7-
FOR /L %%b IN (1, 1, %1) DO CALL :SECOND %1 %%b
8-
GOTO :END
9-
10-
:SECOND
11-
FOR /L %%a IN (1, 1, %2) DO CALL :THIRD %1 %2 %%a
12-
GOTO :END
13-
14-
:THIRD
15-
SET /A legs=%3 * %3 + %2 * %2
16-
SET /A hyp=%1*%1
17-
IF %legs% EQU %hyp% ECHO %3, %2, %1
18-
19-
:END
2+
SETLOCAL ENABLEDELAYEDEXPANSION
3+
FOR /L %%c IN (1, 1, 40) DO (
4+
FOR /L %%b IN (1, 1, %%c) DO (
5+
FOR /L %%a IN (1, 1, %%b) DO (
6+
SET /A legs=%%a * %%a + %%b * %%b
7+
SET /A hyp=%%c * %%c
8+
IF !legs! EQU !hyp! ECHO %%a, %%b, %%c
9+
)
10+
)
11+
)

0 commit comments

Comments
 (0)