中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-24 20:49
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to find out which numbers in the text add up to a specified value
Printable Version  4,422 / 48
Floor1 ccwan Posted 2007-03-03 01:42
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
I encountered a problem at work and now post it on the forum to ask everyone to help solve it.

There is test.txt, the content is:



I want to find out which numbers among them add up to 171780
Requirement: If there are multiple combinations, list them in turn; each number in these 72 numbers in each combination can only be used once.
Floor2 slore Posted 2007-03-03 01:44
铂金会员 Posts 2,478 Credits 5,212
Floor3 ccwan Posted 2007-03-03 01:47
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
I don't care about efficiency, nor do I care whether to use third-party tools like awk, etc., as long as the requirement is met.
Floor4 oilio Posted 2007-03-03 02:16
高级用户 Posts 303 Credits 641
This is so troublesome with p, and I definitely can't figure it out at my current level, heh. Looking forward to experts' solutions!
Floor5 zh159 Posted 2007-03-03 02:36
金牌会员 Posts 1,467 Credits 3,687
Add the first data to the subsequent ones one by one, and discard the first number when reaching the second one...
Floor6 ccwan Posted 2007-03-03 04:38
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Bump up, don't let it sink.
Floor7 NaturalJ0 Posted 2007-03-03 04:56
银牌会员 Posts 533 Credits 1,181
Is it necessary to go through all combination methods one by one
Floor8 ccwan Posted 2007-03-03 05:00
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
It should be. To find all combinations, and finally display the combination whose value equals the desired value.
Floor9 NaturalJ0 Posted 2007-03-03 05:02
银牌会员 Posts 533 Credits 1,181
It's a very interesting question, but it seems the difficulty is not small either.
Floor10 zh159 Posted 2007-03-03 05:38
金牌会员 Posts 1,467 Credits 3,687
Refer to this and add "if "Calculation result" == "171780" " for judgment at an appropriate place

Find the sum of all different combinations of a column of numbers
Floor11 slore Posted 2007-03-03 05:54
铂金会员 Posts 2,478 Credits 5,212
Floor12 20080610 Posted 2007-03-03 05:55
初级用户 Posts 34 Credits 83
72 numbers permutation and combination?

I'm afraid it would take N hours to get the result.

Batch processing doesn't have this computing power yet
Floor13 ccwan Posted 2007-03-03 06:09
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
re zh159

BrothermeansIunderstandthatactuallytheforummoderatorsetupthatthreadpreciselyformypuzzle。Afterusingit,Ididn'tachievethegoalandputitaside。

Recently,Ineedtouseitagain,soImentionitagain,hopingtogetitsolved。
Floor14 zh159 Posted 2007-03-03 06:13
金牌会员 Posts 1,467 Credits 3,687
I tried that, but nothing came out after a long time. I'm thinking about using VBS or something like that.
Floor15 NaturalJ0 Posted 2007-03-03 06:18
银牌会员 Posts 533 Credits 1,181
It seems that a lot of recursive layers need to be nested.
1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023