+ 3

[challenge] Where to buy - Shopping at sololearn

Given a list of shops each with different products. Enter a product . Output the shops who have the product. This is no homework i am not a student (-; shops =[ {'walmart' :[soap,shoe,sweets]}, {'pcking':[keyboard, monitor,sweets]}, {'dodo':[soap,sweets]} ] user enters : soap output: walmart, dodo

21st Oct 2017, 11:55 AM
Oma Falk
Oma Falk - avatar
7 Antworten
+ 4
Please provide a sample input and output case, for proper understanding. What all do you need as input? Test cases, then number of shops? Or just the list of products and we determine the number ourselves? In output, do we need to display the shop number or is there some other format?
21st Oct 2017, 8:11 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
@kinshuk I added an example.
21st Oct 2017, 8:22 AM
Oma Falk
Oma Falk - avatar
+ 4
@Kinshuk yes that it is. Indeed the point is to find a good datastrucure. you can do it as simple or ellaborated as you want.
21st Oct 2017, 8:32 AM
Oma Falk
Oma Falk - avatar
+ 4
Here is my Python example with dictionary as data structure https://code.sololearn.com/cd8Ku62qOZFx
21st Oct 2017, 11:56 AM
Oma Falk
Oma Falk - avatar
+ 3
So, the data of the shop products is entered before compilation?
21st Oct 2017, 8:23 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
21st Oct 2017, 9:57 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
heres a self generating...shop...things tht can be bought....a random thing....corresponding shops to get it... ### EACH TIME U RUN IT...U GET ALL DIFFERENT OUTCOMES### https://code.sololearn.com/cR6Qg9O9AFtW/?ref=app
22nd Oct 2017, 5:39 AM
sayan chandra
sayan chandra - avatar