maths help

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello, i'm stuck with a maths question i hope you can help with.

    Say to be 100% (A) needs = 5 of (B), 12 of (C), 2 of (D).

    5+12+2 = 19

    But (A) currently has say 1(B), 8 (C), 1(D).

    so i know it has 1+8+1=10 , which is 10/19*100 = 52.6% of total (A) needs to be whole.

    Here is the problem i can't get my head around.

    (A) might have more of one or all of (B),(C) or (D) then it needs.

    for example 12(B) instead, but it only needs 5(B).

    I want to make it so the value can be greater than 100%, but doing 12+8+1 = 21/12*100 = 110% is incorrect as it still does not have enough of (C) or (D) it needs.

    Thank you for your help.

  • I want to make it so the value can be greater than 100%, but doing 12+8+1 = 21/12*100 = 110% is incorrect as it still does not have enough of (C) or (D) it needs.

    How much of (C) and (D) does (A) need to be 'legal' ?

    Is it minimum 5 of (B) AND minimum 12 of (C) AND minimum 2 of (D) ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • yes thats correct.

  • Thanks for the example, and taking the time to help, but i'm not sure what it does.

    I'm really look for the maths formula to give me the correct percentage. I'm probably trying to cram too much into one value. I'll have to try a new approach

    Thanks.

  • 5+12+2 = 19 .... stands for 100

    B = 5 = (100/19) * 5 = 26.31%

    C =12 = (100/19) * 12 = 63.15%

    D= 2 = (100/19) * 2 = 10.52 %

    26.31% + 63.15% + 10.52 % = 100%

    But, as soon B is higher then 26.31% it can not add to the total amount no more

    So

    AMax = 19

    MiniB = 5

    MiniC = 12

    MiniD = 2

    B = current value for B

    C = current value for C

    D = current value for D

    MaxB = ( (100/AMax ) * ( min(MiniB, B ))

    MaxC = ( (100/AMax ) * ( min(MiniC, C ))

    MaxD = ( (100/AMax ) * ( min(MiniD, D ))

    So

    A = MaxB + MaxC + MaxD

    Example

    5+12+2 = 19 .... stands for 100

    How many % is 12+8+1?

    Well

    AMax = 19

    MiniB = 5

    MiniC = 12

    MiniD = 2

    B = 12

    C = 8

    D = 1

    min(MiniB, B ) = 5

    min(MiniC, C ) = 8

    min(MiniD, D ) = 1

    MaxB = ( (100/19) * ( 5 ))

    MaxC = ( (100/19) * ( 8 ))

    MaxD = ( (100/19) * ( 1 ))

    A = ( (100/19) * ( 5 )) + ( (100/19) * ( 8 )) + ( (100/19) * ( 1 )) = 73.6842105263 %

    C = ( (100/19) * ( 12 )) - ( (100/19) * ( 8 )) = 21.0526315789% short

    D = ( (100/19) * ( 2 )) - ( (100/19) * ( 1 )) = 5.26315789474% short

    73.6842105263% + 21.0526315789% + 5.26315789474% = 100% (with a floating point error)

  • Thanks so much for your help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)