## Update Product Attribute through Import Tool using csv – ERROR: keep creating new same sku number – magento 2

I’m try to update a product attribute called “custom_stock_status”. I have put together a csv file, with 2 columns like this, and import the file using import behavior “add/update”, but it keeps creating the same sku number, even-though the sku p1,p2,p3 are already exists in the backend. Everytime i try to import the csv file again, it create another SAME sku number in the backend.

``sku | custom_stock_status p1    coming soon p2    coming soon p3    coming soon ``

## nginx, docker, and gunicorn url without the port number in the url

I have a django app that’s also using gunicorn and nginx. I’m able to access my site using http://url:8000, but I don’t know how to correctly configure it so I don’t have to use the port number in the url at all, ie http://url would by the same as http://url:8000 .

Here’s my docker-compose.yml:

``version: '3.2'  services:   immweb:     restart: always     build: .     expose:       - "8000"     command: gunicorn smn_imm.wsgi:application --bind 0.0.0.0:8000     volumes:       - type: volume         source: smnvol         target: /etc/smn_imm/smnvol     ports:       - "8000:8000"    nginx:     build: nginx     depends_on:       - immweb ``

nginx.conf:

``upstream smn_imm {     server web:8000; }  server {      listen 80;     server_name smn-imm;      location / {         proxy_pass http://smn_imm;         proxy_set_header X-Forwarded-For \$  proxy_add_x_forwarded_for;         proxy_set_header Host \$  host;         proxy_set_header  X-Real-IP   \$  remote_addr;         #proxy_set_header  X-Forwarded-For   \$  proxy_add_x_forwarded_for;         proxy_redirect off;     }  } ``

## Arthimetic Game gets harder as the number line grows exponentially on each new round.

z = X(d^d+L)

S=Z/D is the number line’s length

L=length of string

X=how many strings

d=hamming distance

S / RT = custom choice for 1st farthest string(eg. enter 1) and 2nd farthest string (eg. 2 for 2nd farthest, etc)

The script is simple.

``1 INPUT "LENGTH OF STRING";L  2 INPUT "X FOR HOW MANY";X  3 INPUT "D FOR HAMMING DISTANCE";D  4 Z = X*(d^d+L)  5 S = Z / D  6 INPUT "ENTER # FOR NEXT STRING";RT  7 PRINT"YOUR CLOSEST STRING"RT, S / RT  8 INPUT "WOULD YOU LIKE TO GO BACK FOR MORE STRING?";M  9 IF M=1 THEN GOTO 6 ELSE GOTO 10  10 PRINT"GAME OVER" ``

You take the data output if its a whole or near whole number and write it on a paper number line. I have a picture at the end of the question to prevent confusion.

Rules of Game.

Rounds are based on length of string. Round 2 is 2 character strings. Assuming d is fixed or increases

Never go over the line’s number limit.

(eg. never go over 30!)

The game has unlimited rounds and data is recorded written down on a chart of strings that are numerically listed

Points gathered up and winner is selected.

The objective of the game is to keep playing until its to hard and just quit.

All strings are alphabetically organized. You try to find all the strings that are listed by finding a whole or near whole coefficient.

You enter 2 then 3 and so on to find the 1st farthest string and so on within 30 and so on strings permutated. Each round gets harder and harder as the length of the number line gets bigger. So its hard to find more strings.

The purpose of the formula is based on a script that I written. The game is known as “Numberline” and the idea is to strike all the strings and show arithmetic work for human to understand.

The game gets exponentially more difficult as each number line grows in length with each new round.

You place all whole coefficients for Z on a number line. The more whole numbers you find by dividing the more the number line gets filled up. All strings are alphabetically organized. So do not mistake this as the closest string problem.

You place all whole coefficients for S on a number line

(The reason being that you might not get a string if you have a non-whole number) The graph below shows to the lower right that when you enter 1 you get the first farthest string and enter 2 and so on. Integers that are near wholes are okay.)

To get an idea here’s a a list of permuated strings. The goal of the game is to find all numerically listed strings that have whole or near whole S and mark them on the number line paper.

`` 01 aa               02 ab   03 ac   04 ad   05 ae   06 af ``

etc ….. ag, ah, & az…

Shortened string with whole number list out of S .

15 ao – 15th letter o S/RT = 2

10 aj – 10th letter j S/RT = 3

03 ac – 3rd letter c S/RT = 10

Overall, what is the quickest way to find all whole or near-whole numbers solutions on any number-line of S size?

## Q: Expected number of coin tosses to get N heads in a row, in Python. My code gives answers that don’t match published correct ones

I’m trying to write Python code to see how many coin tosses, on average, are required to get a sequences of N heads in a row.

The thing that I’m puzzled by is that the answers produced by my code don’t match ones that are given online, e.g. here (and many other places) https://math.stackexchange.com/questions/364038/expected-number-of-coin-tosses-to-get-five-consecutive-heads

According to that, the expected number of tosses that I should need to get various numbers of heads in a row are: E(1) = 2, E(2) = 6, E(3) = 14, E(4) = 30, E(5) = 62. But I don’t get those answers! For example, I get E(3) = 8, instead of 14. The code below runs to give that answer, but you can change n to test for other target numbers of heads in a row.

What is going wrong? Presumably there is some error in the logic of my code, but I confess that I can’t figure out what it is.

You can see, run and make modified copies of my code here: https://trinket.io/python/17154b2cbd

Here’s the code itself, outside of that runnable trinket.io page. Any help figuring out what’s wrong with it would be greatly appreciated!

``import random # n is  the target number of heads in a row # Change the value of n, for different target heads-sequences n = 3   possible_tosses = [ 'h', 't' ] num_trials = 1000 target_seq = ['h' for i in range(0,n)] toss_sequence = [] seq_lengths_rec = []  for trial_num in range(0,num_trials):      if (trial_num % 100) == 0:         print 'Trial num', trial_num, 'out of', num_trials      target_reached = 0     toss_num = 0      while target_reached == 0:          toss_num += 1         random.shuffle(possible_tosses)         this_toss = possible_tosses[0]         #print([toss_num, this_toss])         toss_sequence.append(this_toss)         last_n_tosses = toss_sequence[-n:]         #print(last_n_tosses)     if last_n_tosses == target_seq:         #print('Reached target at toss', toss_num)         target_reached = 1         seq_lengths_rec.append(toss_num)  print('Average', sum(seq_lengths_rec) / len(seq_lengths_rec)) ``

## Is it possible to stop Google Forms adding a sequence number to each question when printed

I have set up a form in which each section has its own number and each question within the section a sequence number based on the section number. All is fine when the form is being send by email, however when the form is printed, Google Forms adds a seqnece number in front of each question. Is it possible to stop Google Forms from doing that and if so, how?! Should or Can it be done with Apps Script?

## Find the sum of the digits of a given number

I need to find the sum of the digits of the given number and repeat the process until the value lies between 1 to 9.

e.g if the input is 72457 then,

7+2+4+5+7 = 25

2+5 = 7

so , the function should return 7.

Also, if the input is a negative number like -72457 the function should return -7.

Here’s what i tried,

``int digitSum(int input1){  int flag=0;  if(input1<0)      flag=1;   int rem,sum=0;  int x=abs(input1);   while(x>0){     rem=x%10;     sum+=rem;     x=x/10;      }   int value = sum%9;   if(value==0){      if(flag==1)      return -9;      else      return 9;   }   else{    if(flag==1)    return -value;     else     return value;   }  } ``

## fill Matrix with labels to form special number of component

I’m sorry. There is problem. My English is not so good so forgive me.

Problem:

There is matrix with maximum size $$50 * 50$$. we put characters $$a$$, $$b$$, $$c$$ and $$d$$ in each cell. We must fill an rectangle area and it doesn’t need to fill all matrix cells.

Cells with label $$x$$ will create a group if they are near each other in way of left, right, top and down. (see example)

we want to have $$A$$ groups with label $$a$$, $$B$$ groups with label $$b$$, $$C$$ groups with label $$c$$ and $$D$$ groups with label $$d$$.

In first line $$A$$, $$B$$, $$C$$ and $$D$$ is given. ($$1 \le A, B, C, D \le 100$$)
In output, first print size of rectangle are which is necessary to fill and then show a correct from of groups.

Example 1:

``5 3 2 1 ``

Output:

``4 7 ddddddd dabacad dbabacd ddddddd ``

Explanation: all $$d$$ forms $$1$$ group, all $$a$$ are individual (there is no other $$a$$ in 4 side of them) so they form $$5$$ group, same for other.

Example 2:

``2 1 0 0 ``

Output:

``3 11 bbbbbbbbbbb baaabbbaaab bbbbbbbbbbb ``

Explanation: There is only $$1$$ $$b$$ group. all $$b$$ form one group because they are in 4 side of each other. each $$3$$ $$a$$ next to each other form $$1$$ group and so there is $$2$$ group of $$a$$.
There is no unique answer for question

At first I think it is a greedy problem but I couldn’t find a best way to solve it. the tag of question is constructive problem. Is it possible to help me and give me a idea or approach or something else to solve that? I know that I have to not ask question directly without any effort however I do a lot of trying and each of them have some problems so I couldn’t find a best way to solve it. I just want an idea or a way or a famous algorithm which map to this question.
Thanks so much.

## Update

If I want to say problem very easily, there is a problem here:
problem
In that we find largest connected component. but here, we do it in reverse. we want to construct a grid with $$A + B + C + D$$ component and we have $$A$$ component with color $$a$$, $$B$$ component with color $$b$$, and same for other.

## Formula used for searching strings on a number line based on any input

z = X(d^d+L)

L=length of string

X=how many strings

d=hamming distance

30(1^1+2) == 2^(log n)

The purpose of the formula is based on a script that I written. The game is known as “Numberline” and the idea is to strike all the strings and give an arithmetic proof for the computer(or human for paper game) to understand.

If your math is determined to be right by the computer, you gain 1 point. The game gets exponentially more difficult as the line gets longer.

You place all whole coefficients for Z on a number line. The more whole numbers you find by dividing the more the number line gets filled up. All strings are alphabetically organized. So do not mistake this as the closest string problem.

Overall, what is the correct mathematical approach to gain the most completed number lines?

You place all whole coefficients for Z on a number line

## Shortening the number of reductions to prove NP-Completeness

This question is based on the slides from this pdf:

• Slide 54, they define the Subset Sum Problem.

• Slide 65, they define the Partition problem.

• Slide 74, they talk about the Job Scheduling problem.

My question is, is it possible to cut the middle man of the partition problem and reduce Subset Sum to Job Scheduling directly?

To prove scheduling is NP, we can use what is already stated since it’s not related to partition.

I’m not sure how to combine the reduction from both onto one though.

## The time complexity of finding the kth smallest number using buckets

I’ve implemented kth smallest number using buckets representing the `current` nibble value of each element in the array where `current` is a value starting possibly at 64 (for 64 bits integers at most) and decrements each iteration by 4 (nibble size).

I was wondering what is the time complexity (worst) of this implementation. I think it’s `O(n^log64/4)` which is `O(n^16)`, is that correct?

``function nthSmallest(array, k, sizeOfInt) { let buckets = [     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [],     [] ]; // put numbers in buckets - O(n) for (let i = 0; i < array.length; i++) {     const high = (array[i] >> sizeOfInt - 4) & 0xF; // 4 = nibble size     buckets[high].push(array[i]); } let numbers = []; for (let i = 0; i < buckets.length && numbers.length < k; i++) {     if (numbers.length === k - 1 && buckets[i].length === 1) {         return buckets[i][0];     }     for (let j = 0; j < buckets[i].length; j++) {         numbers.push(buckets[i][j]);     } } return nthSmallest(numbers, k, sizeOfInt - 4); ``

}