Skip to content

Instantly share code, notes, and snippets.

@dheerajrav
Created October 27, 2012 20:31

Revisions

  1. Dheeraj revised this gist Oct 27, 2012. No changes.
  2. Dheeraj revised this gist Oct 27, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Random number generator
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    1. Why isn't the answer 1/4 and 1/2 for the first sample test case.
    1. Why isn't the answer 1/4 for the first sample test case.

    ans: The trick lies in the space the input rests in. Its REAL numbers and not INTEGERS. So, the asnwer is 1/2 and not 1/4.

    2. If a random number generates between 0 and M are 0 and M included? Does it affect my strategy if I assume either?
    2. If a random number generates between 0 and M are 0 and M included does it affect my strategy if I assume either?

    ans: No! Real numbers have a limit of 0 at any integer value. Its always limiting. So, it doesn't matter if 0 and M are included or excluded. For clarity sake a random number generates a number in the range [0..M]
  3. Dheeraj revised this gist Oct 27, 2012. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions nCr
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    1. Output not matching

    ans: The answer is num%142857 and not just the nCr answer.

    2. 142857 isn't a prime. Is it intentional?

    ans: Yes!! it is intentional. Some numbers are special and 142857 is one among them though it isn't a prime
  4. Dheeraj created this gist Oct 27, 2012.
    6 changes: 6 additions & 0 deletions Bowling
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    1. How is the third test case in the sample test case 1?

    ans: for the testcase 1 25, only 1 situation is possible. A Strike, A spare and an extra ball using which we can get a 5. 10 9 6 isn't a valid bowling score as for that frame, a strike in the first try and a 9 in the second try will leave 1 pin on the bowling alley and not 6. Hence only 1 valid case results in a score of 25.

    For more information on bowling scoring check
    https://en.wikipedia.org/wiki/Ten-pin_bowling#Rules_of_play
    5 changes: 5 additions & 0 deletions Exchange
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    1. Is the matrix symmetric?
    ans: Yes

    2. Is the permutation transitive?
    ans: yes. Matrix serves as a checker for every permutation P starting from the initial permutation that one reads as the input. The same is clearly explained in the second sample test case.
    7 changes: 7 additions & 0 deletions Random number generator
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    1. Why isn't the answer 1/4 and 1/2 for the first sample test case.

    ans: The trick lies in the space the input rests in. Its REAL numbers and not INTEGERS. So, the asnwer is 1/2 and not 1/4.

    2. If a random number generates between 0 and M are 0 and M included? Does it affect my strategy if I assume either?

    ans: No! Real numbers have a limit of 0 at any integer value. Its always limiting. So, it doesn't matter if 0 and M are included or excluded. For clarity sake a random number generates a number in the range [0..M]