I have a problem.

For a project i'm working on i have 4 buttons to be read with only one analog in pin in an ESP32C3. for which i'm thinking on doing the usual voltage divider setup. BUT i would like it to have SOME semblance of multi touch by detecting when i click any two buttons at the same time and i know this is possible by some testing and theoretically.

for example, the usual multi-button voltage divider input works as such: you have a series of resistors and switches conecting each node between these resistors to the analog input. when you press a button the input will read the tension at that node as given by: V * (Req_bottom / (Req_top + Req_bottom), where Req_top and Req_bottom are the Equivalent resistance of the "top" and "bottom" resistors. BUT this also works if you press two switches for current will flow up to switch A the go through their shared connection at the input pin to switch b then on. in this case Req_top is from the first resistor on the VDD to the first switch and Req_bottom is from the second switch to ground

The problem is: if all values are the same, you can't differentiate the switch at the halfway point to the first and last switches together, and if all values are different the distance between values might be too small for the microcontroller to reliably measure.

I've written some code, a genetic algorithm and a brute force one with the following fitness evaluation:
```
def evaluategene(tres):
  out,dc = [],[]
  for a in range(1,len(tres)):
    for b in range(a,len(tres)):

      reqtop = sum([tres[j] for j in range(0,a)])
      reqbot = sum([tres[j] for j in range(b,len(tres))])

      adiv = reqbot/(reqtop+reqbot)
      out.append(adiv)
      dc.append(math.floor(4095* adiv))

  mindiff,maxdiff,meandiff = 10,0,0

  if len(dc) != len(set(dc)):
    return 0

  for a in range(0,len(tres)):
    for b in range(a+1,len(tres)):
      ldiff = abs(out[a]-out[b])
      meandiff += ldiff
      if ldiff<mindiff:
        mindiff = ldiff
      if ldiff>maxdiff:
        maxdiff = ldiff
  meandiff = meandiff/len(tres)
  orange = (max(out) - min(out))
  fit = (mindiff*2) + (0.3*(1-meandiff))+(0.3*orange)
  return fit
```

The next results are in the form of: 
teste de: [resistors] 
switch/switches 
Analogreadvalue percentvalue voltage value

teste de: [1, 9.1, 1, 1, 1]
s: 1
3782 0.9236641221374046 3.048091603053435 

s1: 1 s2: 2
3071 0.75 2.4749999999999996 

s1: 1 s2: 3
2730 0.6666666666666666 2.1999999999999997 

s1: 1 s2: 4
2047 0.5 1.65 

s: 2
937 0.22900763358778625 0.7557251908396946 

s1: 2 s2: 3
676 0.1652892561983471 0.5454545454545454 

s1: 2 s2: 4
368 0.0900900900900901 0.2972972972972973 

s: 3
625 0.15267175572519084 0.5038167938931297 

s1: 3 s2: 4
338 0.08264462809917356 0.2727272727272727 

s: 4
312 0.07633587786259542 0.25190839694656486 




teste de: [1.8, 9.1, 9.1, 9.1, 1]
s: 1
3850 0.9401993355481727 3.1026578073089697 

s1: 1 s2: 2
3744 0.9142857142857143 3.017142857142857 

s1: 1 s2: 3
3475 0.8487394957983193 2.8008403361344536 

s1: 1 s2: 4
1462 0.35714285714285715 1.1785714285714286 

s: 2
2612 0.6378737541528239 2.104983388704319 

s1: 2 s2: 3
1969 0.4809523809523809 1.587142857142857 

s1: 2 s2: 4
344 0.08403361344537814 0.27731092436974786 

s: 3
1374 0.33554817275747506 1.1073089700996677 

s1: 3 s2: 4
195 0.047619047619047616 0.1571428571428571 

s: 4
136 0.03322259136212624 0.1096345514950166 




teste de: [3.9, 9.1, 9.1, 1, 1]
s: 1
3432 0.8381742738589212 2.7659751037344398 

s1: 1 s2: 2
3030 0.74 2.4419999999999997 

s1: 1 s2: 3
1388 0.3389830508474576 1.11864406779661 

s1: 1 s2: 4
835 0.2040816326530612 0.6734693877551019 

s: 2
1886 0.4605809128630705 1.5199170124481327 

s1: 2 s2: 3
546 0.13333333333333333 0.43999999999999995 

s1: 2 s2: 4
292 0.07142857142857142 0.23571428571428568 

s: 3
339 0.08298755186721991 0.2738589211618257 

s1: 3 s2: 4
177 0.04329004329004329 0.14285714285714285 

s: 4
169 0.04149377593360996 0.13692946058091285