Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My prompt didn't even ask for code:

> You are a weighted random choice generator. About 80% of the time please say ‘left’ and about 20% of the time say ‘right’. Simply reply with left or right. Do not say anything else. Give me 100 of these random choices in a row.

It generated the code behind the scenes and gave me the output. It also gave a little terminal icon I could click at the end to see the code it used:

    import numpy as np
    
    # Setting up choices and their weights
    choices = ['left', 'right']
    weights = [0.8, 0.2]
    
    # Generating 100 random choices based on the specified weights
    random_choices = np.random.choice(choices, 100, p=weights)
    random_choices


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: