WeixiangYan/CodeTransOcean huggingface dataset:
Task: Gapful numbers

C: #include<stdio.h>

void generateGaps(unsigned long long int start,int count){
    
    int counter = 0;
    unsigned long long int i = start;
    char str[100];
    
    printf("\nFirst %d Gapful numbers >= %llu :\n",count,start);

    while(counter<count){
        sprintf(str,"%llu",i);
        if((i%(10*(str[0]-'0') + i%10))==0L){
            printf("\n%3d : %llu",counter+1,i);
            counter++;
        }
        i++;
    }
}

int main()
{
    unsigned long long int i = 100;
    int count = 0;
    char str[21];

    generateGaps(100,30);
    printf("\n");
    generateGaps(1000000,15);
    printf("\n");
    generateGaps(1000000000,15);
    printf("\n");

    return 0;
}





Java: import java.util.List;

public class GapfulNumbers {
    private static String commatize(long n) {
        StringBuilder sb = new StringBuilder(Long.toString(n));
        int le = sb.length();
        for (int i = le - 3; i >= 1; i -= 3) {
            sb.insert(i, ',');
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        List<Long> starts = List.of((long) 1e2, (long) 1e6, (long) 1e7, (long) 1e9, (long) 7123);
        List<Integer> counts = List.of(30, 15, 15, 10, 25);
        for (int i = 0; i < starts.size(); ++i) {
            int count = 0;
            Long j = starts.get(i);
            long pow = 100;
            while (j >= pow * 10) {
                pow *= 10;
            }
            System.out.printf("First %d gapful numbers starting at %s:\n", counts.get(i), commatize(starts.get(i)));
            while (count < counts.get(i)) {
                long fl = (j / pow) * 10 + (j % 10);
                if (j % fl == 0) {
                    System.out.printf("%d ", j);
                    count++;
                }
                j++;
                if (j >= 10 * pow) {
                    pow *= 10;
                }
            }
            System.out.println('\n');
        }
    }
}
Task: Gapful numbers

C: #include<stdio.h>

void generateGaps(unsigned long long int start,int count){
    
    int counter = 0;
    unsigned long long int i = start;
    char str[100];
    
    printf("\nFirst %d Gapful numbers >= %llu :\n",count,start);

    while(counter<count){
        sprintf(str,"%llu",i);
        if((i%(10*(str[0]-'0') + i%10))==0L){
            printf("\n%3d : %llu",counter+1,i);
            counter++;
        }
        i++;
    }
}

int main()
{
    unsigned long long int i = 100;
    int count = 0;
    char str[21];

    generateGaps(100,30);
    printf("\n");
    generateGaps(1000000,15);
    printf("\n");
    generateGaps(1000000000,15);
    printf("\n");

    return 0;
}







Python: from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
    print(f"\nFirst {n} gapful numbers from {start:_}")
    print(list(islice(( x for x in count(start) 
                        if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
                      , n)))
Task: Gapful numbers

C: #include<stdio.h>

void generateGaps(unsigned long long int start,int count){
    
    int counter = 0;
    unsigned long long int i = start;
    char str[100];
    
    printf("\nFirst %d Gapful numbers >= %llu :\n",count,start);

    while(counter<count){
        sprintf(str,"%llu",i);
        if((i%(10*(str[0]-'0') + i%10))==0L){
            printf("\n%3d : %llu",counter+1,i);
            counter++;
        }
        i++;
    }
}

int main()
{
    unsigned long long int i = 100;
    int count = 0;
    char str[21];

    generateGaps(100,30);
    printf("\n");
    generateGaps(1000000,15);
    printf("\n");
    generateGaps(1000000000,15);
    printf("\n");

    return 0;
}








VB: Module Module1

    Function FirstNum(n As Integer) As Integer
        REM Divide by ten until the leading digit remains.
        While n >= 10
            n /= 10
        End While
        Return n
    End Function

    Function LastNum(n As Integer) As Integer
        REM Modulo gives you the last digit.
        Return n Mod 10
    End Function

    Sub FindGap(n As Integer, gaps As Integer)
        Dim count = 0
        While count < gaps
            Dim i = FirstNum(n) * 10 + LastNum(n)

            REM Modulo with our new integer and output the result.
            If n Mod i = 0 Then
                Console.Write("{0} ", n)
                count += 1
            End If

            n += 1
        End While
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Sub Main()
        Console.WriteLine("The first 30 gapful numbers are: ")
        FindGap(100, 30)

        Console.WriteLine("The first 15 gapful numbers > 1,000,000 are: ")
        FindGap(1000000, 15)

        Console.WriteLine("The first 10 gapful numbers > 1,000,000,000 are: ")
        FindGap(1000000000, 10)
    End Sub

End Module
Task: Gapful numbers


C++: #include <iostream>

bool gapful(int n) {
    int m = n;
    while (m >= 10)
        m /= 10;
    return n % ((n % 10) + 10 * (m % 10)) == 0;
}

void show_gapful_numbers(int n, int count) {
    std::cout << "First " << count << " gapful numbers >= " << n << ":\n";
    for (int i = 0; i < count; ++n) {
        if (gapful(n)) {
            if (i != 0)
                std::cout << ", ";
            std::cout << n;
            ++i;
        }
    }
    std::cout << '\n';
}

int main() {
    show_gapful_numbers(100, 30);
    show_gapful_numbers(1000000, 15);
    show_gapful_numbers(1000000000, 10);
    return 0;
}



Go: package main

import "fmt"

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
    counts := []int{30, 15, 15, 10, 25}
    for i := 0; i < len(starts); i++ {
        count := 0
        j := starts[i]
        pow := uint64(100)
        for {
            if j < pow*10 {
                break
            }
            pow *= 10
        }
        fmt.Printf("First %d gapful numbers starting at %s:\n", counts[i], commatize(starts[i]))
        for count < counts[i] {
            fl := (j/pow)*10 + (j % 10)
            if j%fl == 0 {
                fmt.Printf("%d ", j)
                count++
            }
            j++
            if j >= 10*pow {
                pow *= 10
            }
        }
        fmt.Println("\n")
    }
}
Task: Gapful numbers


C++: #include <iostream>

bool gapful(int n) {
    int m = n;
    while (m >= 10)
        m /= 10;
    return n % ((n % 10) + 10 * (m % 10)) == 0;
}

void show_gapful_numbers(int n, int count) {
    std::cout << "First " << count << " gapful numbers >= " << n << ":\n";
    for (int i = 0; i < count; ++n) {
        if (gapful(n)) {
            if (i != 0)
                std::cout << ", ";
            std::cout << n;
            ++i;
        }
    }
    std::cout << '\n';
}

int main() {
    show_gapful_numbers(100, 30);
    show_gapful_numbers(1000000, 15);
    show_gapful_numbers(1000000000, 10);
    return 0;
}




Java: import java.util.List;

public class GapfulNumbers {
    private static String commatize(long n) {
        StringBuilder sb = new StringBuilder(Long.toString(n));
        int le = sb.length();
        for (int i = le - 3; i >= 1; i -= 3) {
            sb.insert(i, ',');
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        List<Long> starts = List.of((long) 1e2, (long) 1e6, (long) 1e7, (long) 1e9, (long) 7123);
        List<Integer> counts = List.of(30, 15, 15, 10, 25);
        for (int i = 0; i < starts.size(); ++i) {
            int count = 0;
            Long j = starts.get(i);
            long pow = 100;
            while (j >= pow * 10) {
                pow *= 10;
            }
            System.out.printf("First %d gapful numbers starting at %s:\n", counts.get(i), commatize(starts.get(i)));
            while (count < counts.get(i)) {
                long fl = (j / pow) * 10 + (j % 10);
                if (j % fl == 0) {
                    System.out.printf("%d ", j);
                    count++;
                }
                j++;
                if (j >= 10 * pow) {
                    pow *= 10;
                }
            }
            System.out.println('\n');
        }
    }
}
Task: Gapful numbers


C++: #include <iostream>

bool gapful(int n) {
    int m = n;
    while (m >= 10)
        m /= 10;
    return n % ((n % 10) + 10 * (m % 10)) == 0;
}

void show_gapful_numbers(int n, int count) {
    std::cout << "First " << count << " gapful numbers >= " << n << ":\n";
    for (int i = 0; i < count; ++n) {
        if (gapful(n)) {
            if (i != 0)
                std::cout << ", ";
            std::cout << n;
            ++i;
        }
    }
    std::cout << '\n';
}

int main() {
    show_gapful_numbers(100, 30);
    show_gapful_numbers(1000000, 15);
    show_gapful_numbers(1000000000, 10);
    return 0;
}






Python: from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
    print(f"\nFirst {n} gapful numbers from {start:_}")
    print(list(islice(( x for x in count(start) 
                        if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
                      , n)))
Task: Gapful numbers


C++: #include <iostream>

bool gapful(int n) {
    int m = n;
    while (m >= 10)
        m /= 10;
    return n % ((n % 10) + 10 * (m % 10)) == 0;
}

void show_gapful_numbers(int n, int count) {
    std::cout << "First " << count << " gapful numbers >= " << n << ":\n";
    for (int i = 0; i < count; ++n) {
        if (gapful(n)) {
            if (i != 0)
                std::cout << ", ";
            std::cout << n;
            ++i;
        }
    }
    std::cout << '\n';
}

int main() {
    show_gapful_numbers(100, 30);
    show_gapful_numbers(1000000, 15);
    show_gapful_numbers(1000000000, 10);
    return 0;
}







VB: Module Module1

    Function FirstNum(n As Integer) As Integer
        REM Divide by ten until the leading digit remains.
        While n >= 10
            n /= 10
        End While
        Return n
    End Function

    Function LastNum(n As Integer) As Integer
        REM Modulo gives you the last digit.
        Return n Mod 10
    End Function

    Sub FindGap(n As Integer, gaps As Integer)
        Dim count = 0
        While count < gaps
            Dim i = FirstNum(n) * 10 + LastNum(n)

            REM Modulo with our new integer and output the result.
            If n Mod i = 0 Then
                Console.Write("{0} ", n)
                count += 1
            End If

            n += 1
        End While
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Sub Main()
        Console.WriteLine("The first 30 gapful numbers are: ")
        FindGap(100, 30)

        Console.WriteLine("The first 15 gapful numbers > 1,000,000 are: ")
        FindGap(1000000, 15)

        Console.WriteLine("The first 10 gapful numbers > 1,000,000,000 are: ")
        FindGap(1000000000, 10)
    End Sub

End Module
Task: Gapful numbers




Go: package main

import "fmt"

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
    counts := []int{30, 15, 15, 10, 25}
    for i := 0; i < len(starts); i++ {
        count := 0
        j := starts[i]
        pow := uint64(100)
        for {
            if j < pow*10 {
                break
            }
            pow *= 10
        }
        fmt.Printf("First %d gapful numbers starting at %s:\n", counts[i], commatize(starts[i]))
        for count < counts[i] {
            fl := (j/pow)*10 + (j % 10)
            if j%fl == 0 {
                fmt.Printf("%d ", j)
                count++
            }
            j++
            if j >= 10*pow {
                pow *= 10
            }
        }
        fmt.Println("\n")
    }
}


Java: import java.util.List;

public class GapfulNumbers {
    private static String commatize(long n) {
        StringBuilder sb = new StringBuilder(Long.toString(n));
        int le = sb.length();
        for (int i = le - 3; i >= 1; i -= 3) {
            sb.insert(i, ',');
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        List<Long> starts = List.of((long) 1e2, (long) 1e6, (long) 1e7, (long) 1e9, (long) 7123);
        List<Integer> counts = List.of(30, 15, 15, 10, 25);
        for (int i = 0; i < starts.size(); ++i) {
            int count = 0;
            Long j = starts.get(i);
            long pow = 100;
            while (j >= pow * 10) {
                pow *= 10;
            }
            System.out.printf("First %d gapful numbers starting at %s:\n", counts.get(i), commatize(starts.get(i)));
            while (count < counts.get(i)) {
                long fl = (j / pow) * 10 + (j % 10);
                if (j % fl == 0) {
                    System.out.printf("%d ", j);
                    count++;
                }
                j++;
                if (j >= 10 * pow) {
                    pow *= 10;
                }
            }
            System.out.println('\n');
        }
    }
}
Task: Gapful numbers





Java: import java.util.List;

public class GapfulNumbers {
    private static String commatize(long n) {
        StringBuilder sb = new StringBuilder(Long.toString(n));
        int le = sb.length();
        for (int i = le - 3; i >= 1; i -= 3) {
            sb.insert(i, ',');
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        List<Long> starts = List.of((long) 1e2, (long) 1e6, (long) 1e7, (long) 1e9, (long) 7123);
        List<Integer> counts = List.of(30, 15, 15, 10, 25);
        for (int i = 0; i < starts.size(); ++i) {
            int count = 0;
            Long j = starts.get(i);
            long pow = 100;
            while (j >= pow * 10) {
                pow *= 10;
            }
            System.out.printf("First %d gapful numbers starting at %s:\n", counts.get(i), commatize(starts.get(i)));
            while (count < counts.get(i)) {
                long fl = (j / pow) * 10 + (j % 10);
                if (j % fl == 0) {
                    System.out.printf("%d ", j);
                    count++;
                }
                j++;
                if (j >= 10 * pow) {
                    pow *= 10;
                }
            }
            System.out.println('\n');
        }
    }
}



Python: from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
    print(f"\nFirst {n} gapful numbers from {start:_}")
    print(list(islice(( x for x in count(start) 
                        if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
                      , n)))
Task: Gapful numbers




Go: package main

import "fmt"

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
    counts := []int{30, 15, 15, 10, 25}
    for i := 0; i < len(starts); i++ {
        count := 0
        j := starts[i]
        pow := uint64(100)
        for {
            if j < pow*10 {
                break
            }
            pow *= 10
        }
        fmt.Printf("First %d gapful numbers starting at %s:\n", counts[i], commatize(starts[i]))
        for count < counts[i] {
            fl := (j/pow)*10 + (j % 10)
            if j%fl == 0 {
                fmt.Printf("%d ", j)
                count++
            }
            j++
            if j >= 10*pow {
                pow *= 10
            }
        }
        fmt.Println("\n")
    }
}




Python: from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
    print(f"\nFirst {n} gapful numbers from {start:_}")
    print(list(islice(( x for x in count(start) 
                        if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
                      , n)))
Task: Gapful numbers




Go: package main

import "fmt"

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func main() {
    starts := []uint64{1e2, 1e6, 1e7, 1e9, 7123}
    counts := []int{30, 15, 15, 10, 25}
    for i := 0; i < len(starts); i++ {
        count := 0
        j := starts[i]
        pow := uint64(100)
        for {
            if j < pow*10 {
                break
            }
            pow *= 10
        }
        fmt.Printf("First %d gapful numbers starting at %s:\n", counts[i], commatize(starts[i]))
        for count < counts[i] {
            fl := (j/pow)*10 + (j % 10)
            if j%fl == 0 {
                fmt.Printf("%d ", j)
                count++
            }
            j++
            if j >= 10*pow {
                pow *= 10
            }
        }
        fmt.Println("\n")
    }
}





VB: Module Module1

    Function FirstNum(n As Integer) As Integer
        REM Divide by ten until the leading digit remains.
        While n >= 10
            n /= 10
        End While
        Return n
    End Function

    Function LastNum(n As Integer) As Integer
        REM Modulo gives you the last digit.
        Return n Mod 10
    End Function

    Sub FindGap(n As Integer, gaps As Integer)
        Dim count = 0
        While count < gaps
            Dim i = FirstNum(n) * 10 + LastNum(n)

            REM Modulo with our new integer and output the result.
            If n Mod i = 0 Then
                Console.Write("{0} ", n)
                count += 1
            End If

            n += 1
        End While
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Sub Main()
        Console.WriteLine("The first 30 gapful numbers are: ")
        FindGap(100, 30)

        Console.WriteLine("The first 15 gapful numbers > 1,000,000 are: ")
        FindGap(1000000, 15)

        Console.WriteLine("The first 10 gapful numbers > 1,000,000,000 are: ")
        FindGap(1000000000, 10)
    End Sub

End Module
Task: Gapful numbers







Python: from itertools import islice, count
for start, n in [(100, 30), (1_000_000, 15), (1_000_000_000, 10)]:
    print(f"\nFirst {n} gapful numbers from {start:_}")
    print(list(islice(( x for x in count(start) 
                        if (x % (int(str(x)[0]) * 10 + (x % 10)) == 0) )
                      , n)))


VB: Module Module1

    Function FirstNum(n As Integer) As Integer
        REM Divide by ten until the leading digit remains.
        While n >= 10
            n /= 10
        End While
        Return n
    End Function

    Function LastNum(n As Integer) As Integer
        REM Modulo gives you the last digit.
        Return n Mod 10
    End Function

    Sub FindGap(n As Integer, gaps As Integer)
        Dim count = 0
        While count < gaps
            Dim i = FirstNum(n) * 10 + LastNum(n)

            REM Modulo with our new integer and output the result.
            If n Mod i = 0 Then
                Console.Write("{0} ", n)
                count += 1
            End If

            n += 1
        End While
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Sub Main()
        Console.WriteLine("The first 30 gapful numbers are: ")
        FindGap(100, 30)

        Console.WriteLine("The first 15 gapful numbers > 1,000,000 are: ")
        FindGap(1000000, 15)

        Console.WriteLine("The first 10 gapful numbers > 1,000,000,000 are: ")
        FindGap(1000000000, 10)
    End Sub

End Module
Task: Gapful numbers





Java: import java.util.List;

public class GapfulNumbers {
    private static String commatize(long n) {
        StringBuilder sb = new StringBuilder(Long.toString(n));
        int le = sb.length();
        for (int i = le - 3; i >= 1; i -= 3) {
            sb.insert(i, ',');
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        List<Long> starts = List.of((long) 1e2, (long) 1e6, (long) 1e7, (long) 1e9, (long) 7123);
        List<Integer> counts = List.of(30, 15, 15, 10, 25);
        for (int i = 0; i < starts.size(); ++i) {
            int count = 0;
            Long j = starts.get(i);
            long pow = 100;
            while (j >= pow * 10) {
                pow *= 10;
            }
            System.out.printf("First %d gapful numbers starting at %s:\n", counts.get(i), commatize(starts.get(i)));
            while (count < counts.get(i)) {
                long fl = (j / pow) * 10 + (j % 10);
                if (j % fl == 0) {
                    System.out.printf("%d ", j);
                    count++;
                }
                j++;
                if (j >= 10 * pow) {
                    pow *= 10;
                }
            }
            System.out.println('\n');
        }
    }
}




VB: Module Module1

    Function FirstNum(n As Integer) As Integer
        REM Divide by ten until the leading digit remains.
        While n >= 10
            n /= 10
        End While
        Return n
    End Function

    Function LastNum(n As Integer) As Integer
        REM Modulo gives you the last digit.
        Return n Mod 10
    End Function

    Sub FindGap(n As Integer, gaps As Integer)
        Dim count = 0
        While count < gaps
            Dim i = FirstNum(n) * 10 + LastNum(n)

            REM Modulo with our new integer and output the result.
            If n Mod i = 0 Then
                Console.Write("{0} ", n)
                count += 1
            End If

            n += 1
        End While
        Console.WriteLine()
        Console.WriteLine()
    End Sub

    Sub Main()
        Console.WriteLine("The first 30 gapful numbers are: ")
        FindGap(100, 30)

        Console.WriteLine("The first 15 gapful numbers > 1,000,000 are: ")
        FindGap(1000000, 15)

        Console.WriteLine("The first 10 gapful numbers > 1,000,000,000 are: ")
        FindGap(1000000000, 10)
    End Sub

End Module
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}



C#: public static bool IsNumeric(string s)
{
    double Result;
    return double.TryParse(s, out Result);  
}        

string value = "123";
if (IsNumeric(value)) 
{
  
}
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}


C++: #include <sstream> 

using namespace std;

bool isNumeric( const char* pszInput, int nNumberBase )
{
	istringstream iss( pszInput );

	if ( nNumberBase == 10 )
	{
		double dTestSink;
		iss >> dTestSink;
	}
	else if ( nNumberBase == 8 || nNumberBase == 16 )
	{
		int nTestSink;
		iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
	}
	else
		return false;

	
	if ( ! iss )
		return false;

	
	return ( iss.rdbuf()->in_avail() == 0 );
}
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}




Go: package main

import (
    "fmt"
    "strconv"
)

func isNumeric(s string) bool {
    _, err := strconv.ParseFloat(s, 64)
    return err == nil
}

func main() {
    fmt.Println("Are these strings numeric?")
    strings := []string{"1", "3.14", "-100", "1e2", "NaN", "rose"}
    for _, s := range strings {
        fmt.Printf("  %4s -> %t\n", s, isNumeric(s))
    }
}
Task: Determine if a string is numeric

C: #include <ctype.h>
#include <stdlib.h>
int isNumeric (const char * s)
{
    if (s == NULL || *s == '\0' || isspace(*s))
      return 0;
    char * p;
    strtod (s, &p);
    return *p == '\0';
}





Java: public boolean isNumeric(String input) {
  try {
    Integer.parseInt(input);
    return true;
  }
  catch (NumberFormatException e) {
    
    return false;
  }
}