diff --git "a/6553.jsonl" "b/6553.jsonl" new file mode 100644--- /dev/null +++ "b/6553.jsonl" @@ -0,0 +1,624 @@ +{"seq_id":"457115308","text":"# Time: O(n)\n# Space: O(1)\n\n'''\nGiven a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0.\n\nExample 1:\n\nInput: [1,0,1,1,0]\nOutput: 4\nExplanation: Flip the first zero will get the the maximum number of consecutive 1s.\n After flipping, the maximum number of consecutive 1s is 4.\nNote:\n\nThe input array will only contain 0 and 1.\nThe length of input array is a positive integer and will not exceed 10,000\n'''\n\nclass Solution(object):\n def findMaxConsecutiveOnes(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n result, prev, curr = 0, 0, 0\n for n in nums:\n if n == 0:\n prev, curr = curr, 0\n else:\n curr += 1\n result = max(result, prev + curr + 1)\n return min(result, len(nums)) # for all 1 array edge case\n","sub_path":"Python/max-consecutive-ones-ii.py","file_name":"max-consecutive-ones-ii.py","file_ext":"py","file_size_in_byte":884,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"68"} +{"seq_id":"19700103","text":"import pandas as pd\nimport walter\nfrom walter import df_frame\n\"\"\"\ncolumns: 'time_stamp', 'action', 'product_credited', 'product_cred_quantity', 'product_cred_case?',\n'product_cred_unit_price', 'product_cred_total', 'debtor_name'\n\"\"\"\n#Study of credits given out\ncredit_df = df_frame[['time_stamp', 'action', 'product_credited', 'product_cred_quantity',\n 'product_cred_case?', 'product_cred_unit_price', 'product_cred_total',\n 'debtor_name']]\n\n#analyse the action column where the action is to give out credits\ncred_action = credit_df[credit_df['action'] == 'Ideni'].reset_index(0)\n\n#Change the dtype in total purchase from object to int\ncred_total_col = cred_action['product_cred_total']\ncred_total_col = pd.to_numeric(cred_total_col)\n\n#Get the total business credit on products\n#These are all credits that the business offered to its clients\ntotal_credits = cred_total_col.sum()\nprint('THE TOTAL BUSINESS CREDITS:{}RWF'.format(total_credits))\n","sub_path":"chezwalter/creditout.py","file_name":"creditout.py","file_ext":"py","file_size_in_byte":1004,"program_lang":"python","lang":"en","doc_type":"code","dataset":"code-starcoder2","pt":"68"} +{"seq_id":"529599552","text":"# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Sat Dec 23 13:39:39 2017\r\n\r\n@author: shiro\r\n\"\"\"\r\nimport re\r\nimport numpy as np\r\nimport csv\r\n\r\n'''\r\n functions where we preprocess the data so as to save them in a file corrected\r\n'''\r\ndef clean_str(string, tolower=True):\r\n \"\"\"\r\n Tokenization/string cleaning.\r\n Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py\r\n \"\"\"\r\n # Different regex parts for smiley faces\r\n happy =\t[':-\\)', ':\\)', '\\(:', '\\(-:' ] \r\n laugh =\t[':-d', ':d', 'x-d', 'xd', 'xd' ]\r\n love=\t['<3', ':\\*' ]\r\n wink = [';-\\)', ';\\)', ';-d', ';d', '\\(;', '\\(-;', ] \r\n sad = [':-\\(', ':\\(' , '\\):', '\\)-:', ':,\\(', ':\\'\\(', ':/', ':\"\\(', ':\\(\\(', 't.t', ':-\\|'] \r\n surprise = [':o']\r\n\r\n special = [\",\", \":\", \"\\\"\", \"=\", \"&\", \";\", \"%\", \"$\",\"@\", \"%\", \"^\", \"*\",\r\n \"(\", \")\", \"{\", \"}\", \"[\", \"]\", \"|\", \"/\", \"\\\\\", \">\", \"<\", \"-\",\r\n \"!\", \"?\", \".\", \"'\", \"--\", \"---\", \"#\"]\r\n if tolower:\r\n string = string.lower()\r\n # contraction\r\n string = re.sub(r\"!\", \" ! \", string)\r\n string = re.sub(r\"\\'s\", \" \\'s\", string)\r\n string = re.sub(r\"\\'ve\", \" \\'ve\", string)\r\n string = re.sub(r\"n\\'t\", \" n\\'t\", string)\r\n string = re.sub(r\"\\'re\", \" \\'re\", string)\r\n string = re.sub(r\"\\'d\", \" \\'d\", string)\r\n string = re.sub(r\"\\'ll\", \" \\'ll\", string)\r\n string = re.sub(r\",\", \" , \", string)\r\n string = re.sub(r\"\\n\", \"\", string)\r\n string = re.sub(' +',' ', string)\r\n # tweet\r\n string = re.sub(r'\\@[^\\s]+[\\s]?', \" \", string) # replace user @ by \r\n string = re.sub(r'\\#[^\\s]+[\\s]?', \"\", string) # remove hashtag\r\n string = re.sub(r\"\\$[\\d]+(\\.)?[\\d]*\", \"\", string) # float and int prince\r\n string = re.sub(r\"http.?://[^\\s]+[\\s]?\", \"\", string) # detect url\r\n string = re.sub(r\"[\\d]+:[\\d]+\", \"