-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem7.cmd
More file actions
50 lines (46 loc) · 818 Bytes
/
Problem7.cmd
File metadata and controls
50 lines (46 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:: Project Euler Problem 7
:: Using hashing!
SET _Count=1
SET _Check=1
:: 8192 character limit in each hash
SET _PHash1=2
SET _PHash2=
SET _PHash3=
SET _PHash4=
SET _PHash5=
SET _PHash6=
SET _PHash7=
SET _PHash8=
SET _PHash9=
SET _PHash10=
:Loop
SET /A _Check+=2
FOR /L %%G IN (1,1,10) DO (
SET /A _CheckMax=!_Check!/3
IF DEFINED _PHash%%G (
FOR %%H IN (!_PHash%%G!) DO (
IF %%H LEQ !_CheckMax! (
SET /A _PCheck = !_Check! %% %%H
IF !_PCheck! EQU 0 GOTO Loop
)
)
)
)
SET /A _Count+=1
FOR /L %%I IN (1,1,10) DO (
IF %_Count% LSS %%I000 (
IF DEFINED _PHash%%I (
SET _PHash%%I=!_PHash%%I!,%_Check%
GOTO Break
) ELSE (
SET _PHash%%I=%_Check%
GOTO Break
)
)
)
:Break
ECHO:%_Count% :: %_Check%
IF %_Count% LSS 10001 GOTO Loop
GOTO :EOF