C ++ – full intcode computer (code 2019: day 9)

My best languages ​​are Python and Rust, but I want to improve my knowledge of C ++, so I decided to try the Advent of Code 2019 in C ++. I haven't encountered too many problems so far, but I want to know what I'm doing, which is subtly (or not so subtly) wrong.

The following program is my solution for the 9th day problem. It is essentially an interpreter for an invented machine language called intcode. The intcode specification is spread across day 2, day 5 and day 9. The day 7 issues had additional limitations that may explain some of my architectural decisions.

It is not my intention to summarize the entire Intcode specification, but here are some key points about the Intcode language and the computer:

  • Intcode programs require common command and data storage, and most or all of the sample programs use it.
  • An intcode computer has two registers: the command pointer, which I have called the program counter (_pc) and the relative base that I called the stack pointer (_sp). Both are defined to be initialized to zero.
  • Intcode instructions have a variable size and the program counter must be increased by the width of the current instruction in each cycle.
  • Intcode statements support arguments with three different addressing modes: immediate, "positional" (ie direct addressing) and "relative" (ie batch-related addressing). The addressing modes of all arguments of an instruction are encoded in the high digits of its opcode.
  • To solve certain problems, you must start several Intcode computers, connect their inputs and outputs, and run them simultaneously (though not literally at the same time).
  • I created mnemonics for each of the intcode instruction opcodes when I came across them and invented an assembly language for debugging purposes. these are not part of the specification, but you can observe them by commenting out the relevant lines.

My code passes all tests on the website. It's more about eradicating bad habits and avoiding pitfalls than whether the Intcode logic itself is right.

#include 
#include 
#include 
#include 
#include 
#include 
#include 

using Int = long;

enum Opcode {
    ADD = 1,
    MUL = 2,
    INPUT = 3,
    OUTPUT = 4,
    JNZ = 5,
    JZ = 6,
    TESTLT = 7,
    TESTEQ = 8,
    ADDSP = 9,
    HALT = 99,
};

enum class Mode {
    Pos/*ition*/ = 0,
    Imm/*ediate*/ = 1,
    Rel/*ative*/ = 2,
};

class Argument {
public:
    Argument(Mode mode, Int value) : _mode(mode), _value(value) {}

    Mode mode() const {
        return _mode;
    }

    Int value() const {
        return _value;
    }

private:
    Mode _mode;
    Int _value;
    friend std::ostream& operator<<(std::ostream& os, const Argument& self);
};

std::ostream& operator<<(std::ostream& os, const Argument& self) {
    switch (self._mode) {
        case Mode::Imm:
            return os << self._value;
        default:
            std::cerr << "Warning: unknown addressing mode" << std::endl;
            ((fallthrough));
        case Mode::Pos:
            return os << "(" << self._value << ")";
        case Mode::Rel:
            if (self._value < 0) {
                return os << "(sp - " << -self._value << ")";
            } else if (self._value > 0) {
                return os << "(sp + " << self._value << ")";
            } else {
                return os << "(sp)";
            }
    }
}

class Instruction {
public:
    Instruction(const Int* mem) {
        if (mem(0) < 0) {
            throw std::runtime_error("negative opcode");
        }
        _opcode = (Opcode)(mem(0) % 100); // the last two digits are the opcode
        Int addr_modes = mem(0) / 100;
        // parse arguments:
        for (size_t a = 1; a < length(); ++a) {
            auto mode = static_cast(addr_modes % 10);
            _args.emplace_back(mode, mem(a));
            addr_modes /= 10;
        }
        if (addr_modes > 0) {
            std::cerr << "Warning: unused addressing flags";
        }
    }

    Opcode opcode() const {
        return _opcode;
    }

    const Argument& arg(size_t n) const {
        return _args(n);
    }

    /* The code size of this instruction. The amount by which the program
     * counter should be incremented after executing it. */
    size_t length() const {
        switch (_opcode) {
            case ADD:
            case MUL:
            case TESTLT:
            case TESTEQ:
                return 4;
            case JNZ:
            case JZ:
                return 3;
            case INPUT:
            case OUTPUT:
            case ADDSP:
                return 2;
            case HALT:
                return 1;
            default:
                throw std::logic_error("bad opcode in Instruction::length");
        }
    }

private:
    std::vector _args;
    Opcode _opcode;
    friend std::ostream& operator<<(std::ostream& os, const Instruction& self);

