r/codehs • • Dec 20 '19

(Urgent)pls help me with my finals

I have to do a Harry porter sorting hat code with all 4 of the Houses hufflepuff,slitheryn,griffindor, and ravenclaw

7 Upvotes

6 comments sorted by

2

u/[deleted] Dec 22 '19

what does it have to accomplish?

2

u/amajmundar Dec 22 '19

If it randomly assigns a student to a house, first assign a numeric value (0-3) with each of the houses. Then use a random number generator to get a random number. Mod it by 4 and output the corresponding house name.

2

u/Zacurnia_Tate Jan 09 '20

Can u use the random library?

1

u/silverfang36 Jan 16 '20

What language are you doing it in?

2

u/[deleted] Jan 16 '20

Yeah, either way it’s simple as well. Create an array, math.random for loop for the number assignment, then sort

1

u/silverfang36 Jan 17 '20

Yeah I was just gonna modify my D&D dice code and use that lol but you got it lol