Drill

ProblemsC# › network

Cache hit ratio in permille

easynetworkMathC#

A proxy dashboard reports cache efficiency as permille — parts per thousand — so operators can spot a 2 permille dip that a percentage would round away.

CacheHitPermille(hits: int, requests: int) → int

C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

public int CacheHitPermille(int hits, int requests) {
    
}

Worked examples

CallResult
CacheHitPermille(500, 1000)500
CacheHitPermille(1, 3)333
CacheHitPermille(0, 100)0
CacheHitPermille(100, 0)0

Hint

Integer division gives the floor you need.

Reference solution in C#
public int CacheHitPermille(int hits, int requests) {
    if (requests <= 0) return 0;
    return hits * 1000 / requests;
}

The same problem in another language

More network problems in C#