Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Translate the given Java code snippet into Arturo without altering its behavior. | 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... | primes: select 0..10000 => prime?
frobenius: function [n] -> sub sub primes\[n] * primes\[n+1] primes\[n] primes\[n+1]
frob: 0
lst: new []
j: new 0
while [frob < 10000] [
'lst ++ frob: <= frobenius j
inc 'j
]
loop split.every:10 chop lst 'a ->
print map a => [pad to :string & 5]
|
Convert the following code from Java to Arturo, 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... | primes: select 0..10000 => prime?
frobenius: function [n] -> sub sub primes\[n] * primes\[n+1] primes\[n] primes\[n+1]
frob: 0
lst: new []
j: new 0
while [frob < 10000] [
'lst ++ frob: <= frobenius j
inc 'j
]
loop split.every:10 chop lst 'a ->
print map a => [pad to :string & 5]
|
Maintain the same structure and functionality when rewriting this code in Arturo. | 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... | sorted?: function [arr][
previous: first arr
loop slice arr 1 (size arr)-1 'item [
if not? item > previous -> return false
previous: item
]
return true
]
permutationSort: function [items][
loop permutate items 'perm [
if sorted? perm -> return perm
]
]
print permutatio... |
Ensure the translated Arturo code behaves exactly like the original Java snippet. | import java.math.BigInteger;
public class IntegerRoots {
private static BigInteger iRoot(BigInteger base, int n) {
if (base.compareTo(BigInteger.ZERO) < 0 || n <= 0) {
throw new IllegalArgumentException();
}
int n1 = n - 1;
BigInteger n2 = BigInteger.valueOf(n);
... | iroot: function [b n][
if b<2 -> return b
n1: n-1
n2: n
n3: n1
c: 1
d: (n3+b)/n2
e: ((n3*d) + b/d^n1)/n2
while [and? c<>d c<>e][
c: d
d: e
e: ((n3*e) + b/e^n1)/n2
]
if d<e -> return d
return e
]
print ["3rd root of 8:" iroot 8 3]
print ["3rd root o... |
Produce a language-to-language conversion: from Java to Arturo, same semantics. | import java.math.BigInteger;
public class IntegerRoots {
private static BigInteger iRoot(BigInteger base, int n) {
if (base.compareTo(BigInteger.ZERO) < 0 || n <= 0) {
throw new IllegalArgumentException();
}
int n1 = n - 1;
BigInteger n2 = BigInteger.valueOf(n);
... | iroot: function [b n][
if b<2 -> return b
n1: n-1
n2: n
n3: n1
c: 1
d: (n3+b)/n2
e: ((n3*d) + b/d^n1)/n2
while [and? c<>d c<>e][
c: d
d: e
e: ((n3*e) + b/e^n1)/n2
]
if d<e -> return d
return e
]
print ["3rd root of 8:" iroot 8 3]
print ["3rd root o... |
Translate this program into Arturo but keep the logic exactly as in Java. | public class ScriptedMain {
public static int meaningOfLife() {
return 42;
}
public static void main(String[] args) {
System.out.println("Main: The meaning of life is " + meaningOfLife());
}
}
|
meaningOfLife: function [][
42
]
if standalone? ->
print ~"Library: The meaning of life is |meaningOfLife|"
|
Convert this Java snippet to Arturo and keep its semantics consistent. | public class ScriptedMain {
public static int meaningOfLife() {
return 42;
}
public static void main(String[] args) {
System.out.println("Main: The meaning of life is " + meaningOfLife());
}
}
|
meaningOfLife: function [][
42
]
if standalone? ->
print ~"Library: The meaning of life is |meaningOfLife|"
|
Transform the following Java implementation into Arturo, maintaining the same output and logic. | public class NicePrimes {
private static boolean isPrime(long n) {
if (n < 2) {
return false;
}
if (n % 2 == 0L) {
return n == 2L;
}
if (n % 3 == 0L) {
return n == 3L;
}
var p = 5L;
while (p * p <= n) {
... | sumd: function [n][
s: sum digits n
(1 = size digits s)? -> return s
-> return sumd s
]
nice?: function [x] -> and? prime? x
prime? sumd x
loop split.every:10 select 500..1000 => nice? 'a ->
print map a => [pad to :string & 4]
|
Convert the following code from Java to Arturo, ensuring the logic remains intact. | public class NicePrimes {
private static boolean isPrime(long n) {
if (n < 2) {
return false;
}
if (n % 2 == 0L) {
return n == 2L;
}
if (n % 3 == 0L) {
return n == 3L;
}
var p = 5L;
while (p * p <= n) {
... | sumd: function [n][
s: sum digits n
(1 = size digits s)? -> return s
-> return sumd s
]
nice?: function [x] -> and? prime? x
prime? sumd x
loop split.every:10 select 500..1000 => nice? 'a ->
print map a => [pad to :string & 4]
|
Generate a Arturo translation of this Java snippet without changing its computational steps. | 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... | lastSundayForMonth: function [m,y][
ensure -> in? m 1..12
daysOfMonth: @[0 31 (leap? y)? -> 28 -> 27 31 30 31 30 31 31 30 31 30 31]
loop range get daysOfMonth m 1 [d][
dt: to :date.format:"yyyy-M-dd" ~"|y|-|m|-|d|"
if dt\Day = "Sunday" -> return dt
]
]
getLastSundays: function [year][
... |
Generate a Arturo translation of this Java snippet without changing its computational steps. | 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... | lastSundayForMonth: function [m,y][
ensure -> in? m 1..12
daysOfMonth: @[0 31 (leap? y)? -> 28 -> 27 31 30 31 30 31 31 30 31 30 31]
loop range get daysOfMonth m 1 [d][
dt: to :date.format:"yyyy-M-dd" ~"|y|-|m|-|d|"
if dt\Day = "Sunday" -> return dt
]
]
getLastSundays: function [year][
... |
Preserve the algorithm and functionality while converting the code from Java to Arturo. | import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
public class RandomLatinSquares {
private static void printSquare(List<List<Integer>> latin) {
for (List<Integer> row : latin) {
Iterator<Integer> it = row.itera... | latinSquare: function [n][
square: new []
variants: shuffle permutate 0..n-1
while -> n > size square [
row: sample variants
'square ++ @[row]
filter 'variants 'variant [
reject: false
loop.with:'i variant 'col [
if col = row\[i] ->
... |
Rewrite this program in Arturo while keeping its functionality equivalent to the Java version. | 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... | wordset: map read.lines relative "unixdict.txt" => strip
rotateable?: function [w][
loop 1..dec size w 'i [
rotated: rotate w i
if or? [rotated = w][not? contains? wordset rotated] ->
return false
]
return true
]
results: new []
loop select wordset 'word [3 =< size word] 'word... |
Generate an equivalent Arturo version of this Java code. | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FairshareBetweenTwoAndMore {
public static void main(String[] args) {
for ( int base : Arrays.asList(2, 3, 5, 11) ) {
System.out.printf("Base %d = %s%n", base, thueMorseSequence(25, base));
}
}... | thueMorse: function [base, howmany][
i: 0
result: new []
while [howmany > size result][
'result ++ (sum digits.base:base i)Β % base
i: i + 1
]
return result
]
loop [2 3 5 11] 'b ->
print [
(pad.right "Base "++(to :string b) 7)++" =>"
join.with:" " map to [:strin... |
Generate an equivalent Arturo version of this Java code. | import java.util.ArrayList;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
public class EstheticNumbers {
interface RecTriConsumer<A, B, C> {
void accept(RecTriConsumer<A, B, C> f, A a, B b, C c);
}
private static boolean isEsthetic(long n, long b) {
if (n == 0) {
... | esthetic?: function [n, b][
if n=0 -> return false
k: nΒ % b
l: n / b
while [l>0][
j: lΒ % b
if 1 <> abs k-j -> return false
l: l / b
k: j
]
return true
]
HEX: "0000000000ABCDEF"
getHex: function [ds][
map ds 'd [
(d < 10)? -> to :string d
... |
Convert this Java block to Arturo, preserving its control flow and logic. | 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: function [arr][
d: 1
c: array.of: size arr 0
xs: new arr
sign: 1
ret: new @[@[xs, sign]]
while [true][
while [d > 1][
d: d-1
c\[d]: 0
]
while [c\[d] >= d][
d: d+1
if d >= size arr -> return ret
]
... |
Translate the given Java code snippet into Arturo without altering its behavior. | import java.util.List;
import java.util.Random;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
public class Rpg {
private static final Random random = new Random();
public static int genAttribute() {
return random.ints(1, 6 + 1)
.limit(4)
... | vals: []
while [or? 75 > sum vals
2 > size select vals => [&>=15]] [
vals: new []
while [6 > size vals][
rands: new map 1..4 => [random 1 6]
remove 'rands .once (min rands)
'vals ++ sum rands
]
]
print ["values:" vals ]
print ["with sum:" sum vals]
|
Generate a Arturo translation of this Java snippet without changing its computational steps. | import java.util.Arrays;
public class Kolakoski {
private static class Crutch {
final int len;
int[] s;
int i;
Crutch(int len) {
this.len = len;
s = new int[len];
i = 0;
}
void repeat(int count) {
for (int j = 0; j < ... | kolakoski: function [a, length][
result: array.of: length 0
i: new 0
k: new 0
loop.forever a 'x [
result\[i]: x
if result\[k] > 1 [
loop 1..dec result\[k] 'j [
inc 'i
if i = length -> return result
result\[i]: result\[i-1]
... |
Ensure the translated Arturo code behaves exactly like the original Java snippet. | public class VariableDeclarationReset {
public static void main(String[] args) {
int[] s = {1, 2, 2, 3, 4, 4, 5};
for (int i = 0; i < s.length; ++i) {
int curr = s[i];
int prev = 0;
if (i > 0 && curr == prev) System.out.println(i);
... | Red[]
s: [1 2 2 3 4 4 5]
repeat i length? s [
curr: s/:i
if all [i > 1 curr = prev][
print i
]
prev: curr
]
|
Keep all operations the same but rewrite the snippet in Arturo. | 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;
}
... | firstNumWithDivisors: function [n][
i: 0
while ΓΈ [
if n = size factors i -> return i
i: i+1
]
]
print map 1..15 => firstNumWithDivisors
|
Translate the given Java code snippet into Arturo without altering its 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};
... | bar: "βββββ
βββ"
barcount: to :floating dec size bar
while ΓΈ [
line: input "Numbers separated by spaces: "
numbers: to [:floating] split.words line
mn: min numbers
mx: max numbers
extent: mx-mn
sparkLine: new ""
loop numbers 'n [
i: to :integer barcount*(n-mn)//extent
'sparkL... |
Transform the following Java implementation into Arturo, maintaining the same output and logic. | public class LevenshteinAlignment {
public static String[] alignment(String a, String b) {
a = a.toLowerCase();
b = b.toLowerCase();
int[][] costs = new int[a.length()+1][b.length()+1];
for (int j = 0; j <= b.length(); j++)
costs[0][j] = j;
for (int i = ... | print join.with:"\n" levenshtein.align "place" "palace"
print join.with:"\n" levenshtein.align "rosettacode" "raisethysword"
|
Port the provided Java code into Arturo while preserving the original functionality. | 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, ... | lis: function [d][
l: new [[]]
loop d 'num [
x: []
loop l 'seq [
if positive? size seq [
if and? num > last seq
(size seq) > size x ->
x: seq
]
]
'l ++ @[x ++ @[num]]
]
result: []
loop... |
Convert this Java block to Arturo, preserving its control flow and logic. | 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,... | name: strip input "enter a variable name: "
value: strip input "enter a variable value: "
let name value
print ["the value of variable" name "is:" var name]
|
Transform the following Java implementation into Arturo, maintaining the same output and logic. | import java.math.BigInteger;
public class SquareRoot {
public static final BigInteger ONE_HUNDRED = BigInteger.valueOf(100);
public static final BigInteger TWENTY = BigInteger.valueOf(20);
public static void main(String[] args) {
var i = BigInteger.TWO;
var j = BigInteger.valueOf((long) Ma... | i: 2
j: to :integer sqrt 2.0
k: new j
d: new j
n: new 500
n0: n
while ΓΈ [
prints d
i: (i - k * d) * 100
k: new 20 * j
d: new 1
while [d =< 10][
if i < d * k+d [
dec 'd
break
]
inc 'd
]
j: d + j*10
'k + d
if n0 > 0 -> dec 'n
if n=0 ... |
Convert this Java snippet to Arturo and keep its semantics consistent. | import java.math.BigInteger;
public class SquareRoot {
public static final BigInteger ONE_HUNDRED = BigInteger.valueOf(100);
public static final BigInteger TWENTY = BigInteger.valueOf(20);
public static void main(String[] args) {
var i = BigInteger.TWO;
var j = BigInteger.valueOf((long) Ma... | i: 2
j: to :integer sqrt 2.0
k: new j
d: new j
n: new 500
n0: n
while ΓΈ [
prints d
i: (i - k * d) * 100
k: new 20 * j
d: new 1
while [d =< 10][
if i < d * k+d [
dec 'd
break
]
inc 'd
]
j: d + j*10
'k + d
if n0 > 0 -> dec 'n
if n=0 ... |
Change the programming language of this snippet from Java to Arturo without modifying what it does. | import java.util.*;
public class BrilliantNumbers {
public static void main(String[] args) {
var primesByDigits = getPrimesByDigits(100000000);
System.out.println("First 100 brilliant numbers:");
List<Integer> brilliantNumbers = new ArrayList<>();
for (var primes : primesByDigits) {... | brilliant?: function [x][
pf: factors.prime x
and? -> 2 = size pf
-> equal? size digits first pf
size digits last pf
]
brilliants: new []
i: 2
while [100 > size brilliants][
if brilliant? i -> 'brilliants ++ i
i: i + 1
]
print "First 100 brilliant numbers:"
loop split.every... |
Generate an equivalent Arturo version of this Java code. | import java.util.*;
public class BrilliantNumbers {
public static void main(String[] args) {
var primesByDigits = getPrimesByDigits(100000000);
System.out.println("First 100 brilliant numbers:");
List<Integer> brilliantNumbers = new ArrayList<>();
for (var primes : primesByDigits) {... | brilliant?: function [x][
pf: factors.prime x
and? -> 2 = size pf
-> equal? size digits first pf
size digits last pf
]
brilliants: new []
i: 2
while [100 > size brilliants][
if brilliant? i -> 'brilliants ++ i
i: i + 1
]
print "First 100 brilliant numbers:"
loop split.every... |
Convert this Java block to Arturo, preserving its control flow and logic. | 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... | orderDisjoint: function [m,n][
ms: split.words m
ns: split.words n
indexes: new []
loop ns 'item [
idx: index ms item
unless null? idx [
'indexes ++ idx
ms\[idx]: ""
]
]
sort 'indexes
loop.with:'i indexes 'idx ->
ms\[idx]: ns\[i]
... |
Preserve the algorithm and functionality while converting the code from Java to Arturo. | 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 ... |
blk: [
[UK London]
[US New-York]
[US Birmingham]
[UK Birmingham]
]
sort/compare blk func [a b] [either a/2 < b/2 [-1] [either a/2 > b/2 [1] [0]]]
blk: [
UK London
US New-York
US Birmingham
UK Birmingham
]
sort/skip/compare blk 2 func [a b] [either a < b [-1] [either a > b [1] [0]]]
|
Translate this program into Arturo but keep the logic exactly as in Java. | public static void main(String[] args) {
System.out.println(concat("Rosetta", "Code", ":"));
}
public static String concat(String a, String b, String c) {
return a + c + c + b;
}
Rosetta::Code
| $ rebol -q
>> f: func [a b s] [print rejoin [a s s b]]
>> f "Rosetta" "Code" ":"
Rosetta::Code
>> q
|
Preserve the algorithm and functionality while converting the code from Java to Arturo. | 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... | prog: [x * 2]
fn: func [x] [do bind prog 'x]
a: fn 2
b: fn 4
subtract b a
|
Preserve the algorithm and functionality while converting the code from Java to Arturo. | 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... | prog: [x * 2]
fn: func [x] [do bind prog 'x]
a: fn 2
b: fn 4
subtract b a
|
Ensure the translated Arturo code behaves exactly like the original Java snippet. | public class ReallyLameTranslationOfJ {
public static void main(String[] args) {
String s = "She was a soul stripper. She took my heart!";
System.out.println(cheapTrick(s));
System.out.println(cheapTrick(cheapTrick(s)));
}
static String cheapTrick(String s) {
if (s.contains... | reverseGender: function [str][
ret: new str
entries: ["She" "she" "Her" "her" "hers" "He" "he" "His" "his" "him"]
repls: ["He_" "he_" "His_" "his_" "his_" "She_" "she_" "Her_" "her_" "her_"]
loop.with:'i entries 'entry ->
replace 'ret to :regex ~{\b|entry|\b} repls\[i]
return replace ret "_" "... |
Write a version of this Java function in Arturo with identical behavior. | public class ReallyLameTranslationOfJ {
public static void main(String[] args) {
String s = "She was a soul stripper. She took my heart!";
System.out.println(cheapTrick(s));
System.out.println(cheapTrick(cheapTrick(s)));
}
static String cheapTrick(String s) {
if (s.contains... | reverseGender: function [str][
ret: new str
entries: ["She" "she" "Her" "her" "hers" "He" "he" "His" "his" "him"]
repls: ["He_" "he_" "His_" "his_" "his_" "She_" "she_" "Her_" "her_" "her_"]
loop.with:'i entries 'entry ->
replace 'ret to :regex ~{\b|entry|\b} repls\[i]
return replace ret "_" "... |
Convert this Java snippet to Arturo and keep its semantics consistent. | 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... | a: {print ["The result is:" 2+3]}
do a
userCode: input "Give me some code: "
do userCode
|
Convert this Java block to Arturo, preserving its control flow and logic. | 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... | a: {print ["The result is:" 2+3]}
do a
userCode: input "Give me some code: "
do userCode
|
Keep all operations the same but rewrite the snippet in Arturo. | import java.math.BigInteger;
import static java.util.Arrays.stream;
import java.util.*;
import static java.util.stream.Collectors.*;
public class Test3 {
static BigInteger rank(int[] x) {
String s = stream(x).mapToObj(String::valueOf).collect(joining("F"));
return new BigInteger(s, 16);
}
... | rank: function [arr][
if empty? arr -> return 0
from.binary "1" ++ join.with:"0" map arr 'a -> repeat "1" a
]
unrank: function [rnk][
if rnk=1 -> return [0]
bn: as.binary rnk
map split.by:"0" slice bn 1 dec size bn => size
]
l: [1, 2, 3, 5, 8]
print ["The initial list:" l]
r: rank l
print ["Ran... |
Maintain the same structure and functionality when rewriting this code in Arturo. | import java.util.*;
public class RandomShuffle {
public static void main(String[] args) {
Random rand = new Random();
List<Integer> list = new ArrayList<>();
for (int j = 1; j <= 20; ++j)
list.add(j);
Collections.shuffle(list, rand);
System.out.println(list);
... | generateUniqueRandoms: function [][
result: new []
while [20 > size result][
rand: sample 1..20
if not? in? rand result ->
'result ++ rand
]
return result
]
loop 3 'x [
print generateUniqueRandoms
]
|
Convert the following code from C# to AutoHotKey, ensuring the logic remains intact. | using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;
class Program {
static bool ispr(int x) { int lim = (int)Sqrt((double)x);
if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
for (int d = 5; d <= lim; d += (odd = !o... | 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 ... |
Keep all operations the same but rewrite the snippet in AutoHotKey. | using System.Collections.Generic; using System.Linq; using static System.Console; using static System.Math;
class Program {
static bool ispr(int x) { int lim = (int)Sqrt((double)x);
if (x < 2) return false; if ((x % 3) == 0) return x == 0; bool odd = false;
for (int d = 5; d <= lim; d += (odd = !o... | 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 ... |
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the C# version. | using System;
namespace LastSundayOfEachMonth
{
class Program
{
static void Main()
{
Console.Write("Year to calculate: ");
string strYear = Console.ReadLine();
int year = Convert.ToInt32(strYear);
DateTime date;
for (int i = 1; i <= ... | 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 the same algorithm in AutoHotKey as shown in this C# implementation. | using System;
namespace LastSundayOfEachMonth
{
class Program
{
static void Main()
{
Console.Write("Year to calculate: ");
string strYear = Console.ReadLine();
int year = Convert.ToInt32(strYear);
DateTime date;
for (int i = 1; i <= ... | 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... |
Ensure the translated AutoHotKey code behaves exactly like the original C# snippet. | using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public static class LIS
{
public static IEnumerable<T> FindRec<T>(IList<T> values, IComparer<T> comparer = null) =>
values == null ? throw new ArgumentNullException() :
FindRecImpl(values, Sequence<T>.E... | 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 :... |
Transform the following C# implementation into AutoHotKey, maintaining the same output and logic. | using System;
using System.Dynamic;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string varname = Console.ReadLine();
dynamic expando = new ExpandoObject();
var map = expando as IDictionary<string, object>;
map.Add(varname, "Hello... | InputBox, Dynamic, Variable Name
%Dynamic% = hello
ListVars
MsgBox % %dynamic% Β
|
Write the same code in AutoHotKey as shown below in C#. | using System;
using System.IO;
using System.Text;
namespace RosettaFileByChar
{
class Program
{
static char GetNextCharacter(StreamReader streamReader) => (char)streamReader.Read();
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
char c... | File := FileOpen("input.txt", "r")
while !File.AtEOF
MsgBox, % File.Read(1)
|
Maintain the same structure and functionality when rewriting this code in AutoHotKey. | using System;
class Program
{
static void Main(string[] args)
{
int i, d, s, t, n = 50, c = 1;
var sw = new int[n];
for (i = d = s = 1; c < n; i++, s += d += 2)
for (t = s; t > 0; t /= 10)
if (t < n && sw[t] < 1)
Console.Write("", sw[t] = ... | loop 49
result .= SS(A_Index) (Mod(A_Index,7)?"`t":"`n")
MsgBox % result
return
SS(n) {
if (n < 1)
return
loop{
sq := a_index**2
while (sq > n)
sq := Format("{:d}", sq/10)
if (sq = n)
return a_index**2
}
}
|
Convert the following code from C# to AutoHotKey, ensuring the logic remains intact. | using System;
class Program
{
static void Main(string[] args)
{
int i, d, s, t, n = 50, c = 1;
var sw = new int[n];
for (i = d = s = 1; c < n; i++, s += d += 2)
for (t = s; t > 0; t /= 10)
if (t < n && sw[t] < 1)
Console.Write("", sw[t] = ... | loop 49
result .= SS(A_Index) (Mod(A_Index,7)?"`t":"`n")
MsgBox % result
return
SS(n) {
if (n < 1)
return
loop{
sq := a_index**2
while (sq > n)
sq := Format("{:d}", sq/10)
if (sq = n)
return a_index**2
}
}
|
Convert this C# block to AutoHotKey, preserving its control flow and logic. | using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static System.Linq.Enumerable;
public static class BraceExpansion
{
enum TokenType { OpenBrace, CloseBrace, Separator, Text, Alternate, Concat }
const char L = '{', R = '}', S = ',';
public static void M... |
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... |
Translate the given C# code snippet into AutoHotKey without altering its behavior. | using System;
using System.Collections.Generic;
using System.Linq;
public static class IntersectingNumberWheels
{
public static void Main() {
TurnWheels(('A', "123")).Take(20).Print();
TurnWheels(('A', "1B2"), ('B', "34")).Take(20).Print();
TurnWheels(('A', "1DD"), ('D', "678")).Take(20).Pr... | 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, ", ... |
Convert this C# block to AutoHotKey, preserving its control flow and logic. | using System;
using System.Collections.Generic;
using System.Linq;
public static class IntersectingNumberWheels
{
public static void Main() {
TurnWheels(('A', "123")).Take(20).Print();
TurnWheels(('A', "1B2"), ('B', "34")).Take(20).Print();
TurnWheels(('A', "1DD"), ('D', "678")).Take(20).Pr... | 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, ", ... |
Produce a functionally identical AutoHotKey code for the snippet given in C#. | using System;
using System.Drawing;
using System.Windows.Forms;
class Program
{
static Color GetPixel(Point position)
{
using (var bitmap = new Bitmap(1, 1))
{
using (var graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(position, new Point... | PixelGetColor, color, %X%, %Y%
|
Convert the following code from C# to AutoHotKey, ensuring the logic remains intact. | using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Collections.Generic;
class YahooSearch {
private string query;
private string content;
private int page;
const string yahoo = "http:
public YahooSearch(string query) : this(query, 0) { }
public YahooSearch(str... | 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="... |
Translate this program into AutoHotKey but keep the logic exactly as in C#. | using System;
public class CirclesOfGivenRadiusThroughTwoPoints
{
public static void Main()
{
double[][] values = new double[][] {
new [] { 0.1234, 0.9876, 0.8765, 0.2345, 2 },
new [] { 0.0, 2.0, 0.0, 0.0, 1 },
new [] { 0.1234, 0.9876, 0.1234, 0.9876, ... | 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... |
Generate a AutoHotKey translation of this C# snippet without changing its computational steps. | using System;
public class CirclesOfGivenRadiusThroughTwoPoints
{
public static void Main()
{
double[][] values = new double[][] {
new [] { 0.1234, 0.9876, 0.8765, 0.2345, 2 },
new [] { 0.0, 2.0, 0.0, 0.0, 1 },
new [] { 0.1234, 0.9876, 0.1234, 0.9876, ... | 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... |
Can you help me rewrite this code in AutoHotKey instead of C#, keeping it the same logically? | using System;
namespace RosettaVampireNumber
{
class Program
{
static void Main(string[] args)
{
int i, j, n;
ulong x;
var f = new ulong[16];
var bigs = new ulong[] { 16758243290880UL, 24959017348650UL, 14593825548650UL, 0 };
ulong[] t... | 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
... |
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the C# version. | using System;
using System.Threading;
using System.Media;
class Program
{
static void Main(string[] args)
{
SoundPlayer s1 = new SoundPlayer();
s1.SoundLocation = file;
s1.Play();
s1.Play();
Thread.Sleep(100);
s1.Stop();
... | SoundPlay, %A_WinDir%\Media\tada.wav, wait
SoundPlay, %A_WinDir%\Media\Windows XP Startup.wav, wait
SoundPlay, %A_WinDir%\Media\tada.wav
SoundPlay, Nonexistent Β
SoundSet +10 Β
Loop, 2
SoundPlay, %A_WinDir%\Media\tada.wav, wait
|
Preserve the algorithm and functionality while converting the code from C# to AutoHotKey. | using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
public static class PokerHandAnalyzer
{
private enum Hand {
Invalid, High_Card, One_Pair, Two_Pair, Three_Of_A_Kind, Straight,
Flush, Full_House, Four_Of_A_Kind, Straight_Flush, Five_Of_A_Kind
}
private co... | 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... |
Can you help me rewrite this code in AutoHotKey instead of C#, keeping it the same logically? | using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
public static class PokerHandAnalyzer
{
private enum Hand {
Invalid, High_Card, One_Pair, Two_Pair, Three_Of_A_Kind, Straight,
Flush, Full_House, Four_Of_A_Kind, Straight_Flush, Five_Of_A_Kind
}
private co... | 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... |
Write the same algorithm in AutoHotKey as shown in this C# implementation. | using static System.Console;
using static System.Threading.Thread;
using System;
public static class PenneysGame
{
const int pause = 500;
const int N = 3;
static Random rng = new Random();
static int Toss() => rng.Next(2);
static string AsString(this int sequence) {
string s = "";
... | 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... |
Preserve the algorithm and functionality while converting the code from C# to AutoHotKey. | using System;
using System.Linq;
using System.Text;
public static class Nonoblock
{
public static void Main() {
Positions(5, 2,1);
Positions(5);
Positions(10, 8);
Positions(15, 2,3,2,3);
Positions(5, 2,3);
}
public static void Positions(int cells, params int[] block... |
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] ... |
Write the same code in AutoHotKey as shown below in C#. | using System;
using System.Linq;
using System.Text;
public static class Nonoblock
{
public static void Main() {
Positions(5, 2,1);
Positions(5);
Positions(10, 8);
Positions(15, 2,3,2,3);
Positions(5, 2,3);
}
public static void Positions(int cells, params int[] block... |
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 this C# block to AutoHotKey, preserving its control flow and logic. | using System;
namespace EbanNumbers {
struct Interval {
public int start, end;
public bool print;
public Interval(int start, int end, bool print) {
this.start = start;
this.end = end;
this.print = print;
}
}
class Program {
stati... | 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)
... |
Convert this C# block to AutoHotKey, preserving its control flow and logic. | using System;
namespace EbanNumbers {
struct Interval {
public int start, end;
public bool print;
public Interval(int start, int end, bool print) {
this.start = start;
this.end = end;
this.print = print;
}
}
class Program {
stati... | 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)
... |
Transform the following C# implementation into AutoHotKey, maintaining the same output and logic. | class Test
{
static bool 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);
}
static vo... | 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 "... |
Produce a functionally identical AutoHotKey code for the snippet given in C#. | class Test
{
static bool 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);
}
static vo... | 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 "... |
Write the same algorithm in AutoHotKey as shown in this C# implementation. | using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Threading;
namespace Polyspiral
{
public partial class Form1 : Form
{
private double inc;
public Form1()
{
Width = Height = 640;
StartPosition = ... | 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
... |
Generate an equivalent AutoHotKey version of this C# code. | using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Threading;
namespace Polyspiral
{
public partial class Form1 : Form
{
private double inc;
public Form1()
{
Width = Height = 640;
StartPosition = ... | 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
... |
Port the following code from C# to AutoHotKey with equivalent syntax and logic. | using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
public static class MergeAndAggregateDatasets
{
public static void Main()
{
string patientsCsv = @"
PATIENT_ID,LASTNAME
1001,Hopper
4004,Wirth
3003,Kemeny
2002,Gosling
5005... | Merge_and_aggregate(patients, visits){
ID := [], LAST_VISIT := [], SCORE_SUM := [], VISIT := []
for i, line in StrSplit(patients, "`n", "`r"){
if (i=1)
continue
x := StrSplit(line, ",")
ID[x.1] := x.2
}
for i, line in StrSplit(visits, "`n", "`r"){
if (i=1)
... |
Maintain the same structure and functionality when rewriting this code in AutoHotKey. |
var objDE = new System.DirectoryServices.DirectoryEntry("LDAP:
| objConn := CreateObject("ADODB.Connection")
objCmd := CreateObject("ADODB.Command")
objConn.Provider := "ADsDSOObject"
objConn.Open()
|
Transform the following C# implementation into AutoHotKey, maintaining the same output and logic. | using System;
class program
{
static void Main()
{
knapSack(40);
var sw = System.Diagnostics.Stopwatch.StartNew();
Console.Write(knapSack(400) + "\n" + sw.Elapsed);
Console.Read();
}
static string knapSack(uint w1)
{
init(); change();
uint n = (ui... | 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... |
Please provide an equivalent version of this C# code in AutoHotKey. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
hidatoMoves = {(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)};
priva... | 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... |
Write a version of this C# function in AutoHotKey with identical behavior. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
hidatoMoves = {(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)};
priva... | 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... |
Port the provided C# code into AutoHotKey while preserving the original functionality. | using System;
public static class Angles
{
public static void Main() => Print(-2, -1, 0, 1, 2, 6.2831853, 16, 57.2957795, 359, 6399, 1_000_000);
public static void Print(params double[] angles) {
string[] names = { "Degrees", "Gradians", "Mils", "Radians" };
Func<double, double> rnd = a => Mat... | testAngles := [-2, -1, 0, 1, 2, 6.2831853, 16, 57.2957795, 359, 399, 6399, 1000000]
result .= "Degrees Degrees Gradians Mils Radians`n"
for i, a in testAngles
result .= a "`t" Deg2Deg(a) "`t" Deg2Grad(a) "`t" Deg2Mil(a) "`t" Deg2Rad(a) "`n"
result .= "`nGradians Degrees Gradians Mils Radian... |
Port the provided C# code into AutoHotKey while preserving the original functionality. | XmlReader XReader;
XReader = XmlReader.Create(new StringReader("<inventory title=... </inventory>"));
XReader = XmlReader.Create("xmlfile.xml");
IXPathNavigable XDocument = new XPathDocument(XReader);
XPathNavigator Nav = XDocument.CreateNavigator();
Nav = Nav.SelectSingleNode("
if(Nav.MoveToFirst())
{
... | FileRead, inventory, xmlfile.xml
RegExMatch(inventory, "<item.*?</item>", item1)
MsgBox % item1
pos = 1
While, pos := RegExMatch(inventory, "<price>(.*?)</price>", price, pos + 1)
MsgBox % price1
While, pos := RegExMatch(inventory, "<name>.*?</name>", name, pos + 1)
names .= name . "`n"
MsgBox % names
|
Write the same algorithm in AutoHotKey as shown in this C# implementation. | using System;
using System.Net;
class Program
{
static void Main(string[] args)
{
var client = new WebClient();
client.Credentials = CredentialCache.DefaultCredentials;
client.Credentials = new NetworkCredential("User", "Password");
var data = client.Download... | iWeb_Init()
pwb := iWeb_newGui(0, 0, 1000, 800)
iWeb_nav(pwb, "http://www.facebook.com/login.php?ref=pf")
iWeb_Term()
iWeb_complete(pwb)
inputbox, email, email
inputbox, pass, password
iWeb_setDomObj(pwb,"Email",email)
iWeb_setDomObj(pwb,"pass",pass)
iWeb_clickDomObj(pwb, "login")
return
#Include iweb.ahk
#Include COM... |
Write the same algorithm in AutoHotKey as shown in this C# implementation. | using System;
using System.Collections.Generic;
using System.Linq;
namespace RankingMethods {
class Program {
static void Main(string[] args) {
Dictionary<string, int> scores = new Dictionary<string, int> {
["Solomon"] = 44,
["Jason"] = 42,
["Erro... | Rank(data, opt:=1){Β
for index, val in StrSplit(data, "`n", "`r") {
RegExMatch(val, "^(\d+)\s+(.*)", Match)
if !(Match1=prev)
n := index
prev := Match1
Res1 .= n "`t" Match "`n"
Res4 .= index "`t" Match "`n"
Temp .= n ":" index " " Match "`n"
}
n:=0
while pos := RegExMatch(Temp, "`asm)^(\d+).*?\R(?!\... |
Write the same algorithm in AutoHotKey as shown in this C# implementation. | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace StraddlingCheckerboard
{
class Program
{
public readonly static IReadOnlyDictionary<char, string> val2Key;
public readonly static IReadOnlyDictionary<string, char> key2Val;
... | board := "
(
ET AON RIS
BCDFGHJKLM
PQ/UVWXYZ.
)"
Text = One night-it was on the twentieth of March, 1888-I was returning
StringUpper, Text, Text
Text := RegExReplace(text, "[^A-Z0-9]")
Num2 := InStr(board, A_Space) -1
Num3 := InStr(board, A_Space, true, Num1+1) -1
Loop Parse, Text
{
char := A_LoopField
... |
Change the programming language of this snippet from C# to AutoHotKey without modifying what it does. | using System;
using System.Collections.Generic;
using System.IO;
namespace IBeforeE {
class Program {
static bool IsOppPlausibleWord(string word) {
if (!word.Contains("c") && word.Contains("ei")) {
return true;
}
if (word.Contains("cie")) {
... | WordList := URL_ToVar("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
WordList := RegExReplace(WordList, "i)cie", "", cieN)
WordList := RegExReplace(WordList, "i)cei", "", ceiN)
RegExReplace(WordList, "i)ie", "", ieN)
RegExReplace(WordList, "i)ei", "", eiN)
cei := ceiN / cieN > 2 ? "plausible" : "implausible"
... |
Change the programming language of this snippet from C# to AutoHotKey without modifying what it does. | using System;
using System.Collections.Generic;
using System.IO;
namespace IBeforeE {
class Program {
static bool IsOppPlausibleWord(string word) {
if (!word.Contains("c") && word.Contains("ei")) {
return true;
}
if (word.Contains("cie")) {
... | WordList := URL_ToVar("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt")
WordList := RegExReplace(WordList, "i)cie", "", cieN)
WordList := RegExReplace(WordList, "i)cei", "", ceiN)
RegExReplace(WordList, "i)ie", "", ieN)
RegExReplace(WordList, "i)ei", "", eiN)
cei := ceiN / cieN > 2 ? "plausible" : "implausible"
... |
Please provide an equivalent version of this C# code in AutoHotKey. | using System.Diagnostics;
namespace RC
{
internal class Program
{
public static void Main()
{
string sSource = "Sample App";
string sLog = "Application";
string sEvent = "Hello from RC!";
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);... |
h := RegisterForEvents("AutoHotkey")
SendWinLogEvent(h, "Test Message")
DeregisterForEvents(h)
SendWinLogEvent(hSource, String="", evType=0x0004, evId=0x03EA, evCat=0, pData=0) {
Ptr := A_PtrSize ? "Ptr" : "UInt"
LPCtSTRs := A_PtrSize ? "Ptr*" : "UInt"
StringPut := A_IsUnicode ? "StrPut" : "StrPut2"
VarSetCap... |
Preserve the algorithm and functionality while converting the code from C# to AutoHotKey. | using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
Circle circle = ((3, -5), 3);
Line[] lines = {
((-10, 11), (10, -9)),
((-10, 11), (-11, 12), true),
((3, -2), (7, -2))
};
Pri... | data := [[[3, -5], 3, [-10, 11], [10, -9], 0]
, [[3, -5], 3, [-10, 11], [-11, 12], 1]
, [[3, -5], 3, [3, -2], [7, -2], 1]
, [[0, 0], 4, [0, -3], [0, 6], 0]
, [[0, 0], 4, [0, -3], [0, 6], 1]
, [[4, 2], 5, [6, 3], [10,... |
Rewrite this program in AutoHotKey while keeping its functionality equivalent to the C# version. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
hopidoMoves = {(-3,0),(0,-3),(0,3),(3,0),(-2,-2),(-2,2),(2,-2),(2,2)},
priva... | SolveHopido(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(loc... |
Ensure the translated AutoHotKey code behaves exactly like the original C# snippet. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
hopidoMoves = {(-3,0),(0,-3),(0,3),(3,0),(-2,-2),(-2,2),(2,-2),(2,2)},
priva... | SolveHopido(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(loc... |
Translate the given C# code snippet into AutoHotKey without altering its behavior. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
numbrixMoves = {(1,0),(0,1),(-1,0),(0,-1)};
private (int dx, int dy)[] moves... | SolveNumbrix(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... |
Keep all operations the same but rewrite the snippet in AutoHotKey. | using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static System.Linq.Enumerable;
public class Solver
{
private static readonly (int dx, int dy)[]
numbrixMoves = {(1,0),(0,1),(-1,0),(0,-1)};
private (int dx, int dy)[] moves... | SolveNumbrix(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 C# to AutoHotKey, same semantics. | using System;
using System.Dynamic;
class Example : DynamicObject
{
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
result = null;
Console.WriteLine("This is {0}.", binder.Name);
return true;
}
}
class Program
{
static void M... | class example
{
foo()
{
Msgbox Called example.foo()
}
__Call(method, params*)
{
funcRef := Func(funcName := this.__class "." method)
if !IsObject(funcRef)
{
str := "Called undefined method " funcName "() with these parameters:"
for k,v in params
str .= "`n" v
Msgbox ... |
Produce a functionally identical AutoHotKey code for the snippet given in C#. | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChemicalCalculator {
class Program {
static Dictionary<string, double> atomicMass = new Dictionary<string, double>() {
{"H", 1.008 },
{"He", 4.002602}... | test := ["H", "H2", "H2O", "H2O2", "(HO)2", "Na2SO4", "C6H12", "COOH(C(CH3)2)3CH3", "C6H4O2(OH)4", "C27H46O"
, "Uue", "C6H4O2(O)H)4", "X2O"]
for i, str in test
result .= str "`t`t`t> " Chemical_calculator(str) "`n"
MsgBox, 262144, , % result
return
Chemical_calculator(str){
if (RegExReplace(str, "\(([^... |
Write a version of this Python function in REXX with identical behavior. | infile = open('infile.dat', 'rb')
outfile = open('outfile.dat', 'wb')
while True:
onerecord = infile.read(80)
if len(onerecord) < 80:
break
onerecordreversed = bytes(reversed(onerecord))
outfile.write(onerecordreversed)
infile.close()
outfile.close()
|
iFID= 'FIXEDLEN.TXT'
call charin iFID, 1, 0
do j=1 while chars(iFID) >= 80
@.j= charin(iFID, , 80)
end
#= j - 1
... |
Can you help me rewrite this code in REXX instead of Python, keeping it the same logically? | import urllib.request
urllib.request.urlretrieve("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", "unixdict.txt")
dictionary = open("unixdict.txt","r")
wordList = dictionary.read().split('\n')
dictionary.close()
for word in wordList:
if len(word)>5 and word[:3].lower()==word[-3:].lower():
print(wo... |
parse arg minL many iFID .
if minL=='' | minL=="," then minL= 6
if many=='' | many=="," then many= 3
if iFID=='' | iFID=="," then iFID='unixdict.txt'
do #=1 while lines(iFID)\==0
x= strip( linein( iFID) )
@.#=... |
Write the same algorithm in REXX as shown in this Python implementation. | print('\n'.join((f'{x[0]}: {" ".join(sorted(x[1]))}' if len(x[1]) < 30 else f'{x[0]}: {len(x[1])} words' for x in
(x for x in ((n, [x[1] for x in l if x[0] == n]) for n in range(maxlen, -1, -1)) if x[1]))) if (maxlen := max(l := [(len(c), w)
for w in [l for l in [l.rstrip() for l in open('unixdict.txt')] if... |
parse arg minl iFID .
if minl=='' | minl=="," then minl= 11
if iFID=='' | iFID=="," then iFID='unixdict.txt'
do #=1 while lines(iFID)\==0
x= strip( linein( iFID) )
@.#= x
end
... |
Transform the following Python implementation into REXX, maintaining the same output and logic. | import urllib.request
from collections import Counter
urllib.request.urlretrieve("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", "unixdict.txt")
dictionary = open("unixdict.txt","r")
wordList = dictionary.read().split('\n')
dictionary.close()
for word in wordList:
if len(word)>10:
frequency = Co... |
parse arg minL iFID .
if minL=='' | minL=="," then minL= 11
if iFID=='' | iFID=="," then iFID='unixdict.txt'
@.=
do #=1 while lines(iFID)\==0
x= strip( linein( iFID) )
$.#= x ... |
Maintain the same structure and functionality when rewriting this code in REXX. |
import urllib.request
urllib.request.urlretrieve("http://wiki.puzzlers.org/pub/wordlists/unixdict.txt", "unixdict.txt")
dictionary = open("unixdict.txt","r")
wordList = dictionary.read().split('\n')
dictionary.close()
oddWordSet = set({})
for word in wordList:
if len(word)>=9 and word[::2] in wordList:
... |
fid='d:\unix.txt'
ww.=0
w.=0
Do While lines(fid)>0
l=linein(fid)
ll=length(l)
w.l=1
If ll>=9 Then Do
z=ww.0+1
ww.z=l
ww.0=z
End
End
n=0
Do i=1 To ww.0
wodd=wodd(ww.i)
If w.wodd Then Do
n=n+1
Say format(n,3) left(ww.i,10) wodd
End
End
Exit
w... |
Transform the following Python implementation into REXX, maintaining the same output and logic. | import random
from typing import List, Callable, Optional
def modifier(x: float) -> float:
return 2*(.5 - x) if x < 0.5 else 2*(x - .5)
def modified_random_distribution(modifier: Callable[[float], float],
n: int) -> List[float]:
d: List[float] = []
while len(d)... |
parse arg randn bins seed .
if randN=='' | randN=="," then randN= 100000
if bins=='' | bins=="," then bins= 20
if datatype(seed, 'W') then call random ,,seed
call MRD
!.= 0
do j=1 for randN; bin= @.j*bins%1
!.bin= !.bin + 1
end ... |
Change the programming language of this snippet from Python to REXX without modifying what it does. | import random
from typing import List, Callable, Optional
def modifier(x: float) -> float:
return 2*(.5 - x) if x < 0.5 else 2*(x - .5)
def modified_random_distribution(modifier: Callable[[float], float],
n: int) -> List[float]:
d: List[float] = []
while len(d)... |
parse arg randn bins seed .
if randN=='' | randN=="," then randN= 100000
if bins=='' | bins=="," then bins= 20
if datatype(seed, 'W') then call random ,,seed
call MRD
!.= 0
do j=1 for randN; bin= @.j*bins%1
!.bin= !.bin + 1
end ... |
Maintain the same structure and functionality when rewriting this code in REXX. |
def common_list_elements(*lists):
return list(set.intersection(*(set(list_) for list_ in lists)))
if __name__ == "__main__":
test_cases = [
([2, 5, 1, 3, 8, 9, 4, 6], [3, 5, 6, 2, 9, 8, 4], [1, 3, 7, 6, 9]),
([2, 2, 1, 3, 8, 9, 4, 6], [3, 5, 6, 2, 2, 2, 4], [2, 3, 7, 6, 2]),
]
for c... |
parse arg a
if a='' | a="," then a= '[2,5,1,3,8,9,4,6] [3,5,6,2,9,8,4] [1,3,7,6,9]'
#= words(a)
do j=1 for #
@.j= translate( word(a, j), ,'],[')
end
$= ... |
Port the provided Python code into REXX while preserving the original functionality. |
def common_list_elements(*lists):
return list(set.intersection(*(set(list_) for list_ in lists)))
if __name__ == "__main__":
test_cases = [
([2, 5, 1, 3, 8, 9, 4, 6], [3, 5, 6, 2, 9, 8, 4], [1, 3, 7, 6, 9]),
([2, 2, 1, 3, 8, 9, 4, 6], [3, 5, 6, 2, 2, 2, 4], [2, 3, 7, 6, 2]),
]
for c... |
parse arg a
if a='' | a="," then a= '[2,5,1,3,8,9,4,6] [3,5,6,2,9,8,4] [1,3,7,6,9]'
#= words(a)
do j=1 for #
@.j= translate( word(a, j), ,'],[')
end
$= ... |
Convert the following code from Python to REXX, ensuring the logic remains intact. | while 1:
print "SPAM"
|
options replace format comments java crossref savelog symbols nobinary
say
say 'Loops/Infinite'
loop label spam forever
say 'SPAM'
end spam
|
Transform the following Python implementation into REXX, maintaining the same output and logic. | import math
rotate_amounts = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15,... | #!/usr/bin/rexx
0xd41d8cd98f00b204e9800998ecf8427e <== ""
0x0cc175b9c0f1b6a831c399e269772661 <== "a"
0x900150983cd24fb0d6963f7d28e17f72 <== "abc"
0xf96b697d7cb7938d525a2f31aaf161d0 <== "message digest"
0xc3fcd3d76192e4007dfb496cca67e13b <== "abcdefghijklmnopqrstuvwxyz"
0xd174ab98d277d9f5a5611c2c9f... |
Generate a REXX translation of this Python snippet without changing its computational steps. | from itertools import product
xx = '-5 +5'.split()
pp = '2 3'.split()
texts = '-x**p -(x)**p (-x)**p -(x**p)'.split()
print('Integer variable exponentiation')
for x, p in product(xx, pp):
print(f' x,p = {x:2},{p}; ', end=' ')
x, p = int(x), int(p)
print('; '.join(f"{t} =={eval(t):4}" for t in texts))
pr... |
_= 'β'; ! = 'β'; mJunct= 'ββ«β'; bJunct= 'ββ¨β'
say @(' x ', 5) @(" p ", 5) !
say @('value', 5) @("value", 5) copies(! @('expression',10) @("result",6)" ", 4)
say @('' , 5, _) @("", 5, _)copies(mJunct || @('', 10, _) @("", 6, _) , 4)
do x=-5 to 5 by 10 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.