    /* The number of input arguments this instruction has. Input arguments are
     * distinguished from output arguments because they may be immediate. In
     * the Intcode machine language, input arguments always precede output
     * arguments. */
    size_t inputs() const {
        switch (_opcode) {
            case ADD:
            case MUL:
            case JNZ:
            case JZ:
            case TESTLT:
            case TESTEQ:
                return 2;
            case OUTPUT:
            case ADDSP:
                return 1;
            case INPUT:
            case HALT:
                return 0;
            default:
                throw std::logic_error("bad opcode in Instruction::inputs");
        }
    }
};

std::ostream& operator<<(std::ostream& os, const Instruction& self) {
    constexpr const char *opcode_names() = {
        NULL, "ADD", "MUL", "INPUT", "OUTPUT", "JNZ", "JZ", "TESTLT", "TESTEQ",
        "ADDSP", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, "HALT"};
    os << opcode_names(self._opcode);
    for (auto& arg: self._args) {
        os << " " << arg;
    }
    return os;
}

class Cpu {
public:
    Cpu(std::ostream& out = std::cout, std::istream& in = std::cin)
        : _pc(0), _sp(0), _out(out), _in(in) {}

    /* for debugging purposes
    void set_name(std::string name) {
        _name = name;
    }
    */

    /* Populates this cpu's memory with data read from a file.
     * Also resets the program counter and stack pointer to 0. */
    void load(const std::string& file_name)
    {
        _mem.clear();
        _pc = 0;
        _sp = 0;
        auto fp = std::ifstream(file_name);
        if (!fp.is_open()) {
            throw std::runtime_error("failed to open input file");
        }
        std::string line;
        Int arg;
        while (fp >> arg) {
            _mem.emplace_back(arg);
            char comma;
            if (!(fp >> comma)) {
                break;
            } else if (comma != ',') {
                throw std::runtime_error("expected ','");
            }
        }
        fp.close();
    }

    /* Runs this Cpu until it halts or stops to wait for input. */
    void run() {
        while (true) {
            Instruction inst(&_mem(_pc));

            //debug() << std::setw(7) << inst << std::endl;
            auto pc_nxt = execute(inst);
            if (pc_nxt) {
                _pc = *pc_nxt;
            } else {
                break;
            }
        }
    }

    /* Returns true if the program is halted, false if it is blocked waiting
     * for input. */
    bool is_halted() {
        return _mem(_pc)%100 == HALT;
    }

private:
    std::vector _mem;
    size_t _pc;
    size_t _sp;
    std::ostream& _out = std::cout;
    std::istream& _in = std::cin;
    //std::optional _name;

    /* Returns a (reference to a) value in memory. */
    Int& lvalue(const Argument& arg) {
        size_t i;
        switch (arg.mode()) {
            case Mode::Imm:
                throw std::logic_error("immediate mode is not available for lvalues");
            default:
                std::cerr << "Warning: unknown addressing mode" << std::endl;
                ((fallthrough));
            case Mode::Pos:
                i = arg.value();
                break;
            case Mode::Rel:
                i = _sp + arg.value();
                break;
        }
        // resize _mem so i is in range
        if (i >= _mem.size()) {
            _mem.resize(i + 1);
        }
        return _mem(i);
    }

    /* Evaluates an argument to an instruction, either immediate or from memory
     * according to the addressing mode of the argument. */
    Int rvalue(const Argument& arg) const {
        size_t i;
        switch (arg.mode()) {
            case Mode::Imm:
                return arg.value();
            default:
                std::cerr << "Warning: unknown addressing mode" << std::endl;
                ((fallthrough));
            case Mode::Pos:
                i = arg.value();
                break;
            case Mode::Rel:
                i = _sp + arg.value();
                break;
        }
        // return 0 for out of range
        if (i >= _mem.size()) {
            return 0;
        }
        return _mem(i);
    }

