Excel Challenge #2

Discussion in 'Off-topic' started by Steve Hales, Mar 13, 2015.

  1. maz1987

    maz1987 Member

    It can be reduced further by changing LEFT(String,1) to LEFT(String), which appears to give the first letter by default.

    Also, you do not need to specify the formula to give 0 if the test is false, so the ,0 part can also be removed:

    Code:
    =IF(SUM(IF(MID(A1,ROW(A:A),1)=LEFT(RIGHT(A1,ROW(A:A))),1))=LEN(A1),,"No ")&"Palindrome"
    which is 86 characters.

    I feel we're just refining it now so...back to study!
     
  2. Steve Hales

    Steve Hales ActEd Tutor Staff Member

    That's a really neat idea!
     
  3. Steve Hales

    Steve Hales ActEd Tutor Staff Member

    This may be considered cheating ;), but if you change the cell formatting to
    Code:
    "Palindrome";;"No palindrome"
    then the following solution only requires 66 characters
    Code:
    =--(SUM(IF(MID(A1,ROW(A:A),1)=LEFT(RIGHT(A1,ROW(A:A))),1))=LEN(A1))
     
  4. maz1987

    maz1987 Member

    CA2 examiners would go mad.....and I like it!

    edit: by the same logic, we could use:

    Code:
    (SUM((MID(A1,ROW(A:A),1)=LEFT(RIGHT(A1,ROW(A:A))))*1)=LEN(A1))*1
    for 64 characters!
     
    Last edited by a moderator: Mar 24, 2015
  5. Steve Hales

    Steve Hales ActEd Tutor Staff Member

    I think that boat sailed some time ago :D
     
  6. Steve Hales

    Steve Hales ActEd Tutor Staff Member

    This attempt has a character count of 56.

    Code:
    =--AND(RIGHT(LEFT(A1,ROW(A:A)))=LEFT(RIGHT(A1,ROW(A:A))))
    The MID function had to be abandoned because MID(string,x,1) returns "" when x>len(string), whereas RIGHT(LEFT(string,x)) just gives RIGHT(string) for large values of x.
     
  7. maz1987

    maz1987 Member

    Nice one! I tried to change the approach by using the SEARCH() function to reduce the character count but to no avail.

    Although only one "-" sign is needed, with a result of -1 verifying it is a palindrome :)
     
  8. Steve Hales

    Steve Hales ActEd Tutor Staff Member

    There haven't been any new suggestions for a couple of days, so it looks as though maz1987 is this month's winner - well done! Here's a summary of the final submission;

    Code:
    =-AND(RIGHT(LEFT(A1,ROW(A:A)))=LEFT(RIGHT(A1,ROW(A:A))))
    with the number formatting set to

    Code:
    ;"Palindrome";"No palindrome"
    That puts the character count at 55.

    Watch out for Excel Challenge #3 - launching Friday 10th April 2015. :)
     
  9. maz1987

    maz1987 Member

    I couldn't possibly accept that after I simply removed one character from your attempt!

    Look forward to the third..
     

Share This Page