Alibaba Treasure Selection
Challenge: In the Arabian Nights, Alibaba accidentally found a cave where 40 thieves had been hiding their loot when traveling with his donkey. He decided to take as much as possible to share with his family and friends. But the donkey can only carry up to 25 kg. Each item has a label indicating its value and weight. In this activity, you will help Alibaba decide which items should be selected to take the maximum value of items, and code the VR Robot to drive around the Art Canvas +playground to “click” the Select buttons under the items to indicate the selected items. To click a Select button, drive to it and use the Pen to fill the area with green.
Item | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|
Weight | 8 | 9 | 4 | 10 | 3 | 6 |
Value | 20 | 18 | 3 | 12 | 8 | 10 |
- Choose and download the Alibaba Treasure Selection sheet as a PNG file from this Google slideshow.
- Select the Art Canvas+ Playground and upload the Alibaba Treasure Selection Sheet.
- Determine the items to be selected with a total weight of up to 25 kg.
- Code the VR Robot to color the Select button under each of the selected items.
- Use [Drive for] and [Turn for] blocks to drive the VR Robot into the Select button under the item. Use the [Fill area with color] block to fill the area with green.
- Use variables to store and track the total value of the selected items and the total weight of the selected items.
- Add a note in your project to explain why you choose these items.
- Use the [print] block to print the variable values to the Print Console to report the total value of the selected items and the total weight of the selected items.
- Play the Alibaba Treasure Selection activity with a friend. The highest value wins!
Helpful Hints
- For help with storing data in the project, please select the “TUTORIALS” button in VEXcode VR and choose the Storing Data Tutorial.
- For more information about the name rules for variables in VEXcode VR, please see this article.
Use the set block from the Variables category to set the value of the variable.
Matching Python command:
totalValue = 0