    /* Executes a single instruction, modifying memory and the stack pointer
     * but not the program counter. */
    std::optional execute(const Instruction& inst) {
        auto arg = (&)(size_t n) { return rvalue(inst.arg(n)); };
        switch (inst.opcode()) {
            case ADD:
                lvalue(inst.arg(2)) = arg(1) + arg(0);
                break;
            case MUL:
                lvalue(inst.arg(2)) = arg(1) * arg(0);
                break;
            case INPUT:
                if (_in >> lvalue(inst.arg(0))) {
                    //debug() << "input = " << arg(0) << std::endl;
                    break;
                } else {
                    _in.clear(); // clear the eof state
                    //debug() << "waiting for input" << std::endl;
                    return std::nullopt;
                }
            case OUTPUT:
                _out << arg(0) << std::endl;
                //debug() << "output = " << arg(0) << std::endl;
                break;
            case JNZ:
                if (0 != arg(0)) {
                    return arg(1);
                }
                break;
            case JZ:
                if (0 == arg(0)) {
                    return arg(1);
                }
                break;
            case TESTLT:
                lvalue(inst.arg(2)) = arg(0) < arg(1);
                break;
            case TESTEQ:
                lvalue(inst.arg(2)) = arg(0) == arg(1);
                break;
            case ADDSP:
                _sp += arg(0);
                break;
            case HALT:
                return std::nullopt;
            default:
                throw std::logic_error("bad opcode in execute");
        }
        return _pc + inst.length();
    }

    /*
    std::ostream& debug() {
        if (_name) {
            std::cerr << std::setw(10) << *_name << ": ";
        }
        return std::cerr;
    }
    */
};

int main() {
    Cpu cpu;
    cpu.load("day09.in");
    cpu.run();
}

I am most interested in knowing what is prone to error, buggy, or just "strange" to an experienced C ++ programmer. I've seen and selected different C ++ styles in action, which makes sense to me, but that does not mean that they make sense overall.

Some specific things that seem a bit awkward are:

  • Cpu::run() Returns either when the program stops or waiting for input. (The customer can call Cpu::is_halted To distinguish these cases.) When the program was waiting for the input, I had to call _in.clear() Within execute to clear the EOF flag from the stream. This seemed a little risky to me because I may be deleting an error flag instead. I suppose I could test for EOF or errors separately, but it just seems a bit cumbersome. Is there a better way to structure the input that I wasn't thinking about?

  • I tried to find a way to write one value Function that interprets an argument contextually as input or output, instead of

    lvalue(inst.arg(2)) = arg(1) + arg(0);
    

    I would be able to write

    value(2) = value(1) + value(0);
    

    and argument 2 would be parsed as an output parameter (for which the immediate addressing mode is not allowed), while arguments 1 and 0 would be parsed as input parameters (for which any addressing mode is allowed). Maybe that was a stupid idea; anyway i thought it would be possible to send it via the constness of thisbut I couldn't find a way to do it. Still, if possible, I'd like to know how.

  • There seems to be a difference between enum and enum class when it comes to how integer values ​​are assigned. I use enum for opcodes and enum class for addressing modes, not really rhyme or reason. I should have used enum class or enum for both? With enum class It seems that you have to give them all explicit values ​​if you want to static_cast work consistently. I did not find much information about this topic online.

  • friend ostream& operator<<: Is this a good way to create a debugable output format?

  • is const std::string& a good way to accept a string argument if you don't need to mutate or copy it? I tried std::string_view but apparently you can not make a from a char *,

  • One of the mistakes I made was as follows: lvalueWhen I tested whether the size of the memory needed to be changed, I used > instead of >=, This caused a subtle error that was only triggered if the address to be written was exactly one after the end of the vector. Valgrind could not detect this error (at least not with standard options). Is there a compiler switch that I can enable, or another tool that makes it easy for me to detect out-of-range index errors while debugging?

  • The vectors for Arguments in Instruction seem a bit extra. I want to save them in a row Instruction, and save on the assignment, since the maximum size is only 3. Is there a typical solution to this type of problem? The only thing I could imagine was an array of 3 optionals and that seemed difficult.

Here is a simple intcode quine to test the code with (day09.in):

109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99

It should be printed after stdout (but with line breaks instead of commas).

Uninstall and reinstall SharePoint 2019

We currently have a development environment that includes an app server and a WFE. It wasn't fully set up from the start and there were big problems installing Handshake. The decision was made to reinstall and start over. I've never done anything like this before.

What are best practices here? Should I simply uninstall and reinstall all SP components from both virtual boxes or do they have to be completely deleted?

HostWithLove – Promotions at the end of the year 2019! Get up to $ 100 credits & 10 months free hosting!

frequently asked Questions

Q: How long have you been in business?
A: We were first established in 2012. This is our eighth year of operation and we have received consistently good ratings.

