We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a10121a commit 734c101Copy full SHA for 734c101
HackerRank-Utopian Tree/Utopian_Tree.py
@@ -0,0 +1,34 @@
1
+#!/bin/python3
2
+
3
+import math
4
+import os
5
+import random
6
+import re
7
+import sys
8
9
+# Complete the utopianTree function below.
10
+def utopianTree(n):
11
+ boolean = False
12
+ count=0
13
+ for i in range(n+1):
14
+ if(boolean == False):
15
+ count+=1
16
+ boolean = True
17
+ else:
18
+ count*=2
19
+ boolean=False
20
+ return count
21
22
+if __name__ == '__main__':
23
+ fptr = open(os.environ['OUTPUT_PATH'], 'w')
24
25
+ t = int(input())
26
27
+ for t_itr in range(t):
28
+ n = int(input())
29
30
+ result = utopianTree(n)
31
32
+ fptr.write(str(result) + '\n')
33
34
+ fptr.close()
0 commit comments