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
76268ce5
Commit
76268ce5
authored
Dec 06, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solved 45
parent
fadf1e2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
problem45.py
problem45.py
+22
-0
No files found.
problem45.py
0 → 100755
View file @
76268ce5
#!/usr/bin/env python
def
tri
(
n
):
return
n
*
(
n
+
1
)
/
2
def
pent
(
n
):
return
n
*
(
3
*
n
-
1
)
/
2
def
hexa
(
n
):
return
n
*
(
2
*
n
-
1
)
funcs
=
(
tri
,
pent
,
hexa
)
n
=
[
20
]
*
3
vals
=
[
f
(
20
)
for
f
in
funcs
]
while
len
(
set
(
vals
))
>
1
or
vals
[
0
]
==
40755
:
mini
=
0
minv
=
None
for
i
,
v
in
enumerate
(
vals
):
if
minv
is
None
or
v
<
minv
:
mini
=
i
minv
=
v
n
[
mini
]
+=
1
vals
[
mini
]
=
funcs
[
mini
](
n
[
mini
])
print
vals
[
0
]
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