Questions tagged [card-games]

For challenges which involve card games. This includes playing the game, implementing the game, as well as challenges concerned with individual mechanics and analysis of the game (for instance, computing probabilities of certain events).

Filter by
Sorted by
Tagged with
72 votes
48 answers
9k views

Magic the Gathering: Friends or Foes?

In the card game Magic: the Gathering there are five different colours, which represent loose affiliations of cards, White (W), Blue (...
Martin Ender's user avatar
50 votes
12 answers
9k views

Professor at MIT can read minds!

The task is taken from an MIT lecture by Prof. Devadas called You can read minds. A detailed explanation of the trick can be found in the linked video, or in this document. I'll try to explain it in ...
Stewie Griffin's user avatar
32 votes
11 answers
2k views

Nothing like a good ol' game of ModTen

Disclaimer: ModTen is a fictional card game which was created for the sole purpose of this challenge. The rules of ModTen ModTen is played with a standard 52-card deck. Because the full rules are ...
Arnauld's user avatar
  • 192k
31 votes
20 answers
3k views

Faro shuffle an array

A Faro shuffle is a technique frequently used by magicians to "shuffle" a deck. To perform a Faro shuffle you first cut the deck into 2 equal halves then you interleave the two halves. For ...
DJMcMayhem's user avatar
  • 59.2k
31 votes
6 answers
6k views

That's BS! (card game)

BS is a card game where the object of the game is to lose all of your cards. A game consists of four players and a 52-card deck. Each player is randomly dealt 13 cards. Normally, cards are labeled 2 -...
soktinpk's user avatar
  • 4,462
31 votes
3 answers
958 views

Choose the last card in a poker hand

Poker hands are ranked from best to worst as follows: Straight flush - five cards of sequential rank, all of the same suit Four of a kind - four cards of the same rank and one card of another rank ...
Stewie Griffin's user avatar
31 votes
1 answer
2k views

Magic: the Gathering Combat Golf

Magic: the Gathering is a trading card game where, among other things, players play cards representing creatures, which can then attack the other player, or defend against the other player's attacks ...
isaacg's user avatar
  • 42k
30 votes
13 answers
4k views

20 cards with no Set

Background Set is a card game. The deck consists of 81 unique cards that vary in four features: number of shapes (one, two, or three), shape (diamond, squiggle, oval), shading (solid, striped, or ...
Bubbler's user avatar
  • 76k
25 votes
8 answers
2k views

Golf a golf-scorer

As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this ...
DJMcMayhem's user avatar
  • 59.2k
22 votes
13 answers
2k views

Score a hand of Hearts

Hearts is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score ...
user avatar
22 votes
10 answers
1k views

How many Blackjack sequences in that list?

Your task is to find how many distinct Blackjack sequences can be found in an ordered list of 12 cards. A Blackjack sequence is defined as a sequence of consecutive cards whose sum of points is ...
Arnauld's user avatar
  • 192k
22 votes
2 answers
834 views

Can you cast the spell?

In Magic: the Gathering, mages (known as "planeswalkers") battle each other by casting spells. Spells cost mana. Five colors of mana exist: White, Blue, Black, Red, and Green, represented as {W}, {U}, ...
Rainbolt's user avatar
  • 6,376
20 votes
9 answers
2k views

Identify halves of Poker cards

A casino uses the following deck of cards. (* is one of the card suits D, S, ...
user694733's user avatar
20 votes
9 answers
834 views

Hand patterns in a card game

A deck of cards is the Cartesian product of S suits and R ranks. Many, though not all, card games use ...
ngn's user avatar
  • 15.3k
20 votes
4 answers
1k views

Determine the winner of a game of War

The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked ...
user avatar
19 votes
14 answers
2k views

Is it a shuffle?

Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a ...
Wheat Wizard's user avatar
  • 98.7k
19 votes
10 answers
2k views

Who wins a Spades trick

Write code to determine who wins a four-card trick in a game of Spades. Fewest bytes wins. The input is a string that lists the four cards played in sequence like ...
xnor's user avatar
  • 145k
19 votes
3 answers
750 views

Evaluate a Skat-Hand

Introduction Skat is a traditional German card game for 3 players. The deck consists of 32 cards: Ace, King, Queen, Jack, 10, 9, 8, 7 in all 4 suits (Clubs, Spades, Hearts, Diamonds). In every round ...
Denker's user avatar
  • 6,851
18 votes
2 answers
573 views

How many shuffles

A riffle shuffle is a type of shuffle where the deck is split into two partitions and the partitions are then spliced back together to create a new shuffled deck. The cards are spliced together in ...
Wheat Wizard's user avatar
  • 98.7k
18 votes
1 answer
801 views

Hold'em or Fold'em?

Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given ...
Magic Octopus Urn's user avatar
17 votes
11 answers
2k views

Want to see a Magic Card Trick?

The first magic card trick I ever learned as a child was the following: Have 1 deck of cards where the pattern on the back is not vertically symmetric. Organize all cards to be facing one direction. ...
Magic Octopus Urn's user avatar
17 votes
8 answers
2k views

Stage a Coup to become king of the hill!

Leaderboard ...
Purple P's user avatar
  • 1,657
15 votes
13 answers
4k views

Execute a Superb Shuffle™

For the purposes of this question, a deck of cards is formatted in this way: ...
AJFaraday's user avatar
  • 11.8k
15 votes
15 answers
2k views

How many Faro shuffles for a cycle?

Background Inspired by this video by Matt Parker A Faro shuffle is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one: the deck of 52 cards ...
pxeger's user avatar
  • 23.7k
15 votes
14 answers
2k views

Irish Snap: Variant Rules

Introduction Recently, me and a couple of my friends decided to play some cards, and one of them suggested the game 'Irish Snap', which was the inspiration for this challenge. However, I later learnt ...
EdgyNerd's user avatar
  • 1,376
15 votes
9 answers
926 views

What is the score of my Scopa hand?

I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun ...
qdread's user avatar
  • 509
14 votes
13 answers
3k views

Play a game of memory

Playing the game of memory against a machine is highly unfair, because they play almost as good as small children. So let's make the machine play alone, but in a fair way: Input: 1...26 pairs of ...
Philippos's user avatar
  • 2,511
14 votes
6 answers
1k views

Clock (card game)

Clock is an interesting card game, as it requires no skill. It is a single player game, and the same card configuration always leads to a win or a loss. In this challenge, you need to figure out ...
Nathan Merrill's user avatar
14 votes
3 answers
749 views

Snap (card game)

When I was a child I used to play a variation of Snap to stake soccer trading cards. "Game" is an overstatement because the only role of the players is to secretly prepare their starting ...
Domenico's user avatar
  • 2,273
14 votes
5 answers
566 views

Professor at MIT needs an AP!

The 5-card magic trick involves a magician whose assistant gives them 4 shown cards and a hidden one, in this order, and the magician must guess the hidden one. WARNING: Solution below! Leave now or ...
Erik the Outgolfer's user avatar
14 votes
3 answers
985 views

Simulate a 'battle' in the playing card game 'Oorlog'

Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). How does 'Oorlog' work? Two decks of cards (each including two Jokers)...
Kevin Cruijssen's user avatar
14 votes
4 answers
781 views

Leo's Pokerface

Pokerface Introduction Leo enjoys playing poker, but his job at Tech Inc. is too demanding for him to learn how to play well. Leo, being a computer scientist, is not discouraged. He decides to take ...
Socratic Phoenix's user avatar
13 votes
18 answers
770 views

Shuffle Up and Deal!

It is Friday and I am tired, so let's do a quick one! Take no input, however you should output all thirteen different numbered cards in a standard deck of cards. You should output 2 through Ace (Suit ...
jacksonecac's user avatar
  • 2,634
13 votes
9 answers
2k views

Magic: the Gathering - Colour Sorting

Related: Deck Names Friends or Foes Paying for Spells The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of ...
Matthew Jensen's user avatar
13 votes
10 answers
816 views

Deal an ASCII Deck

There's never really been a definitive ASCII-cards challenge AFAIK. So, using the following deck of ASCII cards: ...
Magic Octopus Urn's user avatar
13 votes
3 answers
408 views

Analyze overhanded shuffles

Rod is moderating a card game between two players: George and Tim. Currently, Tim is shuffling the cards. Rod suspects that Tim is trying to cheat, so he needs your help to check that the shuffle is ...
aditsu quit because SE is EVIL's user avatar
13 votes
4 answers
805 views

Help me cheat at Cheat

Cheat is a card game where you're trying to get rid of your hand. A turn looks something roughly like this: Determine what card rank you have to play that turn. In most variants this is one rank ...
Hovercouch's user avatar
13 votes
1 answer
720 views

Solve a game of Accordion

Accordion is a solitaire card game I recently came across where nearly every layout is solvable, but incredibly hard. You can play it here. Rules 52 face cards are placed face-up in a random order. ...
Nathan Merrill's user avatar
13 votes
1 answer
328 views

Play Best Card in Euchre

Input: Firstly An array of three cards representing the cards played by each player formatted like [JD][TH][9S] Representing ...
jacksonecac's user avatar
  • 2,634
12 votes
8 answers
1k views

Blackjack Bust Calculator

Blackjack, also known as twenty-one, is a comparing card game between yourself and a dealer, where each player in turn competes against the dealer, but players do not play against each other. Play ...
DevelopingDeveloper's user avatar
12 votes
7 answers
1k views

Simple Pazaak (Star Wars Card Game from Knights of the Old Republic)

Pazaak is a card game from the Star Wars universe. It is similar to BlackJack, with two players pitted against each other trying to reach a total of twenty without going over. Each player has a "side ...
Michael Brandon Morris's user avatar
12 votes
7 answers
431 views

Bridge Hand Scoring

One of the things that makes contract bridge very interesting is its highly complicated "artificial" meta game. This system of scoring hands is a small part of it. Bridge is a trick-taking ...
a spaghetto's user avatar
  • 11.2k
12 votes
2 answers
415 views

One-card Poker for Two

This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game. Rules of the poker game There are two players, A and B. Each antes $10 into the pot, and is dealt ...
Rosie F's user avatar
  • 417
11 votes
13 answers
825 views

Scoring Briscola

Introduction Briscola is one of Italy's most popular card games. It is a trick-taking card game, like Bridge. Briscola is well known for its bizarre point system. In this challenge, given two cards, ...
Amphibological's user avatar
11 votes
8 answers
781 views

Score counter for Skat

You task is to write a small program, that counts the points of a Skat hand. A Skat deck has cards 7 to 10, Jack, Queen, King and Ace (called Unter, Ober, König and Daus). We use the German suits, ...
FUZxxl's user avatar
  • 10.1k
11 votes
8 answers
3k views

Should the banker hit?

Baccarat is a casino game where gamblers bet on whether one of two hands, the player or the banker, will have a sum closer to 9 (mod 10) or whether they will tie. It is played with four to eight ...
Purple P's user avatar
  • 1,657
11 votes
5 answers
537 views

Display a cribbage score in ASCII

Cribbage is an interesting game, because you need a specific board to score your game. A cribbage board looks like this: Notice how the first column is on the left as it goes up, then on the right as ...
DJMcMayhem's user avatar
  • 59.2k
11 votes
4 answers
544 views

Name the Brag Hand

Background Brag is a card game similar in concept to, but simpler than, poker. A hand in brag consists of three cards and is ranked as follows from highest to lowest: Three of a kind - all three ...
IanF1's user avatar
  • 212
11 votes
2 answers
327 views

Is this a valid Tichu play?

Tichu is a card game in which players take turn playing sets of cards from a deck consisting of a standard 52-card deck, plus 4 additional cards: the dragon, which has a greater value than any other ...
Doorknob's user avatar
  • 71.5k
11 votes
2 answers
208 views

Counting icons for Innovation splays

Innovation is a card game where players battle through the ages, from prehistory to modern times, in an attempt to earn achievements faster than their opponents. Each card in Innovation is unique, ...
Sp3000's user avatar
  • 61.9k