Download benchmarks/quixbugs/java/TO_BASE.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 768 Bytes
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/TO_BASE.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/quixbugs/java/TO_BASE.java
-
curl -L -o TO_BASE.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/TO_BASE.java
768 Bytes
| import java.util.*; | |
| /** | |
| * Integer Base Conversion | |
| * base-conversion | |
| * | |
| * | |
| * Input: | |
| * num: A base-10 integer to convert. | |
| * b: The target base to convert it to. | |
| * | |
| * Precondition: | |
| * num > 0, 2 <= b <= 36. | |
| * | |
| * Output: | |
| * A string representing the value of num in base b. | |
| * | |
| * Example: | |
| * >>> to_base(31, 16) | |
| * '1F' | |
| * | |
| * @author derricklin | |
| */ | |
| public class TO_BASE { | |
| public static String to_base(int num, int b) { | |
| String result = ""; | |
| String alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
| int i; | |
| while (num > 0) { | |
| i = num % b; | |
| num = num / b; // floor division? | |
| result = String.valueOf(alphabet.charAt(i))+result; | |
| } | |
| return result; | |
| } | |
| } | |