Coding Challenge Coding Live

Find the second smallest integer in array

To run the existing JUnit tests using Gradle, execute the following commands

which the runtime system calls when the program starts. Themain()method then calls all the other methods required to run the application. It takes two arguments. The first argument is the path to the file containing theTown Graph, while the second argument points to the file containing thecommandswe want our application to execute.

Interface defining a command that can be executed by calling itsexecute()method. A typical command would be calculating the distance of a route.


Notes: – You may needGradle Integration for Eclipse- Make sure to replaceapply plugin: ideawithapply plugin: eclipsein thebuild.gradlefile located in projects root directory.

Providesstaticmethods for global access to the applications properties.

The project is a Gradle project. To build, open up your Terminal and fire up the following commands:

Setup Jenkins On AWS EC2 For Your Python (Django) Application Part 2

To import the project using Eclipse, do the following: -File – Import… – Gradle – Gradle Projectfrom the main menu. – ClickNext. – ClickBrowse…for theRoot Directory. – Select and open theTrainsproject. – ClickBuild Model. – Select all projects. – ClickFinish.

5 Great Books For Software Engineering Interview Preparation

The purpose of this problem is to help the railroad provide its customers with information about the routes. In particular, you will compute the distance along a certain route, the number of different routes between two towns, and the shortest route between two towns.

LLRailRoadServiceImplimplements theLLRailRoadServiceinterface. It makes use ofLLTownMap. Although most of the functionality inLLRailRoadServiceImplis cascaded toLLTownMap, the idea of providingLLRailRoadServiceImpl, is to separate the functionality between a service system and a map. That is,LLRailRoadServiceImplcould be expanded to support further functionality such asrequestClosingHours()ornextTrainDepartureTime()without the need to modify theLLTownMap.

– Compute length of shortest path between node. Example:

To import the project using Eclipse, do the following: -File – New – Project from Existing Sourcesfrom the main menu. – Browse to the project directory and clickOK. – SelectGradleas build tool and clickNext. – SpecifyGradle homeand make sure theGradle JVMis set to version1.8.x. – ClickFinish.

The local commuter railroad services a number of towns in Kiwiland. Because of monetary concerns, all of the tracks are one-way. That is, a route from Kaitaia to Invercargill does not imply the existence of a route from Invercargill to Kaitaia. In fact, even if both of these routes do happen to exist, they are distinct and are not necessarily the same distance!

LLCommandFactoryInterface that defines which functionality anLLCommandfactory must provide.LLCommandFactoryprovides functionality for creating new commands that implement theLLCommandinterface.

– Compute distance of route. Example:

Below follows an example with input data, actions performed and expected output result.

Find the second smallest integer in array

This coding-challenge was part of the interview process with ThoughtWorks for a software developer role. Time frame was about 3 days.

length_of_shortest_path;[START TOWN];[DESTINATION TOWN]

Output messages are both availabe in English and German, depending on the systems default locale. The messages are available in thetrains.propertiesandtrains_de.propertiesfile, respectively, and can be found under/src/main/resources/com/lucaslouca/.

distance;[TOWN 1];[TOWN 2]; … ;[TOWN N]

Setup Jenkins On AWS EC2 For Your Python (Django) Application Part 2


– Count routes with maximum number of hops. Example:

You should see a BUILD SUCCESSFUL message when everything went well. When the build completed succesfully, the program will be namedTrains.jarand can be found under/build/libs/in theTrainsproject directory.

or run all commands contained in a text file:

The towns are named using the first few letters of the alphabet fromAtoE. A route between two towns (AtoB) with a distance of5is represented asAB5. A directed graph is represented by a list of routes, with each route as a separate line.

Setup Jenkins On AWS EC2 For Your Python (Django) Application Part 1

Commuter railroad service for the towns in Kiwiland.

count_routes_with_hops;[START TOWN];[DESTINATION TOWN];[HOP COUNT]

Available Actions- Compute the distance along a certain route. If no such route exists, output NO SUCH ROUTE. Otherwise, follow the route as given; do not make any extra stops! – Compute the number of different routes between two towns. – Compute the shortest route between two towns.

TheLLCommandFactorywill then be used byLLCommandProccesorto createLLCommandobjects for a given input.LLCommandProccesorcan take and execute a single command in the form of text:

count_routes_with_max_distance;[START TOWN];[DESTINATION TOWN];[MAX DISTANCE]

LLRailRoadServiceCommandFactoryThis class implements theLLCommandFactoryinterface. It provides methods for creating concrete command implementations of the abstract typeLLAbstractRailRoadServiceCommand. TheLLRailRoadServiceCommandFactorygets initialised with anLLRailRoadService, which it sets asreceiverinLLAbstractRailRoadServiceCommandinstances:

JUnittests are located under/src/test/java.

LLDirectedGraphrepresents a generic directed graph. It provides basic functionality for adding nodes and edges as well as methods for computing the shortest path (Dijkstra) and distance between nodes.

Sample data for agraphandcommandscan be foundhere.

– Compute shortest path between nodes. Example:

count_routes_with_max_hops;[START TOWN];[DESTINATION TOWN];[MAX HOP COUNT]

The distance of the route A-B-C. The distance of the route A-D. The distance of the route A-D-C. The distance of the route A-E-B-C-D. The distance of the route A-E-D. The number of trips starting at C and ending at C with a maximum of 3 stops. In the sample data below, there are two such trips: C-D-C (2 stops). and C-E-B-C (3 stops). The number of trips starting at A and ending at C with exactly 4 stops. In the sample data below, there are three such trips: A to C (via B,C,D); A to C (via D,C,D); and A to C (via D,E,B). The length of the shortest route (in terms of distance to travel) from A to C. The length of the shortest route (in terms of distance to travel) from B to B. The number of different routes from C to C with a distance of less than 30. In the sample data, the trips are: CDC, CEBC, CEBCDC, CDCEBC, CDEBC, CEBCEBC, CEBCEBCEBC.

Setup Jenkins On AWS EC2 For Your Python (Django) Application Part 1

– Count routes with maximum distance. Example:

TheLLTownMapinterface represents a map that stores towns using aLLDirectedGraphunderneath. It wraps the functionality ofLLDirectedGraphand provides methods for accessing it using the town names.

Classes inheriting fromLLAbstractRailRoadServiceCommandare commands that implement theLLCommandinterface but are specifically implemented for theLLRailRoadService. An example would be theLLDistanceCommand.

At we want to help fellow software engineers become better at what they do by sharing our experiences during our quest to become better engineers ourselves. We provide you with software engineering interview and job experiences, programming questions and tutorials.

LLCommandProccesorexecutesLLCommandcommands. TheLLCommandProccesorgets initialised with anLLCommandFactory.

A directed graph where a node represents a town and an edge represents a route between two towns. The weighting of the edge represents the distance between the two towns. A given route will never appear more than once, and for a given route, the starting and ending town will not be the same town.

– Count routes with exact number of hops. Example:

TheMainclass is the main entry point of the application. It contains amain()method whose signature looks like this

Output 1: 9 Output 2: 5 Output 3: 13 Output 4: 22 Output 5: NO SUCH ROUTE Output 6: 2 Output 7: 3 Output 8: 9 Output 9: 9 Output 10: 7

Use the search below to find our solutions for selected questions!

Leave a Reply