Solve number sorting (equivalent to paiza rank D) in Python

at first

I was solving a collection of paiza level-up questions, but I didn't have a model answer, so I made it myself. The language is Python3.

problem

Sorting the number of Paiza skill check sample questions (equivalent to paiza rank D) https://paiza.jp/works/mondai/skillcheck_sample/sort-number?language_uid=python3 I couldn't see the problem statement without logging in. Registration is free and can be done immediately, so I recommend you to register for the time being.

Answer code

I wrote the bubble sort myself.

sort-number.py


#Save the entered value
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

#Bubble sort
def bSort(a):
    for i in range(len(a)-1):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a

#Output the answer
for i in bSort(a):
    print(i)

reference

https://qiita.com/KoyanagiHitoshi/items/3286fbc65d56dd67737c

Finally

Feel free to comment if you have any questions. I will answer as much as possible!

Recommended Posts

Solve number sorting (equivalent to paiza rank D) in Python
Solve addition (equivalent to paiza rank D) in Python
Solve multiplication (equivalent to paiza rank D) in Python
Solve character matches (equivalent to paiza rank D) in Python
Solve the smallest value in Python (equivalent to paiza rank D)
Solve island hunting (equivalent to paiza rank S) in Python
Solve word counts (equivalent to paiza rank C) in Python
Solve mod7 fortune-telling (equivalent to paiza rank S) in Python
Solve Fizz Buzz (equivalent to paiza rank C) in Python
[With commentary] Solve Fizz Buzz (equivalent to paiza rank C) in Python
Solve ABC175 D in Python
ABC 157 D --Solve Friend Suggestions in Python!
I wanted to solve ABC159 in Python
Solve ABC165 A, B, D in Python
Sorting AtCoder ARC 086 C hashes to solve in Ruby, Perl, Java and Python
Solve ABC168D in Python
Solve ABC167-D in Python
Basic sorting in Python
Solve ABC146-C in Python
Solve ABC098-C in Python
Solve ABC159-D in Python
Solve ABC169 in Python
Prime number 2 in Python
Solve ABC160-E in Python
How to get the number of digits in Python
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
I tried to solve AOJ's number theory with Python
To flush stdout in Python
Login to website in Python
Processing of python3 that seems to be usable in paiza
Solve ABC176 E in Python
Techniques for sorting in Python
Solve Wooldridge exercises in Python
Speech to speech in python [text to speech]
13th Offline Real-time How to Solve Writing Problems in Python
Solve optimization problems in Python
How to develop in Python
Post to Slack in Python
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
The 17th Offline Real-time How to Solve Writing Problems in Python
How to write offline real time Solve E04 problems in Python
I wanted to solve the ABC164 A ~ D problem with Python
How to display legend marks in one with Python 2D plot
Number recognition in images with Python
Convert markdown to PDF in Python
Sorting algorithm and implementation in Python
How to collect images in Python
Solve ABC166 A ~ D with Python
Infinite prime number generator in Python3
How to use SQLite in Python
Solve Atcoder ABC169 A-D in Python
In the python command python points to python3.8
Try to calculate Trace in Python
Solve ABC036 A ~ C in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
6 ways to string objects in Python
How to use PubChem in Python
Study, number guessing game in Python
Implementation of original sorting in Python