Skip to content

go-counting: Implement the exercise "go-counting" #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 7, 2017

Conversation

yunchih
Copy link
Contributor

@yunchih yunchih commented Oct 8, 2017

See #748

Copy link
Contributor

@ilya-khadykin ilya-khadykin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunchih
Copy link
Contributor Author

yunchih commented Oct 8, 2017

Thanks for the head-up! Added

Copy link
Contributor

@ilya-khadykin ilya-khadykin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great 👍

Could please rename file names of gocounting.py and gocountingtest.py to follow snake_case naming convention?

Plus there are some minor code flake8 style issues, but I'm sure you'll fix them easily

config.json Outdated
"topics": [
"parsing",
"tuples",
"optional values"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've switched to snake_case naming convention for topics to increase consistency among tracks, so could you please choose them from the following list - https://github.com/exercism/problem-specifications/blob/master/TOPICS.txt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also propose adding classes here

config.json Outdated
"slug": "go-counting",
"core": false,
"unlocked_by": null,
"difficulty": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the difficulty for this one should be increased.
What do you think?

@yunchih
Copy link
Contributor Author

yunchih commented Oct 9, 2017

Updated as requested. Thanks for being patient on me 😆

@yunchih
Copy link
Contributor Author

yunchih commented Oct 30, 2017

Hi, I've added the version string. Anything else that needs update?

Copy link
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunchih I've left some comments. Please make the appropriate changes.

[wikipedia](https://en.wikipedia.org/wiki/Go_%28game%29) or [Sensei's
Library](http://senseis.xmp.net/).

### Submitting Exercises
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RE #950, this should be ## Submitting Exercises

import unittest
import gocounting

# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor change: please add 1 additional blank line above this (2 before, 1 after) for consistency across exercises.


class GoCountingTest(unittest.TestCase):
def test_5x5_for_black(self):
board = gocounting.GoCounting(board5x5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class GoCounting should not be the same name as the module gocounting. Please rename to something more intuitive, such as Board

def test_5x5_for_black(self):
board = gocounting.GoCounting(board5x5)
stone, territory = board.territoryFor((0, 1))
self.assertEqual(stone, board.black)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to define constants at either the module level

BLACK = "B"
WHITE = "W"
NONE = ""

class GoCounting(object):
    ...

or in a separate class

class Player(object):
    BLACK = "B"
    WHITE = "W"
    NONE = ""

class GoCounting(object):
    ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make the related changes in go_counting_test.py as well.

@yunchih
Copy link
Contributor Author

yunchih commented Nov 1, 2017

@cmccandless Thanks for your review! You've been very kind.

Copy link
Contributor

@cmccandless cmccandless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend running the tests yourself before pushing new commits. The easiest way to do this without heavy modifications to your code would be to temporarily change the import statement in go_counting_test.py to import from example instead of go_counting, then just run pytest. Just make sure to revert that one change before commiting.

def test_5x5_for_black(self):
board = gocounting.GoCounting(board5x5)
stone, territory = board.territoryFor((0, 1))
self.assertEqual(stone, board.black)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make the related changes in go_counting_test.py as well.

@yunchih
Copy link
Contributor Author

yunchih commented Nov 2, 2017

@cmccandless updated as requested.

@ilya-khadykin ilya-khadykin merged commit 9785ac6 into exercism:master Nov 7, 2017
@ilya-khadykin
Copy link
Contributor

Merged, thanks @yunchih!

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.

3 participants