Created
October 23, 2022 08:16
-
-
Save glenkusuma/1a0640f070658bab0eb9be5d9cae9a26 to your computer and use it in GitHub Desktop.
Lipat Kertas Gambar GemasTIK XIV (2021)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lipat Kertas Gambar GemasTIK XIV (2021) | |
# ini adalah fungsi untuk menghitung jumlah lipatan kertas gambar | |
def lkg(N,jumlahKertas): | |
i = 1 | |
while i <= jumlahKertas: | |
n = N[i-1] | |
m = n[2] | |
j = 1 | |
# melipat sisi kertas yang paling besar | |
while j <= m: | |
if n[0] > n[1]: | |
p = n[0] // 2 | |
q = n[1] | |
else: | |
p = n[1] // 2 | |
q = n[0] | |
n[0] = p | |
n[1] = q | |
j += 1 | |
# menampilkan keluaran hasil lipatan | |
print(n[0],n[1]) | |
i += 1 | |
if __name__ == '__main__': | |
# inisialisasi banyaknya kertas | |
jumlahKertas = int(input("N: ")) | |
l = 1 | |
n = [] | |
# meminta input panjang dan lebar kertas serta banyaknya lipatan | |
while l < jumlahKertas + 1: | |
inp = input("P Q M: ") | |
l += 1 | |
# memisahkan input berdasarkan spasi | |
inps = [] | |
for i in inp.split(" "): | |
inps.append(int(i)) | |
# memasukkan input ke dalam list | |
n.append(inps) | |
# memanggil fungsi lkg (Lipat Kertas Gambar) | |
print("Hasil lipatan kertas gambar:") | |
lkg(n,jumlahKertas) | |
""" | |
3 | |
120 80 3 | |
3 2 50 | |
3 7 2 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment