Skip to main content
Clarified second rule
Source Link

Challenge

Create a sorting algorithm in as few bytes as possible. It can be, at worst, \$ O(n^2) \$. This can be insertion sort, mergesort, quicksort, or any other sorting algorithm with \$O(n^2)\$ time complexity.

Input

An array of numbers, such as [1,2,3] or [41,17,8].

Output

You can print an array of numbers in order, or you can print them (ordered) one by one. Sorting [3,1,2] could return:

[1,2,3]

or

1
2
3

Rules

  • Program must run in \$ O(n^2) \$ time or better
  • The main body of the program cannot be a call touse any sorting functions, libraries, etc. You can, however create a predefined function that sorts, such as .sort() in Python or {but it must be made from scratch in 05AB1Eyour program.

Test cases

[0,1,2,3] -> [0,1,2,3]

[5,2,8,91,4,6] -> [2,4,5,6,8,91]

[16,42,13,2,71] -> [2,13,16,42,71]

Challenge

Create a sorting algorithm in as few bytes as possible. It can be, at worst, \$ O(n^2) \$. This can be insertion sort, mergesort, quicksort, or any other sorting algorithm with \$O(n^2)\$ time complexity.

Input

An array of numbers, such as [1,2,3] or [41,17,8].

Output

You can print an array of numbers in order, or you can print them (ordered) one by one. Sorting [3,1,2] could return:

[1,2,3]

or

1
2
3

Rules

  • Program must run in \$ O(n^2) \$ time or better
  • The main body of the program cannot be a call to a predefined function, such as .sort() in Python or { in 05AB1E.

Test cases

[0,1,2,3] -> [0,1,2,3]

[5,2,8,91,4,6] -> [2,4,5,6,8,91]

[16,42,13,2,71] -> [2,13,16,42,71]

Challenge

Create a sorting algorithm in as few bytes as possible. It can be, at worst, \$ O(n^2) \$. This can be insertion sort, mergesort, quicksort, or any other sorting algorithm with \$O(n^2)\$ time complexity.

Input

An array of numbers, such as [1,2,3] or [41,17,8].

Output

You can print an array of numbers in order, or you can print them (ordered) one by one. Sorting [3,1,2] could return:

[1,2,3]

or

1
2
3

Rules

  • Program must run in \$ O(n^2) \$ time or better
  • The program cannot use any sorting functions, libraries, etc. You can, however create a function that sorts, but it must be made from scratch in your program.

Test cases

[0,1,2,3] -> [0,1,2,3]

[5,2,8,91,4,6] -> [2,4,5,6,8,91]

[16,42,13,2,71] -> [2,13,16,42,71]
Source Link

Challenge

Create a sorting algorithm in as few bytes as possible. It can be, at worst, \$ O(n^2) \$. This can be insertion sort, mergesort, quicksort, or any other sorting algorithm with \$O(n^2)\$ time complexity.

Input

An array of numbers, such as [1,2,3] or [41,17,8].

Output

You can print an array of numbers in order, or you can print them (ordered) one by one. Sorting [3,1,2] could return:

[1,2,3]

or

1
2
3

Rules

  • Program must run in \$ O(n^2) \$ time or better
  • The main body of the program cannot be a call to a predefined function, such as .sort() in Python or { in 05AB1E.

Test cases

[0,1,2,3] -> [0,1,2,3]

[5,2,8,91,4,6] -> [2,4,5,6,8,91]

[16,42,13,2,71] -> [2,13,16,42,71]