# Thread: is this really right

1. ## is this really right

i am working on a way of scoring the hands of poker to determine the winner. im sure there has to be a better way than this because the numbers end up huge.
9,314,160 for the max score but as you can see from the code below (if i haven't made a mistake) that's what they are.
Code:
```#include <stdio.h>
#include <stdlib.h>
#define SFLUSH 394
#define FOURKIND 212
#define FULLHOUSE 85
#define FLUSH 38
#define STRAIGHT 22
#define THREEKIND 12
#define TWOPAIR 5
#define PAIR 2
int main()
{
int pair_max, pair_min, two_pair_max, two_pair_min, three_kind_max, three_kind_min, straight_min, straight_max;
long int flush_min, flush_max, full_house_min, full_house_max, four_kind_min, four_kind_max, straight_flush_min, straight_flush_max;

straight_flush_max = 14 * SFLUSH + 13 * SFLUSH + 12 * SFLUSH + 11 * SFLUSH + 10 * SFLUSH;
straight_flush_max *= SFLUSH;

straight_flush_min = 6 * SFLUSH + 5 * SFLUSH + 4 * SFLUSH + 3 * SFLUSH + 2 * SFLUSH;
straight_flush_min *= SFLUSH;

four_kind_max = 14 * FOURKIND + 14 * FOURKIND + 14 * FOURKIND + 14 * FOURKIND + 13 * FOURKIND;
four_kind_max *= FOURKIND;

four_kind_min = 2 * FOURKIND + 2 * FOURKIND + 2 * FOURKIND + 2 * FOURKIND + 3 * FOURKIND;
four_kind_min *= FOURKIND;

full_house_max = 14 * FULLHOUSE + 14 * FULLHOUSE + 14 * FULLHOUSE + 13 * FULLHOUSE + 13 * FULLHOUSE;
full_house_max *= FULLHOUSE;

full_house_min = 2 * FULLHOUSE + 2 * FULLHOUSE + 2 * FULLHOUSE + 3 * FULLHOUSE + 3 * FULLHOUSE;
full_house_min *= FULLHOUSE;

flush_max = 14 * FLUSH + 13 * FLUSH + 12 * FLUSH + 11 * FLUSH + 9 * FLUSH;
flush_max *= FLUSH;

flush_min = 2 * FLUSH + 3 * FLUSH + 4 * FLUSH + 5 * FLUSH + 7 * FLUSH;
flush_min *= FLUSH;

straight_max = 14 * STRAIGHT + 13 * STRAIGHT + 12 * STRAIGHT + 11 * STRAIGHT + 10 * STRAIGHT;
straight_max *= STRAIGHT;

straight_min = 2 * STRAIGHT + 3 * STRAIGHT + 4 * STRAIGHT + 5 * STRAIGHT + 6 * STRAIGHT;
straight_min *= STRAIGHT;

three_kind_max = 14 * THREEKIND + 14 * THREEKIND + 14 * THREEKIND + 13 * THREEKIND + 12 * THREEKIND;
three_kind_max *= THREEKIND;

three_kind_min = 2 * THREEKIND + 2 * THREEKIND + 2 * THREEKIND + 3 * THREEKIND + 4 * THREEKIND;
three_kind_min *= THREEKIND;

two_pair_max = 14 * TWOPAIR + 14 * TWOPAIR + 13 * TWOPAIR + 12 * TWOPAIR + 11 * TWOPAIR;
two_pair_max *= TWOPAIR;

two_pair_min = 2 * TWOPAIR + 2 * TWOPAIR + 3 * TWOPAIR + 4 * TWOPAIR + 5 * TWOPAIR;
two_pair_min *= TWOPAIR;

pair_max = 14 * PAIR + 14 * PAIR + 13 * PAIR + 12 * PAIR + 11 * PAIR;
pair_max *= PAIR;

pair_min = 2 * PAIR + 2 * PAIR + 3 * PAIR + 4 * PAIR + 5 * PAIR;
pair_min *= PAIR;

printf("straight FLUSH max = %ld\n", straight_flush_max);
printf("straight FLUSH min = %ld\n", straight_flush_min);
printf("four of a kind max = %ld\n", four_kind_max);
printf("four of a kind min = %ld\n", four_kind_min);
printf("full house max = %ld\n", full_house_max);
printf("full house min = %ld\n", full_house_min);
printf("flush max = %ld\n", flush_max);
printf("flush min = %ld\n", flush_min);
printf("straight max = %d\n", straight_max);
printf("straight min = %d\n", straight_min);
printf("three of a kind max %d\n", three_kind_max);
printf("three of a kind min %d\n", three_kind_min);
printf("2 pair max = %d\n", two_pair_max);
printf("2 pair min = %d\n", two_pair_min);
printf("pair max = %d\n", pair_max);
printf("pair min = %d\n", pair_min);
printf("single card max = 59\n");
printf("single card min = 21");
return 0;
}```
gives the output of
Code:
```straight FLUSH max = 9314160
straight FLUSH min = 3104720
four of a kind max = 3101136
four of a kind min = 494384
full house max = 491300
full house min = 86700
flush max = 85196
flush min = 30324
straight max = 29040
straight min = 9680
three of a kind max 9648
three of a kind min 1872
2 pair max = 1600
2 pair min = 400
pair max = 256
pair min = 64
single card max = 59
single card min = 21```
i did suddenly realise when i was nearly done that if i added the face values together then multiplyed by the multiplyer ^ 2 i got the same result so it ould be easy to break it down into a function to add the values toether and another to multiply everything
many thanks
coop

2. I don't know jack about poker, but this stackoverflow answer seems like it explains it pretty good:
Algorithm to give a value to a 5 card Poker hand - Stack Overflow