Upload files to "/"

This commit is contained in:
202510715092 REZA BUDI SAPUTRA 2026-04-22 20:56:00 +07:00
commit 62450fdb87

120
rezabudisaputra.ipynb Normal file
View File

@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4X_QOdIuLrFs"
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "tsRz1mFy7uYz"
},
"source": [
"**PROGRAM INI BERTEMA TANPA UANG KEMBALIAN**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"collapsed": true,
"executionInfo": {
"elapsed": 84,
"status": "ok",
"timestamp": 1776777366121,
"user": {
"displayName": "Reza Budi Saputra",
"userId": "03472603998301488075"
},
"user_tz": -420
},
"id": "0vHBDsQk8TFD",
"outputId": "641c5e1c-8171-4800-ce99-b3fe4881ef2f"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#1: TIDAK\n",
"#2: TIDAK\n",
"#3: TIDAK\n"
]
}
],
"source": [
"def bisa_bayar(harga, pecahan):\n",
" # Menggunakan DP (subset sum)\n",
" dp = set()\n",
" dp.add(0)\n",
"\n",
" for uang in pecahan:\n",
" baru = set(dp)\n",
" for nilai in dp:\n",
" total = nilai + uang\n",
" if total == harga:\n",
" return \"YA\"\n",
" if total < harga:\n",
" baru.add(total)\n",
" dp = baru\n",
"\n",
" return \"YA\" if harga in dp else \"TIDAK\"\n",
"\n",
"\n",
"# Input beberapa baris (contoh seperti soal)\n",
"data = [\n",
" [4000, 200, 50, 25],\n",
" [2200, 1000],\n",
" [5500, 2000, 200, 100]\n",
"]\n",
"\n",
"# Proses dan output\n",
"for i, baris in enumerate(data, start=1):\n",
" harga = baris[0]\n",
" pecahan = baris[1:]\n",
" hasil = bisa_bayar(harga, pecahan)\n",
" print(f\"#{i}: {hasil}\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "h1R2f-LR9LzP"
},
"source": [
"#Output :\n",
"\n",
"#1: YA\n",
"#2: TIDAK\n",
"#3: YA"
]
}
],
"metadata": {
"colab": {
"provenance": [
{
"file_id": "1NE2ODz7ixfT2ozJWTWaTFahqI3GWAM7a",
"timestamp": 1776820738663
}
]
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}