Program to Anaylze Dependencies

RudeDue

New member
Joined
May 23, 2019
Messages
4
Programming Experience
3-5
Hi I am working on a program to perform analysis on dependencies of systems.

For example a system with the following system requirements will be in a text file as exampled below
I added comments to the input file ( - Comment) the comments will not be present in the input text files and can be ignored.

2 - Denotes number of Packages to be installed
A,1 - Package 1 to be installed
B,1 - Package 2 to be installed
3 - Denotes number of Dependencies to be installed (P1 , V1 , P2, V2) - package p1 in version v1 depends on p2 in version v2
A,1,B,1 - Dependency 1
A,2,B,2 - Dependency 2
C,1,B,1 - Dependency 3

My goal is to perform analysis of various text files with similar input to determine Validation for System configuration..
If more than one version of a package is required the installation is invalid. Your task is to check if installing the packages (along with all packages required by dependencies) is valid

The sample input above is valid, but the sample input below is invalid as A,1 requires B,1 and we are trying to install B,2.

2
A,1 B,2
3
A,1,B,1
A,2,B,2
C,1,B,1

I am trying to determine the best course of action to perform analysis on the text files to determine Success and Failure configurations.
I would appreciate any input on how I can design a software solution...
Thanks
 
This seems like a very simple look up problem. Just keep the list of packages and version pairs in a list, and search through the list. It'll be an O(N) solution. If you need an O(1) solution, use a dictionary instead of a list. What am I missing that is making this a hard problem?
 
This seems like a very simple look up problem. Just keep the list of packages and version pairs in a list, and search through the list. It'll be an O(N) solution. If you need an [ICODE}O(1)[/ICODE] solution, use a dictionary instead of a list. What am I missing that is making this a hard problem?

HI
Thanks for the response.
The only inputs are the textfiles, and I need to determine if each textfile/system is valid based on the textfiles only.
The configuration of the Dependancies are what is to be used for the analysis to determine what is Valid and What is Not Valid

Yes this does appear from the 2 sample inputs to be a simple solution however.
I have only listed 2 file inputs..
For example the following input text file

2
A,2
B,2
3
A,1,B,1
A,1,B,2
A,2,C,3


This should produce a Success, however I am unsure how to determine the logic in the code. The previous sample I do have the solution in code. But the sample text information above I am unsure, how to design the logic.

I have created a Package class that has Package and Version info and from that I have created a List<PackageObjects>

the following code should produce A Failure

2
A,2
B,2
5
A,1,B,1
A,1,B,2
A,2,C,3
C,3,D,4
D,4,B,1

I am not asking for the answer , but I am new to this type of logic design and am trying to find a elegant solution to my over all task.
I have researched using trees, topological graphs, and was wondering if there was a more elegant solution to my problem...
I have written code that will handle the most obvious sample input , however the ones that I have listed above does not seem to be a simple solution .. Maybe you can provide some insight ??
 
Last edited:
For example the following input text file

2
A,2
B,2
3
A,1,B,1
A,1,B,2
A,2,C,3


This should produce a Success, however I am unsure how to determine the logic in the code.
I don't understand. Why would that produce success? From my understanding of post #1, that has packages A2 and B2, so it should fail because A1 needs B1, and A2 needs C3. Since you don't have either A1 nor C3, the installation would fail.
 
I don't understand. Why would that produce success? From my understanding of post #1, that has packages A2 and B2, so it should fail because A1 needs B1, and A2 needs C3. Since you don't have either A1 nor C3, the installation would fail.

Sorry I forgot to mention the second input file in the first post should produce Fail. Due to A,1 requires B,1 and we are trying to install B,2.
2.

I test the first line to determine that PackageObject A1 and PackageObject B2 of the Dependency Packages, based on PackageObject A1 and PackageObject B2 that are required for the System configuration are valid. This scheme works for most of my input files however this design does not work for 100% of my input files.

For example the files
2
A,2
B,2
5
A,1,B,1
A,1,B,2
A,2,C,3
C,3,D,4
D,4,B,1
Should produce a failure, due to I believe the Package Objects B,1 in the dependency section in the second column is listed more than once.
While the following example input
2
A,2
B,2
3
A,1,B,1
A,1,B,2
A,2,C,3
Should produce Success

I can hard code the fix however, I am seeking a more experience view point to determine a more elegant solution to my overall problem

I appreciate you input.

Thanks
 
Sorry I forgot to mention the second input file in the first post should produce Fail. Due to A,1 requires B,1 and we are trying to install B,2.
2.
You did mention that. See your post #1's:
..., but the sample input below is invalid as A,1 requires B,1 and we are trying to install B,2.

2
A,1 B,2
3
A,1,B,1
A,2,B,2
C,1,B,1

Using that same logic, I don't understand why you are saying:

While the following example input
2
A,2
B,2
3
A,1,B,1
A,1,B,2
A,2,C,3
Should produce Success

In this case A1 is dependent on B1, but B2 is being installed according to the line that says A,1,B,1.

And furthermore, it looks like A2 is dependent on C3 (due to line A,2,C,3, but you only listed two packages being installed: A,2 and B,2.

Can you explain why that would be successfull?
 
You did mention that. See your post #1's:


Using that same logic, I don't understand why you are saying:



In this case A1 is dependent on B1, but B2 is being installed according to the line that says A,1,B,1.

And furthermore, it looks like A2 is dependent on C3 (due to line A,2,C,3, but you only listed two packages being installed: A,2 and B,2.

Can you explain why that would be successfull?
Yes I agree with your confusion, that is where my confusion is as well.
The sample text file as per requirement should produce a Valid result.

The only solution is to hard code the installing packages are referenced in the each of the columns of the dependency section.
But not in the same columns.

I am hoping for a more experienced viewpoint to design a more elegant solution..
I don't like to hard code solutions

I appreciate you help and input.
I know its confusing
 
You shouldn't have to hard code anything as long as there is a consistent rule as to why an input file is classified as valid or invalid. So far I'm not seeing any consistency.

Do you have an actual link to the problem statement? Maybe there is an extra constraint that you forgot to mention but is in the original problem statement?
 
Back
Top Bottom