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
1598cdc8
Commit
1598cdc8
authored
Dec 07, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked on 79
parent
30ad39bf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
48 deletions
+10
-48
problem79.py
problem79.py
+10
-48
No files found.
problem79.py
View file @
1598cdc8
...
@@ -3,6 +3,7 @@ codes = [319, 680, 180, 690, 129, 620, 762, 689, 762, 318, 368, 710, 720, 710,
...
@@ -3,6 +3,7 @@ codes = [319, 680, 180, 690, 129, 620, 762, 689, 762, 318, 368, 710, 720, 710,
629
,
168
,
160
,
689
,
716
,
731
,
736
,
729
,
316
,
729
,
729
,
710
,
769
,
290
,
629
,
168
,
160
,
689
,
716
,
731
,
736
,
729
,
316
,
729
,
729
,
710
,
769
,
290
,
719
,
680
,
318
,
389
,
162
,
289
,
162
,
718
,
729
,
319
,
790
,
680
,
890
,
362
,
719
,
680
,
318
,
389
,
162
,
289
,
162
,
718
,
729
,
319
,
790
,
680
,
890
,
362
,
319
,
760
,
316
,
729
,
380
,
319
,
728
,
716
]
319
,
760
,
316
,
729
,
380
,
319
,
728
,
716
]
codes
=
map
(
str
,
codes
)
def
indices
(
partial
):
def
indices
(
partial
):
ind
=
[]
ind
=
[]
...
@@ -19,53 +20,14 @@ def indices(partial):
...
@@ -19,53 +20,14 @@ def indices(partial):
return
ind
return
ind
def
match
(
code
):
passcode
=
[]
partials
=
(
code
,
code
[
1
:],
code
[:
2
],
code
[::
2
],
code
[
0
],
code
[
1
],
code
[
2
])
for
i
,
partial
in
enumerate
(
partials
):
def
genpass
(
):
ind
=
indices
(
partial
)
return
''
.
join
(
c
for
i
,
c
in
passcode
)
if
ind
:
for
c
,
code
in
enumerate
(
codes
):
return
partial
,
i
,
ind
for
d
in
code
:
if
d
in
:
return
None
,
None
,
None
pass
else
:
#codes.sort()
a
codes
=
map
(
str
,
set
(
codes
))
passcode
=
codes
.
pop
(
0
)
print
passcode
while
len
(
codes
):
possibilities
=
[(
0
,
-
1
,
[])]
for
index
,
code
in
enumerate
(
codes
):
partial
,
i
,
ind
=
match
(
code
)
if
ind
:
#print code, partial, ind
possibilities
.
append
((
index
,
i
,
ind
,
partial
))
possibilities
.
sort
(
lambda
a
,
b
:
cmp
(
len
(
a
[
2
]),
len
(
b
[
2
])))
#print possibilities
index
,
i
,
ind
,
partial
=
possibilities
[
-
1
]
code
=
codes
.
pop
(
index
)
if
i
==
1
:
passcode
=
code
[
0
]
+
passcode
elif
i
==
2
:
passcode
+=
code
[
2
]
elif
i
==
3
:
passcode
=
passcode
[:
ind
[
0
]]
+
code
[
1
]
+
passcode
[
ind
[
0
]:]
elif
i
==
4
:
passcode
+=
code
[
1
:]
elif
i
==
5
:
passcode
=
code
[
0
]
+
passcode
+
code
[
2
]
elif
i
==
6
:
passcode
=
code
[:
2
]
+
passcode
elif
i
==
-
1
:
passcode
+=
code
print
code
,
partial
,
passcode
#print len(passcode), len(codes) * 3, passcode
#print passcode
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