Santa Claus has to optimize the space for everyone present on the sled.

Overview

How to generate all sets of P packages into N bags

Santa Claus has to optimize the space for everyone present on the sled

Description

Santa Claus got himself a quantum computer, but the computer is still being designed by a big high tech Open Source and Open Hardware company (it's a donation to the common good for 2022). So Santa asked a bunch of developers to make small pieces of code to help him Optimize the placement of all presents in the sled bags. The algorithm that was attributed to me was a simple one:

  • Generate all sets of P packages into N bags

Others will have to make do other parts of all the christmas software, already preparing for the christmas of 2022 ...
This is a nice way to start the new year, looking and developing some code for Santa Claus.

How does the algorithm works?

Well, we will do a backtracking algorithm with recurrence. In it we will transverse the stack, implicitly drawing a tree (depth first traversal) that at each node as a state for each configuration. We will be making changes to the state as we go down the tree and we will undo does changes has we come back up the tree. In the first node we will put all the presents in the first bag and then we will shift the presents between bags (from left to right) into all places, into all combinations as we travel the tree. At each node we test the constraints and collect the new presents in the bags configuration.

Tree

                                    (A,B,C:_:_)
                     ____________________||____________________
                 (A,B:C:_)                                 (A,B:_:C)
           __________||__________                    __________||__________
       (A:B,C:_)             (A:C:B)              (A:B:C)            (A:_:B,C)
      _____||_____         _____||_____         _____||_____        _____||_____
(_:A,B,C:_) (_:B,C:A)  (_:A,C:B) (_:C:A,B)  (_:A,B:C) (_:B:A,C)  (_:A:B,C) (_:_:A,B,C)

How many states are there?

               Max P
               -----
               \             p 
 Num states =   |     (b - 1)
               /
               -----
                p=0


 Where:
    "Max P" is the number of Presents or Packages.
    b is the number of Bags in the Sled.

License

MIT Open Source License

Have fun!

Best regards,
João Nuno Carvalho

You might also like...
Finding the shortest and fastest path in the graph to optimize traffic.

Finding the shortest and fastest path in the graph to optimize traffic. Because we don't want to spend unnecessary time searching for the optimal route back to home.

Optimize floating-point expressions for accuracy
Optimize floating-point expressions for accuracy

Herbie automatically improves the error of floating point expressions. Visit our website for tutorials, documentation, and an online demo. Herbie has

A tool to optimize your Solidity function signatures.

sigop A CLI tool to optimize your Solidity function signatures. I wanted to create this after seeing transmissions11's comment about this optimization

Revolutionize handheld gaming with adaptive game settings. Optimize graphics and gameplay experience based on real-time system metrics. Open-source project empowering developers to enhance games on portable devices
Revolutionize handheld gaming with adaptive game settings. Optimize graphics and gameplay experience based on real-time system metrics. Open-source project empowering developers to enhance games on portable devices

Welcome to the server-side application for the HarmonyLink project. This innovative software is developed with the Rust programming language and is ai

Empowering everyone to build asynchronous software

Runtime Empowering everyone to build asynchronous software. API Docs | Contributing | Chat Built with ⛵ by The Rust Async Ecosystem WG ⚠️ Deprecation

A simple programming language for everyone.

Slang A simple programming language for everyone, made with Rust. State In very early stages. Plan is to create a byte-code compiler and make that exe

HyperCube is a free and open source blockchain project for everyone to use.

XPZ Public Chain HyperCube is a free and open source blockchain project for everyone to use. 日本語 简体中文 正體中文 HyperCube Wiki Wha is HyperCube HyperCube i

Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁)

