Search HoldMyTwist

Browse all posts

Episode 47

Two Lists, One Lantern Crew

Duck is comparing two training lists to see who should get a lantern badge. If you see the same name more than once, that's not a new member.

Episodes

Computing Basics

    Two training boards are outside the monitor. On the diagram: left list: ADA,BO,BO,CY right list: BO,CY,DEE. Empty crew.
    Duck is happily trying to spill out 7 paper tickets into a waiting basket. Robot prevents this from becoming an accepted crew before the tickets spill. Just a proposed pile(not accepted result).
    Robot points at the ADA over here on the left list and not on the right. Duck freezes with ADA ticket next to the empty harness.
    Duck is holding up 2 coral tickets and 1 aqua ticket next to an empty basket. Diagram has BO listed twice on the left and once on the right. Waiting on crew result.
    Robot lifts a single finger; Duck drops a single gold badge into an empty basket. This diagram allows BO once (because it's in both lists). BO is shown in both of the entries on the left (the source list).
    Duck has coral source ticket (by the basket). There's only one gold badge left in the basket. There is no second badge.
    Duck has another gold badge it is ready to put in the basket with the first badge. In the diagram CY can be used once with BO as it also shows up on both lists. So we have two different helpers in the crew now.
    The BOTH crew is still BO and CY.
    Duck combines duplicate BO tickets, while keeping the original evidence intact, into a single named slot.
    Duck is holding ribbon between accepted badge (2 of them). Robot is pointing to the teaching board. BO and CY are common names for both sets - from diagram.
    Duck flips an independent rule card. The comparison tray has 4 different badges. The original 2 badges remain in their basket. The diagram indicates that the EITHER part is the union (ADA, BO, CY, DEE). The BOTH crew is still BO and CY.
    Duck goes back to BOTH rule, holding two lanterns with BO and CY on them.
    Duck is studying new practice boards. Output tray is covered with cloth. Diagram shows left list AN, EL, EL and right list EL, IV, AN. No match or accepted name is disclosed.
    Duck opens up wings on either side of the practice boards. The output tray is covered. On the left, the diagram indicates AN, EL, EL. On the right, EL, IV, AN. No names marked as accepted.
    Duck opens up lid, exposing 2 badges. Diagram shows AN and EL are once accepted crew. There is no extra helper even with repeated EL in left list.
    Duck puts 2 badges on 2 practice lanterns. Robot looks at a 2-row clipboard. Diagram shows 1 crew place for AN. 1 crew place for EL. Source tickets are not combined with the accepted crew.

    Episode transcript

    Too many tickets

    Two training boards are outside the monitor. On the diagram: left list: ADA,BO,BO,CY right list: BO,CY,DEE. Empty crew.

    Diagram values: L: ADA BO BO CY; R: BO CY DEE; RULE: BOTH

    Duck: I need 1 lantern crew. All helpers need to be on both training lists.

    Duck is happily trying to spill out 7 paper tickets into a waiting basket. Robot prevents this from becoming an accepted crew before the tickets spill. Just a proposed pile(not accepted result).

    Diagram values: PROPOSED: ADA BO BO CY BO CY DEE; NOT ACCEPTED

    Duck: I'll just invite each one. Seven helpers!

    Robot points at the ADA over here on the left list and not on the right. Duck freezes with ADA ticket next to the empty harness.

    Diagram values: ADA: L YES R NO; BOTH: NO

    Robot: Ada is in a single list. Does that satisfy your rule?

    Duck is holding up 2 coral tickets and 1 aqua ticket next to an empty basket. Diagram has BO listed twice on the left and once on the right. Waiting on crew result.

    Diagram values: BO: L YES R YES; L HAS BO TWICE; BO'S CREW SEATS: ?

    Duck: BO is in both, however, BO has 2 tickets on the left. So, how many crew seats are there?

    One place per name

    Robot lifts a single finger; Duck drops a single gold badge into an empty basket. This diagram allows BO once (because it's in both lists). BO is shown in both of the entries on the left (the source list).

    Diagram values: ACCEPTED: BO; ONE BADGE PER NAME

    Robot: BO is in both. Gets 1 crew spot.

    Duck has coral source ticket (by the basket). There's only one gold badge left in the basket. There is no second badge.

    Diagram values: ACCEPTED: BO; DUPLICATE BO: NO EXTRA BADGE

    Duck: The other bo ticket is that same helper. It doesn't add a crew place.

    Duck has another gold badge it is ready to put in the basket with the first badge. In the diagram CY can be used once with BO as it also shows up on both lists. So we have two different helpers in the crew now.

    Diagram values: CY: L YES R YES; ACCEPTED: BO CY

    Duck: Cy is also on both the lists. Welcome aboard.

    The BOTH crew is still BO and CY.

    Diagram values: DEE: L NO R YES; BOTH: BO CY

    Robot: Dee is right side only, right? So crew is still 2.

    Both or either

    Duck combines duplicate BO tickets, while keeping the original evidence intact, into a single named slot.

    Diagram values: SET L: ADA BO CY; SET R: BO CY DEE

    Duck: I can get rid of repeating names before I compare the lists.

    Duck is holding ribbon between accepted badge (2 of them). Robot is pointing to the teaching board. BO and CY are common names for both sets - from diagram.

    Diagram values: L INTERSECTION R: BO CY; BOTH

    Robot: The intersection includes those names common to both sets.

    Duck flips an independent rule card. The comparison tray has 4 different badges. The original 2 badges remain in their basket. The diagram indicates that the EITHER part is the union (ADA, BO, CY, DEE). The BOTH crew is still BO and CY.

    Diagram values: EITHER / UNION: ADA BO CY DEE; BOTH / INTERSECTION: BO CY

    Duck: If either is enough, it can include ADA and DEE.

    Duck goes back to BOTH rule, holding two lanterns with BO and CY on them.

    Diagram values: CHOSEN RULE: BOTH; CREW: BO CY

    Duck: We need both on the lantern job. Not 7 tickets, 2 helpers.

    A fresh crew

    Duck is studying new practice boards. Output tray is covered with cloth. Diagram shows left list AN, EL, EL and right list EL, IV, AN. No match or accepted name is disclosed.

    Diagram values: NEW L: AN EL EL; NEW R: EL IV AN; RULE: BOTH

    Robot: Try these new lists. Doesn't matter if you have the same name multiple times. It still gets a single spot.

    Duck opens up wings on either side of the practice boards. The output tray is covered. On the left, the diagram indicates AN, EL, EL. On the right, EL, IV, AN. No names marked as accepted.

    Diagram values: BOTH LISTS REQUIRED; ONE PLACE PER NAME

    Duck: What are all the unique names you can put on this crew? Keep in mind they need to be on both lists.

    Duck opens up lid, exposing 2 badges. Diagram shows AN and EL are once accepted crew. There is no extra helper even with repeated EL in left list.

    Diagram values: ANSWER: AN EL; IV: L NO R YES

    Robot: AN and EL in both columns, IV only in the right.

    Duck puts 2 badges on 2 practice lanterns. Robot looks at a 2-row clipboard. Diagram shows 1 crew place for AN. 1 crew place for EL. Source tickets are not combined with the accepted crew.

    Diagram values: BOTH: AN EL; DUPLICATES DO NOT ADD MEMBERS

    Duck: I'll tally the number of helpers by name, not by pieces of paper.

    The lesson

    A set has distinct elements in it. If you see the same name more than once, that's not a new member. The intersection shows what names are in both sets. Here's the left list: ADA, BO, BO, CY. Here's the right list: BO, CY, DEE. The intersection of the two is: BO, CY. But if you want to know which names are in either list, you're asking about the union. Here's the union: ADA, BO, CY, DEE. Each name is a (case sensitive exact token) of a pretend helper. It's not that more tickets mean more people. We're arbitrarily picking an order for this story. The sets don't guarantee any order.

    Try it

    New left list = KIT KIT MO. Right list = REN SAI. What are the different names that appear in both lists? What are the different names that appear in at least one list? How does the duplication of KIT affect the result? Explain.

    Answer

    There is no element common between them. So the intersection is empty. The union includes KIT, MO, REN, SAI (each only once). Repeating KIT on left doesn't mean it's on the right, nor that it is adding a new unique element.

    Sources

    Python built-in types: set and frozenset (opens in a new tab)