1 / 25
Aug 2019

getting AC. Thanks @simes for brainstorming with me.

Turns out my approach was right . I still dont know why previous code was wrong.
What i did was rearrange my code. tested some cases at the end.
Rewrote the code . I did remove the check whether the string was odd or even. I started to test from the middle and two pointers and voila. Spoj is one weird place.

Corrected for this and also added some code for test cases like 191 etc. WA still .

Ok, here’s another couple.

2
97268987378
97268989378

I’m having the same problem. Can’t find a case where my program doesn’t work, still i’m getting WA.

I tried a few things on spojtoolkit/test/palin, which yield weird results :
04 becomes 05, as expected.
09 becomes 0, which is weird.
099 becomes 00, which isn’t any less weird.
So i tried to change my program to match this behavior, still WA.

I’m checking my output with cat -e to make sure I’m not displaying anything else than what i’m supposed to.

Don’t worry about case like 04, 05 - leading zeros are disallowed. (I have vague memories of using asserts to test whether there are any leading zeros in the test data, and there aren’t.)

Did you correct:

2
97268987378
97268989378

updated the code for these cases both in even and odd length numbers. WA still. I can’t seem get past first test case itself. Shows running(1) and bang WA!

I get 97269096279 for both, i think that’s the good answer.
I can’t figure out a case where i’d get a wrong output…

That latest code is a step backwards. You need to retest with the test cases attached to your first post.

changed it back and added some more modifications . All previous test cases working( I hope) I tried most of them. Still WA. Any more I am missing.

That latest code passes all my test cases.

I am confused. Did you get AC or all the test cases that you could think of ?

This is why I hate ad hoc questions like these or greedy algorithms for the same reason. :slight_smile:

This is gonna drive me crazy.

I made a checker program that verifies that:

  1. the output is a valid palindrome
  2. It is bigger than input
  3. There is no palindrome smaller than output and bigger than input

Then i also made a random number generator that outputs a test file containing a specified amount of test cases, each test cases being a random number string of random length up to 1000000 digits.

I tested like this :
ruby -e “puts (100000001); puts (0…10000000).to_a” | ./palin | ./checker 2> log.txt
and
./gen 10000000 | ./palin | ./checker 2> log.txt

And i didn’t get a single wrong output ! I spent a few hours verifying each and every part of my checker program and running tests, And i can’t find ONE test case that fucks up.
All this time i’m assuming there are NO leading zero in any input.
I’m gonna modify my program and my checker to handle leading zeros in different ways and try to submit, but i already did several tries like this.
Now what ?
Can someone who passed this problem send me his code so i can compare outputs before i go completely nuts ?

bro/lady we understand your frustation but this is not a social media platform where it’s alright to use cuss words. I am not offended but such behaviour needs to be nipped in the bud .
Also do share a test case if you find any which was causing wa in your code.

I’m curious as to what in what i wrote you consider a cuss word.

I’ll make sure to share if i find something.
In the meantime i can also send your code through my tests if you will.

“fucks” i am 100% sure that’s not a decent word even though we commonly use it. :slight_smile: Now let’s focus on getting an AC on this one.

I’m not going to share any code, but I’ll happily verify your test cases if you want. Either post your input here, or if it’s too big, PM me and I’ll share my email address.

how about that as an input ?
ruby -e “puts (100000001); puts (0…10000000).to_a”

I’m currently running randomized tests (it’s been running for 3 hours now, and still no error found), but i can store the cases instead of testing them if needed.

i’ll push the checker on github if you want to test it.

edit:


palin.c has been modified to output the input as well, so the checker knows what its dealing with

edit: Well the smaller palindrome detection is bugged. I’ll fix that and run another series of tests

  • should be fixed.