Skip to content

Commit bd32a55

Browse files
committed
Adds 'Tuples' Python Challenge
1 parent 9ed66c1 commit bd32a55

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

Python/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- Loops: [Challenge](https://www.hackerrank.com/challenges/python-loops/problem) - [Solution](https://github.com/monoprosito/hackerrank_challenges/tree/master/Python/loops)
99
- Leap year: [Challenge](https://www.hackerrank.com/challenges/write-a-function/problem) - [Solution](https://github.com/monoprosito/hackerrank_challenges/tree/master/Python/is_a_leap_year)
1010
- Print function: [Challenge](https://www.hackerrank.com/challenges/python-print/problem) - [Solution](https://github.com/monoprosito/hackerrank_challenges/tree/master/Python/print_function)
11+
- Tuples: [Challenge](https://www.hackerrank.com/challenges/python-tuples/problem) - [Solution](https://github.com/monoprosito/hackerrank_challenges/tree/master/Python/tuples)

Python/tuples/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Task
2+
3+
Given an integer, ![equation](https://latex.codecogs.com/gif.latex?n), and ![equation](https://latex.codecogs.com/gif.latex?n) space-separated integers as input, create a tuple, ![equation](https://latex.codecogs.com/gif.latex?t), of those ![equation](https://latex.codecogs.com/gif.latex?n) integers. Then compute and print the result of ![equation](https://latex.codecogs.com/gif.latex?hash%28t%29).
4+
5+
**Note:** [hash()](https://docs.python.org/3/library/functions.html#hash) is one of the functions in the *\_\_builtins\_\_* module, so it need not be imported.
6+
7+
### Input Format
8+
9+
The first line contains an integer, ![equation](https://latex.codecogs.com/gif.latex?n), denoting the number of elements in the tuple.
10+
11+
The second line contains ![equation](https://latex.codecogs.com/gif.latex?n) space-separated integers describing the elements in tuple ![equation](https://latex.codecogs.com/gif.latex?t).
12+
13+
### Output Format
14+
15+
Print the result of ![equation](https://latex.codecogs.com/gif.latex?hash%28t%29).
16+
17+
### Sample Input 0
18+
19+
```
20+
2
21+
1 2
22+
```
23+
24+
### Sample Output 0
25+
26+
```
27+
3713081631934410656
28+
```
29+
30+
**Author:** [Shashank Sharma](https://www.hackerrank.com/profile/shashank21j)
31+
32+
**Difficulty:** Easy
33+
34+
**Max Score:** 10

Python/tuples/test_case_0.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Input (stdin)
2+
2
3+
1 2
4+
5+
Expected Output
6+
3713081631934410656

Python/tuples/tuples.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if __name__ == '__main__':
2+
n = int(input())
3+
integer_list = map(int, input().split())
4+
5+
print(hash(tuple(integer_list)))

0 commit comments

Comments
 (0)