Dataset Viewer
Auto-converted to Parquet Duplicate
image
imagewidth (px)
920
2.05k
text
stringlengths
60
1.15k
def prgm(array[], target): list = [] for i in array: list.append(array[i]) list = list.set() for i in range(len(list)): if list[i] == target: return target elif list[i] > target: return list[i] else: for i in range(len(list)): ...
int A[10], i, n, k; printf("Target number: "); scanf("%d", &k); for (i = 0; i < n; i++) { if (A[i] = k) printf("Output %d", A[i]); else if (A[i] != k) printf("Output %d", A[i]>k); else printf("Output %d", A[n]); }
#include <stdio.h> void main() { int a[100], n, target, temp1, temp2, index; scanf("%d", &n); // Read the number of elements for (int i = 0; i < n; i++) // Initialize the array scanf("%d", &a[i]); scanf("%d", &target); // Read the target value temp2 = __INT_MAX(); // Set temp2 to t...
#include <stdio.h> int main() { int a[100], i, k, n, b[100], x = 0; printf("Enter k: "); scanf("%d", &k); printf("Enter n: "); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n; i++) { b[i] = k - a[i]; } for (i = 0; i < n; i+...
#include <stdio.h> int main() { int a[100], n, tar, j, sum, temp, b[100]; printf("Enter the size of array: "); scanf("%d", &n); printf("Enter the array: "); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } printf("Enter the target number: "); scanf("%d", &tar); ...
#include <stdio.h> void main() { int arr[10]; int i, n, t, diff; printf("Enter the size of array:\n"); scanf("%d", &n); printf("Enter the sorted array:\n"); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } printf("Enter target number:\n"); scanf("%d", &t); f...
function Find(arrays,target): rduplicate = set(arrays) difference = abs(target - rduplicate[0]) for i in range(1, len(rduplicate)): d = abs(target - rduplicate[i]) if d < difference: difference = d pos = i print(rduplicate[i]) find([2, 5, 6, 7, 8, 8, 9], 5)
def closest_number(): int arr = [ ] int num arr.sort() target_number = i for i in range(arr): if i = target_number: print(i) else i != target_number print("Closest value:", closest)
n = int(input("Enter the numbers in sorted order: ") t = int(input("Enter the target number: ")) for i in n: if i <= t: print("numbers close to target value:", i) n = input("Enter the text: ") print(n) for i in n: s = i + 1+1 print s
int A[10], i, n, k; printf("Target number: "); scanf("%d", &k); for (i = 0; i < n; i++) { if (A[i] = k) printf("Output %d", A[i]); else if (A[i] != k) printf("Output %d", A[i] > k); else printf("Output %d", A[n]); }
def prgm, (array[], target): List = [] for i in array: List.append(array[i]) List1 = List.set() for i in range(len(List)): if list[i] == target: return target elif list1[i] > target: return list1[i] else: for i in range(len(list)): minimum = m...
#include <stdio.h> int main() { int a[100], i, k, n, b[100], x = 0; scanf("%d", &k); scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n; i++) { b[i] = k - a[i]; } for (i = 0; i < n; i++) { if (b[i] > b[i+1]) ...
#include <stdio.h> void main() { int a[100], n, target, temp1, temp2, index; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); // Initializing array scanf("%d", &target); // Initializing target temp2 = INT_MAX(); // Setting temp2 to the highest int value for the fir...
#include <stdio.h> #include<iostream.h> void main() { int arr[20], n, temp = 0, con = 0; printf("Enter the number of elements:\n"); scanf("%d", &n); printf("Enter the array elements (0 or 1):\n"); for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } printf("\n"); arr[n] = 0;...
#include <stdio.h> #include <conio.h> #include <stdlib.h> int main() { int a[], n, i, j; printf("Enter the array size:"); scanf("%d", &n); for(i = 0; i < n; i++) { printf("Enter the required array element:"); scanf("%d", &a[i]); } while(i = 0, a[i], i++) { j =...
#include <stdio.h> void main() { int i, j, n, ar[30], c[10]; printf("Enter the no. of elements"); scanf("%d", &n); printf("Enter the elements"); for(i = 0; i <= n; i++) scanf("%d", &ar[i]); for(k=0; k<=10; k++) for(j = 0; j <= n; j++) { if(ar[j] == ar[j + 1]) { cou...
arr = [0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0] count = 0 n = len.arr for i in range(0, n): if arr[i] == 1: count = count + 1 print("Max number of consecutive 1's is:") print(count)
arr = [int(x) for x in input()] # Take array as input flag = 0 for ele in arr: if ele != 0 and ele != 1: flag = 1 break if flag == 1: print("Enter correct input") cnt = 0 m = 0 max = 0 for i in range(0, len(arr)): if arr[i] == 1: cnt = 1 for j in range(i, len(arr)): ...
#include <stdio.h> void main() { int i, j, n, ar[20], c[10]; printf("Enter the no. of elements: "); scanf("%d", &n); printf("Enter the elements:\n"); for (i = 0; i < n; i++) scanf("%d", &ar[i]); for(k=0;k<=10;k++) for (j = 0; j < n; j++) { if (ar[j] == ar[j + 1]) c...
#include <stdio.h> #include <conio.h> #include <stdlib.h> int main() { int a[], n, i, j; printf("Enter the array size: "); scanf("%d", &n); for (i = 0; i < n; i++) { printf("Enter the required array elements: "); scanf("%d", &a[]); } j = 0; if (a[i] == 1) { j =+ ...
list1 = [] num = int(input("Enter the numbers ")) count = 0 n = len(num) for i in range(0, n-1): if (num[i] == 1): list1[i] = count++ else: break print(max(list1))
#include <stdio.h> #include <stdlib.h> void max_one(int arr, int length) { int count = 0, max = 0; for (int i = 0; i <= length; i++) { if (arr[i] == 1) { // count no. of consecutive 1's count++; } else { count = 0; // reset when 0 comes } if (count > ...
L1 = input() list1 = list(L1) count = 0 onecount = [] for ele in list1: if ele == 1: count += 1 else: if count > 0: onecount.append(count) count = 0 max_count = max(onecount) print(max_count)
count = 0 n = int(input("Enter the size: ")) list = [] print("Enter the elements:") # Enter 0's and 1's for i in range(0, n): num = int(input()) list.append(num) for i in range(0, n): if (list[i] == 1 and list[i + 1] == 1): count = count + 1 else: if list1[i] == 0 an...
print("Enter no of elements") n = int(input()) a = [] for i in range(n): num = int(input) a.append(num) l = len(a) c = 0 max = 0 for i in range(l): if a[i] == 1: c = c + 1 if c > max: max = c if a[i] == 0: c = 0 print("Maximum no of consecutive 1's is:", max)
arr = [int(x) for x in input().split()] max = 0; i = 0; li_max = [] do{ if (arr[i] == 1) { if (max == 0): max += 1; i++; if (arr[i] == 1 and arr[i + 1] == 1): max += 1; i++; else if (arr[i] == 1 and arr[i + 1] != 1): li_max.append(max) if(max>=1 and...
num = input() # Reading input count = 0 count_list = [] # To store count for i in range(len(num)): if (num[i] == 1): { count += 1 if (num[i + 1] == 0) { count_list.append(count) count = 0 } } print("Max number of consecutive 1's is:", max(count_li...
count = 0 n = int(input("Enter the size: ")) list = [] print("Enter the elements:") # Enter 0's and 1's for i in range(0, n): num = int(input()) list.append(num) for i in range(0, n): if (list[i] == 1 and list[i+1] == 1: count = count + 1 else: if(list[i] == 0 and list[i+1]==0): ...
L1 = input() List1 = list(L1) count = 0 onecount = [] for ele in list1 if ele == 1: count += 1 else: if count > 0: onecount.append(count) count = 0 max_count = max(onecount) print(max_count)
function arraymanipulation(L1[], L2[]): L3 = [] L3 = L1 + L2 ; result = [] for ele in L3: if ele not in result: result.append(L3) else : continue . return result.sort()
#include <stdio.h> #include <stdlib.h> void max_one(int arr, int length) { int count = 0, max = 0; for (int i = 0; i <= length; i++) { if (arr[i] == 1) count++; // count no. of consecutive 1's. else count = 0; // reset when 0 comes. if (count > max) { ...
list1 = [] num = int(input("Enter the number")) count = 0 n = len(num) for i in range(0, n-1): if num[i] == 1: list1[i] = count++ else: break print(max(list1))
void file_read(filename) { int b, sum = 0; f1 = fopen(filename, "r"); while (!f1.eof()) { f1.read(l); b = parseInt(l); sum = sum + b; } printf("Sum = %d\n", sum); void main() { file_read("Input.txt"); }
def file_handle(): file1 = "input.txt" # Read all the contents of file1 to file2 file1.read() file2.write() num = arr.num sum = sum(arr) print(sum) return 0
def prgm2(): File = input.txt.open("r") list = File.read() sum = 0 for i in list: sum = sum + i return sum
#include <stdio.h> #include <stdlib.h> int sum(FILE fp) { int s = 0, i; while (getc(fp) != EOF) { i = gets(fp); s = s + i; } return s; } int main() { FILE *fp; fp = fopen("input.txt", "r"); a = sum(fp); printf("%d", a); fclose(fp); }
#include <stdio.h> void main() { FILE *fp; fp = fopen("input.txt", "r"); char str; int sum; while (str != endln) { str = readln(fp); sum = sum + str; } printf("%d", sum); }
def pgm2(): File = input.txt.open("r") list = File.read() sum = 0 for i in list: sum = sum + i return sum
#include <stdio.h> void main() { FILE *fp; fp = fopen("input.txt", "r"); char str; int sum; while (str != endln) { str = readln(fp); sum = sum + str; } printf("%d", sum); }
#include <stdio.h> #include <stdlib.h> int sum(FILE fp) { int s = 0, i; while (geth(fp) != EOF) { i = gets(fp); s = s + i; } return s; } int main() { FILE *fp; fp = fopen("input.txt", "a"); a = sum(fp); printf("%d", a); fclose(fp); }
#include <stdio.h> #include <iostream.h> int main() { int list1[20], list2[20], n1, n2, k = 0, min = 1000,res[20],flag=0,Q=0; printf("Enter the number of elements in list1 and list2: "); scanf("%d %d", &n1, &n2); for (int i = 0; i < n1; i++) { scanf("%d", &list1[i]); } fo...
sample_list1 = [3, 1, 4, 1, 5, 9] sample_list2 = [2, 6, 5, 3, 5] new_list = sample_list1 + sample_list2 tuple1 = () tuple1 = tuple.new_list new_list1 = list.tuple1 print(new_list.ascending)
sample_list1 = [int(x) for x in input().split(',')] sample_list2 = [int(x) for x in input().split(',')] l = [] arr = sample_list1 + sample_list2 # The merged result is stored in arr s = set(arr) # The set function removes duplicates in arr l = list(s) l.sort() # The sort method sorts the array in ascending order pr...
#include <stdio.h> void array() { s1 = [3, 1, 4, 5, 9]; s2 = [2, 1, 5, 3, 5]; s3 = append[s1, s2]; print(s3); }
def listadency(a): sample_list1 = int(input(a)) sample_list2 = int(input(b)) sample_list3 = {} sample_list3 = append(sample_list1(sample_list2))
sample_list1 = [3, 1, 4, 1, 5, 9] sample_list2 = [2, 6, 5, 3, 5] sample_list3 = [] for i in range(0, len(sample_list1)): sample_list3[i] = sample_list1[i]
def manipulate(list1, list2): list3 = list1.append(list2) list3 = list3.sort() # to remove duplicates for i in list3: for j in list3: if i == j: list3.pop(j) return list3
Function array_manipulation(L1, L2): L3 = [] L3 = L1 + L2 result = [] for ele in L3: if ele not in result: result.append(L3) else: continue return result.sort()
list1 = [3, 1, 4, 1, 5, 9] list2 = [2,6, 5, 3, 5] def merge(list1, list2): list3 = [] for i in list1: if i not in list3: list3.append[i] for j in list2: if j not in list3: list3.append[j] return list3 print("Merged list in ascending order:") print(list...
sl1 = [3, 1, 4, 1, 5, 9] sl2 = [2, 6, 5, 3, 5] l2 = length(sl2) l1 = length(sl1) l1.extend(l2) # Function to merge lists in Python c = l1 for i in range(l2): sl1[c] = sl2[i] c = c + 1 l1 = length(sl1) for i in range(l1): if(sl1.count(sl1[i] > 1) sl1.remove(sl1[i]) sl1.sort() print(sl1)...
sample_list1 = [int(x) for x in input().split()] sample_list2 = [int(x) for x in input().split()] final_list = [] res = [] final_list = sample_list1.merge(sample_list2) res = sort(final_list) print(res)
def mergeList(list_1, list_2): list_3 = list_1 + list_2 # Merging lists for i in list_3: if (count(i) > 1): { list_3.remove(i) # Removing duplicate values } list_3.sort() return (list_3) # Return the results in ascending order
list1 = [3,1,4,1,5,9] list2 = [2,6,5,3,5] def merge(list1, list2): list3 = [] for i in list1: if i not in list3: list3.append[i] for j in list2: if j not in list3: list3.append[j] return list3 print("Merged list in ascending order") print(list3.sort())
def manipulate(list1, list2): list3 = list1.append(list2) list3 = list3.sort() # to remove duplicate. for i in list3: for j in list3: if i == j: list3.pop(j) return list3
Sample_list1 = [3, 1, 4, 1, 5, 9] Sample_list2 = [2, 6, 5, 3, 5] Sample_list3 = [ ] for i in range(0, len( Sample_list1)): Sample_list3[i] = Sample_list1[i]
def listanclug(a) sample_list1 = int(input(a)) sample_list2 = int(input(b)) sample_list3 = [ ] sample_list3 = append(sample_list1(sample_list2))
#include <stdio.h> void merge() { s1 = [3,1,4,5,9] s2 = [2,6,5,3,5] s3 = append[s1, s2]; print(s3); }
print() { int n; n = 0; for (i=n; n <= 100; n++) { printf(" ", n); } }
#include <stdio.h> int main() { int first = 0, second = 1, third=2; printf("%d", &first); printf("%d", &second); while (third < 100) { printf("%d", &third); third = third + second; third++; }
#include <stdio.h> void number(int n) { if (n <= 100) { printf("%d ", n); n++; number(n); } } int main() { int n = 1; number(n); return 0; }
def add1(s): if (s < 101): print(s) s = s + 1 add1(s) __init__main: add1(1)
#include <stdio.h> void main() { n = 1; if (n <= 100) { printf("%d\t", n); n = n + 1; } }
def add1(s): if(s < 101): print(s) s = s + 1 add1(s) __init__main(): add1(1)
#include <stdio.h> void number(int n) { if (n != 100) { printf("%d ", n); } if (n <= 100) { printf("%d ", n); n++; number(n); } } int main() { int n = 1; number(n); return 0; }
# Using loop n = int(input("Enter a limit: ")) for i in range(1 : n+1): print(i) # Without using loop n = int(input("Enter a limit: "))
#include <stdio.h> int main() { int n = 100 , i=1; if (i <= n) { printf( i); i = i+1; } return 100; }
import java.util.Scanner; public class Numbers { public static void Numbers(int s, int e) { if (s <= e) { System.out.println(s); Numbers(s + 1, e); } } public static void main(String[] args) { Numbers(1, 100); } }
// Recursive Function void num(int n) { if (n <= 100) { printf(" %d ", n); num(n + 1); } else { exit(0); } }
// Without loop System.out.println("1"); System.out.println(i.next); System.out.println(i.next+1); ... ?
void print() { int num; print(randomize num(100)); }
void print() { s = 0; print(s); a = s + 1; print(a); goto (a); }
number = 0; print_numbers(number) { printf("number + 1); } return_function() { while (number <= 100) { print_numbers(number); number = number + 1; } } return_function();
# Using loop n = int(input("Enter a limit: ")) for i in range(1: n + 1): print(i) # Without using loop n = int(input("Enter a limit: "))
function count(s): l = list(s.split(' ')) dct = {} for i in l: if (i in dct): dct[i] = dct[i] + 1 else: dct[i] = 0 return dct
def StringCount(s): dictionary = {} for ch in s: if s[ch] = s[ch+1]: c = c + 1 dictionary.append(ch, c) print(dictionary) a = StringCount("Programming is fun") print(a)
Void occurance(String s): dict = { } word = s.split() for i in word: dict[i] = count(i) return dict
tr = input().lower() d = { } for ele in str: if ele not in d: d[ele] = 1 else: d[ele] += 1 print("dictionary =", end=" ") print(d.items())
int count(char ch) // Consider size of s = 5 { for(int i = 0; i < strlen(ch); i++) { if(strcmpi(ch[0], ch[i+1]) == 0) c++; if(strcmpi(ch[1], ch[i+1]) == 0) d++; if(strcmpi(ch[2], ch[i+1]) == 0) e++; if(strcmpi(ch[3], ch[i+1]) == 0) ...
dict = {} count = 0 n = len(s) for i in range(0, n+1, 1): for j in range(0, i+1, 1): if (s[i] == s[j]): count ++ dict.append(s[i]: count) else: count = 1 dict.append(s[i]: count) print(dict)
def char_count(s): dict1 = {} # Empty dictionary for i in s: # Iterate through string if i not in dict1: # Check presence of character dict1.add(i) # Add i as key of dictionary i.value = s.count(i) # Count the occurrences of i and add it as value of item return di...
set = {} temp = 1 count = [] string = int(input()) string1 = string.split(' ') arr = [] def strManipulation: for i in range[0, len(string1)]: for j in range[i+1, len(string1)]: if (string1[i] == string1[j]): count[i] = temp + 1 else: count[i] = temp ...
s = (input("Enter a string")) n = str(s).count dict = {} l = [] for i in range[:n+1]: if (s[i] in dict{}): l[i] = l[i] + 1 dict.append(s[i]:l[i]) else: l[i] = 1 dict.append({s[i]:l[i]}) print(dict)
def count_chars(str): char_count = {} for char in str: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 return char_count str = "Programming is fun" result = count_chars(str) print(result)
#include <stdio.h> void main() { char s[20]; int count = 0; char a; printf("Enter the string "); for (int i = 0; i != '\0'; i++) { scanf("%s", &s[i]); } for (int i = 0; i != '\0'; i++) { a = s[i]; for (int j = 0; j != '\0'; j++) { if (s[...
def frequency(string): string = string.split().strip() strlist = [] for i in string: strlist.append(i) freq = [] dict = {} for i in strlist: for i not in freq: freq.append(i) c = strlist.count(i) key.dict = i value.dict =...
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { char str, char dict int n,str[20] scanf("%s", &str[i]); for (i = 0; i < n; i++) { if (strcmp(str[i] == 0) set str[i] = 1; printf("%s = %d", s, str[i]); else(strcmp(str[i] != 0) && str[...
int count(char ch) // Consider size of s = 5 { for (int i = 0; i < strlen(ch); i++) { if (strcmp(ch[0], ch[i+1]) == 0) c++; if (strcmp(ch[1], ch[i+1]) == 0) d++; if (strcmp(ch[2], ch[i+1]) == 0) e++; if (strcmp(ch[3], ch[i+1]) == 0) ...
dict = {} count = 0 n = len(s) for i in range(0, n + 1, 1): for j in range(0, i + 1, 1): if s[i] == s[j]: count ++ dict.append(s[i]:count) else: count = 1 dict.append(s[i]:count) print(dict)
void occurrence(String s): dict = {} word = s.split() for i in word: dict[i] = count(i) return dict
def frequency(string): string = string.split().strip() strlist = [] for i in string: strlist.append(i) freq = [] dict = {} for i in strlist: for i not in freq: freq.append(i) c = strlist.count(i) key.dict = i value.dict = c ...
#include <stdio.h> void main() { char s[10]; int count = 0; char a; printf("Enter the string: "); for (int i = 0; i != '\0'; i++) { scanf(" %s", &s[i]); } for (int i = 0; i != '\0'; i++) { a = s[i]; for (int j = 0; j != '\0'; j++) { ...
def count_chars(str): char_count = {} for char in str: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 return char_count str = "Programming is fun" result = count_chars(str) print(result)
s = input("Enter a string") n = str(s).count dict = {} l = [] for i in range[int1]: if (s[i] in dict{}): l[i] = l[i] + 1 dict.append(s[i]:l[i]) else: l[i] = 1 dict.append(s[i]:l[i]) print(dict)
int i, j, temp, count = 0; char input[100]; len = strlen(input[10]) n = input[0]; for (i = n; i < len; i++) { for (j = i + 1; j < len-1; j++) { if input[i] == input[j] { count++; } printf(" ": " ", input[i], count); } }
def count(s): count = 0 leng = s.length arr = [], for (i=0; i<leng; i++) { if s.charAt(i) == s.charAt(i+1)) arr[0] s.charAt(i).push() count ++; } else. arr[i]=s.charAt(i).push() count ++; dictionary = {arr[...
#include <string.h> #include <stdio.h> int main() { int n, len, count; printf("Enter the string: "); scanf("%s", &n); len = len(s); for(i = 0; i < len; i++) { if (str(n) = len(s)) { i++; } else { count = count + ...
#include <stdio.h> #include <string.h> void countCharacters(const char* str, int* countDict) { while (*str) { countDict[*str]++; str++; } } int main() { char* inputString; scanf("%s", inputString); int countDict[128] = {0}; countCharacters(inputString, countDict)...
// Python def frequ(string s): i = 0 freq = { } while i < len(s): C = tolower(s[i]) freq[C]++ return freq // C++ unordered_map frequency (String s) { unordered_map<char, int> mp ; int i = 0 , n = s.length() ; for (i = 0 ; i < n ; i++) { Char c = tolower (s(i)) mp...
public static void (String s) { char ch = sc.newchar(); int array[] = sc.nextArray[20]; int length = s.length(); for (i = 1; i <= length; i++) { System.out.println("char is ", i); for (j = 1; j <= length; j++) { System.out.println("count of each char", j); ...
function string_read(input): list[] = input. for i in range list. if list[i] == list[i+1].: count++
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
7