## Solution

```
1 = 1
3 - 1 = 2
3 = 3
3 + 1 = 4
9 - 3 - 1 = 5
9 - 3 = 6
9 - 3 + 1 = 7
9 - 1 = 8
9 = 9
9 + 1 = 10
9 + 3 - 1 = 11
9 + 3 = 12
9 + 3 + 1 = 13
27 - 9 - 3 - 1 = 14
27 - 9 - 3 = 15
27 - 9 - 3 + 1 = 16
27 - 9 - 1 = 17
27 - 9 = 18
27 - 9 + 1 = 19
27 - 9 + 3 - 1 = 20
27 - 9 + 3 = 21
27 - 9 + 3 + 1 = 22
27 - 3 - 1 = 23
27 - 3 = 24
27 - 3 + 1 = 25
27 - 1 = 26
27 = 27
27 + 1 = 28
27 + 3 - 1 = 29
27 + 3 = 30
27 + 3 + 1 = 31
27 + 9 - 3 - 1 = 32
27 + 9 - 3 = 33
27 + 9 - 3 + 1 = 34
27 + 9 - 1 = 35
27 + 9 = 36
27 + 9 + 1 = 37
27 + 9 + 3 - 1 = 38
27 + 9 + 3 = 39
27 + 9 + 3 + 1 = 40
```

The right approach to think of a solution for this problem is this. If you have X cans that let you measure the quantities between 1 to N, now you will include 2*N + 1 as your next can because it has some very good advantages.

- It will let you measure all quantities between N+1 to 2*N by subtracting N to 1, respectively(we already can measure this quantity using previous X cans) from a new can(2*N+1).
- It will also let you measure quantities between 2*N+2 to 3*N+1 by adding 1 to N(we already can measure these quantities using previous X cans) from a new can(2*N+1).

We need to start with 1, as it is mandatory to measure quantity 1, so now, according to the above logic, the next can should be 3(you can measure up to 4), the next one should be 9(you can measure up to 13), and the fourth one should be 27.

**As shown above, these cans can measure all quantities between 1 and 40. **

## Frequently Asked Questions

### What are logical skills?

Analyzing a situation and coming up with a reasonable solution is also known as logical thinking. It's a lot like critical thinking. Logical thinking employs reasoning abilities to objectively examine any issue, allowing for a sensible decision on how to continue. For example, if you're dealing with a problem at work, you'll utilize the information at hand and your logical thinking abilities to solve it.

### What are analytical skills?

Analytical abilities allow you to recognize the complexity of a problem, analyze and organize it, solve it, make projections, and generate new ideas. Making accurate assessments of events and offering insight into how various components interact is what analytical thinking entails. As a result, analytical skills are highly directed toward understanding cause and effect and forecasting the implications of possible solutions.

### What are puzzles?

A puzzle is a game, problem, or toy that challenges one's imagination or understanding. The solver is meant to arrange pieces logically to arrive at the correct or pleasurable answer to a puzzle.

## Conclusion

This article briefly discussed the puzzle to find the dimensions of cans to measure each quantity between 1 and 40.

We hope you understand the problem and solution properly. Now you can do more similar questions.

**Recommended Readings:**

Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Happy Learning!