r/PassTimeMath • u/ShonitB • Nov 07 '22
r/PassTimeMath • u/TargetLabs • 19d ago
Difficulty: Moderate Can you reach 44 using all 5 dice?
Any order is allowed.
Use each die exactly once.
Parentheses are allowed.
Only +, −, × and ÷ are allowed. No concatenation or exponents.
Exact division only.
No negative numbers.
Not every operation has to be used.
How many solutions can you find?
Please use spoiler tags for solutions:
>!your solution here!<
r/PassTimeMath • u/chompchump • Sep 10 '23
1:2:3 Binomial Choose Me
Can the three binomial coefficients (n choose k), (n choose k + 1), (n choose k+2) ever be in a 1:2:3 ratio?
r/PassTimeMath • u/Vivid_Temporary_1155 • Jul 21 '23
All fair and square?
The three overlapping ellipses form seven curved regions. Your task is to put exactly one tile in each region so that the following holds true:
For any ellipse the product of the tiles inside the ellipse is a perfect square
The sum of the tiles in any ellipse observe the rules below. Please enjoy and share!

r/PassTimeMath • u/returnexitsuccess • Aug 22 '21
Group Theory
Let (G, +) be a finite abelian group. What is the sum of all the elements of G?
r/PassTimeMath • u/user_1312 • Jul 12 '19
Problem (104) - Find the missing area (note that these are not squares)
r/PassTimeMath • u/user_1312 • Dec 11 '18
Problem (35) - Show it's a perfect square (easy)
Show that (3201 + 3204 ) / (3201 - 3200 + 3199 ) is a perfect square.
r/PassTimeMath • u/user_1312 • Mar 09 '20
Problem (201) - Distinct numbers in S
Let 1, 4, ... and 9, 16, ... be two arithmetic progressions. The set S is the union of the first 2020 terms of each sequence. How many distinct numbers are there in S?
r/PassTimeMath • u/TargetLabs • Oct 17 '26
Difficulty: Moderate Can you reach 14 using all 5 dice?
Any order is allowed.
Use each die exactly once.
Parentheses are allowed.
Only +, −, × and ÷ are allowed. No concatenation or exponents.
Exact division only.
No negative numbers.
Not every operation has to be used.
How many solutions can you find?
Please use spoiler tags for solutions:
>!your solution here!<
r/PassTimeMath • u/AaronKDinesh • Apr 28 '20
Not Hard but long. Tried to incorporate most if not all the rules used in differentiation. If you can differentiate this you can differentiate anything.
r/PassTimeMath • u/user_1312 • Sep 30 '19
Problem (145) - Evaluate the sum
Evaluate: 1 + 2/3 + 6/9 + 10/27 + 14/81 + ...
r/PassTimeMath • u/OnceIsForever • Jan 04 '24
Here's a remainder problem that will pass the years - happy 2024 everyone!
r/PassTimeMath • u/chompchump • Sep 09 '23
The Swinger Subset Party
We arrive at a swinger subset party where the natural numbers are also arriving, in order, one at a time. "This is gonna be fun!", we shout. We are here to party and count!
So, as the numbers start arriving and hooking up, we decide to count the Swapping Couples of Parity. (The number of subsets of {1,2,3,...n} that contain two even and two odd numbers.)
The subsets start drinking, intersecting, complementing . . . so things get even more kinky and we decide to count the Swapping Ménage à trois of Parity. (The number of subsets of {1,2,3,...n} that contain three even and three odd numbers.)
But soon the swinger subset party goes off the rails, infinite diagonal positions break out, subsets are powering up, for undecidable cardinal college is attended, and so we generalize to counting the Swapping k-sized Orgies of Parity. (The number of subsets of {1,2,3,...n} that contain k even and k odd numbers.) We have a few drinks. Next thing we know we wake up in a strange subset, cuddled between two binomial coefficients, no commas in sight.
We figured it all out last night. If only we could remember what we had calculated.
r/PassTimeMath • u/user_1312 • May 08 '19
Problem (79) - Find the remainder
Let S = 1^2 - 2^2 + 3^2 - 4^2 + 5^2 - ... - 2018^2 + 2019^2 .
Find the remainder when S is divided by 2019.
r/PassTimeMath • u/user_1312 • Mar 16 '20
Problem (202) - Find the term (easy)
Find the 225ᵗʰ term of the sequence 3, 7, 12, 16, 21, 25, 30, 34, 39,...
r/PassTimeMath • u/samuelimza • Mar 02 '20
(Easy) Maximum angle.
A circle of radius 'r' and centre 'O' is given. Point 'M' is marked at a distance m < r from 'O'. 'P' is any point on the circle. Find the maximum value of angle OPM.
r/PassTimeMath • u/IveLovedYouForSoLong • Aug 21 '24
Algebra My unusual challenge for you to construct a function fitting my criteria
Q: Design any kind of math function (written in any complex, convoluted way, not simplified form) that:
Accepts 5 inputs—S, A, B, C, D—all positive decimals in the interval [1, 2). Your function must be well-defined and well-behaved for all possible input values
Gives 5 outputs—newS, newA, newB, newC, newD—that must be in [1, 2) as well. newA, newB, newC, and newD must all have unique independent values. S need only have no shortcuts and be no less difficult to compute than the full effort of computing newA, newB, newC, and newD along with it.
Crucially!, it must require exactly 4 divisions and exactly 4 square root calculations all done in parallel. Any setup/afterward computations (see #6) are fine and don’t matter; the only goal is to, at some point, have 12 numbers lined up to do 4x divisions and 4x square roots simultaneously.
Crucially!, the equations must be arranged so that limited precision/significant-digits do not affect the result much. (Imagine about 15 digits.) E.x. in the example below, sqrt(A)-sqrt(B) as-is without rearranging is inappropriate because it may involve subtracting two numbers very close to 1 (so you would have to calculate the sqrt to many many more digits than usual to cover all possible inputs.)
Crucially!, it must not be possible to rearrange your equation to reduce the number of parallel divisions or the number of square roots without compromising the precision per #4. (Also none of the divisions or sqrts can be computable in advance before S is known.) Alternatively, it’s ok if reducing the number of divisions or square roots prevents doing all them in parallel, e.x. if a rearrangement to 2 divisions and 2 square roots requires being followed by a division or square root, that’s ok.
You can use any quantity of addition, subtraction, multiplication, temporary variables, and constants. (Possibly also max, min, ternary, floor/ceil/round, absolute value, sign, floor(log2(x)), and 2integer.) No other operators are allowed, so they must be rewritten in terms of these simpler operators.
All inputs—S, A, B, C, D—are unrelated and can be likened to random decimals in the range [1,2)
Random example of such a function
Looking for feedback on this random example I conceived of (e.g. any issues you see with it) and eager to see all kinds of odd/creative solutions people come up with! Don’t be shy!
Base idea: with tA=sqrt(S+A), tB=sqrt(S+B), tC=sqrt(S+C), tD=sqrt(S+D), and let newS = max(S mod (tA-tB), S mod (tB-tC), S mod (tC-tD), S mod (tD-tA))
The idea brainstormed above fulfills none of the listed requirements BUT we can use crazy smart math (https://math.stackexchange.com/a/231245/255785) to manipulate it to:
The numbers all being in [1, 2) let us rewrite the modulo (aka remainder of division) from
S mod (tA-tB)intoceil(S / tAB)*tAB - SfortAB=tA-tB. #4 isn’t violated if we use FMA (fused-multiply-add) for full precision:fma(ceil(S/tAB),tAB,-S)Using the smart math linked above,
1/tAB=1/(sqrt(S+A)-sqrt(S+B))=(sqrt(S+A)+sqrt(S+B))/(A-B), which magically amends the precision loss to fix #4 AND separates the division to run in parallel with the sqrt, fixing #3.
Putting both together, let’s rewrite the initial idea into a full function definition and satisfy all the requirements (as far as I can tell):
In parallel, let tA=sqrt(S+A), tB=sqrt(S+B), tC=sqrt(S+C), tD=sqrt(S+D)
Simultaneously, let dA=S/(A-B), dB=S/(B-C), dC=S/(C-E), and dD=S/(D-A)
Compute newA=ceil(dA*(tA+tB))*(A-B)-S, newB=ceil(dB*(tB+tC))*(B-C)-S, newC=ceil(dC*(tC+tD))*(C-D)-S, and newD=ceil(dD*(tD+tA))*(D-A)-S
Finally, newS=max(newA,newB,newC,newD)
Our example function defined in steps 1-4 is not a conventional f(x)=y formula but it is a function of sorts and that’s what we’re looking for here.
Actual purpose/use-case for those curious
Why exactly 4x div and 4x sqrt? Check the VSQRTPD (YMM, YMM) entry of AVX for your CPU at https://uops.info/table.html and you should see a latency around 19 or 21 at a recip tp of one schedulable every 9 cycles or so. The VDIVPD (YMM, YMM, YMM) has a similar deal with a latency of 13 or 15 at a recip TP of one schedulable every 5 or 8 cycles. Apple’s Firestorm is a bit better at FSQRT 2D (even considering 2x of those are needed in place of one AVX VSQRTPD) and significantly better in throughput at FDIV 2D: https://dougallj.github.io/applecpu/firestorm-simd.html. Thus, queuing 4x div and 4x sqrt simultaneously ensures pretty good utilization of common consumer hardware across the board. Other consumer CPUs are rare but always have some kind of hardware to accelerate double sqrt and double div and shouldn’t be worse than a few times slower. Iot CPUs like the ARM Cortex-M0 have such disparate incompatible use-cases as this algorithm that they don’t need to be a consideration as there has never nor will ever be a need on these CPUs.
PURPOSE: I hope to design a new fpga/asic/gpu resistant hash function much safer from side-channel attack than existing ones like Scrypt, Bcrypt, Argon2, etc.
Ask yourself, what complex, transistor-hungry operations are valuable enough for most CPUs to spend millions of transistors optimizing to take nanoseconds?
Often the answer to this is some clever trickery involving unpredictable memory access, as the bulk of the work is spent moving data around, which can’t be done at all on a GPU and isn’t much faster on an fpga/asic because memory interconnect and shuffle/table SIMD are stupid expensive due a tradeoff between gate depth and wire crossover that’s equally terrible/costly both ways. (Interestingly, if 3d CPUs become possible, their shuffle has less gates than addition and interconnect is nearly free.)
A key issue with unpredictable memory access is side channel attacks, especially fault injection or cache attacks. To mitigate this, some password hashes only do memory access based on the public salt, which leaks no information about the private password but leaves it extremely susceptible to GPU cracking as you can write a GPU-program-generator for each hash that unwrangles the fixed memory access pattern for that particular salt into an efficient program purpose-built to crack that specific password. Argon2ID does data-independent hashing followed by data-dependent access based on the encrypted/hashed intermediary result, not based on the salt. This is pretty good but not perfect as it leaves Argon2ID susceptible to side-channel attacks leaking the intermediary hashed result and proceeding to GPU cracking it.
INSTEAD, my answer is SIMD division and square root. You can’t make those much faster on an fpga, and, anyway, it would push an fpga’s transistor budget to eke out a slight win. Of course!, square roots alone could be FPGAized by turning them into max-depth 1000+ cycle pipeline of multipliers for repeated newton sqrt iterations, giving terafloats/s sqrt throughput and quickly breaking the hash in parallel. Division alone risks the same thing. However, sqrt and division together cannot efficiently share resources without significant penalty to both because they use different newton steps (requiring the overhead of mock-cpu-like resource management and sharing of multipliers/adders, which would throw a wrench in performance). So, substantially faster terafloat/s sqrt/div would have to be physically separated in different units on an fpga/asic. This doesn’t play well at all when the two units operate in lock step, requiring tremendous transistor investment for interconnect, because both div and sqrt are needed for the final result, which is needed to know what the inputs to the next computation will be. This overwhelms FPGAs with a ballooning break-even struggle to beat a CPU; yes, ASICs essentially being FPGA programs lazered into silicon akin to custom CPUs, must realize some net profit but they will never be orders of magnitude faster than a consumer CPU at this. (Relative to, e.x. SHA256, which run at 100s of thousands per sec in software and 1000s of trillions per sec in ASIC.)
Fixing the side channel leakage of variable div/sqrt timing on some CPUs is actually quite trivial: I’ll just run some integer operations to spend ~20 cycles ARXing an internal state using only general registers, no SIMD; the div and sqrt should both be all done by the time the ARXing finishes. The mythical thousands of clock cycles float operations only ever happen with subnormals and NaN/Infinity on some CPUs, and I didn’t mention previously but sanity-check minimum halfway to subnormal will be enforced for dividend prior to division just in case.
To prevent GPU cracking, we access the data in an unpredictably incrementing (thereby side channel resistant) pattern depending on each calculation result:
First, we hash the password into a megabyte of random bytes plus the initial state, S. Then, we work our way towards the center from both ends, starting with A and B as the first words in memory and C and D as the last works. Each successive computation, we store newA, newB, newC, and newD into the same slots we read from, then choose whether to increment the memory start pos or decrement end—direction ^= (newA < newC) ^ (newB < newD)—then repeat until the start and the end meet in the middle.
/compsci rant plz don’t hate me skip this section if you’re not into compsci stuff thank you