Ready to begin
Choose Next step to follow the actual course records.
In this lecture, a loyal customer has at least two observed bills, all from the same shop. One visit is too little evidence for this definition. Several visits to different shops fail the definition. We describe only the bills in our dataset.

Trace the records, compare the methods and watch what changes. Back and Reset let you try again.
Ready
Choose Next step to follow the actual course records.
Start with Next step. Predict what changes before reading the explanation.
Group the bills by Customer
for each customer bin B:
if number of bills in B < 2:
report "Too little evidence"
else:
FirstShop = the shop on the first bill
SameShop = true
for each bill X in B:
if X.Store != FirstShop:
SameShop = false
if SameShop:
report "Loyal in these observations"
else:
report "Uses multiple shops"We do not need to compare every bill with every other bill. Within each customer bin, compare each shop name with one reference shop. The inner scans together inspect every bill once, even though the code has a loop over bins and a loop over their contents. Work depends on how often records are visited, not only on counting WHILE keywords.
There are 16 customer bins: 9 single-visit customers, 6 customers who visited multiple shops, and Neeraja, the only customer with repeated bills from one shop. Srivatsan has 4 bills from 2 shops; Ahmed has 4 bills from 2 shops. Seeing a different shop proves a customer fails, but seeing only the first two same-shop bills does not yet prove they pass.
The lecture also tries collecting one customer’s bills while scanning the remaining pile. Removing the whole completed customer group prevents repeating that customer’s task. However, repeatedly searching for the next customer’s bills can still revisit other bills. Grouping all customers first avoids those repeated full searches when bins can be located efficiently.
Four bills for a customer: SV Stores, SV Stores, SV Stores, Sun General. Loyal?
No. The last bill breaks the “all bills from one shop” condition. Never return true after checking only the first few matching bills.
Why group by customer instead of shop?
The question asks about one customer’s behaviour across shops. A shop bin mixes customers and does not by itself tell whether a particular customer also visited another shop.
Does “loyal in these bills” mean the person never uses another shop?
No. It is a conclusion about the supplied observations under the stated rule, not a claim about all their shopping.