Question
Python Program: I Have a nested dictionary as follows which is the only thing i can input to my function; { 1: [1, 2, 3,
Python Program:
I Have a nested dictionary as follows which is the only thing i can input to my function;
{ 1: [1, 2, 3, 4], 2: [1, 3, 4, 2], 3: [2, 3, 1, 4], 4: [3, 1, 4, 2], }
so my function has to be able to perform the rules mentioned below without any manual help from me
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. The point here is each time my dictionary will be new so I wont know the length of each list neither the values of each list. So i want my program to be able to work on as many list as my dictionary has same goes for the values inside the list
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