Go to file
2023-05-01 23:49:29 +02:00
.gitignore initial commit. 2022-11-26 21:49:04 +01:00
makefile add v version. 2023-05-01 23:49:29 +02:00
README.md initial commit. 2022-11-26 21:49:04 +01:00
snail.c make "all tests passed" message uniform 2023-05-01 23:49:11 +02:00
snail.d add d version. 2022-11-27 10:14:11 +01:00
snail.nim add nim version. 2022-11-26 21:49:38 +01:00
snail.odin make "all tests passed" message uniform 2023-05-01 23:49:11 +02:00
snail.py add shebang to python script. 2023-04-23 22:12:34 +02:00
snail.rs add rust version. 2022-11-26 21:49:28 +01:00
snail.v add v version. 2023-05-01 23:49:29 +02:00

🐌 snail-sort

Implementations in various languages for the snail sorting algorithm, sorting an nxm rectangular, 2d array by traversing elements in a clockwise spiral.


Examples

Snail-sorting a 3x3 array:

    [                        
        [1, 2, 3],
        [4, 5, 6],
        [7, 8, 9],
    ]                        

    => [1, 2, 3, 6, 9, 8, 7, 4, 5]

Snail-sorting a 4x5 array:

    [                        
        [a, b, c, d, e],     
        [f, g, h, i, j],     
        [k, l, m, n, o],     
        [p, q, r, s, t]      
    ]                        

    => [a, b, c, d, e, j, o, t, s, r, q, p, k, f, g, h, i, n, m, l]