FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm-test-python/exercises.py at master · KNU-Software-Algorithms/algorithm-test-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
KNU-Software-Algorithms
/
algorithm-test-python
Public
forked from
Mobeye/algorithm-test-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm-test-python
/
exercises.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (36 loc) · 1.57 KB
Breadcrumbs
algorithm-test-python
/
exercises.py
Copy path
File metadata and controls
43 lines (36 loc) · 1.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
def
is_anagram
(
s1
,
s2
):
"""
Write an algorithm that returns whether s1 and s2 are anagrams of each other, i.e.
if s1 and s2 contain the same letters in a possibly different order.
E.g.: "abc" and "cab" are anagrams, "aab" and "bba" are not.
:param s1: string
:param s2: string
:return: True or False
"""
# Write your code here
pass
def
check_parenthesis_consistency
(
string
):
"""
Write an algorithm that determines if the parenthesis (round brackets "()") in a string are properly balanced.
An expression is said to be properly parenthesised if it has the form "(p)" or "pq", where p and q are
properly parenthesised expressions. Any string (including an empty string) that does not contain any parenthesis
is properly parenthesised.
E.g.: "()()" is properly parenthesised, "(()" is not.
:param string: the string to analyse.
:return: True if the parentheses are balanced, False if not.
"""
# Write your code here
pass
def
shortest_path
(
start
,
end
,
maze
):
"""
Write an algorithm that finds the shortest path in a maze from start to end
The maze is represented by a list of lists containing 0s and 1s:
0s are walls, paths cannot go through them
The only movements allowed are UP/DOWN/LEFT/RIGHT
:param start: tuple (x_start, y_start) - the starting point
:param end: tuple (x_end, y_end) - the ending point
:param maze: list of lists - the maze
:return: list of positions [(x1, y1), (x2, y2), ...] representing the shortest path in the maze
"""
# Write your code here
pass
Back
|
FazBrowse Home
|
New Git URL