Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Rewrite this program in Python while keeping its functionality equivalent to the Perl version. | use Crypt::Random::Seed;
my $source = Crypt::Random::Seed->new( NonBlocking => 1 );
print "$_\n" for $source->random_values(10);
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Transform the following Perl implementation into Go, maintaining the same output and logic. | use Crypt::Random::Seed;
my $source = Crypt::Random::Seed->new( NonBlocking => 1 );
print "$_\n" for $source->random_values(10);
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Convert the following code from Perl to Go, ensuring the logic remains intact. | use Crypt::Random::Seed;
my $source = Crypt::Random::Seed->new( NonBlocking => 1 );
print "$_\n" for $source->random_values(10);
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Change the following PowerShell code into C without altering its purpose. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Preserve the algorithm and functionality while converting the code from PowerShell to C. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Maintain the same structure and functionality when rewriting this code in C#. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Convert this PowerShell snippet to C# and keep its semantics consistent. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Generate an equivalent C++ version of this PowerShell code. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Write the same code in C++ as shown below in PowerShell. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Ensure the translated Java code behaves exactly like the original PowerShell snippet. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Generate a Java translation of this PowerShell snippet without changing its computational steps. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Port the following code from PowerShell to Python with equivalent syntax and logic. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Convert this PowerShell snippet to Python and keep its semantics consistent. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Produce a functionally identical Go code for the snippet given in PowerShell. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Convert this PowerShell snippet to Go and keep its semantics consistent. | function Get-RandomInteger
{
Param
(
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[ValidateScript({$_ -ge 4})]
[int[]]
$InputObject = 64
)
Begin
{
... | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Rewrite this program in C while keeping its functionality equivalent to the Racket version. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Change the programming language of this snippet from Racket to C without modifying what it does. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Can you help me rewrite this code in C# instead of Racket, keeping it the same logically? | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Produce a functionally identical C# code for the snippet given in Racket. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Write the same code in C++ as shown below in Racket. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Change the following Racket code into C++ without altering its purpose. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Transform the following Racket implementation into Java, maintaining the same output and logic. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Change the programming language of this snippet from Racket to Java without modifying what it does. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Produce a language-to-language conversion: from Racket to Python, same semantics. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Write a version of this Racket function in Python with identical behavior. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Keep all operations the same but rewrite the snippet in Go. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Port the provided Racket code into Go while preserving the original functionality. | #lang racket
(call-with-input-file* "/dev/random"
(λ(i) (integer-bytes->integer (read-bytes 4 i) #f)))
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Port the following code from REXX to C with equivalent syntax and logic. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Convert this REXX snippet to C and keep its semantics consistent. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Write a version of this REXX function in C# with identical behavior. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Maintain the same structure and functionality when rewriting this code in C#. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Maintain the same structure and functionality when rewriting this code in C++. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Convert this REXX block to C++, preserving its control flow and logic. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Port the provided REXX code into Java while preserving the original functionality. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Rewrite this program in Java while keeping its functionality equivalent to the REXX version. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Translate the given REXX code snippet into Python without altering its behavior. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Port the following code from REXX to Python with equivalent syntax and logic. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Port the following code from REXX to Go with equivalent syntax and logic. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Translate this program into Go but keep the logic exactly as in REXX. |
options replace format comments java crossref savelog symbols binary
import java.math.BigInteger
randomDevNameFile = File
randomDevNameList = ['/dev/random', '/dev/urandom'] -- list of random data source devices
randomDevIStream = InputStream
do
loop dn = 0 to randomDevNameList.length - 1
randomDevNameFile = F... | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Change the following Ruby code into C without altering its purpose. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Port the following code from Ruby to C with equivalent syntax and logic. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Produce a language-to-language conversion: from Ruby to C#, same semantics. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Convert this Ruby snippet to C# and keep its semantics consistent. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Can you help me rewrite this code in C++ instead of Ruby, keeping it the same logically? | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Maintain the same structure and functionality when rewriting this code in C++. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Write the same algorithm in Java as shown in this Ruby implementation. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Write the same code in Java as shown below in Ruby. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Generate a Python translation of this Ruby snippet without changing its computational steps. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Maintain the same structure and functionality when rewriting this code in Python. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Port the provided Ruby code into Go while preserving the original functionality. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Ensure the translated Go code behaves exactly like the original Ruby snippet. | require 'securerandom'
SecureRandom.random_number(1 << 32)
p (1..10).to_a.sample(3, random: SecureRandom)
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Translate this program into C but keep the logic exactly as in Scala. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Can you help me rewrite this code in C instead of Scala, keeping it the same logically? |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Change the programming language of this snippet from Scala to C# without modifying what it does. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Convert the following code from Scala to C#, ensuring the logic remains intact. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Ensure the translated C++ code behaves exactly like the original Scala snippet. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Can you help me rewrite this code in C++ instead of Scala, keeping it the same logically? |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Port the following code from Scala to Java with equivalent syntax and logic. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Convert the following code from Scala to Java, ensuring the logic remains intact. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Translate this program into Python but keep the logic exactly as in Scala. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Can you help me rewrite this code in Python instead of Scala, keeping it the same logically? |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Convert the following code from Scala to Go, ensuring the logic remains intact. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Maintain the same structure and functionality when rewriting this code in Go. |
import java.security.SecureRandom
fun main(args: Array<String>) {
val rng = SecureRandom()
val rn1 = rng.nextInt()
val rn2 = rng.nextInt()
val newSeed = rn1.toLong() * rn2
rng.setSeed(newSeed)
println(rng.nextInt())
}
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Please provide an equivalent version of this Tcl code in C. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Convert this Tcl block to C, preserving its control flow and logic. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... |
Convert this Tcl snippet to C# and keep its semantics consistent. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Translate the given Tcl code snippet into C# without altering its behavior. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
|
Write the same code in C++ as shown below in Tcl. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Translate the given Tcl code snippet into C++ without altering its behavior. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
|
Produce a functionally identical Java code for the snippet given in Tcl. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Translate the given Tcl code snippet into Java without altering its behavior. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
|
Produce a functionally identical Python code for the snippet given in Tcl. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Maintain the same structure and functionality when rewriting this code in Python. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Generate an equivalent Go version of this Tcl code. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Port the provided Tcl code into Go while preserving the original functionality. | package require Tcl 8.5
proc systemRandomInteger {{device "/dev/random"}} {
set f [open $device "rb"]
binary scan [read $f 4] "I" x
close $f
return $x
}
| package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... |
Please provide an equivalent version of this C code in Rust. | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Produce a language-to-language conversion: from C to Rust, same semantics. | #include <stdio.h>
#include <stdlib.h>
#define RANDOM_PATH "/dev/urandom"
int main(void)
{
unsigned char buf[4];
unsigned long v;
FILE *fin;
if ((fin = fopen(RANDOM_PATH, "r")) == NULL) {
fprintf(stderr, "%s: unable to open file\n", RANDOM_PATH);
return... | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Transform the following C++ implementation into Rust, maintaining the same output and logic. | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Generate an equivalent Rust version of this Java code. | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Port the following code from Go to Rust with equivalent syntax and logic. | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Convert this Rust snippet to Python and keep its semantics consistent. | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Write the same code in Python as shown below in Rust. | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
| import random
rand = random.SystemRandom()
rand.randint(1,10)
|
Translate the given C# code snippet into Rust without altering its behavior. | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Please provide an equivalent version of this Go code in Rust. | package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
)
func main() {
testRandom("crypto/rand", rand.Reader)
testRandom("dev/random", newDevRandom())
}
func newDevRandom() (f *os.File) {
var err error
if f, err = os.Open("/dev/random"); err != nil {
panic(e... | extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Write a version of this C++ function in Rust with identical behavior. | #include <iostream>
#include <random>
int main()
{
std::random_device rd;
std::uniform_int_distribution<long> dist;
std::cout << "Random Number: " << dist(rd) << std::endl;
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Generate a Rust translation of this C# snippet without changing its computational steps. | using System;
using System.Security.Cryptography;
private static int GetRandomInt()
{
int result = 0;
var rng = new RNGCryptoServiceProvider();
var buffer = new byte[4];
rng.GetBytes(buffer);
result = BitConverter.ToInt32(buffer, 0);
return result;
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Transform the following Java implementation into Rust, maintaining the same output and logic. | import java.security.SecureRandom;
public class RandomExample {
public static void main(String[] args) {
SecureRandom rng = new SecureRandom();
System.out.println(rng.nextInt());
}
}
| extern crate rand;
use rand::{OsRng, Rng};
fn main() {
let mut rng = match OsRng::new() {
Ok(v) => v,
Err(e) => panic!("Failed to obtain OS RNG: {}", e)
};
let rand_num: u32 = rng.gen();
println!("{}", rand_num);
}
|
Translate this program into C# but keep the logic exactly as in Ada. | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | using System;
using System.Numerics;
using System.Text;
class Program
{
static void Main(string[] args)
{
BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357");
BigInteger e = 65537;
BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");... |
Translate this program into C but keep the logic exactly as in Ada. | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>
int main(void)
{
mpz_t n, d, e, pt, ct;
mpz_init(pt);
mpz_init(ct);
mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10);
mpz_init_set_str(e, "65537", 10);
mpz_init_set_str(d, "56178431878449531703084... |
Write the same code in Go as shown below in Ada. | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | package main
import (
"fmt"
"math/big"
)
func main() {
var n, e, d, bb, ptn, etn, dtn big.Int
pt := "Rosetta Code"
fmt.Println("Plain text: ", pt)
n.SetString("9516311845790656153499716760847001433441357", 10)
e.SetString("65537", 10)
d.SetString("56178431878... |
Can you help me rewrite this code in Java instead of Ada, keeping it the same logically? | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | public static void main(String[] args) {
BigInteger n = new BigInteger("9516311845790656153499716760847001433441357");
BigInteger e = new BigInteger("65537");
BigInteger d = new BigInteger("5617843187844953170308463622230283376298685");
Charset c = Charsets.UTF_8;
String plainText = "Rosetta Co... |
Change the programming language of this snippet from Ada to Python without modifying what it does. | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | import binascii
n = 9516311845790656153499716760847001433441357
e = 65537
d = 5617843187844953170308463622230283376298685
message='Rosetta Code!'
print('message ', message)
hex_data = binascii.hexlify(message.encode())
print('hex data ', hex_data)
plain_text = int(hex_data, 16)
... |
Produce a functionally identical VB code for the snippet given in Ada. | WITH GMP, GMP.Integers, Ada.Text_IO, GMP.Integers.Aliased_Internal_Value, Interfaces.C;
USE GMP, Gmp.Integers, Ada.Text_IO, Interfaces.C;
PROCEDURE Main IS
FUNCTION "+" (U : Unbounded_Integer) RETURN Mpz_T IS (Aliased_Internal_Value (U));
FUNCTION "+" (S : String) RETURN Unbounded_Integer IS (To_Unbounded_Intege... | Imports System
Imports System.Numerics
Imports System.Text
Module Module1
Sub Main()
Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357")
Dim e As BigInteger = 65537
Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685")
... |
Rewrite the snippet below in C so it works the same as the original Common_Lisp code. | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>
int main(void)
{
mpz_t n, d, e, pt, ct;
mpz_init(pt);
mpz_init(ct);
mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10);
mpz_init_set_str(e, "65537", 10);
mpz_init_set_str(d, "56178431878449531703084... |
Keep all operations the same but rewrite the snippet in C#. | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | using System;
using System.Numerics;
using System.Text;
class Program
{
static void Main(string[] args)
{
BigInteger n = BigInteger.Parse("9516311845790656153499716760847001433441357");
BigInteger e = 65537;
BigInteger d = BigInteger.Parse("5617843187844953170308463622230283376298685");... |
Please provide an equivalent version of this Common_Lisp code in Java. | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | public static void main(String[] args) {
BigInteger n = new BigInteger("9516311845790656153499716760847001433441357");
BigInteger e = new BigInteger("65537");
BigInteger d = new BigInteger("5617843187844953170308463622230283376298685");
Charset c = Charsets.UTF_8;
String plainText = "Rosetta Co... |
Can you help me rewrite this code in Python instead of Common_Lisp, keeping it the same logically? | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | import binascii
n = 9516311845790656153499716760847001433441357
e = 65537
d = 5617843187844953170308463622230283376298685
message='Rosetta Code!'
print('message ', message)
hex_data = binascii.hexlify(message.encode())
print('hex data ', hex_data)
plain_text = int(hex_data, 16)
... |
Port the provided Common_Lisp code into VB while preserving the original functionality. | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | Imports System
Imports System.Numerics
Imports System.Text
Module Module1
Sub Main()
Dim n As BigInteger = BigInteger.Parse("9516311845790656153499716760847001433441357")
Dim e As BigInteger = 65537
Dim d As BigInteger = BigInteger.Parse("5617843187844953170308463622230283376298685")
... |
Rewrite this program in Go while keeping its functionality equivalent to the Common_Lisp version. | (defparameter *n* 9516311845790656153499716760847001433441357)
(defparameter *e* 65537)
(defparameter *d* 5617843187844953170308463622230283376298685)
(defun encode-string (message)
(parse-integer (reduce #'(lambda (x y) (concatenate 'string x y))
(loop for c across message collect (format nil "~2,'0d" (- (ch... | package main
import (
"fmt"
"math/big"
)
func main() {
var n, e, d, bb, ptn, etn, dtn big.Int
pt := "Rosetta Code"
fmt.Println("Plain text: ", pt)
n.SetString("9516311845790656153499716760847001433441357", 10)
e.SetString("65537", 10)
d.SetString("56178431878... |
Convert this D block to C, preserving its control flow and logic. | void main() {
import std.stdio, std.bigint, std.algorithm, std.string, std.range,
modular_exponentiation;
immutable txt = "Rosetta Code";
writeln("Plain text: ", txt);
immutable BigInt n = "2463574872878749457479".BigInt *
"386280601842257... | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gmp.h>
int main(void)
{
mpz_t n, d, e, pt, ct;
mpz_init(pt);
mpz_init(ct);
mpz_init_set_str(n, "9516311845790656153499716760847001433441357", 10);
mpz_init_set_str(e, "65537", 10);
mpz_init_set_str(d, "56178431878449531703084... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.