From 717d48fd9215d52be3b72705ef44d2a0072cc366 Mon Sep 17 00:00:00 2001 From: sameer2403 <76219383+sameer2403@users.noreply.github.com> Date: Sun, 10 Oct 2021 20:26:50 +0530 Subject: [PATCH 1/4] Add files via upload --- Program-28/Bin Packing Problem.cpp | 36 ++++++++++++++++++++++++++++++ Program-28/Readme.md | 18 +++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Program-28/Bin Packing Problem.cpp create mode 100644 Program-28/Readme.md diff --git a/Program-28/Bin Packing Problem.cpp b/Program-28/Bin Packing Problem.cpp new file mode 100644 index 00000000..8f59d0cb --- /dev/null +++ b/Program-28/Bin Packing Problem.cpp @@ -0,0 +1,36 @@ +// C++ program to find number of bins required using +// next fit algorithm. +#include +using namespace std; + +// Returns number of bins required using next fit +// online algorithm +int nextFit(int weight[], int n, int c) +{ + // Initialize result (Count of bins) and remaining + // capacity in current bin. + int res = 0, bin_rem = c; + + // Place items one by one + for (int i = 0; i < n; i++) { + // If this item can't fit in current bin + if (weight[i] > bin_rem) { + res++; // Use a new bin + bin_rem = c - weight[i]; + } + else + bin_rem -= weight[i]; + } + return res; +} + +// Driver program +int main() +{ + int weight[] = { 2, 5, 4, 7, 1, 3, 8 }; + int c = 10; + int n = sizeof(weight) / sizeof(weight[0]); + cout << "Number of bins required in Next Fit : " + << nextFit(weight, n, c); + return 0; +} diff --git a/Program-28/Readme.md b/Program-28/Readme.md new file mode 100644 index 00000000..33513f47 --- /dev/null +++ b/Program-28/Readme.md @@ -0,0 +1,18 @@ +Given n items of different weights and bins each of capacity c, assign each item to a bin such that number of total used bins is minimized. It may be assumed that all items have weights smaller than bin capacity. + + +Example: +Input: weight[] = {4, 8, 1, 4, 2, 1} + Bin Capacity c = 10 +Output: 2 +We need minimum 2 bins to accommodate all items +First bin contains {4, 4, 2} and second bin {8, 1, 1} + +Input: weight[] = {9, 8, 2, 2, 5, 4} + Bin Capacity c = 10 +Output: 4 +We need minimum 4 bins to accommodate all items. + +Input: weight[] = {2, 5, 4, 7, 1, 3, 8}; + Bin Capacity c = 10 +Output: 3 \ No newline at end of file From 4cd32d3267f2144d07606b31f1686529769f0364 Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:36:23 -0800 Subject: [PATCH 2/4] WAP To Reverse a List In Python --- Python/Program-36/Program-36.py | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Python/Program-36/Program-36.py diff --git a/Python/Program-36/Program-36.py b/Python/Program-36/Program-36.py new file mode 100644 index 00000000..4b2d10dd --- /dev/null +++ b/Python/Program-36/Program-36.py @@ -0,0 +1,36 @@ +#WAP TO REVERSING A LIST IN PYTHON + +#METHOD-01: + +# Reversing a list using reversed() +def Reverse(lst): + return [ele for ele in reversed(lst)] + +# Driver Code +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +#METHOD-02: + +# Reversing a list using reverse() +def Reverse(lst): + lst.reverse() + return lst + +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +METHOD-03: + +# Reversing a list using slicing technique +def Reverse(lst): + new_lst = lst[::-1] + return new_lst + +lst = [10, 11, 12, 13, 14, 15] +print(Reverse(lst)) + + +#END From 9aee6e67c3f0dbf1c2d227254a61d0b52ddc481a Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:38:38 -0800 Subject: [PATCH 3/4] Create README.md --- Python/Program-36/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Python/Program-36/README.md diff --git a/Python/Program-36/README.md b/Python/Program-36/README.md new file mode 100644 index 00000000..bd3e7e73 --- /dev/null +++ b/Python/Program-36/README.md @@ -0,0 +1 @@ +THIS IS THE PYTHON BASED CODES WHICH HELPS YOU TO REVERSE A LIST FROM 3 DIFFERENT METHODS From f5fa86c90e2ba0b4b6393c4716228b5f9f507ae2 Mon Sep 17 00:00:00 2001 From: Suvrat Patel <72069889+MadJokkerr@users.noreply.github.com> Date: Tue, 12 Oct 2021 05:43:33 -0800 Subject: [PATCH 4/4] Update README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index b7e94009..e44831be 100644 --- a/Python/README.md +++ b/Python/README.md @@ -37,7 +37,7 @@ | [Program-33](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program33/Program33.py) | Program to find HCF | [Program-34](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program34/Program34.py) | Program to display calender | [Program-35](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program%2035/Program35.py) | Program to search an element in a Circular Linked List -| Program-36 | - | +| [Program-36](https://github.com/swaaz/basicprograms/blob/814a1e60ae23d81158d8174666f23c9b7419e15e/Python/Program-36/Program-36.py) | Program to Reverse a list | Program-37 | - | | Program-38 | - | | Program-39 | - |