All Questions
Tagged with programming-challengepython-3.x
448 questions
32votes
8answers
5kviews
Project Euler Problem 45
As a self-teaching Python beginner for almost 4 months, I have mostly been doing online challenges including Project Euler problems. Problem 45 asks: Triangle, pentagonal, and hexagonal numbers are ...
26votes
2answers
6kviews
Printing 1,000,000 numbers in 1 sec. in Python
Here's a fairly simple task from CSES Problem Set - Permutations 1070 that reads: A permutation of integers 1,2, …, n is called beautiful if there are no adjacent elements whose difference is 1. ...
18votes
5answers
3kviews
Flipping coins performance
This is the Flipping coins problem on CodeChef: There are \$N\$ coins kept on the table, numbered from \$0\$ to \$N - 1\$. Initially, each coin is kept tails up. You have to perform two types of ...
17votes
2answers
2kviews
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 ...
16votes
5answers
6kviews
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 ...
16votes
2answers
3kviews
Translate English to Pig Latin
This is a program for converting English to the pseudo-language Pig Latin. Not the strictest form of Pig Latin but it most likely will accurately output an argument in Pig Latin. I got the idea from a ...
15votes
6answers
5kviews
Project Euler, problem # 9, Pythagorean triplet
Project Euler #9, Pythagorean triplet is A Pythagorean triplet is a set of three natural numbers \$a < b < c\$ for which \$a^2 + b^2 = c^2\$. For example, \$3^2 + 4^2 = 9 + 16 = 25 = 5^...
15votes
2answers
1kviews
Project Euler #22 - Names Scores
I programmed Problem #22 from Project Euler in Python. It works but I want to know if it really is pythonic enough. Using names.txt (right click and 'Save Link/Target As...'), a 46K text file ...
14votes
4answers
4kviews
100-doors puzzle
Here is a very simple solution to the 100 doors challenge You are in a hotel with 100 doors. Initially every door is closed. On the first round, you change the state of every door (if it is open, ...
14votes
1answer
328views
Recover flights from found tickets
I just found a whole bunch of plane tickets that only have a start and destination on them. I also know the route started in a certain city. I would like to recover the (alphabetically) first possible ...
13votes
2answers
5kviews
Average spam confidence
Exercise 7.2 from Python for Informatics: Write a program to prompt for a file name, and then read through the file and look for lines of the form: ...
13votes
5answers
9kviews
"Algorithmic Crush" problem hitting timeout errors
This is the HackerRank problem Algorithmic Crush: You are given a list of size N, initialized with zeroes. You have to perform ...
13votes
2answers
2kviews
Beginner Coin Flip project
I think I finally finished a small coin flip project I found online. However, I'm pretty confident this is far from the optimal solution and would really appreciate any feedback on how this could be ...
12votes
9answers
69kviews
Find the repeated elements in a list
You are given an array of n+2 elements. All elements of the array are in range 1 to n. All elements occur once except two numbers, which occur twice. Your task is to find the two repeating numbers. My ...
12votes
2answers
2kviews
"Longest Collatz sequence" in C slower than in Python 3
This tight-looped memoization-less C solution to Project Euler's problem 14 seems efficient, but ran much slower than a similarly trivial Python 3 program. For the desired ...