Problem: Software Versioning
Problem Type : Complex
ABC corp. makes a large range of softwares. They always need to distribute new patches and updates to their existing users. The updates may have dependency on earlier versions and hence the update process may vary for different users, depending upon which version a user is using at the moment.
To distribute it, the company wants it to be a one-click process and hence your script should be able to determine the entire list and order of packages a user needs to install, when he wants to upgrade to the current version.
Problem Specifications :
• Every application has an upgrade dependency on its previous Major Release.
o i.e. An application with a version 5.2 can only upgrade if the system already has a 5.x version installed. Here x is a minor version no. less than 2.
o If the user is using a version earlier than 5.x, then a cumulative upgrade process should be initiated. Eg. If user is using 3.0 and wants to upgrade to 5.2, then he should download 4.0, 5.0 and then 5.2
o If the user is already using a version 5.x, then only v5.2 should be downloaded.
• The script will be provided with a user id, and should be able to generate the list of all packages, to be downloaded to upgrade all applications used by that user.
• Version numbers will always be in the format a.b, where a & b are positive integers.
• If the user is already using the most updated version, then nothing has to be done. Don’t display any output corresponding to that application.
Files Provided :
1. versionfile.txt : This file will contain the latest upgrade available for an application and its dependency hierarchy.
Format: <app_id>,<latest_version>,<list of all older versions>
Eg.
34,5.2,5.1,5.0,4.6,4.2,4.0,3.9,3.5,3.0,2.0,1.0
2. users.txt : This file will contain information on users, with the application and their versions currently used by them.
Format: <user_id>,<app_id>,<current_version_used>
143,34,4.6
786,98,3.2
143,14,3.6
Input:
• The input will be given as standard console input.
• Input will consist of three lines.
• The first line of input will contain absolute path to versionfile.txtd
• The second line of input will contain absolute path to users.txt
• The third line will contain a single integer, containing user_id
Output:
• The output should contain one line for each application, the user has, with the following information in comma-separated format.
<user_id>,<app_id>,<versions to be installed in oldest-version-first order>
Note: If you need to create any temporary files, do so in the /tmp folder and the filename should be prefixed with your employteeid so that it does not conflicts with others’ files.
Sample Input Sample Output
/path_to_file/versionfile.txt
/path_to_file/users.txt
143 143,34,5.0,5.2
143,14,4.0,5.0,6.0,6.3
nimesh g 0 Newbie Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.