Skip to main content
39 votes

Deck of cards as an interview exercise

No one but the folks who reviewed your code for the company can say with certainty why you were rejected. It also depends on the position you're applying for. If you're applying for an entry-level ...
Chris G's user avatar
  • 501
34 votes
Accepted

Object Oriented Design of Card Deck

So much to say, in so little space. This could be answered in so many ways, mainly due to why you need to model the cards. Without a proper context, the requirements will change and can thusly change ...
holroy's user avatar
  • 11.5k
31 votes

Deck of Cards written in C++

Design review Card Let’s start by looking at the Card class. As designed, Card has 4 data ...
indi's user avatar
  • 13.8k
28 votes

Deck of cards as an interview exercise

This is mostly how I would solve it (in Python): ...
Zah's user avatar
  • 450
26 votes
Accepted

Deck of cards as an interview exercise

While not strictly required, we value usage instructions, nicely-modeled data, automated tests, and thoughtful consideration of architectural decisions and simplicity-vs-completeness trade-offs. ...
Joseph's user avatar
  • 25.2k
22 votes
Accepted

Making a deck of cards in Python

You could just use str.join in a list comprehension and create deck directly: ...
Graipher's user avatar
  • 41.1k
19 votes
Accepted

Yu-Gi-Oh cards in Python 3

Trim redundant else ...here: if len(self.main_deck) > 60: return "You have to many cards in your deck (60)." else: ...
Reinderien's user avatar
  • 65.6k
16 votes
Accepted

Blackjack game interview task

Avoid repetitive code ...
mdfst13's user avatar
  • 21.7k
16 votes

Yu-Gi-Oh cards in Python 3

dataclasses.dataclass would single handedly remove the majority of your code. ...
Peilonrayz's user avatar
  • 43.5k
16 votes
Accepted

Card Shuffle without using any help C#

Modeling the real world You've clearly drawn inspiration from the real world. That's a good thing. A lot of programming and the design that goes into it can be modeled based off of real life. However, ...
Flater's user avatar
  • 5,542
13 votes

Simple Blackjack game in console

Avoid singletons private static Blackjack game; and later ...
mdfst13's user avatar
  • 21.7k
12 votes
Accepted

Comparable playing cards

Plain enum (unlike enum class) convert implicitly to integers, so there's no need for the ...
Toby Speight's user avatar
  • 81.9k
12 votes

Yu-Gi-Oh cards in Python 3

Since you're using python 3.7, I would take advantage of f-strings. For example, this: return "That card hasn't been added to the game yet (" + card_to_add + ")." ...
Paul M.'s user avatar
  • 271
11 votes

Weekend Challenge - Poker Hand Evaluation

Almost four years later... I discovered a bug. Consider the following tests: ...
Simon Forsberg's user avatar
11 votes

Simple Blackjack game in console

I wanna start of by saying that I think this code is to a very high standard for someone just completing their first project, the game is overall well put together. So for this review I'm going to ...
chatton's user avatar
  • 1,496
10 votes

Making a deck of cards in Python

You can unpack the tuple directly in the list comprehension and use + to join the cards. ...
tobias_k's user avatar
  • 1,669
10 votes
Accepted

Beginnings of a Poker hand classifier part 2

...
Heslacher's user avatar
  • 50.4k
10 votes

Deck of cards as an interview exercise

I sympathise :) I'm not sure if my answer will actually help much as it's either a rant or a list of hard work to do but hopefully it informs. Interview tests are hopelessly flawed experiments When ...
Seth's user avatar
  • 209
10 votes
Accepted

Command line Blackjack

Instead of switch (choice) { case "n": gameLoop = false; break; default: break; } you could use something like the following: <...
JanDotNet's user avatar
  • 8,538
10 votes

Blackjack game interview task

main method In the main method, I don't think you should pass args to the ...
IEatBagels's user avatar
  • 12.4k
10 votes

Poker dealer Hold'em

Overall the code seems ok. But there are some things to consider which have to do with cleaner code and SOLID principles. Firstly your variable names are confusing and not indicative. ...
downrep_nation's user avatar
10 votes
Accepted

Macau Card Game

CardProperties.hpp #pragma once Don't use #pragma once. It's not standard, it's not ...
indi's user avatar
  • 13.8k
9 votes
Accepted

Another attempt at a Blackjack game

Boolean used in conditions Let's take the following example : if (skyIsBlue == true). In a proper English sentence, we'd read : If it is true that the sky is ...
IEatBagels's user avatar
  • 12.4k
9 votes

Yu-Gi-Oh cards in Python 3

I know you're trying to abbreviate "defense," but you could consider writing the whole thing out instead of making inconsistent naming with the preceding underscore. As such, you could write out "...
Jamal's user avatar
  • 34.9k
9 votes
Accepted

A Python Blackjack terminal based game

Card: Consider renaming card_value to just value. Since it belongs to an instance of the ...
Aleksandr Hovhannisyan's user avatar
9 votes

C# Blackjack prototype

Just a few notes so you can improve your code: ...
Heslacher's user avatar
  • 50.4k
8 votes

Find and display best Poker hand

Overall, this solution is quite good, especially if you are a beginner as you say. Each function has a clear purpose, and the docstrings are helpful. The docstrings could be improved by writing the ...
200_success's user avatar
8 votes

The card game war

The other answer already mentions the Fisher-Yates Shuffle which is definitely what you want to use. I thought I'd break down your Shuffle a bit to show you why it's flawed. This is what I consider ...
RobH's user avatar
  • 17k

Only top scored, non community-wiki answers of a minimum length are eligible