C# Class Round3_2013.Problem4.WheelBruteForce

Show file Open project: eric7237cire/CodeJam

Public Methods

Method Description
E_bruteForce ( bool gondalas, int i, int j, int k, int N ) : Utils.math.BigFraction

The expected money we get while filling out the interval [i, j) so that the last filled gondola is at position (i+k) is:

P_bruteForce ( bool gondalas, int i, int j ) : Utils.math.BigFraction

so first let’s look at P(i, j), the probability that j-th gondola will stay empty while we fill up all gondolas from the interval [i, j) assuming each coming person approaches some gondola in inteval [i, j] (note that j is included here)

P_bruteForce ( bool gondalas, int i, int j, int k ) : Utils.math.BigFraction

The probability that gondola j stays empty while we fill interval [i, j) and that gondola at position (i+k) is filled last is P(i, j, k) and can be computed as:

getE_wheelFast ( bool a, int i, int j, int holeCount, int N ) : Utils.Fraction
simulateForWheelFast ( bool gondolas, IList permOrder, int N = 300 ) : int
simulatePermutation ( bool gondolas, IList permOrder, int secondToLastToFill = -1, int N = 300 ) : int

simulatePermutationExpectedValue ( bool gondolas, IList permOrder, int secondToLastToFill, int N ) : int

Method Details

E_bruteForce() public static method

The expected money we get while filling out the interval [i, j) so that the last filled gondola is at position (i+k) is:
public static E_bruteForce ( bool gondalas, int i, int j, int k, int N ) : Utils.math.BigFraction
gondalas bool
i int
j int
k int
N int
return Utils.math.BigFraction

P_bruteForce() public static method

so first let’s look at P(i, j), the probability that j-th gondola will stay empty while we fill up all gondolas from the interval [i, j) assuming each coming person approaches some gondola in inteval [i, j] (note that j is included here)
public static P_bruteForce ( bool gondalas, int i, int j ) : Utils.math.BigFraction
gondalas bool
i int
j int
return Utils.math.BigFraction

P_bruteForce() public static method

The probability that gondola j stays empty while we fill interval [i, j) and that gondola at position (i+k) is filled last is P(i, j, k) and can be computed as:
public static P_bruteForce ( bool gondalas, int i, int j, int k ) : Utils.math.BigFraction
gondalas bool True if filled, false if empty
i int
j int
k int
return Utils.math.BigFraction

getE_wheelFast() public static method

public static getE_wheelFast ( bool a, int i, int j, int holeCount, int N ) : Utils.Fraction
a bool
i int
j int
holeCount int
N int
return Utils.Fraction

simulateForWheelFast() public static method

public static simulateForWheelFast ( bool gondolas, IList permOrder, int N = 300 ) : int
gondolas bool
permOrder IList
N int
return int

simulatePermutation() public static method

public static simulatePermutation ( bool gondolas, IList permOrder, int secondToLastToFill = -1, int N = 300 ) : int
gondolas bool
permOrder IList
secondToLastToFill int
N int
return int

simulatePermutationExpectedValue() public static method

public static simulatePermutationExpectedValue ( bool gondolas, IList permOrder, int secondToLastToFill, int N ) : int
gondolas bool
permOrder IList
secondToLastToFill int
N int
return int