Hello again fellow replers! Last week, we started our weekly challenges, check out that post by clicking here.

### More guidelines

Today, I'm posting this week's challenge. **But before that,** a few more instructions that weren't mentioned in the last post.

- You are allowed to make only 1 submission. Only submit after you're completely sure about submitting your submission. Your score won't be updated once your submission is scored.
- If there is any sort of condition in which your submission does
**not**satisfy the challenge's requirement, it's score will be`0`

.

And that's it! Now, let's get back to this week's weekly challenge.

### Number of digits (but palindromic)!

Write a program that takes a numerical input (integer) from the user (for example: `n`

). For all the numbers between 0 and `n`

, count the number of digits in each of these numbers and get the total number of digits among all these numbers. Then find the number closest to the total number of digits such that the found number is a palindrome (for example: `x`

) and print out `x`

's value.

Example: -**INPUT :** `20`

**PROCESS: -**

Total = 0

For 0 to 9, number of digits = 1. Total = 1 * 10 = 10.

For 10 to 20, number of digits = 2. Total = 1 * 10 + 2 * 11 = 32.

Closest number to 32 that is also a palindrome = `33`

.

**OUTPUT :** `33`

Again, for submitting your repls, post them on the share board and be sure to keep `#WEEKLY`

in the post's title.

If you have any further questions, you can ask them via the comments section, and if you don't, I would still recommend going through the comments section as they may contains some extra information.

Given below are the results for last week's weekly challenge.

### WEEKLY CHALLENGE 1 - RESULTS

**Rank 1 : @qsa** with a perfect score of 10 points. Check out their submission here.

**Rank 2 : @DynamicSquid** with a score of 9 points. Check out their submission here.

**Rank 3 : @sugarfi @Scoder12 @EthanHorowitz @Lord_Poseidon** with a score of 8 points among all 4 users. The links to their submissions are given below.

@sugarfi : https://repl.it/talk/share/WEEKLY-Underscore-Edition/36190

@Scoder12 : https://repl.it/talk/share/WEEKLY-Challenges-1-Fractions-solution/36204

@EthanHorowitz : https://repl.it/talk/share/WEEKLY-1-Binary-By-Hand/36274

@Lord_Poseidon : https://repl.it/talk/share/WEEKLY-binary-arithmetic-because-why-not/36273

- During this challenge, we
**did**allow submitting multiple times or updating your submissions but it won't be allowed from this week. - We
**did not**score the submissions which had errors.

Two of the most common errors were - Division by 0 (For people doing inverse division) and Infinite recursion (When entering a negative number for those who used recursion).

And that's it! Good luck with this week's weekly challenge and have fun!

@TheDrone7 Oh, what about negative numbers?

You *will* have to take them into account. Although, the `-`

symbol is not a valid digit. @DynamicSquid

@TheDrone7 Hey, I have a quick question. So at the start of today, I was at like 580 cycles, however, as soon as you posted this, I jumped to 700. And it's not only me seeing this, @johnstev111 also reports the same thing. So I was just wondering, is this glitch, or did you award me 120 cycles for coming in second place?

No, you were not awarded the cycles. You either received them or there is a bug. @DynamicSquid

@TheDrone7 yeah, I think it's a bug, cause I got like 120 cycles, and it's still rising, within a couple minutes. Who should I talk to about this?

@DynamicSquid I found this on Repl Customs:

They are legitimate

@johnstev111 120 cycles in a couple minutes without posting anything? I think it's a bug.

@DynamicSquid Maybe an old post?

@johnstev111 nope, I checked all my posts, none got any new upvotes

@DynamicSquid A comment maybe?

@johnstev111 no. and remember, I got 120 cycles in a couple minutes! that has to to a bug or glitch of somekind

@DynamicSquid I don't know... speak to a mod...

@johnstev111 do you know how?

@DynamicSquid Speak to a mod... it's weird

@DynamicSquid If you're a member of our Repl.it Discord, you can report it in #bugs. If you aren't, I believe you can email [email protected] or report here: https://repl.it/bugs

@bramley please don't advertise discord #bugs, it's not well monitored. Email and /bugs is great, thanks for sharing.

@DynamicSquid You just lost 100 cycles... Those buggy cycles are gone

@johnstev111 yeah, and I'm continuing to lose them, hopefully it goes back down to the right number

@DynamicSquid It looks like it's back

@johnstev111 oh yup, that's good :)

@DynamicSquid The 703 cycles was just a fluke then..

Closest as in a higher num, lower num, or both?

Closest means the closest, it can be higher or lower. If there's a higher *and* a lower palindromic number equally close, either is fine. @DynamicSquid

@TheDrone7 got it :)

@DynamicSquid prob both

Can you add more examples? It's not very clear what you want us to do.

If I add any more examples, it would pretty much reveal the entire solution. @CodeLongAndPros Although, if you have doubts about something specific, I would be glad to clarify.

get the total number of digits among all these numbers

This would be for 11 then:

0-9 = 10*1; Total = 10

10 = 2*1; Total = 12

Closest palindrome: 11?

I just don't understand what you are trying to say.

@CodeLongAndPros basically, count the amount of chars there are from 0 to INPUT, then find the closest palindrome to that number

