Skip to main content

All Questions

3 votes
1 answer
350 views

Python function to find the count of digits of numerals in base n up to a given limit

This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
Ξένη Γήινος's user avatar
1 vote
0 answers
174 views

Applied Solution Based On Polya Enumeration Theorem

Problem A function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a grid w blocks wide, h blocks tall and s possible ...
Anit Shrestha's user avatar
1 vote
1 answer
570 views

Coin Flip Streaks script

I am attempting to complete the coin flip streaks problem from automate the boring stuff with python. My code works fine but my only concern is the phrasing of the task. Does the question want us to ...
JerryTn's user avatar
  • 19
2 votes
2 answers
172 views

Project Euler, Problem 273: finding perfect-square partitions

Problem: Consider equations of the form: \$a^2 + b^2 = N; 0 \leq a \leq b; a, b, N \in \mathbb{N}\$. For \$N=65\$ there are two solutions: \$a=1, b=8\$ and \$a=4, b=7\$. We call \$S(...
Alex Hal's user avatar
8 votes
3 answers
1k views

Balanced centrifuge configurations

Given an input N as the size of a centrifuge, I need to find out the number of balanced configurations. The full description is here. Centrifuge is a piece of ...
Kristada673's user avatar
6 votes
1 answer
1k views

Navigating over a square spiral

I recently found adventofcode, but when I solved Day 3 in Python, I noticed that my code isn't looking very nice. The challenge is about navigating a hypothetical memory laid out in a square spiral: ...
Maya's user avatar
  • 163
3 votes
2 answers
588 views

Time limit exceeded on finding out the GCD and LCM of a Python list

I'm doing this HackerRank problem: Consider two sets of positive integers, \$A=\{a_0, a_1, \ldots, a_{n-1}\}\$ and \$B=\{b_0, b_1, \ldots, b_{m-1}\}\$. We say that a positive integer, \$x\$, is ...
Sidharth Samant's user avatar
3 votes
3 answers
1k views

Last five non-zero digits of a factorial in base b

This HackerRank problem (based on Project Euler problem 160) says: For any \$n\$, let \$f_b(n)\$ be the last five digits before the trailing zeroes in \$n!\$ written in base \$b\$. For example,...
Generic Snake's user avatar
3 votes
2 answers
620 views

Zeckendorf Representation of positive integer

Zeckendorf's theorem states that all positive integers can be represented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive ...
MooingRawr's user avatar
2 votes
1 answer
577 views

Generating numbers that are a product of consecutive primes

I have implemented a correct but horribly coded solution to Project Euler Problem 293. An even positive integer N will be called admissible, if it is a power of 2 or its distinct prime factors ...
Jacob's user avatar
  • 31
4 votes
3 answers
303 views

Time Limit Exceeded for ETF - Euler Totient Function at Spoj

In number theory, the totient φ of a positive integer n is defined to be the number of positive integers less than or equal to n that are coprime to n. Given an integer n (1 ≤ n ≤ 106), compute the ...
sarvajeetsuman's user avatar
26 votes
4 answers
1k views

Generalized Project Euler 1: A sledgehammer to crack a nut

The problem Project Euler 1 is one of the most asked questions on site. However I wanted to solve the more general problem of division. Multiples of a list If we list all the natural numbers ...
N3buchadnezzar's user avatar
5 votes
6 answers
9k views

Counting pairs of relatively prime numbers

Problem from Hacker Earth: Inverted GCD: Given an array a of \$N\$ numbers , you have to find the number of pair of indices \$i\$ and \$j\$ that satisfy the following relation: \$i <...
Kaushal28's user avatar
  • 455
3 votes
1 answer
2k views

Project Euler #549: Divisibility of factorials

This is the problem: Calculate $$\sum_{i=2}^{10^8} s(i)$$ where \$s(n)\$ is the smallest \$m\$ such that \$n\$ divides \$m!\$. Quite mathematical, I've found a better way than brute ...
pjpj's user avatar
  • 131
6 votes
3 answers
3k views

Rotating an NxN matrix

I came up with the following solution for rotating an NxN matrix 90 degrees clockwise, to solve this CodeEval challenge: Input The first argument is a file that contains 2D N×N matrices (where ...
Ohas's user avatar
  • 163

15 30 50 per page