Question: Write a Scheme program to solve the problem described above. Define a function (best_candidates Voter Candidates) which takes two parameters, Voter and Candidates . Voter

Write a Scheme program to solve the problem described above. Define a function(best_candidates Voter Candidates) which takes two parameters, Voter and Candidates. Voter is a list of ten integers (1, 0, or -1) indicating the voter's answers. Candidates is a list of lists; each inner list contains a name, followed by ten integers (1, 0, or -1) indicating the candidate's answers. You are guaranteed that there will be at least one candidate in the Candidates list. The function should return a list of the names of the candidates with the best agreement score.

You may assume that the Voter and Candidates lists will be in the correct format when the function is called; you do not have to error-check for a non-list or an incorrectly formed list. In your program, you may write and call any additional functions that are helpful in the computation.

Examples:

(best_candidates '( 0 0 0 1 1 1 -1 -1 -1 1) '((Adams 1111111111)

(Grant -1-1-1-1-1-1-1-1-1-1) (Polk 1-1 1-1 1-1 1-1 1-1) (Jackson 1 0 1 0 1 0 1 0 1 0) (Taft 0-1 0-1 0-1 0-1 0-1) (Ford 1111000000) (Madison 0 0 0 1 -1 0 0 -1 1 1)))

should return (Adams Ford Madison), and

(best_candidates '( -1-1-1-1-1 1 1 1 1 1) '((Wilson -1 -1 -1 -1 -1 -1 -1 -1 -1 -1)

(Taylor -1 -1 -1 1 1 1 1 1 1 1) (Monroe-1-1-1 1 1-1-1 1 1 1)))

should return (Taylor).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!