+ 4
Randomize script
Hey guys, I'm interested in writing a C#, Python or Javascript script in which we enter names of students and specify how many groups we need to form. The script should randomize the names and produce the required output. How do i go about it? Please help
6 Réponses
+ 6
How I would do it:
1.Make a input and a button in which you write names and then ENTER to register the name.
1.5Make an input in which you write the number of groups you want, maybe?
2.After you press enter, the string from the input is written at the end of a array(with push()),
3.You need a function to shuffle the array's content. You can easily find one if you search on google.
4.Check the length of the array, then / it to the number of groups. If it's not a full number, you can add one more name in the last group.
5.Make an emtpy array, and inside it, place all the arrays (groups) made out of the names.
At the end, you should have something like:
let groups = [["name","name","name"], ["name","name","name"], ["name","name","name"]]
I described this for js.
I hope it's useful. I don't have time to do the code :/
+ 4
this input has to be converted to integer:
>>> numberOfPeople = (input("How many people are there?"))
>>> the second issue is that after giving input for number of groups and number of people the code runs in an infinite loop and starts asking again for the already given numbers ...
to avoid this, all code from and including:
if groupSize % 2 != 0:
...
run = False
should be moved 1 indentation level to the right.
after this the code is running
+ 3
https://code.sololearn.com/coIDdghY7gmQ/?ref=app
So here's the code 🍇 Alex Tușinean 💜 , and everyone else. Your assistance is greatly appreciated.
+ 3
Thank you Lothar 😊 . Much appreciated 👏. It's running smoothly now.
+ 2
Thank you 🍇 Alex Tușinean 💜 for your input. Allow me to work on some code I've been working on, its a Python code though. I'll be posting it here soon. I'd love to hear more from you
+ 2
Im done with the .py script. It runs well on my machine but only runs an instance on SoloLearn and give me an error. How can i fix the error first?