of     1   

ColorfulBody
#94829709Sunday, April 14, 2013 4:11 AM GMT

Quenty and some others asked for logic-based scripting challenges instead of challenges where you have to find out about Lua tricks, so I decided to follow their advice. You are a developer working for a big school, where there are many students. Each student has classes in many subjects, and is in a group for each of these subjects. Groups students are in will not be the same for all subjects. The people working on creating the groups of students have asked you to create a program that would find, for each group of students, the other group of students which has the most similarity in its members with it (the group with which the group has the most common students, students that are in both groups). The data your program receives is a table. That table contains a record for each student: the key of the record is the student's name (all student names are unique) and the value is another record, in which keys are subjects and values are identifiers (numbers) that represent a group. If the number corresponding to a subject is the same for two students, they are in the same group for that subject. Each group has its own identifier. You must create a program in Lua that will return a table in which each field is a pair of identifiers that represent two groups that are the groups with the most similarity (the most students that are common to both groups) for both groups. You must make sure that your program can run very quickly (it must be able to handle 1000 students that each have 15 groups in less than 5 seconds on an average computer, but that's really only a minimum) because it will be used together with another program that generates different combinations of groups, and that other program will generate millions of combinations. _________________________________________________________________________ I possess 4 ROBUX and 144 tickets.
iStone4S
#94830912Sunday, April 14, 2013 4:25 AM GMT

Less than 5 seconds? Impossible. 1000 * 1/30 = 100/3 which is way more than 5 seconds, unless we omit the wait(), but that might cause a crash, so...
miz656
#94831102Sunday, April 14, 2013 4:27 AM GMT

What if I don't have an average computer? What if I have a cheap CPU or a fast CPU? That enables me to win the challenge easier or harder. I say take out that rule.
DrHaximus
#94831110Sunday, April 14, 2013 4:27 AM GMT

I was going to create it in C++ and simply return the result to Lua just to be funny, but I don't have time :p
ColorfulBody
#94848823Sunday, April 14, 2013 11:28 AM GMT

@miz656 It's not rules, it's just a context. There are many things that are open to interpretation, and you cannot "win" the challenge. It should be very easy to get it to run in under 5 seconds, but that's obviously only a minimum: if the code is going to be ran at least a million of times, that'd mean 5 millions of seconds, which means it'd take almost 2 months to run. _________________________________________________________________________ I possess 4 ROBUX and 154 tickets.

    of     1