Comment

Comment by bumbledraven

Here’s a way to use algebra to grind out the solution to #1 with no particular insight needed.

Assume that prices and the amount of kopeks a person has are both represented by nonnegative integers. Let A be Masha’s kopeks, let I be Misha’s kopeks, and let B be the price of the book. We are given the following:

A = B - 7 (1)

I = B - 1 (2)

A + I < B (3)

Substituting (1) and (2) into (3) yields

B - 7 + B - 1 < B (4)

This simplifies to

B < 8 (5)

B = 7 satisfies (5) and, from (1) and (2), implies that A = 0 and I = 6, which together satisfy the givens (1), (2), and (3). So B = 7 is a solution. Furthermore, we cannot have B < 7 or else (1) would imply A < 0, contradicting the assumption that our variables are represented by nonnegative integers. So B = 7 is the only solution.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton