Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming_Project_Group_14
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2032074
Programming_Project_Group_14
Commits
df50fff4
Commit
df50fff4
authored
4 years ago
by
s2032074
Browse files
Options
Downloads
Patches
Plain Diff
the length of the correct sequence is calculated
parent
56078b1e
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sequence_update.py
+24
-2
24 additions, 2 deletions
sequence_update.py
with
24 additions
and
2 deletions
sequence_update.py
+
24
−
2
View file @
df50fff4
...
...
@@ -173,17 +173,39 @@ class Sequence:
k
=-
1
#we can compare sequences only if they are of the same length
if
len
(
user_seq
)
!
=
len
(
self
.
sequence
):
if
len
(
user_seq
)
=
=
len
(
self
.
sequence
):
k
=
0
#the loop comparing two sequences by comparing each pair of elements
for
i
in
range
(
len
(
self
.
sequence
)):
#if elements on the same position in two sequences are not equal,
#then the counter is getting +1
if
user_seq
[
i
].
ID
=
=
self
.
sequence
[
i
].
ID
:
if
user_seq
[
i
].
ID
!
=
self
.
sequence
[
i
].
ID
:
k
=
k
+
1
return
k
# user_seq -- the sequence which user entered
def
compare_sequences_length
(
self
,
user_seq
):
'''
this method compares sequences and returns the length of the correctly repeated sequence
'''
#k -- counter for errors that user made while repeating the pattern
#if this metod returns -1, we know that there is an error in input
k
=-
1
#we can compare sequences only if they are of the same length
if
len
(
user_seq
)
==
len
(
self
.
sequence
):
k
=
0
#the loop comparing two sequences by comparing each pair of elements
for
i
in
range
(
len
(
self
.
sequence
)):
#if elements on the same position in two sequences are not equal,
#then then break
if
user_seq
[
i
].
ID
!=
self
.
sequence
[
i
].
ID
:
break
#if elements on the same position are equal, the length of the correct
#sequence is increased by 1
k
=
k
+
1
return
k
#this class will be tested, thus, we need this main method
#as it sets the environment where we are going to test
def
main
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment