# [Community Puzzle] Solid Integer

Coding Games and Programming Challenges to Code Better

Created by @Meepophobia,validated by @pardouin,@TimberStalker and @ChuOkupai.
If you have any issues, feel free to ping them.

1 Like

Hello
I have solved the 4th first puzzles, but I canâ€™t success for the last one (05 - Out of Memory).
If the 4th one were not correct, I would keep on searching, but it is.
Is the Expected output correct for puzzle 5? itâ€™s expected 33646585979948395414, and I find 33646586081048405414 , which is weirdly close enough.

Yes, the expected output is correct.

1 Like

Thank you!
:y bad actually, I have just noticed that my answer was involving â€¦ a 0

Hello
The correct solution of puzzle 5 is 33646586081048405414 not
33646585979948395414. The algorithm consists in writing n in base 9 and the solution x is equal to writing x in base 10 with the coefficients of n in base 9.

Your solution as 0 in it so it cannot be correct.

Also, youâ€™re not supposed to give detailed explanation of how to solve the puzzle, let alone share your program.

my solution is mathematically correct.

A solid integer is an integer without 0. Yours has 0 i it, so it doesnâ€™t work. I agree that it has to do with base 9 and your solution is close but you must slightly tweak your algorithm.

Cute puzzle. Very easy to solve once you realize the trick.

1 Like

and I donâ€™t have the trick, can you help me ? x)

Think about how many solid integers there are for 1-digit numbers.
Then for 2-digit numbers.
Then for 3-digit numbers.
etc
Work out a pattern.

4 Likes

I think some relevant tests are missing.
I posted a wrong solution that passed all the tests, but my answer would be wrong when the base 9 expression of n contains consecutive 0s.

1 Like

I donâ€™t know how to access the contribution. The specific test case to add would be a value of n whose expression in base 9 has two or more consecutive 0s, like 81.

I agree. Looking through the solutions I think most will fail to print 9 as a 9th solid int.

Not far from the solution

Yes youâ€™re right. I have to modify my code ! Thx

Hi, I technically solved the challenge by validating all the test cases (donâ€™t get me wrong, I didnâ€™t do a simple switch case) but I didnâ€™t understand how to properly solve the underlying maths problem, if anyone is willing to share hints with me it would free my mind :â€™)

Spent more than 4 hours to finally solve it fully. It was a tough one for me.
Used two different techniques (wrt C++):

1. (From pattern) base 9 conversion of n (dropped it since the the solid numbers containing 9 part was tricky to correct)
2. Figure out how much to add in n, to find nth solid number (used string addition as the sum goes beyond unsigned long long) - AC