3 ms·
Should confront it with some obvious evidence that it can write code. Such as asking it about a coding problem.
by worldsayshi 4y ago
Should confront it with some obvious evidence that it can write code. Such as asking it about a coding problem.
- nl 4y agoI like this: > Why can't most programmers solve FizzBuzz? [snip] The reason why most programmers cannot solve the FizzBuzz problem is that it requires a basic understanding of programming concepts, such as loops, conditionals, and modulo arithmetic. Many programmers may not have a strong foundation in these concepts, or may not be familiar with the specific requirements of the FizzBuzz problem. As a result, they may struggle to write a correct and efficient solution to the problem. [snip] > solve FizzBuzz in Bash using recursion # Function to solve the FizzBuzz problem fizzbuzz() { # Check if the number is greater than 100 if [[ $1 -gt 100 ]]; then # If so, return return fi # Check if the number is a multiple of 3 and 5 if [[ $1 -eq 0 ]]; then echo "FizzBuzz" # Check if the number is a multiple of 3 elif [[ $(( $1 % 3 )) -eq 0 ]]; then echo "Fizz" # Check if the number is a multiple of 5 elif [[ $(( $1 % 5 )) -eq 0 ]]; then echo "Buzz" # Otherwise, print the number else echo $1 fi # Increment the number and call the function recursively fizzbuzz $(( $1 + 1 )) } # Call the function to solve the FizzBuzz problem fizzbuzz 1 This solution uses a recursive function called fizzbuzz to solve the FizzBuzz problem. The function takes a number as an argument and checks if it is greater than 100. If so, it returns and the recursion ends. Otherwise, it checks if the number is a multiple of 3 and 5, 3, or 5, and outputs the appropriate string (FizzBuzz, Fizz, or Buzz) based on the result of the check. For all other numbers, the function simply outputs the number itself. It then increments the number and calls the function recursively with the incremented value as the argument. This continues until the number is greater than 100, at which point the recursion ends and the solution is complete. This solution is correct and efficient, as it uses a recursive function and the modulo operator to check for the required conditions and output the appropriate string. It also follows the best practices of the Bash programming language, such as using [[ to test conditions and $(( )) to perform arithmetic operations.
- tedunangst 4y ago# Check if the number is a multiple of 3 and 5 if [[ $1 -eq 0 ]]; then echo "FizzBuzz" It knows what it wants, just not quite how to do it here.
- nl 4y agoGood pickup! > In this code it incorrectly prints FizzBuzz when $1 is 0. Fix it # Function to solve the FizzBuzz problem fizzbuzz() { # Check if the number is greater than 100 if [[ $1 -gt 100 ]]; then # If so, return return fi # Check if the number is a multiple of 3 and 5 if [[ $(( $1 % 3 )) -eq 0 && $(( $1 % 5 )) -eq 0 ]]; then echo "FizzBuzz" # Check if the number is a multiple of 3 elif [[ $(( $1 % 3 )) -eq 0 ]]; then echo "Fizz" # Check if the number is a multiple of 5 elif [[ $(( $1 % 5 )) -eq 0 ]]; then echo "Buzz" # Otherwise, print the number else echo $1 fi # Increment the number and call the function recursively fizzbuzz $(( $1 + 1 )) } # Call the function to solve the FizzBuzz problem fizzbuzz 1
- kikokikokiko 4y agoAm I the only one that sees the parallels between what these language models do when it pertains to code to what some humans savants do, in relation to many "exceptional" skills some of them seem to posses? In the sense that, ChatGPT can spit out responses to very complex prompts, that any human programmer would take some hours of research to put together, but in fact the language model "doesn't know how" it arrived to the answer, it simply "knows how to answer" that specific question? To me it's a very similar phenomenon looking from the outside. Just in the case of a human savant, it's a biological neural net that formed over years, or even on gestation, and "acquired" the abilities to solve the problem.