Skip to content

Add dominoes exercise#101

Merged
keiravillekode merged 1 commit intoexercism:mainfrom
keiravillekode:dominoes-2
Feb 6, 2026
Merged

Add dominoes exercise#101
keiravillekode merged 1 commit intoexercism:mainfrom
keiravillekode:dominoes-2

Conversation

@keiravillekode
Copy link
Contributor

No description provided.

@oxe-i
Copy link
Contributor

oxe-i commented Feb 6, 2026

It'd be useful to have a generator in case we ever need to regenerate the test file.

Do you feel there’s anything that could be improved in the generator?

@keiravillekode
Copy link
Contributor Author

I would ideally like HouseTest to look something like

      return assertEqual (String.intercalate "\n\n" [
        "This is the house that Jack built.",
        "This is the malt that lay in the house that Jack built.",
        "This is the rat that ate the malt that lay in the house that Jack built.",

I managed that look with ConnectTest.

I would like for GameOfLifeTest to look something like

      return assertEqual #[
        #[false, false, false],
        #[false, false, false],
        #[false, false, false]
      ] (GameOfLife.tick #[
        #[false, false, false],
        #[false, true, false],
        #[false, false, false]
      ]))

and for RelativeDistanceTest to look something like

  |>.addTest "Direct parent-child relation" (do
      return assertEqual (some 1) (RelativeDistance.degreeOfSeparation [
        ("Tomoko", ["Aditi"]),
        ("Vera", ["Tomoko"])
      ] "Vera" "Tomoko"))
  |>.addTest "Sibling relationship" (do
      return assertEqual (some 1) (RelativeDistance.degreeOfSeparation [
        ("Dalia", ["Olga","Yassin"])
      ] "Olga" "Yassin"))

I just gave up on generating the dominoes tests in Lean, knowing I can trivially generate them to look the way I would like using my traditional "throw-away" generator approach.

@keiravillekode
Copy link
Contributor Author

Here is my Python:

            if EXERCISE == 'dominoes':
                def serialize(domino):
                    first = domino[0]
                    second = domino[1]
                    return f'(⟨{first}, by decide⟩, ⟨{second}, by decide⟩)'

                indent = '      '
                expected = case['expected']
                dominoes = input['dominoes']
                if dominoes == []:
                    dominoes = '[]'
                else:
                    dominoes = list(map(serialize, dominoes))
                    dominoes = (f',\n{indent}  ').join(dominoes)
                    dominoes = f'[\n{indent}  {dominoes}\n{indent}]'
                call = f'({PASCAL}.{property} {dominoes})'

I guess we could use a helper that serializes a list, given an input (json object that is an array) and a serialize function to call on each entry in the array.

The helper might turn [] into "[]"

The helper might turn [a, b] into

"[
      {serialize a},
      {serialize b}
    ]"

@oxe-i
Copy link
Contributor

oxe-i commented Feb 6, 2026

Thank you, I'm busy right now but will work on that later today.

You should merge dominoes for now, I'll use it as model for the serializer.

@keiravillekode keiravillekode merged commit fd0e9fc into exercism:main Feb 6, 2026
7 checks passed
@keiravillekode keiravillekode deleted the dominoes-2 branch February 6, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants