## Best practice for checkout process where users need to meet certain criteria to make purchase?

In a multi-step checkout process, what’s the best practice for basically filtering out people who do not meet 3-4 certain criteria for purchase?

One criteria is country of residence for example. So if a user doesn’t live in a certain country, there is basically no point for him to proceed to the next step of the form as he won’t be able to actually buy the product. (The criteria are strict and can’t be changed for legal reasons as this is to do with insurance products.)

Is it advisable to start by filtering the users first? The obvious way is to have them confirm that they meet the criteria like country of residence before they can get to the rest of the form (e.g. “I confirm that… – I live in x, – I have y…”)

In that case, should there be an option for users who do not meet the criteria? A way of doing that would be via radio buttons with a “yes” and “no” option.

For the “no” users, the journey would end right there (with a message explaining why of course). The “yes” users would be able to start the checkout process.

In terms of tracking user behavior, having both options is probably best as it will provide information on who tried but couldn’t make the purchase. If only the “yes” option is available, the data on terminated sessions at that stage of the process wouldn’t really explain much (could be the criteria, could be something else). However, I worry that having a “negative” option could deter some users.

Of course, starting with the criteria and a “yes” or “no” question might put some people off. Because of the nature of the purchase, users should be aware that some legal stuff is required though.

A third way I can think of, would be to integrate the criteria into the form as the users move along (e.g. country of residence could be checked as part of entering the address in the form later on). That way, everyone can start the form but some users then wouldn’t be able to complete the purchase.

I wasn’t able to find much information on this. Any thoughts are appreciated!

## Hiding Bottom Nav bar on certain situations

I’m going to try and explain this the best way I can. I have a main activity with 3 fragments. In the main activity it has a bottom nav, a container(a constraint layout that holds my fragments), and a search bar at the top. The main activity is a constraint layout.

What I’m trying to do is when the user hits the search bar or a fab I have at the bottom it replaces the container with a search fragment. (I have the search fragment showing up and all that is great). In the search fragment there is a search bar, a recycler view, and set of buttons that only show when the keyboard is visible.

So when the user comes into the search view what I have happening right now is as soon as the search view shows the keyboard also automatically shows and those hidden buttons sit just on top of the keyboard. At this point I don’t want the bottom nav to be visible to the user. When the user hits the recycler view or hits the soft key to hide the keyboard I want those two buttons that are sitting on top of the keyboard to hide and the bottom nav to be visible again so the user can move back to the home page or go to other fragments.

I have tried using the manifest file and adding in a “adjustResize” and I’ve tried “adjustPan” and I’ve gotten close but can’t get what I want.

What I’ve tested is using a interface but because I am not actually hitting any button from the fragment that I can use to call back to the main activity I can’t kick off the function to show or hide the bottom nav. I’ve tried doing a listen on the buttons that sit on top of the keyboard to show they changed their layout but it doesn’t update the layout correctly.

Hopefully this was written clear as mud but if anyone has any ideas on how this might be done I’d greatly appreciate any feedback.

## Python program to find Armstrong numbers in a certain range

I have written a program to check for Armstrong numbers in a certain range.

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.

Here is my code:

lower = int(input("Enter lower range: ")) upper = int(input("Enter upper range: "))  for num in range(lower, upper + 1):     order = len(str(num))     sum = 0     temp = num    while temp > 0:        digit = temp % 10        sum += digit ** order        temp //= 10     if num == sum:        print(num) 

Here is an example output:

Enter lower range: 200 Enter upper range: 5000  370 371 407 1634 

So, I would like to know whether I could make this program shorter and more efficient.

Any help would be highly appreciated.

## Is there any way (or best practise) to measure the perceived workload caused by a software on a certain user?

Perceived Workload has a subjective character trait, but I would like to find a way how one can measure for example the perceived workload from any individual. Here I mean the workload, which is caused by a single software on the person, who has to work with it.

The software I am talking about provides work items as some part of a workflow from a project team. And here I would like to find out, what is circa the optimal amount of work items (for example daily) for one single stakeholder in order to avoid fatigue or cognitive overload. (The work items themselves always take circa same efforts and time)

Are there any best practices for my matter or any (scientifically) proven ways to do this?

## Quicksort where element comparison outcome is random. Probability of element being in a certain position

So we have this block of pseudocode:

Monsters = [M1,M2,M3,M4,M5,M6,M7,M8]; qsort(Monsters,rand_compare); 

qsort() sorts the array via quicksort where we use the last element as pivot. To compare two elements it uses rand_compare, which, with equal probability (i.e., 1/2 either way), will return either “1. element is bigger” or “2. element is bigger” and never “both are equal”. What is the probability that M8 appears in position 0, 1 or 2, respectively, after applying qsort ?

I’m really not sure how to tackle this question. Intuitively it should be 1/8 for every position. Does it depend on what implementation of quicksort you use?

## Adding script to certain nodes and pages on drupal 7

I am trying to add a script code on all pages of my drupal except a few. Is there any conditionals I can use in html.tpl.php ? or any functions on the template.php to achieve this?

I tried the code below on template.php but no luck 🙁

 function THEME_preprocess_page(&$variables) { if (isset($  variables['node']->type)) {    $variables['theme_hook_suggestions'][] = 'page__' .$  variables['node']->type;   }    //this is what I am trying    if (\$  variables['nid'] == '77') {     drupal_add_js(drupal_get_path('theme', 'THEME') .'/scripts/path.js');    }  }  

## Subbbundle with certain property

Let $$M$$ is smooth manifold and $$\pi: Ε \longrightarrow M$$ is a smooth vector bundle. Suppose $$L$$ is a subbundle of $$(E,π)$$. For any $$(x \in M)$$ we denote $$L_{x}$$ a fiber of subbundle $$L$$ which it is subspace of $$E_{x}$$. $$L_{x}$$ have a certain property. The space of all subspace $$L_{x}$$ diffeomorphic the manifold with two connected component.

1. How can regard a subbundle $$L$$ as a family of subspaces in fiber $$E_{x}$$, varying smoothly with x? $$(x \in M)$$
2. How can say for any $$(x \in M)$$, the property of $$L_{x}$$ invariant on connected component of $$M$$?

## Set certain days of the week on repeat

I’m making an attendance sheet for my team, how do i make only sertain days like Mon Tue Wed appear in the top column?

## Compute Probability with random draws without replacement for certain order

I would like to know if the solution to the problem is correct. If not, could you please explain the reasoning?

There are 7 white balls and 6 black balls in a bag. We draw without replacement. What is the probability that the first and third are white and second and fourth are black?

P(W for first position) = 7/13 P(B for second position = 6/13 P(W for third position) = 6/13 P(B for fourth position) = 5/13  So, the total probability is:  (7/13)(6/13)(6/13)(5/13) = 0.0441 or 4.41% 

Does this make sense? When I run the simulation, I get 0.0735. So, why is there a discrepancy?

# Initialize success, sims and urn success, sims = 0, 50000 urn = ['w']*7 + ['b']*6  for _ in range(sims):     # Draw 4 balls without replacement     draw = np.random.choice(urn, replace=False, size=4)     # Count the number of successes     if (draw[0] == 'w') & (draw[1] == 'b') & (draw[2] == 'w') & (draw[3] == 'b'):         success +=1  print("Probability of success = {}".format(success/sims))