Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 104 #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

murilocamargos
Copy link
Collaborator

How the solution works

This is a brute force solution with two optimizations:

  1. Getting first and last 9 digits without transforming it to string so we don't need to convert the entire number (it's big);
  2. Checking if the number is divisible by three, all 1-9 pandigital numbers are divisible by three.

Performance

Python 3

Real time: 24.138 s
User time: 23.978 s
Sys. time: 0.015 s
CPU share: 99.40 %
Exit code: 0

@FrankKair FrankKair changed the title Adds problem 104 brute force solution Python 104 May 16, 2018
@@ -0,0 +1,14 @@
import math

pand2 = lambda x: '0' not in x and len(set(x)) == 9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔝

import math

pand2 = lambda x: '0' not in x and len(set(x)) == 9
pand1 = lambda x: x % 3 == 0 and pand2(str(x))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot simply pass as a set to pand2? Like pand2(set(x)) and there we do the same thing, but without a string comparison.

What do you think? (:

@FrankKair FrankKair force-pushed the master branch 2 times, most recently from fb21135 to 5f2c6c5 Compare May 30, 2018 14:17
Copy link
Owner

@FrankKair FrankKair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, @murilocamargos.
Thank you for this contribution. This is a hard one!

Can you just check the CONTRIBUTING file to meet the standards for Python?

We're trying to keep a pattern for better comparison between languages :)

@FrankKair FrankKair force-pushed the master branch 9 times, most recently from a9fcab8 to aae4df4 Compare June 14, 2018 01:56
@FrankKair FrankKair force-pushed the master branch 8 times, most recently from 87d4889 to 01bc663 Compare June 19, 2018 03:12
@FrankKair FrankKair force-pushed the master branch 9 times, most recently from 4d4bab9 to d533539 Compare July 2, 2018 21:21
@FrankKair FrankKair force-pushed the master branch 6 times, most recently from 7521a47 to c86e864 Compare December 6, 2018 19:05
@FrankKair FrankKair force-pushed the master branch 3 times, most recently from 2791cd8 to 6684343 Compare February 13, 2019 00:23
@FrankKair FrankKair force-pushed the master branch 3 times, most recently from 1710f7e to d2163af Compare March 1, 2019 12:18
@FrankKair FrankKair force-pushed the master branch 5 times, most recently from e627ccd to 7342761 Compare March 8, 2020 00:06
@caiopo caiopo removed their request for review February 7, 2022 15:11
@caiangums caiangums removed their request for review July 7, 2022 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants