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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started