generating lists of integers with constraint

Suppose you have the list $a=(k_1,k_2,k_3, dots, k_N)$ such that $k_{i}; (i=1,ldots, N)$ are non negative integers. How can you get all the lists that satisfy the constraint $sum_{i=1}^{N} k_{i}=M$?

lists – Better user experience while having a small amount of content to show

I have the below screen that shows a list of items. The list can sometimes be long and sometimes short. When the list is long, the UI looks okay, but when it is short, the screen looks a little boring. Is there any suggestion to improve the display in this scenario?

Display of two phone mockups; one has only two items, the other has many

Context:

  • This is an app for a IOT device.
  • This screen comes in the middle of the user guide/on-board screens.

calculus and analysis – Picking elements from separate lists and multiplying them

So I’m doing some instruction items about surface integrals. I’ve written the following code. it calculates curl and partial derivatives of the surface. I now want to create the following function, which will be my integrand. Merely dot producting the two vectors doesn’t change the signs like I need. Is there a way to says multiply one element of a vector times its corresponding one and changing the sign, along the way?

What I want to do is change the sign of the first two elements created by the dot product, whle leaving the third alone.

Here’s my code;

F = {2 z, 4 x, 5 y};
Print("The curl is:")
NewF = Curl(F, {x, y, z}) (*Step 1*)

g = x + 4;(*Step 3 solving for z of the curve*)
Print("The partial derivatives of z are the following (with 1 as a placeholder for R):")
g1 = {D(g, x), D(g, y), 1}(*Step 4, the partials of z*)
Print("The new integrand is the following (don't forget to sub g for z.")
NewF . g1

The curl is shown to be 5,2,4 and the partials are 1,0,1. But a correct answer for what i want to do gives 1 as the ‘new integrand’ while the code here gives ‘9.”

Any thoughts?

sharepoint online – Default views for list folders isn’t working in new experience lists

I’m trying to set up a folder based list where the top level of the list will only contain folders of a custom type “Incident” and the incident folders will contain other types such as “Action” etc.

I have this set up but the automatic view selection isn’t working. I have created two views:

  • Incidents – set to show in “Top-level” and is set as the default view
  • Actions – set to show in folders of type “Incident” and is also set as the default view

I want it to automatically switch between those views when I go from the top level to the “Incident” level but it doesn’t. It just stays at whatever I last set it to and both views are available in both the top level folder and the incident folders.

Our site is configured to use the “new experience” and if I change the list to use the “classic experience” instead of the default one then this part works.

I don’t want to use the classic experience because other parts of it don’t work well for what we want and also we need to be able to use the list from Teams which seems to use the new experience regardless of the setting in the list.

Is there something that I am doing wrong or is it a fault in Sharepoint?

dnd 5e – Is there a resource anywhere that lists every spell and the classes that can use them?

There are now a number of resources that provide lists of spells, the PHB, Tashas Cauldron, XGTE etc. As well as spells that are included in specific adventure or campaign books.

There are also new classes that come with new spell rules, artificer is one.

Is there a single resource anywhere that lists all the spells currently published for 5th edition, the classes they can be used by and the level? I am not looking for the spell rules just an updated list as per the PHB that includes every published spell by class.

Or a list that lists out every spell and the classes that can use them.

google sheets – How to shrink lists of strings so that all consecutive values are represented by “A to D” instead of as “A, B, C, D”

Quite tricky to phrase this question but I’m asking getting times ranges of when people are available in 3 hours chunks. They can answer with any combination of "00:00 to 03:00", "03:00 to 06:00", "06:00 to 09:00", "09:00 to 12:00", "12:00 to 15:00", "15:00 to 18:00", "18:00 to 21:00", "21:00 to 00:00", and "All Day". In my current “solution” I replace these strings as numbers, 1 through 8 with “All Day” just being an overwrite and check if all the numbers are consecutive and if so, concatenate two pre-determined strings depending on what’s the first number and what’s the last numbers.

If, for instance, someone replied with the following answer: "06:00 to 09:00, 12:00 to 15:00, 15:00 to 18:00, 18:00 to 21:00", how do I properly shrink that to "06:00 to 09:00, 12:00 to 21:00"? In my solution the formula just fails since they’re not entirely consecutive. It will just return the original input string.

I think I probably need to address every answer as an array and somehow iterate through to see which values are consecutive, saving that to a separate array and then just replacing the text back to a readable format in another cell but I have no clue how I would go about comparing the first number to the second number without an obscene number of IF statements.

