Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Produce a functionally identical PHP code for the snippet given in Julia. | using Printf
function findsolution(rng=1:7)
rst = Matrix{Int}(0, 3)
for p in rng, f in rng, s in rng
if p != s != f != p && p + s + f == 12 && iseven(p)
rst = [rst; p s f]
end
end
return rst
end
function printsolutions(sol::Matrix{Int})
println(" Pol. Fire San.... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Translate the given Lua code snippet into PHP without altering its behavior. | print( "Fire", "Police", "Sanitation" )
sol = 0
for f = 1, 7 do
for p = 1, 7 do
for s = 1, 7 do
if s + p + f == 12 and p % 2 == 0 and f ~= p and f ~= s and p ~= s then
print( f, p, s ); sol = sol + 1
end
end
end
end
print( string.format( "\n%d solutions fo... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Write a version of this Lua function in PHP with identical behavior. | print( "Fire", "Police", "Sanitation" )
sol = 0
for f = 1, 7 do
for p = 1, 7 do
for s = 1, 7 do
if s + p + f == 12 and p % 2 == 0 and f ~= p and f ~= s and p ~= s then
print( f, p, s ); sol = sol + 1
end
end
end
end
print( string.format( "\n%d solutions fo... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Change the following Mathematica code into PHP without altering its purpose. | Select[Permutations[Range[7], {3}], Total[#] == 12 && EvenQ[First[#]] &]
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Ensure the translated PHP code behaves exactly like the original Mathematica snippet. | Select[Permutations[Range[7], {3}], Total[#] == 12 && EvenQ[First[#]] &]
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Port the provided Nim code into PHP while preserving the original functionality. | type Solution = tuple[p, s, f: int]
iterator solutions(max, total: Positive): Solution =
for p in countup(2, max, 2):
for s in 1..max:
if s == p: continue
let f = total - p - s
if f notin [p, s] and f in 1..max:
yield (p, s, f)
echo "P S F"
for sol in solutions(7, 12):
echo sol.p, " ... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this Nim block to PHP, preserving its control flow and logic. | type Solution = tuple[p, s, f: int]
iterator solutions(max, total: Positive): Solution =
for p in countup(2, max, 2):
for s in 1..max:
if s == p: continue
let f = total - p - s
if f notin [p, s] and f in 1..max:
yield (p, s, f)
echo "P S F"
for sol in solutions(7, 12):
echo sol.p, " ... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Can you help me rewrite this code in PHP instead of OCaml, keeping it the same logically? |
type sfp = {s : int; f : int; p : int}
let print_sfp e =
Printf.printf "%d %d %d\n" e.s e.f e.p
let print_sfp_list l =
l |> List.iter print_sfp
let sum l = List.fold_left (+) 0 l
let element_in_list e l =
l |> List.find_map (fun x -> if x == e then Some(e) else None) <> None
let uniq l =
l... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Change the programming language of this snippet from OCaml to PHP without modifying what it does. |
type sfp = {s : int; f : int; p : int}
let print_sfp e =
Printf.printf "%d %d %d\n" e.s e.f e.p
let print_sfp_list l =
l |> List.iter print_sfp
let sum l = List.fold_left (+) 0 l
let element_in_list e l =
l |> List.find_map (fun x -> if x == e then Some(e) else None) <> None
let uniq l =
l... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this Perl block to PHP, preserving its control flow and logic. |
my @even_numbers;
for (1..7)
{
if ( $_ % 2 == 0)
{
push @even_numbers, $_;
}
}
print "Police\tFire\tSanitation\n";
foreach my $police_number (@even_numbers)
{
for my $fire_number (1..7)
{
for my $sanitation_number (1..7)
{
if ( $police_number + $fire_number + $sanitation_number == 12 &... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this Perl block to PHP, preserving its control flow and logic. |
my @even_numbers;
for (1..7)
{
if ( $_ % 2 == 0)
{
push @even_numbers, $_;
}
}
print "Police\tFire\tSanitation\n";
foreach my $police_number (@even_numbers)
{
for my $fire_number (1..7)
{
for my $sanitation_number (1..7)
{
if ( $police_number + $fire_number + $sanitation_number == 12 &... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this Racket block to PHP, preserving its control flow and logic. | #lang racket
(cons '(police fire sanitation)
(filter (Ξ» (pfs) (and (not (check-duplicates pfs))
(= 12 (apply + pfs))
pfs))
(cartesian-product (range 2 8 2) (range 1 8) (range 1 8))))
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Change the programming language of this snippet from Racket to PHP without modifying what it does. | #lang racket
(cons '(police fire sanitation)
(filter (Ξ» (pfs) (and (not (check-duplicates pfs))
(= 12 (apply + pfs))
pfs))
(cartesian-product (range 2 8 2) (range 1 8) (range 1 8))))
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Maintain the same structure and functionality when rewriting this code in PHP. | IDENTIFICATION DIVISION.
PROGRAM-ID. DEPARTMENT-NUMBERS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 BANNER PIC X(24) VALUE "POLICE SANITATION FIRE".
01 COMBINATION.
03 FILLER PIC X(5) VALUE SPACES.
03 POLICE PIC 9.
03 FILL... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Change the following COBOL code into PHP without altering its purpose. | IDENTIFICATION DIVISION.
PROGRAM-ID. DEPARTMENT-NUMBERS.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 BANNER PIC X(24) VALUE "POLICE SANITATION FIRE".
01 COMBINATION.
03 FILLER PIC X(5) VALUE SPACES.
03 POLICE PIC 9.
03 FILL... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this REXX snippet to PHP and keep its semantics consistent. |
say 'police sanitation fire'
say 'ββββββ ββββββββββ ββββ'
#=0
do p=1 for 7; if p//2 then iterate
do s=1 for 7; if s==p then iterate
do f=1 for 7; if f==s then iterate
if p + s + ... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Generate an equivalent PHP version of this REXX code. |
say 'police sanitation fire'
say 'ββββββ ββββββββββ ββββ'
#=0
do p=1 for 7; if p//2 then iterate
do s=1 for 7; if s==p then iterate
do f=1 for 7; if f==s then iterate
if p + s + ... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Maintain the same structure and functionality when rewriting this code in PHP. | (1..7).to_a.permutation(3){|p| puts p.join if p.first.even? && p.sum == 12 }
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Port the following code from Ruby to PHP with equivalent syntax and logic. | (1..7).to_a.permutation(3){|p| puts p.join if p.first.even? && p.sum == 12 }
| <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Write the same algorithm in PHP as shown in this Scala implementation. |
fun main(args: Array<String>) {
println("Police Sanitation Fire")
println("------ ---------- ----")
var count = 0
for (i in 2..6 step 2) {
for (j in 1..7) {
if (j == i) continue
for (k in 1..7) {
if (k == i || k == j) continue
if (i +... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Please provide an equivalent version of this Scala code in PHP. |
fun main(args: Array<String>) {
println("Police Sanitation Fire")
println("------ ---------- ----")
var count = 0
for (i in 2..6 step 2) {
for (j in 1..7) {
if (j == i) continue
for (k in 1..7) {
if (k == i || k == j) continue
if (i +... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Convert this Swift snippet to PHP and keep its semantics consistent. | let res = [2, 4, 6].map({x in
return (1...7)
.filter({ $0 != x })
.map({y -> (Int, Int, Int)? in
let z = 12 - (x + y)
guard y != z && 1 <= z && z <= 7 else {
return nil
}
return (x, y, z)
}).compactMap({ $0 })
}).flatMap({ $0 })
for result in res {
prin... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Port the provided Swift code into PHP while preserving the original functionality. | let res = [2, 4, 6].map({x in
return (1...7)
.filter({ $0 != x })
.map({y -> (Int, Int, Int)? in
let z = 12 - (x + y)
guard y != z && 1 <= z && z <= 7 else {
return nil
}
return (x, y, z)
}).compactMap({ $0 })
}).flatMap({ $0 })
for result in res {
prin... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Rewrite the snippet below in PHP so it works the same as the original Tcl code. |
proc .. max {
for {set i 1} {$i <= $max} {incr i} {
lappend l $i
}
return $l
}
proc anyEqual l {
if {[llength [lsort -unique $l]] != [llength $l]} {
return 1
}
return 0
}
proc odd n {
expr $n %2 != 0
}
proc sum args {
expr [join $args +]
}
set sanitation [.. 7]
set fire $sanitation
... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Can you help me rewrite this code in PHP instead of Tcl, keeping it the same logically? |
proc .. max {
for {set i 1} {$i <= $max} {incr i} {
lappend l $i
}
return $l
}
proc anyEqual l {
if {[llength [lsort -unique $l]] != [llength $l]} {
return 1
}
return 0
}
proc odd n {
expr $n %2 != 0
}
proc sum args {
expr [join $args +]
}
set sanitation [.. 7]
set fire $sanitation
... | <?php
$valid = 0;
for ($police = 2 ; $police <= 6 ; $police += 2) {
for ($sanitation = 1 ; $sanitation <= 7 ; $sanitation++) {
$fire = 12 - $police - $sanitation;
if ((1 <= $fire) and ($fire <= 7) and ($police != $sanitation) and ($sanitation != $fire)) {
echo 'Police: ', $police, ', Sa... |
Change the following C code into Rust without altering its purpose. | #include<stdio.h>
int main()
{
int police,sanitation,fire;
printf("Police Sanitation Fire\n");
printf("----------------------------------");
for(police=2;police<=6;police+=2){
for(sanitation=1;sanitation<=7;sanitation++){
for(fire=1;fire<=7;fire++){
if(police!=sanitation && sanitation!=fir... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Port the following code from C++ to Rust with equivalent syntax and logic. | #include <iostream>
#include <iomanip>
int main( int argc, char* argv[] ) {
int sol = 1;
std::cout << "\t\tFIRE\t\tPOLICE\t\tSANITATION\n";
for( int f = 1; f < 8; f++ ) {
for( int p = 1; p < 8; p++ ) {
for( int s = 1; s < 8; s++ ) {
if( f != p && f != s && p != s && !( p... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Write the same algorithm in Rust as shown in this C++ implementation. | #include <iostream>
#include <iomanip>
int main( int argc, char* argv[] ) {
int sol = 1;
std::cout << "\t\tFIRE\t\tPOLICE\t\tSANITATION\n";
for( int f = 1; f < 8; f++ ) {
for( int p = 1; p < 8; p++ ) {
for( int s = 1; s < 8; s++ ) {
if( f != p && f != s && p != s && !( p... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Produce a language-to-language conversion: from C# to Rust, same semantics. | using System;
public class Program
{
public static void Main() {
for (int p = 2; p <= 7; p+=2) {
for (int s = 1; s <= 7; s++) {
int f = 12 - p - s;
if (s >= f) break;
if (f > 7) continue;
if (s == p || f == p) continue;
... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Please provide an equivalent version of this C# code in Rust. | using System;
public class Program
{
public static void Main() {
for (int p = 2; p <= 7; p+=2) {
for (int s = 1; s <= 7; s++) {
int f = 12 - p - s;
if (s >= f) break;
if (f > 7) continue;
if (s == p || f == p) continue;
... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Preserve the algorithm and functionality while converting the code from Java to Rust. | public class DepartmentNumbers {
public static void main(String[] args) {
System.out.println("Police Sanitation Fire");
System.out.println("------ ---------- ----");
int count = 0;
for (int i = 2; i <= 6; i += 2) {
for (int j = 1; j <= 7; ++j) {
if (j ... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Write the same code in Rust as shown below in Java. | public class DepartmentNumbers {
public static void main(String[] args) {
System.out.println("Police Sanitation Fire");
System.out.println("------ ---------- ----");
int count = 0;
for (int i = 2; i <= 6; i += 2) {
for (int j = 1; j <= 7; ++j) {
if (j ... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Change the programming language of this snippet from Go to Rust without modifying what it does. | package main
import "fmt"
func main() {
fmt.Println("Police Sanitation Fire")
fmt.Println("------ ---------- ----")
count := 0
for i := 2; i < 7; i += 2 {
for j := 1; j < 8; j++ {
if j == i { continue }
for k := 1; k < 8; k++ {
if k == i || k == j { ... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Translate the given Rust code snippet into Python without altering its behavior. | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... | from itertools import permutations
def solve():
c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
print(f"{c:>3} {p:^6} {f:^4} {s:^10}")
c = 1
for p, f, s in permutations(range(1, 8), r=3):
if p + s + f == 12 and p % 2 == 0:
print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
c ... |
Convert this Rust block to Python, preserving its control flow and logic. | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... | from itertools import permutations
def solve():
c, p, f, s = "\\,Police,Fire,Sanitation".split(',')
print(f"{c:>3} {p:^6} {f:^4} {s:^10}")
c = 1
for p, f, s in permutations(range(1, 8), r=3):
if p + s + f == 12 and p % 2 == 0:
print(f"{c:>3}: {p:^6} {f:^4} {s:^10}")
c ... |
Produce a functionally identical Rust code for the snippet given in C. | #include<stdio.h>
int main()
{
int police,sanitation,fire;
printf("Police Sanitation Fire\n");
printf("----------------------------------");
for(police=2;police<=6;police+=2){
for(sanitation=1;sanitation<=7;sanitation++){
for(fire=1;fire<=7;fire++){
if(police!=sanitation && sanitation!=fir... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Port the following code from Go to Rust with equivalent syntax and logic. | package main
import "fmt"
func main() {
fmt.Println("Police Sanitation Fire")
fmt.Println("------ ---------- ----")
count := 0
for i := 2; i < 7; i += 2 {
for j := 1; j < 8; j++ {
if j == i { continue }
for k := 1; k < 8; k++ {
if k == i || k == j { ... | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... |
Convert the following code from Rust to VB, ensuring the logic remains intact. | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... | Module Module1
Sub Main()
For p = 2 To 7 Step 2
For s = 1 To 7
Dim f = 12 - p - s
If s >= f Then
Exit For
End If
If f > 7 Then
Continue For
End If
If s = p OrE... |
Produce a language-to-language conversion: from Rust to VB, same semantics. | extern crate num_iter;
fn main() {
println!("Police Sanitation Fire");
println!("----------------------");
for police in num_iter::range_step(2, 7, 2) {
for sanitation in 1..8 {
for fire in 1..8 {
if police != sanitation
&& sanitation != fire
... | Module Module1
Sub Main()
For p = 2 To 7 Step 2
For s = 1 To 7
Dim f = 12 - p - s
If s >= f Then
Exit For
End If
If f > 7 Then
Continue For
End If
If s = p OrE... |
Generate a C# translation of this Ada snippet without changing its computational steps. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Produce a functionally identical C# code for the snippet given in Ada. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Change the programming language of this snippet from Ada to C without modifying what it does. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Produce a functionally identical C code for the snippet given in Ada. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Rewrite the snippet below in C++ so it works the same as the original Ada code. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Port the following code from Ada to C++ with equivalent syntax and logic. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Write the same algorithm in Go as shown in this Ada implementation. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Rewrite this program in Go while keeping its functionality equivalent to the Ada version. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Ensure the translated Java code behaves exactly like the original Ada snippet. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Convert this Ada block to Java, preserving its control flow and logic. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Write the same code in Python as shown below in Ada. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Generate an equivalent Python version of this Ada code. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Rewrite this program in VB while keeping its functionality equivalent to the Ada version. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Produce a language-to-language conversion: from Ada to VB, same semantics. | with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Show_Fusc is
generic
Precalculate : Natural;
package Fusc_Sequences is
function Fusc (N : in Natural) return Natural;
end Fusc_Sequences;
package body Fusc_Sequences is
Precalculated_Fusc : array (0 .. Precalculate) of Natural;
... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Port the provided Arturo code into C while preserving the original functionality. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Write the same code in C as shown below in Arturo. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Generate a C# translation of this Arturo snippet without changing its computational steps. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Convert this Arturo block to C#, preserving its control flow and logic. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Port the provided Arturo code into C++ while preserving the original functionality. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Translate the given Arturo code snippet into C++ without altering its behavior. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Preserve the algorithm and functionality while converting the code from Arturo to Java. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Rewrite the snippet below in Java so it works the same as the original Arturo code. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Rewrite this program in Python while keeping its functionality equivalent to the Arturo version. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Produce a functionally identical Python code for the snippet given in Arturo. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Generate an equivalent VB version of this Arturo code. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Write the same algorithm in VB as shown in this Arturo implementation. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Keep all operations the same but rewrite the snippet in Go. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Produce a functionally identical Go code for the snippet given in Arturo. | fusc: function [n][
if? or? n=0 n=1 -> n
else [
if? 0=n%2 -> fusc n/2
else -> (fusc (n-1)/2) + fusc (n+1)/2
]
]
print "The first 61 Fusc numbers:"
print map 0..61 => fusc
print "\nThe Fusc numbers whose lengths are greater than those of previous Fusc numbers:"
print " n fusc(n)"
p... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Generate a C translation of this AutoHotKey snippet without changing its computational steps. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Generate a C translation of this AutoHotKey snippet without changing its computational steps. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Keep all operations the same but rewrite the snippet in C#. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Port the provided AutoHotKey code into C# while preserving the original functionality. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Write the same code in C++ as shown below in AutoHotKey. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Write the same algorithm in C++ as shown in this AutoHotKey implementation. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Rewrite the snippet below in Java so it works the same as the original AutoHotKey code. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Change the programming language of this snippet from AutoHotKey to Java without modifying what it does. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Transform the following AutoHotKey implementation into Python, maintaining the same output and logic. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Convert this AutoHotKey snippet to Python and keep its semantics consistent. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Convert this AutoHotKey block to VB, preserving its control flow and logic. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Keep all operations the same but rewrite the snippet in VB. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Translate this program into Go but keep the logic exactly as in AutoHotKey. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Rewrite the snippet below in Go so it works the same as the original AutoHotKey code. | fusc:=[], fusc[0]:=0, fusc[1]:=1, n:=1, l:=0, result:=""
while (StrLen(fusc[n]) < 5)
fusc[++n] := Mod(n, 2) ? fusc[floor((n-1)/2)] + fusc[Floor((n+1)/2)] : fusc[floor(n/2)]
while (A_Index <= 61)
result .= (result = "" ? "" : ",") fusc[A_Index-1]
result .= "`n`nfusc number whose length is greater than any pr... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Write a version of this AWK function in C with identical behavior. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Write the same code in C as shown below in AWK. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Rewrite this program in C# while keeping its functionality equivalent to the AWK version. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Write a version of this AWK function in C# with identical behavior. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Convert this AWK block to C++, preserving its control flow and logic. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Transform the following AWK implementation into C++, maintaining the same output and logic. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Port the provided AWK code into Java while preserving the original functionality. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Produce a functionally identical Java code for the snippet given in AWK. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | public class FuscSequence {
public static void main(String[] args) {
System.out.println("Show the first 61 fusc numbers (starting at zero) in a horizontal format");
for ( int n = 0 ; n < 61 ; n++ ) {
System.out.printf("%,d ", fusc[n]);
}
System.out.printf("%n%nS... |
Generate an equivalent Python version of this AWK code. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Keep all operations the same but rewrite the snippet in Python. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | from collections import deque
from itertools import islice, count
def fusc():
q = deque([1])
yield 0
yield 1
while True:
x = q.popleft()
q.append(x)
yield x
x += q[0]
q.append(x)
yield x
def longest_fusc():
sofar = 0
for i, f in zip(count(), ... |
Change the programming language of this snippet from AWK to VB without modifying what it does. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Convert this AWK block to VB, preserving its control flow and logic. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | Module Module1
Dim n As Integer = 61, l As List(Of Integer) = {0, 1}.ToList
Function fusc(n As Integer) As Integer
If n < l.Count Then Return l(n)
fusc = If((n And 1) = 0, l(n >> 1), l((n - 1) >> 1) + l((n + 1) >> 1))
l.Add(fusc)
End Function
Sub Main(args As String())
... |
Rewrite this program in Go while keeping its functionality equivalent to the AWK version. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Transform the following AWK implementation into Go, maintaining the same output and logic. |
BEGIN {
for (i=0; i<61; i++) {
printf("%d ",fusc(i))
}
printf("\n")
print("fusc numbers whose length is greater than any previous fusc number length")
printf("%9s %9s\n","fusc","index")
for (i=0; i<=700000; i++) {
f = fusc(i)
leng = num_leng(f)
if (leng > max_leng) {
... | package main
import (
"fmt"
"strconv"
)
func fusc(n int) []int {
if n <= 0 {
return []int{}
}
if n == 1 {
return []int{0}
}
res := make([]int, n)
res[0] = 0
res[1] = 1
for i := 2; i < n; i++ {
if i%2 == 0 {
res[i] = res[i/2]
} els... |
Change the following D code into C without altering its purpose. | import std.functional, std.stdio, std.format, std.conv;
ulong fusc(ulong n) =>
memoize!fuscImp(n);
ulong fuscImp(ulong n) =>
( n < 2 ) ? n :
( n % 2 == 0 ) ? memoize!fuscImp( n/2 ) :
memoize!fuscImp( (n-1)/2 ) + memoize!fuscImp( (n+1)/2 );
void main() {
const N_FIRST=61;
const MAX_N_DIGITS=5;
f... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Convert this D snippet to C and keep its semantics consistent. | import std.functional, std.stdio, std.format, std.conv;
ulong fusc(ulong n) =>
memoize!fuscImp(n);
ulong fuscImp(ulong n) =>
( n < 2 ) ? n :
( n % 2 == 0 ) ? memoize!fuscImp( n/2 ) :
memoize!fuscImp( (n-1)/2 ) + memoize!fuscImp( (n+1)/2 );
void main() {
const N_FIRST=61;
const MAX_N_DIGITS=5;
f... | #include<limits.h>
#include<stdio.h>
int fusc(int n){
if(n==0||n==1)
return n;
else if(n%2==0)
return fusc(n/2);
else
return fusc((n-1)/2) + fusc((n+1)/2);
}
int numLen(int n){
int sum = 1;
while(n>9){
n = n/10;
... |
Convert the following code from D to C#, ensuring the logic remains intact. | import std.functional, std.stdio, std.format, std.conv;
ulong fusc(ulong n) =>
memoize!fuscImp(n);
ulong fuscImp(ulong n) =>
( n < 2 ) ? n :
( n % 2 == 0 ) ? memoize!fuscImp( n/2 ) :
memoize!fuscImp( (n-1)/2 ) + memoize!fuscImp( (n+1)/2 );
void main() {
const N_FIRST=61;
const MAX_N_DIGITS=5;
f... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Keep all operations the same but rewrite the snippet in C#. | import std.functional, std.stdio, std.format, std.conv;
ulong fusc(ulong n) =>
memoize!fuscImp(n);
ulong fuscImp(ulong n) =>
( n < 2 ) ? n :
( n % 2 == 0 ) ? memoize!fuscImp( n/2 ) :
memoize!fuscImp( (n-1)/2 ) + memoize!fuscImp( (n+1)/2 );
void main() {
const N_FIRST=61;
const MAX_N_DIGITS=5;
f... | using System;
using System.Collections.Generic;
static class program
{
static int n = 61;
static List<int> l = new List<int>() { 0, 1 };
static int fusc(int n)
{
if (n < l.Count) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.Add(f); return... |
Write a version of this D function in C++ with identical behavior. | import std.functional, std.stdio, std.format, std.conv;
ulong fusc(ulong n) =>
memoize!fuscImp(n);
ulong fuscImp(ulong n) =>
( n < 2 ) ? n :
( n % 2 == 0 ) ? memoize!fuscImp( n/2 ) :
memoize!fuscImp( (n-1)/2 ) + memoize!fuscImp( (n+1)/2 );
void main() {
const N_FIRST=61;
const MAX_N_DIGITS=5;
f... | #include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <vector>
const int n = 61;
std::vector<int> l{ 0, 1 };
int fusc(int n) {
if (n < l.size()) return l[n];
int f = (n & 1) == 0 ? l[n >> 1] : l[(n - 1) >> 1] + l[(n + 1) >> 1];
l.push_back(f);
return f;
}
int main() {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.