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 8678327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:41:23+00:00 2026-06-12T20:41:23+00:00

My Project Purpose : There are 4 files. Each of them has different number

  • 0

My Project Purpose : There are 4 files. Each of them has different number of lines. Each line consists of a single or few words. Now, for each of these files, I want to count which other file has the maximum common words.

  • eg. (‘,’ is a new line \n)
  • Input:
  • File 1 Lines : A,B,C,D
  • File 2 Lines : C,D,E,F
  • File 3 Lines : A,E,C,G
  • File 4 Lines : C,E,F,A

  • Output :

  • File 1 : Maximum common words is 2 and they are in the files : File 2 (C,D), File 3 (A,C) and File 4 (C,A).
  • File 2 : Maximum common words is 3 and they are in the files : File 4 (C,E,F).
  • File 3 : Maximum common words is 3 and they are in the files : File 4 (C,E,A).
  • File 4 : Maximum common words is 3 and they are in the files : File 2 (C,E,F).

My logic :

  1. Start
  2. Read each line from file and store it in memory as a 1-D array (eg. array1[0] = “A”, array1[1] = “B” and so on.
  3. Since there are 4 files, I create 4 arrays = array1 to array4. Each of them will have the contents of their corresponding files.
  4. Now I will compare the first words in the first array with the first word in the second array.
  5. Now I will compare the first words in the first array with the second word in the second array and so on till the end on second array.
  6. I will continue this till the last word in the last array.
  7. When ever I found something was matching I will note down in a variable by incrementing 1.

Wish to know if this is the right of approaching this problem.

Or is there a better way to think at this problem?

Edits :
1. Forgot to add, Will be using php.

  • 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-12T20:41:25+00:00Added an answer on June 12, 2026 at 8:41 pm

    Should be easily done with array_intersect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My project consists of an app that links to two static libraries. Each of
We maintain a large number of .NET Project and Solution files by hand; it's
I'm undertaking a project with a learning purpose. Since this project is compelling to
Background: Trevor was working on a test project solely for the purpose of trying
I'm about to start a new project. The purpose of this project will be
Is there a way to modify Visual Studio 2008 or 2010 project pre-build events
I have an unusual environment in a project where I have many files that
I need to perform some actions (prepare gettext *.mo message files) on my project
I'm utterly confused. There's an 'assets' folder in my project, but the AssetManager does
I created my first Hello world project for BlackBerry and following files were created

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.