calculateMiddleSegment function
Implementation
int calculateMiddleSegment(int totalWidth, int segmentWidth) {
int middleIndex = totalWidth ~/ 2;
int middleSegment = middleIndex ~/ segmentWidth;
int wastedSize = middleIndex - (segmentWidth * middleSegment);
if (wastedSize > 10) {
middleSegment++;
}
return middleSegment * 20;
}