Problem:


Insertion Sort

Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:

for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key

Note that, indices for array elements are based on 0-origin.

To illustrate the algorithms, your program should trace intermediate result for each step.

Input

The first line of the input includes an integer N, the number of elements in the sequence.

In the second line, N elements of the sequence are given separated by a single space.

Output

The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.

Constraints

1 ≤ N ≤ 100

Sample Input 1

6
5 2 4 6 1 3

Sample Output 1

5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3
1 2 3
1 2 3

Hint

Template in C



Sample input:
6
5 2 4 6 1 3


Sample output:
5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
size = int(input())
line = list(map(int, input().split()))

def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v


def main():
    insertionSort(line, size)
    ans = " ".join(map(str, line))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = input()
A = map(int,raw_input().split())

for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for i in range(N-1):
        print A[i],
    print A[-1]

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
for i in range(1,n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1 
    a[j+1] = v
    print(" ".join(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
def insertionSort(ary,num):
    for i in range(1,n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1 
        a[j+1] = v
        print(" ".join(a))
insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
def insertionSort(ary,num):
    for i in range(1,n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1 
        a[j+1] = v
        print(" ".join(a).rstrip())

insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
def insertionSort(ary,num):
    for i in range(n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1 
        a[j+1] = v
        print(" ".join(a).rstrip())

insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
def insertionSort(ary,num):
    for i in range(1,n):
        v = a[i]
        j = i -1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1 
        a[j+1] = v
        print(" ".join(a).rstrip())
print(" ".join(a).rstrip())
insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
def print_list(ele_list):
    print(" ".join(map(str, ele_list)))

def insertion_sort(ele_list):
    len_ele_list = len(ele_list)
    for i in range(1, len_ele_list):
        key = ele_list[i]
        j = i - 1
        while j >= 0 and ele_list[j] > key:
            ele_list[j+1] = ele_list[j]
            j -= 1
        ele_list[j+1] = key
        print_list(ele_list)

N = int(input())
ele_list = list(map(int, input().split()))

insertion_sort(ele_list)

Submission status: Wrong Answer

Solution code:
# 3.2

# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    print(' '.join(map(str, a)))

Submission status: Wrong Answer

Solution code:
# 3.2

import sys

# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    #print(' '.join(map(str, a)))
    sys.stdout.write(' '.join(map(str, a)))
    sys.stdout.write('\n')

Submission status: Wrong Answer

Solution code:
# 3.2

import sys

# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    #print(' '.join(map(str, a)))
    sys.stdout.write(' '.join(map(str, a)))
    if i != N - 1:
        sys.stdout.write('\n')

Submission status: Wrong Answer

Solution code:
# 3.2

import sys

# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    print(" ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
# 3.2
# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???

for i in range(1, N):
    tmp = a[i]
    j = i - 1
    while j >= 0 and a[j] > tmp:
        a[j + 1] = a[j]
        j -= 1
    
    a[j + 1] = tmp
    print(" ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
size = int(input())
element = list(map(int,input().split()))

for i in range(1,len(element)):
    v = element[i]
    j = i-1
    while j >=0 and element[j] > v:
        element[j+1] = element[j]
        j -=1
        element[j+1] = v
    print(" ".join(list(map(str,element))))

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    for i,v in enumerate(A):
        j = i-1
        while j>=0 and A[j] > v:
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(A)

N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
#ALDS1_1-A
def insertionSort(A,N):
    for i in range(N-1):
        v=A[i+1]
        j=i
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        stri = ""
        for i in range(N-1):
            stri+=str(A[i])+" "
        stri+=str(A[5])
        print(stri)
N=int(input())
A=[int(x) for x in input().split()]
stri = ""
for i in range(N-1):
    stri+=str(A[i])+" "
stri+=str(A[5])
print(stri)
insertionSort(A,N)

Submission status: Wrong Answer

Solution code:
def insertionsort(x):
    for i in range(len(x)):
        for k in range(i, 0, -1):
            if x[k-1] > x[k]:
                x[k-1], x[k] = x[k], x[k-1]
        print(" ".join(map(str, x)))


if __name__ == "__main__":
    input()
    insertionsort(input().split(" "))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(A) for A in input().split()]
for i in range(1, N):
    j = i -1
    v = A[i]
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(A) for A in input().split()]
for i in range(1, N):
    j = i -1
    v = A[i]
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for k in range(N):
        if k == N -1:
            print("{}".format(A[k]))
        else:
            print("{}".format(A[k]), end = " ")

Submission status: Wrong Answer

Solution code:
def insertionSort(N,A): 
    for i in range(0,N):
        innum = A[i]
        j = i - 1
        while j>=0 and innum < A[j]:
            A[j+1] = A[j]
            j = j -1
        A[j+1] = innum
        for j in range(0,N):
            if j < 5:
                print(A[j], end=" ")
            else:
                print(A[j])

    
    return A

if __name__ == "__main__":
    N = input()
    N = int(N)
    A = input()
    A = A.split()
    for i in range(0,N):
        A[i] = int(A[i])
    insertionSort(N,A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = (input()).split()
for i in range(0,N):
    A[i] = int(A[i])
for i in range(0,N):
    innum = A[i]
    j = i - 1
    while j>=0 and innum < A[j]:
        A[j+1] = A[j]
        j = j -1
    A[j+1] = innum
    for j in range(0,N):
        if j < 5:
            print(A[j], end=" ")
        else:
            print(A[j])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(A) for A in input().split()]
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for cnt in range(N):
        if cnt == N - 1:
            print("{}".format(A[cnt]))
        else:
            print("{}".format(A[cnt]), end=' ')

Submission status: Wrong Answer

Solution code:
def insertion_sort(A, N):
    for i  in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v

def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    
    insertion_sort(A, N)
    
    print(' '.join(map(str, A)))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def insertionSort(*args):
    l = list(args)
    for i in range(1, n):
        v = l[i]
        j = i - 1
        while j >= 0 and l[j] > v:
            l[j + 1] = l[j]
            j -= 1
            l[j + 1] = v
        print ' '.join(map(str, l))

n = input()
l = map(int, raw_input().split())
insertionSort(*l)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
?????\?????????

N ??????????´????????????°??? A ????????????????????????????????\????????????????????°????????????????????????????????????

1 insertionSort(A, N) // N??????????´??????????0-?????????????????????A
2   for i ??? 1 ?????? N-1 ?????§
3     v = A[i]
4     j = i - 1
5     while j >= 0 ?????? A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v

????????????????????????????????¢?????´????????????????£??????????????????????
??¢?????´??????????????????????¢???????????????????????¨??????????????????§?????????
?????\?????´??????????????¨?????? i ??????????????????????????´?????????????????????????????????????????????

"""

def iSort(A,N):
    """ ?????\????????? """
#    print(" ".join(map(str,A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >=0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))

# ?????????
num = int(input().strip())
arr = list(map(int,input().strip().split()))
iSort(arr,num)

Submission status: Wrong Answer

Solution code:
len = int(input())
Arr = [int(i) for i in input().split()]
print([Arr[i] for i in range(len)])

for i in range(1, len):
    v = Arr[i]
    j = i - 1
    while j >= 0 and Arr[j] > v:
        Arr[j + 1] = Arr[j]
        j -= 1
    Arr[j + 1] = v
    print([Arr[i] for i in range(len)])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N):
    # ?????????????±?
    v = A[i]
    # ????????????????????????????????¨???
    j = i - 1
    # ?????????????????¨????????????????????§????????????
    # ????±? > ??????????±????????????????????±???????????????????1?????????????????? j ?????????????????????
    # ????±? < ??????????±??????????break ??????????????´??????
    while j >= 0 and A[j] > v:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(' '.join(map(str, A)))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))

for i in range(n):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    print(A)

Submission status: Wrong Answer

Solution code:
n = raw_input()
A = map(int, raw_input().split())

for i in range(1, len(A)):
    j = i - 1
    tmp = A[i]
    while A[j] > tmp and j >= 0:
        tmp2 = A[j]
        A[j] = tmp
        A[j+1] = tmp2
        j -= 1
        
    for i in range(0, len(A)):
        if i == len(A)-1:
            print A[i]
        else:
            print A[i],

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
for i in range(1,N):
    j=i-1
    v=A[i]
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    print(A)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
for i in range(1,N):
    j=i-1
    v=A[i]
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    B=""
    for k in range(N):
        B+=str(A[k])+" "
    print(B)

Submission status: Wrong Answer

Solution code:
"""
1 insertionSort(A, N) // N??????????´??????????0-?????????????????????A
2   for i ??? 1 ?????? N-1 ?????§
3     v = A[i]
4     j = i - 1
5     while j >= 0 ?????? A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
"""
N=int(input())
A=input().split()
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    for j in range(N):
        print(str(A[j]),end=' ')
        if j==N-1:
            print('\b')

Submission status: Wrong Answer

Solution code:

N=int(input())
A=input().split()
for i in range(1,N):
    v=A[i]
    j=i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    for j in range(N):
        print(str(A[j]),end=' ')
        if j==N-1:
            print('\b')

Submission status: Wrong Answer

Solution code:
"""
for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key
"""

def sort(A):
    for i in range(1,len(A)):
        key=A[i]
        j=i-1
        while j>=0 and A[j]>key:
            A[j+1]=A[j]
            j-=1
        A[j+1]=key
        for j in range(len(A)):
            print(A[j],end=' ')
            print('\b\n',end='')

N=int(input())
A=input().split()
print(len(A))
sort(A)

Submission status: Wrong Answer

Solution code:
"""
for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key
"""

def sort(A):
    for i in range(1,len(A)):
        key=A[i]
        j=i-1
        while j>=0 and A[j]>key:
            A[j+1]=A[j]
            j-=1
        A[j+1]=key
        for j in range(len(A)):
            print(A[j],end=' ')
            print('\b\n',end='')

N=int(input())
A=input().split()
print(N)
sort(A)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=list(map(int,input().split()))
for i in range(1,n):
    v=z[i]
    j=i-1
    while j>=0 and z[j]>v:
        z[j+1]=z[j]
        j-=1
        
    z[j+1]=v
    print(' '.join(str(z)))

Submission status: Wrong Answer

Solution code:
n=int(input())
z=list(map(int,input().split()))
for i in range(1,n):
    v=z[i]
    j=i-1
    while j>=0 and z[j]>v:
        z[j+1]=z[j]
        j-=1
        
    z[j+1]=v
    print(' '.join([str(i) for i in z ]))

Submission status: Wrong Answer

Solution code:
def insertionSort(A,N):
    print(A)
    for i in range(1,N):
        v=A[i]
        j=i-1
        while j>=0 and A[j]>v:
            A[j+1]=A[j]
            j-=1
        A[j+1]=v
        print(A)


N=int(input())
sl=input()
lis=list(map(int,sl.split()))
insertionSort(lis,N)

Submission status: Wrong Answer

Solution code:
num = int(input())
array = list(map(int,input().split()))

for i in range(num):
    v = array[i]
    j = i-1
    while j >=0 and array[j]>v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print(array)

Submission status: Wrong Answer

Solution code:
size=int(input())
raw=input().split(" ")
print(' '.join(map(str, raw)))
for i in range(1,size):
    v=raw[i]
    j=i-1
    while j>=0 and raw[j]>v:
        raw[j+1]=raw[j]
        j-=1
    raw[j+1]=v
    print(' '.join(map(str, raw)))

Submission status: Wrong Answer

Solution code:
nums  = int(input())
array = list(map(int, input().split()))

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print(array)

Submission status: Wrong Answer

Solution code:
nums  = int(input())
array = list(map(int, input().split()))

for i in range( 1, nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print(*array)

Submission status: Wrong Answer

Solution code:
nums  = int(input())
array = list(map(int, input().split()))

for i in range( nums ):
    v = array[i]
    j = i - 1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    print(array)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = map(int,raw_input().split())
for i in range(1,n):
    v = lst[i]
    j = i - 1
    while j >= 0 and lst[j] > v:
        lst[j+1] = lst[j]
        j -= 1
    lst[j+1] = v
    print ' '.join(map(str, lst))

Submission status: Wrong Answer

Solution code:
n = int(input())

array = input().split()

intarr = [int(x) for x in array]
print(intarr)

for c in range(1,n):
    v = intarr[c]
    j = c-1
    while j>=0 and intarr[j]>v:
        intarr[j+1] = intarr[j]
        j -= 1
    intarr[j+1] = v
    print(intarr)

Submission status: Wrong Answer

Solution code:
n = int(input())

array = input().split()

intarr = [int(x) for x in array]
print(intarr)

for c in range(1,n):
    v = intarr[c]
    j = c-1
    while j>=0 and intarr[j]>v:
        intarr[j+1] = intarr[j]
        j -= 1
    intarr[j+1] = v
    for x in intarr:
        print(x,end=' ')
        if x == intarr[-1]:
            print()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1, n):
    k, j = a[i], i-1
    while j >= 0 and a[j] > k:
        a[j+1], j = a[j], j-1
    a[j+1] = k
    print(*a)

Submission status: Wrong Answer

Solution code:



if __name__ == '__main__':
    N = (int)(input())
    A = list(map(int,input().split()))

    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j -1
        A[j+1] = v
        if i == N - 1:
            print(' '.join(map(str,A)),end = '')
        else:
            print(' '.join(map(str,A)))

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    nums = list(input())
    insertionSort(nums)



def insertionSort(nums):
    for i in range(1,len(nums)):
        v = nums[i]
        j = i - 1
        while j >= 0 and nums[j] > v:
            nums[j+1] = nums[j]
            j -= 1
        nums[j+1] = v
        print(' '.join(nums))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding : utf-8 -*-
input()
seq = input().split()
for i in range(len(seq)):
    j = i - 1
    key = seq[i]
    assert isinstance(i, int)
    while j >= 0 and seq[j] > key:
        seq[j + 1] = seq[j]
        j -= 1
    seq[j + 1] = key
    print(seq)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding : utf-8 -*-
input()
seq = input().split()
for i in range(len(seq)):
    j = i - 1
    key = seq[i]
    assert isinstance(i, int)
    while j >= 0 and seq[j] > key:
        seq[j + 1] = seq[j]
        j -= 1
    seq[j + 1] = key
    print(' '.join(seq))

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding : utf-8 -*-
input()
seq = input().split()
for i in range(0, len(seq)):
    key = seq[i]
    j = i - 1
    assert isinstance(i, int)
    while j >= 0 and seq[j] > key:
        seq[j + 1] = seq[j]
        j -= 1
    seq[j + 1] = key
    print(' '.join(seq))

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int,input().split()))

for i in range(1,n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    for k in range(n):
        if k == n-1:
            print(a[k],end='')
        else:
            print(a[k],end=' ')
    print()

Submission status: Wrong Answer

Solution code:
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str,A)))

    return A

n = int(input())
a = list(map(int, input().split()))
insertionSort(a, n)

Submission status: Wrong Answer

Solution code:
def insertionSort(lst, n):
    for i in range(1, n):
        v = lst[i]
        j = i - 1
        while j >= 0 and lst[j] > v:
            lst[j+1] = lst[j]
            j = j - 1
        lst[j+1] = v
        print(lst)


if __name__ == "__main__":
    n = int(input())
    lst = [int(n) for n in input().split()]
    print(lst)
    insertionSort(lst, n)

Submission status: Wrong Answer

Solution code:
def insertionSort(lst, n):
    for i in range(1, n):
        v = lst[i]
        for j in range(0, i):
            if lst[j] > v:
                lst.insert(j, lst.pop(i))
                break

        print(" ".join([str(n) for n in lst]))

    return lst


if __name__ == "__main__":
    n = int(input())
    lst = [int(n) for n in input().split()]
    insertionSort(lst, n)

Submission status: Wrong Answer

Solution code:
def insersionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print " ".join([str(i) for i in A])
    return A

if __name__ == "__main__":
    N = int(raw_input())
    A = map(int, raw_input().split())
    insersionSort(A, N)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def insersionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print " ".join([str(i) for i in A])

if __name__ == "__main__":
    N = int(raw_input())
    A = map(int, raw_input().split())
    insersionSort(A, N)

Submission status: Wrong Answer

Solution code:
def insersionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print " ".join([str(k) for k in A])

if __name__ == "__main__":
    N = int(raw_input())
    A = map(int, raw_input().split())
    insersionSort(A, N)

Submission status: Wrong Answer

Solution code:
kazu=int(input())
A=[int(i) for i in range(kazu)]
# kazu=6
# A=[5,2,4,6,1,3]

j=0
for i in range(kazu - 1):
    print(A[i], end=" ")
print(A[kazu-1])

for i in range(1,kazu):
    v=A[i]
    j=i-1

    while j>=0 and A[j] >v:
        A[j+1]=A[j]
        j =j -1
        A[j+1]=v
    for i in range(kazu-1):
        print(A[i],end=" ")
    print(A[kazu-1])

Submission status: Wrong Answer

Solution code:
kazu=int(input())
A=[int(i) for i in range(kazu)]
# kazu=6
# A=[5,2,4,6,1,3]

j=0
for i in range(kazu - 1):
    print(A[i], end=" ")
print(A[kazu-1],end="")

for i in range(1,kazu):
    v=A[i]
    j=i-1

    while j>=0 and A[j] >v:
        A[j+1]=A[j]
        j =j -1
        A[j+1]=v
    for i in range(kazu-1):
        print(A[i],end=" ")
    print(A[kazu-1],end="")

Submission status: Wrong Answer

Solution code:
kazu=int(input())
A=[int(i) for i in range(kazu)]

j=0
for i in range(kazu - 1):
    print(A[i], end=" ")
print(A[kazu-1],end="")

for i in range(1,kazu):
    v=A[i]
    j=i-1

    while j>=0 and A[j] >v:
        A[j+1]=A[j]
        j =j -1
        A[j+1]=v
    for i in range(kazu-1):
        print(A[i],end=" ")
    print(A[kazu-1],end="")

Submission status: Wrong Answer

Solution code:
#coding: UTF-8

k=[26,5,6,95,1]

def insert_sort(buff):
    k = len(buff)
    for i in xrange(1, k):
        temp = buff[i]
        j = i - 1
        while j >= 0 and temp < buff[j]:
            buff[j + 1] = buff[j]
            j -= 1
        buff[j + 1] = temp
print k

Submission status: Wrong Answer

Solution code:
def insertion_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1

        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A)

    return A

N = int(input())
A = list(map(int, input().split()))

A = insertion_sort(A, N)
print(*A)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]

for i in range(n-1):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
  print(" ".join([str(k) for k in l]))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]

for i in range(n-1):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key

print(" ".join([str(k) for k in l]))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]

for i in range(n-1):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
print(" ".join([str(k) for k in l]))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]
print(n)
 
for i in range(n-1):
  key = l[i + 1]
  j = i
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
 
print(" ".join([str(k) for k in l]))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]
print(n)
 
for i in range(1,n):
  key = l[i]
  j = i - 1
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
  print(" ".join(str(x) for x in l))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]
 
for i in range(1,n):
  key = l[i]
  j = i - 1
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
  print(" ".join(str(x) for x in l))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [int(m) for m in input().split() ]
  
for i in range(1,n):
  key = l[i]
  j = i - 1
  while j >= 0 and l[j] > key:
    l[j+1] = l[j]
    j -= 1
  l[j+1] = key
  print(" ".join(str(x) for x in l))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, N):
  v = a[i]
  j = i - 1
  while j >= 0 and a[j] > v:
    a[j + 1] = a[j]
    j -= 1
    a[j + 1] = v
    print(*a)

Submission status: Wrong Answer

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

Submission status: Wrong Answer

Solution code:
N = int(input())
array = map(int, input().split())
print(*array)

for i in range(1, N-1):
    print(*array)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int, input().split()))
for i in range(n):
    l[0:i]=sorted(l[0:i])
    print(l)

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
l=list(map(int, raw_input().split()))
for i in range(1,n+1):
    l[0:i]=sorted(l[0:i])
    print l

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
for i in range(1,n):
    v = x[i]
    j = i - 1
    while j >= 0:
        if x[j] > v:
            x[j + 1] = x[j]
            x[j] = v
        j += -1
    print (*x)

Submission status: Wrong Answer

Solution code:
def insertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(A)

n = int(input())
a = [int(i) for i in input().split()]

insertionSort(a,n)

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input()
nums = line.split(" ")

print(line)
for i in range(1, n):
    v = nums[i]
    j = i-1
    while j >= 0 and nums[j] > v:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    num_line = ""
    for num in nums:
        num_line += num
        num_line += " "    
    print(num_line.rstrip(" "))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and v<A[j]:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    print(A)

Submission status: Wrong Answer

Solution code:
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)
    print(arr)

    insetionSort(li=arr, length=n)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 1000:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def insetionSort(li, length):
    for i in range(1, length):
        v = li[i]
        j = i - 1
        while j >= 0 and li[j] > v:
            li[j + 1] = li[j]
            j -= 1

        li[j + 1] = v
        print(li)


main()

Submission status: Wrong Answer

Solution code:
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)
    print(arr, end='\n')

    insetionSort(li=arr, length=n)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 1000:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def insetionSort(li, length):
    for i in range(1, length):
        v = li[i]
        j = i - 1
        while j >= 0 and li[j] > v:
            li[j + 1] = li[j]
            j -= 1

        li[j + 1] = v
        print(li, end='\n')


main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(x) for x in input().split()]

for i in range(1, n):
    key = A[i]
    j = i-1
    while j >=0 and A[j] > key:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
    print(" ".join([str(x) for x in A]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
print(n,a)

def insertionSort(a,n):
    for i in range(n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v 
        print(" ".join(map(str, a)))
        
insertionSort(a,n)