turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- BI
- /
- Enterprise Guide
- /
- how to write an algorithm which would generate the...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2016 06:27 AM

This is a challenging situation of combining mathematics into programming skills.

I have the following situation in which there is a train with 6 Bogies numbered as 1101 for first, 1102 for second all the way upto 1601. Sometime two trains are combined into one and hence this train will have 6 + 6 bogies (1101 through 1106 for first train, and 1201 through 1206 for the second train). THE DATA IS SHOW IN TABLE BELOW. The train first cab be leading train or trailing train in both, upward journey or return journey. Therefore final sequence of bogies can be a combination of, for upward journey, [ train 1 -> train 2 |or| train 2 -> train 1 ] and for return journey, [ train 1 <- train 2 |or| train 2 <- train 1 ] Whenever the train passes the measuring station, bogie number 1101 will be the first to cross and then bogie no. 1201 followed by bogie nos. 1301, 1401 and 1501. Every bogie has four axles, so when going upward direction (say, upward journey), the numbering will be Axle no. 1, 2, 3 and 4 for bogie no. 1101 (i.e. first bogie) then Axle no. 5, 6, 7, and 8 for Bogie no. 1201 followed by Axle no. 9, 10, 11, and 12 for Bogie 1301 and so forth, that in line of the sequence of bogies that are passing through the station. But when moving downward direction (say, return journey), Sequence number of axles changes to something like this Axle no. 24, 23, 22, and 21 for Bogie no. 1101, similarly Axle no. 20, 19, 18, and 17 for Bogie no. 1201 and Axle no. 16, 15, 14, and 13 for Bogie no. 1301 and so forth for the rest 3 Bogies. Now, if the train has 6 more bogies, the Axle sequence nos will add on up to 48 (i.e. 12 boggies and 4 axles = 48) and if there are another 8 bogies, as is the case of 1120, the axle sequence numbers will go upto 120 (20 x 4 = 120). But in rest all the cases, such as 1201 through 1218 or 1301 through 1318, there are maximum 18 bogies and hence max axle sequence numbers will be 72 (i.e. 18 x 4 = 72). I want to write an algorithm which would generate the possible combinations of Axle nos. for each of the bogies. A sample of possible Axle sequence numbers for 1101, when there are only 12 bogies (i.e. Train 1 and Train 2 attached together in either of the 4 possible conbinations for both upward & return journey): 1101 -> [ Axle 1 ] --> 1, 24, 25, 48 ; [ Axle 2 ] --> 2, 23, 26, 47 ; [ Axle 3 ] --> 3, 22, 27, 46 ; [ Axle 2 ] --> 4, 21, 28, 45 Similary for 1201: 1201 -> [ Axle 1 ] --> 5, 20, 29, 44 ; [ Axle 2 ] --> 6, 19, 30, 43 ; [ Axle 3 ] --> 7, 18, 31, 42 ; [ Axle 2 ] --> 8, 17, 32, 41 And so forth. |

Bogie |

1101 |

1102 |

1103 |

1104 |

1105 |

1106 |

1107 |

1108 |

1109 |

1110 |

1111 |

1112 |

1113 |

1114 |

1115 |

1116 |

1117 |

1118 |

1119 |

1120 |

1201 |

1202 |

1203 |

1204 |

1205 |

1206 |

1207 |

1208 |

1209 |

1210 |

1211 |

1212 |

1213 |

1214 |

1215 |

1216 |

1217 |

1218 |

1301 |

1302 |

1303 |

1304 |

1305 |

1306 |

1307 |

1308 |

1309 |

1310 |

1311 |

1312 |

1313 |

1314 |

1315 |

1316 |

1317 |

1318 |

1401 |

1402 |

1403 |

1404 |

1405 |

1406 |

1407 |

1408 |

1409 |

1410 |

1411 |

1412 |

1413 |

1414 |

1415 |

1416 |

1417 |

1418 |

1501 |

1502 |

1503 |

1504 |

1505 |

1506 |

1507 |

1508 |

1509 |

1510 |

1511 |

1512 |

1513 |

1514 |

1515 |

1516 |

1517 |

1518 |

1601 |

1602 |

1603 |

1604 |

1605 |

1606 |

1607 |

1608 |

1609 |

1610 |

1611 |

1612 |

1613 |

1614 |

1615 |

1616 |

1617 |

1618 |

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-10-2016 12:00 PM

Lots of details.

Try to narrow down your problem, and perhaps with a simpler example.

Attach sample input and desired outcome.

Try to narrow down your problem, and perhaps with a simpler example.

Attach sample input and desired outcome.

Data never sleeps