Skip to content
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

Straight optimization proposal #3

Closed
kiko81 opened this issue Oct 31, 2015 · 11 comments
Closed

Straight optimization proposal #3

kiko81 opened this issue Oct 31, 2015 · 11 comments
Assignees

Comments

@kiko81
Copy link
Contributor

kiko81 commented Oct 31, 2015

better list clear than new list - line 97

@NikolayIT
Copy link
Owner

Will be fixed. Thanks! Create pull request next time.

@kiko81
Copy link
Contributor Author

kiko81 commented Oct 31, 2015

this way not the highest possible straight is returned but the lowest instead - will fix it

@NikolayIT
Copy link
Owner

Add unit tests (for regression)

@kiko81
Copy link
Contributor Author

kiko81 commented Nov 1, 2015

!!! line 134 - var straightCards = cards.Select(x => (int)x.Type).ToList(); - returns duplicates

renaming proposal: CompareTwoHandsWithHighCard => CompareKickers/CompareSideCards

Comparing straights - comparing any card[1-3] is enough - no Ace possible there -
bigger wins - no matter which way sorted - think will be faster O(1)

@NikolayIT
Copy link
Owner

Open new issues for every single bug.

@NikolayIT
Copy link
Owner

When comparing straights there are objects of type CardType so Ace is expected.

@kiko81
Copy link
Contributor Author

kiko81 commented Nov 1, 2015

Mean if compare e.g. 2nd cards only - no Ace possible there - Ace may be first or last only

@NikolayIT NikolayIT assigned NikolayIT and unassigned hiksa Nov 1, 2015
@NikolayIT
Copy link
Owner

What about this case:

new[]
    {
        CardType.Six, CardType.Five,
        CardType.Four, CardType.Three,
        CardType.Two
    },
new[]
    {
        CardType.Five, CardType.Four,
        CardType.Three, CardType.Two,
        CardType.Ace
    }

@kiko81
Copy link
Contributor Author

kiko81 commented Nov 1, 2015

e.g.
2nd cards: five > four => first wins
3rd cards: four > three => first wins
4th cards.......
Aces can be in the beginning or the end of hand - not in the middle - don't check ends - any middle card will do the trick
Not wrong now, of course, but may be less complex

@NikolayIT
Copy link
Owner

I've got the idea but the current solution is O(n) and the one you suggest requires sorting which will be O(n * log(n).

@kiko81
Copy link
Contributor Author

kiko81 commented Nov 1, 2015

thought they come sorted from hand evaluator, from tests come shuffled - anyway U know better 👍

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

No branches or pull requests

3 participants