Giter VIP home page Giter VIP logo

fiestasort's Introduction

fiestaSort.c

ridiculous sorting algorithm lol

so a few weeks ago while I was bored I saw at a golf sorting question on the codegolf stackexchange
I can't remember the exact wording, but it more or less said "sort in the fewest number of bytes possible"

I also think the original question had an additional given that each value only appears once in the input,
I didn't take this into account and just wrote it generally tho

but I instead added my own restriction that I'd use C and not use a single for/do/while/if
wild right? xD

I remember some languages were able to do the original question in less than 5 bytes but I don't think that's possible in C lmao
anyway, I originaly wrote this code a while back, but I wasn't using git/github much at that point, might as well upload it now

also iirc, a number of the answers I saw were Bogosorts of some form, kinda just generating each permutation
but this one is provably O(n2) despite having a single mysterious goto
xD

fiestasort's People

Contributors

ekatwikz avatar

Watchers

 avatar

fiestasort's Issues

sz check is incorrect

size_t sz = atoi(...) is unsigned,
checking if (sz > 1) doesnt account for atoi returning a negative value because that shit
just gets reinterpreted as unsigned

could time(NULL) fail?

so the standard man 3p time says that time(NULL) could fail if the time difference would EOVERFLOW,
but man 2 time:

  • doesn't declare this error
  • declares a possible EFAULT instead, but not for time(NULL)
  • says tloc is becoming obsolete and it should always be time(NULL) anyway
  • says time(NULL) cannot fail

lmfao idk which one should we respect

degenerate arrays CAN be handled

USAGE(sz > 1) is a slick-ish band-aid for the fact that fiestaSort-ing an array with length 1 causes a heap buffer overflow.
we can simply start with j = 0 to fix this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.