Q: How long does it take for my account to be set up?
A: Accounts are automatically set up by our system immediately upon receipt of payment. If you do not receive your hosting account details within 5 minutes of receiving your payment, please send a ticket to our technical support for further assistance.

Q: If I update my account, will the discounts be transferred?
A: Yes, the discounted rate will remain valid even if you update your account.

Q: Have your prices been adjusted / fixed in place of cPanel's recent price increase?
A: Yes, our prices have already been increased slightly (~ 5-10%) to account for cPanel's price increase. Despite further price increases by cPanel, there will be no further adjustments to our prices. If you compare our past and current prices, you will find that we did not use a tricky reaction, as was the case with some other providers. This is because we have never understood ourselves as a budget provider and have always marketed ourselves to the merits of our service quality.

Q: Are you a reseller / do you own servers?
A: No, we are not a reseller. We have full root access to all our infrastructures (hosting servers, backup servers, filter servers, etc.) and demonstrate this by using exactly the same configurations (ie software features, server resource assignments, server hostnames, etc) in all our hosting systems .) use sites that a reseller can not. Direct forwarding means that you get better and faster support quality because you do not have to wait for the middle man to forward the message between you and the upstream.

Q: Which place is best for me?
A: Good question! There is no place that meets all needs, as it really depends on where the visitors to your site come from. Even CloudFlare can only cache about 65% of the content of your website, which means that the other 35% of your site content is still served by the web server. Therefore, choosing the right location is extremely important to ensure a fast web page load. Since you and your requirements are unique and important to us, please submit a sales ticket and tell us the requirements of your website / company. We are happy to assist you in choosing the most suitable hosting location.

Q: May I use all of my assigned resources?
A: Yes, you may use all resources assigned to you as long as your form of use complies with our Terms of Use.

Best way to upload multiple large files from SharePoint Hosted Add-in to SharePoint 2019

I need to upload several large files from a SharePoint hosted page to the SharePoint document library.

Well, SaveBinaryDirect works very well in CSOM but uses "filepath".

When I create a WebAPI to upload a file from this CSOM code, the file path is no longer useful because the API is hosted on the server.

Is there an alternative to uploading multiple large files using the client-side approach or a better approach to connecting to CSOM through SharePoint Hosted Add-in?

Environment: SharePoint 2019.
Architecture: SharePoint hosted add-in

Any help is greatly appreciated!

December 2019 Server Parts Pricing Report

This is the ninth installment of monthly server price reporting for 2019.

If you went through it, we tracked the changing parts prices for RAM, SSDs, hard drives, CPUs and some GPUs. Usually this is done monthly and then shared with WHT and in our blog.

Currently, all prices quoted refer to used hardware from ebay. I can also start finding more new hardware if there is a demand for it.

Prices from 10th December 2019

– or + indicates if the price has gone up or down since last month

Code:

Price Low* / Price High** / Part Name


SSDs

$64(+) / $89(+) / 480gb Intel DC S3500 
$100(-) / $169(-) / 800gb Intel DC S3500 
$200(+) / $275(+) / 1.6TB Intel DC S3500 

New SSDs

$115() / $184(+) / 240gb Intel D3-S4610
$160(-) / $250(-) / 480gb Intel D3-S4610
$410(+) / $410(+) / 960gb Intel D3-S4610
$495(-) / $1195(+) / 1.92tb Intel D3-S4610
$1040(+) / $1040(+) / 3.84tb Intel D3-S4610
 
Hard Drives

$40() / $50(-) / 3TB HGST SATA
$160(+) / $199(+) / 8TB HGST SATA
$190(+) / $260(+) / 10TB HGST SATA
$299(+) / $459(+) / 12TB HGST SATA


DDR3 RAM

$10() / $15() / 8GB DDR3 (a)
$15() / $30() / 8GB DDR3 (b)
$25() / $40() / 16GB DDR3 (a)
$22() / $30() / 16GB DDR3 (b)
$68() / $105() / 32GB DDR3 (c)


DDR4 RAM

$24() / $45() / 8GB DDR4 (d)
$45(+) / $115(+) / 8GB DDR4 (e)
$24(-) / $40(+) / 8GB DDR4 (f)
$37() / $60(-) / 16GB DDR4 (d)
$50(-) / $90() / 16GB DDR4 (e)
$72(+) / $100(+) / 16GB DDR4 (f)
$84() / $100(-) / 32GB DDR4 (d)
$85() / $150() / 32GB DDR4 (e)
$99() / $155() / 32GB DDR4 (f)

