Search found 2041 matches

by dbenham
28 Apr 2018 20:59
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

As promised, here is a version that allows you to easily modify the list of available stamps. Instructions for how to modify the list are at the bottom of the code. It is currently configured and optimized to quickly compute solutions for the original list of stamps. But the first time you run with ...
by dbenham
26 Apr 2018 15:14
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

Your code is too complicated to understand. Could you please make a list of stamps (values/display) more user friendly so new stamps could be added or removed with ease. One more thing: how can I use comma as a decimal point? If I replace '0.20' with '0,20' I get divide by zero. My new code at the ...
by dbenham
26 Apr 2018 09:31
Forum: DOS Batch Forum
Topic: more tricks with certutil
Replies: 2
Views: 243

Re: more tricks with certutil

:shock:
Wonderful - Thankyou :!: :D
by dbenham
25 Apr 2018 22:20
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

Thanks penpen. The failure comes from my erroneous 2nd postulate where I only allow a count of n or n-1 for any given denomination. I had to change the algorithm to allow each denomination to test more than 2 counts. It was surprisingly easy. I didn't spend much time trying to optimize the implement...
by dbenham
25 Apr 2018 12:22
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

I investigated the performance, and I'm pretty sure the maximum number of CALLs to :solve must be <=111 for any given number. I tested all values from 1 to 4000, and the maximum number of CALLs was 55, and the vast majority required between 30 and 50 calls. I looked at the results of running 1 to 40...
by dbenham
25 Apr 2018 10:24
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

I believe I have an efficient solution that quickly computes an optimal solution for any positive integral value supported by SET /A. Some values have multiple optimal solutions. My code finds the optimal solution with the highest possible number of D. My code is dependent on one additional postulat...
by dbenham
25 Apr 2018 05:26
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

Actual best solution for 460: 2 X D 2 X C 2 X 0.02 or 4 X C 1 X A 1 X 0.20 Your first best solution is wrong. It gives 456, not 460... Sorry, I was sloppy and used a value of D=128 instead of D=126 :oops: Ok. This is my second attempt: I did some comparisons with penpen's code, and your result for ...
by dbenham
24 Apr 2018 15:54
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

Impressive :!: 8)

Now I have to see if I can figure out how your code works :D
by dbenham
24 Apr 2018 14:25
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

It is a lot easier than coming up with a solution :lol: I'm not sure how to translate this into a calculus multi-variable max/min problem (or even if it is possible). Like aGerman, it has been nearly 40 years. And I don't think I would want to do that in batch anyway :wink: In lieu of that, this see...
by dbenham
24 Apr 2018 13:48
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

@Aacini - Nope :!: :twisted: Your result for 160: Possible solutions: 1- 5 stamps = 1@D 1@0.20 1@0.10 2@0.02 2- 4 stamps = 1@C 1@B 1@0.10 1@0.02 3- 6 stamps = 3@B 1@0.10 1@0.05 1@0.01 4- 4 stamps = 4@A 5- 8 stamps = 8@0.20 6- 16 stamps = 16@0.10 7- 32 stamps = 32@0.05 8- 80 stamps = 80@0.02 9- 160 s...
by dbenham
24 Apr 2018 11:31
Forum: DOS Batch Forum
Topic: stamps
Replies: 25
Views: 820

Re: stamps

All of the listed solutions give the following for 60:

1 X B
1 X 0,10
1 X 0,02

The correct answer should be :

1 X A
1 X 0,20


Dave Benham
by dbenham
23 Apr 2018 07:01
Forum: DOS Batch Forum
Topic: 'for' statement in macro will not accept 'tokens' argument from another 'for' statement. Why?
Replies: 5
Views: 249

Re: 'for' statement in macro will not accept 'tokens' argument from another 'for' statement. Why?

Because FOR /F options are parsed and interpreted before FOR variables are expanded. The fact that you are using FOR /F within a macro has nothing to do with the problem. It all makes sense if you study How does the Windows Command Interpreter (CMD.EXE) parse scripts? . You cannot use FOR variables ...
by dbenham
19 Apr 2018 18:52
Forum: DOS Batch Forum
Topic: exit function and preserve variable over endlocal barrier
Replies: 23
Views: 6353

Re: exit function and preserve variable over endlocal barrier

Hi Ed. That line is from Phil (pieh-ejdsch), not me. There is nothing mysterious about it. Starting value: "return.var=Hello world!" Starting statement: set "return.var=%return.var:!=!delayed!%" ! After percent expansion: set "return.var=Hello world!delayed!" ! After delayed expansion: set "return.v...
by dbenham
19 Apr 2018 18:00
Forum: DOS Batch Forum
Topic: exit function and preserve variable over endlocal barrier
Replies: 23
Views: 6353

Re: exit function and preserve variable over endlocal barrier

Hi Phil. The FOR /F loop to handle conditional escaping of ! and ^ is very clever, and the general concept of using 1 return variable instead of 2 is attractive. I did some tests, and your version does seem to work. But your code is inconsequentially longer, and doesn't seem to perform noticeably fa...
by dbenham
19 Apr 2018 15:36
Forum: DOS Batch Forum
Topic: Discussion about jeb's batch parsing rules on StackOverflow
Replies: 42
Views: 2670

Re: Discussion about jeb's batch parsing rules on StackOverflow

If delayedExpansion only takes effect shortly before the command is executed - it still resolves after the call but before the variable is resolved in double percent signs??? I'm not sure of the source of your confusion. Delayed expansion occurs in phase 5. Then the CALL is processed in phase 6, wh...