|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『楼 主』:
[求助]如何求出文本中哪些数相加等于指定的值
使用 LLM 解释/回答一下
我在工作中遇到一个难题,现在发到论坛上,请大家帮忙解决。
现有test.txt,内容为:
4816
4776
4498
4616
4948
4684
4710
5266
4760
5168
4770
5134
5076
4784
5174
4732
4782
4746
4730
5224
5164
4742
4724
4730
4762
4162
4188
4830
4942
4072
4270
4520
4808
5130
4272
4262
4238
4240
4828
4168
4754
4720
4896
4824
5206
4322
3800
4826
4632
5104
5134
4838
3858
5008
4828
5234
4324
5282
5348
5150
4724
4682
4720
5218
4744
4742
4760
5194
4792
4712
4754
4704
我想求出其中哪些数相加结果等于171780
要求:如果有多种组合,依次列出;这72个数中每个数在每种组合中只能用一次。
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:
4816
4776
4498
4616
4948
4684
4710
5266
4760
5168
4770
5134
5076
4784
5174
4732
4782
4746
4730
5224
5164
4742
4724
4730
4762
4162
4188
4830
4942
4072
4270
4520
4808
5130
4272
4262
4238
4240
4828
4168
4754
4720
4896
4824
5206
4322
3800
4826
4632
5104
5134
4838
3858
5008
4828
5234
4324
5282
5348
5150
4724
4682
4720
5218
4744
4742
4760
5194
4792
4712
4754
4704
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.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-3-3 01:42 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
|
2007-3-3 01:44 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
我不求效率高,也不在乎是否使用第三方工具,如awk等,只要达到要求就行。
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.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-3-3 01:47 |
|
|
oilio
高级用户
    前进者
积分 641
发帖 303
注册 2007-1-10
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
这个要用p多麻烦啊,而且我的水平现在肯定是想不出来的,呵呵。期待高手解答!
This is so troublesome with p, and I definitely can't figure it out at my current level, heh. Looking forward to experts' solutions!
|

我相信总有一天,总会遇到一个人可以相濡以沫、相吻以湿! |
|
2007-3-3 02:16 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
第一个数据和后面的逐一相加,到第二个时抛弃第一个数......
Add the first data to the subsequent ones one by one, and discard the first number when reaching the second one...
|
|
2007-3-3 02:36 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
顶起,莫沉了。
Bump up, don't let it sink.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-3-3 04:38 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
是不是得把所有组合方式都过一遍
Is it necessary to go through all combination methods one by one
|
|
2007-3-3 04:56 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
应该是的。
要求出所有的组合,最后显示=所求值的组合。
It should be. To find all combinations, and finally display the combination whose value equals the desired value.
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-3-3 05:00 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
很有意思的一题啊,不过难度好像也不小。
It's a very interesting question, but it seems the difficulty is not small either.
|
|
2007-3-3 05:02 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
|
2007-3-3 05:38 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
|
2007-3-3 05:54 |
|
|
20080610
初级用户
 
积分 83
发帖 34
注册 2006-11-24
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
72个数排列组合?
恐怕需要N个小时才能出结果.
批处理还没有到这个运算能力
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
|
|
2007-3-3 05:55 |
|
|
ccwan
金牌会员
     
积分 2725
发帖 1160
注册 2006-9-23 来自 河北廊坊
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
re zh159
兄的意思我明白,其实版主那道题本就是为我的疑难而立的,我经过使用之后,没有达到目的,搁置了起来。
近日又要用到了,所以再次提及,希望可以得到解决。
re zh159
BrothermeansIunderstandthatactuallytheforummoderatorsetupthatthreadpreciselyformypuzzle。Afterusingit,Ididn'tachievethegoalandputitaside。
Recently,Ineedtouseitagain,soImentionitagain,hopingtogetitsolved。
|

三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。 |
|
2007-3-3 06:09 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
我用那个试了,半天没出来,考虑vbs之类的吧
I tried that, but nothing came out after a long time. I'm thinking about using VBS or something like that.
|
|
2007-3-3 06:13 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
好像要套很多层的递归啊。
It seems that a lot of recursive layers need to be nested.
|
|
2007-3-3 06:18 |
|