E5v2 CPUs

$130() / $145() / E5-2660v2
$140(-) / $160(-) / E5-2680v2
$195(-) / $270(-) / E5-2697v2

E5v3 CPUs

$88(-) / $100(-) / E5-2650v3
$125(-) / $155(-) / E5-2660v3
$138(-) / $175() / E5-2670v3
$164(-) / $198(-) / E5-2680v3
$200(-) / $255(+) / E5-2690v3
$290() / $340(-) / E5-2695v3
$549(+) / $795(+) / E5-2698v3
$630(+) / $775(-) / E5-2699v3


E5v4 CPUs

$845(-) / $1143(+) / E5-2650v4
$830(-) / $1370() / E5-2660v4
$599(-) / $979(-) / E5-2680v4**
$1800(+) / $2328(+) / E5-2690v4
$3400(-) / $3680(-) / E5-2699v4

Graphics Cards

$450(+) / $530(+) / Nvidia GTX 1080Ti
$288(+) / $315(+) / Nvidia GTX 1080
$299(+) / $359(+) / AMD Vega 64

For comparison with last month, here are the prices from November 8, 2019:

Code:

Price Low* / Price High** / Part Name


SSDs

$50(-) / $70(-) / 480gb Intel DC S3500 
$120(-) / $225(-) / 800gb Intel DC S3500 
$180(-) / $210(-) / 1.6TB Intel DC S3500 

New SSDs

$115() / $167(+) / 240gb Intel D3-S4610
$166(+) / $240(+) / 480gb Intel D3-S4610
$278(+) / $358(+) / 960gb Intel D3-S4610
$559(+) / $653(+) / 1.92tb Intel D3-S4610
$893(+) / $960(+) / 3.84tb Intel D3-S4610
 
Hard Drives

$40() / $50(-) / 3TB HGST SATA
$146(-) / $189(-) / 8TB HGST SATA
$170(-) / $215() / 10TB HGST SATA
$233(-) / $317(-) / 12TB HGST SATA


DDR3 RAM

$10() / $15() / 8GB DDR3 (a)
$15() / $30() / 8GB DDR3 (b)
$25() / $40() / 16GB DDR3 (a)
$22(-) / $30() / 16GB DDR3 (b)
$68() / $105() / 32GB DDR3 (c)


DDR4 RAM

$24() / $45() / 8GB DDR4 (d)
$37(-) / $55(-) / 8GB DDR4 (e)
$26() / $37() / 8GB DDR4 (f)
$37(+) / $115(+) / 16GB DDR4 (d)
$55(-) / $90() / 16GB DDR4 (e)
$55() / $64() / 16GB DDR4 (f)
$84(-) / $120() / 32GB DDR4 (d)
$85(-) / $150(+) / 32GB DDR4 (e)
$99() / $128() / 32GB DDR4 (f)

E5v2 CPUs

$130() / $145() / E5-2660v2
$150() / $200() / E5-2680v2
$218(-) / $275(-) / E5-2697v2

***********************

E5v3 CPUs

$105(-) / $150() / E5-2650v3
$150(-) / $200(+) / E5-2660v3
$150(-) / $217() / E5-2670v3
$145(-) / $185(-) / E5-2680v3
$215(-) / $225(+) / E5-2690v3
$290() / $378() / E5-2695v3
$399(+) / $470(+) / E5-2698v3
$440() / $790(-) / E5-2699v3


E5v4 CPUs

$1030(+) / $1300(+) / E5-2650v4
$900(+) / $1370(+) / E5-2660v4
$1199(+) / $1489(+) / E5-2680v4
$1710(+) / $1845(+) / E5-2690v4
$4000(+) / $4760(+) / E5-2699v4

Graphics Cards

$305 / $399 / Nvidia GTX 1080Ti
$275 / $350 / AMD Vega 64

Code:

* Price Low -- The lowest price to buy this part from a reputable seller in a moderate quantity, price as shipped to the US			
** Price High -- There is a reasonably large quantity of this part available from multiple reputable sellers for this price or lower, price as shipped to the US			

*** Price for the lowest priced drive of this size, matching this model number or better in the same class. "Same class" would mean sata (S) or nvme (P), as applicable. "Better" means a higher model number than listed. Ranked from worst to best, Intel model numbers are 3500, 3510, 3600, 3610, 3700, 3710			

