All Questions
31 questions
2
votes
0
answers
134
views
How to make this arbitrary precision π calculator using Machin-like formula run faster?
Two days ago (or yesterday depending on your timezone) was π-day. So I thought it was a good day to calculate π.
I used Machin-like formula to calculate π, in homage of William Shanks, who calculated ...
9
votes
3
answers
2k
views
Euler's brick generator in C++
I stumbled upon this unsolved problem of math named Euler's brick. I wrote a program in C++ to generate solutions for Euler's brick problem.
It searches from ...
4
votes
4
answers
1k
views
Count numbers that are the sum of three perfect cubes
From numbers from 1 to 100, count the numbers where the following equation is satisfied with 1 <= a <= 100, 1 <= b <= 100, and 1 <= c <= 100: $$a³ + b³ + c³$$
I have this:
...
3
votes
1
answer
566
views
(Google Foobar XOR Checksum Challenge) How do i optimize this function to run for much larger values?
I wrote a function that accepts 2 integers start and length as input and returns the bitwise XOR of certain numbers as described below:
...
2
votes
0
answers
220
views
Maximizing Efficiency of Collatz Conjecture Program Python
My question is very simple.
I wrote this program for pure entertainment. It takes a numerical input and finds the length of every Collatz Sequence up to and including that number.
I want to make it ...
5
votes
1
answer
217
views
Algorithm Optimization -- Automatic Dimensionality of PCA
I have implemented (rather, edited the implementation of) a technique to automatically detect the optimal number of dimensions for PCA, based off of this paper.
This was inspired by ...
5
votes
1
answer
478
views
Bancroft's method implementation
Background
I've written an algorithm to solve the three-dimensional Time Difference of Arrival (TDoA) multi-lateration problem. That is, given the coordinates of n ...
1
vote
1
answer
184
views
"Backwards Read Primes" of Codewars powershell version
Link to problem: https://www.codewars.com/kata/5539fecef69c483c5a000015/train/powershell
I have a working solution in Codewars but my solution is slow for some reason and I need to improve the ...
6
votes
1
answer
2k
views
Scan-line algorithm to fill in a triangle
I wrote the following script to fill a Triangle.
...
5
votes
2
answers
1k
views
Magic Square with Five Methods (Python)
Problem
Write a program to return a boolean if an input grid is magic square.
A magic square of order \$N\$ is an arrangement of \$N^2\$ distinct integers in a square such that the \$N\$ numbers in ...
3
votes
1
answer
71
views
Stern's diatomic series fusc: replacing #define functions with two return values
I have a function to review which implements Stern's diatomic series fusc for a single word (ulong = unsigned long) in place, as ...
0
votes
1
answer
340
views
Modular multiplicative inverse in Ruby
I implemented an algorithm to find the modular multiplicative inverse of an integer. The code works, but it is too slow and I don't know why. I compared it with an algorithm I found in Rosetta Code, ...
1
vote
1
answer
97
views
Sum of number's quotients when divided by exact powers of 2
Problem
I have written code to solve this challenge:
Given a formula:
GCD(x,y) means the GCD (Greatest Common Divisor) of x and y.
For example: if N=2, then:
f(2) = 1/GCD(1, 4) + 2/GCD(2, 4) + 3/...
3
votes
2
answers
586
views
Finding the number of integers between 1 and K, who's sum of the digits is a multiple of D
Good day. So, I need to find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo (10^9)+7:
The sum of the digits in base ten is a multiple of D
Here is my ...
4
votes
1
answer
80
views
Hungarian algorithm to perform least-cost assignments
The Hungarian algorithm solves the assignment problem, and I'm looking for
any suggestions regarding improvement on my implementation (also coding style). It is based on the wikipedia entry and ...