-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractica1.py
108 lines (100 loc) · 2.57 KB
/
practica1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# def alphabet_position(text):
# ret=''
# text=text.lower()
# for i in range(len(text)):
# if (ord(text[i])<65)or(ord(text[i])>122):
# continue
# else:
# ret+=' '+str((ord(text[i])-96))
# ret=ret[1::]
# return ret
# x=alphabet_position("The sunset sets at twelve o' clock.")
# print(x)
# dat=[[18, 20],[45, 2],[61, 12],[37, 6],[21, 21],[78, 7]]
# def open_or_senior(data):
# t=[]
# for i in data:
# if i[0]>=55 and i[1]>=7:
# t.append('Senior')
# else:
# t.append('Open')
# return t
# print(open_or_senior(dat))
# def song_decoder(song):
# song=song.split('WUB')
# t=song.copy()
# for i in song:
# if i=='':
# t.remove(i)
# print(t)
# t=' '.join(t)
# return print(song)
#
# song_decoder("AWUBWUBWUBBWUBWUBWUBC")
# def sum_two_smallest_numbers(numbers):
# if len(numbers)>=4:
# x=min(numbers)
# numbers.remove(x)
# return print(x+min(numbers))
#
# print(sum_two_smallest_numbers([5, 8, 12, 18, 22]))
# def pig_it(text):
# word = text.split()
# temp=[]
# for i in word:
# if i.isalpha():
# temp.append(i[1:]+i[0]+'ya')
# else:
# temp.append(i)
# print(' '.join(temp))
#
#
# pig_it('Pig latin is cool !')
#
# def anagrams(word, words):
# temp=[]
# for i in words:
# if sorted(word)==sorted(i):
# temp.append(i)
# return print(temp)
#
# print(anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']))
# def duplicate_encode(word):
# word = word.lower()
# res=''
# for i in word:
# if word.count(i)>1:
# res+=')'
# else:
# res+='('
# print(res)
#
# print(duplicate_encode('recede'))
# print(duplicate_encode('11123'))
# def expanded_form(num):
# num = str(num)
# dec=[]
# for i in range(len(num)):
# if num[i] == "0":
# continue
# dec.append(num[i] + '0' * (len(num) - i - 1))
# return ' + '.join(dec)
#
#
# print(expanded_form(12)) # Should return '10 + 2'
# print(expanded_form(42)) # Should return '40 + 2'
# print(expanded_form(70304)) # Should return '70000 + 300 + 4'
# def solution(number):
# s=0
# for i in range(3,number):
# if i%3==0 or i%5==0:
# s+=i
# continue
# elif i%5==0:
# s+=i
# elif i%3==0:
# s+=i
# print(s)
#
#
# print(solution(10),' = ', 23)