Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
47f55b7f
Commit
47f55b7f
authored
Jan 23, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of kompiler.org:trs
parents
77af3ae1
c09b8a63
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
29 deletions
+1
-29
src/rules/utils.py
src/rules/utils.py
+0
-17
tests/test_rules_utils.py
tests/test_rules_utils.py
+1
-12
No files found.
src/rules/utils.py
View file @
47f55b7f
...
@@ -10,23 +10,6 @@ def nary_node(operator, scope):
...
@@ -10,23 +10,6 @@ def nary_node(operator, scope):
else
Node
(
operator
,
nary_node
(
operator
,
scope
[:
-
1
]),
scope
[
-
1
])
else
Node
(
operator
,
nary_node
(
operator
,
scope
[:
-
1
]),
scope
[
-
1
])
def
is_prime
(
n
):
"""
Check if the given integer n is a prime number.
"""
if
n
==
2
:
return
True
if
n
<
2
or
not
n
&
1
:
return
False
for
i
in
xrange
(
3
,
int
(
n
**
.
5
)
+
1
,
2
):
if
not
divmod
(
n
,
i
)[
1
]:
return
False
return
True
def
gcd
(
a
,
b
):
def
gcd
(
a
,
b
):
"""
"""
Return greatest common divisor using Euclid's Algorithm.
Return greatest common divisor using Euclid's Algorithm.
...
...
tests/test_rules_utils.py
View file @
47f55b7f
from
src.node
import
ExpressionNode
as
N
from
src.node
import
ExpressionNode
as
N
from
src.rules.utils
import
nary_node
,
is_prime
,
least_common_multiple
from
src.rules.utils
import
nary_node
,
least_common_multiple
from
tests.rulestestcase
import
RulesTestCase
,
tree
from
tests.rulestestcase
import
RulesTestCase
,
tree
...
@@ -15,17 +15,6 @@ class TestRulesUtils(RulesTestCase):
...
@@ -15,17 +15,6 @@ class TestRulesUtils(RulesTestCase):
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
,
b
,
c
,
d
]),
self
.
assertEqualNodes
(
nary_node
(
'+'
,
[
a
,
b
,
c
,
d
]),
N
(
'+'
,
N
(
'+'
,
N
(
'+'
,
a
,
b
),
c
),
d
))
N
(
'+'
,
N
(
'+'
,
N
(
'+'
,
a
,
b
),
c
),
d
))
def
test_is_prime
(
self
):
self
.
assertTrue
(
is_prime
(
2
))
self
.
assertTrue
(
is_prime
(
3
))
self
.
assertTrue
(
is_prime
(
647
))
self
.
assertFalse
(
is_prime
(
0
))
self
.
assertFalse
(
is_prime
(
1
))
self
.
assertFalse
(
is_prime
(
4
))
self
.
assertFalse
(
is_prime
(
9
))
self
.
assertFalse
(
is_prime
(
100
))
def
test_least_common_multiple
(
self
):
def
test_least_common_multiple
(
self
):
self
.
assertEqual
(
least_common_multiple
(
5
,
6
),
30
)
self
.
assertEqual
(
least_common_multiple
(
5
,
6
),
30
)
self
.
assertEqual
(
least_common_multiple
(
5
,
6
,
15
),
30
)
self
.
assertEqual
(
least_common_multiple
(
5
,
6
,
15
),
30
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment