Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions numberFour.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def repeatedString(s, n):
# Write your code here
a = 0
for word in s:
if word == "a":
a += 1

b = n // len(s)

c = 0
last = s[:n % len(s)]
for huruf in last:
print(huruf)
if huruf == "a":
c += 1

hasil = a * b + c
return hasil


s = "aba"
n = 10
result = repeatedString(s, n)
print(result)
18 changes: 18 additions & 0 deletions numberOne.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def sockMerchant(ar):
temp = {}
hasil = 0

for angka in ar:
if angka not in temp:
temp[angka] = 1
else:
temp[angka] = temp[angka] + 1

for total in temp:
hasil = hasil + temp[total] // 2
return hasil

n = 9
ar = [10, 20, 20, 10, 10, 30, 50, 10, 20]
result = sockMerchant(ar)
print(result)
24 changes: 24 additions & 0 deletions numberThree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


def migratoryBirds(n, arr):
# Write your code here
bird = [0, 0, 0, 0, 0, 0]

for number in arr:
bird[number] += 1

maxs = max(bird)
for n in range(0, len(bird)):
if bird[n] >= maxs:
maxs = bird[n]

index = bird.index(maxs)
# print('The index of e:', index)

return index


n = 6
arr = [1, 4, 4, 4, 5, 3]
result = migratoryBirds(n, arr)
print(result)
25 changes: 25 additions & 0 deletions numberTwo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def angryProfessor(k, a):
# Write your code here
temp = 0

for data in a:
if data <= 0:
temp += 1

# print("kapasitas", k)
# print("tepat waktu", len(temp))
if temp >= k:
hasil = "NO"
else:
hasil = "YES"

return hasil



n, k = [4, 3]
a = [-1, -3, 4, 2]
result = angryProfessor(k, a)
print(result)