Break complicated Latex table – Stack Overflow en español

we are noobs in Latex Overleaf, and we don’t know how to split this table by columns, because it is too wide, in order to have it in the same page. Can someone help? There are more tables, but I will take this as an example:
………………………………………………………….
………………………………………………………………
…………………………………………..
…………………………………………………………………..

begin{table}(!htbp)
 centering
  caption{Regressió amb el model FF4 - metodologia Ward} 
  label{} 

  scalebox{0.4}{
begin{tabular}{@{extracolsep{5pt}}lcccccccccccc} 
\(-1.8ex)hline 
hline \(-1.8ex) 
 & multicolumn{12}{c}{textit{Dependent variable:}} \ 
cline{2-13} 
\(-1.8ex) & SL & SM & SH & BL & BM & BH & SLo & SMe & SWi & BLo & BMe & BWi \ 
\(-1.8ex) & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) & (11) & (12)\ 
hline \(-1.8ex) 
 RP & 0.911$^{***}$ & 1.222$^{***}$ & 0.873$^{***}$ & 0.974$^{***}$ & 0.944$^{***}$ & 1.456$^{***}$ & 0.744$^{***}$ & 1.237$^{***}$ & 0.795$^{***}$ & 0.912$^{***}$ & 1.338$^{***}$ & 0.881$^{***}$ \ 
  & (0.061) & (0.107) & (0.049) & (0.038) & (0.061) & (0.097) & (0.060) & (0.087) & (0.080) & (0.040) & (0.120) & (0.086) \ 
  & & & & & & & & & & & & \ 
 SMB & 0.751$^{***}$ & 1.423$^{***}$ & 0.586$^{***}$ & 0.049 & $-$0.121$^{*}$ & $-$0.017 & 0.383$^{***}$ & 1.018$^{***}$ & 0.433$^{***}$ & $-$0.023 & 0.034 & $-$0.099 \ 
  & (0.064) & (0.113) & (0.052) & (0.040) & (0.072) & (0.088) & (0.063) & (0.092) & (0.084) & (0.042) & (0.109) & (0.089) \ 
  & & & & & & & & & & & & \ 
 HML & $-$0.311$^{***}$ & $-$0.290$^{***}$ & 0.669$^{***}$ & $-$0.103$^{***}$ & 0.087$^{**}$ & 0.493$^{***}$ & 0.117$^{**}$ & $-$0.114$^{*}$ & 0.003 & $-$0.001 & $-$0.042 & 0.152$^{**}$ \ 
  & (0.048) & (0.084) & (0.038) & (0.031) & (0.043) & (0.099) & (0.047) & (0.068) & (0.062) & (0.031) & (0.092) & (0.069) \ 
  & & & & & & & & & & & & \ 
 WML & 0.096$^{**}$ & $-$0.001 & 0.096$^{***}$ & 0.057$^{**}$ & $-$0.013 & 0.129$^{**}$ & $-$0.181$^{***}$ & 0.025 & 0.790$^{***}$ & $-$0.082$^{***}$ & 0.078 & 0.970$^{***}$ \ 
  & (0.038) & (0.067) & (0.031) & (0.025) & (0.032) & (0.055) & (0.038) & (0.055) & (0.050) & (0.025) & (0.069) & (0.066) \ 
  & & & & & & & & & & & & \ 
 Constant & 0.004 & $-$0.008 & 0.006$^{**}$ & 0.006$^{***}$ & 0.001 & $-$0.002 & 0.008$^{**}$ & $-$0.004 & 0.008$^{*}$ & 0.005$^{**}$ & $-$0.010$^{*}$ & 0.007 \ 
  & (0.003) & (0.006) & (0.003) & (0.002) & (0.003) & (0.005) & (0.003) & (0.005) & (0.004) & (0.002) & (0.006) & (0.005) \ 
  & & & & & & & & & & & & \ 
