Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How do i solve this fare splitting array problem? [closed]

$
0
0

Suppose, you and your whole group just finished the CSE220 class in BracU at 5PM. All of you are going to the Oppenheimer screening at Bashundhara. You know that now the buses will be the most congested, so you decide to go by DUBER. DUBER is a ride sharing app like UBER which can take at most two passengers. Each DUBER car has the same amount of fare but all of you have variable amounts of money with you. So now, you need to split up in groups of at most 2 so that the total amount of money of the group is equal to the fare of a DUBER car so that you can pay easily. Now given an array of the amount of money each of you have, write a program to find and print groups of maximum 2 that have a total amount of money exactly equal to the fare. If someone can not be grouped in such a way, create an array with them and print the ungrouped array.[Printing the group numbers is optional]Hint:You do not need to create arrays of the eligible groups; print them inside the function only.Group Member serial or group serial does not matter.You need to create an array of ungrouped members and print.

You need to solve it using python.

Sample Input:

findGroups( [120, 100, 150, 50, 30], 150 )

Sample Output:

Group 1 : 120, 30

Group 2 : 100, 50

Group 3 : 150

Sample Input:

findGroups ( [60, 150, 60, 30, 120, 30], 180 )

Sample Output

Group 1 : 60, 120

Group 2 : 30, 150

Ungrouped : 30 60

Note:This is the question but we aren't allowed to use any built in functions except len() and also ONLY USE NUMPY ARRAY. DO NOT USE LIST.YOU HAVE TO MENTION SIZE OF ARRAY WHILE INITIALIZATIONDO NOT USE DICTIONARY

I am trying to solve this since yesterday but can't get it done as it's not allowed to use any built in functions or list or even dictionary, can use numpy solely.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>