id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
0967a87d-f924-4e47-b4e9-58ef6fc995b0 | private static void runTestCase()
{
/* it's been such a */ long time /* I think I should be goin' */ = System.currentTimeMillis();
long compilationTime = 0;
long solveTime = 0;
for (int trials = 0; trials < 50; trials++)
{
int count = 100;
Episode epp = n... |
77ceeca8-0b1c-4bc2-87c9-e3c91336376a | public Vote(Episode ep, int keepThisGuy, int kickThisGuy, VoteType forCatOrDog)
{
this.ep = ep;
this.keepThisGuy = keepThisGuy;
this.kickThisGuy = kickThisGuy;
this.forCatOrDog = forCatOrDog;
this.catChoice = forCatOrDog == VoteType.forCat? keepThisGuy : kickThisGu... |
f788a73a-5408-4f51-9795-f5b8514943f0 | public Vote(int keepThisGuy, int kickThisGuy)
{
this.keepThisGuy = keepThisGuy;
this.kickThisGuy = kickThisGuy;
} |
735eab76-26d2-4d9f-921a-b87f3eb02643 | public int getVoteToKeep()
{
return keepThisGuy;
} |
3c1077e9-948d-42b5-ba52-8e73104a15da | public int getVoteToKick()
{
return kickThisGuy;
} |
0d72cdbf-dc7e-4c57-af5f-cdebea07c36f | public int getCatChoice()
{
return this.catChoice;
} |
adb20881-3cc7-4a91-85b5-57280921e38b | public int getDogChoice()
{
return this.dogChoice;
} |
ef2c4e7d-1bfd-45ae-a540-79d165d37314 | public VoteType getVoteType()
{
return forCatOrDog;
} |
81e0d475-d811-4209-ba3b-8f041cf33076 | @Override
public String toString()
{
return "(" + (forCatOrDog == VoteType.forCat? "C" : "D") + (this.keepThisGuy + 1) + ", "
+ (forCatOrDog == VoteType.forCat? "D" : "C") + (this.kickThisGuy + 1) + ")";
} |
24a754ad-3a3d-4af5-885a-cda20e1ebedf | private void validateVote()
{
int catVote = this.getVoteType() == VoteType.forCat? this.getVoteToKeep() : this.getVoteToKick();
int dogVote = this.getVoteType() == VoteType.forDog? this.getVoteToKeep() : this.getVoteToKick();
if (catVote < 0 || catVote >= ep.getNumCats())
{
... |
f2d335d7-f7b6-4eec-aed5-5db6326afd3c | public Episode(int numCats, int numDogs)
{
this.numCats = numCats;
this.numDogs = numDogs;
} |
36a30e78-e6ef-4343-aef8-db88b393de03 | public int getNumCats()
{
return numCats;
} |
a7a02464-84b5-4634-9332-06f9e5622cb8 | public int getNumDogs()
{
return numDogs;
} |
63931666-bd62-4391-b762-d0567212cc79 | public VoteResultFinder(VotingRound votingRound)
{
List<Vote> votes = votingRound.getVotes();
int voteCount = votes.size();
this.voterGraph = new DirectedGraph(2 + voteCount, null); // one node per voter + source & sink nodes
this.sourceNode = this.voterGra... |
0a62f38a-8746-4acd-9a18-7fd234a534ed | public int determineMaxHappyVoterCount()
{
List<Integer> shortestPath;
// Nodes connected to edges in the current matching. Will ultimately be the set of
// nodes connected to edges in the maximum matching (Note that the actual edges
// need not be recorded)
Li... |
f95a9567-9871-4717-9e15-4a46f26abe57 | public HandRank(List<Card> cards)
{
Collections.sort(cards); // Lowest to highest
for(int i = 0 ; i < 9 ; i ++){
missingCards[i] = 0;
try {
bestCard[i] = new Card('C','2');
} catch (Exception e) {
e.printStackTrace();
}
try {
secondBestCard[i%2] = new Card('C','2');
... |
d374c0b8-42a8-43ed-877e-96d6b0f22034 | public HandRank(Hand h) {
this(h.getHand());
//assessedHand = h;
} |
00616f82-72c4-4aca-af46-8d21dbace89d | public int compareTo(HandRank x) // 1 <-> this wins; 0 <-> tie; -1 <-> x wins
{
for(int i = 0 ; i < 9 ; i ++)
{
if(this.missingCards[i] == 0 && x.missingCards[i] != 0){
return 1;
}
if(this.missingCards[i] != 0 && x.missingCards[i] == 0){
return -1;
}
if(this.missingCards[i] == 0 && x.missing... |
d9fe2f02-6315-4d6f-9e27-956b892b13ce | protected void checkStraightFlush(List<Card> cards)
{
int[] anyCard = new int[14];
for(int i = 0 ; i < 14 ; i ++){
anyCard[i] = -1;
}
for(int i = 0 ; i < cards.size() ; i ++){
int it = cards.get(i).getCardValue();
anyCard[it+1] = i;
}
anyCard[0] = anyCard[13];
int cnt = 0;
for(int... |
abc32e3c-c5ac-4225-9d61-9ad2d82740d9 | protected void checkFour(List<Card> cards)
{
for(int i = cards.size()-1 ; i >= 0 ; i --)
{
for(int j = i-1 ; j >= 0 ; j --)
{
for(int k = j-1 ; k >= 0 ; k --)
{
for(int l = k-1 ; l >= 0 ; l --)
{
if(cards.get(i).compareTo(cards.get(j)) == 0 && cards.get(j).compareTo(cards.get(k)) == ... |
66576da8-545e-40ec-aa99-659bbbec3d8e | protected void checkFull(List<Card> cards)
{
if(missingCards[5] == 0 && missingCards[6] == 0){
missingCards[2] = 0;
bestCard[2] = bestCard[5];
secondBestCard[1] = (secondBestCard[0] == bestCard[5]) ? bestCard[6] : secondBestCard[0];
return;
}
if(missingCards[5] == 0 && missingCards[6] == 1... |
424e1b35-273d-4e06-a31c-533d89abce00 | protected void checkFlush(List<Card> cards)
{
List<Integer> Spades = new ArrayList<Integer>();
List<Integer> Hearts = new ArrayList<Integer>();
List<Integer> Diamonds = new ArrayList<Integer>();
List<Integer> Clubs = new ArrayList<Integer>();
for(int i = 0 ; i < cards.size() ; i ++)
{
char tmp... |
65635a72-ac36-446b-9e3c-5db75cba185a | protected void checkStraight(List<Card> cards)
{
int[] anyCard = new int[14];
for(int i = 0 ; i < 14 ; i ++){
anyCard[i] = -1;
}
for(int i = 0 ; i < cards.size() ; i ++){
int it = cards.get(i).getCardValue();
anyCard[it+1] = i;
}
anyCard[0] = anyCard[13];
int cnt = 0;
for(int i... |
c708ada8-a599-41ec-814e-d57c178c821d | protected void checkThree(List<Card> cards)
{
for(int i = cards.size()-1 ; i >= 0 ; i --)
{
for(int j = i-1 ; j >= 0 ; j --)
{
for(int k = j-1 ; k >= 0 ; k --)
{
if(cards.get(i).compareTo(cards.get(j)) == 0 && cards.get(j).compareTo(cards.get(k)) == 0){
missingCards[5] = 0;
bestCard... |
b27e6400-2990-48ca-aba6-8aafd45eedf3 | protected void checkTwoPair(List<Card> cards)
{
boolean foundOnePair = false;
for(int i = cards.size()-1 ; i >= 0 ; i --)
{
for(int j = i-1 ; j >= 0 ; j --)
{
if(cards.get(i).compareTo(cards.get(j)) == 0)
{
if(!foundOnePair){
foundOnePair = true;
missingCards[6] = 1;
b... |
289a9c1c-9085-4dc9-a195-2fafed2519a1 | protected void checkOnePair(List<Card> cards)
{
for(int i = cards.size()-1 ; i >= 0 ; i --)
{
for(int j = i-1 ; j >= 0 ; j --)
{
if(cards.get(i).compareTo(cards.get(j)) == 0){
missingCards[7] = 0;
bestCard[7] = cards.get(i);
return;
}
}
}
missingCards[7] = 1;
bestCard... |
d0d6ed39-21ca-4a8e-8532-d8b28288db65 | protected void checkHighCard(List<Card> cards) {
missingCards[8] = 0;
bestCard[8] = cards.get(cards.size()-1);
} |
6074de60-5e7e-43fd-adda-a923b7e00454 | public static String strategy1(int accountBalance, int biddingRoundNumber, int startBalance, int currentBalance, boolean amIBluffing, HandRankBot hrb)
{
if(biddingRoundNumber == 1)
{
if(accountBalance-currentBalance > 0)
{
if(currentBalance == 0){
return "CHECK";
}
if((double)currentBal... |
aa4de200-d2bc-4786-a12e-a917a7079f4c | ClientThread() {} |
7eaf6091-5d0b-4690-a24e-0a73e8086d5e | ClientThread(int id) {
this.id = id;
deck = Deck.getInstance();
//A lock for further synchronization of clients' threads is created
if (lock == null)
lock = new Object();
} |
a28908be-cdbc-4d16-a4bf-e3fe43a0e8f7 | @Override
public void run() {
try {
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(), true);
}
catch (IOException e) {
System.out.println("#"+id+": Unable to reach client.");
}
msgr =... |
ca3aec1f-b1df-42db-8254-dd445b165f31 | public void bindSocket(Socket newSocket) {
socket = newSocket;
} |
4bbbacae-8bce-4efb-937b-6a31d2d2f5f9 | public BufferedReader getInputStream() {
return in;
} |
d9b0b0bb-f74a-47c3-9b71-54069bd70d0b | public PrintWriter getOutputStream() {
return out;
} |
07b1cd86-0cba-4d3a-bd54-603de0101942 | public void changeHand(String msg) {
String localStr = Server.getHandOfId(id);
if (!msg.startsWith(localStr)) {
msgr.broadcast("ERROR|CHEAT");
System.out.println("Cheater (player #"+id+") kicked.");
finalize();
}
String arr[] = msg.split("\\|");
if (arr.length <= 5){
System.out.println... |
c23fb6c9-c423-45fe-b893-6e9b757634cc | public void bet(String param) {
String[] params = param.split("\\|");
PlayerData pd;
pd = Server.getPlayerData(id);
int currentBalance = pd.getBalance();
boolean isDone = false;
int bet = 0;
switch (params[0]) {
case "CHECK":
if (highestBet != 0) {
msgr.broadcast("ERROR|BET|Unable to check wh... |
c8404fab-4fed-4fcb-bd59-82cac45dbfa6 | public void moveLockToNextPlayer() {
synchronized (lock) {
int newID = (allowedThread+1)%(getServer().players);
for (int i=0; i<getServer().players; i++) {
if (!Server.getPlayerData(newID).isInGame())
newID++;
}
allowedThread=newID;
lock.notifyAll();
}
} |
4c5ad592-e3d8-48f4-b3c4-beb9e570cef3 | public void setPlayerName(String name) {
if (name.equals("Player") || name.equals("Bot"))
name+=" "+String.valueOf(id);
Server.getPlayerData(id).setName(name);
myName = name;
System.out.println("Player #"+id+" is now: "+name);
} |
e1d1456f-f9e7-458d-aa53-4e37848cdc70 | public Hand generateHand() throws Exception {
String cmd = "SETHAND";
String handStr = "";
//Pull 5 cards from deck
for (int i=0; i<5; i++) {
try {
handStr += deck.pullCardToString();
}
catch (Exception e) {
e.printStackTrace();
}
if (i!=4) handStr+="|";
}
//Send Hand ... |
926b16ce-24fa-48ab-9819-75a6fd20bdaf | public void displayAccount(int money) {
msgr.broadcast("DISPLAYMONEY|"+money);
} |
bd9b7dba-7cc7-44d2-8d26-98cc6c58e7e9 | @Override
public void finalize() {
System.out.println("Player #"+id+" has left the table.");
getServer().detachPlayer(id);
try {
super.finalize();
}
catch (Throwable ex) {}
} |
ceaa8551-b180-45bb-a409-d625fbf93048 | @Override
public void interrupt() {
msgr.broadcast("END");
super.interrupt();
} |
356843a3-a17d-46cd-ac36-44ca5b3a3577 | public void queueBroadcast(String msg) {
synchronized (lock) {
while (allowedThread != id) {
try {
lock.wait();
}
catch(InterruptedException ex) {}
}
}
try {
sleep(1000);
} catch (InterruptedException e) {}
msgr.broadcast(msg);
} |
2f371c01-2d3a-4761-981d-0c05c96b4f2f | public Messenger getMsgr() {
return msgr;
} |
902d94f0-8d0e-43ae-a752-925cdeadfaba | public void win() {
msgr.broadcast("WIN");
} |
d0ff06c1-82a3-4920-bd5e-17d7889d103a | public void tie() {
msgr.broadcast("TIE");
} |
1373345a-2eb8-42a9-8262-9b2031daf9dd | public void lost() {
msgr.broadcast("LOST");
} |
a8ee6c22-b39d-48ec-8a4e-f31eb927d98b | public void setHand(String handStr) {
getServer().setHandOfId(id, handStr);
} |
43a67f74-d216-442e-b83c-b6fbba18b795 | public int getID() {
return id;
} |
73521bfa-c012-4d8b-a87e-f4fc975b1690 | public Server getServer() {
return Server.getInstance();
} |
5da4800b-f737-4a89-8570-19735f8c5ab3 | public static int getHighestBet() {
return highestBet;
} |
cb8f7a14-67ec-45a0-9287-fd792686a4d3 | public static void resetBet() {
previousBet = 0;
highestBet = 0;
} |
63a65982-7be5-42c0-847d-b217413980d1 | public static void resetAllowedThread() {
allowedThread = 0;
} |
2723c01a-bc4e-49bd-a2da-ad6329f85a3b | public PlayerData() {
hand = null;
name = null;
previousBet = balance = wins = 0;
sentWins = false;
inGame = true;
} |
8a623a62-6af9-4936-8abb-c58bbaace853 | public String getName() {
return name;
} |
89c8a0e2-8ff3-4c15-a141-b1dfa7a42499 | public void setName(String name) {
this.name = name;
} |
0034dcd8-e717-445d-9fbf-32046f55ac41 | public int getBalance() {
return balance;
} |
dd8c94e4-c268-4a86-9c6a-7d071d6822ee | public void setBalance(int balance) {
this.balance = balance;
} |
edbaad38-0eaf-4eaf-9ab6-e5f42b9b5038 | public void addBalance(int balance) {
this.balance += balance;
} |
7ba4f7a5-bc10-4e8b-a6b5-23e9587a81b4 | public Hand getHand() {
return hand;
} |
93a0d0af-a1ed-4978-bc7e-e37740281cec | public String getHandToString() {
return hand.toString();
} |
14e61fbc-17ea-46c5-8be3-4572f33eba26 | public void setHand(Hand hand) {
this.hand = hand;
} |
487803d8-f23e-42f5-93c6-2f1387e84807 | public Integer getWins() {
return wins;
} |
b23c3ab2-0b36-4893-a55a-d2fe0d756d7d | public void setWins(int wins) {
this.wins = wins;
} |
7ec46349-c6d4-4d85-a9e0-e76e44f8376b | public void setSentWins() {
sentWins = true;
} |
cf70f21f-eb6f-4d39-b7fd-e23fa4518354 | public int compareTo(PlayerData d) {
if (getWins() > d.getWins())
return 1;
else if (getWins() == d.getWins())
return 0;
else return -1;
} |
41ff450f-a447-4131-ad71-cdee93113bb6 | public boolean isSentWins() {
return sentWins;
} |
393b2609-ae9a-45f9-a28c-200e6da563d8 | public boolean isInGame() {
return inGame;
} |
5ff6c08d-5e58-4927-82a2-e113ed89d2f9 | public void setInGame(boolean inGame) {
this.inGame = inGame;
} |
64aef032-e3be-4bc7-91df-4b484b924a80 | public int getPreviousBet() {
return previousBet;
} |
ab2be4f1-3bef-4646-9107-1eb8f8aa2805 | public void setPreviousBet(int previousBet) {
this.previousBet = previousBet;
} |
6eb0f53b-cb87-4c87-88c9-f15d3558c39e | Human(String host, int port) {
super(host, port);
} |
a10360a0-8a30-45f6-938f-7c52981cf7f9 | public void run() {
connect();
} |
5fe46f61-907e-4cfa-9250-a2faa3f1feed | public void promptChange()
{
int a;
System.out.println("How many cards do you wish to change? (0-4)");
String str = input.next();
try {
a = Integer.parseInt(str);
}
catch (NumberFormatException ex) {
System.err.println("This was not amount of cards to change.");
promptChang... |
ea12aaf5-4a7a-46eb-83a3-908bb305b601 | public void setMoneyAtBeginning() {} |
44d43d63-004d-43c2-81bf-1360a07fbced | @Override
public void promptBet(String data) {
System.out.println("RAW BET PROMPT: ");
String params = input.nextLine();
msgr.broadcast("SETBET|"+params);
} |
ef01b9d8-8f68-4a08-8d86-421507444857 | @Override
public String promptName() {
System.out.println("Enter your name:");
String name = "Player";
name = input.nextLine();
return name;
} |
1580630a-8fd0-4356-974a-b039452ecc4f | public Hand(String s) throws Exception
{
cards = new ArrayList<Card>(5);
String[] arr = s.split("\\|");
Card addedCard = null;
for (String cardString: arr)
{
try {
addedCard = new Card(cardString.charAt(0), cardString.charAt(1));
}
catch(Exception ex) {
throw new Exception("Failed to crea... |
cf3048b3-6e80-45f2-b632-49bc94803061 | public List<Card> getHand(){
sort();
return cards;
} |
f7974101-329e-4467-bfb0-35d55afa9c2a | public String toString() {
String out="";
for (Card c: cards) {
out+=c.getColor()+""+c.getCard()+"|";
}
return out.substring(0, out.length()-1);
} |
9de85ff3-f352-4366-bf9f-9085031290f1 | public boolean includes(String s)
{
Card c = null;
try {
c = new Card(s.charAt(0), s.charAt(1));
} catch (Exception e) {
e.printStackTrace();
return false;
}
for (Card v: cards)
if (v.toString().equals(c.toString()))
return true;
return false;
} |
7d505ebf-4af2-4fe9-ab06-81b6519977da | public void sort() {
Collections.sort(cards);
} |
40c173dd-99df-49aa-b666-877e5457054e | @Override
public int compareTo(Hand o) {
return handRank.compareTo(o.getHandRank());
} |
09349667-9e20-4d59-a92c-a1b117093b6a | public HandRank getHandRank() {
return handRank;
} |
42cbac53-3125-458e-be2e-33c744863e62 | public HandRankBot(String x) throws Exception {
super(new Hand(x));
} |
a1d6bb00-8fcb-4497-b1c5-b077c390bd1e | public HandRankBot(List<Card> cards){
super(cards);
} |
b2f3fe1e-0e1b-423d-9d4b-c0fc99e8383f | public HandRankBot(Hand x){
super(x);
} |
07218e25-9202-4c80-a9c8-dc4a73ff6c4c | public int getBestId()
{
for(int i = 0 ; i < 9 ; i ++)
{
if(missingCards[i] == 0){
return i;
}
}
return 10;
} |
a724fa5a-2aa1-4e1e-962c-343ca5e54cdd | public List<Card> getChangeList(List<Card> cards)
{
for(int i = 0 ; i < 9 ; i ++)
{
if(missingCards[i] == 1 || missingCards[i] == 0)
{
switch(i){
case 0: return getStraightFlush(cards);
case 1: return getFour(cards);
case 2: return getFullHouse(cards);
case 3: return getFlush(cards);
... |
1cb7ee11-0abf-4f09-b285-5ae8e238e2e6 | public List<Card> getChangeList(Hand x){
return getChangeList(x.getHand());
} |
aadcc672-5718-410e-83ac-e4dcc3777907 | public List<Card> getChangeList(String x){
List<Card> ret = null;
try {
ret = getChangeList(new Hand(x).getHand());
} catch (Exception e) {
e.printStackTrace();
}
return ret;
} |
e16ce003-6f7e-46b9-bfdb-5d02c3f16097 | private List<Card> getHighCard(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[8].getCardValue()){
ret.add(cards.get(i));
}
}
return ret;
} |
edccc2b6-9724-425d-9f07-087c4d51e066 | private List<Card> getOnePair(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[7].getCardValue()){
ret.add(cards.get(i));
}
}
return ret;
} |
22309177-0520-4b89-b2f9-044ee38849a7 | private List<Card> getTwoPair(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[6].getCardValue() && cards.get(i).getCardValue() != secondBestCard[0].getCardValue()){
ret.add(cards.get(i));
}
}
ret... |
bb0ec459-ad96-49cd-9305-316bd9977cf4 | private List<Card> getThree(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[5].getCardValue()){
ret.add(cards.get(i));
}
}
return ret;
} |
f464b91a-2928-4977-b1e1-59f330142821 | private List<Card> getStraight(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
int minValue = 13;
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() > bestCard[4].getCardValue()-5 && cards.get(i).getCardValue() <= bestCard[4].getCardValue()){
minValue = Math.min(min... |
f49ff1bf-c689-4b49-ada4-cd0b323be6f1 | private List<Card> getFlush(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getColorValue() != bestCard[3].getColorValue()){
ret.add(cards.get(i));
}
}
return ret;
} |
39462633-4165-4fe4-9517-0e6e1d7c042d | private List<Card> getFullHouse(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[2].getCardValue() && cards.get(i).getCardValue() != secondBestCard[1].getCardValue()){
ret.add(cards.get(i));
}
}
r... |
e5b888f5-cf03-41dc-904c-b20e25701cbb | private List<Card> getFour(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() != bestCard[1].getCardValue()){
ret.add(cards.get(i));
}
}
return ret;
} |
810ca65e-56e6-4836-8133-12bc69af29ea | private List<Card> getStraightFlush(List<Card> cards)
{
List<Card> ret = new ArrayList<Card>();
int minValue = 13;
for(int i = 0 ; i < cards.size() ; i ++)
{
if(cards.get(i).getCardValue() > bestCard[0].getCardValue()-5 && cards.get(i).getCardValue() <= bestCard[0].getCardValue() && cards.get(i).getColor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.