hline \(-1.8ex) 
Observations & 108 & 108 & 108 & 96 & 84 & 48 & 108 & 108 & 108 & 108 & 84 & 96 \ 
R$^{2}$ & 0.775 & 0.738 & 0.937 & 0.880 & 0.791 & 0.889 & 0.688 & 0.769 & 0.845 & 0.837 & 0.644 & 0.829 \ 
Adjusted R$^{2}$ & 0.766 & 0.727 & 0.934 & 0.874 & 0.780 & 0.878 & 0.676 & 0.760 & 0.839 & 0.831 & 0.626 & 0.821 \ 
Residual Std. Error & 0.032 (df = 103) & 0.056 (df = 103) & 0.026 (df = 103) & 0.019 (df = 91) & 0.024 (df = 79) & 0.029 (df = 43) & 0.031 (df = 103) & 0.046 (df = 103) & 0.042 (df = 103) & 0.021 (df = 103) & 0.048 (df = 79) & 0.043 (df = 91) \ 
F Statistic & 88.605$^{***}$ (df = 4; 103) & 72.414$^{***}$ (df = 4; 103) & 379.861$^{***}$ (df = 4; 103) & 166.183$^{***}$ (df = 4; 91) & 74.739$^{***}$ (df = 4; 79) & 85.779$^{***}$ (df = 4; 43) & 56.891$^{***}$ (df = 4; 103) & 85.530$^{***}$ (df = 4; 103) & 140.806$^{***}$ (df = 4; 103) & 132.072$^{***}$ (df = 4; 103) & 35.788$^{***}$ (df = 4; 79) & 110.230$^{***}$ (df = 4; 91) \ 
hline 
hline \(-1.8ex) 
textit{Note:}  & multicolumn{12}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \ 
end{tabular}}
end{table} 

lexical analysis – What makes a nested function in C so complicated?

Disclaimer: I’m not a compiler expert, but some of my best friends are! 🙂

I do a lot of embedded systems programming where stack (and other memory) is limited. Most of my code is written in gcc, so I thought nested functions could be useful for reducing stack usage. Here’s an example of what I had in mind:

(Though the algorithm isn’t important for this question, assume that list_traverse takes a pointer to a list head and a function. The function gets called with each element in turn, returning false when it wants the traversal to stop.)

bool list_contains(list_t *head, list_t *item) {
  bool found = false;
  bool contains_aux(list_t *list) {
    if (list == item) {
      found = true;
      return false;
    }
    return true;
  }
  list_traverse(head, contains_aux);
  return found;
}

I assumed that the nested contains_aux() function would simply be compiled “inside” the list_contains() and be able to reference the lexically closed variables (found and item). But I was wrong.

Instead, looking at the generated code, I see that it installs some sort of trampoline function on the stack and calls that before getting to the contains_aux() function.

I guess that makes sense: contains_aux() can’t share the same stack frame as list_contains() because we’re another function deeper in the stack when its called (via list_traverse()).

So is there some way to accomplish this sort of lexical closure efficiently? Or should I just resign myself using un-nested functions and passing a “context” object to contains_aux()?

javascript – Is there a less complicated alternative to handling this simple mySQL query in Node?

To Put My Question In Better Context…

I am about done writing my first real-world Node application, which would be classified as a REST API. For myself, it was a bit challenging to wrap my head around Node’s Async event processing. I still don’t think I fully grasp it, as you will see by the specifics of this post. That being said…

Am I Making This Overly Complicated?

I found some code snippets online that helped me get my API working. Below is one function that deals with finding a client. I guess you would call the file this is in, a Controller, for those of you familiar with MVC. But this being Node, and NOT MVC, my question is this:

GET http://localhost/clients/3 -> brings me to this code…

// Find a single client with a Id
exports.findOne = (req, res) => {
  Client.findById(req.params.clientId, (err, data) => {
    if (err) {
      if (err.kind === "not_found") {
        res.status(404).send({
          message: `Not found Client with id ${req.params.clientId}.`
        });
      } else {
        res.status(500).send({
          message: "Error retrieving Client with id " + req.params.clientId
        });
      }
    } else res.send(data);
  });
};

What is the reason for this call to have a callback itself???

