Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
projecteuler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Taddeüs Kroes
projecteuler
Commits
21186ede
Commit
21186ede
authored
12 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Moved some common functions to 'utils'
parent
4a07d490
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
frac.py
+0
-8
0 additions, 8 deletions
frac.py
problem243.py
+1
-1
1 addition, 1 deletion
problem243.py
problem33.py
+1
-1
1 addition, 1 deletion
problem33.py
problem41.py
+9
-21
9 additions, 21 deletions
problem41.py
utils.py
+9
-0
9 additions, 0 deletions
utils.py
with
20 additions
and
31 deletions
frac.py
deleted
100644 → 0
+
0
−
8
View file @
4a07d490
def
_gcd
(
a
,
b
):
while
b
:
a
,
b
=
b
,
a
%
b
return
a
def
gcd
(
*
args
):
return
reduce
(
_gcd
,
args
)
This diff is collapsed.
Click to expand it.
problem243.py
+
1
−
1
View file @
21186ede
#!/usr/bin/env python
from
__future__
import
division
from
prime
s
import
is_prime
,
nprimes
from
util
s
import
is_prime
,
nprimes
print
list
(
nprimes
(
15499
))
import
sys
;
sys
.
exit
()
...
...
This diff is collapsed.
Click to expand it.
problem33.py
+
1
−
1
View file @
21186ede
#!/usr/bin/env python
from
__future__
import
division
from
itertools
import
combinations
,
permutations
from
frac
import
gcd
from
utils
import
gcd
nrs
=
[(
i
,
str
(
i
))
for
i
in
xrange
(
10
,
100
)]
pairs
=
((
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
))
...
...
This diff is collapsed.
Click to expand it.
problem41.py
+
9
−
21
View file @
21186ede
#!/usr/bin/env python
def
is_prime
(
n
):
if
n
==
2
:
return
True
from
utils
import
is_prime
if
n
<
2
or
not
n
&
1
:
return
False
from
itertools
import
permutations
for
i
in
xrange
(
3
,
int
(
n
**
.
5
)
+
1
,
2
):
if
not
divmod
(
n
,
i
)[
1
]:
return
False
m
=
0
return
True
for
i
in
xrange
(
2
,
10
):
for
digits
in
permutations
(
map
(
str
,
range
(
i
,
0
,
-
1
))):
n
=
int
(
''
.
join
(
digits
))
if
__name__
==
'
__main__
'
:
from
itertools
import
permutations
if
n
>
m
and
is_prime
(
n
)
:
m
=
n
m
=
0
for
i
in
xrange
(
2
,
10
):
for
digits
in
permutations
(
map
(
str
,
range
(
i
,
0
,
-
1
))):
n
=
int
(
''
.
join
(
digits
))
if
n
>
m
and
is_prime
(
n
):
m
=
n
print
m
print
m
This diff is collapsed.
Click to expand it.
prime
s.py
→
util
s.py
+
9
−
0
View file @
21186ede
def
_gcd
(
a
,
b
):
while
b
:
a
,
b
=
b
,
a
%
b
return
a
def
gcd
(
*
args
):
return
reduce
(
_gcd
,
args
)
def
is_prime
(
n
):
if
n
==
2
:
return
True
...
...
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