Dcoder icon

The coding Challenges @ Dcoder

By Lochard | Asylum Diary | 29 May 2023


Title: The coding Challenges

Problem: There are n participants appearing for one on one coding challenge.Each participant plays twice (challenges) with each of his opponents.You need to compute the total number of challenges. 

Input: First line contains an integer n, represent number of participants.

Output: Print the total number of challenges.

Constraints: 1≤n≤100

Sample Input: 16

Sample Output: 

240

from operator import mul
from functools import reduce
n= int(input())
if n > 2:
  print(reduce(mul, range(1, n+1)) // reduce(mul, range(1, n-1)))
else:
  print(n // 2)

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


Asylum Diary
Asylum Diary

Sometimes the seemingly trivial matters are better kept recorded. One premise is that many others will record them, not for you, anyway. E.g.: the big teches and the Big Brother, or just someone next to you. https://github.com/locharp/asylum_diary

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.