Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
698a1a73ade5ac0e19180fa6 Challenge 203: Flattened 29 challenge-203

--description--

Given an array, determine if it is flat.

  • An array is flat if none of its elements are arrays.

--hints--

is_flat([1, 2, 3, 4]) should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_flat([1, 2, 3, 4]), True)`)
}})

is_flat([1, [2, 3], 4]) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_flat([1, [2, 3], 4]), False)`)
}})

is_flat([1, 0, False, True, "a", "b"]) should return True.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_flat([1, 0, False, True, "a", "b"]), True)`)
}})

is_flat(["a", [0], "b", True]) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_flat(["a", [0], "b", True]), False)`)
}})

is_flat([1, [2, [3, [4, [5]]]], 6]) should return False.

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(is_flat([1, [2, [3, [4, [5]]]], 6]), False)`)
}})

--seed--

--seed-contents--

def is_flat(arr):

    return arr

--solutions--

def is_flat(arr):
    for el in arr:
        if isinstance(el, list):
            return False
    return True