Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/student-rubeena/chakravyuhsolution
https://github.com/student-rubeena/chakravyuhsolution
Last synced: about 8 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/student-rubeena/chakravyuhsolution
- Owner: student-rubeena
- Created: 2024-07-23T16:55:50.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-23T17:01:51.000Z (4 months ago)
- Last Synced: 2024-07-24T17:17:04.215Z (4 months ago)
- Language: Java
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chakravyuhsolution
Algorithm Design
1. Initialization:
• p: Initial power of Abhimanyu.
• k: Array of length 11 representing the power of enemies in each circle.
• a: Number of skips available.
• b: Number of recharges available.
• Initialize circle = 0 (Abhimanyu starts at the innermost circle).2. Simulate Movement Through Circles:
• Loop through each circle from innermost to outermost.
• At each circle, perform the following:
Check for Skip: If skips are available (a > 0), skip this circle and decrement a.
Check for Recharge: If recharges are available (b > 0), recharge and increment p.
Battle:
If p < k[circle], Abhimanyu loses.
If p >= k[circle], decrement p by k[circle] to simulate power loss in battle.
Regeneration Check: For circles 3 and 7, if the enemy regenerates, reduce p by half of k[2] or k[6] (index is 0-based).
3. Victory Condition: If Abhimanyu survives all circles, return "Can cross Chakravyuh". If Abhimanyu loses at any circle, return "Cannot cross Chakravyuh".