My solution for Word Search is not showing up

I submitted this solution about 10 minutes ago, and it is not showing up in the Community Solutions. It’s not because my solution is a duplicate of anyone else’s solution since mine is 19 lines, and the current shortest solution is 20.

@ErikSchierboom Can you debug why this didn’t get synced to the search indexes please? There’s probably:

  • A code fix
  • A batch check
  • Fixing this solution

I’m curious about the tooling for this site. Are all exercises checked with the same version of python? Locally, I’m using python 3.10, which allows type annotation using primitive types like tuple[Point, Point] | None as opposed to Optional[Tuple[Point, Point]] from the typing library. However, since the tests passed, that probably isn’t the problem.

Yes. They are.

I’m also seeing the same problem with my Alphametrics solution. My first submission didn’t show up after waiting for several minutes and refreshing the page several times, so to test my theory, I removed all the type annotations, and it’s still not showing up :frowning:

Typehints aren’t the problem. :slightly_smiling_face:

The tooling for the Python track currently runs on Alpine Python 3.11.5, which is a slightly earlier version of this docker image from the PSF. Except for the Analyzer, which is currently using python:3.11.2-slim. We’re in the early process of moving to Python 3.12.x for everything, but there are library and code changes that need testing before we can do that.

We strip type annotations in the representer as part of our code normalization. See representations.md in the repo for more details on what we remove/change for Python.

Because we are not using MyPy, type annotations and aliases are largely ignored by the test runner, representer, and analyzer.

Does that mean this is a Python “issue” rather than a me/Erik issue, or do we need to research further ? :)

I was just in the process of replying. :wink:

TL;DR: Its a Python issue. At least for the first solution.

I will need to test the second solution (Alphametics), to see what is wrong with that one. I’ll post when I figure it out.

The first solution is running into the nasty dataclass bug I mentioned in this post. Kevin Brown (brocla) found it while helping me with representer tests. I am hoping to to do a pass on fixing it this weekend, fingers crossed.

Because dataclasses use a typehint as part of the class creation shortcut, the code that creates ASTs without the typehints interferes with the dataclass representation. The resulting code then fails the representation/Black formatting process.

The solution is to go back to having typhints removed manually, or check for dataclass creation and pass it thorough. Not sure which I want to try yet.

I’ll look at the second solution now. :smile:

1 Like

@iHiD /@ErikSchierboom – For Alphametics, we may have a website/platform issue to investigate.

When I run rzuckerm’s solution through the representer manually, there are no errors, and a representation is produced. But when I look at the most recent community solutions, there is nothing newer than 4/5 months ago.

Now, this exercise is ranked medium, but given that we’ve had over 10,000 students sign up in that time period I would expect at least a few more recent solutions to show. Another thought is that the disabled editor is somehow interfering with publication … but the editor has been disabled for this exercise for far longer than 4/5 months.

Gist of the representer output here.

I will also try uploading a solution to my account, and see if that shows up or not.


EDIT: Just uploaded and published a solution. It has not shown up with either the “Most Recent” filter nor “Highest Rep User” filter. I did, however get 2 points for publishing it, and everything else website-wise looks ok at a glance.

Going to push a second iteration to see if that triggers anything.

EDIT #2: Pushing additional iterations doesn’t change the community solutions.

For Word Search, I guess I’ll post a solution without dataclass. That makes me sad, though, since dataclass is one of my favorite Python features. It saves me from having to do a lot of boilerplate type stuff.

My Word Search solution is showing up now that I removed dataclass. Strangely enough, it’s the same number of line :grinning:.

You could also keep the @dataclass and assign a default value. Just did that for your former solution, and it both passed the tests and the representer:

@dataclass
class Point:
    x: int = 0
    y: int = 0

class WordSearch:
    def __init__(self, puzzle: list[str]):
        self.puzzle, self.xmax, self.ymax = puzzle, len(puzzle[0]), len(puzzle)

    def search(self, word: str) -> tuple[Point, Point] | None:
        w = len(word) - 1
        for y, row in enumerate(self.puzzle):
            x = -1
            while (x := row.find(word[0], x + 1)) >= 0:
                for dx, dy in DIRS:
                    if 0 <= x + dx * w < self.xmax and 0 <= y + dy * w < self.ymax:
                        if all(self.puzzle[y + n * dy][x + n * dx] == ch for n, ch in enumerate(word)):
                            return Point(x, y), Point(x + dx * w, y + dy * w)

        return None

It is the case where there is a typehint in the dataclass and no default that is the problem. :slightly_smiling_face:

Nonetheless, happy your solution showed up! :tada:

1 Like

Any word on why Alphametrics isn’t showing up?

Edit above. Looks like we may need to investigate the indexing or other code around publishing/community solutions for that one.

The representer is fine. I’ll look into it.

I think I’ve found the bug: Run representer and analyzer when exercise does not have test runner by ErikSchierboom · Pull Request #6933 · exercism/website · GitHub

2 Likes

Thanks @ErikSchierboom for fixing that. I’m still not seeing my solution. I have 2 iterations, and I tried to change the iteration between the two. I guess I have to submit a new iteration for it to show up?

We’ll rerun solutions, but we have to script it etc first.

@iHiD No need to run the script. I made some changes and submitted a new iteration. Now my solution for Alphametrics is showing up on this page toward the middle

It sounds like all solutions submitted over the last four years need that script run to show up, too :wink: