Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [python-3.x]

Python 3 is the latest version of the Python programming language and was formally released on December 3rd, 2008. Use this tag along with the main python tag to denote programs that are meant to be run on a Python 3 interpreter only. Do not mix this tag with the python-2.x tag.

Filter by
Sorted by
Tagged with
3
votes
1answer
63 views

Project Euler - Problem No.4 - Largest palindrome product

according to the problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
3
votes
2answers
77 views

Tic-Tac-Toe code using Python with Tkinter

`I made this Tic-Tac-Toe game first, by using user input in the console here: https://pastebin.com/6zLjrWcf , and now new and improved using Tkinter: ...
3
votes
2answers
54 views

Trial Division Prime Generator

...
4
votes
1answer
76 views

Find the number of pawns available for a rook to capture

I find that very very often with matrix questions, the traversal and comparison part of the solution is very verbose and repetitive. For example, this code (written for a coding challenge) to find ...
11
votes
1answer
2k views

Raindrops in Python

There's this simple coding challenge that feels like a twist on FizzBuzz. Your task is to convert a number to a string, the contents of which depends on the number's factors. If the number has 3 ...
4
votes
2answers
61 views

Project Euler - Problem 3

The description of the problem is: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Here is my solution: ...
1
vote
1answer
42 views

Short function to remove unnecessary whitespace

I have a function consisting of one line of code: def trimString(string): """ Remove unnecessary whitespace. """ return re.sub('\s+', ' ', string).strip() ...
3
votes
2answers
96 views

Project Euler # 67 Maximum path sum II (Bottom up) in Python

This is Project Euler #67: Maximum path sum II: By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 ...
1
vote
1answer
30 views

Return timeframes relevant to just-elapsed time period (financial/trading context)

I am writing trading software, and have written this utility function. Its purpose is to return a list of timeframes relevant to the just-elapsed time period. "Timeframe" here means bar or candle ...
3
votes
0answers
30 views

Form deserializer for Python Flask

I've started working on a small Flask project for no real reason other than fun, and pulled myself back on form validation. I realize that there are existing libraries like WTForms, but wanted to try ...
2
votes
1answer
123 views

Python Tkinter login GUI with database

I created a simple login program that works how I wanted them to work. I separated the GUI and database codes into two different python files. I named the files as login.py and dbaseManip.py. The ...
4
votes
1answer
94 views

Footwear scraper

I've done this parser to scrape all footwear data, but I don't know if it is good to use OOP in this case. Can you please check this out and give me the strongest feedback? I'm working on improving my ...
2
votes
1answer
54 views

Project Euler # 55 Lychrel numbers in Python

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, ...
3
votes
2answers
98 views

Project Euler # 54 Poker hands in Python

In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way: High Card: Highest value card. One Pair: Two cards of the same value. Two Pairs: ...
12
votes
1answer
120 views

Not so Excellent Knight's Tour

Note: This is part of a set of demo applications I'm writing for colleagues to show we're not limited to VBA when dealing with Excel. Considering our IT challenges (no admin on-site & no local-...
4
votes
0answers
53 views

Linny: Continued Language Development

A previous question regarding Linny exists here. After a wonderful response on my previous question regarding my developing programming language, I worked on it for a couple days, and am returning ...
2
votes
1answer
67 views

Updateable Priority Queue

I've implemented an updateable priority queue as a part of implementing some single-source-shortest-path algorithms (Dijkstra, BF). I'm relatively new to Python. ...
2
votes
2answers
37 views

Consolidating a dictionary from nested dictionary

Currently learning from "LPTHW - Zed Shaw" and "Automating the boring stuff". There is a nested dictionary of the type ...
3
votes
2answers
71 views

Project Euler # 56 Powerful digit sum in Python

A googol (\$10^{100}\$) is a massive number: one followed by one-hundred zeros; \$100^{100}\$ is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits ...
7
votes
1answer
118 views

Linny: An Interpreted Programming Language

There is a follow up question here. I've undertaken the project of creating my own programming language, Linny. It's a very, very simple language, with only variable creation, variable changing, and ...
7
votes
3answers
1k views

Determine if a triangle is equilateral, isosceles, or scalene

I've been fiddling around with some easy code challenges and there's one about determining if a triangle is equilateral, isosceles, or scalene. I've come up with a working solution, but I feel this ...
3
votes
1answer
66 views

Project Euler # 53 Combinatoric selections in Python

There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3=10. In general, nCr = n! / r! (n−r)!, ...
2
votes
2answers
68 views

Project Euler # 52 Permuted multiples in Python

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, ...
2
votes
2answers
81 views

Determine whether three sides form a valid triangle, and classify the triangle

This is a my first Python program, and whilst I am new to Python I would like to keep in good practice Below is a short program to work out what type a triangle is and if it makes a valid triangle ...
0
votes
0answers
34 views

Python script to import MySQL tables to PostgreSQL

I'm using the below Python script to port few table data from a remote server (MySQL database) to my data warehouse server (PostgreSQL DB), The script is working fine (I'm using foreign data wrapper), ...
1
vote
1answer
35 views

Optimising the BFS

The input graph to the bfs function is in the form of edge list representation. ...
2
votes
1answer
48 views

Traversing two trees until a common value has been found

I am traversing two objects that may share a common ancestor. To make the code small enough to show here, I have changed it into two dictionaries with values. As you can see, ...
1
vote
0answers
32 views

Invoking parallel threads of a nslookup command in python

I've written below python script just to invoke parallel threads of a command nslookup linux-host01 dns-server, i'm Just trying to flood the DNS Server ...
-2
votes
1answer
120 views

Project Euler # 50 Consecutive prime sum in Python

The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum ...
2
votes
2answers
75 views

Caesar Cipher Guesser

I've written a Caesar Cipher in python (a more in-depth explanation is provided in the docstring at the top of the program). At first, it was supposed to just be the cipher, but I expanded it to have ...
0
votes
0answers
19 views

Grouping by on Pandas df with focus on performance

I am doing a group by on a subset of a dataframe. I am working with 9m+ rows atm, subject to sharp increase. I tried different approaches already and wanted to know if i could squeeze a bit more ...
2
votes
1answer
241 views

Project Euler # 49 Prime permutations in Python

The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are ...
0
votes
1answer
72 views

Project Euler # 48 Self powers in Python

The series, \$1^1 + 2^2 + 3^3 + \ldots + 10^{10} = 10405071317\$. Find the last ten digits of the series, \$1^1 + 2^2 + 3^3 + \ldots + 1000^{1000}\$. ...
3
votes
1answer
48 views

File compressor

I have written a file compressor in python. The program generates a file filled with sequences of the same character with a random length, and compresses that file. I would like feedback on code ...
5
votes
2answers
68 views

Grouping sorted coordinates based on proximity to each other

I created an algotrithm that groups a sorted list of coordinates into buckets based on their proximity (30) to one another. Steps: Create a new key with a list ...
1
vote
3answers
89 views

Project Euler # Triangular, pentagonal and hexagonal in Python

Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle: \$T_n=\frac{n(n+1)}{2}\$ 1, 3, 6, 10, 15, … Pentagonal: \$...
1
vote
1answer
75 views

Project Euler # 44 Pentagon numbers in Python

Pentagonal numbers are generated by the formula, \$P_n=\frac{n(3n−1)}{2}\$. The first ten pentagonal numbers are: 1, 5, 12, 22, 35, 51, 70, 92, 117, 145 ...
-1
votes
2answers
67 views

Project Euler # 43 Sub-string divisibility in Python

The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let \...
1
vote
0answers
49 views

Project Euler # 42 Coded triangle number in Python

The nth term of the sequence of triangle numbers is given by, \$t_n = \frac{n(n+1)}{2}\$; so the first ten triangle numbers are: ...
1
vote
0answers
47 views

Project Euler # 38 Pandigital multiples in Python

Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will ...
0
votes
1answer
50 views

Project Euler # 37 Truncatable primes in Python

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can ...
5
votes
1answer
45 views

A view for Python list slices

As you probably know, Python slices like arr[1:3] etc. do NOT provide a view onto list and instead creates a copy of the list, what can be not optimal performance ...
1
vote
1answer
68 views

Project Euler # 36 Double-base palindromes in Python

The decimal number, 585 = 1001001001 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note ...
3
votes
1answer
113 views

Project Euler # 35 Circular primes in Python

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime. There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, ...
1
vote
1answer
70 views

Project Euler 34 # Digit Factorials in Python

145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are equal to the sum of the factorial of their digits. Note: as 1! = 1 and 2! = 2 are not ...
1
vote
1answer
65 views

Project Euler # 30 Digits fifth power in Python

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: \$1634 = 1^4 + 6^4 + 3^4 + 4^4\$ \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$ \$9474 = 9^4 + ...
1
vote
1answer
38 views

Project Euler # 29: Distinct powers in Python

Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 2 ** 2 = 4, 2 ** 3 = 8, 2 ** 4 = 16, 2 ** 5 = 32 3 ** 2 = 9, 3 ** 3 = 27, 3 ** 4 = 81, 3 * 5 = 243 4 ** 2 = 16, 4 ** 3 = ...
1
vote
0answers
23 views

Project Euler # 28: Number spiral diagonals in Python

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: ...
3
votes
2answers
61 views

Checking the strength of a password using regexes

I'm a beginner in Python and I made a password checker. I'm following these rules: I have to use regex password must be at least 8 characters must have at least one lower case character must have at ...
15
votes
5answers
3k views

Project Euler # 25 The 1000 digit Fibonacci index

The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 ...