linked lists – Writing a C program that reads data.txt and reverses the order of odd numbers

Can you help me with this question please? I tried everything but couldn’t do it myself. I couldn’t find a similar question on the internet so I had to ask it myself.

Write a C program that reads a line from data.txt and creates a singly linked list queue from it. This C program changes that queue order by reversing the order of the odd integers while leaving the even integers in place.
Run this program for each line of the data.txt file and print out the results.
The first line of the data.txt file contains the sample count.

Use Singly Linked List, not Array! Solution is based on stack and queue combination.

For example given this queue:
14 13 17 8 4 10 11 4 15 18 19 //queue 1 2 3 4 5 //order of the odd integers

program would change it to:
14 19 15 8 4 10 11 4 17 18 13 //queue 5 4 3 2 1 //order of the odd integers

This is the data file:

Data.txt

Thank you in advance.

immutability – Is there a better method to implement an immutable double ended queue, that uses two single link lists internally for the dequeue using C++?

I am writing an immutable interpreter in C++ for fun. Originally standard vectors and dequeues were used to create a double ended queue data type, but it was very slow, because each operation require a whole new copy of the original container to be created.

So it was redone using a custom immutable single linked node lists which only requires a single node to be recreated during each operation on list like data types. And a double ended queue was implemented using two of these single linked lists. While it doesn’t require the whole data type and each element to be copied during each operation. It does require a limited recreation of the data type during dequeue operations to rebalance the two lists, which is expensive.

Is there a more efficient, and less copy expensive method, that could have been used to implement the double ended queue? Which does not require rebalancing the lists, and the original data still remains immutable during each operation.

class list {

        let    _lead;
        let    _last;
        int_t  _size;

    public:

        list();
        list(const list& exp);
        list(let exp);
        virtual ~list();

        friend str_t           __type__(const list& self);
        friend bool_t            __is__(const list& self);
        friend real_t          __comp__(const list& self, const let& other);
        friend void             __str__(stream_t& out, const list& self);
        friend void            __repr__(stream_t& out, const list& self);

        friend int_t            __len__(const list& self);
        friend let             __lead__(const list& self);
        friend let             __last__(const list& self);
        friend let       __place_lead__(const list& self, const let& other);
        friend let       __shift_lead__(const list& self);
        friend let       __place_last__(const list& self, const let& other);
        friend let       __shift_last__(const list& self);
        friend let          __reverse__(const list& self);