Sophy Bot Hi I'm Sophy, a discord bot in devlopment, soon I'll be available to help everyone (❁´◡`❁) Contribution Do you like me and want to help me?

Build fast, reward everyone, and scale without friction.
Build fast, reward everyone, and scale without friction.

Scrypto Language for building DeFi apps on Radix. Terminology Package: A collection of blueprints, compiled and published as a single unit. Blueprint:

Rust - Empowering everyone to build reliable and efficient software.

The Rust Programming Language This is the main source code repository for Rust. It contains the compiler, standard library, and documentation. Note: t

This is the Rust course used by the Android team at Google. It provides you the material to quickly teach Rust to everyone.

Comprehensive Rust 🦀 This repository has the source code for Comprehensive Rust 🦀 , a four day Rust course developed by the Android team. The course

Open to everyone 👪 - The Polkadot Blockchain Academy's Rust Qualifier Exam.

Rust Qualifier Exam An open source learning resource, available to all. This exam is maintained by the Polkadot Blockchain Academy, for the benefit of

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Example application using a Vue frontend with Rust backend that has authentication + authorization.

This project contains a Rust server that serves a single page application and has authentication + JWT-based authorization.

Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldberg-Moleman scale or whatever.

about Tells you how many years you need to wait until your subatomic xeon crystal synchronizer has doubled in plasma inversion efficiency on the Goldb

A position (finance) definition that has some good algebraic properties.

Positions A position (finance) definition with some good algebraic properties. API Docs Example Add positions as a dependency of your project. [depend

Annoyed that Rust has many string types? Well it doesn't have to

generic-str The one true string type in Rust! This project intends to be a proof-of-concept for an idea I had a few months back. There is lots of unsa

Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.
Distrod is a meta-distro for WSL 2 which runs Systemd as init process. You can run Ubuntu, Arch, and et.c with systemd in a minute. Distrod also has built-in auto-start feature on Windows startup and port forwarding abiltiy.

Distrod - WSL2 Distros with Systemd! Distrod is a systemd-based meta-distro for WSL2 that allows you to install Ubuntu, Arch Linux, Gentoo and many ot

This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust !

NumbersRepresentation This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust ! This is an id

Owner
João Nuno Carvalho
Hi, I’m a software engineer - computer science and electronics. I develop in many programming lang. I do command line, GUI and Web, Machine Learning and others.
João Nuno Carvalho
Open to everyone 👪 - The Polkadot Blockchain Academy's Rust Qualifier Exam.

Rust Qualifier Exam An open source learning resource, available to all. This exam is maintained by the Polkadot Blockchain Academy, for the benefit of

Polkadot Blockchain Academy 8 Apr 18, 2023
This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust !

NumbersRepresentation This repository presents a numbers vizualizer in a polar base. This small project has been entirely made in Rust ! This is an id

Lilian 'S3l4h' Schall 3 Apr 12, 2022
skyWM is an extensible tiling window manager written in Rust. skyWM has a clear and distinct focus adhering to the KISS and Unix philosophy.

Please note: skyWM is currently in heavy development and is not usable as of yet. Documentation and versions will change quickly. skyWM skyWM is an ex

MrBeeBenson 74 Dec 28, 2022
A command-line tool for re-packaging an epub that has been unzipped. Can also be used as a library.

?? zaino A command-line tool for re-packaging an epub that has been unzipped. Can also be used as a library. Installation To use zaino as a library, a

Zachary Golba 3 Aug 17, 2023
dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory

dua (-> Disk Usage Analyzer) is a tool to conveniently learn about the usage of disk space of a given directory. It's parallel by default and will max

Sebastian Thiel 1.8k Jan 2, 2023
CLI search and replace | Space Age seD

SAD! Space Age seD What does it do? Basically sad is a Batch File Edit tool. It will show you a really nice diff of proposed changes before you commit

i love my dog 986 Dec 29, 2022
Terminal disk space navigator 🔭

Given a path on your hard-drive (which could also be the root path, eg. /). diskonaut scans it and indexes its metadata to memory so that you could explore its contents (even while still scanning!).

Aram Drevekenin 1.6k Dec 30, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
CLI tool to work with Sled key-value databases.

sledtool CLI tool to work with Sled key-value databases. $ sledtool --help Usage: sledtool <dbpath> <command> [<args>] CLI tool to work with Sled da

Vitaly Shukela 27 Sep 26, 2022
Sled - the champagne of beta embedded databases

key value buy a coffee for us to convert into databases documentation chat about databases with us sled - it's all downhill from here!!! An embedded d

Tyler Neely 6.6k Jan 8, 2023