Question
Python Program: I Have a nested dictionary as follows; { 1: [1, 2, 3, 4], 2: [1, 3, 4, 2], 3: [2, 3, 1, 4],
Python Program:
I Have a nested dictionary as follows;
{ 1: [1, 2, 3, 4], 2: [1, 3, 4, 2], 3: [2, 3, 1, 4], 4: [3, 1, 4, 2], }
I need to create a function that removes number from my list based on the rule, which number appears least frequently in the first position, it will work in rounds removing those numbers. So for example here, the first round we remove 4 as it never appeared on the lists as the first position. we are left with
{ 1: [1, 2, 3] 2: [1, 3, 2] 3: [2, 3, 1,] 4: [3, 1, 2] }
replacing 4 with 2 as it also had last place. This keeps on going until we have 1 number left in each list, then we see which one is the winner, meaning the one that appeared in the first position most frequently.
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