Jump to content

random trigger, with decreasing threshold, "relaxed" to be sparse in time and space

Recommended Posts

Posted (edited)

Let's say, there is a class with 10 children and teacher asks 10 questions with decreasing difficulty. Kids are in a row.

Please, is there any common attitude to make the raised hands sparse in time and space? The total count of raised hands is not crucial. The purpose is just to make it visually appealing.

- first question is the hardest, 1 kid raises hand
- second question, 2 or 3 kids, not the kid from first question, hands are "far away" from each other
- third question, 3 kids who did not answer before, and again gaps between kids
- tenth question, everybody raises hand
- at the end, each kid raised hand circa 5 times

Edited by ikoon

Share this post

Link to post
Share on other sites

The best (and simplest) method I could think of is a brute force:

- generate a number of solutions, with different seed
- for each solution, calculate the "sparsity" with weights (the gap between the answers is more important then the gap between kids)
- choose the solution with the highest sparsity

There are not many kids and questions. I think it is going to be fast. Still, I am curious, if it is a common scripting problem.

Share this post

Link to post
Share on other sites

Hi. Here is the crappy function I could think of. It returns list of lists with questions answered by each kid. First question is answered by one kid, last question is answered by everyone.

Kids will get some kind of brain penalty for answers, so they won't know the answer next time. I found if I force this strictly, I get visible switching between two "teams" in the middle.



So, randomized sampling is taking precedence after a few questions:


Function returns after everyone answered about X times, 5 for your case.

from random import seed, shuffle, randint
from numpy import median


def quiz(num_kids, median_answers, randomness=0.8):
    # Empty lists accumulating answered questions per kid.
    kids = [[] for _ in range(num_kids)]

    # Ask until median amount of answers per kid is met.
    i = 0
    while True:
        # Randomize pending kids to avoid halves switching pattern.
        slice = int(len(kids) * randomness)
        a = kids[:slice]
        b = kids[slice:]
        kids = a + b  # Comment this to see problem.

        # Score approximately i answers.
        pick = randint(max(1, i), min(i + 1, num_kids))
        clever = kids[:pick]
        dumb = kids[pick:]
        clever = [scores + [i] for scores in clever]

        # Extra shuffle for cases where randomness is near 0.

        kids = dumb + clever

        # Finish if kids answered enough questions.
        if median([len(s) for s in kids]) >= median_answers:
            # Complete last row.
            kids = [s + [i] if i not in s else s for s in kids]
            return kids, i

        i += 1

Close neighbors can still answer simultaneously, though.



  • Thanks 1

Share this post

Link to post
Share on other sites

Hi F1! This is great! Thank you very much!

It will take me a while to understand it all, but I really like the solution (add until median per kid is met). This is great idea. Also the shuffle ... I never used that, also the array output is great for me. I can build on that, thank you very very much again!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now