Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Write the same algorithm in AutoHotKey as shown in this Java implementation.
public class EqualRisesFalls { public static void main(String[] args) { final int limit1 = 200; final int limit2 = 10000000; System.out.printf("The first %d numbers in the sequence are:\n", limit1); int n = 0; for (int count = 0; count < limit2; ) { if (equalRises...
limit1 := 200, limit2 := 10000000 count := 0, result1 := result1 := "" loop{ num := A_Index if !Rise_Fall(num) continue count++ if (count <= limit1) result1 .= num . (Mod(count, 20) ? "`t" : "`n") if (count = limit2){ result2 := num break } if !mod(count, 1000...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
public class SelfDescribingNumbers{ public static boolean isSelfDescribing(int a){ String s = Integer.toString(a); for(int i = 0; i < s.length(); i++){ String s0 = s.charAt(i) + ""; int b = Integer.parseInt(s0); int count = 0; for(int j = 0; j < s.len...
#NoEnv SetBatchlines -1 ListLines Off Process, Priority,, high MsgBox % 2020 ": " IsSelfDescribing(2020) "`n" 1337 ": " IsSelfDescribing(1337) "`n" 1210 ": " IsSelfDescribing(1210) Loop 100000000 If IsSelfDescribing(A_Index) list .= A_Index "`n" MsgBox % "Self-describing numbers < 100000000 :`n" . list Coun...
Please provide an equivalent version of this Java code in AutoHotKey.
import java.io.*; import java.util.*; public class ChangeableWords { public static void main(String[] args) { try { final String fileName = "unixdict.txt"; List<String> dictionary = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader(fileNam...
FileRead, db, % A_Desktop "\unixdict.txt" oWord := [], Found := [] for i, word in StrSplit(db, "`n", "`r") if (StrLen(word) > 11) oWord[word] := true for word1 in oWord for word2 in oWord if Changeable(word1, word2) && !Found[word2] found[word1] := true, result .= word1 . "`t<-> " w...
Write a version of this Java function in AutoHotKey with identical behavior.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.List; import java.util.Objects; public class DecisionTables { private static class Pair<T, U> { private final T t; private final U u; public static <T, U> Pair<T, U> of(T t, U u) {...
Conditions = ( Printer does not print |Y|Y|Y|Y|N|N|N|N| A red light is flashing |Y|Y|N|N|Y|Y|N|N| Printer is unrecognized |Y|N|Y|N|Y|N|Y|N| ) Actions= ( Check the power cable | | |x| | | | | | Check the printer-computer cable |x| |x| | | | | | Ensure printer software is installed |x| |x| |x| |x| | Check/replac...
Port the following code from Java to AutoHotKey with equivalent syntax and logic.
size(1000,1000); textSize(50); for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ noFill(); square(i*100,j*100,100); fill(#000000); if((i+j)%2==0){ text("1",i*100+50,j*100+50); } else{ text("0",i*100+50,j*100+50); } } }
for i, v in [8, 9] result .= "Matrix Size: " v "*" v "`n" matrix2txt(mosaicMatrix(v)) "`n" MsgBox % result return mosaicMatrix(size){ M := [] loop % size { row := A_Index loop % size M[row, A_Index] := (Toggle:=!Toggle) ? 1 : 0 , toggle := (A_Index = size && size/2 ...
Keep all operations the same but rewrite the snippet in AutoHotKey.
public static double arcLength(double r, double a1, double a2){ return (360.0 - Math.abs(a2-a1))*Math.PI/180.0 * r; }
MsgBox % result := arcLength(10, 10, 120) return arcLength(radius, angle1, angle2){ return (360 - Abs(angle2-angle1)) * (π := 3.141592653589793) * radius / 180 }
Write a version of this Java function in AutoHotKey with identical behavior.
import java.util.List; import java.util.Arrays; import java.util.Collections; public class RotateLeft { public static void main(String[] args) { List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); System.out.println("original: " + list); Collections.rotate(list, -3); Syst...
Shift_list_elements(Arr, dir, n){ nums := Arr.Clone() loop % n if InStr(dir, "l") nums.Push(nums.RemoveAt(1)) else nums.InsertAt(1, nums.RemoveAt(nums.count())) return nums }
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
class Vector{ private double x, y, z; public Vector(double x1,double y1,double z1){ x = x1; y = y1; z = z1; } void printVector(int x,int y){ text("( " + this.x + " ) \u00ee + ( " + this.y + " ) + \u0135 ( " + this.z + ") \u006b\u0302",x,y); } public double norm() { return Math.sq...
v1 := [5,-6,4] v2 := [8,5,-30] a := getAngle(v1, v2) cp := crossProduct(v1, v2) ncp := normalize(cp) np := aRotate(v1, ncp, a) for i, v in np result .= v ", " MsgBox % result := "[" Trim(result, ", ") "]" return norm(v) { return Sqrt(v[1]*v[1] + v[2]*v[2] + v[3]*v[3]) } normalize(v) { length := norm(v) ...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
package example.diagdiag; public class Program { public static void main(String[] args) { DiagonalDiagonalMatrix A = new DiagonalDiagonalMatrix(7); System.out.println(A); } } class DiagonalDiagonalMatrix { final int n; private double[][] a = null; public Matrix(int n) { ...
for i, v in [8, 9] result .= "Matrix Size: " v "*" v "`n" matrix2txt(diagonalMatrix(v)) "`n" MsgBox % result return diagonalMatrix(size){ M := [] loop % size { row := A_Index loop % size M[row, A_Index] := (row = A_Index || row = size-A_Index+1) ? 1 : 0 } return M } ma...
Produce a functionally identical AutoHotKey code for the snippet given in Java.
import java.util.List; public class App { private static String lcs(List<String> a) { var le = a.size(); if (le == 0) { return ""; } if (le == 1) { return a.get(0); } var le0 = a.get(0).length(); var minLen = le0; for (int i = ...
Longest_common_suffix(data){ for num, v in StrSplit(data.1) for i, word in data if (SubStr(word, 1-num) <> SubStr(data.1, 1-num)) return num=1 ? "" : SubStr(word, 2-num) return SubStr(word, 1-num) }
Change the following Java code into AutoHotKey without altering its purpose.
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } }
MsgBox, Hello World!
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } }
MsgBox, Hello World!
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the Java version.
package rosettacode.heredoc; public class MainApp { public static void main(String[] args) { String hereDoc = """ This is a multiline string. It includes all of this text, but on separate lines in the code. """; System.out.println(hereDoc); } }
MyVar = "This is the text inside MyVar" MyVariable = ( Note that whitespace is preserved As well as newlines. The LTrim option can be present to remove left whitespace. Variable references such as %MyVar% are expanded. ) MsgBox % MyVariable
Translate the given Java code snippet into AutoHotKey without altering its behavior.
package rosettacode.heredoc; public class MainApp { public static void main(String[] args) { String hereDoc = """ This is a multiline string. It includes all of this text, but on separate lines in the code. """; System.out.println(hereDoc); } }
MyVar = "This is the text inside MyVar" MyVariable = ( Note that whitespace is preserved As well as newlines. The LTrim option can be present to remove left whitespace. Variable references such as %MyVar% are expanded. ) MsgBox % MyVariable
Port the provided Java code into AutoHotKey while preserving the original functionality.
import java.util.Scanner; public class Pigdice { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int players = 0; while(true) { System.out.println("Hello, welcome to Pig Dice the game! How many players? "); if(scan.hasNextInt()) { int nextInt = scan...
#NoEnv SetBatchLines, -1 #SingleInstance, Force #Include Pig_the_dice_game_Optimal_Play.ahkl  Play:=10000  Wins0:=Wins1:=0 Player0(TurnSum, SumMe, SumOpp) { Return practical(TurnSum, SumMe, SumOpp)  } Player1(TurnSum, SumMe, SumOpp) { Return optimal(TurnSum, SumMe, SumOpp)  } Loop, % Play { CurrentPlayer := 0  S...
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
import java.util.Scanner; public class Pigdice { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int players = 0; while(true) { System.out.println("Hello, welcome to Pig Dice the game! How many players? "); if(scan.hasNextInt()) { int nextInt = scan...
#NoEnv SetBatchLines, -1 #SingleInstance, Force #Include Pig_the_dice_game_Optimal_Play.ahkl  Play:=10000  Wins0:=Wins1:=0 Player0(TurnSum, SumMe, SumOpp) { Return practical(TurnSum, SumMe, SumOpp)  } Player1(TurnSum, SumMe, SumOpp) { Return optimal(TurnSum, SumMe, SumOpp)  } Loop, % Play { CurrentPlayer := 0  S...
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the Java version.
import java.io.*; import java.util.*; public class MazeSolver { private static String[] readLines (InputStream f) throws IOException { BufferedReader r = new BufferedReader (new InputStreamReader (f, "US-ASCII")); ArrayList<String> lines = new ArrayList<String>(); Strin...
Width := 10, Height := 10 SleepTime := 0 gosub, Startup Gui, +AlwaysOnTop Gui, font, s12, consolas Gui, add, edit, vEditGrid x10, % maze Gui, add, button, xs gStartup Default, Generate maze Gui, add, button, x+10 gSolve, Solve Gui, show,, maze GuiControl,, EditGrid, % maze return ^Esc:: GuiE...
Can you help me rewrite this code in AutoHotKey instead of Java, keeping it the same logically?
module MultiplyExample { static <Value extends Number> Value multiply(Value n1, Value n2) { return n1 * n2; } void run() { (Int i1, Int i2) = (7, 3); Int i3 = multiply(i1, i2); (Double d1, Double d2) = (2.7182818, 3.1415); Double d3 = multiply...
MsgBox % multiply(10,2) multiply(multiplicand, multiplier) { Return (multiplicand * multiplier) }
Port the following code from Java to AutoHotKey with equivalent syntax and logic.
public class JacobiSymbol { public static void main(String[] args) { int max = 30; System.out.printf("n\\k "); for ( int k = 1 ; k <= max ; k++ ) { System.out.printf("%2d ", k); } System.out.printf("%n"); for ( int n = 1 ; n <= max ; n += 2 ) { ...
result := "n/k|" loop 20 result .= SubStr(" " A_Index, -1) " " l := StrLen(result) result .= "`n" loop % l result .= "-" result .= "`n" loop 21 { if !Mod(n := A_Index, 2) continue result .= SubStr(" " n, -1) " |" loop 20 result .= SubStr(" " jacobi(a := A_Index, n), -1) " " ...
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
public class JacobiSymbol { public static void main(String[] args) { int max = 30; System.out.printf("n\\k "); for ( int k = 1 ; k <= max ; k++ ) { System.out.printf("%2d ", k); } System.out.printf("%n"); for ( int n = 1 ; n <= max ; n += 2 ) { ...
result := "n/k|" loop 20 result .= SubStr(" " A_Index, -1) " " l := StrLen(result) result .= "`n" loop % l result .= "-" result .= "`n" loop 21 { if !Mod(n := A_Index, 2) continue result .= SubStr(" " n, -1) " |" loop 20 result .= SubStr(" " jacobi(a := A_Index, n), -1) " " ...
Generate a AutoHotKey translation of this Java snippet without changing its computational steps.
private static final Random rng = new Random(); void sattoloCycle(Object[] items) { for (int i = items.length-1; i > 0; i--) { int j = rng.nextInt(i); Object tmp = items[i]; items[i] = items[j]; items[j] = tmp; } }
loop 3 { testCases:= [[] ,[10] ,[10, 20] ,[10, 20, 30] ,[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]] for n, items in testCases { Sattolo_cycle(items) res := "[" for m, v in items res .= v ", " r...
Change the following Java code into AutoHotKey without altering its purpose.
private static final Random rng = new Random(); void sattoloCycle(Object[] items) { for (int i = items.length-1; i > 0; i--) { int j = rng.nextInt(i); Object tmp = items[i]; items[i] = items[j]; items[j] = tmp; } }
loop 3 { testCases:= [[] ,[10] ,[10, 20] ,[10, 20, 30] ,[11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]] for n, items in testCases { Sattolo_cycle(items) res := "[" for m, v in items res .= v ", " r...
Change the programming language of this snippet from Java to AutoHotKey without modifying what it does.
public class Factorion { public static void main(String [] args){ System.out.println("Base 9:"); for(int i = 1; i <= 1499999; i++){ String iStri = String.valueOf(i); int multiplied = operate(iStri,9); if(multiplied == i){ System.out.print(i + "\t")...
fact:=[] fact[0] := 1 while (A_Index < 12) fact[A_Index] := fact[A_Index-1] * A_Index b := 9 while (b <= 12) { res .= "base " b " factorions: `t" while (A_Index < 1500000){ sum := 0 j := A_Index while (j > 0){ d := Mod(j, b) sum += fact[d] j /= b } if (sum = A_Index) res .= A_Index " " } b...
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
public class Factorion { public static void main(String [] args){ System.out.println("Base 9:"); for(int i = 1; i <= 1499999; i++){ String iStri = String.valueOf(i); int multiplied = operate(iStri,9); if(multiplied == i){ System.out.print(i + "\t")...
fact:=[] fact[0] := 1 while (A_Index < 12) fact[A_Index] := fact[A_Index-1] * A_Index b := 9 while (b <= 12) { res .= "base " b " factorions: `t" while (A_Index < 1500000){ sum := 0 j := A_Index while (j > 0){ d := Mod(j, b) sum += fact[d] j /= b } if (sum = A_Index) res .= A_Index " " } b...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
import java.util.*; public class SortComp1 { public static void main(String[] args) { List<String> items = Arrays.asList("violet", "red", "green", "indigo", "blue", "yellow", "orange"); List<String> sortedItems = new ArrayList<>(); Comparator<String> interactiveCompare = new Comparator<Stri...
data := ["Violet", "Red", "Green", "Indigo", "Blue", "Yellow", "Orange"] result := [], num := 0, Questions :="" for i, Color1 in data{ found :=false if !result.count(){ result.Push(Color1) continue } for j, Color2 in result { if (color1 = color2) continue ...
Preserve the algorithm and functionality while converting the code from Java to AutoHotKey.
public class BeadSort { public static void main(String[] args) { BeadSort now=new BeadSort(); int[] arr=new int[(int)(Math.random()*11)+5]; for(int i=0;i<arr.length;i++) arr[i]=(int)(Math.random()*10); System.out.print("Unsorted: "); now.display1D(arr); int[] sort=now.beadSort(arr); System.out.pr...
BeadSort(data){ Pole:=[] , TempObj:=[], Result:=[] for, i, v in data { Row := i loop, % v MaxPole := MaxPole>A_Index?MaxPole:A_Index , Pole[A_Index, row] := 1 } for i , obj in Pole { TempVar:=0 , c := A_Index for n, v in obj TempVar += v loop, % TempVar TempObj[c, A_Index] := 1 } loop, % Row ...
Can you help me rewrite this code in AutoHotKey instead of Java, keeping it the same logically?
package keybord.macro.demo; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; class KeyboardMacroDemo { public static void main( String [] args ) { final JFrame frame = new JFrame(); String directions = "<html><b>Ctrl-S...
Loop, 200   { TrayTip, counting, %A_Index% press alt-p to pause Sleep, 1000 } !p::   pauseMe() Return !r::   resume() Return pauseMe() { MsgBox, pausing`, press alt-r to resume Pause } resume() { TrayTip, resume, resuming, 2 Pause, off }
Port the provided Java code into AutoHotKey while preserving the original functionality.
public class TauFunction { private static long divisorCount(long n) { long total = 1; for (; (n & 1) == 0; n >>= 1) { ++total; } for (long p = 3; p * p <= n; p += 2) { long count = 1; for (; n % p == 0; n /= p) { +...
loop 100 result .= SubStr(" " Tau(A_Index), -3) . (Mod(A_Index, 10) ? " " : "`n") MsgBox % result return Tau(n){ return StrSplit(Factors(n), ",").Count() } Factors(n) { Loop, % floor(sqrt(n)) v := A_Index = 1 ? 1 "," n : mod(n,A_Index) ? v : v "," A_Index "," n//A_Index Sort, v, N U D, Re...
Transform the following Java implementation into AutoHotKey, maintaining the same output and logic.
public class TauFunction { private static long divisorCount(long n) { long total = 1; for (; (n & 1) == 0; n >>= 1) { ++total; } for (long p = 3; p * p <= n; p += 2) { long count = 1; for (; n % p == 0; n /= p) { +...
loop 100 result .= SubStr(" " Tau(A_Index), -3) . (Mod(A_Index, 10) ? " " : "`n") MsgBox % result return Tau(n){ return StrSplit(Factors(n), ",").Count() } Factors(n) { Loop, % floor(sqrt(n)) v := A_Index = 1 ? 1 "," n : mod(n,A_Index) ? v : v "," A_Index "," n//A_Index Sort, v, N U D, Re...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
public class MöbiusFunction { public static void main(String[] args) { System.out.printf("First 199 terms of the möbius function are as follows:%n "); for ( int n = 1 ; n < 200 ; n++ ) { System.out.printf("%2d ", möbiusFunction(n)); if ( (n+1) % 20 == 0 ) { ...
loop 100 result .= SubStr(" " Möbius(A_Index), -1) . (Mod(A_Index, 10) ? " " : "`n") MsgBox, 262144, , % result return Möbius(n){ if n=1 return 1 x := prime_factors(n) c := x.Count() sq := [] for i, v in x if sq[v] return 0 else sq[v] := 1 r...
Port the provided Java code into AutoHotKey while preserving the original functionality.
public class MertensFunction { public static void main(String[] args) { System.out.printf("First 199 terms of the merten function are as follows:%n "); for ( int n = 1 ; n < 200 ; n++ ) { System.out.printf("%2d ", mertenFunction(n)); if ( (n+1) % 20 == 0 ) { ...
result := "first 100 terms:`n" loop 100 result .= SubStr(" " Mertens(A_Index), -1) . (Mod(A_Index, 10) ? " " : "`n") eqZero := crZero := 0, preced:=1 loop 1000 { if !(x := Mertens(A_Index)) eqZero++, crZero += preced<>0 ? 1 : 0 preced := x } result .= "`nfirst 1000 terms:" MsgBox, 262144, , % res...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
public enum Pip { Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace }
suits := ["♠", "♦", "♥", "♣"] values := [2,3,4,5,6,7,8,9,10,"J","Q","K","A"] Gui, font, s14 Gui, add, button, w190 gNewDeck, New Deck Gui, add, button, x+10 wp gShuffle, Shuffle Gui, add, button, x+10 wp gDeal, Deal Gui, add, text, xs w600 , Current Deck: Gui, add, Edit, xs wp r4 vDeck Gui, add, text, xs , Hands: Gui, ...
Generate a AutoHotKey translation of this Java snippet without changing its computational steps.
import java.util.ArrayList; import java.util.List; public class PerfectTotientNumbers { public static void main(String[] args) { computePhi(); int n = 20; System.out.printf("The first %d perfect totient numbers:%n%s%n", n, perfectTotient(n)); } private static final List<Intege...
MsgBox, 262144, , % result := perfect_totient(20) perfect_totient(n){ count := sum := tot := 0, str:= "", m := 1 while (count < n) { tot := m, sum := 0 while (tot != 1) { tot := totient(tot) sum += tot } if (sum = m) { str .= m ", " ...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
import java.util.ArrayList; import java.util.List; public class PerfectTotientNumbers { public static void main(String[] args) { computePhi(); int n = 20; System.out.printf("The first %d perfect totient numbers:%n%s%n", n, perfectTotient(n)); } private static final List<Intege...
MsgBox, 262144, , % result := perfect_totient(20) perfect_totient(n){ count := sum := tot := 0, str:= "", m := 1 while (count < n) { tot := m, sum := 0 while (tot != 1) { tot := totient(tot) sum += tot } if (sum = m) { str .= m ", " ...
Keep all operations the same but rewrite the snippet in AutoHotKey.
import java.util.Arrays; public class TwoSum { public static void main(String[] args) { long sum = 21; int[] arr = {0, 2, 11, 19, 90}; System.out.println(Arrays.toString(twoSum(arr, sum))); } public static int[] twoSum(int[] a, long target) { int i = 0, j = a.length - 1; ...
TwoSum(a, target){ i := 1, j := a.MaxIndex() while(i < j){ if (a[i] + a[j] = target) return i ", " j else if (a[i] + a[j] < target) i++ else if (a[i] + a[j] > target) j-- } return "not found" }
Ensure the translated AutoHotKey code behaves exactly like the original Java snippet.
import java.util.Arrays; public class TwoSum { public static void main(String[] args) { long sum = 21; int[] arr = {0, 2, 11, 19, 90}; System.out.println(Arrays.toString(twoSum(arr, sum))); } public static int[] twoSum(int[] a, long target) { int i = 0, j = a.length - 1; ...
TwoSum(a, target){ i := 1, j := a.MaxIndex() while(i < j){ if (a[i] + a[j] = target) return i ", " j else if (a[i] + a[j] < target) i++ else if (a[i] + a[j] > target) j-- } return "not found" }
Translate the given Java code snippet into AutoHotKey without altering its behavior.
import java.util.*; public class CocktailSort { public static void main(String[] args) { Integer[] array = new Integer[]{ 5, 1, -6, 12, 3, 13, 2, 4, 0, 15 }; System.out.println("before: " + Arrays.toString(array)); cocktailSort(array); System.out.println("after: " + Arrays.toString(...
cocktailShakerSort(A){ beginIdx := 1 endIdx := A.Count() - 1 while (beginIdx <= endIdx) { newBeginIdx := endIdx newEndIdx := beginIdx ii := beginIdx while (ii <= endIdx) { if (A[ii] > A[ii + 1]) { tempVal := A[ii], A[ii] := A[ii+1], A[ii+1] := temp...
Please provide an equivalent version of this Java code in AutoHotKey.
public class Tau { private static long divisorCount(long n) { long total = 1; for (; (n & 1) == 0; n >>= 1) { ++total; } for (long p = 3; p * p <= n; p += 2) { long count = 1; for (; n % p == 0; n /= p) { ++count; ...
n := c:= 0 while (c<100) if isTau(++n) c++, result .= SubStr(" " n, -3) . (Mod(c, 10) ? " " : "`n") MsgBox % result return isTau(num){ return (num/(n := StrSplit(Factors(num), ",").Count()) = floor(num/n)) } Factors(n) { Loop, % floor(sqrt(n)) v := A_Index = 1 ? 1 "," n : mod(n,A_Index) ...
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class DeepCopy { public static void main(String[] args) { Person p1 = new Person("Clark", "Kent", new Address("1 World Center"...
DeepCopy(Array, Objs=0) { If !Objs Objs := Object() Obj := Array.Clone()  Objs[&Array] := Obj  For Key, Val in Obj If (IsObject(Val))  Obj[Key] := Objs[&Val]  ? Objs[&Val]  : DeepCopy(Val,Objs)  Return Obj }
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the Java version.
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class DeepCopy { public static void main(String[] args) { Person p1 = new Person("Clark", "Kent", new Address("1 World Center"...
DeepCopy(Array, Objs=0) { If !Objs Objs := Object() Obj := Array.Clone()  Objs[&Array] := Obj  For Key, Val in Obj If (IsObject(Val))  Obj[Key] := Objs[&Val]  ? Objs[&Val]  : DeepCopy(Val,Objs)  Return Obj }
Rewrite the snippet below in AutoHotKey so it works the same as the original Java code.
public class Frobenius { public static void main(String[] args) { final int limit = 1000000; System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit); PrimeGenerator primeGen = new PrimeGenerator(1000, 100000); int prime1 = primeGen.nextPrime(); f...
n := 0, i := 1, pn := 2 loop { if isprime(i+=2) { if ((f := pn*i - pn - i) > 10000) break result .= SubStr(" " f, -3) . (Mod(++n, 5) ? "`t" : "`n") pn := i } } MsgBox % result return isPrime(n, p=1) { if (n < 2) return false if !Mod(n, 2) return (n ...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
public class Frobenius { public static void main(String[] args) { final int limit = 1000000; System.out.printf("Frobenius numbers less than %d (asterisk marks primes):\n", limit); PrimeGenerator primeGen = new PrimeGenerator(1000, 100000); int prime1 = primeGen.nextPrime(); f...
n := 0, i := 1, pn := 2 loop { if isprime(i+=2) { if ((f := pn*i - pn - i) > 10000) break result .= SubStr(" " f, -3) . (Mod(++n, 5) ? "`t" : "`n") pn := i } } MsgBox % result return isPrime(n, p=1) { if (n < 2) return false if !Mod(n, 2) return (n ...
Generate an equivalent AutoHotKey version of this Java code.
import java.util.List; import java.util.ArrayList; import java.util.Arrays; public class PermutationSort { public static void main(String[] args) { int[] a={3,2,1,8,9,4,6}; System.out.println("Unsorted: " + Arrays.toString(a)); a=pSort(a); System.out.println("Sorted: " + Arrays.toString(a)); } public stat...
MsgBox % PermSort("") MsgBox % PermSort("xxx") MsgBox % PermSort("3,2,1") MsgBox % PermSort("dog,000000,xx,cat,pile,abcde,1,cat") PermSort(var) {   Local i, sorted StringSplit a, var, `,   v0 := a0   Loop %v0% v%A_Index% := A_Index ...
Change the following Java code into AutoHotKey without altering its purpose.
import java.util.Scanner; public class LastSunday { static final String[] months={"January","February","March","April","May","June","July","August","September","October","November","December"}; public static int[] findLastSunday(int year) { boolean isLeap = isLeapYear(year); int[] days={31,isLeap?29:28,31...
InputBox, Year, , Enter a year., , 300, 135 Date := Year . "0101" while SubStr(Date, 1, 4) = Year { FormatTime, WD, % Date, WDay if (WD = 1) MM := LTrim(SubStr(Date, 5, 2), "0"), Day%MM% := SubStr(Date, 7, 2) Date += 1, Days } Gui, Font, S10, Courier New Gui, Add, Text, , % "Last Sundays of " Year...
Write a version of this Java function in AutoHotKey with identical behavior.
import java.util.Scanner; public class LastSunday { static final String[] months={"January","February","March","April","May","June","July","August","September","October","November","December"}; public static int[] findLastSunday(int year) { boolean isLeap = isLeapYear(year); int[] days={31,isLeap?29:28,31...
InputBox, Year, , Enter a year., , 300, 135 Date := Year . "0101" while SubStr(Date, 1, 4) = Year { FormatTime, WD, % Date, WDay if (WD = 1) MM := LTrim(SubStr(Date, 5, 2), "0"), Day%MM% := SubStr(Date, 7, 2) Date += 1, Days } Gui, Font, S10, Courier New Gui, Add, Text, , % "Last Sundays of " Year...
Change the programming language of this snippet from Java to AutoHotKey without modifying what it does.
import java.io.*; import java.util.*; public class Teacup { public static void main(String[] args) { if (args.length != 1) { System.err.println("usage: java Teacup dictionary"); System.exit(1); } try { findTeacupWords(loadDictionary(args[0])); } c...
Teacup_rim_text(wList){ oWord := [], oRes := [], n := 0 for i, w in StrSplit(wList, "`n", "`r") if StrLen(w) >= 3 oWord[StrLen(w), w] := true for l, obj in oWord { for w, bool in obj { loop % l if oWord[l, rotate(w)] { ...
Write a version of this Java function in AutoHotKey with identical behavior.
package org.rosettacode.java; import java.util.Arrays; import java.util.stream.IntStream; public class HeapsAlgorithm { public static void main(String[] args) { Object[] array = IntStream.range(0, 4) .boxed() .toArray(); HeapsAlgorithm algorithm = new HeapsAlgorithm(); algorithm.recursive(array); Sy...
Permutations_By_Swapping(str, list:=""){ ch := SubStr(str, 1, 1) for i, line in StrSplit(list, "`n") loop % StrLen(line) + 1 Newlist .= RegExReplace(line, mod(i,2) ? "(?=.{" A_Index-1 "}$)" : "^.{" A_Index-1 "}\K", ch) "`n" list := Newlist ? Trim(Newlist, "`n") : ch if !str := SubStr(str...
Preserve the algorithm and functionality while converting the code from Java to AutoHotKey.
import java.util.Arrays; public class OEIS_A005179 { static int count_divisors(int n) { int count = 0; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { if (i == n / i) count++; else count += 2; } ...
max := 15 seq := [], n := 0 while (n < max) if ((k := countDivisors(A_Index)) <= max) && !seq[k] seq[k] := A_Index, n++ for i, v in seq res .= v ", " MsgBox % "The first " . max . " terms of the sequence are:`n" Trim(res, ", ") return countDivisors(n){ while (A_Index**2 <= n) if !Mod(n, A_Index) count += A_I...
Write a version of this Java function in AutoHotKey with identical behavior.
public class Sparkline { String bars="▁▂▃▄▅▆▇█"; public static void main(String[] args) { Sparkline now=new Sparkline(); float[] arr={1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1}; now.display1D(arr); System.out.println(now.getSparkline(arr)); float[] arr1={1.5f, 0.5f, 3.5f, 2.5f, 5.5f, 4.5f, 7.5f, 6.5f}; ...
SetFormat, FloatFast, 0.1 strings := ["1 2 3 4 5 6 7 8 7 6 5 4 3 2 1" , "1.5, 0.5 3.5, 2.5 5.5, 4.5 7.5, 6.5"] Loop, % strings.MaxIndex() { SL := Sparklines(strings[A_Index]) MsgBox, % "Min: " SL["Min"] ", Max: " SL["Max"] ", Range: " SL["Rng"] "`n" SL["Chars"] } Sparklines(s) { s := RegexReplac...
Translate the given Java code snippet into AutoHotKey without altering its behavior.
import java.util.*; public class LIS { public static <E extends Comparable<? super E>> List<E> lis(List<E> n) { List<Node<E>> pileTops = new ArrayList<Node<E>>(); for (E x : n) { Node<E> node = new Node<E>(); node.value = x; int i = Collections.binarySearch(pileTops, ...
Lists := [[3,2,6,4,5,1], [0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15]] for k, v in Lists { D := LIS(v) MsgBox, % D[D.I].seq } LIS(L) { D := [] for i, v in L { D[i, "Length"] := 1, D[i, "Seq"] := v, D[i, "Val"] := v Loop, % i - 1 { if(D[A_Index].Val < v && D[A_Index].Length + 1 > D[i].Length) { D[i].Length :...
Preserve the algorithm and functionality while converting the code from Java to AutoHotKey.
import java.io.*; import java.util.*; public class NeighbourWords { public static void main(String[] args) { try { int minLength = 9; List<String> words = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new FileReader("unixdict.txt"))) { ...
FileRead, wList, % A_Desktop "\unixdict.txt" for word in neighbour(wList) result .= word (Mod(A_Index, 6) ? "`t" : "`n") MsgBox, 262144, , % result return neighbour(wList){ words := [], wordExist := [], oRes := [] for i, w in StrSplit(wList, "`n", "`r") { if (StrLen(w) < 9) continu...
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
public static void main(String... args){ HashMap<String, Integer> vars = new HashMap<String, Integer>(); vars.put("Variable name", 3); vars.put("Next variable name", 5); Scanner sc = new Scanner(System.in); String str = sc.next(); vars.put(str,...
InputBox, Dynamic, Variable Name %Dynamic% = hello ListVars MsgBox % %dynamic%  
Generate an equivalent AutoHotKey version of this Java code.
import java.util.Arrays; import java.util.BitSet; import org.apache.commons.lang3.ArrayUtils; public class OrderDisjointItems { public static void main(String[] args) { final String[][] MNs = {{"the cat sat on the mat", "mat cat"}, {"the cat sat on the mat", "cat mat"}, {"A B C A B C A B C...
Data := [ {M: "the cat sat on the mat", N: "mat cat"} , {M: "the cat sat on the mat", N: "cat mat"} , {M: "A B C A B C A B C", N: "C A C A"} , {M: "A B C A B D A B E", N: "E A D A"} , {M: "A B", N: "B"} , {M: "A B", N: "B A"} , {M: "A B B A", N: "B A"} ] for Key, Val in Data Output .= Val.M " :: " Val.N " -> " ...
Preserve the algorithm and functionality while converting the code from Java to AutoHotKey.
import java.util.Arrays; import java.util.Comparator; public class RJSortStability { public static void main(String[] args) { String[] cityList = { "UK London", "US New York", "US Birmingham", "UK Birmingham", }; String[] cn = cityList.clone(); System.out.println("\nBefore sort:"); for (String ...
Table = ( UK, London US, New York US, Birmingham UK, Birmingham ) Gui, Margin, 6 Gui, -MinimizeBox Gui, Add, ListView, r5 w260 Grid, Orig.Position|Country|City Loop, Parse, Table, `n, `r { StringSplit, out, A_LoopField, `,, %A_Space% LV_Add("", A_Index, out1, out2) } LV_ModifyCol(1, "77 Center") LV_ModifyCol(2...
Write the same code in AutoHotKey as shown below in Java.
import java.io.File; import java.lang.reflect.Method; import java.net.URI; import java.util.Arrays; import javax.tools.JavaCompiler; import javax.tools.SimpleJavaFileObject; import javax.tools.ToolProvider; public class Eval { private static final String CLASS_NAME = "TempPleaseDeleteMe"; private static class...
msgbox % first := evalWithX("x + 4", 5) msgbox % second := evalWithX("x + 4", 6) msgbox % second - first return evalWithX(expression, xvalue) { global script script = ( expression(){ x = %xvalue%   return %expression% } ) renameFunction("expression", "")   gosub load  exp := "expression" return %exp%() ...
Generate a AutoHotKey translation of this Java snippet without changing its computational steps.
import java.io.File; import java.lang.reflect.Method; import java.net.URI; import java.util.Arrays; import javax.tools.JavaCompiler; import javax.tools.SimpleJavaFileObject; import javax.tools.ToolProvider; public class Eval { private static final String CLASS_NAME = "TempPleaseDeleteMe"; private static class...
msgbox % first := evalWithX("x + 4", 5) msgbox % second := evalWithX("x + 4", 6) msgbox % second - first return evalWithX(expression, xvalue) { global script script = ( expression(){ x = %xvalue%   return %expression% } ) renameFunction("expression", "")   gosub load  exp := "expression" return %exp%() ...
Write a version of this Java function in AutoHotKey with identical behavior.
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.tools.FileObject; import javax.tools.Fo...
msgbox % eval("3 + 4") msgbox % eval("4 + 4") return eval(expression) { global script script = ( expression(){ return %expression% } ) renameFunction("expression", "")   gosub load  exp := "expression" return %exp%() } load: DllCall(A_AhkPath "\addScript","Str",script,"Uchar",0,"Cdecl UInt") return rena...
Generate an equivalent AutoHotKey version of this Java code.
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.tools.FileObject; import javax.tools.Fo...
msgbox % eval("3 + 4") msgbox % eval("4 + 4") return eval(expression) { global script script = ( expression(){ return %expression% } ) renameFunction("expression", "")   gosub load  exp := "expression" return %exp%() } load: DllCall(A_AhkPath "\addScript","Str",script,"Uchar",0,"Cdecl UInt") return rena...
Convert this Java block to AutoHotKey, preserving its control flow and logic.
import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; public class Main { public static void main(String[] args) throws IOException { final int endOfFile = -1; try ( FileReader reader = new FileReader("input.txt", StandardCharsets.UTF_8) ) { while (...
File := FileOpen("input.txt", "r") while !File.AtEOF MsgBox, % File.Read(1)
Generate a AutoHotKey translation of this Java snippet without changing its computational steps.
import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Frame; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.lang.reflect.InvocationTargetException; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; impo...
F1::   WinGetTitle, window, A   WinMove, %window%, , 100, 100, 800, 800    sleep, 2000 WinHide, % window   TrayTip, hidden, window is hidden, 2 sleep, 2000 WinShow, % window   loop, { inputbox, name, what was the name of your window? if (name = window)  { msgbox you g...
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
import java.util.Random; import java.util.List; import java.util.ArrayList; public class GaltonBox { public static void main( final String[] args ) { new GaltonBox( 8, 200 ).run(); } private final int m_pinRows; private final int m_startRow; private final Position[] m_balls; ...
AutoTrim Off bottompegs := 6 SleepTime := 200 fallspace := 30 out := (pad2 := Space(bottompegs*2+1)) "`n" Loop % bottompegs { out .= Space(bottompegs-A_Index+1) Loop % A_Index out .= "* " out .= Space(bottompegs-A_Index+1) . "`n" } StringTrimRight, strboard, out, 1  Loop % fallspace-1 strboard .= "`n" . pad...
Convert this Java snippet to AutoHotKey and keep its semantics consistent.
import java.io.*; import java.util.*; public class PrimeDescendants { public static void main(String[] args) { try (Writer writer = new BufferedWriter(new OutputStreamWriter(System.out))) { printPrimeDesc(writer, 100); } catch (IOException ex) { ex.printStackTrace(); ...
#Warn #SingleInstance force #NoEnv   SendMode Input   SetBatchLines, -1 SetFormat, IntegerFast, D MaxPrime = 99 MaxAncestor = 99 Descendants := [] Primes := GetPrimes(MaxPrime) Exclusions := Primes.Clone() Exclusions.Insert(4) if A_Is64bitOS { Loop, % MaxAncestor Descendants.Insert({}) for ...
Port the provided Java code into AutoHotKey while preserving the original functionality.
import java.util.Arrays; public class CircleSort { public static void main(String[] args) { circleSort(new int[]{2, 14, 4, 6, 8, 1, 3, 5, 7, 11, 0, 13, 12, -1}); } public static void circleSort(int[] arr) { if (arr.length > 0) do { System.out.println(Arrays.toS...
nums := [6, 7, 8, 9, 2, 5, 3, 4, 1] while circlesort(nums, 1, nums.Count(), 0) continue for i, v in nums output .= v ", " MsgBox % "[" Trim(output, ", ") "]" return circlesort(Arr, lo, hi, swaps){ if (lo = hi) return swaps high:= hi low := lo mid := Floor((hi - lo) / 2) while (lo...
Write a version of this Java function in AutoHotKey with identical behavior.
public class BraceExpansion { public static void main(String[] args) { for (String s : new String[]{"It{{em,alic}iz,erat}e{d,}, please.", "~/{Downloads,Pictures}/*.{jpg,gif,png}", "{,{,gotta have{ ,\\, again\\, }}more }cowbell!", "{}} some }{,{\\\\{ edge, edge} \\,}{ cas...
BraceExp(string, del:="`n") { Loop, Parse, string if (A_LoopField = "{") break else substring .= A_LoopField substr := SubStr(string, InStr(string, "{")+1, InStr(string, "}")-InStr(string, "{")-1) Loop, Parse, substr, `, toreturn .= substring . A_LoopField . del return toreturn } Msgbox, % BraceExp("en...
Change the following Java code into AutoHotKey without altering its purpose.
package intersectingNumberWheels; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.IntStream; public class WheelController { private static final String IS_NUMBER = "[0-9]"; private static final int TWENTY = 20; private static Map<String, Whe...
obj1 := {"A":[1, 2, 3]} obj2 := {"A":[1, "B", 2] , "B":[3, 4]} obj3 := {"A":[1, "D", "D"] , "D":[6, 7, 8]} obj4 := {"A":[1, "B", "C"] , "B":[3, 4] , "C":[5, "B"]} loop 4 { str := "" for k, v in obj%A_Index% { str .= "{" k " : " for i, t in v str .= t "," str := Trim(str, ",") "}, " } str := Trim(str, ", ...
Port the provided Java code into AutoHotKey while preserving the original functionality.
package intersectingNumberWheels; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.IntStream; public class WheelController { private static final String IS_NUMBER = "[0-9]"; private static final int TWENTY = 20; private static Map<String, Whe...
obj1 := {"A":[1, 2, 3]} obj2 := {"A":[1, "B", 2] , "B":[3, 4]} obj3 := {"A":[1, "D", "D"] , "D":[6, 7, 8]} obj4 := {"A":[1, "B", "C"] , "B":[3, 4] , "C":[5, "B"]} loop 4 { str := "" for k, v in obj%A_Index% { str .= "{" k " : " for i, t in v str .= t "," str := Trim(str, ",") "}, " } str := Trim(str, ", ...
Port the following code from Java to AutoHotKey with equivalent syntax and logic.
public static Color getColorAt(int x, int y){ return new Robot().getPixelColor(x, y); }
PixelGetColor, color, %X%, %Y%
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.regex.M...
test: yahooSearch("test", 1) yahooSearch("test", 2) return yahooSearch(query, page) { global start := ((page - 1) * 10) + 1 filedelete, search.txt urldownloadtofile, % "http://search.yahoo.com/search?p=" . query . "&b=" . start, search.txt fileread, content, search.txt reg = <a class="yschttl spt" href="...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
import java.util.Objects; public class Circles { private static class Point { private final double x, y; public Point(Double x, Double y) { this.x = x; this.y = y; } public double distanceFrom(Point other) { double dx = x - other.x; ...
CircleCenter(x1, y1, x2, y2, r){ d := sqrt((x2-x1)**2 + (y2-y1)**2) x3 := (x1+x2)/2 , y3 := (y1+y2)/2 cx1 := x3 + sqrt(r**2-(d/2)**2)*(y1-y2)/d , cy1:= y3 + sqrt(r**2-(d/2)**2)*(x2-x1)/d cx2 := x3 - sqrt(r**2-(d/2)**2)*(y1-y2)/d , cy2:= y3 - sqrt(r**2-(d/2)**2)*(x2-x1)/d if (d = 0) return "No circles can be dr...
Ensure the translated AutoHotKey code behaves exactly like the original Java snippet.
import java.util.Objects; public class Circles { private static class Point { private final double x, y; public Point(Double x, Double y) { this.x = x; this.y = y; } public double distanceFrom(Point other) { double dx = x - other.x; ...
CircleCenter(x1, y1, x2, y2, r){ d := sqrt((x2-x1)**2 + (y2-y1)**2) x3 := (x1+x2)/2 , y3 := (y1+y2)/2 cx1 := x3 + sqrt(r**2-(d/2)**2)*(y1-y2)/d , cy1:= y3 + sqrt(r**2-(d/2)**2)*(x2-x1)/d cx2 := x3 - sqrt(r**2-(d/2)**2)*(y1-y2)/d , cy2:= y3 - sqrt(r**2-(d/2)**2)*(x2-x1)/d if (d = 0) return "No circles can be dr...
Translate this program into AutoHotKey but keep the logic exactly as in Java.
import java.util.Arrays; import java.util.HashSet; public class VampireNumbers{ private static int numDigits(long num){ return Long.toString(Math.abs(num)).length(); } private static boolean fangCheck(long orig, long fang1, long fang2){ if(Long.toString(fang1).endsWith("0") && Long.toStrin...
SetBatchLines -1  StartingNumber := 10 NumberLimit := 126030 CounterLimit := 25  AdditionalNumbers := "16758243290880,24959017348650,14593825548650" CurrentCounter := 0, CurrentNumber := StartingNumber Loop { if !Mod(A_Index,75)  ToolTip, % "Checking numbers...`nNumber: " CurrentNumber ...
Write the same algorithm in AutoHotKey as shown in this Java implementation.
import java.util.Arrays; import java.util.List; public class Cistercian { private static final int SIZE = 15; private final char[][] canvas = new char[SIZE][SIZE]; public Cistercian(int n) { initN(); draw(n); } public void initN() { for (var row : canvas) { Arr...
CistercianNumerals(num){ x := [] x[1, "UL"] := ["000","111","000","000","100","111","100","111","100","111"] x[2, "UL"] := ["000","000","000","001","010","010","100","100","100","100"] x[3, "UL"] := ["000","000","000","010","001","001","100","100","100","100"] x[4, "UL"] := ["000","000","11...
Change the following Java code into AutoHotKey without altering its purpose.
import java.util.Arrays; import java.util.List; public class Cistercian { private static final int SIZE = 15; private final char[][] canvas = new char[SIZE][SIZE]; public Cistercian(int n) { initN(); draw(n); } public void initN() { for (var row : canvas) { Arr...
CistercianNumerals(num){ x := [] x[1, "UL"] := ["000","111","000","000","100","111","100","111","100","111"] x[2, "UL"] := ["000","000","000","001","010","010","100","100","100","100"] x[3, "UL"] := ["000","000","000","010","001","001","100","100","100","100"] x[4, "UL"] := ["000","000","11...
Generate a AutoHotKey translation of this Java snippet without changing its computational steps.
import java.util.Arrays; import java.util.Collections; import java.util.HashSet; public class PokerHandAnalyzer { final static String faces = "AKQJT98765432"; final static String suits = "HDSC"; final static String[] deck = buildDeck(); public static void main(String[] args) { System.out.prin...
PokerHand(hand){ StringUpper, hand, hand Sort, hand, FCardSort D%A_Space% cardSeq := RegExReplace(hand, "[^2-9TJQKA]") Straight:= InStr("23456789TJQKA", cardSeq) || (cardSeq = "2345A") ? true : false hand := cardSeq = "2345A" ? RegExReplace(hand, "(.*)\h(A.)", "$2 $1") : hand Royal := InStr(hand, "A") ? "Royal...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
import java.util.Arrays; import java.util.Collections; import java.util.HashSet; public class PokerHandAnalyzer { final static String faces = "AKQJT98765432"; final static String suits = "HDSC"; final static String[] deck = buildDeck(); public static void main(String[] args) { System.out.prin...
PokerHand(hand){ StringUpper, hand, hand Sort, hand, FCardSort D%A_Space% cardSeq := RegExReplace(hand, "[^2-9TJQKA]") Straight:= InStr("23456789TJQKA", cardSeq) || (cardSeq = "2345A") ? true : false hand := cardSeq = "2345A" ? RegExReplace(hand, "(.*)\h(A.)", "$2 $1") : hand Royal := InStr(hand, "A") ? "Royal...
Convert this Java block to AutoHotKey, preserving its control flow and logic.
import java.awt.*; import javax.swing.*; public class FibonacciWordFractal extends JPanel { String wordFractal; FibonacciWordFractal(int n) { setPreferredSize(new Dimension(450, 620)); setBackground(Color.white); wordFractal = wordFractal(n); } public String wordFractal(int n)...
#NoEnv SetBatchLines, -1 p := 0.3 F_Word := 30 SysGet, Mon, MonitorWorkArea W := FibWord(F_Word) d := 1 x1 := 0 y1 := MonBottom Width := A_ScreenWidth Height := A_ScreenHeight If (!pToken := Gdip_Startup()) { MsgBox, 48, Gdiplus Error!, Gdiplus failed to start. Please ensure you have Gdiplus on your system. ExitAp...
Generate an equivalent AutoHotKey version of this Java code.
import java.util.*; public class PenneysGame { public static void main(String[] args) { Random rand = new Random(); String compChoice = "", playerChoice; if (rand.nextBoolean()) { for (int i = 0; i < 3; i++) compChoice += "HT".charAt(rand.nextInt(2)); ...
Gui, font, s12 Gui, add, text, w90, Computer: loop, 3 Gui, add, button, x+10 h30 w30 vCB%A_Index% Gui, add, edit, xs w240 R3 vSequence Gui, add, text, w90, Human: loop, 3 Gui, add, button, x+10 h30 w30 vHB%A_Index% gHumButton, H Gui, add, button, xm gToss, toss Gui, add, button, x+10 gReset, Reset Gui, show,, Penney...
Write a version of this Java function in AutoHotKey with identical behavior.
import javax.swing.*; import java.awt.*; class SierpinskyTriangle { public static void main(String[] args) { int i = 3; if(args.length >= 1) { try { i = Integer.parseInt(args[0]); } catch(NumberFormatException e) { System.out.println("Usage: 'java SierpinskyTriangle [level]'\nNow setting le...
#NoEnv #SingleInstance, Force SetBatchLines, -1 Width := 512, Height := Width/2*3**0.5, n := 8  #Include ..\lib\Gdip.ahkl If !pToken := Gdip_Startup()  { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } if (Gdip_LibraryVersion() < 1.30) { MsgBox, 48, ...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
import javax.swing.*; import java.awt.*; class SierpinskyTriangle { public static void main(String[] args) { int i = 3; if(args.length >= 1) { try { i = Integer.parseInt(args[0]); } catch(NumberFormatException e) { System.out.println("Usage: 'java SierpinskyTriangle [level]'\nNow setting le...
#NoEnv #SingleInstance, Force SetBatchLines, -1 Width := 512, Height := Width/2*3**0.5, n := 8  #Include ..\lib\Gdip.ahkl If !pToken := Gdip_Startup()  { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } if (Gdip_LibraryVersion() < 1.30) { MsgBox, 48, ...
Rewrite the snippet below in AutoHotKey so it works the same as the original Java code.
import java.util.*; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList; public class Nonoblock { public static void main(String[] args) { printBlock("21", 5); printBlock("", 5); printBlock("8", 10); printBlock("2323", 15); printBlock("23...
NonoBlock(cells, blocks){ result := [], line := "" for i, v in blocks B .= v ", " output := cells " cells and [" Trim(B, ", ") "] blocks`n" if ((Arr := NonoBlockCreate(cells, blocks)) = "Error") return output "No Solution`n" for i, v in arr line.= v " result[line] ...
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
import java.util.*; import static java.util.Arrays.stream; import static java.util.stream.Collectors.toList; public class Nonoblock { public static void main(String[] args) { printBlock("21", 5); printBlock("", 5); printBlock("8", 10); printBlock("2323", 15); printBlock("23...
NonoBlock(cells, blocks){ result := [], line := "" for i, v in blocks B .= v ", " output := cells " cells and [" Trim(B, ", ") "] blocks`n" if ((Arr := NonoBlockCreate(cells, blocks)) = "Error") return output "No Solution`n" for i, v in arr line.= v " result[line] ...
Convert the following code from Java to AutoHotKey, ensuring the logic remains intact.
import java.util.List; public class Main { private static class Range { int start; int end; boolean print; public Range(int s, int e, boolean p) { start = s; end = e; print = p; } } public static void main(String[] args) { ...
eban_numbers(min, max, show:=0){ counter := 0, output := "" i := min while ((i+=2) <= max) { b := floor(i / 1000000000) r := Mod(i, 1000000000) m := floor(r / 1000000) r := Mod(i, 1000000) t := floor(r / 1000) r := Mod(r, 1000) if (m >= 30 && m <= 66) m := Mod(m, 10) if (t >= 30 && t <= 66) ...
Maintain the same structure and functionality when rewriting this code in AutoHotKey.
import java.util.List; public class Main { private static class Range { int start; int end; boolean print; public Range(int s, int e, boolean p) { start = s; end = e; print = p; } } public static void main(String[] args) { ...
eban_numbers(min, max, show:=0){ counter := 0, output := "" i := min while ((i+=2) <= max) { b := floor(i / 1000000000) r := Mod(i, 1000000000) m := floor(r / 1000000) r := Mod(i, 1000000) t := floor(r / 1000) r := Mod(r, 1000) if (m >= 30 && m <= 66) m := Mod(m, 10) if (t >= 30 && t <= 66) ...
Generate an equivalent AutoHotKey version of this Java code.
import java.math.BigInteger; public class MayanNumerals { public static void main(String[] args) { for ( long base10 : new long[] {4005, 8017, 326205, 886205, 1000000000, 1081439556L, 26960840421L, 503491211079L }) { displayMyan(BigInteger.valueOf(base10)); System.out.printf("%n");...
MayanNumerals(num){ pwr:=1, obj:=[], grid:=[] while (num // 20**pwr) pwr++ while --pwr { obj.Push(num // 20**pwr) num := Mod(num, 20**pwr) } obj.Push(num) cols := obj.count() loop % cols { c := A_Index loop 4 grid[c, A_Index] := " " grid[c, 4] := " Θ " } for i, v in obj { j := 5 lo...
Can you help me rewrite this code in AutoHotKey instead of Java, keeping it the same logically?
public class Test { static boolean valid(int n, int nuts) { for (int k = n; k != 0; k--, nuts -= 1 + nuts / n) if (nuts % n != 1) return false; return nuts != 0 && (nuts % n == 0); } public static void main(String[] args) { int x = 0; for (int n ...
loop, 2 { sailor := A_Index+4 while !result := Coco(sailor, A_Index) continue remain := result["Coconuts"] output := sailor " Sailors, Number of coconuts = " result["Coconuts"] "`n" loop % sailor { x := result["Sailor_" A_Index] output .= "Monkey gets 1, Sailor# " A_Index " hides (" remain "-1)/" sailor "...
Rewrite the snippet below in AutoHotKey so it works the same as the original Java code.
public class Test { static boolean valid(int n, int nuts) { for (int k = n; k != 0; k--, nuts -= 1 + nuts / n) if (nuts % n != 1) return false; return nuts != 0 && (nuts % n == 0); } public static void main(String[] args) { int x = 0; for (int n ...
loop, 2 { sailor := A_Index+4 while !result := Coco(sailor, A_Index) continue remain := result["Coconuts"] output := sailor " Sailors, Number of coconuts = " result["Coconuts"] "`n" loop % sailor { x := result["Sailor_" A_Index] output .= "Monkey gets 1, Sailor# " A_Index " hides (" remain "-1)/" sailor "...
Keep all operations the same but rewrite the snippet in AutoHotKey.
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.TimeZone; public class NauticalBell extends Thread { public static void main(String[] args) { NauticalBell bells = new NauticalBell(); bells.setDaemon(true); bells.start(); try { bells.join...
NauticalBell(hh, mm){ Hr := 0, min := 30, Bells := [], pattern := [] Loop 8 { num := A_Index , code := "" while (num/2 >=1) code .= "** ", num := num-2 code .= mod(A_Index, 2) ? "*" : "" pattern[A_Index] := code } loop, 48 { numBells := !mod(A_Index, 8) ? 8 : mod(A_Index, 8) , m...
Write the same code in AutoHotKey as shown below in Java.
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.TimeZone; public class NauticalBell extends Thread { public static void main(String[] args) { NauticalBell bells = new NauticalBell(); bells.setDaemon(true); bells.start(); try { bells.join...
NauticalBell(hh, mm){ Hr := 0, min := 30, Bells := [], pattern := [] Loop 8 { num := A_Index , code := "" while (num/2 >=1) code .= "** ", num := num-2 code .= mod(A_Index, 2) ? "*" : "" pattern[A_Index] := code } loop, 48 { numBells := !mod(A_Index, 8) ? 8 : mod(A_Index, 8) , m...
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the Java version.
import processing.sound.*; float[] frequencies = {261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25}; SinOsc sine; size(500,500); sine = new SinOsc(this); for(int i=0;i<frequencies.length;i++){ sine.freq(frequencies[i]); sine.play(); delay(500); }
for key, val in [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25] SoundBeep, % val, 500
Produce a language-to-language conversion: from Java to AutoHotKey, same semantics.
import processing.sound.*; float[] frequencies = {261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25}; SinOsc sine; size(500,500); sine = new SinOsc(this); for(int i=0;i<frequencies.length;i++){ sine.freq(frequencies[i]); sine.play(); delay(500); }
for key, val in [261.63, 293.66, 329.63, 349.23, 392.00, 440.00, 493.88, 523.25] SoundBeep, % val, 500
Keep all operations the same but rewrite the snippet in AutoHotKey.
import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; public class PolySpiral extends JPanel { double inc = 0; public PolySpiral() { setPreferredSize(new Dimension(640, 640)); setBackground(Color.white); new Timer(40, (ActionEvent e) -> { inc = (inc +...
If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } OnExit, Exit gdip1() incr := 0 π := 3.141592653589793 loop { incr := Mod(incr + 0.05, 360) x1 := Width/2 y1 := Height/2 length := 5 angle := incr ...
Preserve the algorithm and functionality while converting the code from Java to AutoHotKey.
import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; public class PolySpiral extends JPanel { double inc = 0; public PolySpiral() { setPreferredSize(new Dimension(640, 640)); setBackground(Color.white); new Timer(40, (ActionEvent e) -> { inc = (inc +...
If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } OnExit, Exit gdip1() incr := 0 π := 3.141592653589793 loop { incr := Mod(incr + 0.05, 360) x1 := Width/2 y1 := Height/2 length := 5 angle := incr ...
Write the same code in AutoHotKey as shown below in Java.
import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Random; import javax.imageio.ImageIO; import javax.swing.JFrame; public class Voronoi extends JFrame { st...
Gui, 1: +E0x20 +Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs Gui, 1: Show, NA hwnd1 := WinExist() OnExit, Exit If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } Width :=1400, Height := 1050 hbm := CreateDIB...
Ensure the translated AutoHotKey code behaves exactly like the original Java snippet.
import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Random; import javax.imageio.ImageIO; import javax.swing.JFrame; public class Voronoi extends JFrame { st...
Gui, 1: +E0x20 +Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs Gui, 1: Show, NA hwnd1 := WinExist() OnExit, Exit If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } Width :=1400, Height := 1050 hbm := CreateDIB...
Please provide an equivalent version of this Java code in AutoHotKey.
import java.io.IOException; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; public class LdapConnectionDemo { public static void main(String[] args) throws LdapExcepti...
objConn := CreateObject("ADODB.Connection") objCmd := CreateObject("ADODB.Command") objConn.Provider := "ADsDSOObject" objConn.Open()
Produce a language-to-language conversion: from Java to AutoHotKey, same semantics.
Point p = component.getLocation(); Robot robot = new Robot(); robot.mouseMove(p.getX(), p.getY()); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK);
WinActivate, ahk_class MozillaUIWindowClass Click 200, 200 right   sleep, 2000 WinMinimize CoordMode, Mouse, Screen Click 400, 400 right  
Write a version of this Java function in AutoHotKey with identical behavior.
package hu.pj.alg.test; import hu.pj.alg.BoundedKnapsack; import hu.pj.obj.Item; import java.util.*; import java.text.*; public class BoundedKnapsackForTourists { public BoundedKnapsackForTourists() { BoundedKnapsack bok = new BoundedKnapsack(400); bok.add("map", 9, 150, 1); bok...
Item = map,compass,water,sandwich,glucose,tin,banana,apple,cheese,beer,suntan cream ,camera,tshirt,trousers,umbrella,waterproof trousers,waterproof overclothes,notecase ,sunglasses,towel,socks,book Weight= 9,13,153,50,15,68,27,39,23,52,11,32,24,48,73,42,43,22,7,18,4,30 Value = 150,35,200,60,60,45,60,40,30,1...
Translate this program into AutoHotKey but keep the logic exactly as in Java.
import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Hidato { private static int[][] board; private static int[] given, start; public static void main(String[] args) { String[] input = {"_ 33 35 _ _ . . .", "_ _ 24 22 _ . . .", "_ _...
SolveHidato(Grid, Locked, Max, row, col, num:=1, R:="", C:=""){ if (R&&C) { Grid[R, C] := ">" num row:=R, col:=C } num++ if (num=max) return map(Grid) if locked[num] { row := StrSplit((StrSplit(locked[num], ",").1) , ":").1 col := StrSplit((StrSplit(l...
Produce a language-to-language conversion: from Java to AutoHotKey, same semantics.
import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Hidato { private static int[][] board; private static int[] given, start; public static void main(String[] args) { String[] input = {"_ 33 35 _ _ . . .", "_ _ 24 22 _ . . .", "_ _...
SolveHidato(Grid, Locked, Max, row, col, num:=1, R:="", C:=""){ if (R&&C) { Grid[R, C] := ">" num row:=R, col:=C } num++ if (num=max) return map(Grid) if locked[num] { row := StrSplit((StrSplit(locked[num], ",").1) , ":").1 col := StrSplit((StrSplit(l...
Please provide an equivalent version of this Java code in AutoHotKey.
import java.util.Arrays; import java.util.LinkedList; public class Strand{ public static <E extends Comparable<? super E>> LinkedList<E> strandSort(LinkedList<E> list){ if(list.size() <= 1) return list; LinkedList<E> result = new LinkedList<E>(); while(list.size() > 0){ LinkedList<E> sorted = new Linked...
string = ( -2 0 -2 5 5 3 -1 -3 5 5 0 2 -4 4 2 ) string2 := string Loop { loop, parse, string, %A_space% { list := 1 = A_index ? A_loopfield : list StringSplit, k, list, %A_space% if ( k%k0% <= A_loopfield ) && ( l != "" ) && ( A_index != 1 ) list := list . " " . A_loopfield if ( k%k0% > A_loopfield ) ...