Skip to content

Instantly share code, notes, and snippets.

@ironboy
Created April 19, 2023 12:12
Show Gist options
  • Save ironboy/c7ad4ecb0acdd1d463ef288376710aa9 to your computer and use it in GitHub Desktop.
Save ironboy/c7ad4ecb0acdd1d463ef288376710aa9 to your computer and use it in GitHub Desktop.
Straights.... (pokerhand test - example loop)
const ranks = '23456789TJQKA';
const suits = '♥♦♣♠';
// Fake class for hand
// replace with importing real class
class Hand {
constructor() {
console.log([...arguments])
}
}
// Move to straight test
for (let suit of suits) {
for (let rank of 'A23456789T') {
let ranksForHand = '';
if (rank === 'A') { ranksForHand = 'A2345'; }
else {
let index = ranks.indexOf(rank);
ranksForHand += ranks.slice(index, index + 5);
}
new Hand(...[...ranksForHand].map(x => suit + x));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment