aboutsummaryrefslogtreecommitdiff
path: root/challenge-139/mohammad-anwar/python/ch-1.py
blob: 813afb43dfba249e47f20459ab2df763829ebd11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3

'''

Week 139:

    https://theweeklychallenge.org/blog/perl-weekly-challenge-139

Task #1: JortSort

    You are given a list of numbers.

    Write a script to implement JortSort. It should return true/false depending if the given list of numbers are already sorted.

'''

import unittest
import numpy as np
from copy import deepcopy

def jortsort(n = [], *args):
    s = deepcopy(n)
    s.sort()

    index = 0
    while index < len(n):
        if s[index] != n[index]:
            return 0

        index += 1

    return 1

#
#
# Unit test class

class TestJortSort(unittest.TestCase):

    def test_example_1(self):
        self.assertEqual(jortsort([1,2,3,4,5]), 1, 'Example 1')

    def test_example_2(self):
        self.assertEqual(jortsort([1,3,2,4,5]), 0, 'Example 2')

unittest.main()