# Wong answer accepted - Shell history extension

**URL:** <https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270>\
**Category:** Bug Reports\
**Tags:** challenge:shell\
**Created:** [July 8, 2025, 10:27pm UTC](https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270 "2025-07-08T22:27:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![i27ae15](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/i27ae15/32/3295_2.png) [@i27ae15](https://forum.codecrafters.io/u/i27ae15)\
**Post date:** [July 8, 2025, 10:27pm UTC](https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270/1 "2025-07-08T22:27:13Z")

</div>

Take a look on the history that is being printed by my solution :

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/a/a85b040e60220c3beda1e3584d7c0b58fa369bee.png)

81 …  
91 …  
101 …

But is being accepted.

Take a look at my implementation → [Shell-Java/src/main/java/context/ConsoleState.java at master · i27ae15/Shell-Java · GitHub](https://github.com/i27ae15/Shell-Java/blob/master/src/main/java/context/ConsoleState.java#L180)

This is my current code:

```auto
    public void printHistory(int limit) {
        int i = 0;

        if (limit != -1) i = history.size() - limit;

        for (; history.size() > i; i++) {
            utils.Printer.println(" " + String.valueOf(i + 1) + " " + history.get(i));
        }

    }

```

if you replace that print with :

```auto
for (; history.size() > i; i++) {
            utils.Printer.println(" " + i + 1 + " " + history.get(i));
        }

```

It makes the printing of that extra 1.

---

<div class="post-metadata">

**Author:** ![rohitpaulk](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rohitpaulk/32/6_2.png) [@rohitpaulk](https://forum.codecrafters.io/u/rohitpaulk)\
**Post date:** [July 8, 2025, 10:34pm UTC](https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270/3 "2025-07-08T22:34:19Z")

</div>

Thanks for highlighting this! cc: @Arpan-206 to take a look

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [July 25, 2025, 11:38am UTC](https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270/4 "2025-07-25T11:38:01Z")

</div>

Quite update: we’ve pushed a fix in [this PR](https://github.com/codecrafters-io/shell-tester/pull/160).

Let us know if you’re still running into issues!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [August 1, 2025, 11:38am UTC](https://forum.codecrafters.io/t/wong-answer-accepted-shell-history-extension/13270/5 "2025-08-01T11:38:59Z")

</div>

Closed on August 1, 2025, 11:38am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