(a) -- 2Rx4 PC3L-10600R ECC REG	
(b) -- 2Rx4 PC3L-12800R ECC REG	
(c) -- 4Rx4 PC3L-12800L ECC REG LRDIMM	
	
(d) DDR4 PC4-2133P ECC Registered	
(e) DDR4 PC4-2400T ECC Registered
(f) DDR4 PC4-2666V ECC Registered

Some notable changes since last month:

* Although prices for the high-end E5v4 CPU models have fallen marginally, they are still harder to find in the used market, and prices continue to reflect this.

* Alternatively, prices and availability have become much cheaper for some of the lower E5v4 CPU models over the last month.

* The RAM and HDD prices have been largely stable for several months and show only minimal price fluctuations.

* Because SSDs are popular consumer electronics, very few models of Intel D3-S4610 SSDs are currently available. It is likely that the reduced availability has something to do with people waiting until Black Friday / Cyber ​​Monday to purchase those products.

Let me still know if you have feedback, how to make it more useful, etc.

5 Innovation in the Packaging Industry in 2019 – More Ways to Make Money

spacer.png "class =" ipsImage "data-ratio =" 48.75 "height =" 487 "style =" height: auto; "width =" 1000 "data-src =" https://foodboxes307529463.files.wordpress.com/2019/12/5-innovation-in-packaging-industry-in-20192.jpg "src =" https: // topgoldforum.com/applications/core/interface/js/spacer.png "/></p>
<p style= Innovation has become indispensable in this modern world. Every industry uses new and technical methods to produce and produce intelligent things. The packaging industry is also experiencing technical innovations. Production, printing, design and decoration of packaging depend heavily on technology. The innovations in this industry are changing over time. Some of the innovations are discussed here.

1. Zero Waste Boxing

The packing boxes Porridge has several features that can protect the packed items. Environmental protection is also indispensable. The material should be in favor of the atmosphere. The packaging is produced using modern methods. These methods have reduced material waste. The punching method is a truly unique and appealing method of avoiding the use of additional materials. You can do that custom boxes according to the size of the products. This saves material and time. The costs are also reduced. The punch method allows you to make more boxes. The exact size of the containers takes no extra space. Now companies are forgoing plastic bags, Styrofoam packaging and other materials that are not degraded and harm the atmosphere. Modern technology has solved this problem. You can easily buy the environmentally friendly packaging material in the markets.

2. Flexible packaging for long-term use

The traditional boxes were hard and had no flexibility. Now the packaging is made of different materials. They are flexible and durable. You can sue paper packaging, corrugated boxes and others. You can easily pack the goods of any kind. The food, baked goods, cosmetics and other goods can be easily stored in them. The flexible packaging can be used for a long period of time. You can recycle it. You can store your many household products such as books, clothes, CDs, DVDs, cosmetics and tools. You can get them in many sizes. You can provide them with name and description. You can easily store them in your store or shelf. They are light and easy to wear.

3. Premium packaging

Some industries and brands want a luxurious and first-class packaging to package their goods. They want to compete for their competitors in the industry by packaging the items in stylish and high quality packaging. The premium packaging contains 3D and 4D print designs, attractive packaging, durable materials and die-cut forms. The type and appearance of the packaging force customers to buy. They can appeal to buyers. The purchase decision depends strongly on the packaging presentation. You can get premium boxes for your food, fast food, baked goods, cosmetics and many goods. The brands believe that buyers can be easily attracted by the introduction of cartons.

spacer.png "class =" ipsImage "data-ratio =" 58.79 "height =" 587 "style =" height: auto; "width =" 1000 "data-src =" https://foodboxes307529463.files.wordpress.com/2019/12/box-packaging-2.jpg "src =" https://topgoldforum.com/applications/core/ interface / js / spacer.png "/></p>
<p style= 4. Customized Packaging & Designs

Customized boxing is the biggest innovation of this modern age. The customers and brands can get that special packaging of their own decisions. The modern printing and design methods have redesigned the boxes. You can choose the material of your choice. The logo, images and text can be printed on it. You can choose the right printing technique for you. There are many printing methods like laser printing, digital printing etc. that you can easily get individually printed boxes at affordable prices. Digital printing supports customers with the latest and most realistic designs. They have a great color scheme, graphics and stylish text. The labels can be printed with pictures and special text. These all design techniques can easily carry out the customers. You can get customized gift boxes, personalized boxes, printed wholesale containers and window pockets.

