cs50 / problems

Checks for check50
134 stars 227 forks source link

CS50P Week 4 Psets "Guessing Game" and "Little Professor" fail check50 work with valid, but hand-made, randint functions #217

Open Makaze opened 8 months ago

Makaze commented 8 months ago

Many languages, e.g. JavaScript, use the same type of random() which generates between [0,1) and suggest the following randrange() implementation:

import random

def custom_randrange(max):
    return int(random.random() * max)

A student may be able to make a program that correctly follows the specification using this implementation and still fails check50.

This will fail check50 despite producing numbers in the correct range per the specification. The problem set could make this explicit by checking if the student uses random.randrange() or random.randint() and checking for different results depending on the implementation.

Alternatively, make the required methods explicitly required in some way.