“Konversi fungsi Python ke javascript onlie” Kode Jawaban

Konversi fungsi Python ke javascript onlie

for i in range(len(Times)):
    mini=i  #To store minimum time index
    for j in range(i,len(Times)):
        #updating the minimum index
        if(Times[mini]>Times[j]): 
            mini=j
    #swapping the ith element with minimum element
    Times[mini],Times[i]=Times[i],Times[mini]

print("Fastest to slowest order: ",Times)
Troubled Tamarin

Konversi fungsi Python ke javascript onlie

def compute_interesting_times(s, t):
    def convert_number(x):
        pad = ''
        if x < 10:
            pad = '0'
        return pad + str(x)
        
    # Check times
    if s > t:
        raise ValueError("The init time is greater than the finishing time")
        
        
    # Parse times
    h_c, m_c, s_c = map(lambda x: int(x), s.split(':'))
    h_f, m_f, s_f = map(lambda x: int(x), t.split(':'))
    total = 0
    
    while not (h_c == h_c and m_c == m_f and s_c == s_f):
        # Transform the numbers into a proper string and
        # check if we have to increase the total
        a = '{}{}{}'.format(convert_number(h_c),
                            convert_number(m_c), 
                            convert_number(s_c))
        if len(set(a)) <= 2:
            total += 1
        
        # Update the time counters
        s_c += 1
        if s_c == 60:
            s_c = 0
            m_c += 1
            if m_c == 60:
                m_c = 0
                h_c += 1

    # Check if the finishing time is an interesting time
    a = '{}{}{}'.format(convert_number(h_c),
                            convert_number(m_c), 
                            convert_number(s_c))
    if len(set(a)) <= 2:
        total += 1

    return total
Modern Millipede

Jawaban yang mirip dengan “Konversi fungsi Python ke javascript onlie”

Pertanyaan yang mirip dengan “Konversi fungsi Python ke javascript onlie”

Lebih banyak jawaban terkait untuk “Konversi fungsi Python ke javascript onlie” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya