- I’m a devops engineer. I personally haven’t written code to do this, but it isn’t something that hasn’t been done before. Just take all possible combinations of candidates and use thier answers to compute the percentage that answered a given way for each question foreach combination. Do the same with the voting results. Then compare the % of the population to the % of each combination to get a set of differences for each combination. For small states you probably need to increase the number of seats to some minimum like 20 or more. For big states you will probably get a match with a tolerance of +/- 1%. For others you will have to iterate the tolerance up until you get a match.
If you want to get a better match, you could make the number of cadadites selected dynamic. And personally I support having a larger number as it reduces the power of anyone individual. Then the reps from the state can vote on any issue, and the states votes can be distributed to represnt the votes of the many representatives.
The idea is a group that actually represents the views of the people they represent istead of special interests.