Skip to content
TheChatArchiveThe Chat Archive
Databricksdolly-v2-12b· DatabricksHugging Face Arena Human Preference 55K

Give me a python implementation of quicksort

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Stability AIstablelm-tuned-alpha-7b’s answer.
  1. User

    Give me a python implementation of quicksort

  2. Databricks Assistant

    The python code for quicksort is as follows:

    def quicksort(sequence): if len(sequence) > 1: p = partition(sequence, 1, len(sequence)) quicksort(sequence[:p]) quicksort(sequence[p+1:]) return sequence

    function partition(sequence, start, end) pivot = sequence[start] i = start j = end - 1 while i < j: while sequence[i] < pivot: i += 1 while sequence[j] > pivot: j -= 1 if i < j: sequence[i], sequence[j] = sequence[j], sequence[i] i += 1 j -= 1 return i

    Implementation of a Quicksort in python

  3. User

    Now, make the same algorithm in Haskell

  4. Databricks Assistant

    The haskell code for quicksort is as follows:

    quicksort [] = [] quicksort (p:ps) = qs ++ [x] ++ qs' where (qs, qs') = splitAt 1 ps x = p

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.