So basically, if the user entered 20, (there are 32 digits from 0 to 20: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), and the closest palindrome to that number would be 33

@CodeLongAndPros You've got the idea, though the number of digits for your 11 example would actually be 14 since it would be 10-11 = 2*2.

Oh wow! I didn't except to get second place :)

why is this pinned in announcements?

but it isn't. @CodingCactus

@TheDrone7 huh, it was a few seconds ago (for me)

How would you find every palindrome, since you would need every one to compare. I know you can find a palindrome based off a number, but those skip a lot of numbers.

Where can we find what scores we got?

i don't get what it's supposed to do other than a random algoritm...

So, I presume my submission must've fallen into the category of "submissions which had errors"?

Here is my submission :D

@ChezCoder wow, you love advertising :)

Oh, but the submissions aren't based on number of views or upvotes. the modes will eventually look at all of them :)

@DynamicSquid lol sorry never meant to advertise. Also, your cycles are back to normal again!

@ChezCoder yup :) kinda glad that I don't have buggy cycles anymore

@DynamicSquid lol but you also lost 200 cycles

@ChezCoder yeah lol, but I would rather have real cycles than buggy ones

@ChezCoder but it is kinda a cool feeling when your first in the 7-day leader board :)

@DynamicSquid WAIT IM FIRST IN LEADERBOARD?? WTFFF

@ChezCoder yup :) good job!

@DynamicSquid omg thank you!!!!!

@ChezCoder those stop animation projects really gained you a lot of cycles :)

@ChezCoder and you're on your way to 800!

@DynamicSquid definitely xD something just clicked inside my head

@DynamicSquid ik XD earlier today, i was reloading the page and watching my cycle count go up, its depressing and exiting at the same time lol

@ChezCoder lol. and you made quite a few animations! you made three in 8 days! It takes me a week to make something...

@DynamicSquid you are very good at flattery, here are some upvotes :D

@ChezCoder oh thanks xD

@DynamicSquid wow! congrats! you reached 600 :D

@ChezCoder yay! however I really need a break from cycles. I'm still working on my 500 cycles special lol

@DynamicSquid oh lol. Im plan on only making my cycle specials like every 500 cycles, for example, my 500 cycle special, and my 1000 cycle special (which I very much hope will be coming soon!)

@ChezCoder yeah, I'm also thinking of doing that

Has my last challenge been graded?

All have been graded. @HahaYes but your scores won't be revealed if you didn't make it in the top 3.

@TheDrone7 Lol I probably failed

Is the range inclusive or exclusive? Like if I enter 20 does it count 20?

Inclusive. @ThatSmart

@TheDrone7 What should I do if the number is equidistant from 2 palindromes?

Either of the two is fine. @ThatSmart

@TheDrone7 Alright. Maybe you should say that in the challenge, like 57 can return either 101 or 111?

@TheDrone7 Will single digits count as palindromes?

Well, yes. @ChezCoder

@TheDrone7 Alright.

@TheDrone7 another question, would we need to count for decimals? if so, can the palindrome result be a decimal?

No, I specified `integers`

meaning only positive or negative numbers without any decimal points. @ChezCoder

@TheDrone7 when testing, will you enter decimals in the input?

Closest higher num, lower num, or both?

Yeah, I saw your comment and the response, and just submitted mine. @DynamicSquid

Ummmm, how do you come up with this?

~~I stole it from some websites I don't even remember~~. I browse through my school's Computer Science book, see a few activities, combine them and make a new challenge. @PYer

@TheDrone7 oh that's neat. and are you doing these challenges by yourself, or are you working with a team of mods?

@DynamicSquid Well all the moderators are free to choose whether or not they want to help with the judging but for now I'm doing this on my own. It's my job at repl.it

@TheDrone7 oh, wow, good job!

@DynamicSquid thank you very much.

Yeeeet

confused...

@TheDrone7 can you clearify the 0 to `n`

part? im confused due to your demonstration.

@ChezCoder if the input is 20, then count all the digits you see here:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

@DynamicSquid you mean add?

0 1 2 3 4 5 6 7 8 9 - that's 10 digits

10 11 12 13 14 15 16 17 18 19 20 - that's 22 digits

the total would be 32

@DynamicSquid oh like count the number of chars

@ChezCoder oh quick question, how many cycles do I have?

@DynamicSquid 720 why?

@ChezCoder a couple minutes ago I had 580. this is definitely a bug/glitch. do you know how to contact a mod?

@DynamicSquid try feedback/bugs? I don't know if its a bug, maybe people are upvoting your comments, etc, but congrats :D

congrats to the winners! yeahhhhh!!!! <3

@lilykhan thanks xD

wha...

Egg

huh? Please clarify

I am obviously not in an interview

@TheDrone7 Oh, more more question (sry if I'm bombarding you with questions), if the input is 0, is the output 0 or 1? Because it says the numbers between 0 and n, but there are no numbers between 0 and 0, so would the output be 0?

No problems with the questions @DynamicSquid and the range is inclusive so among 0 and 0, there is 1 number i.e. 0 so the answer would be 1.

@TheDrone7 oh, okay, thanks so much!