Skip to content

Instantly share code, notes, and snippets.

@kruug
Created April 10, 2020 13:41
Show Gist options
  • Save kruug/57691ba9c3987df7f0659de5b3a20263 to your computer and use it in GitHub Desktop.
Save kruug/57691ba9c3987df7f0659de5b3a20263 to your computer and use it in GitHub Desktop.
function guesswinner($rankA, $rankB) {
#$rankA = $args[0]
#$rankB = $args[1]
$randA = Get-Random
$randB = Get-Random
Write-Output $rankA
Write-Output $rankB
$d16A = (( $randA % 16 ) + 1 )
$d16B = (( $randB % 16 ) + 1 )
if ( $($d16A -gt $rankA) -and $($d16B -le $rankB) ) {
# Team A wins and Team B loses
return $rankA
}
elseif ( $($d16A -le $rankA) -and $($d16B -gt $rankB) ) {
# Team A loses and Team B wins
return $rankB
}
else {
# No winner
return 0
}
}
function winner ($teamA, $teamB) {
#$teamA = $args[0]
#$teamB = $args[1]
Write-Output $teamA + " vs " + $teamB + " : "
$count = 0
# Iterate and return winner, if found
while ( $count -lt 10 ) {
$win = guesswinner $teamA $teamB
if ( $win -gt 0) {
# Winner Found
Write-Output $win
return $win
}
$count += 1
}
# No winner found, return a default winner
Write-Output $teamA
return $teamA
}
function playbracket {
Write-Output 'Round 1'
$round1A = winner 1 16
$round1B = winner 8 9
$round1C = winner 5 12
$round1D = winner 4 13
$round1E = winner 6 11
$round1F = winner 3 14
$round1G = winner 7 10
$round1H = winner 2 15
Write-Output 'Round 2'
$round2A = winner($round1A, $round1B)
$round2B = winner($round1C, $round1D)
$round2C = winner($round1E, $round1F)
$round2D = winner($round1G, $round1H)
Write-Output 'Round 3'
$round3A = winner($round2A, $round2B)
$round3B = winner($round2C, $round2D)
Write-Output 'Round 4'
$champion = winner($round3A, $round3B)
}
Write-Output "___ MIDWEST ___"
playbracket
Write-Output "___ EAST ___"
playbracket
Write-Output "___ WEST ___"
playbracket
Write-Output "___ SOUTH ___"
playbracket
import random
import time
def guesswinner( rankA, rankB ):
#random.seed(time.process_time())
d16A = ( ( ( random.random() * 32767) % 16 ) + 1 )
#random.seed(time.process_time())
d16B = ( ( ( random.random() * 32767) % 16 ) + 1 )
#print(str(d16A) + " : " + str(d16B))
if ( ( d16A > rankA ) and ( d16B <= rankB ) ):
# Team A wins and Team B loses
return rankA
elif ( ( d16A <= rankA ) and ( d16B > rankB ) ):
# Team A loses and Team B wins
return rankB
else:
# No winner
return 0
def winner( teamA, teamB ):
output = str(teamA)
output += " vs "
output += str(teamB)
output += " : "
#print str(teamA) + " vs " + str(teamB) + " : "
print(output, end='')
count = 0
# Iterate and return winner, if found
while ( count < 10 ):
win = guesswinner(teamA, teamB)
if ( win > 0 ):
# Winner found
print(win)
return win
count += 1
# No winner found, return a default winner
print(teamA)
return teamA
def playbracket():
print('Round 1')
round1A = winner(1, 16)
round1B = winner(8, 9)
round1C = winner(5, 12)
round1D = winner(4, 13)
round1E = winner(6, 11)
round1F = winner(3, 14)
round1G = winner(7, 10)
round1H = winner(2, 15)
print('Round 2')
round2A = winner(round1A, round1B)
round2B = winner(round1C, round1D)
round2C = winner(round1E, round1F)
round2D = winner(round1G, round1H)
print('Round 3')
round3A = winner(round2A, round2B)
round3B = winner(round2C, round2D)
print('Round 4')
return winner(round3A, round3B)
print('\n___ MIDWEST ___')
playbracket()
print('\n___ EAST ___')
playbracket()
print('\n___ WEST ___')
playbracket()
print('\n___ SOUTH ___')
playbracket()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment