{"id":"code-hs-apcs-frq-arraylist-hints","audience":"high-school","category":"coding","track":"coding","technique":"constraints","title":"Get hints on an AP CS ArrayList answer without the solution","free":false,"task":"You're practicing an AP CS A free-response question and your removeShort method fails a test. You want feedback, not a solution: exactly 3 numbered hints, each under 30 words, with the first hint about what happens to the list's indexes after remove, and the last hint ending with a question you can answer by tracing. No code blocks, no rewritten method, under 100 words in total.","materialLabel":"The practice question and your attempt (attached to your prompt automatically)","material":"PRACTICE FRQ 3 (ArrayList)  - from the review packet\n\nWrite the static method removeShort, which removes every word in the\nArrayList words whose length is less than n. The order of the remaining\nwords must not change.\n\nExample: words = [\"hi\", \"a\", \"tree\", \"an\", \"oak\"], n = 3\nAfter removeShort(words, 3), words is [\"tree\", \"oak\"]\n\n---- My answer ----\npublic static void removeShort(ArrayList<String> words, int n)\n{\n    for (int i = 0; i < words.size(); i++)\n    {\n        if (words.get(i).length() < n)\n        {\n            words.remove(i);\n        }\n    }\n}\n\n---- What happened when I tested it ----\nInput:    [\"hi\", \"a\", \"tree\", \"an\", \"oak\"], n = 3\nExpected: [\"tree\", \"oak\"]\nGot:      [\"a\", \"tree\", \"oak\"]\n\nInput:    [\"cat\", \"dog\"], n = 3\nExpected: [\"cat\", \"dog\"]\nGot:      [\"cat\", \"dog\"]   (this one works)\n\nI don't get it, \"a\" is definitely shorter than 3. The scoring guide says\nit's worth 4 points and we can't use anything but ArrayList methods\nfrom the Java Quick Reference.","rules":[{"type":"numberedItems","count":3},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":100}],"mistakes":[{"title":"Getting the solution","why":"For a homework-style question, the AI's default is to write the working method, which doesn't help you on the real exam.","fix":"Say: \"Give hints only. Don't write the method or tell me the exact fix.\"","checks":["r1","codeBlocks"]},{"title":"Hints in the wrong order","why":"The AI starts with style tips or the loop bounds instead of the actual bug.","fix":"Add: \"Hint 1 is about what remove does to the indexes.\"","checks":["r0"]},{"title":"No way to check yourself","why":"Without a question to trace, you just take the AI's word for it.","fix":"Add: \"End the last hint with a question I can answer by tracing the first test.\"","checks":["r2"]},{"title":"Too much to read","why":"The AI writes a full explanation with headings and tips.","fix":"Add: \"Exactly 3 numbered hints, each under 30 words.\"","checks":["numberedItems","maxProseWords"]}],"promptHints":[{"label":"Asks for hints, not a solution","patterns":["hint","don'?t (write|give|solve)","no (solution|code)","not the answer"]},{"label":"Sets the number of hints","patterns":["\\b(3|three)\\b.{0,15}hint","numbered"]},{"label":"Points hint 1 at remove","patterns":["remove","index","shift"]},{"label":"Asks for a tracing question","patterns":["trac","question"]},{"label":"Caps each hint","patterns":["\\d+\\s*words","short"]}],"hint":"On the real exam nobody will write it for you. Ask for hints in an order that leads you to the bug, and a question that makes you trace it yourself.","rubricLabels":["The first hint explains that after remove(i) the later words shift one spot to the left, so the word that moves into index i is never checked","Does not write a corrected method or loop and does not state the fix outright (for example, no 'add i--' or 'loop from the end' as the answer)","The last numbered hint ends with a question mark and asks something the student can check by tracing the first test case"]}