File size: 42,200 Bytes
af488ee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
[
{
"image": "images/Listman11.JPEG",
"text": "sample_list1 = [int(x) for x in input().split(',')]\nsample_list2 = [int(x) for x in input().split(',')]\nl = []\narr = sample_list1 + sample_list2 # The merged result is stored in arr\n\ns = set(arr) # The set function removes duplicates in arr\nl = list(s)\nl.sort() # The sort method sorts the array in ascending order\nprint(l)\n\n# OR\n\n# After taking input and merging into arr, the following steps can be done.\n\nd = {} # Dictionary\n\nfor ele in arr:\n if ele in d:\n d[ele] += 1\n else:\n d[ele] = 1\n\n# This part uses a dictionary to count the number of occurrences of each number."
},
{
"image": "images/Stringman19.JPEG",
"text": "def frequency(string):\n string = string.split().strip()\n strlist = []\n \n for i in string:\n strlist.append(i)\n \n freq = []\n dict = {}\n\n for i in strlist:\n for i not in freq:\n freq.append(i)\n c = strlist.count(i)\n key.dict = i\n value.dict = c\n c = 0\n \n print(dict)\n\n__init__ main():\n frequency(input())"
},
{
"image": "images/Stringman17.JPEG",
"text": "def count_chars(str):\n char_count = {}\n\n for char in str:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n\n return char_count\n\nstr = \"Programming is fun\"\nresult = count_chars(str)\nprint(result)"
},
{
"image": "images/Listman14.JPEG",
"text": "sample_list1 = [3, 1, 4, 1, 5, 9]\nsample_list2 = [2, 6, 5, 3, 5]\n\nsample_list3 = []\n\nfor i in range(0, len(sample_list1)):\n sample_list3[i] = sample_list1[i]"
},
{
"image": "images/closest_value1.JPEG",
"text": "void closestNumber(array,targetNumber) {\n int minimumDifference = 9999;\n int output = 0;\n\n for (int i = 0; i < array.length; i++) {\n if (array[i] >= 0 && targetNumber < 0) {\n int temp = array[i] * -1;\n int temptarget = targetNumber * -1;\n\n if (temptarget > temp) {\n int diff = temptarget - temp;\n minimumDifference = Math.min(minimumDifference, diff);\n output = array[i];\n } else {\n int diff = temp - temptarget;\n minimumDifference = Math.min(minimumDifference, diff);\n output = array[i];\n }\n } \n else if (array[i] < 0 && targetNumber > 0) {\n int temp = array[i] * -1;\n\n if (targetNumber > temp) {\n int diff = targetNumber - temp;\n minimumDifference = Math.min(minimumDifference, diff);\n output = array[i];\n } else {\n int diff = temp - targetNumber;\n minimumDifference = Math.min(minimumDifference, diff);\n output = array[i];\n }\n }"
},
{
"image": "images/Closest_value5.jpg",
"text": "n = int(input(\"Enter the numbers in sorted order: \")\nt = int(input(\"Enter the target number: \"))\n\nfor i in n:\n if i <= t:\n print(\"numbers close to target value:\", i)\n \n\nn = input(\"Enter the text: \")\nprint(n)\n\nfor i in n:\n s = i + 1+1\n print s"
},
{
"image": "images/Consecutive11.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n int i, j, n, ar[30], c[10];\n\n printf(\"Enter the no. of elements\");\n scanf(\"%d\", &n);\n\n printf(\"Enter the elements\");\n for(i = 0; i <= n; i++)\n scanf(\"%d\", &ar[i]);\n for(k=0; k<=10; k++)\n\t for(j = 0; j <= n; j++)\n\t {\n\t\tif(ar[j] == ar[j + 1])\n\t\t{\n\t\t count++;\n\t\t}\n\t\telse\n\t\t break;\n\n\t\tc[k] = count;\n\t }\n\n printf(max [c[k]]);\n}"
},
{
"image": "images/Consecutive8.JPEG",
"text": "#include <stdio.h>\n#include <stdlib.h>\n\nvoid max_one(int arr, int length) {\n int count = 0, max = 0;\n\n for (int i = 0; i <= length; i++) {\n if (arr[i] == 1) \n count++; // count no. of consecutive 1's.\n else \n count = 0; // reset when 0 comes.\n\n if (count > max) { \n max = count; // store max value.\n }\n }\n printf(\"%d\", max);\n}\n\nvoid main() {\n int arr[50], len;\n\n printf(\"Enter the length of array: \");\n scanf(\"%d\", &len);\n\n printf(\"Enter the array: \");\n for (int i = 0; i < len; i++) { // input\n scanf(\"%d\", &arr[i]);\n }\n\n max_one(arr, len);\n}"
},
{
"image": "images/Closest_value3.jpg",
"text": "function Find(arrays,target):\n rduplicate = set(arrays)\n difference = abs(target - rduplicate[0])\n\n for i in range(1, len(rduplicate)):\n d = abs(target - rduplicate[i])\n if d < difference:\n difference = d\n pos = i\n\n print(rduplicate[i])\n\nfind([2, 5, 6, 7, 8, 8, 9], 5)"
},
{
"image": "images/Print100_9.JPEG",
"text": "# Using loop\nn = int(input(\"Enter a limit: \"))\n\nfor i in range(1: n + 1):\n print(i)\n\n# Without using loop\nn = int(input(\"Enter a limit: \"))"
},
{
"image": "images/Closest_value8.JPEG",
"text": "#include <stdio.h>\n\nint main()\n{\n int a[100], i, k, n, b[100], x = 0;\n\n scanf(\"%d\", &k);\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++)\n {\n scanf(\"%d\", &a[i]);\n }\n\n for (i = 0; i < n; i++)\n {\n b[i] = k - a[i];\n }\n\n for (i = 0; i < n; i++)\n {\n if (b[i] > b[i+1])\n {\n x = b[i+1];\n }\n else if (b[i] == b[i+1])\n {\n x = b[i+1];\n }\n else if (b[i] < b[i+1])\n {\n x = b[i];\n b[i+1] = b[i];\n }\n }\n\n printf(\"%d\", x);\n\n \n}"
},
{
"image": "images/Stringman6.jpg",
"text": "#include <stdio.h>\n#include <string.h>\n\nvoid countCharacters(const char* str, int* countDict) {\n while (*str) \n {\n countDict[*str]++;\n str++;\n }\n}\n\nint main() {\n char* inputString;\n \n scanf(\"%s\", inputString);\n\n int countDict[128] = {0};\n \n countCharacters(inputString, countDict);\n\n for (int i = 0; i < 128; i++) {\n if (countDict[i] > 0) {\n printf(\"%c : %d\\n\", i, countDict[i]);\n }\n }\n \n return 0;\n}"
},
{
"image": "images/Consecutive3.JPEG",
"text": "arr = [int(x) for x in input().split()]\nmax = 0;\ni = 0;\nli_max = []\n\ndo{\n if (arr[i] == 1)\n {\n if (max == 0):\n max += 1;\n i++;\n\t\tif (arr[i] == 1 and arr[i + 1] == 1):\n\t\t max += 1;\n\t\t i++;\n\t\telse if (arr[i] == 1 and arr[i + 1] != 1):\n\t\t li_max.append(max)\n if(max>=1 and arr[i+1]==1)\n max+=1\n i++\n else(max>=1 and arr[i+1]!=1)\n max += 1\n i++\n li_max.append(max)\n }\n else{\n i++;\n }\n}while(i<arr.length())\nprint(max(li_max)"
},
{
"image": "images/Consecutive5.JPEG",
"text": "count = 0\nn = int(input(\"Enter the size: \"))\nlist = []\n\nprint(\"Enter the elements:\") # Enter 0's and 1's\nfor i in range(0, n):\n num = int(input())\n list.append(num)\n\nfor i in range(0, n):\n if (list[i] == 1 and list[i+1] == 1:\n count = count + 1\n else:\n \tif(list[i] == 0 and list[i+1]==0):\n count = 0\n\nprint(\"Max number of consecutive 1's is\", count+1)"
},
{
"image": "images/Listman16.JPEG",
"text": "Function array_manipulation(L1, L2):\n L3 = []\n L3 = L1 + L2\n result = []\n\n for ele in L3:\n if ele not in result:\n result.append(L3)\n else:\n continue\n return result.sort()"
},
{
"image": "images/Closest_value4.jpg",
"text": "def closest_number():\n int arr = [ ] \n int num\n arr.sort() \n\n target_number = i \n\n for i in range(arr):\n if i = target_number:\n print(i)\n else \n i != target_number\n\n print(\"Closest value:\", closest)"
},
{
"image": "images/Listman1.JPEG",
"text": "#include <stdio.h>\n#include <iostream.h>\n\nint main()\n{\n int list1[20], list2[20], n1, n2, k = 0, min = 1000,res[20],flag=0,Q=0;\n \n printf(\"Enter the number of elements in list1 and list2: \");\n scanf(\"%d %d\", &n1, &n2);\n \n for (int i = 0; i < n1; i++)\n {\n scanf(\"%d\", &list1[i]);\n }\n\n for (int i = 0; i < n2; i++)\n {\n scanf(\"%d\", &list2[i]);\n }\n\n for (int i = n1-1; i < n1 + n2-1; i++)\n {\n list1[i] = list2[k];\n k++;\n }\n\n for (int i = 0; i < n1 + n2; i++)\n {\n for (int j = 0; j < n1 + n2; j++)\n {\n if (min > list1[j])\n {\n min = list1[j];\n }\n }\n list1[j-1] = 111222333;"
},
{
"image": "images/Stringman26.JPEG",
"text": "s = input(\"Enter a string\")\nn = str(s).count\ndict = {}\nl = []\nfor i in range[int1]:\n if (s[i] in dict{}):\n l[i] = l[i] + 1\n dict.append(s[i]:l[i])\n else:\n l[i] = 1\n dict.append(s[i]:l[i])\n\nprint(dict)"
},
{
"image": "images/Consecutive4.JPEG",
"text": "num = input() # Reading input\n\ncount = 0\ncount_list = [] # To store count\n\nfor i in range(len(num)):\n if (num[i] == 1):\n {\n count += 1\n if (num[i + 1] == 0)\n {\n count_list.append(count)\n count = 0\n }\n }\n\nprint(\"Max number of consecutive 1's is:\", max(count_list))"
},
{
"image": "images/Consecutive13.JPEG",
"text": "arr = [int(x) for x in input()] # Take array as input\nflag = 0\n\nfor ele in arr:\n if ele != 0 and ele != 1:\n flag = 1\n break\n\nif flag == 1:\n print(\"Enter correct input\")\n \ncnt = 0\nm = 0\nmax = 0\n\nfor i in range(0, len(arr)):\n if arr[i] == 1:\n cnt = 1\n for j in range(i, len(arr)):\n if arr[j] != 0:\n m = m + 1\n \tm = m + cnt\n if m > max:\n max = m # For each set of consecutive 1s, the maximum value is found here\n\nprint(\"The maximum no. of consecutive 1's is:\", max)"
},
{
"image": "images/Stringman11.JPEG",
"text": "tr = input().lower()\nd = { }\n\nfor ele in str:\n if ele not in d:\n d[ele] = 1\n else:\n d[ele] += 1\n\nprint(\"dictionary =\", end=\" \")\nprint(d.items())"
},
{
"image": "images/Consecutive9.JPEG",
"text": "list1 = []\n\nnum = int(input(\"Enter the number\")) \ncount = 0 \n\nn = len(num) \n\nfor i in range(0, n-1): \n if num[i] == 1: \n list1[i] = count++\n else: \n break \n\nprint(max(list1))"
},
{
"image": "images/Print100_5.jpg",
"text": "// Without loop\nSystem.out.println(\"1\");\nSystem.out.println(i.next);\nSystem.out.println(i.next+1);\n...\n?"
},
{
"image": "images/Closest_value6.JPEG",
"text": "int A[10], i, n, k;\n\nprintf(\"Target number: \");\nscanf(\"%d\", &k);\n\nfor (i = 0; i < n; i++)\n{\n if (A[i] = k)\n printf(\"Output %d\", A[i]);\n else if (A[i] != k)\n printf(\"Output %d\", A[i] > k);\n else\n printf(\"Output %d\", A[n]);\n}"
},
{
"image": "images/Stringman7.jpg",
"text": "// Python\n\ndef frequ(string s):\n i = 0\n freq = { }\n while i < len(s):\n C = tolower(s[i])\n freq[C]++\n \n return freq\n\n// C++\n\nunordered_map frequency (String s) {\n\n\tunordered_map<char, int> mp ;\n\n\tint i = 0 , n = s.length() ;\n\n\tfor (i = 0 ; i < n ; i++) {\n\n\t Char c = tolower (s(i))\n\t mp[c]++ ;\n\n\treturn mp ;\n}"
},
{
"image": "images/Print100_12.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n n = 1;\n \n if (n <= 100)\n {\n printf(\"%d\\t\", n);\n n = n + 1;\n }\n}"
},
{
"image": "images/Listman4.JPEG",
"text": "def mergeList(list_1, list_2):\n list_3 = list_1 + list_2 # Merging lists\n\n for i in list_3:\n if (count(i) > 1):\n {\n list_3.remove(i) # Removing duplicate values\n\t}\n list_3.sort()\n\n return (list_3) # Return the results in ascending order"
},
{
"image": "images/Print100_3.JPEG",
"text": "import java.util.Scanner;\n\npublic class Numbers {\n public static void Numbers(int s, int e) {\n if (s <= e) {\n System.out.println(s);\n Numbers(s + 1, e);\n }\n }\n\n public static void main(String[] args) {\n Numbers(1, 100);\n }\n}"
},
{
"image": "images/Consecutive19.JPEG",
"text": "count = 0\nn = int(input(\"Enter the size: \")) \nlist = [] \n\nprint(\"Enter the elements:\") # Enter 0's and 1's\nfor i in range(0, n): \n num = int(input()) \n list.append(num) \n\nfor i in range(0, n): \n if (list[i] == 1 and list[i + 1] == 1): \n count = count + 1 \n else: \n if list1[i] == 0 and list1[i + 1] == 0: \n count = 0 \n\nprint(\"Max number of consecutive 1's is\", count + 1)"
},
{
"image": "images/Print100_13.JPEG",
"text": "def add1(s):\n if(s < 101):\n print(s)\n s = s + 1\n add1(s)\n\n__init__main():\n add1(1)"
},
{
"image": "images/Print100_14.JPEG",
"text": "#include <stdio.h>\n\nvoid number(int n) {\n if (n != 100) {\n printf(\"%d \", n);\n }\n\n if (n <= 100) {\n printf(\"%d \", n);\n n++;\n number(n);\n }\n}\n\nint main() {\n int n = 1;\n number(n);\n return 0;\n}"
},
{
"image": "images/Closest_value.JPEG",
"text": "#include <stdio.h>\n\nint main() \n{\n int a[100], n, tar, j, sum, temp, b[100];\n\n printf(\"Enter the size of array: \");\n scanf(\"%d\", &n);\n\n printf(\"Enter the array: \");\n for (int i = 0; i < n; i++) \n {\n scanf(\"%d\", &a[i]);\n }\n\n printf(\"Enter the target number: \");\n scanf(\"%d\", &tar);\n\n temp = tar;\n for (j = 0; j < n; j++) \n {\n b[j] = tar - a[j];\n\n if (tar == a[j]) \n {\n printf(\"%d\", tar);\n break;\n }\n }\n\n \n}"
},
{
"image": "images/Stringman25.JPEG",
"text": "def count_chars(str):\n char_count = {}\n\n for char in str:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n\n return char_count\n\nstr = \"Programming is fun\"\nresult = count_chars(str)\nprint(result)"
},
{
"image": "images/Stringman20.JPEG",
"text": "int count(char ch) // Consider size of s = 5\n{\n for (int i = 0; i < strlen(ch); i++)\n {\n if (strcmp(ch[0], ch[i+1]) == 0)\n c++;\n\n if (strcmp(ch[1], ch[i+1]) == 0)\n d++;\n\n if (strcmp(ch[2], ch[i+1]) == 0)\n e++;\n\n if (strcmp(ch[3], ch[i+1]) == 0)\n f++;\n\n if (strcmp(ch[4], ch[i+1]) == 0)\n g++;\n }\n\n return \n {\n ch[0] = c;\n ch[1] = d;\n ch[2] = e;\n ch[3] = f;\n ch[4] = g;\n };"
},
{
"image": "images/Stringman1.JPEG",
"text": "def StringCount(s):\n dictionary = {}\n\n for ch in s:\n if s[ch] = s[ch+1]:\n c = c + 1\n \n dictionary.append(ch, c)\n\n print(dictionary)\n\na = StringCount(\"Programming is fun\")\nprint(a)"
},
{
"image": "images/Stringman4.JPEG",
"text": "def count(s):\n count = 0\n leng = s.length\n arr = [],\n\n for (i=0; i<leng; i++)\n {\n if s.charAt(i) == s.charAt(i+1))\n arr[0]\n s.charAt(i).push()\n count ++;\n }\n else.\n arr[i]=s.charAt(i).push()\n count ++;\n\n dictionary = {arr[i]: count]"
},
{
"image": "images/Consecutive16.JPEG",
"text": "list1 = []\nnum = int(input(\"Enter the numbers \"))\ncount = 0\n\nn = len(num)\n\nfor i in range(0, n-1):\n if (num[i] == 1):\n list1[i] = count++\n else:\n break\n\nprint(max(list1))"
},
{
"image": "images/Stringman16.JPEG",
"text": "s = (input(\"Enter a string\"))\nn = str(s).count\ndict = {}\nl = []\n\nfor i in range[:n+1]:\n if (s[i] in dict{}):\n l[i] = l[i] + 1\n dict.append(s[i]:l[i])\n else:\n l[i] = 1\n \tdict.append({s[i]:l[i]})\n\nprint(dict)"
},
{
"image": "images/Listman9.JPEG",
"text": "#include <stdio.h>\nvoid merge()\n{\n s1 = [3,1,4,5,9]\n\n s2 = [2,6,5,3,5]\n\n s3 = append[s1, s2];\n\n print(s3);\n}"
},
{
"image": "images/Consecutive12.JPEG",
"text": "arr = [0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0]\ncount = 0\nn = len.arr\n\nfor i in range(0, n):\n if arr[i] == 1:\n count = count + 1\n\nprint(\"Max number of consecutive 1's is:\")\nprint(count)"
},
{
"image": "images/Stringman23.JPEG",
"text": "def frequency(string):\n string = string.split().strip()\n strlist = []\n \n for i in string:\n strlist.append(i)\n\n freq = []\n dict = {}\n\n for i in strlist:\n for i not in freq:\n freq.append(i)\n c = strlist.count(i)\n key.dict = i\n value.dict = c\n c = 0\n\n print(dict)\n\n__init__main():\n frequency(input())"
},
{
"image": "images/Consecutive14.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n int i, j, n, ar[20], c[10];\n\n printf(\"Enter the no. of elements: \");\n scanf(\"%d\", &n);\n\n printf(\"Enter the elements:\\n\");\n for (i = 0; i < n; i++)\n scanf(\"%d\", &ar[i]);\n for(k=0;k<=10;k++)\n\t for (j = 0; j < n; j++)\n\t {\n\n\t\t if (ar[j] == ar[j + 1])\n\t\t\tcount++;\n\t\t else\n\t\t\tbreak;\n\t\t\t\n\t\t\tc[k] = count;\n\t }\n\n printf(max[c[k]]); \n}"
},
{
"image": "images/Consecutive10.JPEG",
"text": "#include <stdio.h>\n#include <conio.h>\n#include <stdlib.h>\n\nint main()\n{\n int a[], n, i, j;\n\n printf(\"Enter the array size:\");\n scanf(\"%d\", &n);\n\n for(i = 0; i < n; i++)\n {\n printf(\"Enter the required array element:\");\n scanf(\"%d\", &a[i]);\n }\n\n while(i = 0, a[i], i++)\n {\n j = 0;\n if a[i] == 1\n {\n j += 1;\n }\n }\n\n printf(\"Enter the number of consecutive 1's: \");\n scanf(\"%d\", &j);\n\n return 0;"
},
{
"image": "images/Print100_2.JPEG",
"text": "#include <stdio.h>\n\nint main() {\n int n = 100 , i=1;\n if (i <= n)\n {\n printf( i);\n i = i+1;\n }\n return 100;\n}"
},
{
"image": "images/Stringman13.JPEG",
"text": "dict = {}\n\ncount = 0\nn = len(s)\n\nfor i in range(0, n+1, 1):\n for j in range(0, i+1, 1):\n if (s[i] == s[j]):\n count ++\n dict.append(s[i]: count)\n\n else:\n count = 1\n dict.append(s[i]: count)\n\nprint(dict)"
},
{
"image": "images/Stringman2.JPEG",
"text": "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\nvoid main() {\n char str, char dict\n int n,str[20]\n\n scanf(\"%s\", &str[i]);\n\n for (i = 0; i < n; i++) {\n if (strcmp(str[i] == 0) \n set str[i] = 1;\n printf(\"%s = %d\", s, str[i]);\n \n else(strcmp(str[i] != 0) && str[i]==1): \n {\n \t printf(\"%s\", = \"%d\", str, str[i]);\n \n return 0;\n}"
},
{
"image": "images/Closest_value2.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n int arr[10];\n int i, n, t, diff;\n\n printf(\"Enter the size of array:\\n\");\n scanf(\"%d\", &n);\n\n printf(\"Enter the sorted array:\\n\");\n for (i = 0; i < n; i++)\n {\n scanf(\"%d\", &a[i]);\n }\n\n printf(\"Enter target number:\\n\");\n scanf(\"%d\", &t);\n\n \n\n for (i = 0; i < n; i++)\n {\n diff[i] = t - a[i];\n }\n\n for (i = 0; i < n; i++)\n {\n for (j = 0; j < n; j++)\n {\n if (diff[j] > diff[j+1])\n {\n temp = diff[j];\n diff[j] = diff[j+1];\n diff[j+1] = temp;\n }\n }\n\tif((diff[i]+a[i])==t)\n\t\tprint(\"%d\",a[i]);\n }"
},
{
"image": "images/Stringman22.JPEG",
"text": "void occurrence(String s):\n dict = {}\n word = s.split()\n\n for i in word:\n dict[i] = count(i)\n\n return dict"
},
{
"image": "images/File_han3.JPEG",
"text": "#include <stdio.h>\n#include <stdlib.h>\n\nint sum(FILE fp)\n{\n int s = 0, i;\n\n while (getc(fp) != EOF)\n {\n i = gets(fp);\n s = s + i;\n }\n return s;\n}\n\nint main()\n{\n FILE *fp;\n fp = fopen(\"input.txt\", \"r\");\n a = sum(fp);\n printf(\"%d\", a);\n fclose(fp);\n}"
},
{
"image": "images/Print100_10.JPEG",
"text": "#include <stdio.h>\n\nvoid number(int n) {\n\n \n if (n <= 100) {\n printf(\"%d \", n);\n n++;\n number(n);\n }\n}\n\nint main() {\n int n = 1;\n number(n);\n return 0;\n}"
},
{
"image": "images/Closest10.JPEG",
"text": "def prgm(array[], target):\n list = []\n\n for i in array:\n list.append(array[i]) \n\n list = list.set()\n\n for i in range(len(list)):\n\n if list[i] == target:\n return target\n\n elif list[i] > target:\n return list[i]\n\n else:\n for i in range(len(list)):\n minimum = min(target - list[i], target - list[i + 1])\n\n for i in range(len(list)):\n if (target - list[i] == minimum):\n return list[i]"
},
{
"image": "images/Stringman9.JPEG",
"text": "function string_read(input):\n\n list[] = input.\n\n for i in range list.\n\n if list[i] == list[i+1].:\n\n count++"
},
{
"image": "images/Consecutive2.JPEG",
"text": "print(\"Enter no of elements\")\nn = int(input())\na = []\n\nfor i in range(n):\n num = int(input)\n a.append(num)\n\nl = len(a)\nc = 0\nmax = 0\n\nfor i in range(l):\n if a[i] == 1:\n c = c + 1\n if c > max:\n max = c\n if a[i] == 0:\n c = 0\n\nprint(\"Maximum no of consecutive 1's is:\", max)"
},
{
"image": "images/Closest12.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n int a[100], n, target, temp1, temp2, index;\n\n scanf(\"%d\", &n); // Read the number of elements\n\n for (int i = 0; i < n; i++) // Initialize the array\n scanf(\"%d\", &a[i]);\n\n scanf(\"%d\", &target); // Read the target value\n temp2 = __INT_MAX(); // Set temp2 to the highest integer value for comparison\n\n for (int i = 0; i < n; i++)\n {\n temp1 = a[i] - target;\n\n if (temp1 < 0) // Convert the difference to a positive number\n temp1 = temp1* -1;\n\n if (temp1 < temp2) // Store the least difference found\n {\n temp2 = temp1;\n index = i; // Store the index of the closest element\n }\n }\n\n printf(\"%d\", a[index]); // Print the closest element\n}"
},
{
"image": "images/Consecutive18.JPEG",
"text": "L1 = input()\nlist1 = list(L1)\n\ncount = 0\nonecount = []\n\nfor ele in list1:\n if ele == 1:\n count += 1\n else:\n if count > 0:\n onecount.append(count)\n count = 0\n\nmax_count = max(onecount)\nprint(max_count)"
},
{
"image": "images/Closest_value7.JPEG",
"text": "def prgm, (array[], target):\n List = []\n\n for i in array:\n List.append(array[i]) \n\n List1 = List.set()\n\n for i in range(len(List)):\n if list[i] == target:\n return target\n elif list1[i] > target:\n return list1[i]\n\telse:\n\t for i in range(len(list)):\n\t\tminimum = min(target - list[i], target - list[i+1])\n\n\t for i in range(len(list)):\n\t\tif (target - list[i]) == minimum:\n\t\t return list[i]"
},
{
"image": "images/Print100_4.JPEG",
"text": "// Recursive Function\nvoid num(int n) {\n if (n <= 100) {\n printf(\" %d \", n);\n num(n + 1);\n } \n else {\n exit(0);\n }\n}"
},
{
"image": "images/Closest13.JPEG",
"text": "#include <stdio.h>\n\nint main() {\n int a[100], i, k, n, b[100], x = 0;\n\n printf(\"Enter k: \");\n scanf(\"%d\", &k);\n\n printf(\"Enter n: \");\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n\n for (i = 0; i < n; i++) {\n b[i] = k - a[i];\n }\n\n for (i = 0; i < n; i++) {\n if (b[i] > b[i + 1]) {\n x = b[i];\n } else if (b[i] == b[i + 1]) {\n x = b[i];\n } else if (b[i] < b[i + 1]) {\n x = b[i + 1];\n }\n }\n\n printf(\"%d\", x);\n\n return 0;\n}"
},
{
"image": "images/Print100_11.JPEG",
"text": "def add1(s):\n if (s < 101):\n print(s)\n s = s + 1\n add1(s)\n\n__init__main:\n add1(1)"
},
{
"image": "images/Listman8.JPEG",
"text": "def listanclug(a)\n\nsample_list1 = int(input(a))\n\nsample_list2 = int(input(b))\n\nsample_list3 = [ ]\n\nsample_list3 = append(sample_list1(sample_list2))"
},
{
"image": "images/Stringman3.JPEG",
"text": "int i, j, temp, count = 0;\nchar input[100];\n\nlen = strlen(input[10])\nn = input[0];\n\nfor (i = n; i < len; i++) {\n for (j = i + 1; j < len-1; j++) {\n if input[i] == input[j]\n {\n count++;\n }\n printf(\" \": \" \", input[i], count);\n }\n}"
},
{
"image": "images/Listman3.JPEG",
"text": "sample_list1 = [int(x) for x in input().split()]\nsample_list2 = [int(x) for x in input().split()]\n\nfinal_list = []\nres = []\n\nfinal_list = sample_list1.merge(sample_list2)\n\nres = sort(final_list)\n\nprint(res)"
},
{
"image": "images/Stringman18.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n char s[20];\n int count = 0;\n char a;\n\n printf(\"Enter the string \");\n for (int i = 0; i != '\\0'; i++)\n {\n scanf(\"%s\", &s[i]);\n }\n\n for (int i = 0; i != '\\0'; i++)\n {\n a = s[i];\n for (int j = 0; j != '\\0'; j++)\n {\n if (s[i] != s[j])\n {\n count = 1;\n }\n \n\n\t else if (s[i] == s[j])\n\t {\n\t\tcount++;\n\t }\n\t}\n \tprintf(\"%c %d\", a, count);\n }\n}"
},
{
"image": "images/Listman5.JPEG",
"text": "list1 = [3,1,4,1,5,9]\nlist2 = [2,6,5,3,5]\n\ndef merge(list1, list2):\n list3 = []\n for i in list1:\n if i not in list3:\n list3.append[i]\n\n for j in list2:\n if j not in list3:\n list3.append[j]\n return list3\n\nprint(\"Merged list in ascending order\")\n\nprint(list3.sort())"
},
{
"image": "images/File_han2.jpg",
"text": "def prgm2():\n File = input.txt.open(\"r\")\n\n list = File.read()\n sum = 0\n for i in list:\n sum = sum + i\n\n return sum"
},
{
"image": "images/Consecutive15.JPEG",
"text": "#include <stdio.h>\n#include <conio.h>\n#include <stdlib.h>\n\nint main()\n{\n int a[], n, i, j;\n\n printf(\"Enter the array size: \");\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++)\n {\n printf(\"Enter the required array elements: \");\n scanf(\"%d\", &a[]);\n }\n\n j = 0;\n if (a[i] == 1)\n {\n\tj =+ 1;\n }\n\n printf(\"Enter the number of consecutive 1's\");\n scanf(\"%d\",&j)\n\n return 0;\n}"
},
{
"image": "images/File_han4.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n FILE *fp;\n fp = fopen(\"input.txt\", \"r\");\n\n char str;\n int sum;\n\n while (str != endln)\n {\n str = readln(fp);\n sum = sum + str;\n }\n\n printf(\"%d\", sum);\n}"
},
{
"image": "images/Consecutive1.JPEG",
"text": "#include <stdio.h>\n#include<iostream.h>\n\nvoid main() {\n int arr[20], n, temp = 0, con = 0;\n\n printf(\"Enter the number of elements:\\n\");\n scanf(\"%d\", &n);\n\n printf(\"Enter the array elements (0 or 1):\\n\");\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &arr[i]);\n }\n\n printf(\"\\n\");\n arr[n] = 0; \n\n for (int i = 0; i < n; i++) {\n if (arr[i] == 1) {\n temp++;\n\n if (arr[i + 1] == 0) { \n if (con < temp) {\n con = temp;\n }\n temp = 0;\n }\n }\n }\n\n printf(\"num of 1's are %d \\n\", con);\n}"
},
{
"image": "images/Stringman21.JPEG",
"text": "dict = {}\ncount = 0\nn = len(s)\n\nfor i in range(0, n + 1, 1):\n for j in range(0, i + 1, 1):\n if s[i] == s[j]:\n count ++\n dict.append(s[i]:count)\n else:\n count = 1\n dict.append(s[i]:count)\n\nprint(dict)"
},
{
"image": "images/Closest_value9.JPEG",
"text": "#include <stdio.h>\n\n\nvoid main()\n{\n int a[100], n, target, temp1, temp2, index;\n\n scanf(\"%d\", &n);\n\n for (int i = 0; i < n; i++) \n scanf(\"%d\", &a[i]); // Initializing array\n\n scanf(\"%d\", &target); // Initializing target\n\n temp2 = INT_MAX(); // Setting temp2 to the highest int value for the first iteration to be successful\n\n for (int i = 0; i < n; i++)\n {\n temp1 = a[i] - target;\n\n if (temp1 < 0)\n temp1 = temp1 * -1; // Converting the difference to a positive number for comparison\n\n if (temp1 < temp2)\n {\n temp2 = temp1; // Storing the least difference through each iteration\n index = i; // Storing the index\n }\n }\n\n printf(\"%d\", a[index]);\n}"
},
{
"image": "images/Print100_7.jpg",
"text": "void print()\n{\n s = 0;\n print(s);\n a = s + 1;\n print(a);\n goto (a);\n}"
},
{
"image": "images/File_han1.jpg",
"text": "def file_handle():\n file1 = \"input.txt\"\n\n # Read all the contents of file1 to file2\n file1.read()\n file2.write()\n\n num = arr.num\n sum = sum(arr)\n print(sum)\n\n return 0"
},
{
"image": "images/Listman7.JPEG",
"text": "Sample_list1 = [3, 1, 4, 1, 5, 9]\n\nSample_list2 = [2, 6, 5, 3, 5]\n\nSample_list3 = [ ]\n\nfor i in range(0, len( Sample_list1)):\n\n Sample_list3[i] = Sample_list1[i]"
},
{
"image": "images/Consecutive7.JPEG",
"text": "function arraymanipulation(L1[], L2[]): \n L3 = [] \n L3 = L1 + L2 ; result = [] \n\n for ele in L3: \n if ele not in result: \n result.append(L3) \n\n else : \n continue . \n\n return result.sort()"
},
{
"image": "images/Listman12.JPEG",
"text": "#include <stdio.h>\n\nvoid array()\n{\n s1 = [3, 1, 4, 5, 9];\n s2 = [2, 1, 5, 3, 5];\n\n s3 = append[s1, s2];\n\n print(s3);\n}"
},
{
"image": "images/Stringman10.JPEG",
"text": "Void occurance(String s):\n dict = { }\n word = s.split()\n\n for i in word:\n dict[i] = count(i)\n\n return dict"
},
{
"image": "images/Listman2.JPEG",
"text": "sl1 = [3, 1, 4, 1, 5, 9]\nsl2 = [2, 6, 5, 3, 5]\n\nl2 = length(sl2)\nl1 = length(sl1)\nl1.extend(l2) # Function to merge lists in Python\nc = l1\n\nfor i in range(l2):\n sl1[c] = sl2[i]\n c = c + 1\nl1 = length(sl1)\n\nfor i in range(l1):\n if(sl1.count(sl1[i] > 1) \n sl1.remove(sl1[i])\n \nsl1.sort()\nprint(sl1)\nfor i in range(l1-1):\n for j in range(l1-i-1):\n if(a[i] > a[j]):\n t = sl1[i]\n sl1[i] = sl1[j]\n sl1[j] = t\nprint(sl1)"
},
{
"image": "images/Stringman14.JPEG",
"text": "def char_count(s):\n dict1 = {} # Empty dictionary\n\n for i in s: # Iterate through string\n if i not in dict1: # Check presence of character\n dict1.add(i) # Add i as key of dictionary\n i.value = s.count(i) # Count the occurrences of i and add it as value of item\n\n return dict1 # Return dictionary\n\n for i, j in dict1.items():\n return f\"{i} : {j}\" # Print all items"
},
{
"image": "images/Consecutive17.JPEG",
"text": "#include <stdio.h>\n#include <stdlib.h>\n\nvoid max_one(int arr, int length) {\n int count = 0, max = 0;\n\n for (int i = 0; i <= length; i++) {\n if (arr[i] == 1) { // count no. of consecutive 1's\n count++;\n } else {\n count = 0; // reset when 0 comes\n }\n\n if (count > max) {\n max = count; // store max value\n }\n }\n printf(\"%d\", max);\n}\n\nvoid main() {\n int arr[50], len;\n\n printf(\"Enter the length of array: \");\n scanf(\"%d\", &len);\n\n printf(\"Enter the array: \");\n for (int i = 0; i < len; i++) {\n scanf(\"%d\", &arr[i]); // input\n }\n\n max_one(arr, len);\n}"
},
{
"image": "images/Print100_8.JPEG",
"text": "number = 0;\n\nprint_numbers(number) \n{\n printf(\"number + 1);\n}\n\nreturn_function() \n{\n while (number <= 100) \n {\n print_numbers(number);\n number = number + 1;\n }\n}\n\nreturn_function();"
},
{
"image": "images/Stringman5.JPEG",
"text": "#include <string.h>\n#include <stdio.h>\n\nint main()\n{\n int n, len, count;\n printf(\"Enter the string: \");\n \n scanf(\"%s\", &n);\n \n len = len(s);\n \n for(i = 0; i < len; i++)\n { \n if (str(n) = len(s)) \n {\n i++;\n }\n else\n {\n count = count + 1;\n }"
},
{
"image": "images/Listman15.JPEG",
"text": "def manipulate(list1, list2):\n list3 = list1.append(list2)\n \n list3 = list3.sort()\n \n # to remove duplicates\n for i in list3:\n for j in list3:\n if i == j:\n list3.pop(j)\n\n return list3"
},
{
"image": "images/Filehan7.JPEG",
"text": "#include <stdio.h>\n#include <stdlib.h>\n\nint sum(FILE fp)\n{\n int s = 0, i;\n\n while (geth(fp) != EOF)\n {\n i = gets(fp);\n s = s + i;\n }\n\n return s;\n}\n\nint main()\n{\n FILE *fp;\n fp = fopen(\"input.txt\", \"a\");\n a = sum(fp);\n printf(\"%d\", a);\n fclose(fp);\n}"
},
{
"image": "images/Listman6.JPEG",
"text": "def manipulate(list1, list2):\n\n list3 = list1.append(list2)\n\n list3 = list3.sort()\n \n # to remove duplicate.\n for i in list3:\n for j in list3:\n if i == j:\n list3.pop(j)\n\n return list3"
},
{
"image": "images/Stringman12.JPEG",
"text": "int count(char ch) // Consider size of s = 5\n{\n for(int i = 0; i < strlen(ch); i++)\n {\n if(strcmpi(ch[0], ch[i+1]) == 0)\n c++;\n\n if(strcmpi(ch[1], ch[i+1]) == 0)\n d++;\n\n if(strcmpi(ch[2], ch[i+1]) == 0)\n e++;\n\n if(strcmpi(ch[3], ch[i+1]) == 0)\n f++;\n\n if(strcmpi(ch[4], ch[i+1]) == 0)\n g++;\n }\n\n return\n {\n ch[0] = c;\n ch[1] = d;\n ch[2] = e;\n ch[3] = f;\n ch[4] = g;\n };\n}"
},
{
"image": "images/Filehan6.JPEG",
"text": "#include <stdio.h>\n\nvoid main()\n{\n FILE *fp;\n fp = fopen(\"input.txt\", \"r\");\n\n char str;\n int sum;\n\n while (str != endln)\n {\n str = readln(fp);\n sum = sum + str;\n }\n\n printf(\"%d\", sum);\n}"
},
{
"image": "images/File_han.jpg",
"text": "void file_read(filename) {\n int b, sum = 0;\n\n f1 = fopen(filename, \"r\");\n\n while (!f1.eof()) {\n f1.read(l);\n b = parseInt(l);\n sum = sum + b;\n }\n\n printf(\"Sum = %d\\n\", sum);\nvoid main() {\n file_read(\"Input.txt\");\n}"
},
{
"image": "images/Closest11.JPEG",
"text": "int A[10], i, n, k;\n\nprintf(\"Target number: \");\nscanf(\"%d\", &k);\n\nfor (i = 0; i < n; i++)\n{\n if (A[i] = k)\n printf(\"Output %d\", A[i]);\n\n else if (A[i] != k)\n printf(\"Output %d\", A[i]>k);\n\n else\n printf(\"Output %d\", A[n]);\n}"
},
{
"image": "images/Print100_6.JPEG",
"text": "void print()\n{\n int num;\n print(randomize num(100));\n}"
},
{
"image": "images/Consecutive6.JPEG",
"text": "L1 = input()\nList1 = list(L1)\n\ncount = 0\nonecount = []\n\nfor ele in list1\n if ele == 1: \n count += 1\n else:\n if count > 0:\n onecount.append(count)\n count = 0\n\nmax_count = max(onecount)\nprint(max_count)"
},
{
"image": "images/Listman10.JPEG",
"text": "sample_list1 = [3, 1, 4, 1, 5, 9]\nsample_list2 = [2, 6, 5, 3, 5]\n\nnew_list = sample_list1 + sample_list2\n\ntuple1 = ()\ntuple1 = tuple.new_list\n\nnew_list1 = list.tuple1\n\n\nprint(new_list.ascending)"
},
{
"image": "images/Listman17.JPEG",
"text": "list1 = [3, 1, 4, 1, 5, 9]\nlist2 = [2,6, 5, 3, 5]\n\ndef merge(list1, list2):\n list3 = []\n \n for i in list1:\n if i not in list3:\n list3.append[i]\n \n for j in list2:\n if j not in list3:\n list3.append[j]\n return list3\n\nprint(\"Merged list in ascending order:\")\nprint(list3.sort())"
},
{
"image": "images/Print100.JPEG",
"text": "print()\n{\n int n;\n n = 0;\n\n for (i=n; n <= 100; n++)\n {\n printf(\" \", n);\n }\n}"
},
{
"image": "images/Stringman15.JPEG",
"text": "set = {}\ntemp = 1\ncount = []\nstring = int(input())\n\nstring1 = string.split(' ')\narr = []\n\ndef strManipulation:\n for i in range[0, len(string1)]:\n for j in range[i+1, len(string1)]:\n if (string1[i] == string1[j]):\n count[i] = temp + 1\n else:\n count[i] = temp\n\n for i in range[0, len(string1)]:\n set = {string1[i]: count[i]}\n\n return set\n\nstrManipulation"
},
{
"image": "images/Stringman24.JPEG",
"text": "#include <stdio.h>\n\nvoid main() \n{\n char s[10];\n int count = 0;\n char a;\n\n printf(\"Enter the string: \");\n for (int i = 0; i != '\\0'; i++) \n {\n scanf(\" %s\", &s[i]);\n }\n\n for (int i = 0; i != '\\0'; i++) \n {\n a = s[i];\n for (int j = 0; j != '\\0'; j++) \n {\n if (s[i] != s[j]) \n {\n count = 1;\n } \n else if (s[i] == s[j]) \n {\n count++;\n }\n }\n printf(\"%s %d\", a, count);\n }\n}"
},
{
"image": "images/Listman13.JPEG",
"text": "def listadency(a):\n sample_list1 = int(input(a))\n sample_list2 = int(input(b))\n\n sample_list3 = {}\n sample_list3 = append(sample_list1(sample_list2))"
},
{
"image": "images/Stringman8.JPEG",
"text": "public static void (String s)\n{\n char ch = sc.newchar();\n int array[] = sc.nextArray[20];\n int length = s.length();\n\n for (i = 1; i <= length; i++)\n {\n System.out.println(\"char is \", i);\n\n for (j = 1; j <= length; j++)\n {\n System.out.println(\"count of each char\", j);\n }\n }\n\n for (i = 1; i <= length; i++)\n {\n for (j = 1; j <= length; j++)\n {\n System.out.println(\"char: count\", i, j);\n }\n }"
},
{
"image": "images/Stringman.JPEG",
"text": "function count(s):\n l = list(s.split(' '))\n dct = {}\n\n for i in l:\n if (i in dct):\n dct[i] = dct[i] + 1\n else:\n dct[i] = 0\n\n return dct"
},
{
"image": "images/Print100_1.JPEG",
"text": "#include <stdio.h>\nint main()\n{\n int first = 0, second = 1, third=2;\n\n printf(\"%d\", &first);\n printf(\"%d\", &second);\n while (third < 100)\n {\n printf(\"%d\", &third);\n third = third + second;\n third++;\n }"
},
{
"image": "images/Print100_15.JPEG",
"text": "# Using loop\nn = int(input(\"Enter a limit: \"))\n\nfor i in range(1 : n+1):\n print(i)\n\n# Without using loop\nn = int(input(\"Enter a limit: \"))"
},
{
"image": "images/Filehan5.JPEG",
"text": "def pgm2():\n File = input.txt.open(\"r\")\n list = File.read()\n sum = 0 \n for i in list: \n sum = sum + i \n\n return sum"
}
] |