Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Threading;
- namespace Gambling
- {
- class Gambling
- {
- static void Main()
- {
- Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
- decimal cash = decimal.Parse(Console.ReadLine());
- decimal potValue = 2m*cash;
- string houseHand = Console.ReadLine();
- string[] houseCards = houseHand.Split(' ');
- Dictionary<string,int> dict = new Dictionary<string, int>();
- dict.Add("J",11);
- dict.Add("Q",12);
- dict.Add("K",13);
- dict.Add("A",14);
- string[] cardFaces = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
- int[] cardValues = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
- int houseStrength = 0;
- int betterHandsCount = 0;
- int allHands = 0;
- for (int i = 0; i < 4; i++)
- {
- if (dict.ContainsKey(houseCards[i]))
- {
- houseStrength += dict[houseCards[i]];
- }
- else
- {
- houseStrength += Convert.ToInt32(houseCards[i].ToString());
- }
- }
- for (int i = 0; i < cardFaces.Length; i++)
- {
- for (int j = 0; j < cardFaces.Length; j++)
- {
- for (int k = 0; k < cardFaces.Length; k++)
- {
- for (int l = 0; l < cardFaces.Length; l++)
- {
- string[] tempCombo = {cardFaces[i], cardFaces[j], cardFaces[k], cardFaces[l]};
- if (tempCombo != houseCards)
- {
- int tempWeight = cardValues[i] + cardValues[j] + cardValues[k] + cardValues[l];
- if (tempWeight>houseStrength)
- {
- betterHandsCount++;
- allHands++;
- }
- else
- {
- allHands++;
- }
- }
- }
- }
- }
- }
- decimal percentage = GetPercentage(betterHandsCount, allHands);
- if (percentage<50)
- {
- Console.WriteLine("FOLD");
- }
- else
- {
- Console.WriteLine("DRAW");
- }
- decimal expectedWinnings = (percentage*potValue)/100;
- Console.WriteLine("{0:0.00}",Math.Round(expectedWinnings,2));
- }
- public static Decimal GetPercentage(Int32 value, Int32 total)
- {
- Decimal percent = 0;
- if (value == 0 || total == 0)
- {
- percent = 0;
- }
- else
- {
- percent = Decimal.Divide(value, total) * 100;
- }
- return percent;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment