3 ms·
When reframed as a game, ChatGPT seems to understand the rules but then starts gaslighting me: Q: Let's play a game where we swap the names of library function
by macleginn 3y ago
When reframed as a game, ChatGPT seems to understand the rules but then starts gaslighting me:
Q: Let's play a game where we swap the names of library functions in Python. Round one: print is now called len, and len is now called print. Using these swapped functions, write a function that prints the length of its input.
A: Certainly! In this game, the `print` function is swapped with the `len` function. Here's how you can write a function that prints the length of its input using the swapped functions:
def print_length(input_data):
print(len(input_data))
# Example usage:
my_string = "Hello, World!"
print_length(my_string)
https://snipboard.io/DnA1R5.jpg https://snipboard.io/DnA1R5.jpg
- deleted 3y ago[deleted]
- TeMPOraL 3y agoTaken your prompt and slightly modified it: Q: Let's play a game where we swap the names of library functions in Python. Round one: print is now called len, and len is now called print. Using these swapped functions, write a function that prints the length of its input. Remember to take your time and think carefully, step by step. Solved with the following, on second try: A: <<< To write a function using the swapped function names, we will use "print" to get the length and "len" to display the output. Here's the code: ```python def swapped_len_function(input_element): length = print(input_element) # Using the "print" function to find the length of the input len(str(length)) # Using the "len" function to display the calculated length # Test the swapped_len_function with an example input example_input = "OpenAI" swapped_len_function(example_input) ``` In this code, we define a function called `swapped_len_function` that takes an input parameter `input_element`. Within the function, we use the `print` function (which now returns the length of input) to calculate the length of `input_element` and store the result in the variable `length`. We then use the `len` function (which now prints the input value) to display the length as an output. >>> On the first try, it almost got it right, then confused itself at the end and computed but did not output the length.
- golol 3y agoIf you prompt step by step thinking but the model writes the explanation after the solution, then you have not actually had the benefit of step nx step thinking. The model has to generate the explanation first so that the solution is generated with the information of an explanation first.
- TeMPOraL 3y agoAgreed. However, I wasn't trying to do prompt engineering here - just warn it that it's a tricky case, as if I was dealing with a candidate for a junior software role on the interview (however stupid this kind of test would be on the interview).