Best Python code snippet using avocado_python
day13.py
Source:day13.py  
...36for i in fm_list[1:]:37  lcm = lcm*i//gcd(lcm, i)38print(lcm)39max_bus = buses.index(max(buses))40def check_buses(buses, ts0):41    new_ts = [(ts0 // x[1]) * x[1] + (x[0] // x[1])*x[1] + x[1] - x[0] for x in buses]42    new_ts[0] =  new_ts[0] - buses[0][1]43    check = new_ts[0]44    if new_ts.count(check) == len(new_ts):45        return True, buses46    else:47        return False, buses48stop = False49ts0 = fm_list[max_bus] - buses2[max_bus][0]50increment = buses2[0][1]*buses2[max_bus][1]51i = 052while not stop:53    i += 154    ts0 += increment55    stop, bs = check_buses(buses2, ts0)56    if i % 100000 == 0:57        pass58        #print(ts0)59print(ts0)60i = 261ch = True62while ch:63    if i % 20000 == 0: print(i)64    ts0 = buses2[max_bus][1]*i - buses2[max_bus][0]65    ch, lastb = check_buses(buses2, ts0)66    i += 167print(ts0)68"""...check_buses.py
Source:check_buses.py  
...9import os10import sys11from fps_sandbox.osu.check_layout import prepare_layout_data12from jaeger import FPS13async def check_buses(data):14    fps = await FPS.create()15    n_bus = {ii: [0, 0, 0, 0] for ii in range(1, 7)}16    for pid in fps.positioners:17        iface, bus = fps[pid].get_bus()18        iface += 119        n_bus[iface][bus - 1] += 120    for sextant in sorted(n_bus):21        for ibus, bus in enumerate(n_bus[sextant]):22            print(f"Sextant {sextant}, bus {ibus+1}: {n_bus[sextant][ibus]}.")23    for pid in fps.positioners:24        p_data = data.loc[pid]25        iface, bus = fps[pid].get_bus()26        if p_data.Sextant != iface + 1:27            print(f"Positioner {pid}. Mismatch layout (sextant, bus) "28                  f"({p_data.Sextant}, {p_data.CAN}) with measured "29                  f"({iface+1}, {bus}).")30        elif p_data.CAN != bus:31            print(f"Positioner {pid}. Mismatch layout (sextant, bus) "32                  f"({p_data.Sextant}, {p_data.CAN}) with measured "33                  f"({iface+1}, {bus}).")34if __name__ == "__main__":35    if len(sys.argv) > 1:36        data_file = sys.argv[1]37    else:38        data_file = os.path.join(39            os.path.dirname(__file__),40            "../data/SloanFPS_Assignments_2021Oct22.csv",41        )...I_Buses.py
Source:I_Buses.py  
1def makeminutes(time):2    h, m = time.split(':')3    return int(h)*60+int(m)4def check_buses(n, m, lines):5    cntbuses = [0]*(n+1)6    busbalance = [0]*(n+1)7    events = []8    overnight = 09    for line in lines:10        cdep, deptime, carr, arrtime = line.split()11        cdep = int(cdep)12        carr = int(carr)13        deptime = makeminutes(deptime)14        arrtime = makeminutes(arrtime)15        if arrtime < deptime:16            overnight += 117        busbalance[cdep] -= 118        busbalance[carr] += 119        events.append((deptime, 1, cdep))20        events.append((arrtime, -1, carr))21    disbalance = False22    for i in range(n+1):23        if busbalance[i] != 0:24            disbalance = True25    if disbalance:26        return '-1'27    events.sort()28    for event in events:29        if event[1] == -1:30            cntbuses[event[2]] += 131        else:32            if cntbuses[event[2]] > 0:33                cntbuses[event[2]] -= 134    ans = 035    for i in range(n+1):36        ans += cntbuses[i]37    return str(ans+overnight)38with open('input.txt') as file:39    lines = file.readlines()40    n, m = map(int, lines[0].split())41with open('output.txt', 'w') as file:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
