You are not logged in. Please login at www.codechef.com to post your questions!

×

Need help regarding CHDIGER

I am trying to solve Chef and a Beautiful Digit From March Long challenge. I have tried implementing it but am not able to get why I am getting the wrong answer. I have tried it for many input but I am getting correct for all the input. It would be great if someone could tell me what I am missing. Attached the link to my code.

https://ideone.com/e.js/fYgwqO

asked 13 Mar, 19:10

snami_01's gravatar image

2★snami_01
31
accept rate: 0%


Hi!!Could you please describe what your logic is and what exactly your code is doing??. or add comments in between your code to show what each step is doing??.

One Test case i found where your solution fails is the following

1

423234 6

Your Answer - 223666

Correct Answer - 223466

Hope This Helps!!. :)

link

answered 13 Mar, 20:06

lonewolf_kj's gravatar image

3★lonewolf_kj
311
accept rate: 25%

edited 13 Mar, 20:07

1

Got it. Thanks a lot for the help.

(14 Mar, 13:07) snami_012★

Dude, The correct output would be 223366

link

answered 13 Mar, 21:22

shivam3211's gravatar image

2★shivam3211
1
accept rate: 0%

@shivam3211

The correct answer would 223466 only. You are only to append a digit and then remove a digit from any place. So you cannot shift the digits.

Thus to have 2nd digit as "2", The first 3 needs to be removed. Also since 4<6 There is no need to remove 4. Thus the minimum number that can be obtained turns out to be 223466.

(223366 > 223346, and both 223366 and 223346 cannot be obtained by only appending and removing a digit.)

link

answered 14 Mar, 02:07

lonewolf_kj's gravatar image

3★lonewolf_kj
311
accept rate: 25%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,424
×267

question asked: 13 Mar, 19:10

question was seen: 82 times

last updated: 14 Mar, 13:07