Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #8257
| Subject | Re: Looking for simple brute force solution |
|---|---|
| Newsgroups | comp.programming |
| References | <p2jobe$48s$1@news.albasani.net> <7c7ab511-b4db-47ac-8720-9005d345b271@googlegroups.com> <e03b1053-de0c-488b-b1f3-266755f14760@googlegroups.com> <p2kuq1$hjp$1@dont-email.me> |
| From | Richard Damon <Richard@Damon-Family.org> |
| Message-ID | <V4s3C.138032$4Z6.37846@fx41.iad> (permalink) |
| Organization | Forte - www.forteinc.com |
| Date | 2018-01-04 10:52 -0500 |
On 1/4/18 5:14 AM, root wrote:
> cost of materials 100.
> cost of assembly 45.
> cost of item 145.
> cost of shipping 11.
> total cost 156.
>
>
> In this list it is easy to see that we can take the
> first, second, and fourth items to account for the total
> cost. We have to ignore the intermediate term 145.
It sounds like your goal is to transform that list into something like;
100 Cost of materials
45 Cost of Assembly
145 Cost of Item
11 Cost of Shipping
156 Total Cost
Where you assign everything a 'level' (the grand sum being level 0) and
a given level is the sum of all the items 1 level higher between it and
the previous item of its level. It sounds like you also want to allow
some items to be negated for the sum, as credits/debits aren't carefully
indicated (which actually make the process much tougher). If at all
possible, I would try to understand the category names and assign a sign
to them, even if I had to try a couple possibilities, as only having
sums and no differences makes things much simpler.
Now if 'running sums' aren't actually right after the items they are the
sum for, then you probably need to brute force the solution.
IF you can try assigning signs to values to make it so you are always
adding, then you can work starting at the top of the list with the
second item (as the first can't be a running sum) and see if that item
is the sum of some number of items before it that aren't part of a
previously detected running sum, and if you find such a case, mark it as
a running sum, and push everything that went into it up a level (and
things that made them up a level too).
Note, this means that Cost of Shipping would only check if it was 'sum
of Cost of Item, and not include Cost of Assembly, as this is already
accounted for.
There is a chance that you may miss-detect some running sums if the
numbers aren't accurate or just happen to add up, and for a one-off,
just outputting that detection may be enough (or even do it by hand, as
the human brain is better at detecting suspicious conditions) for you to
manually adjust things.
If you really need to do it programmatically, you can add back tracking
where you systematically undo marking things as possible running sums
until you get to a suitable result.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-03 23:18 +0000
Re: Looking for simple brute force solution fir <profesor.fir@gmail.com> - 2018-01-03 16:49 -0800
Re: Looking for simple brute force solution fir <profesor.fir@gmail.com> - 2018-01-03 17:11 -0800
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 10:14 +0000
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-04 10:52 -0500
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 16:46 +0000
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-04 12:37 -0500
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-03 21:28 -0500
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 09:42 +0000
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-04 10:16 -0500
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 17:26 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 21:19 +0000
Re: Looking for simple brute force solution Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-01-04 02:29 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 09:55 +0000
Re: Looking for simple brute force solution Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-01-04 14:29 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 16:55 +0000
Re: Looking for simple brute force solution Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-01-04 20:36 +0000
Re: Looking for simple brute force solution Robert Wessel <robertwessel2@yahoo.com> - 2018-01-04 12:03 -0600
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 21:28 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 21:50 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-04 23:06 +0000
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-04 21:35 -0500
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-05 05:59 +0000
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-05 16:48 +0000
Re: Looking for simple brute force solution Richard Damon <Richard@Damon-Family.org> - 2018-01-06 08:50 -0500
Re: Looking for simple brute force solution root <NoEMail@home.org> - 2018-01-06 16:47 +0000
csiph-web