Python Forum
Dice and Random Variables
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dice and Random Variables
#1
Hello! I am taking a combinatorics and probability course and the final project requires us to use python. I am a complete newb and have no idea where to even start. I understand all of the concepts however I do not have any background in python. Any advice, help, hints would be greatly appreciated. You don't need to directly answer the question as I too would like to be challenged, however some guidance would be awesome.

Here is the first question.

Implement a function that takes two dices as input and computes two values: the first value is the number of times the first dice wins (out of all possible 36 choices), the second value is the number of times the second dice wins. We say that a dice wins if the number on it is greater than the number on the other dice.

To debug your implementation, use the following test cases:

Sample 1

Input: dice1 = [1, 2, 3, 4, 5, 6], dice2 = [1, 2, 3, 4, 5, 6]

Output: (15, 15)


def count_wins(dice1, dice2):
assert len(dice1) == 6 and len(dice2) == 6
dice1_wins, dice2_wins = 0, 0

# write your code here

return (dice1_wins, dice2_wins)
Reply
#2
Do you have a specific question / problem?
Reply
#3
Yes. Sorry. This is the prompt.

"Project Overview

In this series of three programming tasks, we will implement together a program that will play optimally in a tricky dice game! You program will be given a list of dices and will decide who chooses the dice first (you or your opponent).

When the dices are chosen, we will simulate 10000 throws. Each time your number is greater, you get $1 from your opponent. Conversely, each time your number is smaller, you pay $1 to your opponent.

Your ultimate goal is to implement a program that always wins in such a simulation."
Reply
#4
That's the question that's been posed to you, but we want to know your question. Your question should be the smallest possible that will allow you to get to unblocked so you can continue with your task yourself.

Note: if you're blocked on code, make sure to post the smallest snippet that reproduces your problem, but is still runnable, and make sure it's in code tags so we get the indentation. An explanation is also important, not just some codeĀ  :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Optimisation the rejection method of generating random variables Hummingbird 2 2,358 Apr-21-2019, 01:02 PM
Last Post: priyanshu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020