question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactor exercises to match canonical data

See original GitHub issue

There are a number of exercises that fall into one of the following cases:

Function names that differ from those specified in the canonical data

armstrong-numbers uses is_armstrong instead of is_armstrong_number:

https://github.com/exercism/python/blob/222c02976c2c0e75d03440893f543c760ca39ba9/exercises/armstrong-numbers/example.py#L1-L2

From the canonical-data:

    {
      "description": "Zero is an Armstrong number",
      "property": "isArmstrongNumber",
      "input": {
        "number": 0
      },
      "expected": true
    },

*Note: in these cases, the camelCase names used in the canonical data should be converted to snake_case names in the tests, example solution, and solution stub.

Test input format differs from canonical data

tournament passes a multiline string instead of a list of single-line strings.

https://github.com/exercism/python/blob/222c02976c2c0e75d03440893f543c760ca39ba9/exercises/tournament/tournament_test.py#L51-L57

From the canonical-data:

    {
      "description": "There can be more than one winner",
      "property": "tally",
      "input": {
        "rows": [
          "Allegoric Alaskans;Blithering Badgers;loss",
          "Allegoric Alaskans;Blithering Badgers;win"
        ]
      },
      "expected": [
        "Team                           | MP |  W |  D |  L |  P",
        "Allegoric Alaskans             |  2 |  1 |  0 |  1 |  3",
        "Blithering Badgers             |  2 |  1 |  0 |  1 |  3"
		]
	},

Test output format differs from canonical data

saddle-points expects a set of tuples instead of a list of dict objects

https://github.com/exercism/python/blob/222c02976c2c0e75d03440893f543c760ca39ba9/exercises/saddle-points/saddle_points_test.py#L16-L18

From the canonical-data:

    {
      "description": "Can identify single saddle point",
      "comments": [
        "This is the README example."
      ],
      "property": "saddlePoints",
      "input": {
        "matrix": [
          [9, 8, 7],
          [5, 3, 2],
          [6, 6, 7]
        ]
      },
      "expected": [
        {
          "row": 2,
          "column": 1
        }
      ]
    },

Test input order differs from canonical data

change uses the order target, coins instead of coins, target

https://github.com/exercism/python/blob/222c02976c2c0e75d03440893f543c760ca39ba9/exercises/change/change_test.py#L9-L10

From the canonical-data:

    {
      "description": "single coin change",
      "property": "findFewestCoins",
      "input": {
        "coins": [1, 5, 10, 25, 100],
        "target": 25
      },
      "expected": [25]
    },

In an effort to simplify the job of the WIP test generator, it would be beneficial to reduce these inconsistencies now, so that it does not become the job of the generator PR to correct example solutions and stubs that do not match newly generated tests.

Here is the full list of exercises in which this occurs

  • alphametics
  • armstrong-numbers
  • binary-search
  • bob
  • book-store
  • change
  • collatz-conjecture
  • crypto-square
  • diamond
  • difference-of-squares
  • dominoes
  • gigasecond
  • grains
  • grep
  • isbn-verifier
  • knapsack
  • leap
  • list-ops
  • markdown
  • meetup
  • minesweeper
  • nth-prime
  • palindrome-products
  • prime-factors
  • pythagorean-triplet
  • raindrops
  • rectangles
  • roman-numerals
  • saddle-points
  • secret-handshake
  • sieve
  • spiral-matrix
  • sublist
  • ~sum-of-multiples~ (foregoing updates for now)
  • tournament
  • transpose
  • triangle
  • two-fer
  • word-count
  • wordy
  • yacht

This issue may be considered resolved once all of the above issues have been updated to match the canonical properties.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
cmccandlesscommented, Jun 20, 2019

Nope; the decision was made to not require students to use exact error message, only to have a message present. It’s up to mentors then to comment on whether the exception messages match the case.

1reaction
cmccandlesscommented, May 31, 2019

@Grociu regarding two-fer, the mismatch is in the choice to use name="" as the null case rather than name=None

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 coding exercises to practice refactoring Legacy Code
Feeling overwhelmed by your legacy codebase? These katas will help you learn how to tackle it.
Read more >
Understanding Refactoring Tasks over Time: A Study Using ...
In this paper, we rely on a graph- based abstraction—called refactoring graphs—to visualize and analyze refac- torings performed by students in a canonical...
Read more >
Binary Refactoring: Improving Code Behind the Scenes
We present Binary Refactoring: a software engineering technique for improving the implementation of programs without modifying their source code.
Read more >
Pattern Refactoring - Python 3 Patterns, Recipes and Idioms
This chapter will look at the process of solving a problem by applying design patterns in an evolutionary fashion. That is, a first...
Read more >
(PDF) Canonical Forms in Interactive Exercise Assistants
Canonical forms and notational conventions can be captured in a view [12] , which consists of a partial function for matching, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found