    private:
        void  balance();
    };

    /********************************************************************************************/
    //
    //                               'list' Class Implimentation
    //
    /********************************************************************************************/

    list::list() : _lead(__node__()), _last(__node__()), _size(0) {
    }

    list::list(const list& exp) : _lead(exp._lead), _last(exp._last), _size(exp._size) {
    }

    list::list(let exp) : _lead(__node__()), _last(__node__()), _size(0) {
        
        while (exp.is()) {

            _lead = _lead.place_lead(pop_lead(exp));

            _size += 1;
        }

        balance();
    }

    list::~list() {
    }

    std::string __type__(const list& self) {
        return "list";
    }

    bool_t __is__(const list& self) {

        if (self._lead.is() || self._last.is()) {
            return true;
        }

        return false;
    }

    real_t __comp__(const list& self, const let& other) {

        const list* e = other.cast<list>();

        if (e) {

            if ((self._lead == e->_lead) && (self._last == e->_last)) {
                return 0.0;
            }
        }

        return NOT_A_NUMBER;
    }

    void __str__(stream_t& out, const list& self) {

        if (!__is__(self)) {
            out << "()";
            return;
        }

        out << "(";

        out << str(self._lead);

        if (self._last.is()) {

            if (self._lead.is()) {
                out << " ";
            }

            out << str(self._last.reverse());
        }

        out << ")";
    }

    void __repr__(stream_t& out, const list& self) {

        if (!__is__(self)) {
            out << "()";
            return;
        }

        out << "(";

        out << repr(self._lead);

        if (self._last.is()) {

            if (self._lead.is()) {
                out << " ";
            }

            out << repr(self._last.reverse());
        }

        out << ")";
    }

    int_t __len__(const list& self) {
        return self._size;
    }

    let __lead__(const list& self) {

        if (!self._lead.is()) {
            return self._last.lead();
        }

        return self._lead.lead();
    }

    let __last__(const list& self) {

        if (!self._last.is()) {
            return self._lead.lead();
        }

        return self._last.lead();
    }

    let __place_lead__(const list& self, const let& other) {

        if (other.is_nothing()) {
            return self;
        }

        list e = self;

        e._lead = e._lead.place_lead(other);

        e._size += 1;

        if (!e._last.is()) {
            e.balance();
        }

        return e;
    }

    let __shift_lead__(const list& self) {

        if (__len__(self) == 0) {
            return self;
        }

        list e = self;

        if (!e._lead.is()) {

            if (e._last.shift_lead().is()) {
                // Balance if _last has more than one element.
                e.balance();
            }
            else {
                e._last = e._last.shift_lead();
                return e;
            }
        }

        e._lead = e._lead.shift_lead();

        if (!e._lead.is()) {

            if (e._last.shift_lead().is()) {
                e.balance();
            }
        }

        return e;
    }

    let __place_last__(const list& self, const let& other) {

        if (other.is_nothing()) {
            return self;
        }

        list e = self;

        e._last = e._last.place_lead(other);

        e._size += 1;

        if (!e._lead.is()) {
            e.balance();
        }

        return e;
    }

    let __shift_last__(const list& self) {

        if (__len__(self) == 0) {
            return self;
        }

        list e = self;

        if (!e._last.is()) {

            if (e._lead.shift_lead().is()) {
                // Balance if _last has more than one element.
                e.balance();
            }
            else {
                e._lead = e._lead.shift_lead();
                return e;
            }
        }

        e._last = e._last.shift_lead();

        if (!e._last.is()) {

            if (e._lead.shift_lead().is()) {
                e.balance();
            }
        }

        return e;
    }

    let __reverse__(const list& self) {

        if (__len__(self) < 2) {
            return self;
        }

        list e;

        e._lead = self._last;
        e._last = self._lead;
        e._size = self._size;

        return e;
    }

    void list::balance() {

        // print("lead = " + str(_lead) + " : last = " + str(_last));

        bool_t flip = _last.is() && !_lead.is();

        if (flip) {
            std::swap(_lead, _last);
        }

        int_t i = _size < 2 ? 1 : _size / 2;

        _lead = _lead.reverse();
        _last = _last.reverse();

        while (i --> 0) {

            _last = _last.place_lead(_lead.lead());
            _lead = _lead.shift_lead();
        }

        _lead = _lead.reverse();
        _last = _last.reverse();

        if (flip) {
            std::swap(_lead, _last);
        }
    }
```

Algorithm to convert many instances of unidirectional lists to a graph?

I feel like I’m missing something basic.

I have instances of a list compromising of unique graph nodes / elements visited. Lists happen in order, but follow graph based rules (can be cyclical, only some connections are allowed, there are optional nodes in a graph, some nodes always happen in unison, etc). How can I derive the graph represented by billions of instances of these lists? And maybe even sub-graphs nested within?

e.g. list instance #1: A -> B -> D -> E 
e.g. list instance #2: A -> F -> K
e.g. list instance #3: A-> B-> K > B -> D -> E 

e.g. graph vertices derived from these lists:

A -> B
B -> D 
B -> K
D -> E 
F -> K

This feels like a solved compsci problem that I’m trying rearticulate. Like, I get that I can always calculate the vertices (either by weight / likelihood to occur, or as booleans if they occurred). But that feels like I’m missing a lot of nested complexity and trying to reinvent the wheel. Is there an esteblished approach to this problem?

import – A glitch with importing a list of lists of polynomials

Would anybody know how to import a list of lists of polynomials which I exported earlier?

d = {{3*t^2 + 2*t^(-1), 5*t + 6*t^(-2) + 7*t^(-4)}, {7*t^2 + 8*t^(-1), 9*t + 10*t^(-2)}} 
Export("mydata.dat",d) 
Import("mydata.dat") 
Out()={{"2/t", "+", "3*t^2", "7/t^4", "+", "6/t^2", "+", "5*t"}, {"8/t", "+", "7*t^2", "10/t^2", "+", "9*t"}}

imp=Import("mydata.dat", "List")
Out()={2/t + 3*t^2  7/t^4 + 6/t^2 + 5*t, 8/t + 7*t^2    10/t^2 + 9*t}
imp((1))
Out()= 2/t + 3*t^2  7/t^4 + 6/t^2 + 5*t
imp((1))((1)) 
error: Part::partd: Part specification 2/t + 3*t^2  7/t^4 + 6/t^2 + 5*t((1)) is longer than depth of object.
Head @ imp((1))
Out()=String

Exporting as “List” does not help.