Mailing List Archive: 49091 messages

[REBOL] Re: OT: Competition - Is this solvable

From: Tom::Conlin::gmail::com at: 25-Nov-2007 12:27

```
Robert M. M=FCnch wrote:
> On Fri, 23 Nov 2007 17:57:37 +0100, Sunanda <dhsunanda-gmail.com> wrote:
>
>> No time to write the code (so my hand-waving solution is
>> untested), but I'd say:
>>
>> You are clearly 8800 short of the desired target:
>
> Hi, that's right.
>
>>     t: 41695.83
>>     s: 6594,14 + 981,75 + 8747,39 + 1457,90 + 15114,65 + 8800
>>     == 41695.83
>>
>> So, for *minimal* typos, you need to change an 0-->8 or an 1-->9
>> in the hundreds column and thousands column of one or two of the
>> given numbers. That will affect the minimum digits: ie just two.
>>
>> There are several ways to do that, easily eyeballable, eg:
>>     s: 6594,14 +  981,75 + 8747,39 + 9457,90 + 15914,65 + 0000
>>     s: 6594,14 + 8981,75 + 8747,39 + 1457,90 + 15914,65 + 0000
>
> Here is the typo that caused the error:
>
> 6594,14+9781,75+8747,39+1457,9+15114,65
> ans = 41695,83
>
> 9781,75 - 981,75
> ans = 8800
>
> It was an additional 7 inserted into the 981,75 value.
>
>> One instance changes two 1's to 9s. The other adds a leading 8 to
>> one of the givens.
>
> I think one approach might be to calculate the offset and than look at
>
> each number step by step to see what needs to be changed to get the offs
> et
>
> as difference. The assumption in this case is, that there is only one ty
> po.
>
>> If that had not worked, it gets more interesting: at which point,
>> I'm off out :-)
>
> come on ;-)
>
>> But, following Tom's comment, perhaps take a look
>> at simetrics.r in the REBOL.org Script library -- it has
>> algorithms that can help rate how close strings are to each other.
>
>
>
> which is not available in our case. Robert

in biology things not exactly the same are compared all the time
say DNA and protein. this requires translation according to biological
rules just as your missing reference strings require a rearrangement
according to arithmetic rules.

looking for a single mutation/ single error in one of the givens

given + delta = reference

where delta is derived from the 'sum' which is your overall reference
for this problem.

sum: 41695.83
val: [6594.14  981.75  8747.39 1457.90  15114.65]
valsum: 0
forall val [valsum: valsum + first val]
print valsum
print delta: sum - valsum
forall val[
candidate: round/to (delta + first val) .01
edit: difference form first val form candidate
probe  reduce[first val candidate edit]
]

using a better discriminator than difference will get you a better edit
but the idea is the same.

if it is not a single edit then it grows quickly but the process is the
same. distribute the delta over all possible combinations and look for
cheap edits.
```