Urban75 Home About Offline BrixtonBuzz Contact

Is anyone good at maths?

miss direct said:
Ok well they have given me another one to do now, would you like to give it a go? :)


OK, but it might take a while as it's my boss's last today so she keeps giving me work :mad:
 
Ok this time X is 2282.00

and there are four numbers that equal x


389.10
259.45
909.46
795.63
793.12
599.25
273.78
96.93
38.18
1199.44
1199.44
15.36
167.43
334.87
167.43
1045.75
352.00
522.88
650.00
940.00
167.43
2256.00
466.95
1527.50
518.81
161.56
793.12
94.00
2702.50
260.76
3.33
1410.00
18.31
18.13
51.80
2256.00
 
Mr Retro said:
How convenient

:D


It's true. I have a full side of a tape to type and now she's just come down with a big ring binder and she wants ALL the contents copied :p

So I'm off to have fights with the copier


Shall get back to OP at some stage with the answer to her question
 
Iemanja said:
You'd have to do the pair addition twice because she wants 6 numbers to add up to x. It's doable but it'll take a while - I don't have time... also I can't remember how to set absolute values on spreadsheets... I bet the accountants of urban would be able to sold this!

Grrr, seems I can't attach xml files!!! I would have, as I've got the pair additions done, for some reason I can attach *.doc but not*.xml

Oops I thought it was 3 for some reason. 6 is considerably more difficult.
 
To those asking how he did it:

He wrote a piece of code. The number of combinations of 6 choices from 23 numbers (without replacement) is:

23×22×21×...×2×1
________________________________
(6×5×...×2×1)×(17×16×...×2×1)

= 100,947

This may sound a lot to you. But a couple of lines of code will plough through those 100k combinations quick as you like. All he has to do is run the code until it finds the combination that gives the right result. (On average, this will actually only take about 50k combinations, which should be able to be run in a matter of seconds.)

To do it by hand: there are some tricks that will help you short-cut some of the combinations, but it isn't a particularly tractable problem. In other words, there isn't a nice, easy way to get the quick answer. You need some educated guessing.
 
I think this would proberbly work. It's been 20 years since I wrote any but for anyone who remembers ZX Basic?

5 DIM N(23)
10 LET N(1)= 857.75
20 LET N(2)= 987.00
30 LET N(3)= 1410.00
(and so on, there was a quicker way of doing this but I've forgotten)......
230 LET N(23)= 910.63

400 FOR A= 1 TO 23
410 FOR B= 1 TO 23
420 FOR C= 1 TO 23
430 FOR D= 1 TO 23
440 FOR E= 1 TO 23
450 FOR F= 1 TO 23
460 IF N(A)+N(B)+N(C)+N(D)+N(E)+N(F)= 5369.58 THEN PRINT A: PRINT B : PRINT C: PRINT D: PRINT E: PRINT F: PRINT
470 NEXT F
480 NEXT E
490 NEXT D
500 NEXT C
510 NEXT B
520 NEXT A

Pretty brute force, and goes through every possible combination including those using numbers more than once, but I reckon it would work. If I hadn't throw my Spectrum out last weekend I'd try it :D
 
kabbes said:
Awesome. Who needs VBA when you have Speccy code?


LOL, It's amazing what you remember. I haven't got time now but if I can find an emulator sometime I might try it. I wonder how long a speccy would take to find the first solution .... you obviously wouldn't need to run the program to the end, although it would take awhile if the answer was n(18)+ n(19)+n(20)+n(21)+n(22)+n(23).(the last 6 numbers on the list)

Thinking about it you could proberbly shorten those loops to get rid of some of the redudant combinations.

a = 1 to 18
b= 2 to 19
c= 3 to 20
d= 4 to 21
e= 5 to 22
f= 6 to 23

And I really must go!
 
Well I've got the code churning on a zx81 emulator.
http://www.vavasour.ca/jeff/ts1000/

Been running for just over a hour and nothing yet!

Even using the shortened loops

A=1 TO 18 B=2 TO 19 C=3 TO 20
D=4 TO 21 E= 5 TO 22 F=6 TO 23

it's still checking an awful lot of redundant combinations


I'd be facinated to know how bonfirelight did it- presumably there is some way to only check the 100,947 which are unique- i.e. not the anagram of another combination and don't use any numbers more than once.

I expect VBA is a bit more advanced than ZX basic! :D
 
Minnie_the_Minx said:
:rolleyes:

You can't do that. It's a piece of piss. Honestly, education nowadays :rolleyes:


Are you being serious ?

I wouldn't know where to start with working that out tbh !


:rolleyes:
 
As above, you can write a script/code in VBA - if you have Excel open a worksheet hit Alt+F11, that's where you'd write the code.
 
TBH, it's not hard:

You have Microsoft Excel on your computer - it's part of Microsoft Office: Yes/No

If you don't, move along.
If you do: Open it, open any worksheet, press Alt+F11.
 
Back
Top Bottom