반응형
There are pillars near the road. The distance between the pillars is the same and the width of the pillars is the same. Your function accepts three arguments:
- number of pillars (≥ 1);
- distance between pillars (10 - 30 meters);
- width of the pillar (10 - 50 centimeters).
Calculate the distance between the first and the last pillar in centimeters (without the width of the first and last pillar).
Solution:
def pillars(num_pill: int, dist: int, width: int) -> int:
return 0 if num_pill == 1 else (num_pill - 1) * (dist * 100 + width) - width
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0103. Powers of 2 (0) | 2023.01.03 |
---|---|
0102. Enumerable Magic #25 - Take the First N Elements (0) | 2023.01.03 |
1231. For UFC Fans (Total Beginners): Conor McGregor vs George Saint Pierre (0) | 2022.12.31 |
1230. The Wide-Mouthed frog! (0) | 2022.12.30 |
1229. Parts of a list (0) | 2022.12.30 |