Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:47:08+00:00 2026-06-12T02:47:08+00:00

I am soo close to finishing my program, but I am having a small

  • 0

I am soo close to finishing my program, but I am having a small issue. The I/O is suppose to look like this:

I: fanlc2("human", "chimpanzee")
O: [4, 'h#man', '#h#m#an###']

BUT mine, does the following:

I: fanlc2("human", "chimpanzee")
O: [4, '#', '#h#']

Can someone please edit my code so I get the proper answer. I cant figure it out. Thanks:

def fanlc2(S1, S2):
    if S1 == '' or S2 == '':
        return [0, S1, S2]
    if S1[0] == S2[0]:
        temp = fanlc2(S1[1:], S2[1:])
        return [temp[0]+1, S1[0]+temp[1], S2[0]+temp[2]]
    t1 = fanlc2(S1[1:], S2)
    t2 = fanlc2(S1, S2[1:])
    if t1[0] > t2[0] or t1[0] == t2[0]:
        return [t1[0], '#'+t1[1], t2[1]]
    return [t2[0], t1[1], '#'+t2[1]]

Here are more I/O’s that the program SHOULD be returning:

fanlc2(“x”, “y”)

[0, ‘#’, ‘#’]

fanlc2(“spam”, “”)

[0, ‘####’, ”]

fanlc2(“spa”, “m”)

[0, “###”, “#”]

fanlc2(“cat”, “car”)

[2, “ca#, “ca#”]

fanlc2(“cat”, “lca”)

[2, “ca#”, “#ca”]

fanlc2(“human”, “chimpanzee”)

[4, ‘h#man’, ‘#h#m#an###’]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:47:09+00:00Added an answer on June 12, 2026 at 2:47 am

    You just mixed up some of your variables/indexing in the last couple lines. Try using more descriptive variable names and you may avoid this problem in the future.

    if t1[0] > t2[0] or t1[0] == t2[0]:
        return [t1[0], '#'+t1[1], t1[2]]
    return [t2[0], t2[1], '#'+t2[2]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm SOO close to finishing a pet project, this is the last part I
Im trying to make the look of my application to look something like this:
soo tired and I know I've seen this before but Google's not helping I'm
I know, I know , this sounds soo easy. But I can't seem to
Soo, I think this might be early, but I have a need for usb
I have this SQL query but its running soo slow, SELECT wr.wr_re_id as ReID,
Ok I know this sounds like a stupid question but I JUST CAN NOT
I'm not soo good at MySQL. But want to improve it a bit, to
I've been trying to figure this out for hours and it's soo frustrating! I
So I assume this is something I'm doing flagrantly wrong. It is soo slow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.