Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecteuler
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
projecteuler
Commits
9547fad4
Commit
9547fad4
authored
Nov 29, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solved 33
parent
b8de0807
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
frac.py
frac.py
+5
-0
problem33.py
problem33.py
+23
-0
No files found.
frac.py
0 → 100644
View file @
9547fad4
def
gcd
(
a
,
b
):
while
b
:
a
,
b
=
b
,
a
%
b
return
a
problem33.py
0 → 100755
View file @
9547fad4
#!/usr/bin/env python
from
__future__
import
division
from
itertools
import
combinations
,
permutations
from
frac
import
gcd
nrs
=
[(
i
,
str
(
i
))
for
i
in
xrange
(
10
,
100
)]
pairs
=
((
0
,
0
),
(
0
,
1
),
(
1
,
0
),
(
1
,
1
))
pn
=
pd
=
1
for
(
n
,
ns
),
(
d
,
ds
)
in
combinations
(
nrs
,
2
):
if
n
<
d
:
for
i
,
j
in
pairs
:
if
ds
[
1
-
j
]
!=
'0'
and
ns
[
i
]
==
ds
[
j
]
\
and
int
(
ns
[
1
-
i
])
/
int
(
ds
[
1
-
j
])
==
n
/
d
\
and
ns
[
1
]
!=
'0'
:
pn
*=
n
pd
*=
d
print
'%d / %d == %s / %s'
%
(
n
,
d
,
ns
[
1
-
i
],
ds
[
1
-
j
])
g
=
gcd
(
pn
,
pd
)
print
'product: %d / %d'
%
(
pn
/
g
,
pd
/
g
)
print
'answer: %d'
%
(
pd
/
g
)
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