Lem_in verifier - sergeresko/lem_in GitHub Wiki

Problem

How can you check if a lem-in provides a correct solution for a large map?

If done manually, it would take an enormous amount of time. No one’s gonna do this.

If we just count lines and compare with the number provided by the map generator, we can’t be sure that we’re dealing with an actual solution and not a mess that just happens to have the right number of lines.

Solution

For this reason — and as a bonus part of my project — I wrote a verifier that you can use to verify the output of a Lem_in program.

To build it, clone my repository https://github.com/sergeresko/lem_in and run make verifier.

Then you can use it like this: ./lem-in < some_map | ./verifier (insert the necessary paths into this command or just move the verifier to the folder where the lem-in is).

What it does

It moves ants through the ant-farm according to the solution given by the lem-in.

It checks if all ants eventually arrive at the finish and no rule is violated meanwhile (for example, no ant enters an occupied room or moves twice during a single turn).

If everything is correct, it prints the number of lines in the solution to stdout and returns 0.

If it finds an error, it prints the relevant error message and the problematic line of the solution to stderr and returns 1.

How to use it

Here’s my favorite way to check Lem_in:

./generator --big-superposition > map && tail -n 1 map && ./lem-in < map > out && ./verifier < out

Here I generate a map, print its last line which contains the requested solution length, pass the map to the lem-in, save its output and pass it to the verifier.

Examples

Good Lem_in:

Good Lem_in

Bad Lem_in:

Bad Lem_in

⚠️ **GitHub.com Fallback** ⚠️