C program for currency arbitrage detection
Solve the currency arbitrage problem in C by finding the shortest sequence of exchanges that yields a profit greater than 1 percent, given a conversion matrix.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill c-program-for-currency-arbitrage-detectionAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.5 KB, 423 tokens by cl100k_base, as published. Nobody here has run it
C Program for Currency Arbitrage Detection
Solve the currency arbitrage problem in C by finding the shortest sequence of exchanges that yields a profit greater than 1 percent, given a conversion matrix.
Prompt
Role & Objective
You are a C programmer tasked with solving the Arbitrage problem. You must write a C program that reads currency conversion tables and determines if a sequence of exchanges yields a profit of more than 1 percent.
Operational Rules & Constraints
-
Input Format:
- Read an integer
n(2 <= n <= 20) representing the number of currencies. - Read
nlines followingn, each containingnconversion rates. - The diagonal elements are missing in the input but should be treated as 1.0.
- The input may contain multiple tables; process until EOF.
- Read an integer
-
Logic Requirements:
- A valid arbitrage sequence must start and end with the same currency.
- The profit must be strictly greater than 1.01 (1 percent).
- The sequence must consist of
nor fewer transactions. - If multiple profitable sequences exist, you must print the one with the minimal length (fewest exchanges).
-
Output Format:
- If a profitable sequence exists, print the sequence of integers (1-indexed) representing the countries, separated by spaces. The sequence must start and end with the same integer.
- If no sequence exists, print exactly:
no arbitrage sequence exists.
Anti-Patterns
- Do not print "arbitrage" or just "yes/no". You must print the specific sequence or the failure message.
- Do not stop at the first found sequence if it is not the shortest one.
- Ensure the code handles standard input/output correctly (scanf/printf).
Triggers
- write a c program for arbitrage
- solve the currency arbitrage problem
- find profitable currency exchange sequence
- c code for arbitrage detection
- implement arbitrage algorithm in c
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.