// Numbas version: exam_results_page_options {"name": "Count the number of occurrences (frequencies) of each distinct element in a list", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Count the number of occurrences (frequencies) of each distinct element in a list", "tags": [], "metadata": {"description": "

This question randomly generates a list of 100 items, each chosen from a list of strings.

\n

It then computes the number of occurrences of each distinct item in the list. The statement shows the frequencies in a table.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

{table(frequencies,[\"Item\",\"Frequency\"])}

", "advice": "", "rulesets": {}, "extensions": [], "variables": {"collection": {"name": "collection", "group": "Ungrouped variables", "definition": "repeat(random(\"pizza\",\"burger\",\"curry\",\"sandwich\"),100)", "description": "", "templateType": "anything"}, "frequencies": {"name": "frequencies", "group": "Ungrouped variables", "definition": "map(\n [item,len(filter(x=item,x,collection))],item,set(collection)\n)", "description": "

A list of pairs of the form `[item, frequency]`, listing the number of occurrences of each distinct item in `collection`.