Embercode
✕
Dynamic ProgrammingQuick quiz

Dice probability

7 questions. Covers Probability and counting DP with modulo.

Questions 1 to 5 of 7

  1. 1. Two standard dice (faces 1 to 6) are rolled. How many of the 36 equally likely outcomes give a total of 7?

    Type a number.

  2. 2. What does this program print? It counts the ways for two dice with 4 faces and keeps the totals 0 to 5. ``cpp #include <iostream> #include <utility> #include <vector> int main() { std::vector<int> prev(6, 0); prev[0] = 1; for (int i = 1; i <= 2; ++i) { std::vector<int> curr(6, 0); for (int s = 0; s <= 5; ++s) { for (int f = 1; f <= 4 && f <= s; ++f) { curr[s] += prev[s - f]; } } prev = std::move(curr); } std::cout << prev[5] << ' ' << prev[2] << '\n'; } ``
  3. 3. How many equally likely outcomes are there when three dice with 6 faces are rolled?

    Type a number.

  4. 4. The lesson says 6 / 36 gives 0 when both numbers are integers. Why must a probability never be made by dividing two integer counts?
  5. 5. What does this program print? ``cpp #include <cstdint> #include <iostream> int main() { std::uint64_t ways = 6; std::uint64_t outcomes = 36; std::cout << ways / outcomes << ' ' << (ways * 6) / outcomes << '\n'; } ``

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.