We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Math
- Triangle Quest 2
- Discussions
Triangle Quest 2
Triangle Quest 2
Sort by
recency
|
1167 Discussions
|
Please Login in order to post a comment
The logic is: For i=3 the numbers = [1,2,3,2,1] and enumerate([1,2,3,2,1]) = [(0,1), (1,2), (2,3), (3,2), (4,1)]. For each (index, value) : value * 10^(length-1-index) (0,1): 1 * 10^(5-1-0) = 1 * 10^4 = 10000 (1,2): 2 * 10^(5-1-1) = 2 * 10^3 = 2000
(2,3): 3 * 10^(5-1-2) = 3 * 10^2 = 300 (3,2): 2 * 10^(5-1-3) = 2 * 10^1 = 20 (4,1): 1 * 10^(5-1-4) = 1 * 10^0 = 1 Sum: 10000 + 2000 + 300 + 20 + 1 = 12321 """
Read input
n = int(input())
Apply conditional logic
if n % 2 != 0: print("Weird") elif 2 <= n <= 5: print("Not Weird") elif 6 <= n <= 20: print("Weird") else: print("Not Weird")
It's stupid that this platform doesn't accept print(int("1"*i)**2)
New non-mathematical solution in Python using string-like operations and Java-like curly braces.
I'm biased, but I think this is very hacky.