Client.findById(req.params.clientId, (err, data) => {

which in turn, looks like this:

Client.findById = (clientId, result) => {
  sql.query(`SELECT * FROM clients WHERE id = ${clientId}`, (err, res) => {
    if (err) {
      console.log("error: ", err);
      result(err, null);
      return;
    }

    if (res.length) {
      console.log("found client: ", res(0));
      result(null, res(0));
      return;
    }

    // not found client with the id
    result({ kind: "not_found" }, null);
  });
};

This seems like a lot of work for a simple query function. Coming from a PHP background, this could be done in very few lines of code there.

The whole thing seems complicated. Is all this really necessary for such a simple API that returns a client record of only four columns?

For that matter, do I even need that intermediate function (controller)? What’s the matter with just routing right to the final function (in this case, a function named findById ) ??

I’d sure appreciate some input on this before I get too far ahead. I have another dozen endpoints to code, so if I need to change directions, now would be the time.

Thanks!

postgresql – Is there anything wrong with splitting a complicated view into many small ones?

I have a view where each row is associated with a customer, and the columns are various computed values such as life_time_value and purchases_per_week, as well as more complicated statistical values such as probability_of_buying_premium_membership. I have around 20 such columns of varying complexity (both in terms of lines-of-code and also computional complexity), ranging from a single line of SQL to several dozen. Right now they are all in one monster view.

Is there a down-side to splitting them into multiple smaller views and joining them by customer_id?

Ie, break it down into views called
customer_life_time_value, customer_purchases_per_week and so on, and then recreate the monster view by joining 20 views? It seems like there shouldn’t be a performance hit because of the joining, as it’s over a indexed primary key. Many of the columns/views will perform similar calculations (purchases_per_week and purchases_per_quarter would look very similar), but it seems like the DB should be smart enough to share computation if I am selecting from the joined view.

I am using postgres, but interested for answers in general.

google sheets – “Complicated” Conditional formatting with checkboxes and matches

First of all I apologize that I am failing to come up with a specific title about what exactly I am trying to achieve, so I made this picture as an example result.

enter image description here

If a recipe is checked, I want the formula for the conditional formatting to be looking for a recipe match (of all of the recipes checked (for which rows column C is True)) in D3:G7 and highlight certain cells if a match occurs.

The highlighted cells should be:

  • The cell in the row where the match was found in column A.
  • The cells where the match was found.

I have tried for hours and got familiar with a lot of new functions while working on my sheet but I just keep getting overwhelmed and find myself at a dead end on this specific task.

Would very much appreciate your help!

Differential Equations – A complicated boundary value problem that leads to the third-order eigensystem [Help in continuing forward]

I have the following elliptical PDE (description of the temperature in a plate, w in thermal contact with two liquids H and c ):
$$ lambda_h frac { partially ^ 2 theta_w} { partially x ^ 2} + lambda_c V frac { partially ^ 2 theta_w} { partially y ^ 2} – ( beta_h + V beta_c ) theta_w + ( beta_h theta_h + V beta_c theta_c) = 0 day 1 $$

with the boundary conditions ($ beta_h, beta_c, V, lambda_h, lambda_c $ are constants)

$$ theta_w (0, y) = 1, theta_w (x, 0) = 0 $$
$$ frac { partial theta_w (1, y)} { partial x} = frac { partial theta_w (x, 1)} { partial y} = 0 $$

Where begin {eqnarray}
theta_h (x, y) & = & beta_h e ^ {- beta_h x} int e ^ { beta_h x} theta_w (x, y) , mathrm {d} x, \
theta_c (x, y) & = & beta_c e ^ {- beta_c y} int e ^ { beta_c y} theta_w (x, y) , mathrm {d} y.
end {eqnarray}

It is also known that $ theta_h (0, y) = 1 $ and $ theta_h (x, 0) = 0 $.

Experiment with separation of variables:

Replace $ theta_h $ and $ theta_c $ in the $ (1) $ and with the approach $ theta_w (x, y) = e ^ {- beta_h x} f (x) e ^ {- beta_c y} g (y) $ We get two linear third-order ODEs with constant coefficients for $ F (x): = int f (x) , mathrm {d} x $ and $ G (y): = int g (y) , mathrm {d} y $::
begin {eqnarray}
lambda_h F & # 39; & # 39; & # 39; – 2 lambda_h beta_h F & # 39; & # 39; + left (( lambda_h beta_h – 1) beta_h – mu right) F & # 39; + beta_h ^ 2 F & = & 0, day 2 \
V lambda_c G & # 39; & # 39; & # 39; – 2 V lambda_c beta_c G & # 39; & # 39; + left (( lambda_c beta_c – 1) V beta_c + mu right) G & # 39; + V beta_c ^ 2 G & = & 0, day 3
end {eqnarray}

with a certain separation constant $ mu in mathbb {R} $.

The boundary conditions have the following form:
For G: $ G ((0) = 0, G (0) = 0 $ and $ frac {G & # 39; & # 39; (1)} {G & # 39; (1)} = beta_c $
For F: $ frac {F & # 39; & # 39; (1)} {F & # 39; (1)} = beta_h $

In terms of all homogenoeus ODE, $ G $ the linear differential operator with $ V = 1 $

$$ lambda_c delta ^ 3 – 2 lambda_c beta_c delta ^ 2 + left (( lambda_c beta_c – 1) beta_h + mu right) delta + beta_c ^ 2 = 0 $$

and the three roots $ delta_i ( mu), i = 1,2,3 $ we have that

$$ G (t) = sum_k C_k e ^ {- delta_k ( mu) t} $$

Now use the boundary conditions

$$ G (0) = sum_k C_k = 0 longrightarrow (4) $$

and with
$$ G & # 39; (0) = – sum_k C_k delta_k ( mu) = 0 longrightarrow (5) $$
and similar

$$ frac {G & # 39; & # 39; (1)} {G & (39) (1)} = – frac { sum_k C_k delta_k ( mu) ^ 2e ^ {- delta_k ( mu)}} { sum_k C_k delta_k ( mu ) e ^ {- delta_k ( mu)}} = beta_c longrightarrow (6) $$

then we have three linear equations $ (4,5,6) $ in the $ C_k $ that can be arranged as
$$ M ( mu) cdot C = 0, C = (C_k) $$

This system has a non-trivial solution for $ det (M ( mu)) = 0 $ therefore the roots for this determinant equation are the eigenvalues $ mu_n $ and the eigenfunctions are $ e ^ {- delta_k ( mu_n) t} $

NOTE

Accept numerical values $ lambda_c = 1.775 * 10 ^ {- 4}, beta_c = 0.921 $ We have the operator polynomial

Attached a very simple MATHEMATICA script to get the first one $ mu_k $

    parms = {lc -> 1.775*10^{-4}, bc -> 0.921};
    G(t_, n_) := Sum(
    !(*SubscriptBox((c), ({1, j}))) Exp(exps((j))((1)) t) + 
    !(*SubscriptBox((c), ({2, j}))) Exp(exps((j))((2)) t) + 
    !(*SubscriptBox((c), ({3, j}))) Exp(exps((j))((3)) t), {j, 1,n})
    sols = Solve(
    lc s^3 - 2 lc bc s^2 + ((lc bc - 1) bc + mu) s + bc^2 == 0, s) /. 
    parms // FullSimplify
    roots = s /. sols;
    M = {{1, 1, 1}, {r1, r2, r3}, 
    {E^(-r1) (r1^2 + bh r1), E^(-r2) (r2^2 + bh r2), E^(-r3) (r3^2 + bh r3)}};
    det = -Det(M) // FullSimplify
    subdet20 = subdet2 /. Thread({r1, r2, r3} -> roots) /. parms;
    Plot(Im(subdet20), {mu, -100, 0}, PlotStyle -> {Thick, Black}, 
    PlotRange -> {-10, 10})
    solmu1 = FindRoot(Im(subdet20) == 0, {mu, 0})
    solmu2 = FindRoot(Im(subdet20) == 0, {mu, -7})
    solmu3 = FindRoot(Im(subdet20) == 0, {mu, -20})
    solmu4 = FindRoot(Im(subdet20) == 0, {mu, -40})
    solmu5 = FindRoot(Im(subdet20) == 0, {mu, -60})
    solmu6 = FindRoot(Im(subdet20) == 0, {mu, -80})
    solmu7 = FindRoot(Im(subdet20) == 0, {mu, -110})
    solmu8 = FindRoot(Im(subdet20) == 0, {mu, -150})
    solmu9 = FindRoot(Im(subdet20) == 0, {mu, -190})
    Subscript(mu, 1) = mu /. solmu1;
    Subscript(mu, 2) = mu /. solmu2;
    Subscript(mu, 3) = mu /. solmu3;
    Subscript(mu, 4) = mu /. solmu4;
    Subscript(mu, 5) = mu /. solmu5;
    Subscript(mu, 6) = mu /. solmu6;
    Subscript(mu, 7) = mu /. solmu7;
    Subscript(mu, 8) = mu /. solmu8;
    Subscript(mu, 9) = mu /. solmu9;
    exps = Table(roots /. parms /. {mu -> Subscript(mu, k)}, {k, 1, 9})
    G(t, 9)

Can anyone suggest how to deal with this problem? Now since the first eigenvalues $ mu $ are determined how to use that $ F $ Boundary conditions and determine $ theta_w $ ?
Any help is greatly appreciated.

real analysis – analyze a complicated double summation

To let $ f (x) $ be a real, twice continuously differentiable function and consider the following double sum $$ F (t, f (x)): = dfrac {1} {t} Big ( sum_ {k = 0} ^ { infty} sum_ {m = 0} ^ { infty} f ( x + (km) / sqrt {n}) dfrac {t ^ {k + m}} {2 ^ {k + m} k! m!} e ^ {- t} -f (x) Big) . $$ I want to calculate the limit of $ F (t, f (x)) $ when $ t rightarrow 0 $, but I don't even know how to start …

My idea was to write this double sum in two parts, where the first part can be our desired answer and the second part can be zero if $ t rightarrow infty $, but I don't know what to do to analyze such a complicated sum …

Any idea?

Python code to download records from a complicated website.

I download records from the official portal of the Indian District Courts. I developed the following code. I am not sure if it is perfect, but it is close since I almost managed to achieve the purpose. This is almost because the code jumps in certain cases and does not cover all options. Sometimes it raises errors and I have to restart it manually.
I have to ask questions now:
1. Is the code correct to achieve the goal? (Download pending case records)
2. Can I correct it to avoid mistakes?
The code is inserted below, followed by one of the errors I occasionally encounter.
The code:

District court website - select state - select district - services - case status - act - back
'''
import datetime
import cv2
import base64
from PIL import Image
from io import BytesIO
import time
import selenium
import self as self
from pytesseract import pytesseract
from selenium.webdriver.common.keys import Keys
import os
from selenium.webdriver.support import expected_conditions as EC, expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException, 
    WebDriverException, ElementNotInteractableException

driver = selenium.webdriver.Firefox()
url = r'https://districts.ecourts.gov.in/'
driver.get(url)
# some definatons to be used latter in the code.

invalidCaptcha = "Invalid Captcha"
recordNotFound = "Record Not Found"
wait = WebDriverWait(driver, 180)
waitMid = WebDriverWait(driver, 20)
waitShort = WebDriverWait(driver, 5)


# functions

def district():
    global dateToday

    def complex_and_act():

        def captchcrack():
            def imgtotxt():
                elem = driver.find_element_by_id("captcha_image")
                loc = elem.location
                size = elem.size
                left = loc('x')
                top = loc('y')
                width = size('width')
                height = size('height')
                box = (int(left), int(top), int(left + width), int(top + height))
                screenshot = driver.get_screenshot_as_base64()
                img = Image.open(BytesIO(base64.b64decode(screenshot)))
                area = img.crop(box)
                area.save('/home/sangharshmanuski/Documents/e_courts/captcha/file_trial.png', 'PNG')
                fullPath = r'/home/sangharshmanuski/Documents/e_courts/captcha'
                f = os.listdir(fullPath)
                desPath = r"/home/sangharshmanuski/Documents/e_courts/editC"
                img = cv2.imread(os.path.join(fullPath, 'file_trial.png'), 0)
                ret, thresh1 = cv2.threshold(img, 111, 255, cv2.THRESH_BINARY)
                cv2.imwrite('/home/sangharshmanuski/Documents/e_courts/editC/oneDisNoLoop.png', thresh1)
                # know the text with pytesseract
                captchaText = pytesseract.image_to_string(
                    Image.open('/home/sangharshmanuski/Documents/e_courts/editC/oneDisNoLoop.png'))
                captcha = driver.find_element_by_id('captcha')
                captcha.send_keys(captchaText)
                driver.find_element_by_css_selector('input.button:nth-child(1)').click()
                time.sleep(3)

            def accept():

                while True:
                    try:
                        driver.switch_to.alert.accept()
                        driver.switch_to.window(driver.current_window_handle(-1))
                        driver.find_element_by_css_selector(
                            '#captcha_container_2 > div:nth-child('
                            '1) > div:nth-child(1) > span:nth-child(3) > a:nth-child(7) > img:nth-child(1)').click()
                        print('alert was present')
                        imgtotxt()
                    except:
                        print('no alret')
                        break

            imgtotxt()
            accept()

        def incorrectcaptcha():
            while driver.find_element_by_css_selector('#waitmsg').is_displayed():
                i = 0
                if i < 20:
                    time.sleep(1)

            else:
                while driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').is_displayed():
                    incorrect = driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').text
                    if incorrect == invalidCaptcha:
                        print('invalid captcha')
                        captchcrack()
                    else:
                        return print('captcha cracked correctly')

        def record():
            if driver.find_element_by_css_selector(
                    'a.someclass').is_displayed():
                listAllView = driver.find_elements_by_css_selector('a.someclass')
                print('downloading the record ' + nameCourtComp)
                # make new dirctory by name of Court Complex
                distDir2 = os.path.join(
                    '/home/sangharshmanuski/Documents/e_courts/mha/downloads3',
                    newDistNameDict, nameCourtComp)
                if not os.path.exists(distDir2):
                    os.makedirs(distDir2)
                x = 0
                for view in listAllView:
                    try:
                        view.click()
                        wait.until(EC.presence_of_element_located((By.ID, 'back_top')))
                        openFile = open(
                            os.path.join(distDir2, "file_" + str(x) + ".html"), "w")
                        openFile.write(driver.page_source)
                        openFile.close()
                        back = driver.find_element_by_id('back_top')
                        back.click()
                        x += 1
                    except (TimeoutException, ElementNotInteractableException):
                        driver.refresh()
                        wait.until(
                            EC.presence_of_element_located((
                                By.CSS_SELECTOR,
                                '#captcha_container_2 > div:nth-child(1) > div:nth-child('
                                '1) > span:nth-child(3) > a:nth-child(7) > img:nth-child(1)')))
                        driver.find_element_by_css_selector('input.button:nth-child(2)').click()
                        nonlocal courtComp
                        courtComp = courtComp - 1
                        return print(
                            'While Downloading record for '
                            + nameCourtComp + ' error occured, retrying now...')
                else:
                    time.sleep(2)
                    driver.find_element_by_css_selector('input.button:nth-child(2)').click()

        courtComp = 1
        courtComplexDownload = Select(driver.find_element_by_css_selector('#court_complex_code'))
        courtComplexDownloadList = courtComplexDownload.options
        courtComplexLen = len(courtComplexDownloadList)
        while courtComp < courtComplexLen:
            nameCourtComp = courtComplexDownloadList(courtComp).text
            courtComplexDownload.select_by_index(courtComp)
            try:
                wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#actcode > option:nth-child(1791)')))
                driver.find_element_by_css_selector('#actcode > option:nth-child(1791)').click()
            except (NoSuchElementException, TimeoutException):
                print(nameCourtComp + ' has no option for PoA')
                courtComp += 1
                continue

            captchcrack()
            incorrectcaptcha()
            while driver.find_element_by_css_selector('#waitmsg').is_displayed():
                time.sleep(1)
            if driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').is_displayed():
                courtComp += 1
                continue
            else:
                record()
                courtComp += 1
                continue

    districtListDropdown = Select(driver.find_element_by_css_selector("#sateist"))
    distOptions = districtListDropdown.options
    lenOpts = len(distOptions) - int(1)
    i = 1
    while i <= lenOpts:

            wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#sateist')))
            # change the name latter. set it to format as per name of the state.
            newDistDropDown = Select(driver.find_element_by_css_selector("#sateist"))
            newDistOptions = newDistDropDown.options
            dateToday = datetime.datetime.now()
            newDistName = newDistOptions(i).text
            newDistNameDict = newDistName + '_' + str(dateToday.day) + '_' + str(dateToday.month) + '_' + str(
                dateToday.year)
            newDistDropDown.select_by_index(i)
            distDir = os.path.join('/home/sangharshmanuski/Documents/e_courts/mha/downloads3', newDistNameDict)
            if not os.path.exists(distDir):
                os.mkdir(distDir)
            # wait for new District Court page to upload fully.
            headingDist = driver.find_element_by_css_selector('.heading')
            if headingDist.text.lower() == newDistName.lower():
                wait.until(
                    EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.accordion2:nth-child(2)'))).click()
                current = driver.window_handles(0)
                wait.until(EC.element_to_be_clickable(
                    (By.CSS_SELECTOR,
                     'div.panel:nth-child(3) > ul:nth-child(1) > li:nth-child(6) > a:nth-child(1)'))).click()
                # wait until new tab opens.
                wait.until(EC.number_of_windows_to_be(2))
                # define new tab by differentiating from current tab.
                newWindow = (window for window in driver.window_handles if window != current)(0)
                # switch to the new tab. ref: https://stackoverflow.com/questions/41571217/python-3-5-selenium-how-to-handle-a-new-window-and-wait-until-it-is-fully-lo
                driver.switch_to.window(newWindow)
                # wait till court complex list appears.
                wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#court_complex_code')))
                # create list of all court complex.
                # 2 approaches - 1 select 2 click.
                time.sleep(5)
                complex_and_act()
                driver.close()
                print("all court complexes in " + newDistName + " completed")
                driver.switch_to.window(current)
                driver.back()

            else:
                time.sleep(5)
                continue
            i += 1

    else:
        return print("all districts completed")


wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, "#sateist > option:nth-child(22)")))
select = Select(driver.find_element_by_css_selector('#sateist'))
options = select.options
select.select_by_visible_text('Maharashtra')
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '.region')))
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#sateist')))

district()

The error message:

 > Traceback (most recent call last):   File
    > "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line
    > 234, in 
    >     district()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line
    > 212, in district
    >     complex_and_act()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line
    > 163, in complex_and_act
    >     incorrectcaptcha()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line
    > 99, in incorrectcaptcha
    >     while driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').is_displayed():   File
    > "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py",
    > line 598, in find_element_by_css_selector
    >     return self.find_element(by=By.CSS_SELECTOR, value=css_selector)   File
    > "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py",
    > line 978, in find_element
    >     'value': value})('value')   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py",
    > line 321, in execute
    >     self.error_handler.check_response(response)   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/erroTraceback (most recent call last):   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line 234, in 
    district()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line 212, in district
    complex_and_act()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line 163, in complex_and_act
    incorrectcaptcha()   File "/home/sangharshmanuski/Documents/e_courts/code_2/function_3.py", line 99, in incorrectcaptcha
    while driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').is_displayed():   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 598, in find_element_by_css_selector
    return self.find_element(by=By.CSS_SELECTOR, value=css_selector)   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})('value')   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)   File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: #errSpan > p:nth-child(1) rhandler.py",
    > line 242, in check_response
    >     raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to
    > locate element: #errSpan > p:nth-child(1)

I hope the question is appropriate here. If not, please let me know, I will remove it. Thanks in advance!

How do you solve this sum of series? is a bit complicated.

$ a left (b + c right) left (Σ frac {x ^ { left (r-1 right)}} { left ( left ( frac { left (x ^ r-1 ))) right)} {x-1} right) left (b + c right) + ax ^ { left (r-1 right)} right) left ( frac { left ( x ^ { left (r + 1 right)} – ​​1 right)} {x-1} left (b + c right) + ax ^ r right)} right) $
How can we approach a problem of this complexity?

Why is the search algorithm for the width of the MIT lecture so complicated?

I watched a video for BFS from MIT and the algorithm that the lecturer presented was really complicated compared to what I came up with. My solution seems to work well and go through the key points in the correct order. I miss something

public static void BFS(GraphNode currentNode, GraphNode searchedNode) {
    if (currentNode.index == searchedNode.index) {
        System.out.println("Found!");
        return;
    }

    if (visited(currentNode.index)) {
        return;
    }

    visited(currentNode.index) = true;

    for (GraphNode child : currentNode.children) {
        if (!visited(child.index)) {
            nodeQueue.add(child);
        }
    }

    if (!nodeQueue.isEmpty()) {
        BFS(nodeQueue.poll(), searchedNode);
    }
}

One disadvantage is that it continues to run after a node is found. However, this can be easily fixed by clearing the queue when an item is found.