File size: 278,516 Bytes
31dc8dc | 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 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 | [
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 2,
"prompt": "Write a function to find the shared elements from the given two lists.",
"code": "def similar_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1) & set(test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))",
"assert set(similar_elements((1, 2, 3, 4),(5, 4, 3, 7))) == set((3, 4))",
"assert set(similar_elements((11, 12, 14, 13),(17, 15, 14, 13))) == set((13, 14))"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 3,
"prompt": "Write a python function to identify non-prime numbers.",
"code": "import math\ndef is_not_prime(n):\n result = False\n for i in range(2,int(math.sqrt(n)) + 1):\n if n % i == 0:\n result = True\n return result",
"test_imports": [],
"test_list": [
"assert is_not_prime(2) == False",
"assert is_not_prime(10) == True",
"assert is_not_prime(35) == True",
"assert is_not_prime(37) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 4,
"prompt": "Write a function to find the n largest integers from a given list of numbers, returned in descending order.",
"code": "import heapq as hq\ndef heap_queue_largest(nums,n):\n largest_nums = hq.nlargest(n, nums)\n return largest_nums",
"test_imports": [],
"test_list": [
"assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]",
"assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75]",
"assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 6,
"prompt": "Write a python function to check whether the two numbers differ at one bit position only or not.",
"code": "def is_Power_Of_Two (x): \n return x and (not(x & (x - 1))) \ndef differ_At_One_Bit_Pos(a,b): \n return is_Power_Of_Two(a ^ b)",
"test_imports": [],
"test_list": [
"assert differ_At_One_Bit_Pos(13,9) == True",
"assert differ_At_One_Bit_Pos(15,8) == False",
"assert differ_At_One_Bit_Pos(2,4) == False",
"assert differ_At_One_Bit_Pos(2, 3) == True",
"assert differ_At_One_Bit_Pos(5, 1) == True",
"assert differ_At_One_Bit_Pos(1, 5) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 7,
"prompt": "Write a function to find all words which are at least 4 characters long in a string.",
"code": "import re\ndef find_char_long(text):\n return (re.findall(r\"\\b\\w{4,}\\b\", text))",
"test_imports": [],
"test_list": [
"assert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])",
"assert set(find_char_long('Jing Eco and Tech')) == set(['Jing', 'Tech'])",
"assert set(find_char_long('Jhingai wulu road Zone 3')) == set(['Jhingai', 'wulu', 'road', 'Zone'])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 8,
"prompt": "Write a function to find squares of individual elements in a list.",
"code": "def square_nums(nums):\n square_nums = list(map(lambda x: x ** 2, nums))\n return square_nums",
"test_imports": [],
"test_list": [
"assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]",
"assert square_nums([10,20,30])==([100,400,900])",
"assert square_nums([12,15])==([144,225])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 9,
"prompt": "Write a python function to find the minimum number of rotations (greater than 0) required to get the same string.",
"code": "def find_Rotations(str): \n tmp = str + str\n n = len(str) \n for i in range(1,n + 1): \n substring = tmp[i: i+n] \n if (str == substring): \n return i \n return n ",
"test_imports": [],
"test_list": [
"assert find_Rotations(\"aaaa\") == 1",
"assert find_Rotations(\"ab\") == 2",
"assert find_Rotations(\"abc\") == 3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 11,
"prompt": "Write a python function to remove first and last occurrence of a given character from the string.",
"code": "def remove_Occ(s,ch): \n for i in range(len(s)): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n for i in range(len(s) - 1,-1,-1): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n return s ",
"test_imports": [],
"test_list": [
"assert remove_Occ(\"hello\",\"l\") == \"heo\"",
"assert remove_Occ(\"abcda\",\"a\") == \"bcd\"",
"assert remove_Occ(\"PHP\",\"P\") == \"H\""
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 12,
"prompt": "Write a function to sort a given matrix in ascending order according to the sum of its rows.",
"code": "def sort_matrix(M):\n result = sorted(M, key=sum)\n return result",
"test_imports": [],
"test_list": [
"assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]",
"assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]",
"assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 14,
"prompt": "Write a python function to find the volume of a triangular prism.",
"code": "def find_Volume(l,b,h) : \n return ((l * b * h) / 2) ",
"test_imports": [],
"test_list": [
"assert find_Volume(10,8,6) == 240",
"assert find_Volume(3,2,2) == 6",
"assert find_Volume(1,2,1) == 1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 16,
"prompt": "Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise.",
"code": "import re\ndef text_lowercase_underscore(text):\n patterns = '^[a-z]+_[a-z]+$'\n if re.search(patterns, text):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert text_lowercase_underscore(\"aab_cbbbc\")==(True)",
"assert text_lowercase_underscore(\"aab_Abbbc\")==(False)",
"assert text_lowercase_underscore(\"Aaab_abbbc\")==(False)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 17,
"prompt": "Write a function that returns the perimeter of a square given its side length as input.",
"code": "def square_perimeter(a):\n perimeter=4*a\n return perimeter",
"test_imports": [],
"test_list": [
"assert square_perimeter(10)==40",
"assert square_perimeter(5)==20",
"assert square_perimeter(4)==16"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 18,
"prompt": "Write a function to remove characters from the first string which are present in the second string.",
"code": "NO_OF_CHARS = 256\ndef str_to_list(string): \n\ttemp = [] \n\tfor x in string: \n\t\ttemp.append(x) \n\treturn temp \ndef lst_to_string(List): \n\treturn ''.join(List) \ndef get_char_count_array(string): \n\tcount = [0] * NO_OF_CHARS \n\tfor i in string: \n\t\tcount[ord(i)] += 1\n\treturn count \ndef remove_dirty_chars(string, second_string): \n\tcount = get_char_count_array(second_string) \n\tip_ind = 0\n\tres_ind = 0\n\ttemp = '' \n\tstr_list = str_to_list(string) \n\twhile ip_ind != len(str_list): \n\t\ttemp = str_list[ip_ind] \n\t\tif count[ord(temp)] == 0: \n\t\t\tstr_list[res_ind] = str_list[ip_ind] \n\t\t\tres_ind += 1\n\t\tip_ind+=1\n\treturn lst_to_string(str_list[0:res_ind]) ",
"test_imports": [],
"test_list": [
"assert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'",
"assert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'",
"assert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 19,
"prompt": "Write a function to find whether a given array of integers contains any duplicate element.",
"code": "def test_duplicate(arraynums):\n nums_set = set(arraynums) \n return len(arraynums) != len(nums_set) ",
"test_imports": [],
"test_list": [
"assert test_duplicate(([1,2,3,4,5]))==False",
"assert test_duplicate(([1,2,3,4, 4]))==True",
"assert test_duplicate([1,1,2,2,3,3,4,4,5])==True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 20,
"prompt": "Write a function to check if the given number is woodball or not.",
"code": "def is_woodall(x): \n\tif (x % 2 == 0): \n\t\treturn False\n\tif (x == 1): \n\t\treturn True\n\tx = x + 1 \n\tp = 0\n\twhile (x % 2 == 0): \n\t\tx = x/2\n\t\tp = p + 1\n\t\tif (p == x): \n\t\t\treturn True\n\treturn False",
"test_imports": [],
"test_list": [
"assert is_woodall(383) == True",
"assert is_woodall(254) == False",
"assert is_woodall(200) == False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 56,
"prompt": "Write a python function to check if a given number is one less than twice its reverse.",
"code": "def rev(num): \n rev_num = 0\n while (num > 0): \n rev_num = (rev_num * 10 + num % 10) \n num = num // 10 \n return rev_num \ndef check(n): \n return (2 * rev(n) == n + 1) ",
"test_imports": [],
"test_list": [
"assert check(70) == False",
"assert check(23) == False",
"assert check(73) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 57,
"prompt": "Write a python function to find the largest number that can be formed with the given list of digits.",
"code": "def find_Max_Num(arr) : \n n = len(arr)\n arr.sort(reverse = True) \n num = arr[0] \n for i in range(1,n) : \n num = num * 10 + arr[i] \n return num ",
"test_imports": [],
"test_list": [
"assert find_Max_Num([1,2,3]) == 321",
"assert find_Max_Num([4,5,6,1]) == 6541",
"assert find_Max_Num([1,2,3,9]) == 9321"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 58,
"prompt": "Write a python function to check whether the given two integers have opposite sign or not.",
"code": "def opposite_Signs(x,y): \n return ((x ^ y) < 0); ",
"test_imports": [],
"test_list": [
"assert opposite_Signs(1,-2) == True",
"assert opposite_Signs(3,2) == False",
"assert opposite_Signs(-10,-10) == False",
"assert opposite_Signs(-2,2) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 59,
"prompt": "Write a function to find the nth octagonal number.",
"code": "def is_octagonal(n): \n\treturn 3 * n * n - 2 * n ",
"test_imports": [],
"test_list": [
"assert is_octagonal(5) == 65",
"assert is_octagonal(10) == 280",
"assert is_octagonal(15) == 645"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 61,
"prompt": "Write a python function to count the number of substrings with the sum of digits equal to their length.",
"code": "from collections import defaultdict\ndef count_Substrings(s):\n n = len(s)\n count,sum = 0,0\n mp = defaultdict(lambda : 0)\n mp[0] += 1\n for i in range(n):\n sum += ord(s[i]) - ord('0')\n count += mp[sum - (i + 1)]\n mp[sum - (i + 1)] += 1\n return count",
"test_imports": [],
"test_list": [
"assert count_Substrings('112112') == 6",
"assert count_Substrings('111') == 6",
"assert count_Substrings('1101112') == 12"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 62,
"prompt": "Write a python function to find smallest number in a list.",
"code": "def smallest_num(xs):\n return min(xs)\n",
"test_imports": [],
"test_list": [
"assert smallest_num([10, 20, 1, 45, 99]) == 1",
"assert smallest_num([1, 2, 3]) == 1",
"assert smallest_num([45, 46, 50, 60]) == 45"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 63,
"prompt": "Write a function to find the maximum difference between available pairs in the given tuple list.",
"code": "def max_difference(test_list):\n temp = [abs(b - a) for a, b in test_list]\n res = max(temp)\n return (res) ",
"test_imports": [],
"test_list": [
"assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7",
"assert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15",
"assert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 64,
"prompt": "Write a function to sort a list of tuples using the second value of each tuple.",
"code": "def subject_marks(subjectmarks):\n#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])\n subjectmarks.sort(key = lambda x: x[1])\n return subjectmarks",
"test_imports": [],
"test_list": [
"assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]",
"assert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])",
"assert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 65,
"prompt": "Write a function to flatten a list and sum all of its elements.",
"code": "def recursive_list_sum(data_list):\n\ttotal = 0\n\tfor element in data_list:\n\t\tif type(element) == type([]):\n\t\t\ttotal = total + recursive_list_sum(element)\n\t\telse:\n\t\t\ttotal = total + element\n\treturn total",
"test_imports": [],
"test_list": [
"assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21",
"assert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106",
"assert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 66,
"prompt": "Write a python function to count the number of positive numbers in a list.",
"code": "def pos_count(list):\n pos_count= 0\n for num in list: \n if num >= 0: \n pos_count += 1\n return pos_count ",
"test_imports": [],
"test_list": [
"assert pos_count([1,-2,3,-4]) == 2",
"assert pos_count([3,4,5,-1]) == 3",
"assert pos_count([1,2,3,4]) == 4"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 67,
"prompt": "Write a function to find the number of ways to partition a set of Bell numbers.",
"code": "def bell_number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1): \n bell[i][0] = bell[i-1][i-1] \n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0] ",
"test_imports": [],
"test_list": [
"assert bell_number(2)==2",
"assert bell_number(10)==115975",
"assert bell_number(56)==6775685320645824322581483068371419745979053216268760300"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 68,
"prompt": "Write a python function to check whether the given array is monotonic or not.",
"code": "def is_Monotonic(A): \n return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or\n all(A[i] >= A[i + 1] for i in range(len(A) - 1))) ",
"test_imports": [],
"test_list": [
"assert is_Monotonic([6, 5, 4, 4]) == True",
"assert is_Monotonic([1, 2, 2, 3]) == True",
"assert is_Monotonic([1, 3, 2]) == False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 69,
"prompt": "Write a function to check whether a list contains the given sublist or not.",
"code": "def is_sublist(l, s):\n\tsub_set = False\n\tif s == []:\n\t\tsub_set = True\n\telif s == l:\n\t\tsub_set = True\n\telif len(s) > len(l):\n\t\tsub_set = False\n\telse:\n\t\tfor i in range(len(l)):\n\t\t\tif l[i] == s[0]:\n\t\t\t\tn = 1\n\t\t\t\twhile (n < len(s)) and (l[i+n] == s[n]):\n\t\t\t\t\tn += 1\t\t\t\t\n\t\t\t\tif n == len(s):\n\t\t\t\t\tsub_set = True\n\treturn sub_set",
"test_imports": [],
"test_list": [
"assert is_sublist([2,4,3,5,7],[3,7])==False",
"assert is_sublist([2,4,3,5,7],[4,3])==True",
"assert is_sublist([2,4,3,5,7],[1,6])==False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 70,
"prompt": "Write a function to find whether all the given tuples have equal length or not.",
"code": "def find_equal_tuple(Input):\n k = 0 if not Input else len(Input[0])\n flag = 1\n for tuple in Input:\n if len(tuple) != k:\n flag = 0\n break\n return flag\ndef get_equal(Input):\n return find_equal_tuple(Input) == 1",
"test_imports": [],
"test_list": [
"assert get_equal([(11, 22, 33), (44, 55, 66)]) == True",
"assert get_equal([(1, 2, 3), (4, 5, 6, 7)]) == False",
"assert get_equal([(1, 2), (3, 4)]) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 71,
"prompt": "Write a function to sort a list of elements.",
"code": "def comb_sort(nums):\n shrink_fact = 1.3\n gaps = len(nums)\n swapped = True\n i = 0\n while gaps > 1 or swapped:\n gaps = int(float(gaps) / shrink_fact)\n swapped = False\n i = 0\n while gaps + i < len(nums):\n if nums[i] > nums[i+gaps]:\n nums[i], nums[i+gaps] = nums[i+gaps], nums[i]\n swapped = True\n i += 1\n return nums",
"test_imports": [],
"test_list": [
"assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]",
"assert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]",
"assert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 72,
"prompt": "Write a python function to check whether the given number can be represented as the difference of two squares or not.",
"code": "def dif_Square(n): \n if (n % 4 != 2): \n return True\n return False",
"test_imports": [],
"test_list": [
"assert dif_Square(5) == True",
"assert dif_Square(10) == False",
"assert dif_Square(15) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 74,
"prompt": "Write a function to check whether it follows the sequence given in the patterns array.",
"code": "def is_samepatterns(colors, patterns): \n if len(colors) != len(patterns):\n return False \n sdict = {}\n pset = set()\n sset = set() \n for i in range(len(patterns)):\n pset.add(patterns[i])\n sset.add(colors[i])\n if patterns[i] not in sdict.keys():\n sdict[patterns[i]] = []\n\n keys = sdict[patterns[i]]\n keys.append(colors[i])\n sdict[patterns[i]] = keys\n\n if len(pset) != len(sset):\n return False \n\n for values in sdict.values():\n\n for i in range(len(values) - 1):\n if values[i] != values[i+1]:\n return False\n\n return True",
"test_imports": [],
"test_list": [
"assert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True",
"assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"])==False",
"assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\"])==False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 75,
"prompt": "Write a function to find tuples which have all elements divisible by k from the given list of tuples.",
"code": "def find_tuples(test_list, K):\n res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]\n return res",
"test_imports": [],
"test_list": [
"assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]",
"assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == [(5, 25, 30)]",
"assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == [(8, 16, 4)]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 77,
"prompt": "Write a python function to find whether a number is divisible by 11.",
"code": "def is_Diff(n): \n return (n % 11 == 0) ",
"test_imports": [],
"test_list": [
"assert is_Diff (12345) == False",
"assert is_Diff(1212112) == True",
"assert is_Diff(1212) == False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 79,
"prompt": "Write a python function to check whether the length of the word is odd or not.",
"code": "def word_len(s): \n s = s.split(' ') \n for word in s: \n if len(word)%2!=0: \n return True \n else:\n return False",
"test_imports": [],
"test_list": [
"assert word_len(\"Hadoop\") == False",
"assert word_len(\"great\") == True",
"assert word_len(\"structure\") == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 80,
"prompt": "Write a function to find the nth tetrahedral number.",
"code": "def tetrahedral_number(n): \n\treturn (n * (n + 1) * (n + 2)) / 6",
"test_imports": [],
"test_list": [
"assert tetrahedral_number(5) == 35",
"assert tetrahedral_number(6) == 56",
"assert tetrahedral_number(7) == 84"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 82,
"prompt": "Write a function to find the volume of a sphere.",
"code": "import math\ndef volume_sphere(r):\n volume=(4/3)*math.pi*r*r*r\n return volume",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)",
"assert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)",
"assert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 83,
"prompt": "Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.",
"code": "def get_Char(strr): \n summ = 0\n for i in range(len(strr)): \n summ += (ord(strr[i]) - ord('a') + 1) \n if (summ % 26 == 0): \n return ord('z') \n else: \n summ = summ % 26\n return chr(ord('a') + summ - 1)",
"test_imports": [],
"test_list": [
"assert get_Char(\"abc\") == \"f\"",
"assert get_Char(\"gfg\") == \"t\"",
"assert get_Char(\"ab\") == \"c\""
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 84,
"prompt": "Write a function to find the nth number in the newman conway sequence.",
"code": "def sequence(n): \n\tif n == 1 or n == 2: \n\t\treturn 1\n\telse: \n\t\treturn sequence(sequence(n-1)) + sequence(n-sequence(n-1))",
"test_imports": [],
"test_list": [
"assert sequence(10) == 6",
"assert sequence(2) == 1",
"assert sequence(3) == 2"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 85,
"prompt": "Write a function to find the surface area of a sphere.",
"code": "import math\ndef surfacearea_sphere(r):\n surfacearea=4*math.pi*r*r\n return surfacearea",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)",
"assert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)",
"assert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 86,
"prompt": "Write a function to find nth centered hexagonal number.",
"code": "def centered_hexagonal_number(n):\n return 3 * n * (n - 1) + 1",
"test_imports": [],
"test_list": [
"assert centered_hexagonal_number(10) == 271",
"assert centered_hexagonal_number(2) == 7",
"assert centered_hexagonal_number(9) == 217"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 87,
"prompt": "Write a function to merge three dictionaries into a single dictionary.",
"code": "import collections as ct\ndef merge_dictionaries_three(dict1,dict2, dict3):\n merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))\n return merged_dict",
"test_imports": [],
"test_list": [
"assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}",
"assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}",
"assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 88,
"prompt": "Write a function to get the frequency of all the elements in a list, returned as a dictionary.",
"code": "import collections\ndef freq_count(list1):\n freq_count= collections.Counter(list1)\n return freq_count",
"test_imports": [],
"test_list": [
"assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})",
"assert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3})",
"assert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2})"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 89,
"prompt": "Write a function to find the closest smaller number than n.",
"code": "def closest_num(N):\n return (N - 1)",
"test_imports": [],
"test_list": [
"assert closest_num(11) == 10",
"assert closest_num(7) == 6",
"assert closest_num(12) == 11"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 90,
"prompt": "Write a python function to find the length of the longest word.",
"code": "def len_log(list1):\n max=len(list1[0])\n for i in list1:\n if len(i)>max:\n max=len(i)\n return max",
"test_imports": [],
"test_list": [
"assert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 3",
"assert len_log([\"small\",\"big\",\"tall\"]) == 5"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 91,
"prompt": "Write a function to check if a string is present as a substring in a given list of string values.",
"code": "def find_substring(str1, sub_str):\n if any(sub_str in s for s in str1):\n return True\n return False",
"test_imports": [],
"test_list": [
"assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True",
"assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\")==False",
"assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\")==True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 92,
"prompt": "Write a function to check whether the given number is undulating or not.",
"code": "def is_undulating(n): \n\tn = str(n)\n\tif (len(n) <= 2): \n\t\treturn False\n\tfor i in range(2, len(n)): \n\t\tif (n[i - 2] != n[i]): \n\t\t\treturn False\n\treturn True",
"test_imports": [],
"test_list": [
"assert is_undulating(1212121) == True",
"assert is_undulating(1991) == False",
"assert is_undulating(121) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 93,
"prompt": "Write a function to calculate the value of 'a' to the power 'b'.",
"code": "def power(a,b):\n\tif b==0:\n\t\treturn 1\n\telif a==0:\n\t\treturn 0\n\telif b==1:\n\t\treturn a\n\telse:\n\t\treturn a*power(a,b-1)",
"test_imports": [],
"test_list": [
"assert power(3,4) == 81",
"assert power(2,3) == 8",
"assert power(5,5) == 3125"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 94,
"prompt": "Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value.",
"code": "from operator import itemgetter \ndef index_minimum(test_list):\n res = min(test_list, key = itemgetter(1))[0]\n return (res) ",
"test_imports": [],
"test_list": [
"assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'",
"assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'",
"assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 95,
"prompt": "Write a python function to find the length of the smallest list in a list of lists.",
"code": "def Find_Min_Length(lst): \n minLength = min(len(x) for x in lst )\n return minLength ",
"test_imports": [],
"test_list": [
"assert Find_Min_Length([[1],[1,2]]) == 1",
"assert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2",
"assert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 96,
"prompt": "Write a python function to find the number of divisors of a given integer.",
"code": "def divisor(n):\n for i in range(n):\n x = len([i for i in range(1,n+1) if not n % i])\n return x",
"test_imports": [],
"test_list": [
"assert divisor(15) == 4",
"assert divisor(12) == 6",
"assert divisor(9) == 3"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 97,
"prompt": "Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary.",
"code": "def frequency_lists(list1):\n list1 = [item for sublist in list1 for item in sublist]\n dic_data = {}\n for num in list1:\n if num in dic_data.keys():\n dic_data[num] += 1\n else:\n key = num\n value = 1\n dic_data[key] = value\n return dic_data\n",
"test_imports": [],
"test_list": [
"assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}",
"assert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}",
"assert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 98,
"prompt": "Write a function to multiply all the numbers in a list and divide with the length of the list.",
"code": "def multiply_num(numbers): \n total = 1\n for x in numbers:\n total *= x \n return total/len(numbers) ",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)",
"assert math.isclose(multiply_num((-10,-20,-30)), -2000.0, rel_tol=0.001)",
"assert math.isclose(multiply_num((19,15,18)), 1710.0, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 99,
"prompt": "Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros.",
"code": "def decimal_to_binary(n): \n return bin(n).replace(\"0b\",\"\") ",
"test_imports": [],
"test_list": [
"assert decimal_to_binary(8) == '1000'",
"assert decimal_to_binary(18) == '10010'",
"assert decimal_to_binary(7) == '111'"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 100,
"prompt": "Write a function to find the next smallest palindrome of a specified integer, returned as an integer.",
"code": "import sys\ndef next_smallest_palindrome(num):\n numstr = str(num)\n for i in range(num+1,sys.maxsize):\n if str(i) == str(i)[::-1]:\n return i",
"test_imports": [],
"test_list": [
"assert next_smallest_palindrome(99)==101",
"assert next_smallest_palindrome(1221)==1331",
"assert next_smallest_palindrome(120)==121"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 101,
"prompt": "Write a function to find the kth element in the given array using 1-based indexing.",
"code": "def kth_element(arr, k):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] == arr[j+1], arr[j]\n return arr[k-1]",
"test_imports": [],
"test_list": [
"assert kth_element([12,3,5,7,19], 2) == 3",
"assert kth_element([17,24,8,23], 3) == 8",
"assert kth_element([16,21,25,36,4], 4) == 36"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 102,
"prompt": "Write a function to convert a snake case string to camel case string.",
"code": "def snake_to_camel(word):\n import re\n return ''.join(x.capitalize() or '_' for x in word.split('_'))",
"test_imports": [],
"test_list": [
"assert snake_to_camel('python_program')=='PythonProgram'",
"assert snake_to_camel('python_language')==('PythonLanguage')",
"assert snake_to_camel('programming_language')==('ProgrammingLanguage')"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 103,
"prompt": "Write a function to find the Eulerian number a(n, m).",
"code": "def eulerian_num(n, m): \n\tif (m >= n or n == 0): \n\t\treturn 0 \n\tif (m == 0): \n\t\treturn 1 \n\treturn ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))",
"test_imports": [],
"test_list": [
"assert eulerian_num(3, 1) == 4",
"assert eulerian_num(4, 1) == 11",
"assert eulerian_num(5, 3) == 26"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 104,
"prompt": "Write a function to sort each sublist of strings in a given list of lists.",
"code": "def sort_sublists(input_list):\n result = [sorted(x, key = lambda x:x[0]) for x in input_list] \n return result\n",
"test_imports": [],
"test_list": [
"assert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]",
"assert sort_sublists(([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"]))==[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]",
"assert sort_sublists(([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"]))==[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 105,
"prompt": "Write a python function to count true booleans in the given list.",
"code": "def count(lst): \n return sum(lst) ",
"test_imports": [],
"test_list": [
"assert count([True,False,True]) == 2",
"assert count([False,False]) == 0",
"assert count([True,True,True]) == 3"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 106,
"prompt": "Write a function to append the given list to the given tuples.",
"code": "def add_lists(test_list, test_tup):\n res = tuple(list(test_tup) + test_list)\n return (res) ",
"test_imports": [],
"test_list": [
"assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)",
"assert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)",
"assert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 108,
"prompt": "Write a function to merge three lists into a single sorted list.",
"code": "import heapq\ndef merge_sorted_list(num1,num2,num3):\n num1=sorted(num1)\n num2=sorted(num2)\n num3=sorted(num3)\n result = heapq.merge(num1,num2,num3)\n return list(result)",
"test_imports": [],
"test_list": [
"assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]",
"assert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]",
"assert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 109,
"prompt": "Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times.",
"code": "def odd_Equivalent(s,n): \n count=0\n for i in range(0,n): \n if (s[i] == '1'): \n count = count + 1\n return count ",
"test_imports": [],
"test_list": [
"assert odd_Equivalent(\"011001\",6) == 3",
"assert odd_Equivalent(\"11011\",5) == 4",
"assert odd_Equivalent(\"1010\",4) == 2"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 111,
"prompt": "Write a function to find the common elements in given nested lists.",
"code": "def common_in_nested_lists(nestedlist):\n result = list(set.intersection(*map(set, nestedlist)))\n return result",
"test_imports": [],
"test_list": [
"assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])",
"assert set(common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]))==set([5,23])",
"assert set(common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]))==set([4])"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 113,
"prompt": "Write a function to check if a string represents an integer or not.",
"code": "def check_integer(text):\n text = text.strip()\n if len(text) < 1:\n return None\n else:\n if all(text[i] in \"0123456789\" for i in range(len(text))):\n return True\n elif (text[0] in \"+-\") and \\\n all(text[i] in \"0123456789\" for i in range(1,len(text))):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert check_integer(\"python\")==False",
"assert check_integer(\"1\")==True",
"assert check_integer(\"12345\")==True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 115,
"prompt": "Write a function to check whether all dictionaries in a list are empty or not.",
"code": "def empty_dit(list1):\n empty_dit=all(not d for d in list1)\n return empty_dit",
"test_imports": [],
"test_list": [
"assert empty_dit([{},{},{}])==True",
"assert empty_dit([{1,2},{},{}])==False",
"assert empty_dit({})==True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 116,
"prompt": "Write a function to convert a given tuple of positive integers into a single integer.",
"code": "def tuple_to_int(nums):\n result = int(''.join(map(str,nums)))\n return result",
"test_imports": [],
"test_list": [
"assert tuple_to_int((1,2,3))==123",
"assert tuple_to_int((4,5,6))==456",
"assert tuple_to_int((5,6,7))==567"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 117,
"prompt": "Write a function to convert all possible convertible elements in a list of lists to floats.",
"code": "def list_to_float(test_list):\n res = []\n for tup in test_list:\n temp = []\n for ele in tup:\n if ele.isalpha():\n temp.append(ele)\n else:\n temp.append(float(ele))\n res.append((temp[0],temp[1])) \n return res",
"test_imports": [],
"test_list": [
"assert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]",
"assert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == [(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]",
"assert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == [(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 118,
"prompt": "Write a function to convert a string to a list of strings split on the space character.",
"code": "def string_to_list(string): \n lst = list(string.split(\" \")) \n return lst",
"test_imports": [],
"test_list": [
"assert string_to_list(\"python programming\")==['python','programming']",
"assert string_to_list(\"lists tuples strings\")==['lists','tuples','strings']",
"assert string_to_list(\"write a program\")==['write','a','program']"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 119,
"prompt": "Write a python function to find the element that appears only once in a sorted array.",
"code": "def search(arr):\n n = len(arr)\n XOR = 0\n for i in range(n) :\n XOR = XOR ^ arr[i]\n return (XOR)",
"test_imports": [],
"test_list": [
"assert search([1,1,2,2,3]) == 3",
"assert search([1,1,3,3,4,4,5,5,7,7,8]) == 8",
"assert search([1,2,2,3,3,4,4]) == 1"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 120,
"prompt": "Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list.",
"code": "def max_product_tuple(list1):\n result_max = max([abs(x * y) for x, y in list1] )\n return result_max",
"test_imports": [],
"test_list": [
"assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36",
"assert max_product_tuple([(10,20), (15,2), (5,10)] )==200",
"assert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 123,
"prompt": "Write a function to sum all amicable numbers from 1 to a specified number.",
"code": "def amicable_numbers_sum(limit):\n if not isinstance(limit, int):\n return \"Input is not an integer!\"\n if limit < 1:\n return \"Input must be bigger than 0!\"\n amicables = set()\n for num in range(2, limit+1):\n if num in amicables:\n continue\n sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])\n sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])\n if num == sum_fact2 and num != sum_fact:\n amicables.add(num)\n amicables.add(sum_fact2)\n return sum(amicables)",
"test_imports": [],
"test_list": [
"assert amicable_numbers_sum(999)==504",
"assert amicable_numbers_sum(9999)==31626",
"assert amicable_numbers_sum(99)==0"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 124,
"prompt": "Write a function to get the angle of a complex number.",
"code": "import cmath\ndef angle_complex(a,b):\n cn=complex(a,b)\n angle=cmath.phase(a+b)\n return angle",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)",
"assert math.isclose(angle_complex(2,1j), 0.4636476090008061, rel_tol=0.001)",
"assert math.isclose(angle_complex(0,2j), 1.5707963267948966, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 125,
"prompt": "Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.",
"code": "def find_length(string): \n\tn = len(string)\n\tcurrent_sum = 0\n\tmax_sum = 0\n\tfor i in range(n): \n\t\tcurrent_sum += (1 if string[i] == '0' else -1) \n\t\tif current_sum < 0: \n\t\t\tcurrent_sum = 0\n\t\tmax_sum = max(current_sum, max_sum) \n\treturn max_sum if max_sum else 0",
"test_imports": [],
"test_list": [
"assert find_length(\"11000010001\") == 6",
"assert find_length(\"10111\") == 1",
"assert find_length(\"11011101100101\") == 2"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 126,
"prompt": "Write a python function to find the sum of common divisors of two given numbers.",
"code": "def sum(a,b): \n sum = 0\n for i in range (1,min(a,b)): \n if (a % i == 0 and b % i == 0): \n sum += i \n return sum",
"test_imports": [],
"test_list": [
"assert sum(10,15) == 6",
"assert sum(100,150) == 93",
"assert sum(4,6) == 3"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 127,
"prompt": "Write a function to multiply two integers.",
"code": "def multiply_int(x, y):\n if y < 0:\n return -multiply_int(x, -y)\n elif y == 0:\n return 0\n elif y == 1:\n return x\n else:\n return x + multiply_int(x, y - 1)",
"test_imports": [],
"test_list": [
"assert multiply_int(10,20)==200",
"assert multiply_int(5,10)==50",
"assert multiply_int(4,8)==32"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 128,
"prompt": "Write a function to find words that are longer than n characters from a given list of words.",
"code": "def long_words(n, str):\n word_len = []\n txt = str.split(\" \")\n for x in txt:\n if len(x) > n:\n word_len.append(x)\n return word_len\t",
"test_imports": [],
"test_list": [
"assert long_words(3,\"python is a programming language\")==['python','programming','language']",
"assert long_words(2,\"writing a program\")==['writing','program']",
"assert long_words(5,\"sorting list\")==['sorting']"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 129,
"prompt": "Write a function to calculate whether the matrix is a magic square.",
"code": "def magic_square_test(my_matrix):\n iSize = len(my_matrix[0])\n sum_list = []\n sum_list.extend([sum (lines) for lines in my_matrix]) \n for col in range(iSize):\n sum_list.append(sum(row[col] for row in my_matrix))\n result1 = 0\n for i in range(0,iSize):\n result1 +=my_matrix[i][i]\n sum_list.append(result1) \n result2 = 0\n for i in range(iSize-1,-1,-1):\n result2 +=my_matrix[i][i]\n sum_list.append(result2)\n if len(set(sum_list))>1:\n return False\n return True",
"test_imports": [],
"test_list": [
"assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True",
"assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True",
"assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 130,
"prompt": "Write a function to find the item with maximum frequency in a given list.",
"code": "from collections import defaultdict\ndef max_occurrences(nums):\n dict = defaultdict(int)\n for i in nums:\n dict[i] += 1\n result = max(dict.items(), key=lambda x: x[1]) \n return result[0]",
"test_imports": [],
"test_list": [
"assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2",
"assert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18])==8",
"assert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==20"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 131,
"prompt": "Write a python function to reverse only the vowels of a given string (where y is not a vowel).",
"code": "def reverse_vowels(str1):\n\tvowels = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tvowels += char\n\tresult_string = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tresult_string += vowels[-1]\n\t\t\tvowels = vowels[:-1]\n\t\telse:\n\t\t\tresult_string += char\n\treturn result_string",
"test_imports": [],
"test_list": [
"assert reverse_vowels(\"Python\") == \"Python\"",
"assert reverse_vowels(\"USA\") == \"ASU\"",
"assert reverse_vowels(\"ab\") == \"ab\""
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 132,
"prompt": "Write a function to convert a tuple to a string.",
"code": "def tup_string(tup1):\n str = ''.join(tup1)\n return str",
"test_imports": [],
"test_list": [
"assert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==(\"exercises\")",
"assert tup_string(('p','y','t','h','o','n'))==(\"python\")",
"assert tup_string(('p','r','o','g','r','a','m'))==(\"program\")"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 133,
"prompt": "Write a function to calculate the sum of the negative numbers of a given list of numbers.",
"code": "def sum_negativenum(nums):\n sum_negativenum = list(filter(lambda nums:nums<0,nums))\n return sum(sum_negativenum)",
"test_imports": [],
"test_list": [
"assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32",
"assert sum_negativenum([10,15,-14,13,-18,12,-20])==-52",
"assert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 135,
"prompt": "Write a function to find the nth hexagonal number.",
"code": "def hexagonal_num(n): \n\treturn n*(2*n - 1) ",
"test_imports": [],
"test_list": [
"assert hexagonal_num(10) == 190",
"assert hexagonal_num(5) == 45",
"assert hexagonal_num(7) == 91"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 137,
"prompt": "Write a function to find the ratio of zeroes to non-zeroes in an array of integers.",
"code": "from array import array\ndef zero_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x == 0:\n n1 += 1\n else:\n None\n return n1/(n-n1)",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)",
"assert math.isclose(zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]), 0.00, rel_tol=0.001)",
"assert math.isclose(zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17]), 0.00, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 138,
"prompt": "Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.",
"code": "def is_Sum_Of_Powers_Of_Two(n): \n if (n % 2 == 1): \n return False\n else: \n return True",
"test_imports": [],
"test_list": [
"assert is_Sum_Of_Powers_Of_Two(10) == True",
"assert is_Sum_Of_Powers_Of_Two(7) == False",
"assert is_Sum_Of_Powers_Of_Two(14) == True"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 139,
"prompt": "Write a function to find the circumference of a circle.",
"code": "def circle_circumference(r):\n perimeter=2*3.1415*r\n return perimeter",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)",
"assert math.isclose(circle_circumference(5), 31.415000000000003, rel_tol=0.001)",
"assert math.isclose(circle_circumference(4), 25.132, rel_tol=0.001)"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 140,
"prompt": "Write a function to flatten the list of lists into a single set of numbers.",
"code": "def extract_singly(test_list):\n res = []\n temp = set()\n for inner in test_list:\n for ele in inner:\n if not ele in temp:\n temp.add(ele)\n res.append(ele)\n return (res) ",
"test_imports": [],
"test_list": [
"assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])",
"assert set(extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)])) == set([1, 2, 3, 4, 7, 8])",
"assert set(extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)])) == set([7, 8, 9, 10, 11, 12])"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 141,
"prompt": "Write a function to sort a list of elements.",
"code": "def pancake_sort(nums):\n arr_len = len(nums)\n while arr_len > 1:\n mi = nums.index(max(nums[0:arr_len]))\n nums = nums[mi::-1] + nums[mi+1:len(nums)]\n nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]\n arr_len -= 1\n return nums",
"test_imports": [],
"test_list": [
"assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]",
"assert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]",
"assert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42]"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 142,
"prompt": "Write a function to count number items that are identical in the same position of three given lists.",
"code": "def count_samepair(list1,list2,list3):\n result = sum(m == n == o for m, n, o in zip(list1,list2,list3))\n return result",
"test_imports": [],
"test_list": [
"assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3",
"assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4",
"assert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 143,
"prompt": "Write a function to find number of lists present in the given tuple.",
"code": "def find_lists(Input): \n\tif isinstance(Input, list): \n\t\treturn 1\n\telse: \n\t\treturn len(Input) ",
"test_imports": [],
"test_list": [
"assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2",
"assert find_lists(([1, 2], [3, 4], [5, 6])) == 3",
"assert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1"
]
},
{
"source_file": "Mike's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 145,
"prompt": "Write a python function to find the maximum difference between any two elements in a given array.",
"code": "def max_Abs_Diff(arr): \n n = len(arr)\n minEle = arr[0] \n maxEle = arr[0] \n for i in range(1, n): \n minEle = min(minEle,arr[i]) \n maxEle = max(maxEle,arr[i]) \n return (maxEle - minEle) ",
"test_imports": [],
"test_list": [
"assert max_Abs_Diff((2,1,5,3)) == 4",
"assert max_Abs_Diff((9,3,2,5,1)) == 8",
"assert max_Abs_Diff((3,2,1)) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 160,
"prompt": "Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.",
"code": "def find_solution(a, b, n):\n\ti = 0\n\twhile i * a <= n:\n\t\tif (n - (i * a)) % b == 0: \n\t\t\treturn (i, (n - (i * a)) // b)\n\t\ti = i + 1\n\treturn None",
"test_imports": [],
"test_list": [
"assert find_solution(2, 3, 7) == (2, 1)",
"assert find_solution(4, 2, 7) == None",
"assert find_solution(1, 13, 17) == (4, 1)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 161,
"prompt": "Write a function to remove all elements from a given list present in another list.",
"code": "def remove_elements(list1, list2):\n result = [x for x in list1 if x not in list2]\n return result",
"test_imports": [],
"test_list": [
"assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]",
"assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]) == [2, 4, 6, 8, 9, 10]",
"assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]) == [1, 2, 3, 4, 6, 8, 9, 10]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 162,
"prompt": "Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).",
"code": "def sum_series(n):\n if n < 1:\n return 0\n else:\n return n + sum_series(n - 2)",
"test_imports": [],
"test_list": [
"assert sum_series(6) == 12",
"assert sum_series(10) == 30",
"assert sum_series(9) == 25"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 163,
"prompt": "Write a function to calculate the area of a regular polygon given the length and number of its sides.",
"code": "from math import tan, pi\ndef area_polygon(s, l):\n area = s * (l ** 2) / (4 * tan(pi / s))\n return area",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(area_polygon(4, 20), 400., rel_tol=0.001)",
"assert math.isclose(area_polygon(10, 15), 1731.197, rel_tol=0.001)",
"assert math.isclose(area_polygon(9, 7), 302.909, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 164,
"prompt": "Write a function to determine if the sum of the divisors of two integers are the same.",
"code": "import math \ndef div_sum(n): \n total = 1\n i = 2\n\n while i * i <= n:\n if (n % i == 0):\n total = (total + i + math.floor(n / i))\n i += 1\n\n return total\n\ndef are_equivalent(num1, num2): \n return div_sum(num1) == div_sum(num2); ",
"test_imports": [],
"test_list": [
"assert are_equivalent(36, 57) == False",
"assert are_equivalent(2, 4) == False",
"assert are_equivalent(23, 47) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 165,
"prompt": "Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).",
"code": "def count_char_position(str1): \n count_chars = 0\n for i in range(len(str1)):\n if ((i == ord(str1[i]) - ord('A')) or \n (i == ord(str1[i]) - ord('a'))): \n count_chars += 1\n return count_chars ",
"test_imports": [],
"test_list": [
"assert count_char_position(\"xbcefg\") == 2",
"assert count_char_position(\"ABcED\") == 3",
"assert count_char_position(\"AbgdeF\") == 5"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 166,
"prompt": "Write a function that counts the number of pairs of integers in a list that xor to an even number.",
"code": "def find_even_pair(A): \n count = 0\n for i in range(0, len(A)): \n for j in range(i+1, len(A)): \n if ((A[i] ^ A[j]) % 2 == 0): \n count += 1\n\n return count",
"test_imports": [],
"test_list": [
"assert find_even_pair([5, 4, 7, 2, 1]) == 4",
"assert find_even_pair([7, 2, 8, 1, 0, 5, 11]) == 9",
"assert find_even_pair([1, 2, 3]) == 1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 167,
"prompt": "Write a python function to find the smallest power of 2 greater than or equal to n.",
"code": "def next_power_of_2(n): \n if n and not n & (n - 1):\n return n\n\n count = 0\n while n != 0: \n n >>= 1\n count += 1\n\n return 1 << count; ",
"test_imports": [],
"test_list": [
"assert next_power_of_2(0) == 1",
"assert next_power_of_2(5) == 8",
"assert next_power_of_2(17) == 32"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 168,
"prompt": "Write a function to count the number of occurrences of a number in a given list.",
"code": "def frequency(a,x): \n count = 0 \n for i in a: \n if i == x: \n count += 1\n\n return count ",
"test_imports": [],
"test_list": [
"assert frequency([1,2,3], 4) == 0",
"assert frequency([1,2,2,3,3,3,4], 3) == 3",
"assert frequency([0,1,2,3,1,2], 1) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 170,
"prompt": "Write a function to find the sum of numbers in a list within a range specified by two indices.",
"code": "def sum_range_list(list1, m, n): \n sum_range = 0 \n for i in range(m, n+1, 1): \n sum_range += list1[i] \n return sum_range ",
"test_imports": [],
"test_list": [
"assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29",
"assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 5, 7) == 16",
"assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 7, 10) == 38"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 171,
"prompt": "Write a function to find the perimeter of a regular pentagon from the length of its sides.",
"code": "import math\ndef perimeter_pentagon(a):\n perimeter=(5*a)\n return perimeter",
"test_imports": [],
"test_list": [
"assert perimeter_pentagon(5) == 25",
"assert perimeter_pentagon(10) == 50",
"assert perimeter_pentagon(15) == 75"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 172,
"prompt": "Write a function to count the number of occurence of the string 'std' in a given string.",
"code": "def count_occurance(s):\n count = 0\n for i in range(len(s) - 2):\n if (s[i] == 's' and s[i+1] == 't' and s[i+2] == 'd'):\n count = count + 1\n return count",
"test_imports": [],
"test_list": [
"assert count_occurance(\"letstdlenstdporstd\") == 3",
"assert count_occurance(\"truststdsolensporsd\") == 1",
"assert count_occurance(\"makestdsostdworthit\") == 2",
"assert count_occurance(\"stds\") == 1",
"assert count_occurance(\"\") == 0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 222,
"prompt": "Write a function to check if all the elements in tuple have same data type or not.",
"code": "def check_type(test_tuple):\n res = True\n for ele in test_tuple:\n if not isinstance(ele, type(test_tuple[0])):\n res = False\n break\n return (res) ",
"test_imports": [],
"test_list": [
"assert check_type((5, 6, 7, 3, 5, 6) ) == True",
"assert check_type((1, 2, \"4\") ) == False",
"assert check_type((3, 2, 1, 4, 5) ) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 223,
"prompt": "Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)",
"code": "def is_majority(arr, n, x):\n\ti = binary_search(arr, 0, n-1, x)\n\tif i == -1:\n\t\treturn False\n\tif ((i + n//2) <= (n -1)) and arr[i + n//2] == x:\n\t\treturn True\n\telse:\n\t\treturn False\ndef binary_search(arr, low, high, x):\n\tif high >= low:\n\t\tmid = (low + high)//2 \n\t\tif (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):\n\t\t\treturn mid\n\t\telif x > arr[mid]:\n\t\t\treturn binary_search(arr, (mid + 1), high, x)\n\t\telse:\n\t\t\treturn binary_search(arr, low, (mid -1), x)\n\treturn -1",
"test_imports": [],
"test_list": [
"assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True",
"assert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False",
"assert is_majority([1, 1, 1, 2, 2], 5, 1) == True",
"assert is_majority([1, 1, 2, 2], 5, 1) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 224,
"prompt": "Write a python function to count the number of set bits (binary digits with value 1) in a given number.",
"code": "def count_Set_Bits(n): \n count = 0\n while (n): \n count += n & 1\n n >>= 1\n return count ",
"test_imports": [],
"test_list": [
"assert count_Set_Bits(2) == 1",
"assert count_Set_Bits(4) == 1",
"assert count_Set_Bits(6) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 226,
"prompt": "Write a python function to remove the characters which have odd index values of a given string.",
"code": "def odd_values_string(str):\n result = \"\" \n for i in range(len(str)):\n if i % 2 == 0:\n result = result + str[i]\n return result",
"test_imports": [],
"test_list": [
"assert odd_values_string('abcdef') == 'ace'",
"assert odd_values_string('python') == 'pto'",
"assert odd_values_string('data') == 'dt'",
"assert odd_values_string('lambs') == 'lms'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 227,
"prompt": "Write a function to find minimum of three numbers.",
"code": "def min_of_three(a,b,c): \n if (a <= b) and (a <= c): \n smallest = a \n elif (b <= a) and (b <= c): \n smallest = b \n else: \n smallest = c \n return smallest ",
"test_imports": [],
"test_list": [
"assert min_of_three(10,20,0)==0",
"assert min_of_three(19,15,18)==15",
"assert min_of_three(-10,-20,-30)==-30"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 228,
"prompt": "Write a python function to check whether all the bits are unset in the given range or not.",
"code": "def all_Bits_Set_In_The_Given_Range(n,l,r): \n num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) \n new_num = n & num\n if (new_num == 0): \n return True\n return False",
"test_imports": [],
"test_list": [
"assert all_Bits_Set_In_The_Given_Range(4,1,2) == True",
"assert all_Bits_Set_In_The_Given_Range(17,2,4) == True",
"assert all_Bits_Set_In_The_Given_Range(39,4,6) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 229,
"prompt": "Write a function that takes in an array and an integer n, and re-arranges the first n elements of the given array so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved.",
"code": "def re_arrange_array(arr, n):\n j=0\n for i in range(0, n):\n if (arr[i] < 0):\n temp = arr[i]\n arr[i] = arr[j]\n arr[j] = temp\n j = j + 1\n return arr",
"test_imports": [],
"test_list": [
"assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]",
"assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]",
"assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 230,
"prompt": "Write a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string.",
"code": "def replace_blank(str1,char):\n str2 = str1.replace(' ', char)\n return str2",
"test_imports": [],
"test_list": [
"assert replace_blank(\"hello people\",'@')==(\"hello@people\")",
"assert replace_blank(\"python program language\",'$')==(\"python$program$language\")",
"assert replace_blank(\"blank space\",\"-\")==(\"blank-space\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 232,
"prompt": "Write a function that takes in a list and an integer n and returns a list containing the n largest items from the list.",
"code": "import heapq\ndef larg_nnum(list1,n):\n largest=heapq.nlargest(n,list1)\n return largest",
"test_imports": [],
"test_list": [
"assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])",
"assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5))==set([100,90,80,70,60])",
"assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3))==set([100,90,80])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 233,
"prompt": "Write a function to find the lateral surface area of a cylinder.",
"code": "def lateralsuface_cylinder(r,h):\n lateralsurface= 2*3.1415*r*h\n return lateralsurface",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)",
"assert math.isclose(lateralsuface_cylinder(4,5), 125.66000000000001, rel_tol=0.001)",
"assert math.isclose(lateralsuface_cylinder(4,10), 251.32000000000002, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 234,
"prompt": "Write a function to find the volume of a cube given its side length.",
"code": "def volume_cube(l):\n volume = l * l * l\n return volume",
"test_imports": [],
"test_list": [
"assert volume_cube(3)==27",
"assert volume_cube(2)==8",
"assert volume_cube(5)==125"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 235,
"prompt": "Write a python function to set all even bits of a given number.",
"code": "def even_bit_set_number(n): \n count = 0;res = 0;temp = n \n while(temp > 0): \n if (count % 2 == 1): \n res |= (1 << count)\n count+=1\n temp >>= 1\n return (n | res) ",
"test_imports": [],
"test_list": [
"assert even_bit_set_number(10) == 10",
"assert even_bit_set_number(20) == 30",
"assert even_bit_set_number(30) == 30"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 237,
"prompt": "Write a function that takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.",
"code": "from collections import Counter \ndef check_occurences(test_list):\n res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))\n return (res) ",
"test_imports": [],
"test_list": [
"assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}",
"assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}",
"assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 238,
"prompt": "Write a python function to count the number of non-empty substrings of a given string.",
"code": "def number_of_substrings(str): \n\tstr_len = len(str); \n\treturn int(str_len * (str_len + 1) / 2); ",
"test_imports": [],
"test_list": [
"assert number_of_substrings(\"abc\") == 6",
"assert number_of_substrings(\"abcd\") == 10",
"assert number_of_substrings(\"abcde\") == 15"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 239,
"prompt": "Write a function that takes in positive integers m and n and finds the number of possible sequences of length n, such that each element is a positive integer and is greater than or equal to twice the previous element but less than or equal to m.",
"code": "def get_total_number_of_sequences(m,n): \n\tT=[[0 for i in range(n+1)] for i in range(m+1)] \n\tfor i in range(m+1): \n\t\tfor j in range(n+1): \n\t\t\tif i==0 or j==0: \n\t\t\t\tT[i][j]=0\n\t\t\telif i<j: \n\t\t\t\tT[i][j]=0\n\t\t\telif j==1: \n\t\t\t\tT[i][j]=i \n\t\t\telse: \n\t\t\t\tT[i][j]=T[i-1][j]+T[i//2][j-1] \n\treturn T[m][n]",
"test_imports": [],
"test_list": [
"assert get_total_number_of_sequences(10, 4) == 4",
"assert get_total_number_of_sequences(5, 2) == 6",
"assert get_total_number_of_sequences(16, 3) == 84"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 240,
"prompt": "Write a function that takes in two lists and replaces the last element of the first list with the elements of the second list.",
"code": "def replace_list(list1,list2):\n list1[-1:] = list2\n replace_list=list1\n return replace_list\n",
"test_imports": [],
"test_list": [
"assert replace_list([1, 3, 5, 7, 9, 10],[2, 4, 6, 8])==[1, 3, 5, 7, 9, 2, 4, 6, 8]",
"assert replace_list([1,2,3,4,5],[5,6,7,8])==[1,2,3,4,5,6,7,8]",
"assert replace_list([\"red\",\"blue\",\"green\"],[\"yellow\"])==[\"red\",\"blue\",\"yellow\"]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 242,
"prompt": "Write a function to count the total number of characters in a string.",
"code": "def count_charac(str1):\n total = 0\n for i in str1:\n total = total + 1\n return total",
"test_imports": [],
"test_list": [
"assert count_charac(\"python programming\")==18",
"assert count_charac(\"language\")==8",
"assert count_charac(\"words\")==5"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 244,
"prompt": "Write a python function to find the next perfect square greater than a given number.",
"code": "import math \ndef next_Perfect_Square(N): \n nextN = math.floor(math.sqrt(N)) + 1\n return nextN * nextN ",
"test_imports": [],
"test_list": [
"assert next_Perfect_Square(35) == 36",
"assert next_Perfect_Square(6) == 9",
"assert next_Perfect_Square(9) == 16"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 245,
"prompt": "Write a function that takes an array and finds the maximum sum of a bitonic subsequence for the given array, where a sequence is bitonic if it is first increasing and then decreasing.",
"code": "def max_sum(arr): \n\tMSIBS = arr[:] \n\tfor i in range(len(arr)): \n\t\tfor j in range(0, i): \n\t\t\tif arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: \n\t\t\t\tMSIBS[i] = MSIBS[j] + arr[i] \n\tMSDBS = arr[:] \n\tfor i in range(1, len(arr) + 1): \n\t\tfor j in range(1, i): \n\t\t\tif arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: \n\t\t\t\tMSDBS[-i] = MSDBS[-j] + arr[-i] \n\tmax_sum = float(\"-Inf\") \n\tfor i, j, k in zip(MSIBS, MSDBS, arr): \n\t\tmax_sum = max(max_sum, i + j - k) \n\treturn max_sum",
"test_imports": [],
"test_list": [
"assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194",
"assert max_sum([80, 60, 30, 40, 20, 10]) == 210",
"assert max_sum([2, 3 ,14, 16, 21, 23, 29, 30]) == 138"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 246,
"prompt": "Write a function for computing square roots using the babylonian method.",
"code": "def babylonian_squareroot(number):\n if(number == 0):\n return 0;\n g = number/2.0;\n g2 = g + 1;\n while(g != g2):\n n = number/ g;\n g2 = g;\n g = (g + n)/2;\n return g;",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001)",
"assert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001)",
"assert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 247,
"prompt": "Write a function to find the length of the longest palindromic subsequence in the given string.",
"code": "def lps(str): \n\tn = len(str) \n\tL = [[0 for x in range(n)] for x in range(n)] \n\tfor i in range(n): \n\t\tL[i][i] = 1\n\tfor cl in range(2, n+1): \n\t\tfor i in range(n-cl+1): \n\t\t\tj = i+cl-1\n\t\t\tif str[i] == str[j] and cl == 2: \n\t\t\t\tL[i][j] = 2\n\t\t\telif str[i] == str[j]: \n\t\t\t\tL[i][j] = L[i+1][j-1] + 2\n\t\t\telse: \n\t\t\t\tL[i][j] = max(L[i][j-1], L[i+1][j]); \n\treturn L[0][n-1]",
"test_imports": [],
"test_list": [
"assert lps(\"TENS FOR TENS\") == 5",
"assert lps(\"CARDIO FOR CARDS\") == 7",
"assert lps(\"PART OF THE JOURNEY IS PART\") == 9"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 248,
"prompt": "Write a function that takes in an integer n and calculates the harmonic sum of n-1.",
"code": "def harmonic_sum(n):\n if n < 2:\n return 1\n else:\n return 1 / n + (harmonic_sum(n - 1)) ",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(harmonic_sum(7), 2.5928571428571425, rel_tol=0.001)",
"assert math.isclose(harmonic_sum(4), 2.083333333333333, rel_tol=0.001)",
"assert math.isclose(harmonic_sum(19), 3.547739657143682, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 249,
"prompt": "Write a function to find the intersection of two arrays.",
"code": "def intersection_array(array_nums1,array_nums2):\n result = list(filter(lambda x: x in array_nums1, array_nums2)) \n return result",
"test_imports": [],
"test_list": [
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]",
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]",
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 250,
"prompt": "Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.",
"code": "def count_X(tup, x): \n count = 0\n for ele in tup: \n if (ele == x): \n count = count + 1\n return count ",
"test_imports": [],
"test_list": [
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0",
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3",
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 251,
"prompt": "Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.",
"code": "def insert_element(list,element):\n list = [v for elt in list for v in (element, elt)]\n return list",
"test_imports": [],
"test_list": [
"assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']",
"assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']",
"assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad']"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 252,
"prompt": "Write a python function to convert complex numbers to polar coordinates.",
"code": "import cmath \ndef convert(numbers): \n num = cmath.polar(numbers) \n return (num) ",
"test_imports": [],
"test_list": [
"assert convert(1) == (1.0, 0.0)",
"assert convert(4) == (4.0,0.0)",
"assert convert(5) == (5.0,0.0)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 253,
"prompt": "Write a python function that returns the number of integer elements in a given list.",
"code": "def count_integer(list1):\n ctr = 0\n for i in list1:\n if isinstance(i, int):\n ctr = ctr + 1\n return ctr",
"test_imports": [],
"test_list": [
"assert count_integer([1,2,'abc',1.2]) == 2",
"assert count_integer([1,2,3]) == 3",
"assert count_integer([1,1.2,4,5.1]) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 255,
"prompt": "Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.",
"code": "from itertools import combinations_with_replacement \ndef combinations_colors(l, n):\n return list(combinations_with_replacement(l,n))\n",
"test_imports": [],
"test_list": [
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]",
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]",
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 256,
"prompt": "Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.",
"code": "def count_Primes_nums(n):\n ctr = 0\n for num in range(n):\n if num <= 1:\n continue\n for i in range(2,num):\n if (num % i) == 0:\n break\n else:\n ctr += 1\n return ctr",
"test_imports": [],
"test_list": [
"assert count_Primes_nums(5) == 2",
"assert count_Primes_nums(10) == 4",
"assert count_Primes_nums(100) == 25"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 257,
"prompt": "Write a function that takes in two numbers and returns a tuple with the second number and then the first number.",
"code": "def swap_numbers(a,b):\n temp = a\n a = b\n b = temp\n return (a,b)",
"test_imports": [],
"test_list": [
"assert swap_numbers(10,20)==(20,10)",
"assert swap_numbers(15,17)==(17,15)",
"assert swap_numbers(100,200)==(200,100)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 259,
"prompt": "Write a function to maximize the given two tuples.",
"code": "def maximize_elements(test_tup1, test_tup2):\n res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))",
"assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))",
"assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 260,
"prompt": "Write a function to find the nth newman–shanks–williams prime number.",
"code": "def newman_prime(n): \n\tif n == 0 or n == 1: \n\t\treturn 1\n\treturn 2 * newman_prime(n - 1) + newman_prime(n - 2)",
"test_imports": [],
"test_list": [
"assert newman_prime(3) == 7",
"assert newman_prime(4) == 17",
"assert newman_prime(5) == 41"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 261,
"prompt": "Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.",
"code": "def division_elements(test_tup1, test_tup2):\n res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)",
"assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)",
"assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 262,
"prompt": "Write a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple.",
"code": "def split_two_parts(list1, L):\n return list1[:L], list1[L:]",
"test_imports": [],
"test_list": [
"assert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])",
"assert split_two_parts(['a', 'b', 'c', 'd'],2)==(['a', 'b'], ['c', 'd'])",
"assert split_two_parts(['p', 'y', 't', 'h', 'o', 'n'],4)==(['p', 'y', 't', 'h'], ['o', 'n'])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 264,
"prompt": "Write a function to calculate a dog's age in dog's years.",
"code": "def dog_age(h_age):\n if h_age < 0:\n \texit()\n elif h_age <= 2:\n\t d_age = h_age * 10.5\n else:\n\t d_age = 21 + (h_age - 2)*4\n return d_age",
"test_imports": [],
"test_list": [
"assert dog_age(12)==61",
"assert dog_age(15)==73",
"assert dog_age(24)==109"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 265,
"prompt": "Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.",
"code": "def list_split(S, step):\n return [S[i::step] for i in range(step)]",
"test_imports": [],
"test_list": [
"assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]",
"assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]",
"assert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 266,
"prompt": "Write a function to find the lateral surface area of a cube given its side length.",
"code": "def lateralsurface_cube(l):\n LSA = 4 * (l * l)\n return LSA",
"test_imports": [],
"test_list": [
"assert lateralsurface_cube(5)==100",
"assert lateralsurface_cube(9)==324",
"assert lateralsurface_cube(10)==400"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 267,
"prompt": "Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.",
"code": "def square_Sum(n): \n return int(n*(4*n*n-1)/3) ",
"test_imports": [],
"test_list": [
"assert square_Sum(2) == 10",
"assert square_Sum(3) == 35",
"assert square_Sum(4) == 84"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 268,
"prompt": "Write a function to find the n'th star number.",
"code": "def find_star_num(n): \n\treturn (6 * n * (n - 1) + 1) ",
"test_imports": [],
"test_list": [
"assert find_star_num(3) == 37",
"assert find_star_num(4) == 73",
"assert find_star_num(5) == 121"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 269,
"prompt": "Write a function to find the ascii value of a character.",
"code": "def ascii_value(k):\n ch=k\n return ord(ch)",
"test_imports": [],
"test_list": [
"assert ascii_value('A')==65",
"assert ascii_value('R')==82",
"assert ascii_value('S')==83"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 270,
"prompt": "Write a python function to find the sum of even numbers at even positions of a list.",
"code": "def sum_even_and_even_index(arr): \n i = 0\n sum = 0\n for i in range(0, len(arr),2): \n if (arr[i] % 2 == 0) : \n sum += arr[i] \n return sum",
"test_imports": [],
"test_list": [
"assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30",
"assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26",
"assert sum_even_and_even_index([5, 6, 12, 1]) == 12"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 271,
"prompt": "Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.",
"code": "def even_Power_Sum(n): \n sum = 0; \n for i in range(1,n+1): \n j = 2*i; \n sum = sum + (j*j*j*j*j); \n return sum; ",
"test_imports": [],
"test_list": [
"assert even_Power_Sum(2) == 1056",
"assert even_Power_Sum(3) == 8832",
"assert even_Power_Sum(1) == 32"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 272,
"prompt": "Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.",
"code": "def rear_extract(test_list):\n res = [lis[-1] for lis in test_list]\n return (res) ",
"test_imports": [],
"test_list": [
"assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]",
"assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]",
"assert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 273,
"prompt": "Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.",
"code": "def substract_elements(test_tup1, test_tup2):\n res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)",
"assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)",
"assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 274,
"prompt": "Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.",
"code": "import math \ndef even_binomial_Coeff_Sum( n): \n return (1 << (n - 1)) ",
"test_imports": [],
"test_list": [
"assert even_binomial_Coeff_Sum(4) == 8",
"assert even_binomial_Coeff_Sum(6) == 32",
"assert even_binomial_Coeff_Sum(2) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 276,
"prompt": "Write a function that takes in the radius and height of a cylinder and returns the the volume.",
"code": "def volume_cylinder(r,h):\n volume=3.1415*r*r*h\n return volume",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)",
"assert math.isclose(volume_cylinder(4,5), 251.32000000000002, rel_tol=0.001)",
"assert math.isclose(volume_cylinder(4,10), 502.64000000000004, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 277,
"prompt": "Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.",
"code": "def dict_filter(dict,n):\n result = {key:value for (key, value) in dict.items() if value >=n}\n return result",
"test_imports": [],
"test_list": [
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}",
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}",
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 278,
"prompt": "Write a function to find the number of elements that occurs before the tuple element in the given tuple.",
"code": "def count_first_elements(test_tup):\n for count, ele in enumerate(test_tup):\n if isinstance(ele, tuple):\n break\n return (count) ",
"test_imports": [],
"test_list": [
"assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3",
"assert count_first_elements((2, 9, (5, 7), 11) ) == 2",
"assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 279,
"prompt": "Write a function to find the nth decagonal number.",
"code": "def is_num_decagonal(n): \n\treturn 4 * n * n - 3 * n ",
"test_imports": [],
"test_list": [
"assert is_num_decagonal(3) == 27",
"assert is_num_decagonal(7) == 175",
"assert is_num_decagonal(10) == 370"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 280,
"prompt": "Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).",
"code": "def sequential_search(dlist, item):\n pos = 0\n found = False\n while pos < len(dlist) and not found:\n if dlist[pos] == item:\n found = True\n else:\n pos = pos + 1\n return found, pos",
"test_imports": [],
"test_list": [
"assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)",
"assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)",
"assert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 281,
"prompt": "Write a python function to check if the elements of a given list are unique or not.",
"code": "def all_unique(test_list):\n if len(test_list) > len(set(test_list)):\n return False\n return True",
"test_imports": [],
"test_list": [
"assert all_unique([1,2,3]) == True",
"assert all_unique([1,2,1,2]) == False",
"assert all_unique([1,2,3,4,5]) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 282,
"prompt": "Write a function to subtract two lists element-wise.",
"code": "def sub_list(nums1,nums2):\n result = map(lambda x, y: x - y, nums1, nums2)\n return list(result)",
"test_imports": [],
"test_list": [
"assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]",
"assert sub_list([1,2],[3,4])==[-2,-2]",
"assert sub_list([90,120],[50,70])==[40,50]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 283,
"prompt": "Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.",
"code": "def validate(n): \n for i in range(10): \n temp = n; \n count = 0; \n while (temp): \n if (temp % 10 == i): \n count+=1; \n if (count > i): \n return False\n temp //= 10; \n return True",
"test_imports": [],
"test_list": [
"assert validate(1234) == True",
"assert validate(51241) == False",
"assert validate(321) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 284,
"prompt": "Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.",
"code": "def check_element(list,element):\n check_element=all(v== element for v in list)\n return check_element",
"test_imports": [],
"test_list": [
"assert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False",
"assert check_element([1,2,3,4],7)==False",
"assert check_element([\"green\", \"green\", \"green\", \"green\"],'green')==True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 285,
"prompt": "Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.",
"code": "import re\ndef text_match_two_three(text):\n patterns = 'ab{2,3}'\n if re.search(patterns, text):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert text_match_two_three(\"ac\")==(False)",
"assert text_match_two_three(\"dc\")==(False)",
"assert text_match_two_three(\"abbbba\")==(True)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 286,
"prompt": "Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.",
"code": "def max_sub_array_sum_repeated(a, n, k): \n\tmax_so_far = -2147483648\n\tmax_ending_here = 0\n\tfor i in range(n*k): \n\t\tmax_ending_here = max_ending_here + a[i%n] \n\t\tif (max_so_far < max_ending_here): \n\t\t\tmax_so_far = max_ending_here \n\t\tif (max_ending_here < 0): \n\t\t\tmax_ending_here = 0\n\treturn max_so_far",
"test_imports": [],
"test_list": [
"assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30",
"assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59",
"assert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 287,
"prompt": "Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers.",
"code": "def square_Sum(n): \n return int(2*n*(n+1)*(2*n+1)/3)",
"test_imports": [],
"test_list": [
"assert square_Sum(2) == 20",
"assert square_Sum(3) == 56",
"assert square_Sum(4) == 120"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 290,
"prompt": "Write a function to find the list of maximum length in a list of lists.",
"code": "def max_length(list1):\n max_length = max(len(x) for x in list1 ) \n max_list = max((x) for x in list1)\n return(max_length, max_list)",
"test_imports": [],
"test_list": [
"assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])",
"assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])",
"assert max_length([[5], [15,20,25]])==(3, [15,20,25])"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 291,
"prompt": "Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.",
"code": "def count_no_of_ways(n, k): \n\tdp = [0] * (n + 1) \n\ttotal = k \n\tmod = 1000000007\n\tdp[1] = k \n\tdp[2] = k * k\t \n\tfor i in range(3,n+1): \n\t\tdp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod \n\treturn dp[n]",
"test_imports": [],
"test_list": [
"assert count_no_of_ways(2, 4) == 16",
"assert count_no_of_ways(3, 2) == 6",
"assert count_no_of_ways(4, 4) == 228"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 292,
"prompt": "Write a python function to find quotient of two numbers (rounded down to the nearest integer).",
"code": "def find(n,m): \n q = n//m \n return (q)",
"test_imports": [],
"test_list": [
"assert find(10,3) == 3",
"assert find(4,2) == 2",
"assert find(20,5) == 4"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 293,
"prompt": "Write a function to find the third side of a right angled triangle.",
"code": "import math\ndef otherside_rightangle(w,h):\n s=math.sqrt((w*w)+(h*h))\n return s",
"test_imports": [],
"test_list": [
"assert otherside_rightangle(7,8)==10.63014581273465",
"assert otherside_rightangle(3,4)==5",
"assert otherside_rightangle(7,15)==16.55294535724685"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 294,
"prompt": "Write a function to find the maximum value in a given heterogeneous list.",
"code": "def max_val(listval):\n max_val = max(i for i in listval if isinstance(i, int)) \n return(max_val)",
"test_imports": [],
"test_list": [
"assert max_val(['Python', 3, 2, 4, 5, 'version'])==5",
"assert max_val(['Python', 15, 20, 25])==25",
"assert max_val(['Python', 30, 20, 40, 50, 'version'])==50"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 295,
"prompt": "Write a function to return the sum of all divisors of a number.",
"code": "def sum_div(number):\n divisors = [1]\n for i in range(2, number):\n if (number % i)==0:\n divisors.append(i)\n return sum(divisors)",
"test_imports": [],
"test_list": [
"assert sum_div(8)==7",
"assert sum_div(12)==16",
"assert sum_div(7)==1"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 296,
"prompt": "Write a python function to count inversions in an array.",
"code": "def get_Inv_Count(arr): \n inv_count = 0\n for i in range(len(arr)): \n for j in range(i + 1, len(arr)): \n if (arr[i] > arr[j]): \n inv_count += 1\n return inv_count ",
"test_imports": [],
"test_list": [
"assert get_Inv_Count([1,20,6,4,5]) == 5",
"assert get_Inv_Count([1,2,1]) == 1",
"assert get_Inv_Count([1,2,5,6,1]) == 3"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 297,
"prompt": "Write a function to flatten a given nested list structure.",
"code": "def flatten_list(list1):\n result_list = []\n if not list1: return result_list\n stack = [list(list1)]\n while stack:\n c_num = stack.pop()\n next = c_num.pop()\n if c_num: stack.append(c_num)\n if isinstance(next, list):\n if next: stack.append(list(next))\n else: result_list.append(next)\n result_list.reverse()\n return result_list ",
"test_imports": [],
"test_list": [
"assert flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]])==[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]",
"assert flatten_list([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]",
"assert flatten_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 299,
"prompt": "Write a function to calculate the maximum aggregate from the list of tuples.",
"code": "from collections import defaultdict\ndef max_aggregate(stdata):\n temp = defaultdict(int)\n for name, marks in stdata:\n temp[name] += marks\n return max(temp.items(), key=lambda x: x[1])",
"test_imports": [],
"test_list": [
"assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)",
"assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)",
"assert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 300,
"prompt": "Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.",
"code": "def count_binary_seq(n): \n\tnCr = 1\n\tres = 1\n\tfor r in range(1, n + 1): \n\t\tnCr = (nCr * (n + 1 - r)) / r \n\t\tres += nCr * nCr \n\treturn res ",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)",
"assert math.isclose(count_binary_seq(2), 6.0, rel_tol=0.001)",
"assert math.isclose(count_binary_seq(3), 20.0, rel_tol=0.001)"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 301,
"prompt": "Write a function to find the depth of a dictionary.",
"code": "def dict_depth(d):\n if isinstance(d, dict):\n return 1 + (max(map(dict_depth, d.values())) if d else 0)\n return 0",
"test_imports": [],
"test_list": [
"assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4",
"assert dict_depth({'a':1, 'b': {'c':'python'}})==2",
"assert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 304,
"prompt": "Write a python function to find element at a given index after number of rotations.",
"code": "def find_Element(arr,ranges,rotations,index) : \n for i in range(rotations - 1,-1,-1 ) : \n left = ranges[i][0] \n right = ranges[i][1] \n if (left <= index and right >= index) : \n if (index == left) : \n index = right \n else : \n index = index - 1 \n return arr[index] ",
"test_imports": [],
"test_list": [
"assert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3",
"assert find_Element([1,2,3,4],[[0,1],[0,2]],1,2) == 3",
"assert find_Element([1,2,3,4,5,6],[[0,1],[0,2]],1,1) == 1"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 305,
"prompt": "Write a function to return two words from a list of words starting with letter 'p'.",
"code": "import re\ndef start_withp(words):\n for w in words:\n m = re.match(\"(P\\w+)\\W(P\\w+)\", w)\n if m:\n return m.groups()",
"test_imports": [],
"test_list": [
"assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')",
"assert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')",
"assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 306,
"prompt": "Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .",
"code": "def max_sum_increasing_subseq(a, n, index, k):\n\tdp = [[0 for i in range(n)] \n\t\t\tfor i in range(n)]\n\tfor i in range(n):\n\t\tif a[i] > a[0]:\n\t\t\tdp[0][i] = a[i] + a[0]\n\t\telse:\n\t\t\tdp[0][i] = a[i]\n\tfor i in range(1, n):\n\t\tfor j in range(n):\n\t\t\tif a[j] > a[i] and j > i:\n\t\t\t\tif dp[i - 1][i] + a[j] > dp[i - 1][j]:\n\t\t\t\t\tdp[i][j] = dp[i - 1][i] + a[j]\n\t\t\t\telse:\n\t\t\t\t\tdp[i][j] = dp[i - 1][j]\n\t\t\telse:\n\t\t\t\tdp[i][j] = dp[i - 1][j]\n\treturn dp[index][k]",
"test_imports": [],
"test_list": [
"assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11",
"assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7",
"assert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 307,
"prompt": "Write a function to get a colon of a tuple.",
"code": "from copy import deepcopy\ndef colon_tuplex(tuplex,m,n):\n tuplex_colon = deepcopy(tuplex)\n tuplex_colon[m].append(n)\n return tuplex_colon",
"test_imports": [],
"test_list": [
"assert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True)",
"assert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))",
"assert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 308,
"prompt": "Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.",
"code": "def large_product(nums1, nums2, N):\n result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]\n return result",
"test_imports": [],
"test_list": [
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]",
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]",
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 309,
"prompt": "Write a python function to find the maximum of two numbers.",
"code": "def maximum(a,b): \n if a >= b: \n return a \n else: \n return b ",
"test_imports": [],
"test_list": [
"assert maximum(5,10) == 10",
"assert maximum(-1,-2) == -1",
"assert maximum(9,7) == 9"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 310,
"prompt": "Write a function to convert a given string to a tuple of characters.",
"code": "def string_to_tuple(str1):\n result = tuple(x for x in str1 if not x.isspace()) \n return result",
"test_imports": [],
"test_list": [
"assert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')",
"assert string_to_tuple(\"item1\")==('i', 't', 'e', 'm', '1')",
"assert string_to_tuple(\"15.10\")==('1', '5', '.', '1', '0')"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 311,
"prompt": "Write a python function to set the left most unset bit.",
"code": "def set_left_most_unset_bit(n): \n if not (n & (n + 1)): \n return n \n pos, temp, count = 0, n, 0 \n while temp: \n if not (temp & 1): \n pos = count \n count += 1; temp>>=1\n return (n | (1 << (pos))) ",
"test_imports": [],
"test_list": [
"assert set_left_most_unset_bit(10) == 14",
"assert set_left_most_unset_bit(12) == 14",
"assert set_left_most_unset_bit(15) == 15"
]
},
{
"source_file": "Ellen's Copy of Benchmark Questions Verification V2.ipynb",
"task_id": 312,
"prompt": "Write a function to find the volume of a cone.",
"code": "import math\ndef volume_cone(r,h):\n volume = (1.0/3) * math.pi * r * r * h\n return volume",
"test_imports": [
"import math"
],
"test_list": [
"assert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)",
"assert math.isclose(volume_cone(10,15), 1570.7963267948965, rel_tol=0.001)",
"assert math.isclose(volume_cone(19,17), 6426.651371693521, rel_tol=0.001)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 388,
"prompt": "Write a python function to find the highest power of 2 that is less than or equal to n.",
"code": "def highest_Power_of_2(n): \n res = 0 \n for i in range(n, 0, -1): \n if ((i & (i - 1)) == 0): \n res = i \n break \n return res ",
"test_imports": [],
"test_list": [
"assert highest_Power_of_2(10) == 8",
"assert highest_Power_of_2(19) == 16",
"assert highest_Power_of_2(32) == 32"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 389,
"prompt": "Write a function to find the n'th lucas number.",
"code": "def find_lucas(n): \n\tif (n == 0): \n\t\treturn 2\n\tif (n == 1): \n\t\treturn 1\n\treturn find_lucas(n - 1) + find_lucas(n - 2) ",
"test_imports": [],
"test_list": [
"assert find_lucas(9) == 76",
"assert find_lucas(4) == 7",
"assert find_lucas(3) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 390,
"prompt": "Write a function to apply a given format string to all of the elements in a list.",
"code": "def add_string(list_, string):\n add_string=[string.format(i) for i in list_]\n return add_string",
"test_imports": [],
"test_list": [
"assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']",
"assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']",
"assert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 391,
"prompt": "Write a function to convert more than one list to nested dictionary.",
"code": "def convert_list_dictionary(l1, l2, l3):\n result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]\n return result",
"test_imports": [],
"test_list": [
"assert convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92])==[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]",
"assert convert_list_dictionary([\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400])==[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]",
"assert convert_list_dictionary([\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40])==[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 392,
"prompt": "Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).",
"code": "def get_max_sum (n):\n\tres = list()\n\tres.append(0)\n\tres.append(1)\n\ti = 2\n\twhile i<n + 1:\n\t\tres.append(max(i, (res[int(i / 2)] \n\t\t\t\t\t\t+ res[int(i / 3)] +\n\t\t\t\t\t\t\tres[int(i / 4)]\n\t\t\t\t\t\t+ res[int(i / 5)])))\n\t\ti = i + 1\n\treturn res[n]",
"test_imports": [],
"test_list": [
"assert get_max_sum(60) == 106",
"assert get_max_sum(10) == 12",
"assert get_max_sum(2) == 2"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 393,
"prompt": "Write a function to find the list with maximum length.",
"code": "def max_length_list(input_list):\n max_length = max(len(x) for x in input_list ) \n max_list = max(input_list, key = lambda i: len(i)) \n return(max_length, max_list)",
"test_imports": [],
"test_list": [
"assert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])",
"assert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])",
"assert max_length_list([[3,4,5],[6,7,8,9],[10,11,12]])==(4,[6,7,8,9])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 394,
"prompt": "Write a function to check if given tuple contains no duplicates.",
"code": "def check_distinct(test_tup):\n res = True\n temp = set()\n for ele in test_tup:\n if ele in temp:\n res = False\n break\n temp.add(ele)\n return res ",
"test_imports": [],
"test_list": [
"assert check_distinct((1, 4, 5, 6, 1, 4)) == False",
"assert check_distinct((1, 4, 5, 6)) == True",
"assert check_distinct((2, 3, 4, 5, 6)) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 395,
"prompt": "Write a python function to find the first non-repeated character in a given string.",
"code": "def first_non_repeating_character(str1):\n char_order = []\n ctr = {}\n for c in str1:\n if c in ctr:\n ctr[c] += 1\n else:\n ctr[c] = 1 \n char_order.append(c)\n for c in char_order:\n if ctr[c] == 1:\n return c\n return None",
"test_imports": [],
"test_list": [
"assert first_non_repeating_character(\"abcabc\") == None",
"assert first_non_repeating_character(\"abc\") == \"a\"",
"assert first_non_repeating_character(\"ababc\") == \"c\""
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 396,
"prompt": "Write a function to check whether the given string starts and ends with the same character or not.",
"code": "import re \nregex = r'^[a-z]$|^([a-z]).*\\1$'\ndef check_char(string): \n\tif(re.search(regex, string)): \n\t\treturn \"Valid\" \n\telse: \n\t\treturn \"Invalid\" ",
"test_imports": [],
"test_list": [
"assert check_char(\"abba\") == \"Valid\"",
"assert check_char(\"a\") == \"Valid\"",
"assert check_char(\"abcd\") == \"Invalid\""
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 397,
"prompt": "Write a function to find the median of three numbers.",
"code": "def median_numbers(a,b,c):\n if a > b:\n if a < c:\n median = a\n elif b > c:\n median = b\n else:\n median = c\n else:\n if a > c:\n median = a\n elif b < c:\n median = b\n else:\n median = c\n return median",
"test_imports": [],
"test_list": [
"assert median_numbers(25,55,65)==55.0",
"assert median_numbers(20,10,30)==20.0",
"assert median_numbers(15,45,75)==45.0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 398,
"prompt": "Write a function to compute the sum of digits of each number of a given list.",
"code": "def sum_of_digits(nums):\n return sum(int(el) for n in nums for el in str(n) if el.isdigit())",
"test_imports": [],
"test_list": [
"assert sum_of_digits([10,2,56])==14",
"assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19",
"assert sum_of_digits([10,20,-4,5,-70])==19"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 399,
"prompt": "Write a function to perform the mathematical bitwise xor operation across the given tuples.",
"code": "def bitwise_xor(test_tup1, test_tup2):\n res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)",
"assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)",
"assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 400,
"prompt": "Write a function to extract the number of unique tuples in the given list.",
"code": "def extract_freq(test_list):\n res = len(list(set(tuple(sorted(sub)) for sub in test_list)))\n return (res)",
"test_imports": [],
"test_list": [
"assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3",
"assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4",
"assert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 401,
"prompt": "Write a function to perform index wise addition of tuple elements in the given two nested tuples.",
"code": "def add_nested_tuples(test_tup1, test_tup2):\n res = tuple(tuple(a + b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))",
"assert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))",
"assert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 404,
"prompt": "Write a python function to find the minimum of two numbers.",
"code": "def minimum(a,b): \n if a <= b: \n return a \n else: \n return b ",
"test_imports": [],
"test_list": [
"assert minimum(1,2) == 1",
"assert minimum(-5,-4) == -5",
"assert minimum(0,0) == 0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 405,
"prompt": "Write a function to check whether an element exists within a tuple.",
"code": "def check_tuplex(tuplex,tuple1): \n if tuple1 in tuplex:\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r')==True",
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5')==False",
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 406,
"prompt": "Write a python function to find whether the parity of a given number is odd.",
"code": "def find_Parity(x): \n y = x ^ (x >> 1); \n y = y ^ (y >> 2); \n y = y ^ (y >> 4); \n y = y ^ (y >> 8); \n y = y ^ (y >> 16); \n if (y & 1): \n return True\n return False",
"test_imports": [],
"test_list": [
"assert find_Parity(12) == False",
"assert find_Parity(7) == True",
"assert find_Parity(10) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 407,
"prompt": "Write a function to create the next bigger number by rearranging the digits of a given number.",
"code": "def rearrange_bigger(n):\n nums = list(str(n))\n for i in range(len(nums)-2,-1,-1):\n if nums[i] < nums[i+1]:\n z = nums[i:]\n y = min(filter(lambda x: x > z[0], z))\n z.remove(y)\n z.sort()\n nums[i:] = [y] + z\n return int(\"\".join(nums))\n return False",
"test_imports": [],
"test_list": [
"assert rearrange_bigger(12)==21",
"assert rearrange_bigger(10)==False",
"assert rearrange_bigger(102)==120"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 408,
"prompt": "Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array.",
"code": "import heapq\ndef k_smallest_pairs(nums1, nums2, k):\n queue = []\n def push(i, j):\n if i < len(nums1) and j < len(nums2):\n heapq.heappush(queue, [nums1[i] + nums2[j], i, j])\n push(0, 0)\n pairs = []\n while queue and len(pairs) < k:\n _, i, j = heapq.heappop(queue)\n pairs.append([nums1[i], nums2[j]])\n push(i, j + 1)\n if j == 0:\n push(i + 1, 0)\n return pairs",
"test_imports": [],
"test_list": [
"assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]",
"assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]",
"assert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 409,
"prompt": "Write a function to find the minimum product from the pairs of tuples within a given list.",
"code": "def min_product_tuple(list1):\n result_min = min([abs(x * y) for x, y in list1] )\n return result_min",
"test_imports": [],
"test_list": [
"assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8",
"assert min_product_tuple([(10,20), (15,2), (5,10)] )==30",
"assert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 410,
"prompt": "Write a function to find the minimum value in a given heterogeneous list.",
"code": "def min_val(listval):\n min_val = min(i for i in listval if isinstance(i, int))\n return min_val",
"test_imports": [],
"test_list": [
"assert min_val(['Python', 3, 2, 4, 5, 'version'])==2",
"assert min_val(['Python', 15, 20, 25])==15",
"assert min_val(['Python', 30, 20, 40, 50, 'version'])==20"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 411,
"prompt": "Write a function to convert the given snake case string to camel case string.",
"code": "import re\ndef snake_to_camel(word):\n return ''.join(x.capitalize() or '_' for x in word.split('_'))",
"test_imports": [],
"test_list": [
"assert snake_to_camel('android_tv') == 'AndroidTv'",
"assert snake_to_camel('google_pixel') == 'GooglePixel'",
"assert snake_to_camel('apple_watch') == 'AppleWatch'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 412,
"prompt": "Write a python function to remove odd numbers from a given list.",
"code": "def remove_odd(l):\n for i in l:\n if i % 2 != 0:\n l.remove(i)\n return l",
"test_imports": [],
"test_list": [
"assert remove_odd([1,2,3]) == [2]",
"assert remove_odd([2,4,6]) == [2,4,6]",
"assert remove_odd([10,20,3]) == [10,20]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 413,
"prompt": "Write a function to extract the nth element from a given list of tuples.",
"code": "def extract_nth_element(list1, n):\n result = [x[n] for x in list1]\n return result",
"test_imports": [],
"test_list": [
"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']",
"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[99, 96, 94, 98]",
"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1)==[98, 97, 91, 94]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 414,
"prompt": "Write a python function to check whether any value in a sequence exists in a sequence or not.",
"code": "def overlapping(list1,list2): \n for i in range(len(list1)): \n for j in range(len(list2)): \n if(list1[i]==list2[j]): \n return True\n return False",
"test_imports": [],
"test_list": [
"assert overlapping([1,2,3,4,5],[6,7,8,9]) == False",
"assert overlapping([1,2,3],[4,5,6]) == False",
"assert overlapping([1,4,5],[1,4,5]) == True"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 415,
"prompt": "Write a python function to find a pair with highest product from a given array of integers.",
"code": "def max_Product(arr): \n arr_len = len(arr) \n if (arr_len < 2): \n return (\"No pairs exists\") \n x = arr[0]; y = arr[1] \n for i in range(0,arr_len): \n for j in range(i + 1,arr_len): \n if (arr[i] * arr[j] > x * y): \n x = arr[i]; y = arr[j] \n return x,y ",
"test_imports": [],
"test_list": [
"assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)",
"assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)",
"assert max_Product([1,2,3]) == (2,3)"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 417,
"prompt": "Write a function to find common first element in given list of tuple.",
"code": "def group_tuples(Input): \n\tout = {} \n\tfor elem in Input: \n\t\ttry: \n\t\t\tout[elem[0]].extend(elem[1:]) \n\t\texcept KeyError: \n\t\t\tout[elem[0]] = list(elem) \n\treturn [tuple(values) for values in out.values()] ",
"test_imports": [],
"test_list": [
"assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]",
"assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]",
"assert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 418,
"prompt": "Write a python function to find the element of a list having maximum length.",
"code": "def Find_Max(lst): \n maxList = max((x) for x in lst) \n return maxList",
"test_imports": [],
"test_list": [
"assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']",
"assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]",
"assert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 419,
"prompt": "Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.",
"code": "def round_and_sum(list1):\n lenght=len(list1)\n round_and_sum=sum(list(map(round,list1))* lenght)\n return round_and_sum",
"test_imports": [],
"test_list": [
"assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243",
"assert round_and_sum([5,2,9,24.3,29])==345",
"assert round_and_sum([25.0,56.7,89.2])==513"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 420,
"prompt": "Write a python function to find the cube sum of first n even natural numbers.",
"code": "def cube_Sum(n): \n sum = 0\n for i in range(1,n + 1): \n sum += (2*i)*(2*i)*(2*i) \n return sum",
"test_imports": [],
"test_list": [
"assert cube_Sum(2) == 72",
"assert cube_Sum(3) == 288",
"assert cube_Sum(4) == 800"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 421,
"prompt": "Write a function to concatenate each element of tuple by the delimiter.",
"code": "def concatenate_tuple(test_tup):\n delim = \"-\"\n res = ''.join([str(ele) + delim for ele in test_tup])\n res = res[ : len(res) - len(delim)]\n return (str(res)) ",
"test_imports": [],
"test_list": [
"assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'",
"assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'",
"assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 422,
"prompt": "Write a python function to find the average of cubes of first n natural numbers.",
"code": "def find_Average_Of_Cube(n): \n sum = 0\n for i in range(1, n + 1): \n sum += i * i * i \n return round(sum / n, 6) ",
"test_imports": [],
"test_list": [
"assert find_Average_Of_Cube(2) == 4.5",
"assert find_Average_Of_Cube(3) == 12",
"assert find_Average_Of_Cube(1) == 1"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 424,
"prompt": "Write a function to extract only the rear index element of each string in the given tuple.",
"code": "def extract_rear(test_tuple):\n res = list(sub[len(sub) - 1] for sub in test_tuple)\n return (res) ",
"test_imports": [],
"test_list": [
"assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']",
"assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']",
"assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 425,
"prompt": "Write a function to count the number of sublists containing a particular element.",
"code": "def count_element_in_list(list1, x): \n ctr = 0\n for i in range(len(list1)): \n if x in list1[i]: \n ctr+= 1 \n return ctr",
"test_imports": [],
"test_list": [
"assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3",
"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3",
"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 426,
"prompt": "Write a function to filter odd numbers.",
"code": "def filter_oddnumbers(nums):\n odd_nums = list(filter(lambda x: x%2 != 0, nums))\n return odd_nums",
"test_imports": [],
"test_list": [
"assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]",
"assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]",
"assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 427,
"prompt": "Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.",
"code": "import re\ndef change_date_format(dt):\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)",
"test_imports": [],
"test_list": [
"assert change_date_format(\"2026-01-02\") == '02-01-2026'",
"assert change_date_format(\"2020-11-13\") == '13-11-2020'",
"assert change_date_format(\"2021-04-26\") == '26-04-2021'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 428,
"prompt": "Write a function to sort the given array by using shell sort.",
"code": "def shell_sort(my_list):\n gap = len(my_list) // 2\n while gap > 0:\n for i in range(gap, len(my_list)):\n current_item = my_list[i]\n j = i\n while j >= gap and my_list[j - gap] > current_item:\n my_list[j] = my_list[j - gap]\n j -= gap\n my_list[j] = current_item\n gap //= 2\n\n return my_list",
"test_imports": [],
"test_list": [
"assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]",
"assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]",
"assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 429,
"prompt": "Write a function to extract the elementwise and tuples from the given two tuples.",
"code": "def and_tuples(test_tup1, test_tup2):\n res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)",
"assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)",
"assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 430,
"prompt": "Write a function to find the directrix of a parabola.",
"code": "def parabola_directrix(a, b, c): \n directrix=((int)(c - ((b * b) + 1) * 4 * a ))\n return directrix",
"test_imports": [],
"test_list": [
"assert parabola_directrix(5,3,2)==-198",
"assert parabola_directrix(9,8,4)==-2336",
"assert parabola_directrix(2,4,6)==-130"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 431,
"prompt": "Write a function that takes two lists and returns true if they have at least one common element.",
"code": "def common_element(list1, list2):\n result = False\n for x in list1:\n for y in list2:\n if x == y:\n result = True\n return result",
"test_imports": [],
"test_list": [
"assert common_element([1,2,3,4,5], [5,6,7,8,9])==True",
"assert common_element([1,2,3,4,5], [6,7,8,9])==None",
"assert common_element(['a','b','c'], ['d','b','e'])==True"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 432,
"prompt": "Write a function to find the median length of a trapezium.",
"code": "def median_trapezium(base1,base2,height):\n median = 0.5 * (base1+ base2)\n return median",
"test_imports": [],
"test_list": [
"assert median_trapezium(15,25,35)==20",
"assert median_trapezium(10,20,30)==15",
"assert median_trapezium(6,9,4)==7.5"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 433,
"prompt": "Write a function to check whether the entered number is greater than the elements of the given array.",
"code": "def check_greater(arr, number):\n arr.sort()\n return number > arr[-1]",
"test_imports": [],
"test_list": [
"assert check_greater([1, 2, 3, 4, 5], 4) == False",
"assert check_greater([2, 3, 4, 5, 6], 8) == True",
"assert check_greater([9, 7, 4, 8, 6, 1], 11) == True"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 434,
"prompt": "Write a function that matches a string that has an a followed by one or more b's.",
"code": "import re\ndef text_match_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False\n",
"test_imports": [],
"test_list": [
"assert text_match_one(\"ac\")==False",
"assert text_match_one(\"dc\")==False",
"assert text_match_one(\"abba\")==True"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 435,
"prompt": "Write a python function to find the last digit of a given number.",
"code": "def last_Digit(n) :\n return (n % 10) ",
"test_imports": [],
"test_list": [
"assert last_Digit(123) == 3",
"assert last_Digit(25) == 5",
"assert last_Digit(30) == 0"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 436,
"prompt": "Write a python function to return the negative numbers in a list.",
"code": "def neg_nos(list1):\n out = []\n for num in list1: \n if num < 0: \n out.append(num)\n return out ",
"test_imports": [],
"test_list": [
"assert neg_nos([-1,4,5,-6]) == [-1,-6]",
"assert neg_nos([-1,-2,3,4]) == [-1,-2]",
"assert neg_nos([-7,-6,8,9]) == [-7,-6]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 437,
"prompt": "Write a function to remove odd characters in a string.",
"code": "def remove_odd(str1):\n str2 = ''\n for i in range(1, len(str1) + 1):\n if(i % 2 == 0):\n str2 = str2 + str1[i - 1]\n return str2",
"test_imports": [],
"test_list": [
"assert remove_odd(\"python\")==(\"yhn\")",
"assert remove_odd(\"program\")==(\"rga\")",
"assert remove_odd(\"language\")==(\"agae\")"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 438,
"prompt": "Write a function to count bidirectional tuple pairs.",
"code": "def count_bidirectional(test_list):\n res = 0\n for idx in range(0, len(test_list)):\n for iidx in range(idx + 1, len(test_list)):\n if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:\n res += 1\n return res",
"test_imports": [],
"test_list": [
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3",
"assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2",
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 439,
"prompt": "Write a function to join a list of multiple integers into a single integer.",
"code": "def multiple_to_single(L):\n x = int(\"\".join(map(str, L)))\n return x",
"test_imports": [],
"test_list": [
"assert multiple_to_single([11, 33, 50])==113350",
"assert multiple_to_single([-1,2,3,4,5,6])==-123456",
"assert multiple_to_single([10,15,20,25])==10152025"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 440,
"prompt": "Write a function to find the first adverb and their positions in a given sentence.",
"code": "import re\ndef find_adverb_position(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return (m.start(), m.end(), m.group(0))",
"test_imports": [],
"test_list": [
"assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')",
"assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')",
"assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 441,
"prompt": "Write a function to find the surface area of a cube of a given size.",
"code": "def surfacearea_cube(l):\n surfacearea= 6*l*l\n return surfacearea",
"test_imports": [],
"test_list": [
"assert surfacearea_cube(5)==150",
"assert surfacearea_cube(3)==54",
"assert surfacearea_cube(10)==600"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 442,
"prompt": "Write a function to find the ration of positive numbers in an array of integers.",
"code": "from array import array\ndef positive_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x > 0:\n n1 += 1\n else:\n None\n return round(n1/n,2)",
"test_imports": [],
"test_list": [
"assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54",
"assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69",
"assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 443,
"prompt": "Write a python function to find the largest negative number from the given list.",
"code": "def largest_neg(list1): \n max = list1[0] \n for x in list1: \n if x < max : \n max = x \n return max",
"test_imports": [],
"test_list": [
"assert largest_neg([1,2,3,-4,-6]) == -6",
"assert largest_neg([1,2,3,-8,-9]) == -9",
"assert largest_neg([1,2,3,4,-1]) == -1"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 444,
"prompt": "Write a function to trim each tuple by k in the given tuple list.",
"code": "def trim_tuple(test_list, K):\n res = []\n for ele in test_list:\n N = len(ele)\n res.append(tuple(list(ele)[K: N - K]))\n return (str(res)) ",
"test_imports": [],
"test_list": [
"assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'",
"assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'",
"assert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 445,
"prompt": "Write a function to perform index wise multiplication of tuple elements in the given two tuples.",
"code": "def index_multiplication(test_tup1, test_tup2):\n res = tuple(tuple(a * b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))",
"assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))",
"assert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 446,
"prompt": "Write a python function to count the occurence of all elements of list in a tuple.",
"code": "from collections import Counter \ndef count_Occurrence(tup, lst): \n count = 0\n for item in tup: \n if item in lst: \n count+= 1 \n return count ",
"test_imports": [],
"test_list": [
"assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3",
"assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6",
"assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 447,
"prompt": "Write a function to find cubes of individual elements in a list.",
"code": "def cube_nums(nums):\n cube_nums = list(map(lambda x: x ** 3, nums))\n return cube_nums",
"test_imports": [],
"test_list": [
"assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]",
"assert cube_nums([10,20,30])==([1000, 8000, 27000])",
"assert cube_nums([12,15])==([1728, 3375])"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 448,
"prompt": "Write a function to calculate the sum of perrin numbers.",
"code": "def cal_sum(n): \n\ta = 3\n\tb = 0\n\tc = 2\n\tif (n == 0): \n\t\treturn 3\n\tif (n == 1): \n\t\treturn 3\n\tif (n == 2): \n\t\treturn 5\n\tsum = 5\n\twhile (n > 2): \n\t\td = a + b \n\t\tsum = sum + d \n\t\ta = b \n\t\tb = c \n\t\tc = d \n\t\tn = n-1\n\treturn sum",
"test_imports": [],
"test_list": [
"assert cal_sum(9) == 49",
"assert cal_sum(10) == 66",
"assert cal_sum(11) == 88"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 450,
"prompt": "Write a function to extract specified size of strings from a given list of string values.",
"code": "def extract_string(str, l):\n result = [e for e in str if len(e) == l] \n return result",
"test_imports": [],
"test_list": [
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 451,
"prompt": "Write a function to remove all whitespaces from the given string.",
"code": "import re\ndef remove_whitespaces(text1):\n return (re.sub(r'\\s+', '',text1))",
"test_imports": [],
"test_list": [
"assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'",
"assert remove_whitespaces(' Google Dart ') == 'GoogleDart'",
"assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 452,
"prompt": "Write a function that gives loss amount on a sale if the given amount has loss else return 0.",
"code": "def loss_amount(actual_cost,sale_amount): \n if(sale_amount > actual_cost):\n amount = sale_amount - actual_cost\n return amount\n else:\n return 0",
"test_imports": [],
"test_list": [
"assert loss_amount(1500,1200)==0",
"assert loss_amount(100,200)==100",
"assert loss_amount(2000,5000)==3000"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 453,
"prompt": "Write a python function to find the sum of even factors of a number.",
"code": "import math \ndef sumofFactors(n) : \n if (n % 2 != 0) : \n return 0\n res = 1\n for i in range(2, (int)(math.sqrt(n)) + 1) : \n count = 0\n curr_sum = 1\n curr_term = 1\n while (n % i == 0) : \n count= count + 1\n n = n // i \n if (i == 2 and count == 1) : \n curr_sum = 0\n curr_term = curr_term * i \n curr_sum = curr_sum + curr_term \n res = res * curr_sum \n if (n >= 2) : \n res = res * (1 + n) \n return res",
"test_imports": [],
"test_list": [
"assert sumofFactors(18) == 26",
"assert sumofFactors(30) == 48",
"assert sumofFactors(6) == 8"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 454,
"prompt": "Write a function that matches a word containing 'z'.",
"code": "import re\ndef text_match_wordz(text):\n patterns = '\\w*z.\\w*'\n if re.search(patterns, text):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert text_match_wordz(\"pythonz.\")==True",
"assert text_match_wordz(\"xyz.\")==True",
"assert text_match_wordz(\" lang .\")==False"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 455,
"prompt": "Write a function to check whether the given month number contains 31 days or not.",
"code": "def check_monthnumb_number(monthnum2):\n if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert check_monthnumb_number(5)==True",
"assert check_monthnumb_number(2)==False",
"assert check_monthnumb_number(6)==False"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 456,
"prompt": "Write a function to reverse each string in a given list of string values.",
"code": "def reverse_string_list(stringlist):\n result = [x[::-1] for x in stringlist]\n return result",
"test_imports": [],
"test_list": [
"assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']",
"assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']",
"assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 457,
"prompt": "Write a python function to find the sublist having minimum length.",
"code": "def Find_Min(lst): \n return min(lst, key=len) ",
"test_imports": [],
"test_list": [
"assert Find_Min([[1],[1,2],[1,2,3]]) == [1]",
"assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]",
"assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 458,
"prompt": "Write a function to find the area of a rectangle.",
"code": "def rectangle_area(l,b):\n area=l*b\n return area",
"test_imports": [],
"test_list": [
"assert rectangle_area(10,20)==200",
"assert rectangle_area(10,5)==50",
"assert rectangle_area(4,2)==8"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 459,
"prompt": "Write a function to remove uppercase substrings from a given string.",
"code": "import re\ndef remove_uppercase(str1):\n return re.sub('[A-Z]', '', str1)",
"test_imports": [],
"test_list": [
"assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'",
"assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'",
"assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 460,
"prompt": "Write a python function to get the first element of each sublist.",
"code": "def Extract(lst): \n return [item[0] for item in lst] ",
"test_imports": [],
"test_list": [
"assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]",
"assert Extract([[1,2,3],[4, 5]]) == [1,4]",
"assert Extract([[9,8,1],[1,2]]) == [9,1]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 461,
"prompt": "Write a python function to count the upper case characters in a given string.",
"code": "def upper_ctr(str):\n upper_ctr = 0\n for i in range(len(str)):\n if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1\n return upper_ctr",
"test_imports": [],
"test_list": [
"assert upper_ctr('PYthon') == 1",
"assert upper_ctr('BigData') == 1",
"assert upper_ctr('program') == 0"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 462,
"prompt": "Write a function to find all possible combinations of the elements of a given list.",
"code": "def combinations_list(list1):\n if len(list1) == 0:\n return [[]]\n result = []\n for el in combinations_list(list1[1:]):\n result += [el, el+[list1[0]]]\n return result",
"test_imports": [],
"test_list": [
"assert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]",
"assert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]",
"assert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 463,
"prompt": "Write a function to find the maximum product subarray of the given array.",
"code": "def max_subarray_product(arr):\n\tn = len(arr)\n\tmax_ending_here = 1\n\tmin_ending_here = 1\n\tmax_so_far = 0\n\tflag = 0\n\tfor i in range(0, n):\n\t\tif arr[i] > 0:\n\t\t\tmax_ending_here = max_ending_here * arr[i]\n\t\t\tmin_ending_here = min (min_ending_here * arr[i], 1)\n\t\t\tflag = 1\n\t\telif arr[i] == 0:\n\t\t\tmax_ending_here = 1\n\t\t\tmin_ending_here = 1\n\t\telse:\n\t\t\ttemp = max_ending_here\n\t\t\tmax_ending_here = max (min_ending_here * arr[i], 1)\n\t\t\tmin_ending_here = temp * arr[i]\n\t\tif (max_so_far < max_ending_here):\n\t\t\tmax_so_far = max_ending_here\n\tif flag == 0 and max_so_far == 0:\n\t\treturn 0\n\treturn max_so_far",
"test_imports": [],
"test_list": [
"assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112",
"assert max_subarray_product([6, -3, -10, 0, 2]) == 180",
"assert max_subarray_product([-2, -40, 0, -2, -3]) == 80"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 464,
"prompt": "Write a function to check if all values are same in a dictionary.",
"code": "def check_value(dict, n):\n result = all(x == n for x in dict.values()) \n return result",
"test_imports": [],
"test_list": [
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False",
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True",
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 465,
"prompt": "Write a function to drop empty items from a given dictionary.",
"code": "def drop_empty(dict1):\n dict1 = {key:value for (key, value) in dict1.items() if value is not None}\n return dict1",
"test_imports": [],
"test_list": [
"assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}",
"assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}",
"assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 468,
"prompt": "Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.",
"code": "def max_product(arr): \n n = len(arr)\n mpis = arr[:]\n for i in range(n): \n current_prod = arr[i]\n j = i + 1\n while j < n:\n if arr[j-1] > arr[j]: \n break\n current_prod *= arr[j]\n if current_prod > mpis[j]:\n mpis[j] = current_prod \n j = j + 1\n return max(mpis)",
"test_imports": [],
"test_list": [
"assert max_product([3, 100, 4, 5, 150, 6]) == 3000",
"assert max_product([4, 42, 55, 68, 80]) == 50265600",
"assert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 470,
"prompt": "Write a function to find the pairwise addition of the neighboring elements of the given tuple.",
"code": "def add_pairwise(test_tup):\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\n return (res) ",
"test_imports": [],
"test_list": [
"assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)",
"assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)",
"assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 471,
"prompt": "Write a python function to find the product of the array multiplication modulo n.",
"code": "def find_remainder(arr, n): \n mul = 1\n for i in range(len(arr)): \n mul = (mul * (arr[i] % n)) % n \n return mul % n ",
"test_imports": [],
"test_list": [
"assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9",
"assert find_remainder([1,1,1],1) == 0",
"assert find_remainder([1,2,1],2) == 0"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 472,
"prompt": "Write a python function to check whether the given list contains consecutive numbers or not.",
"code": "def check_Consecutive(l): \n return sorted(l) == list(range(min(l),max(l)+1)) ",
"test_imports": [],
"test_list": [
"assert check_Consecutive([1,2,3,4,5]) == True",
"assert check_Consecutive([1,2,3,5,6]) == False",
"assert check_Consecutive([1,2,1]) == False"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 473,
"prompt": "Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.",
"code": "def tuple_intersection(test_list1, test_list2):\n res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])\n return (res)",
"test_imports": [],
"test_list": [
"assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}",
"assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}",
"assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 474,
"prompt": "Write a function to replace characters in a string.",
"code": "def replace_char(str1,ch,newch):\n str2 = str1.replace(ch, newch)\n return str2",
"test_imports": [],
"test_list": [
"assert replace_char(\"polygon\",'y','l')==(\"pollgon\")",
"assert replace_char(\"character\",'c','a')==(\"aharaater\")",
"assert replace_char(\"python\",'l','a')==(\"python\")"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 475,
"prompt": "Write a function to sort a dictionary by value.",
"code": "from collections import Counter\ndef sort_counter(dict1):\n x = Counter(dict1)\n sort_counter=x.most_common()\n return sort_counter",
"test_imports": [],
"test_list": [
"assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]",
"assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]",
"assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 476,
"prompt": "Write a python function to find the sum of the largest and smallest value in a given array.",
"code": "def big_sum(nums):\n sum= max(nums)+min(nums)\n return sum",
"test_imports": [],
"test_list": [
"assert big_sum([1,2,3]) == 4",
"assert big_sum([-1,2,3,4]) == 3",
"assert big_sum([2,3,6]) == 8"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 477,
"prompt": "Write a python function to convert the given string to lower case.",
"code": "def is_lower(string):\n return (string.lower())",
"test_imports": [],
"test_list": [
"assert is_lower(\"InValid\") == \"invalid\"",
"assert is_lower(\"TruE\") == \"true\"",
"assert is_lower(\"SenTenCE\") == \"sentence\""
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 478,
"prompt": "Write a function to remove lowercase substrings from a given string.",
"code": "import re\ndef remove_lowercase(str1):\n return re.sub('[a-z]', '', str1)",
"test_imports": [],
"test_list": [
"assert remove_lowercase(\"PYTHon\")==('PYTH')",
"assert remove_lowercase(\"FInD\")==('FID')",
"assert remove_lowercase(\"STRinG\")==('STRG')"
]
},
{
"source_file": "charlessutton@: Benchmark Questions Verification V2.ipynb",
"task_id": 479,
"prompt": "Write a python function to find the first digit of a given number.",
"code": "def first_Digit(n) : \n while n >= 10: \n n = n / 10 \n return int(n) ",
"test_imports": [],
"test_list": [
"assert first_Digit(123) == 1",
"assert first_Digit(456) == 4",
"assert first_Digit(12) == 1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 554,
"prompt": "Write a python function which takes a list of integers and only returns the odd ones.",
"code": "def Split(list): \n od_li = [] \n for i in list: \n if (i % 2 != 0): \n od_li.append(i) \n return od_li",
"test_imports": [],
"test_list": [
"assert Split([1,2,3,4,5,6]) == [1,3,5]",
"assert Split([10,11,12,13]) == [11,13]",
"assert Split([7,8,9,1]) == [7,9,1]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 555,
"prompt": "Write a python function to find the difference between the sum of cubes of the first n natural numbers and the sum of the first n natural numbers.",
"code": "def difference(n) : \n S = (n*(n + 1))//2; \n res = S*(S-1); \n return res; ",
"test_imports": [],
"test_list": [
"assert difference(3) == 30",
"assert difference(5) == 210",
"assert difference(2) == 6"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 556,
"prompt": "Write a python function to count the number of pairs whose xor value is odd.",
"code": "def find_Odd_Pair(A,N) : \n oddPair = 0\n for i in range(0,N) : \n for j in range(i+1,N) : \n if ((A[i] ^ A[j]) % 2 != 0): \n oddPair+=1 \n return oddPair ",
"test_imports": [],
"test_list": [
"assert find_Odd_Pair([5,4,7,2,1],5) == 6",
"assert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12",
"assert find_Odd_Pair([1,2,3],3) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 557,
"prompt": "Write a function to toggle the case of all characters in a string.",
"code": "def toggle_string(string):\n string1 = string.swapcase()\n return string1",
"test_imports": [],
"test_list": [
"assert toggle_string(\"Python\")==(\"pYTHON\")",
"assert toggle_string(\"Pangram\")==(\"pANGRAM\")",
"assert toggle_string(\"LIttLE\")==(\"liTTle\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 558,
"prompt": "Write a python function to find the sum of the per-digit difference between two integers.",
"code": "def digit_distance_nums(n1, n2):\n return sum(map(int,str(abs(n1-n2))))",
"test_imports": [],
"test_list": [
"assert digit_distance_nums(1,2) == 1",
"assert digit_distance_nums(23,56) == 6",
"assert digit_distance_nums(123,256) == 7"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 559,
"prompt": "Write a function to find the sum of the largest contiguous sublist in the given list.",
"code": "def max_sub_array_sum(a, size):\n max_so_far = 0\n max_ending_here = 0\n for i in range(0, size):\n max_ending_here = max_ending_here + a[i]\n if max_ending_here < 0:\n max_ending_here = 0\n elif (max_so_far < max_ending_here):\n max_so_far = max_ending_here\n return max_so_far",
"test_imports": [],
"test_list": [
"assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7",
"assert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8",
"assert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 560,
"prompt": "Write a function to find the union of the elements of two given tuples and output them in sorted order.",
"code": "def union_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1 + test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)",
"assert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6)",
"assert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 562,
"prompt": "Write a python function to find the length of the longest sublists.",
"code": "def Find_Max_Length(lst): \n maxLength = max(len(x) for x in lst )\n return maxLength ",
"test_imports": [],
"test_list": [
"assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4",
"assert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3",
"assert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 563,
"prompt": "Write a function to extract values between quotation marks from a string.",
"code": "import re\ndef extract_values(text):\n return (re.findall(r'\"(.*?)\"', text))",
"test_imports": [],
"test_list": [
"assert extract_values('\"Python\", \"PHP\", \"Java\"')==['Python', 'PHP', 'Java']",
"assert extract_values('\"python\",\"program\",\"language\"')==['python','program','language']",
"assert extract_values('\"red\",\"blue\",\"green\",\"yellow\"')==['red','blue','green','yellow']"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 564,
"prompt": "Write a python function which takes a list of integers and counts the number of possible unordered pairs where both elements are unequal.",
"code": "def count_Pairs(arr,n): \n cnt = 0; \n for i in range(n): \n for j in range(i + 1,n): \n if (arr[i] != arr[j]): \n cnt += 1; \n return cnt; ",
"test_imports": [],
"test_list": [
"assert count_Pairs([1,2,1],3) == 2",
"assert count_Pairs([1,1,1,1],4) == 0",
"assert count_Pairs([1,2,3,4,5],5) == 10"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 565,
"prompt": "Write a python function to split a string into characters.",
"code": "def split(word): \n return [char for char in word] ",
"test_imports": [],
"test_list": [
"assert split('python') == ['p','y','t','h','o','n']",
"assert split('Name') == ['N','a','m','e']",
"assert split('program') == ['p','r','o','g','r','a','m']"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 566,
"prompt": "Write a function to get the sum of the digits of a non-negative integer.",
"code": "def sum_digits(n):\n if n == 0:\n return 0\n else:\n return n % 10 + sum_digits(int(n / 10))",
"test_imports": [],
"test_list": [
"assert sum_digits(345)==12",
"assert sum_digits(12)==3",
"assert sum_digits(97)==16"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 567,
"prompt": "Write a function to check whether a specified list is sorted or not.",
"code": "def issort_list(list1):\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\n return result",
"test_imports": [],
"test_list": [
"assert issort_list([1,2,4,6,8,10,12,14,16,17])==True",
"assert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False",
"assert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 568,
"prompt": "Write a function to create a list of N empty dictionaries.",
"code": "def empty_list(length):\n empty_list = [{} for _ in range(length)]\n return empty_list",
"test_imports": [],
"test_list": [
"assert empty_list(5)==[{},{},{},{},{}]",
"assert empty_list(6)==[{},{},{},{},{},{}]",
"assert empty_list(7)==[{},{},{},{},{},{},{}]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 569,
"prompt": "Write a function to sort each sublist of strings in a given list of lists.",
"code": "def sort_sublists(list1):\n result = list(map(sorted,list1)) \n return result",
"test_imports": [],
"test_list": [
"assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]",
"assert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']]",
"assert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 572,
"prompt": "Write a python function to remove duplicate numbers from a given number of lists.",
"code": "def two_unique_nums(nums):\n return [i for i in nums if nums.count(i)==1]",
"test_imports": [],
"test_list": [
"assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]",
"assert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5]",
"assert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 573,
"prompt": "Write a python function to calculate the product of the unique numbers in a given list.",
"code": "def unique_product(list_data):\n temp = list(set(list_data))\n p = 1\n for i in temp:\n p *= i\n return p",
"test_imports": [],
"test_list": [
"assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000",
"assert unique_product([1, 2, 3, 1,]) == 6",
"assert unique_product([7, 8, 9, 0, 1, 1]) == 0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 574,
"prompt": "Write a function to find the surface area of a cylinder.",
"code": "def surfacearea_cylinder(r,h):\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\n return surfacearea",
"test_imports": [],
"test_list": [
"assert surfacearea_cylinder(10,5)==942.45",
"assert surfacearea_cylinder(4,5)==226.18800000000002",
"assert surfacearea_cylinder(4,10)==351.848"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 576,
"prompt": "Write a python function to check whether a list is sublist of another or not.",
"code": "def is_Sub_Array(A,B): \n n = len(A)\n m = len(B)\n i = 0; j = 0; \n while (i < n and j < m): \n if (A[i] == B[j]): \n i += 1; \n j += 1; \n if (j == m): \n return True; \n else: \n i = i - j + 1; \n j = 0; \n return False; ",
"test_imports": [],
"test_list": [
"assert is_Sub_Array([1,4,3,5],[1,2]) == False",
"assert is_Sub_Array([1,2,1],[1,2,1]) == True",
"assert is_Sub_Array([1,0,2,2],[2,2,0]) ==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 577,
"prompt": "Write a python function to find the last digit in factorial of a given number.",
"code": "def last_Digit_Factorial(n): \n if (n == 0): return 1\n elif (n <= 2): return n \n elif (n == 3): return 6\n elif (n == 4): return 4 \n else: \n return 0",
"test_imports": [],
"test_list": [
"assert last_Digit_Factorial(4) == 4",
"assert last_Digit_Factorial(21) == 0",
"assert last_Digit_Factorial(30) == 0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 578,
"prompt": "Write a function to interleave 3 lists of the same length into a single flat list.",
"code": "def interleave_lists(list1,list2,list3):\n result = [el for pair in zip(list1, list2, list3) for el in pair]\n return result",
"test_imports": [],
"test_list": [
"assert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]",
"assert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10]",
"assert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 579,
"prompt": "Write a function to find the dissimilar elements in the given two tuples.",
"code": "def find_dissimilar(test_tup1, test_tup2):\n res = tuple(set(test_tup1) ^ set(test_tup2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)",
"assert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9)",
"assert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 580,
"prompt": "Write a function to remove uneven elements in the nested mixed tuple.",
"code": "def even_ele(test_tuple, even_fnc): \n\tres = tuple() \n\tfor ele in test_tuple: \n\t\tif isinstance(ele, tuple): \n\t\t\tres += (even_ele(ele, even_fnc), ) \n\t\telif even_fnc(ele): \n\t\t\tres += (ele, ) \n\treturn res \ndef extract_even(test_tuple):\n res = even_ele(test_tuple, lambda x: x % 2 == 0)\n return (res) ",
"test_imports": [],
"test_list": [
"assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)",
"assert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8)))",
"assert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 581,
"prompt": "Write a python function to find the surface area of a square pyramid with a given base edge and height.",
"code": "def surface_Area(b,s): \n return 2 * b * s + pow(b,2) ",
"test_imports": [],
"test_list": [
"assert surface_Area(3,4) == 33",
"assert surface_Area(4,5) == 56",
"assert surface_Area(1,2) == 5"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 582,
"prompt": "Write a function to check if a dictionary is empty",
"code": "def my_dict(dict1):\n if bool(dict1):\n return False\n else:\n return True",
"test_imports": [],
"test_list": [
"assert my_dict({10})==False",
"assert my_dict({11})==False",
"assert my_dict({})==True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 583,
"prompt": "Write a function which returns nth catalan number.",
"code": "def catalan_number(num):\n if num <=1:\n return 1 \n res_num = 0\n for i in range(num):\n res_num += catalan_number(i) * catalan_number(num-i-1)\n return res_num",
"test_imports": [],
"test_list": [
"assert catalan_number(10)==16796",
"assert catalan_number(9)==4862",
"assert catalan_number(7)==429"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 584,
"prompt": "Write a function to find the first adverb ending with ly and its positions in a given string.",
"code": "import re\ndef find_adverbs(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))",
"test_imports": [],
"test_list": [
"assert find_adverbs(\"Clearly, he has no excuse for such behavior.\") == '0-7: Clearly'",
"assert find_adverbs(\"Please handle the situation carefuly\") == '28-36: carefuly'",
"assert find_adverbs(\"Complete the task quickly\") == '18-25: quickly'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 585,
"prompt": "Write a function to find the n most expensive items in a given dataset.",
"code": "import heapq\ndef expensive_items(items,n):\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\n return expensive_items",
"test_imports": [],
"test_list": [
"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]",
"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}]",
"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 586,
"prompt": "Write a python function to split a list at the nth eelment and add the first part to the end.",
"code": "def split_Arr(l, n):\n return l[n:] + l[:n]",
"test_imports": [],
"test_list": [
"assert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10]",
"assert split_Arr([1,2,3,4],1) == [2,3,4,1]",
"assert split_Arr([0,1,2,3,4,5,6,7],3) == [3,4,5,6,7,0,1,2]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 587,
"prompt": "Write a function to convert a list to a tuple.",
"code": "def list_tuple(listx):\n tuplex = tuple(listx)\n return tuplex",
"test_imports": [],
"test_list": [
"assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)",
"assert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7)",
"assert list_tuple([58,44,56])==(58,44,56)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 588,
"prompt": "Write a python function to find the difference between largest and smallest value in a given list.",
"code": "def big_diff(nums):\n diff= max(nums)-min(nums)\n return diff",
"test_imports": [],
"test_list": [
"assert big_diff([1,2,3,4]) == 3",
"assert big_diff([4,5,12]) == 8",
"assert big_diff([9,2,3]) == 7"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 589,
"prompt": "Write a function to find perfect squares between two given numbers.",
"code": "def perfect_squares(a, b):\n lists=[]\n for i in range (a,b+1):\n j = 1;\n while j*j <= i:\n if j*j == i:\n lists.append(i) \n j = j+1\n i = i+1\n return lists",
"test_imports": [],
"test_list": [
"assert perfect_squares(1,30)==[1, 4, 9, 16, 25]",
"assert perfect_squares(50,100)==[64, 81, 100]",
"assert perfect_squares(100,200)==[100, 121, 144, 169, 196]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 590,
"prompt": "Write a function to convert polar coordinates to rectangular coordinates.",
"code": "import cmath\ndef polar_rect(x,y):\n cn = complex(x,y)\n cn=cmath.polar(cn)\n cn1 = cmath.rect(2, cmath.pi)\n return (cn,cn1)",
"test_imports": [],
"test_list": [
"assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))",
"assert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j))",
"assert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 591,
"prompt": "Write a python function to interchange the first and last elements in a list.",
"code": "def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList ",
"test_imports": [],
"test_list": [
"assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]",
"assert swap_List([1, 2, 3]) == [3, 2, 1]",
"assert swap_List([4, 5, 6]) == [6, 5, 4]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 592,
"prompt": "Write a python function to find the sum of the product of consecutive binomial co-efficients.",
"code": "def binomial_Coeff(n,k): \n C = [0] * (k + 1); \n C[0] = 1; # nC0 is 1 \n for i in range(1,n + 1): \n for j in range(min(i, k),0,-1): \n C[j] = C[j] + C[j - 1]; \n return C[k]; \ndef sum_Of_product(n): \n return binomial_Coeff(2 * n,n - 1); ",
"test_imports": [],
"test_list": [
"assert sum_Of_product(3) == 15",
"assert sum_Of_product(4) == 56",
"assert sum_Of_product(1) == 1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 593,
"prompt": "Write a function to remove leading zeroes from an ip address.",
"code": "import re\ndef removezero_ip(ip):\n string = re.sub('\\.[0]*', '.', ip)\n return string\n",
"test_imports": [],
"test_list": [
"assert removezero_ip(\"216.08.094.196\")==('216.8.94.196')",
"assert removezero_ip(\"12.01.024\")==('12.1.24')",
"assert removezero_ip(\"216.08.094.0196\")==('216.8.94.196')"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 594,
"prompt": "Write a function to find the difference of the first even and first odd number of a given list.",
"code": "def diff_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even-first_odd)",
"test_imports": [],
"test_list": [
"assert diff_even_odd([1,3,5,7,4,1,6,8])==3",
"assert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1",
"assert diff_even_odd([1,5,7,9,10])==9"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 595,
"prompt": "Write a python function to count minimum number of swaps required to convert one binary number represented as a string to another.",
"code": "def min_Swaps(str1,str2) : \n count = 0\n for i in range(len(str1)) : \n if str1[i] != str2[i] : \n count += 1\n if count % 2 == 0 : \n return (count // 2) \n else : \n return (\"Not Possible\") ",
"test_imports": [],
"test_list": [
"assert min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"111\",\"000\") == \"Not Possible\"",
"assert min_Swaps(\"111\",\"110\") == \"Not Possible\""
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 596,
"prompt": "Write a function to find the size in bytes of the given tuple.",
"code": "import sys \ndef tuple_size(tuple_list):\n return (sys.getsizeof(tuple_list)) ",
"test_imports": [],
"test_list": [
"assert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))",
"assert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == sys.getsizeof((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\"))",
"assert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == sys.getsizeof(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")))"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 597,
"prompt": "Write a function to find kth element from the given two sorted arrays.",
"code": "def find_kth(arr1, arr2, k):\n\tm = len(arr1)\n\tn = len(arr2)\n\tsorted1 = [0] * (m + n)\n\ti = 0\n\tj = 0\n\td = 0\n\twhile (i < m and j < n):\n\t\tif (arr1[i] < arr2[j]):\n\t\t\tsorted1[d] = arr1[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tsorted1[d] = arr2[j]\n\t\t\tj += 1\n\t\td += 1\n\twhile (i < m):\n\t\tsorted1[d] = arr1[i]\n\t\td += 1\n\t\ti += 1\n\twhile (j < n):\n\t\tsorted1[d] = arr2[j]\n\t\td += 1\n\t\tj += 1\n\treturn sorted1[k - 1]",
"test_imports": [],
"test_list": [
"assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6",
"assert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 7) == 256",
"assert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 6) == 8"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 598,
"prompt": "Write a function to check whether the given number is armstrong or not.",
"code": "def armstrong_number(number):\n sum = 0\n times = 0\n temp = number\n while temp > 0:\n times = times + 1\n temp = temp // 10\n temp = number\n while temp > 0:\n reminder = temp % 10\n sum = sum + (reminder ** times)\n temp //= 10\n if number == sum:\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert armstrong_number(153)==True",
"assert armstrong_number(259)==False",
"assert armstrong_number(4458)==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 599,
"prompt": "Write a function to find sum and average of first n natural numbers.",
"code": "def sum_average(number):\n total = 0\n for value in range(1, number + 1):\n total = total + value\n average = total / number\n return (total,average)",
"test_imports": [],
"test_list": [
"assert sum_average(10)==(55, 5.5)",
"assert sum_average(15)==(120, 8.0)",
"assert sum_average(20)==(210, 10.5)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 600,
"prompt": "Write a python function to check whether the given number is even or not.",
"code": "def is_Even(n) : \n if (n^1 == n+1) :\n return True; \n else :\n return False; ",
"test_imports": [],
"test_list": [
"assert is_Even(1) == False",
"assert is_Even(2) == True",
"assert is_Even(3) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 602,
"prompt": "Write a python function to find the first repeated character in a given string.",
"code": "def first_repeated_char(str1):\n for index,c in enumerate(str1):\n if str1[:index+1].count(c) > 1:\n return c",
"test_imports": [],
"test_list": [
"assert first_repeated_char(\"abcabc\") == \"a\"",
"assert first_repeated_char(\"abc\") == None",
"assert first_repeated_char(\"123123\") == \"1\""
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 603,
"prompt": "Write a function to get all lucid numbers smaller than or equal to a given integer.",
"code": "def get_ludic(n):\n\tludics = []\n\tfor i in range(1, n + 1):\n\t\tludics.append(i)\n\tindex = 1\n\twhile(index != len(ludics)):\n\t\tfirst_ludic = ludics[index]\n\t\tremove_index = index + first_ludic\n\t\twhile(remove_index < len(ludics)):\n\t\t\tludics.remove(ludics[remove_index])\n\t\t\tremove_index = remove_index + first_ludic - 1\n\t\tindex += 1\n\treturn ludics",
"test_imports": [],
"test_list": [
"assert get_ludic(10) == [1, 2, 3, 5, 7]",
"assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]",
"assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 604,
"prompt": "Write a function to reverse words seperated by spaces in a given string.",
"code": "def reverse_words(s):\n return ' '.join(reversed(s.split()))",
"test_imports": [],
"test_list": [
"assert reverse_words(\"python program\")==(\"program python\")",
"assert reverse_words(\"java language\")==(\"language java\")",
"assert reverse_words(\"indian man\")==(\"man indian\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 605,
"prompt": "Write a function to check if the given integer is a prime number.",
"code": "def prime_num(num):\n if num >=1:\n for i in range(2, num//2):\n if (num % i) == 0:\n return False\n else:\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert prime_num(13)==True",
"assert prime_num(7)==True",
"assert prime_num(-1010)==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 606,
"prompt": "Write a function to convert degrees to radians.",
"code": "import math\ndef radian_degree(degree):\n radian = degree*(math.pi/180)\n return radian",
"test_imports": [],
"test_list": [
"assert radian_degree(90)==1.5707963267948966",
"assert radian_degree(60)==1.0471975511965976",
"assert radian_degree(120)==2.0943951023931953"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 607,
"prompt": "Write a function to search a string for a regex pattern. The function should return the matching subtring, a start index and an end index.",
"code": "import re\n\ndef find_literals(text, pattern):\n match = re.search(pattern, text)\n s = match.start()\n e = match.end()\n return (match.re.pattern, s, e)",
"test_imports": [],
"test_list": [
"assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)",
"assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)",
"assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 608,
"prompt": "Write a python function to find nth bell number.",
"code": "def bell_Number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0] ",
"test_imports": [],
"test_list": [
"assert bell_Number(2) == 2",
"assert bell_Number(3) == 5",
"assert bell_Number(4) == 15"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 610,
"prompt": "Write a python function which takes a list and returns a list with the same elements, but the k'th element removed.",
"code": "def remove_kth_element(list1, L):\n return list1[:L-1] + list1[L:]",
"test_imports": [],
"test_list": [
"assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]",
"assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]",
"assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 611,
"prompt": "Write a function which given a matrix represented as a list of lists returns the max of the n'th column.",
"code": "def max_of_nth(test_list, N):\n res = max([sub[N] for sub in test_list])\n return (res) ",
"test_imports": [],
"test_list": [
"assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19",
"assert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10",
"assert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 612,
"prompt": "Write a python function which takes a list of lists, where each sublist has two elements, and returns a list of two lists where the first list has the first element of each sublist and the second one has the second.",
"code": "def merge(lst): \n return [list(ele) for ele in list(zip(*lst))] ",
"test_imports": [],
"test_list": [
"assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]",
"assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]",
"assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 614,
"prompt": "Write a function to find the cumulative sum of all the values that are present in the given tuple list.",
"code": "def cummulative_sum(test_list):\n res = sum(map(sum, test_list))\n return (res)",
"test_imports": [],
"test_list": [
"assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30",
"assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37",
"assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 615,
"prompt": "Write a function which takes a tuple of tuples and returns the average value for each tuple as a list.",
"code": "def average_tuple(nums):\n result = [sum(x) / len(x) for x in zip(*nums)]\n return result",
"test_imports": [],
"test_list": [
"assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]",
"assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]",
"assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 616,
"prompt": "Write a function which takes two tuples of the same length and performs the element wise modulo.",
"code": "def tuple_modulo(test_tup1, test_tup2):\n res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) \n return (res) ",
"test_imports": [],
"test_list": [
"assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)",
"assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)",
"assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 617,
"prompt": "Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.",
"code": "def min_Jumps(steps, d): \n (a, b) = steps\n temp = a \n a = min(a, b) \n b = max(temp, b) \n if (d >= b): \n return (d + b - 1) / b \n if (d == 0): \n return 0\n if (d == a): \n return 1\n else:\n return 2",
"test_imports": [],
"test_list": [
"assert min_Jumps((3,4),11)==3.5",
"assert min_Jumps((3,4),0)==0",
"assert min_Jumps((11,14),11)==1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 618,
"prompt": "Write a function to divide two lists element wise.",
"code": "def div_list(nums1,nums2):\n result = map(lambda x, y: x / y, nums1, nums2)\n return list(result)",
"test_imports": [],
"test_list": [
"assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]",
"assert div_list([3,2],[1,4])==[3.0, 0.5]",
"assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 619,
"prompt": "Write a function to move all the numbers to the end of the given string.",
"code": "def move_num(test_str):\n res = ''\n dig = ''\n for ele in test_str:\n if ele.isdigit():\n dig += ele\n else:\n res += ele\n res += dig\n return (res) ",
"test_imports": [],
"test_list": [
"assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'",
"assert move_num('Avengers124Assemble') == 'AvengersAssemble124'",
"assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 620,
"prompt": "Write a function to find the size of the largest subset of a list of numbers so that every pair is divisible.",
"code": "def largest_subset(a):\n\tn = len(a)\n\tdp = [0 for i in range(n)]\n\tdp[n - 1] = 1; \n\tfor i in range(n - 2, -1, -1):\n\t\tmxm = 0;\n\t\tfor j in range(i + 1, n):\n\t\t\tif a[j] % a[i] == 0 or a[i] % a[j] == 0:\n\t\t\t\tmxm = max(mxm, dp[j])\n\t\tdp[i] = 1 + mxm\n\treturn max(dp)",
"test_imports": [],
"test_list": [
"assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4",
"assert largest_subset([10, 5, 3, 15, 20]) == 3",
"assert largest_subset([18, 1, 3, 6, 13, 17]) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 622,
"prompt": "Write a function to find the median of two sorted lists of same size.",
"code": "def get_median(arr1, arr2, n):\n i = 0\n j = 0\n m1 = -1\n m2 = -1\n count = 0\n while count < n + 1:\n count += 1\n if i == n:\n m1 = m2\n m2 = arr2[0]\n break\n elif j == n:\n m1 = m2\n m2 = arr1[0]\n break\n if arr1[i] <= arr2[j]:\n m1 = m2\n m2 = arr1[i]\n i += 1\n else:\n m1 = m2\n m2 = arr2[j]\n j += 1\n return (m1 + m2)/2",
"test_imports": [],
"test_list": [
"assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0",
"assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5",
"assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 623,
"prompt": "Write a function to compute the n-th power of each number in a list.",
"code": "def nth_nums(nums,n):\n nth_nums = list(map(lambda x: x ** n, nums))\n return nth_nums",
"test_imports": [],
"test_list": [
"assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]",
"assert nth_nums([10,20,30],3)==([1000, 8000, 27000])",
"assert nth_nums([12,15],5)==([248832, 759375])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 624,
"prompt": "Write a python function to convert a given string to uppercase.",
"code": "def is_upper(string):\n return (string.upper())",
"test_imports": [],
"test_list": [
"assert is_upper(\"person\") ==\"PERSON\"",
"assert is_upper(\"final\") == \"FINAL\"",
"assert is_upper(\"Valid\") == \"VALID\""
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 625,
"prompt": "Write a python function to interchange the first and last element in a given list.",
"code": "def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList ",
"test_imports": [],
"test_list": [
"assert swap_List([1,2,3]) == [3,2,1]",
"assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]",
"assert swap_List([4,5,6]) == [6,5,4]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 626,
"prompt": "Write a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.",
"code": "def triangle_area(r) : \n if r < 0 : \n return None\n return r * r ",
"test_imports": [],
"test_list": [
"assert triangle_area(-1) == None",
"assert triangle_area(0) == 0",
"assert triangle_area(2) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 627,
"prompt": "Write a python function to find the smallest missing number from a sorted list of natural numbers.",
"code": "def find_First_Missing(array,start=0,end=None):\n if end is None:\n end = len(array) - 1 \n if (start > end): \n return end + 1\n if (start != array[start]): \n return start; \n mid = int((start + end) / 2) \n if (array[mid] == mid): \n return find_First_Missing(array,mid+1,end) \n return find_First_Missing(array,start,mid) ",
"test_imports": [],
"test_list": [
"assert find_First_Missing([0,1,2,3]) == 4",
"assert find_First_Missing([0,1,2,6,9]) == 3",
"assert find_First_Missing([2,3,5,8,9]) == 0"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 628,
"prompt": "Write a function to replace all spaces in the given string with '%20'.",
"code": "def replace_spaces(string):\n return string.replace(\" \", \"%20\")",
"test_imports": [],
"test_list": [
"assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'",
"assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'",
"assert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 629,
"prompt": "Write a python function to find even numbers from a list of numbers.",
"code": "def Split(list): \n return [num for num in list if num % 2 == 0]",
"test_imports": [],
"test_list": [
"assert Split([1,2,3,4,5]) == [2,4]",
"assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]",
"assert Split ([8,12,15,19]) == [8,12]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 630,
"prompt": "Write a function to extract all the adjacent coordinates of the given coordinate tuple.",
"code": "def adjac(ele, sub = []): \n if not ele: \n yield sub \n else: \n yield from [idx for j in range(ele[0] - 1, ele[0] + 2) \n for idx in adjac(ele[1:], sub + [j])] \ndef get_coordinates(test_tup):\n return list(adjac(test_tup))",
"test_imports": [],
"test_list": [
"assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]",
"assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]",
"assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 631,
"prompt": "Write a function to replace whitespaces with an underscore and vice versa in a given string.",
"code": "def replace_spaces(text):\n return \"\".join(\" \" if c == \"_\" else (\"_\" if c == \" \" else c) for c in text)",
"test_imports": [],
"test_list": [
"assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'",
"assert replace_spaces('The_Avengers') == 'The Avengers'",
"assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 632,
"prompt": "Write a python function to move all zeroes to the end of the given list.",
"code": "def move_zero(num_list):\n a = [0 for i in range(num_list.count(0))]\n x = [i for i in num_list if i != 0]\n return x + a",
"test_imports": [],
"test_list": [
"assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]",
"assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]",
"assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 633,
"prompt": "Write a python function to find the sum of xor of all pairs of numbers in the given list.",
"code": "def pair_xor_Sum(arr,n) : \n ans = 0 \n for i in range(0,n) : \n for j in range(i + 1,n) : \n ans = ans + (arr[i] ^ arr[j]) \n return ans ",
"test_imports": [],
"test_list": [
"assert pair_xor_Sum([5,9,7,6],4) == 47",
"assert pair_xor_Sum([7,3,5],3) == 12",
"assert pair_xor_Sum([7,3],2) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 635,
"prompt": "Write a function to sort the given list.",
"code": "import heapq as hq\ndef heap_sort(iterable):\n h = []\n for value in iterable:\n hq.heappush(h, value)\n return [hq.heappop(h) for i in range(len(h))]",
"test_imports": [],
"test_list": [
"assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]",
"assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 637,
"prompt": "Write a function to check whether the given amount has no profit and no loss",
"code": "def noprofit_noloss(actual_cost,sale_amount): \n if(sale_amount == actual_cost):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 638,
"prompt": "Write a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.",
"code": "import math\ndef wind_chill(v,t):\n windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\n return int(round(windchill, 0))",
"test_imports": [],
"test_list": [
"assert wind_chill(120,35)==40",
"assert wind_chill(40,20)==19",
"assert wind_chill(10,8)==6"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 639,
"prompt": "Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.",
"code": "def sample_nam(sample_names):\n sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))\n return len(''.join(sample_names))",
"test_imports": [],
"test_list": [
"assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16",
"assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10",
"assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 640,
"prompt": "Write a function to remove the parenthesis and what is inbetween them from a string.",
"code": "import re\ndef remove_parenthesis(items):\n for item in items:\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))",
"test_imports": [],
"test_list": [
"assert remove_parenthesis([\"python (chrome)\"])==(\"python\")",
"assert remove_parenthesis([\"string(.abc)\"])==(\"string\")",
"assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 641,
"prompt": "Write a function to find the nth nonagonal number.",
"code": "def is_nonagonal(n): \n\treturn int(n * (7 * n - 5) / 2) ",
"test_imports": [],
"test_list": [
"assert is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 643,
"prompt": "Write a function that checks if a strings contains 'z', except at the start and end of the word.",
"code": "import re\ndef text_match_wordz_middle(text):\n return bool(re.search(r'\\Bz\\B', text))",
"test_imports": [],
"test_list": [
"assert text_match_wordz_middle(\"pythonzabc.\")==True",
"assert text_match_wordz_middle(\"zxyabc.\")==False",
"assert text_match_wordz_middle(\" lang .\")==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 644,
"prompt": "Write a python function to reverse an array upto a given position.",
"code": "def reverse_Array_Upto_K(input, k): \n return (input[k-1::-1] + input[k:]) ",
"test_imports": [],
"test_list": [
"assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]",
"assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]",
"assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 720,
"prompt": "Write a function to add a dictionary to the tuple. The output should be a tuple.",
"code": "def add_dict_to_tuple(test_tup, test_dict):\n test_tup = list(test_tup)\n test_tup.append(test_dict)\n test_tup = tuple(test_tup)\n return (test_tup) ",
"test_imports": [],
"test_list": [
"assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})",
"assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})",
"assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 721,
"prompt": "Given a square matrix of size N*N given as a list of lists, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.",
"code": "def maxAverageOfPath(cost):\n N = len(cost)\n dp = [[0 for i in range(N + 1)] for j in range(N + 1)]\n dp[0][0] = cost[0][0]\n for i in range(1, N):\n dp[i][0] = dp[i - 1][0] + cost[i][0]\n for j in range(1, N):\n dp[0][j] = dp[0][j - 1] + cost[0][j]\n for i in range(1, N):\n for j in range(1, N):\n dp[i][j] = max(dp[i - 1][j],\n dp[i][j - 1]) + cost[i][j]\n return dp[N - 1][N - 1] / (2 * N - 1)",
"test_imports": [],
"test_list": [
"assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2",
"assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2",
"assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2",
"assert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 722,
"prompt": "The input is given as - a dictionary with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum.",
"code": "def filter_data(students,h,w):\n result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}\n return result ",
"test_imports": [],
"test_list": [
"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}",
"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}",
"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 723,
"prompt": "The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.",
"code": "from operator import eq\ndef count_same_pair(nums1, nums2):\n result = sum(map(eq, nums1, nums2))\n return result",
"test_imports": [],
"test_list": [
"assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4",
"assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11",
"assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1",
"assert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 724,
"prompt": "Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.",
"code": "def power_base_sum(base, power):\n return sum([int(i) for i in str(pow(base, power))])",
"test_imports": [],
"test_list": [
"assert power_base_sum(2,100)==115",
"assert power_base_sum(8,10)==37",
"assert power_base_sum(8,15)==62",
"assert power_base_sum(3,3)==9"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 725,
"prompt": "Write a function to extract values between quotation marks \" \" of the given string.",
"code": "import re\ndef extract_quotation(text1):\n return (re.findall(r'\"(.*?)\"', text1))",
"test_imports": [],
"test_list": [
"assert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']",
"assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']",
"assert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') == ['4k Ultra HD', 'HDR 10']",
"assert extract_quotation(\"Watch content '4k Ultra HD' resolution with 'HDR 10' Support\") == []"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 726,
"prompt": "Write a function that takes as input a tuple of numbers (t_1,...,t_{N+1}) and returns a tuple of length N where the i-th element of the tuple is equal to t_i * t_{i+1}.",
"code": "def multiply_elements(test_tup):\n res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\n return (res) ",
"test_imports": [],
"test_list": [
"assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)",
"assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)",
"assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)",
"assert multiply_elements((12,)) == ()"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 728,
"prompt": "Write a function takes as input two lists [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n].",
"code": "def sum_list(lst1,lst2):\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \n return res_list",
"test_imports": [],
"test_list": [
"assert sum_list([10,20,30],[15,25,35])==[25,45,65]",
"assert sum_list([1,2,3],[5,6,7])==[6,8,10]",
"assert sum_list([15,20,30],[15,45,75])==[30,65,105]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 730,
"prompt": "Write a function to remove consecutive duplicates of a given list.",
"code": "from itertools import groupby\ndef consecutive_duplicates(nums):\n return [key for key, group in groupby(nums)] ",
"test_imports": [],
"test_list": [
"assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]",
"assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]",
"assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']",
"assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 731,
"prompt": "Write a function to find the lateral surface area of a cone given radius r and the height h.",
"code": "import math\ndef lateralsurface_cone(r,h):\n l = math.sqrt(r * r + h * h)\n LSA = math.pi * r * l\n return LSA",
"test_imports": [],
"test_list": [
"assert lateralsurface_cone(5,12)==204.20352248333654",
"assert lateralsurface_cone(10,15)==566.3586699569488",
"assert lateralsurface_cone(19,17)==1521.8090132193388"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 732,
"prompt": "Write a function to replace all occurrences of spaces, commas, or dots with a colon.",
"code": "import re\ndef replace_specialchar(text):\n return (re.sub(\"[ ,.]\", \":\", text))\n",
"test_imports": [],
"test_list": [
"assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')",
"assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')",
"assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 733,
"prompt": "Write a function to find the index of the first occurrence of a given number in a sorted array.",
"code": "def find_first_occurrence(A, x):\n (left, right) = (0, len(A) - 1)\n result = -1\n while left <= right:\n mid = (left + right) // 2\n if x == A[mid]:\n result = mid\n right = mid - 1\n elif x < A[mid]:\n right = mid - 1\n else:\n left = mid + 1\n return result",
"test_imports": [],
"test_list": [
"assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1",
"assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2",
"assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 734,
"prompt": "Write a python function to find sum of products of all possible sublists of a given list. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subarrays/",
"code": "def sum_Of_Subarray_Prod(arr):\n ans = 0\n res = 0\n i = len(arr) - 1\n while (i >= 0):\n incr = arr[i]*(1 + res)\n ans += incr\n res = incr\n i -= 1\n return (ans)",
"test_imports": [],
"test_list": [
"assert sum_Of_Subarray_Prod([1,2,3]) == 20",
"assert sum_Of_Subarray_Prod([1,2]) == 5",
"assert sum_Of_Subarray_Prod([1,2,3,4]) == 84"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 735,
"prompt": "Write a python function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/",
"code": "def set_middle_bits(n): \n n |= n >> 1; \n n |= n >> 2; \n n |= n >> 4; \n n |= n >> 8; \n n |= n >> 16; \n return (n >> 1) ^ 1\ndef toggle_middle_bits(n): \n if (n == 1): \n return 1\n return n ^ set_middle_bits(n) ",
"test_imports": [],
"test_list": [
"assert toggle_middle_bits(9) == 15",
"assert toggle_middle_bits(10) == 12",
"assert toggle_middle_bits(11) == 13",
"assert toggle_middle_bits(0b1000001) == 0b1111111",
"assert toggle_middle_bits(0b1001101) == 0b1110011"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 736,
"prompt": "Write a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-24.php",
"code": "import bisect\ndef left_insertion(a, x):\n i = bisect.bisect_left(a, x)\n return i",
"test_imports": [],
"test_list": [
"assert left_insertion([1,2,4,5],6)==4",
"assert left_insertion([1,2,4,5],3)==2",
"assert left_insertion([1,2,4,5],7)==4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 737,
"prompt": "Write a function to check whether the given string is starting with a vowel or not using regex.",
"code": "import re \nregex = '^[aeiouAEIOU][A-Za-z0-9_]*'\ndef check_str(string): \n\treturn re.search(regex, string)",
"test_imports": [],
"test_list": [
"assert check_str(\"annie\")",
"assert not check_str(\"dawood\")",
"assert check_str(\"Else\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 738,
"prompt": "Write a function to calculate the geometric sum of n-1. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-recursion-exercise-9.php",
"code": "def geometric_sum(n):\n if n < 0:\n return 0\n else:\n return 1 / (pow(2, n)) + geometric_sum(n - 1)",
"test_imports": [],
"test_list": [
"assert geometric_sum(7) == 1.9921875",
"assert geometric_sum(4) == 1.9375",
"assert geometric_sum(8) == 1.99609375"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 739,
"prompt": "Write a python function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/",
"code": "import math \ndef find_Index(n): \n x = math.sqrt(2 * math.pow(10,(n - 1)))\n return round(x)",
"test_imports": [],
"test_list": [
"assert find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 740,
"prompt": "Write a function to convert the given tuple to a key-value dictionary using adjacent elements. https://www.geeksforgeeks.org/python-convert-tuple-to-adjacent-pair-dictionary/",
"code": "def tuple_to_dict(test_tup):\n res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\n return (res) ",
"test_imports": [],
"test_list": [
"assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}",
"assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}",
"assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 741,
"prompt": "Write a python function to check whether all the characters are same or not.",
"code": "def all_Characters_Same(s) :\n n = len(s)\n for i in range(1,n) :\n if s[i] != s[0] :\n return False\n return True",
"test_imports": [],
"test_list": [
"assert all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 742,
"prompt": "Write a function to caluclate the area of a tetrahedron.",
"code": "import math\ndef area_tetrahedron(side):\n area = math.sqrt(3)*(side*side)\n return area",
"test_imports": [],
"test_list": [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 743,
"prompt": "Write a function to rotate a given list by specified number of items to the right direction. https://www.geeksforgeeks.org/python-program-right-rotate-list-n/",
"code": "def rotate_right(list, m):\n result = list[-m:] + list[:-m]\n return result",
"test_imports": [],
"test_list": [
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]",
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]",
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 744,
"prompt": "Write a function to check if the given tuple has any none value or not.",
"code": "def check_none(test_tup):\n res = any(map(lambda ele: ele is None, test_tup))\n return res ",
"test_imports": [],
"test_list": [
"assert check_none((10, 4, 5, 6, None)) == True",
"assert check_none((7, 8, 9, 11, 14)) == False",
"assert check_none((1, 2, 3, 4, None)) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 745,
"prompt": "Write a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/python-exercises/lambda/python-lambda-exercise-24.php",
"code": "def divisible_by_digits(startnum, endnum):\n return [n for n in range(startnum, endnum+1) \\\n if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]",
"test_imports": [],
"test_list": [
"assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]",
"assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]",
"assert divisible_by_digits(20,25)==[22, 24]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 746,
"prompt": "Write a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees.",
"code": "import math\ndef sector_area(r,a):\n if a > 360:\n return None\n return (math.pi*r**2) * (a/360)",
"test_imports": [],
"test_list": [
"assert sector_area(4,45)==6.283185307179586",
"assert sector_area(9,45)==31.808625617596654",
"assert sector_area(9,361)==None"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 747,
"prompt": "Write a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/",
"code": "def lcs_of_three(X, Y, Z): \n m = len(X)\n n = len(Y)\n o = len(Z)\n L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)]\n for i in range(m+1): \n\t for j in range(n+1): \n\t\t for k in range(o+1): \n\t\t\t if (i == 0 or j == 0 or k == 0): \n\t\t\t\t L[i][j][k] = 0\n\t\t\t elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]): \n\t\t\t\t L[i][j][k] = L[i-1][j-1][k-1] + 1\n\t\t\t else: \n\t\t\t\t L[i][j][k] = max(max(L[i-1][j][k], L[i][j-1][k]), L[i][j][k-1]) \n return L[m][n][o]",
"test_imports": [],
"test_list": [
"assert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2",
"assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5",
"assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 748,
"prompt": "Write a function to put spaces between words starting with capital letters in a given string.",
"code": "import re\ndef capital_words_spaces(str1):\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)",
"test_imports": [],
"test_list": [
"assert capital_words_spaces(\"Python\") == 'Python'",
"assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'",
"assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 749,
"prompt": "Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/",
"code": "def sort_numeric_strings(nums_str):\n result = [int(x) for x in nums_str]\n result.sort()\n return result",
"test_imports": [],
"test_list": [
"assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]",
"assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]",
"assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 750,
"prompt": "Write a function to add the given tuple to the given list.",
"code": "def add_tuple(test_list, test_tup):\n test_list += test_tup\n return test_list",
"test_imports": [],
"test_list": [
"assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]",
"assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]",
"assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 751,
"prompt": "Write a function to check if the given array represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/",
"code": "def check_min_heap_helper(arr, i):\n if 2 * i + 2 > len(arr):\n return True\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap_helper(arr, 2 * i + 1)\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] \n and check_min_heap_helper(arr, 2 * i + 2))\n return left_child and right_child\n\ndef check_min_heap(arr):\n return check_min_heap_helper(arr, 0)",
"test_imports": [],
"test_list": [
"assert check_min_heap([1, 2, 3, 4, 5, 6]) == True",
"assert check_min_heap([2, 3, 4, 5, 10, 15]) == True",
"assert check_min_heap([2, 10, 4, 5, 3, 15]) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 752,
"prompt": "Write a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ...",
"code": "def jacobsthal_num(n): \n\tdp = [0] * (n + 1) \n\tdp[0] = 0\n\tdp[1] = 1\n\tfor i in range(2, n+1): \n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2] \n\treturn dp[n]",
"test_imports": [],
"test_list": [
"assert jacobsthal_num(5) == 11",
"assert jacobsthal_num(2) == 1",
"assert jacobsthal_num(4) == 5",
"assert jacobsthal_num(13) == 2731"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 753,
"prompt": "Write a function to find minimum k records from tuple list. https://www.geeksforgeeks.org/python-find-minimum-k-records-from-tuple-list/ - in this case a verbatim copy of test cases",
"code": "def min_k(test_list, K):\n res = sorted(test_list, key = lambda x: x[1])[:K]\n return (res) ",
"test_imports": [],
"test_list": [
"assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]",
"assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]",
"assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 754,
"prompt": "We say that an element is common for lists l1, l2, l3 if it appears in all three lists under the same index. Write a function to find common elements from three lists. The function should return a list.",
"code": "def extract_index_list(l1, l2, l3):\n result = []\n for m, n, o in zip(l1, l2, l3):\n if (m == n == o):\n result.append(m)\n return result",
"test_imports": [],
"test_list": [
"assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]",
"assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]",
"assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]",
"assert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 755,
"prompt": "Write a function to find the second smallest number in a list.",
"code": "def second_smallest(numbers):\n unique_numbers = list(set(numbers))\n unique_numbers.sort()\n if len(unique_numbers) < 2:\n return None\n else:\n return unique_numbers[1]",
"test_imports": [],
"test_list": [
"assert second_smallest([1, 2, -8, -2, 0, -2])==-2",
"assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5",
"assert second_smallest([2,2])==None",
"assert second_smallest([2,2,2])==None"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 756,
"prompt": "Write a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/python-exercises/re/python-re-exercise-3.php",
"code": "import re\ndef text_match_zero_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False",
"test_imports": [],
"test_list": [
"assert text_match_zero_one(\"ac\")==False",
"assert text_match_zero_one(\"dc\")==False",
"assert text_match_zero_one(\"abbbba\")==True",
"assert text_match_zero_one(\"dsabbbba\")==True",
"assert text_match_zero_one(\"asbbbba\")==False",
"assert text_match_zero_one(\"abaaa\")==True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 757,
"prompt": "Write a function to count the pairs of reverse strings in the given string list. https://www.geeksforgeeks.org/python-program-to-count-the-pairs-of-reverse-strings/",
"code": "def count_reverse_pairs(test_list):\n res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( \n\ttest_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) \n return res",
"test_imports": [],
"test_list": [
"assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== 2",
"assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == 1",
"assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 758,
"prompt": "Write a function to count lists within a list. The function should return a dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.",
"code": "def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result",
"test_imports": [],
"test_list": [
"assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}",
"assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}",
"assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}",
"assert unique_sublists([['john']])=={('john',): 1}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 759,
"prompt": "Write a function to check whether a given string is a decimal number with a precision of 2.",
"code": "def is_decimal(num):\n import re\n dnumre = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\n result = dnumre.search(num)\n return bool(result)",
"test_imports": [],
"test_list": [
"assert is_decimal('123.11')==True",
"assert is_decimal('e666.86')==False",
"assert is_decimal('3.124587')==False",
"assert is_decimal('1.11')==True",
"assert is_decimal('1.1.11')==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 760,
"prompt": "Write a python function to check whether a list of numbers contains only one distinct element or not.",
"code": "def unique_Element(arr):\n s = set(arr)\n return len(s) == 1",
"test_imports": [],
"test_list": [
"assert unique_Element([1,1,1]) == True",
"assert unique_Element([1,2,1,2]) == False",
"assert unique_Element([1,2,3,4,5]) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 762,
"prompt": "Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.",
"code": "def check_monthnumber_number(monthnum3):\n return monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11",
"test_imports": [],
"test_list": [
"assert check_monthnumber_number(6)==True",
"assert check_monthnumber_number(2)==False",
"assert check_monthnumber_number(12)==False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 763,
"prompt": "Write a python function to find the minimum difference between any two elements in a given array. https://www.geeksforgeeks.org/find-minimum-difference-pair/",
"code": "def find_min_diff(arr,n): \n arr = sorted(arr) \n diff = 10**20 \n for i in range(n-1): \n if arr[i+1] - arr[i] < diff: \n diff = arr[i+1] - arr[i] \n return diff ",
"test_imports": [],
"test_list": [
"assert find_min_diff((1,5,3,19,18,25),6) == 1",
"assert find_min_diff((4,3,2,6),4) == 1",
"assert find_min_diff((30,5,20,9),4) == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 764,
"prompt": "Write a python function to count number of digits in a given string.",
"code": "def number_ctr(str):\n number_ctr= 0\n for i in range(len(str)):\n if str[i] >= '0' and str[i] <= '9': number_ctr += 1 \n return number_ctr",
"test_imports": [],
"test_list": [
"assert number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') == 1",
"assert number_ctr('123') == 3",
"assert number_ctr('3wond-1ers2') == 3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 765,
"prompt": "Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/",
"code": "import math \ndef is_polite(n): \n\tn = n + 1\n\treturn (int)(n+(math.log((n + math.log(n, 2)), 2))) ",
"test_imports": [],
"test_list": [
"assert is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 766,
"prompt": "Write a function to return a list of all pairs of consecutive items in a given list.",
"code": "def pair_wise(l1):\n temp = []\n for i in range(len(l1) - 1):\n current_element, next_element = l1[i], l1[i + 1]\n x = (current_element, next_element)\n temp.append(x)\n return temp",
"test_imports": [],
"test_list": [
"assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]",
"assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]",
"assert pair_wise([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 10)]",
"assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 767,
"prompt": "Write a python function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a list of numbers and the sum,",
"code": "def get_pairs_count(arr, sum):\n count = 0 \n for i in range(len(arr)):\n for j in range(i + 1,len(arr)):\n if arr[i] + arr[j] == sum:\n count += 1\n return count",
"test_imports": [],
"test_list": [
"assert get_pairs_count([1,1,1,1],2) == 6",
"assert get_pairs_count([1,5,7,-1,5],6) == 3",
"assert get_pairs_count([1,-2,3],1) == 1",
"assert get_pairs_count([-1,-2,3],-3) == 1"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 769,
"prompt": "Write a python function to get the difference between two lists.",
"code": "def Diff(li1,li2):\n return list(set(li1)-set(li2)) + list(set(li2)-set(li1))\n ",
"test_imports": [],
"test_list": [
"assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]",
"assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]",
"assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 770,
"prompt": "Write a python function to find the sum of fourth power of first n odd natural numbers.",
"code": "def odd_num_sum(n) : \n j = 0\n sm = 0\n for i in range(1,n + 1) : \n j = (2*i-1) \n sm = sm + (j*j*j*j) \n return sm ",
"test_imports": [],
"test_list": [
"assert odd_num_sum(2) == 82",
"assert odd_num_sum(3) == 707",
"assert odd_num_sum(4) == 3108"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 771,
"prompt": "Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/",
"code": "from collections import deque\ndef check_expression(exp):\n if len(exp) & 1:\n return False\n stack = deque()\n for ch in exp:\n if ch == '(' or ch == '{' or ch == '[':\n stack.append(ch)\n if ch == ')' or ch == '}' or ch == ']':\n if not stack:\n return False\n top = stack.pop()\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\n return False\n return not stack",
"test_imports": [],
"test_list": [
"assert check_expression(\"{()}[{}]\") == True",
"assert check_expression(\"{()}[{]\") == False",
"assert check_expression(\"{()}[{}][]({})\") == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 772,
"prompt": "Write a function to remove all the words with k length in the given string.",
"code": "def remove_length(test_str, K):\n temp = test_str.split()\n res = [ele for ele in temp if len(ele) != K]\n res = ' '.join(res)\n return (res) ",
"test_imports": [],
"test_list": [
"assert remove_length('The person is most value tet', 3) == 'person is most value'",
"assert remove_length('If you told me about this ok', 4) == 'If you me about ok'",
"assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 773,
"prompt": "Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match.",
"code": "import re\ndef occurance_substring(text,pattern):\n for match in re.finditer(pattern, text):\n s = match.start()\n e = match.end()\n return (text[s:e], s, e)",
"test_imports": [],
"test_list": [
"assert occurance_substring('python programming, python language','python')==('python', 0, 6)",
"assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)",
"assert occurance_substring('python programming,programming language','language')==('language', 31, 39)",
"assert occurance_substring('c++ programming, c++ language','python')==None"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 775,
"prompt": "Write a python function to check whether every odd index contains odd numbers of a given list.",
"code": "def odd_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))",
"test_imports": [],
"test_list": [
"assert odd_position([2,1,4,3,6,7,6,3]) == True",
"assert odd_position([4,1,2]) == True",
"assert odd_position([1,2,3]) == False"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 776,
"prompt": "Write a function to count those characters which have vowels as their neighbors in the given string.",
"code": "def count_vowels(test_str):\n res = 0\n vow_list = ['a', 'e', 'i', 'o', 'u']\n for idx in range(1, len(test_str) - 1):\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\n res += 1\n if test_str[0] not in vow_list and test_str[1] in vow_list:\n res += 1\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\n res += 1\n return (res) ",
"test_imports": [],
"test_list": [
"assert count_vowels('bestinstareels') == 7",
"assert count_vowels('partofthejourneyistheend') == 12",
"assert count_vowels('amazonprime') == 5"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 777,
"prompt": "Write a python function to find the sum of non-repeated elements in a given list.",
"code": "def find_sum(arr): \n arr.sort() \n sum = arr[0] \n for i in range(len(arr)-1): \n if (arr[i] != arr[i+1]): \n sum = sum + arr[i+1] \n return sum",
"test_imports": [],
"test_list": [
"assert find_sum([1,2,3,1,1,4,5,6]) == 21",
"assert find_sum([1,10,9,4,2,10,10,45,4]) == 71",
"assert find_sum([12,10,9,45,2,10,10,45,10]) == 78"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 778,
"prompt": "Write a function to pack consecutive duplicates of a given list elements into sublists.",
"code": "from itertools import groupby\ndef pack_consecutive_duplicates(list1):\n return [list(group) for key, group in groupby(list1)]",
"test_imports": [],
"test_list": [
"assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]",
"assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]",
"assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 779,
"prompt": "Write a function to count the number of lists within a list. The function should return a dictionary, where every list is turned to a tuple, and the value of the tuple is the number of its occurrences.",
"code": "def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result",
"test_imports": [],
"test_list": [
"assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}",
"assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}",
"assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 780,
"prompt": "Write a function to find the combinations of sums with tuples in the given tuple list. https://www.geeksforgeeks.org/python-combinations-of-sum-with-tuples-in-tuple-list/",
"code": "from itertools import combinations \ndef find_combinations(test_list):\n res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\n return (res) ",
"test_imports": [],
"test_list": [
"assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]",
"assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]",
"assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 781,
"prompt": "Write a python function to check whether the count of divisors is even. https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php",
"code": "import math \ndef count_divisors(n) : \n count = 0\n for i in range(1, (int)(math.sqrt(n)) + 2) : \n if (n % i == 0) : \n if( n // i == i) : \n count = count + 1\n else : \n count = count + 2\n return count % 2 == 0",
"test_imports": [],
"test_list": [
"assert count_divisors(10)",
"assert not count_divisors(100)",
"assert count_divisors(125)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 782,
"prompt": "Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/",
"code": "def odd_length_sum(arr):\n Sum = 0\n l = len(arr)\n for i in range(l):\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\n return Sum",
"test_imports": [],
"test_list": [
"assert odd_length_sum([1,2,4]) == 14",
"assert odd_length_sum([1,2,1,2]) == 15",
"assert odd_length_sum([1,7]) == 8"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 783,
"prompt": "Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/",
"code": "def rgb_to_hsv(r, g, b):\n r, g, b = r/255.0, g/255.0, b/255.0\n mx = max(r, g, b)\n mn = min(r, g, b)\n df = mx-mn\n if mx == mn:\n h = 0\n elif mx == r:\n h = (60 * ((g-b)/df) + 360) % 360\n elif mx == g:\n h = (60 * ((b-r)/df) + 120) % 360\n elif mx == b:\n h = (60 * ((r-g)/df) + 240) % 360\n if mx == 0:\n s = 0\n else:\n s = (df/mx)*100\n v = mx*100\n return h, s, v",
"test_imports": [],
"test_list": [
"assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)",
"assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)",
"assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 784,
"prompt": "Write a function to find the product of first even and odd number of a given list.",
"code": "def mul_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even*first_odd)",
"test_imports": [],
"test_list": [
"assert mul_even_odd([1,3,5,7,4,1,6,8])==4",
"assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2",
"assert mul_even_odd([1,5,7,9,10])==10"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 785,
"prompt": "Write a function to convert tuple string to integer tuple.",
"code": "def tuple_str_int(test_str):\n res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\n return (res) ",
"test_imports": [],
"test_list": [
"assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)",
"assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)",
"assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)",
"assert tuple_str_int(\"(7, 81, 19)\") == (7, 81, 19)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 786,
"prompt": "Write a function to locate the right insertion point for a specified value in sorted order.",
"code": "import bisect\ndef right_insertion(a, x):\n return bisect.bisect_right(a, x)",
"test_imports": [],
"test_list": [
"assert right_insertion([1,2,4,5],6)==4",
"assert right_insertion([1,2,4,5],3)==2",
"assert right_insertion([1,2,4,5],7)==4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 787,
"prompt": "Write a function that matches a string that has an a followed by three 'b'.",
"code": "import re\ndef text_match_three(text):\n patterns = 'ab{3}?'\n return re.search(patterns, text)",
"test_imports": [],
"test_list": [
"assert not text_match_three(\"ac\")",
"assert not text_match_three(\"dc\")",
"assert text_match_three(\"abbbba\")",
"assert text_match_three(\"caacabbbba\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 788,
"prompt": "Write a function to create a new tuple from the given string and list.",
"code": "def new_tuple(test_list, test_str):\n return tuple(test_list + [test_str])",
"test_imports": [],
"test_list": [
"assert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')",
"assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')",
"assert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 790,
"prompt": "Write a python function to check whether every even index contains even numbers of a given list.",
"code": "def even_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))",
"test_imports": [],
"test_list": [
"assert even_position([3,2,1]) == False",
"assert even_position([1,2,3]) == False",
"assert even_position([2,1,4]) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 791,
"prompt": "Write a function to remove tuples from the given tuple.",
"code": "def remove_nested(test_tup):\n res = tuple()\n for count, ele in enumerate(test_tup):\n if not isinstance(ele, tuple):\n res = res + (ele, )\n return (res) ",
"test_imports": [],
"test_list": [
"assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)",
"assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)",
"assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)",
"assert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 792,
"prompt": "Write a python function to count the number of lists in a given number of lists.",
"code": "def count_list(input_list): \n return len(input_list)",
"test_imports": [],
"test_list": [
"assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4",
"assert count_list([[1,2],[2,3],[4,5]]) == 3",
"assert count_list([[1,0],[2,0]]) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 793,
"prompt": "Write a python function to find the last position of an element in a sorted array.",
"code": "def last(arr,x):\n n = len(arr)\n low = 0\n high = n - 1\n res = -1 \n while (low <= high):\n mid = (low + high) // 2 \n if arr[mid] > x:\n high = mid - 1\n elif arr[mid] < x:\n low = mid + 1\n else:\n res = mid\n low = mid + 1\n return res",
"test_imports": [],
"test_list": [
"assert last([1,2,3],1) == 0",
"assert last([1,1,1,2,3,4],1) == 2",
"assert last([2,3,2,3,6,8,9],3) == 3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 794,
"prompt": "Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.",
"code": "import re\ndef text_starta_endb(text):\n patterns = 'a.*?b$'\n return re.search(patterns, text)",
"test_imports": [],
"test_list": [
"assert text_starta_endb(\"aabbbb\")",
"assert not text_starta_endb(\"aabAbbbc\")",
"assert not text_starta_endb(\"accddbbjjj\")"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 796,
"prompt": "Write function to find the sum of all items in the given dictionary.",
"code": "def return_sum(dict):\n sum = 0\n for i in dict.values():\n sum = sum + i\n return sum",
"test_imports": [],
"test_list": [
"assert return_sum({'a': 100, 'b':200, 'c':300}) == 600",
"assert return_sum({'a': 25, 'b':18, 'c':45}) == 88",
"assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 797,
"prompt": "Write a python function to find the sum of all odd natural numbers within the range l and r.",
"code": "def sum_odd(n): \n terms = (n + 1)//2\n sum1 = terms * terms \n return sum1 \ndef sum_in_range(l,r): \n return sum_odd(r) - sum_odd(l - 1)",
"test_imports": [],
"test_list": [
"assert sum_in_range(2,5) == 8",
"assert sum_in_range(5,7) == 12",
"assert sum_in_range(7,13) == 40"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 798,
"prompt": "Write a python function to find the sum of an array.",
"code": "def _sum(arr): \n sum=0\n for i in arr: \n sum = sum + i \n return(sum) ",
"test_imports": [],
"test_list": [
"assert _sum([1, 2, 3]) == 6",
"assert _sum([15, 12, 13, 10]) == 50",
"assert _sum([0, 1, 2]) == 3"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 799,
"prompt": "Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.",
"code": "def left_rotate(n,d): \n INT_BITS = 32\n return (n << d)|(n >> (INT_BITS - d)) ",
"test_imports": [],
"test_list": [
"assert left_rotate(16,2) == 64",
"assert left_rotate(10,2) == 40",
"assert left_rotate(99,3) == 792",
"assert left_rotate(99,3) == 792",
"assert left_rotate(0b0001,3) == 0b1000",
"assert left_rotate(0b0101,3) == 0b101000",
"assert left_rotate(0b11101,3) == 0b11101000"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 800,
"prompt": "Write a function to remove all whitespaces from a string.",
"code": "import re\ndef remove_all_spaces(text):\n return (re.sub(r'\\s+', '',text))",
"test_imports": [],
"test_list": [
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces(' python program')=='pythonprogram'"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 801,
"prompt": "Write a python function to count the number of equal numbers from three given integers.",
"code": "def test_three_equal(x,y,z):\n result = set([x,y,z])\n if len(result)==3:\n return 0\n else:\n return 4-len(result)",
"test_imports": [],
"test_list": [
"assert test_three_equal(1,1,1) == 3",
"assert test_three_equal(-1,-2,-3) == 0",
"assert test_three_equal(1,2,2) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 802,
"prompt": "Write a python function to count the number of rotations required to generate a sorted array. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-array/",
"code": "def count_rotation(arr): \n for i in range (1,len(arr)): \n if (arr[i] < arr[i - 1]): \n return i \n return 0",
"test_imports": [],
"test_list": [
"assert count_rotation([3,2,1]) == 1",
"assert count_rotation([4,5,1,2,3]) == 2",
"assert count_rotation([7,8,9,1,2,3]) == 3",
"assert count_rotation([1,2,3]) == 0",
"assert count_rotation([1,3,2]) == 2"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 803,
"prompt": "Write a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/",
"code": "def is_perfect_square(n) :\n i = 1\n while (i * i<= n):\n if ((n % i == 0) and (n / i == i)):\n return True \n i = i + 1\n return False",
"test_imports": [],
"test_list": [
"assert not is_perfect_square(10)",
"assert is_perfect_square(36)",
"assert not is_perfect_square(14)",
"assert is_perfect_square(14*14)",
"assert not is_perfect_square(125)",
"assert is_perfect_square(125*125)"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 804,
"prompt": "Write a function to check whether the product of numbers in a list is even or not.",
"code": "def is_product_even(arr): \n for i in range(len(arr)): \n if (arr[i] & 1) == 0: \n return True\n return False",
"test_imports": [],
"test_list": [
"assert is_product_even([1,2,3])",
"assert is_product_even([1,2,1,4])",
"assert not is_product_even([1,1])"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 805,
"prompt": "Write a function that returns the list in a list of lists whose sum of elements is the highest.",
"code": "def max_sum_list(lists):\n return max(lists, key=sum)",
"test_imports": [],
"test_list": [
"assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12]",
"assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10]",
"assert max_sum_list([[2,3,1]])==[2,3,1]"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 806,
"prompt": "Write a function to find maximum run of uppercase characters in the given string.",
"code": "def max_run_uppercase(test_str):\n cnt = 0\n res = 0\n for idx in range(0, len(test_str)):\n if test_str[idx].isupper():\n cnt += 1\n else:\n res = cnt\n cnt = 0\n if test_str[len(test_str) - 1].isupper():\n res = cnt\n return (res)",
"test_imports": [],
"test_list": [
"assert max_run_uppercase('GeMKSForGERksISBESt') == 5",
"assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6",
"assert max_run_uppercase('GooGLEFluTTER') == 4"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 807,
"prompt": "Write a python function to find the first odd number in a given list of numbers.",
"code": "def first_odd(nums):\n first_odd = next((el for el in nums if el%2!=0),-1)\n return first_odd",
"test_imports": [],
"test_list": [
"assert first_odd([1,3,5]) == 1",
"assert first_odd([2,4,1,3]) == 1",
"assert first_odd ([8,9,1]) == 9"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 808,
"prompt": "Write a function to check if the given tuples contain the k or not.",
"code": "def check_K(test_tup, K):\n res = False\n for ele in test_tup:\n if ele == K:\n res = True\n break\n return res ",
"test_imports": [],
"test_list": [
"assert check_K((10, 4, 5, 6, 8), 6) == True",
"assert check_K((1, 2, 3, 4, 5, 6), 7) == False",
"assert check_K((7, 8, 9, 44, 11, 12), 11) == True"
]
},
{
"source_file": "Benchmark Questions Verification V2.ipynb",
"task_id": 809,
"prompt": "Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.",
"code": "def check_smaller(test_tup1, test_tup2):\n return all(x > y for x, y in zip(test_tup1, test_tup2))",
"test_imports": [],
"test_list": [
"assert check_smaller((1, 2, 3), (2, 3, 4)) == False",
"assert check_smaller((4, 5, 6), (3, 4, 5)) == True",
"assert check_smaller((11, 12, 13), (10, 11, 12)) == True"
]
}
]
|