0
HD = 4
D = 3
C = 2
P = 1
N = 0

GPA = x/n
where n is the number of variables

x = a + b + c + d 
where 
a is variable 1 which can equal a number between 4(HD) and 0(N)
b is variable 2 which can equal a number between 4(HD) and 0(N)
c is variable 3 which can equal a number between 4(HD) and 0(N)
d is variable 4 which can equal a number between 4(HD) and 0(N)

With that in mind, how would I work out the possible combinations of variables that could = x?

Example: 1. Input = 3.75, output = (HD, HD, HD, D) 2. Input = 2.00, output = (HD, N, HD, N), (C, C, C, C), etc

By the way, this isn't for an assignment or anything - I just saw a lot of people asking what their grades could be after my university released student's GPA before grades and I've been brain storming how to work out the permutations. I'm an arts student with an interest in maths and programming so go easy.

user1395909
  • 157
  • 1
  • 3
  • 12

2 Answers2

1

The easiest way i can think of, is multiplying the GPA by the number of subjects (in your example case 4) and then finding the possible combinations to get to that sum. You can use the code in this link to find all the possible combinations.

In your first example = 3.75*4 = 15. In your second example = 2*4 =8.

Community
  • 1
  • 1
hassan arafat
  • 657
  • 5
  • 15
1

A given x is achieved in n terms from all the sums of x-k in n-1 terms, by adding k.

So you get the recurrence

C(x;n) = C(x-0;n-1) + C(x-1;n-1) + C(x-2;n-1) + C(x-3;n-1) + C(x-4;n-1),

with C(x;n)=0 for x<0 and x>4n.

The first values are (rows for increasing n, x horizontally):

1, 1, 1, 1, 1
1, 2, 3, 4, 5, 4, 3, 2, 1
1, 3, 6, 10, 15, 18, 19, 18, 15, 10, 6, 3, 1
1, 4, 10, 20, 35, 52, 68, 80, 85, 80, 68, 52, 35, 20, 10, 4, 1
1, 5, 15, 35, 70, 121, 185, 255, 320, 365, 381, 365, 320, 255, 185, 121, 70, 35, 15, 5, 1

In other words, one row is computed from the previous by a convolution with the kernel [1, 1, 1, 1, 1], and the sum of a row is 5^n.

Interestingly, the histograms converge to a Gaussian curve.

enter image description here

The recursive implementation of the combination themselves should be obvious from the recurrence.