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
4
votes
1answer
54 views

PRBHA-10: A hashing algorithm in Python

So I've been working on a simple little hashing algorithm for Python that I like to call PRBHA-10 for short, or Pseudo-Random-Based Hash Algorithm. This is a hash algorithm in Python that is meant to ...
6
votes
3answers
249 views

Function to extract float from different price patterns

I've got a project where I get product data and need to get the prices which come in, in different formats. Some examples would be: US$17, USD17.00, 17,00€, 17€, GBP17, Only 17,-€, 17.000,00€, 17,000....
1
vote
1answer
66 views

(Leetcode) K-similar strings in Python

This is a Leetcode problem - Strings A and B are K-similar (for some non-negative integer ...
2
votes
1answer
96 views

Hangman game with Python 3

I tried to create a "guess the word" game. I would appreciate to get some suggestion to improve myself, because I'm new at Python. ...
6
votes
1answer
81 views

Python script to clean out old files from a repository

I wrote the script below as my first python program that will be running in a production environment. Essentially this program looks at a source location and moves all the files to a destination ...
2
votes
1answer
29 views

Indeterminate-length big-endian to little-endian conversion in Python

I have a need to convert wire encoding (big-endian) to little-endian in Python. The conversion needs to happen as a separate function; I am not allowed to change the function that reads the byte ...
1
vote
0answers
62 views

Python 3 Tkinter Calculator - follow-up

I'm a beginner developer, and it's my very first project: a simple math operations calculator in Python 3 using Tkinter for GUI. Obs: This code is an evolution of my previous code of the same project:...
2
votes
1answer
90 views

(Leetcode) Sliding puzzle in Python

This is a Leetcode problem: On a 2 x 3 board, there are 5 tiles represented by the integers 1 through ...
7
votes
1answer
82 views

Google “Wiggle walk”

I am doing Kickstart's problem Wiggle Walk. I have tried to code with matrix, dictionary and nested dictionary but the time exceeds the limit in each submition. Can anyone help me optimize it better ...
4
votes
1answer
52 views

(Leetcode) 24 game in Python

This is a Leetcode problem - You have 4 cards each containing a number from 1 to 9. You need to judge whether they could be ...
1
vote
0answers
33 views

Tkinter application with multiple windows

I'm creating an application that requires multiple tkinter windows. The code below works the way how I want it to work, but I'm not sure if I'm doing it in the proper way. The first window (and in ...
18
votes
6answers
3k views

Comma Code - Ch. 4 Automate the Boring Stuff

I am new to programming and currently learning Python using "Automate the Boring" by Al Sweigart. I've just completed the "Comma Code" task in Chapter 4 and would like some feedback on my solution. ...
0
votes
2answers
80 views

Strong password checker in Python

This is a Leetcode problem - A password is considered strong if below conditions are all met - 1. It has at least 6 characters and at most 20 characters. 2. It must contain at least one ...
10
votes
2answers
187 views

Verhoeff check digit algorithm

A recent question on credit card validation here on Code Review, led me down a dark rabbit hole of check digit algorithms. I took a stop at the Verhoeff algorithm and tried to implement it myself. ...
3
votes
1answer
60 views

Find all concatenated words in a given list of words

This is a Leetcode problem - Given a list of words (without duplicates), write a program that returns all concatenated words in the given list of words. A concatenated word is defined as a ...
0
votes
2answers
64 views

Split an array into m subarrays such that the largest subarray sum is minimized

This is a Leetcode problem - Given an array which consists of non-negative integers and an integer m, you can split the array into ...
4
votes
1answer
63 views

Implementing Hangman using a State Pattern

I decided to implement a Hangman game using an object oriented State Pattern design. This is one of my first actual OOP as I normally write functional code. Code use: ...
7
votes
2answers
233 views

Python program to solve the “skyline problem”

This is a Leetcode problem - A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the ...
33
votes
5answers
5k views

Beginner's snake game using PyGame

I am a complete beginner when it comes to programming and writing games and this is my first ever game. I made it with python 3 using pygame library. I would ...
3
votes
1answer
43 views

Python simple type checking decorator

I'd like to know your opinions on this minimal type-checking decorator (with @ annotations) to make type checking of a method while debugging like : ...
6
votes
1answer
72 views

Python 3 simple external sort with heapq

I've implemented a minimal external sort of text file using heapq python module. On the few tests I did it seems to works well, but I would like to have some advice to have a cleaner and faster code. ...
3
votes
2answers
48 views

Target number sum finder

This is a Target number solution finder which I made with tkinter and is where the user enters a number they want and enters 4 other numbers to find the sum to make the number they want. This is a ...
-1
votes
4answers
88 views

Python program to print all permutations of a string in lexicographic order using recursion

An assignment at school required me to print all permutations of a string in lexicographic or dictionary order. Here is my solution to the task - ...
17
votes
2answers
2k views

Yandex programming contest: Alarms

I've tried to solve this challenge about 4 hours during the contest, but all my attempts exceeded the time limit. I tried to solve it with min-heap, but can't pass all the tests. How it can be solved ...
1
vote
1answer
56 views

Python program to remove invalid parentheses

This is a Leetcode problem - Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note - The input string may contain ...
0
votes
1answer
43 views

Python program for Word Search II

This is a Leetcode problem - Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of a sequentially adjacent ...
0
votes
1answer
46 views

Python program to solve the “rod-cutting problem”

An assignment at school required me to write a program for this task: In the rod-cutting problem, we are given a rod of length n inches and a table of prices <...
3
votes
0answers
83 views

Python program to solve matrix-chain multiplication

An assignment at school required me to write a Python program for this task: In the matrix-chain multiplication problem, we are given a sequence of matrices ...
8
votes
1answer
145 views

A Python Blackjack terminal based game

I am looking for some feedback on my blackjack Python code. Any feedback is much appreciated. Docstring, code etc. Other than that, I need to test it, and I am not sure how to make this code more ...
2
votes
0answers
85 views

Daily coding problem 18: Maximums of k-sized windows

The challenge Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of each subarray of length k. For example, given array = [10, 5, 2, 7, ...
2
votes
1answer
52 views

Daily Coding Challenge solution - day 21

The Challenge Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required. For example, given [(30, 75), (0, 50), (60, 150)],...
5
votes
1answer
51 views

Add-in for input() with validation

What do you think about this code? Do you have some advices and remarks for me about them? I have started learning python recently. ...
1
vote
0answers
23 views

Python3 - Cropping PDF files according to coordinates

I have a python script, that is performing OCR on PDF pages. I am trying to do so I can provide coordinates to the script - so it will only select the text within the provided coordinates ...
4
votes
0answers
33 views

Python: Exception handling in a logic gate

I'm learning about Python and am going through the OO-stage where I'm building a set of logic-gate classes. To make the logic more resilient, I only want the user to be able to enter a value of 0 or ...
2
votes
2answers
91 views

Python program to implement pow(x, n)

This is a Leetcode problem: Implement pow(x, n), which calculates x raised to the power n ...
11
votes
2answers
286 views

Python Chess Game

I'm developing chess in python, and I've decided to make everything text-based before creating a GUI because it'd be my first time doing the latter. I haven't got around to the actual gameplay, but I'...
3
votes
1answer
50 views

Python3 - Determing if a PDF is scanned or “searchable”

I am in a situation where I need to determine if a PDF file is either: Scanned Searchable (contain text) To do this, I am simply running the command pdffonts on ...
-3
votes
1answer
32 views

Remove duplicated code from a Python function that gets data from and endpoint and, after manipulating it, returns the manipulated version [closed]

I have written the following function for a CLI tool, it works as expected but it also contains duplicated code. ...
0
votes
1answer
43 views

Simplify small pieces of code with Python/Django [closed]

I'm trying to make a code review for an external developer on my project. His code could be improved and I need your advices in order to know if my overwritten parts are better or not. Part 1 ...
2
votes
2answers
70 views

Python program for Jump game II

This is a Leetcode problem: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length ...
-3
votes
3answers
126 views

Python program to find the first missing positive integer in a list

This is a Leetcode problem: Given an unsorted integer array, find the smallest missing positive integer. Note: Your algorithm should run in O(n) time and uses constant extra space. ...
18
votes
5answers
2k views

Count Even Digits In Number

I was asked to complete this CodeStepByStep problem. Here's a quick summary: Write a function named count_even_digits that accepts two integers as parameters ...
0
votes
1answer
75 views

Python program to find the substring with concatenation of all words

This is a Leetcode problem: You are given a string, S, and a list of words, L that are all of the same lengths. Find all starting indices of substring(s) in S that is a concatenation of each word ...
1
vote
1answer
59 views

TickeTron for booking seating

I have written a program that simulates a TickeTron and allows the user to book seating in a virtual audience. The virtual audience is read in from a text file which will be included below. The ...
3
votes
2answers
78 views

3D metrics for segmentation evaluation

I am new to programming and I am trying to develop a machine learning approach for image segmentation (https://en.wikipedia.org/wiki/Image_segmentation) and here I want to evaluate the predicted (...
8
votes
5answers
974 views

Python program to find Armstrong numbers in a certain range

I have written a Python program to check for Armstrong numbers in a certain range. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the ...
4
votes
3answers
342 views

Python program for a simple calculator

I have written a program for a simple calculator that can add, subtract, multiply and divide using functions. Here is my code: ...
15
votes
8answers
4k views

Python program to take in two strings and print the larger string

I have written a Python program to take in two strings and print the larger of the two strings. Here is my code - ...
1
vote
1answer
65 views

Python program to find the factorial of a number using recursion

A factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 5 (denoted as <...
2
votes
0answers
38 views

Countdown number game solution v2 using itertools

I recently posted a solution for the numbers game on the Countdown TV show using a recursive technique. For those unfarmiliar with the rules… A fixed set of numbers (usually 6) are chosen at random ...