Hunt 4: Logic bugs
Bugs with no error
- The hardest bugs give no message. The program runs, but the answer is wrong.
- Test with the expected output: what should come out? What comes out?
- Check the first value and the last value of every loop.
| Word | Meaning |
|---|---|
| logic bug | the code runs, but does the wrong thing |
| off by one | a loop that runs one time too many or too few |
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Your pet is stuck! This program should output 1 / 2 / 3 / 4 / 5. Find the bug and fix it.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Your pet is stuck! This program should output 3 / 2 / 1 / Go!. Find the bug and fix it.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Your pet is stuck! This program should output Kit. Find the bug and fix it.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Your pet is stuck! This program should output 10. Find the bug and fix it.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 3/5 · 200 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Your pet is stuck! This program should output -2. Find the bug and fix it.
คลิก Run เพื่อดูผลลัพธ์ที่นี่