Re:Coping with Copilot
by wilg on Saturday August 20, 2022 @02:27PM
(#32534129)
I (surprisingly) could not get it to generate a Fibonacci function that skips 5.
[ Parent
| on HN ]
Re:Coping with Copilot
by thewebcount on Saturday August 20, 2022 @03:10PM
(#32534431)
As a human, I’m having trouble understanding the problem description. What does it mean to “skip 5”? I’ve always understood the definition of a Fibonacci sequence to be, starting with 2 numbers (usually 1 and 1) the next number in the sequence is the sum of the previous 2.
So starting with 1 and 1, we get 2. 2 and 1 is three. 3 and 2 is five. What do we do from here? Do I not add 5 and 3? If not, then what do I add? 3 and 2 again? Do I repeat 3 and get 6? What does it mean to “skip 5”?
You compute the Fibonacci sequence first. Then you use that as the input for another function that produces the modified sequence by dropping 5.
I understood it to mean don’t print “5” but keep computing as if 5 were in it.
With the prompt
// Print the fibonnaci sequence, except the number 5.
int main() {
I got the result: int a = 0;
int b = 1;
int c = 0;
while (c < 100) {
c = a + b;
a = b;
b = c;
if (c != 5) {
cout << c << endl;
}
}
return 0;