]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/054/054.factor
project-euler: Rewrap, update links, add copyrights, tests
[factor.git] / extra / project-euler / 054 / 054.factor
index 53033a50f32d28dc053859c51e974edce378e3c8..2b5fd4a10ec6c71934efdf37cee527bc5fd8f443 100644 (file)
@@ -1,16 +1,16 @@
 ! Copyright (c) 2009 Aaron Schaefer.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: arrays io.encodings.ascii io.files kernel math.order poker
-    project-euler.common sequences ;
+USING: arrays io.encodings.ascii io.files kernel math.order
+poker project-euler.common sequences ;
 IN: project-euler.054
 
-! https://projecteuler.net/index.php?section=problems&id=54
+! https://projecteuler.net/problem=54
 
 ! DESCRIPTION
 ! -----------
 
-! In the card game poker, a hand consists of five cards and are ranked, from
-! lowest to highest, in the following way:
+! In the card game poker, a hand consists of five cards and are
+! ranked, from lowest to highest, in the following way:
 
 !     * High Card: Highest value card.
 !     * One Pair: Two cards of the same value.
@@ -20,18 +20,20 @@ IN: project-euler.054
 !     * Flush: All cards of the same suit.
 !     * Full House: Three of a kind and a pair.
 !     * Four of a Kind: Four cards of the same value.
-!     * Straight Flush: All cards are consecutive values of same suit.
+!     * Straight Flush: All cards are consecutive values of same
+!       suit.
 !     * Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.
 
 ! The cards are valued in the order:
 !     2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.
 
-! If two players have the same ranked hands then the rank made up of the
-! highest value wins; for example, a pair of eights beats a pair of fives (see
-! example 1 below). But if two ranks tie, for example, both players have a pair
-! of queens, then highest cards in each hand are compared (see example 4
-! below); if the highest cards tie then the next highest cards are compared,
-! and so on.
+! If two players have the same ranked hands then the rank made
+! up of the highest value wins; for example, a pair of eights
+! beats a pair of fives (see example 1 below). But if two ranks
+! tie, for example, both players have a pair of queens, then
+! highest cards in each hand are compared (see example 4 below);
+! if the highest cards tie then the next highest cards are
+! compared, and so on.
 
 ! Consider the following five hands dealt to two players:
 
@@ -54,12 +56,13 @@ IN: project-euler.054
 !            Full House          Full House
 !            With Three Fours    With Three Threes     Player 1
 
-! The file, poker.txt, contains one-thousand random hands dealt to two players.
-! Each line of the file contains ten cards (separated by a single space): the
-! first five are Player 1's cards and the last five are Player 2's cards. You
-! can assume that all hands are valid (no invalid characters or repeated
-! cards), each player's hand is in no specific order, and in each hand there is
-! a clear winner.
+! The file, poker.txt, contains one-thousand random hands dealt
+! to two players. Each line of the file contains ten cards
+! (separated by a single space): the first five are Player 1's
+! cards and the last five are Player 2's cards. You can assume
+! that all hands are valid (no invalid characters or repeated
+! cards), each player's hand is in no specific order, and in
+! each hand there is a clear winner.
 
 ! How many hands does Player 1 win?