Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
L4-HW final
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.5.2 def x(y): length=len(y) p=0 while p<length: # print ('p: ', p) i=0 while i<((length-1)-p): #print ('Possible values for i:',i) if y[i] > y[i+1]: temp = y[i] y[i] = y[i+1] y[i+1] = temp i=i+1 p=p+1 #print (i,'-->',y) # print () # print ('------------------------------------------------') return y Input=[3,1,1,5,2] print('y=',Input) R=x(Input) print('R=',R)
[
+
]
Show input
Absolute running time: 0.24 sec, cpu time: 0.18 sec, memory peak: 6 Mb, absolute service time: 0,25 sec
edit mode
|
history
|
discussion
y= [3, 1, 1, 5, 2] R= [1, 1, 3, 2, 5]