spacer.png "class =" ipsImage "data-ratio =" 66.70 "height =" 667 "style =" height: auto; "width =" 1000 "data-src =" https://foodboxes307529463.files.wordpress.com/2019/12/printed-boxes.jpeg "src =" https://topgoldforum.com/applications/core/interface/ js / spacer.png "/></p>
<p style= 5. Packaging of cartons

The packaging is not sufficient to package and present the products. The packaging of the packaging enriches the beauty and protection of the goods. The special butter and wrapping papers are used to package products inside and outside the bags. The inner papers can secure the goods. The outer wrapping paper can be designed and printed. It surprisingly improves the protection and beauty of the packaging.

,

Python – Advent of Code 2019: Day 4

I'm doing Advent of Code this year. Below is my attempt on the 4th day:

problem

part One

— Day 4: Secure container —

You can only reach the Venus tank farm to find that it is password protected. The elves had written the password on a sticky note, but someone threw it out.

However, you remember some important password facts:

  • It's a six-digit number.
  • The value is within the range specified in your puzzle input.
  • Two adjacent digits are the same (like 22 in the 122345).
  • If you go from left to right, the numbers never get smaller. they only ever increase or stay the same (like 111123 or 135679).

Apart from the scope rule, the following applies:

  • 111111 meets these criteria (double 11never takes off).
  • 223450 does not meet these criteria (decreasing digit pair) 50).
  • 123789 does not meet these criteria (no double).

How many different passwords in the area specified in your puzzle input meet these criteria?

Second part

— Second part —

One Elf remembered only one more important detail: the two adjacent matching digits are not part of a larger group of matching digits.

Considering this additional criterion, without considering the scope rule, the following now applies:

  • 112233 Meets these criteria as the number of digits never decreases and all repeated digits are exactly two digits long.
  • 123444 no longer meet the criteria (the repeated 44 is part of a larger group of 444).
  • 111122 meets the criteria (though 1 is repeated more than twice, it still contains a double 22).

How many different passwords within the range specified in your puzzle input meet all the criteria?


solution

from itertools import groupby

bounds = (265275, 781584)

rules = (
    # Digits are never decreasing
    lambda s: all(int(s(i)) <= int(s(i+1))
                  for i in range(len(s)-1)),
    # Two adjacent digits are equal.
    lambda s: any(s(i) == s(i+1) for i in range(len(s)-1)),
    # Two adjacent digits don't form a larger group.
    lambda s: any(len(list(v)) == 2 for _, v in groupby(s))
)


def test(num, rules):
    return all(f(str(num)) for f in rules)


def solve(bounds, rules):
    return sum(1 for i in range(bounds(0), bounds(1)+1) if test(i, rules))


def part_one():
    return solve(bounds, rules(:2))


def part_two():
    return solve(bounds, rules(::2))


print(part_one())  # 960
print(part_two())  # 626


Remarks

I do not consider myself a beginner in Python, but I do not master it either. I think I would be at the lower end of the middle school. I am familiar with PEP 8 and have read it completely. Therefore, all of my stylistic deviations are probably intentional. However, you can point it out if you think that a particular selection of mine was sufficiently flawed. I'm interested in best practices and readability, but also in the performance of my code. I am not sure which compromise is appropriate and I would be pleased to receive feedback on the compromises that I have made.

My style tends to overuse features. This is partly because I think it's good to break functionality into functions, but it's also an artifact of my development practices. I tend to write the program in a Jupyter notebook (the ability to execute arbitrary code snippets in semi-isolated cells is a very helpful aid to development and, of course, lends itself to one function per cell (with the added benefit of making functions independent easily tested by each other))). I would appreciate it when I think about it, but if it is not particularly outrageous, I probably will not change it.

The Complete Digital Marketing 2019 Guide rated the SEO ranking for $ 30

The Complete Digital Marketing 2019 Guide Like Or Trailer SEO Ranking

Hi guy.

If you are looking for an updated, comprehensive and easy-to-understand guide to digital marketing, this is for you.
digital marketing / the-complete-digital-marketing-guide-2019.

This is your Guide to Full Digital Marketing 2019, which will allow you to fully work through everything you need for your digital marketing journey. Whether you're a beginner or a pro, we're here to give you the skills and knowledge you need to become the next digital marketing assistant.

Digital Marketing