Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward solution in Clear category for Ethernet Ring Dimensioning by DiZ
ETHERNET = (100, 40, 10, 1, 0.1) # Ethernet bandwidth capacity in Gbps
def checkio(ring, *flows):
links = [0] * len(ETHERNET)
n, aggregation = len(ring), dict.fromkeys(ring, 0)
for s, dr in flows:
i, e = map(ring.index, s)
if (i - e) % n < (e - i) % n: i, e = e, i
for node in range(i, e + n * (i > e)):
aggregation[ring[node % n]] += dr
for flow in aggregation.values():
if not flow: continue
for i, capacity in enumerate(ETHERNET[::-1]):
if capacity >= flow:
links[i] += 1
break
else:
links[-1] += -(-flow // ETHERNET[0])
return links[::-1]
April 5, 2016