Best Python code snippet using Kiwi_python
tests.py
Source:tests.py  
...61        """Return a message with everyone in the TO, CC, and BCC."""62        message = MailgunMessage(self.bob, self.alice, "Test Subject", body_text="this is a test")63        message.add_to(self.frank)64        message.add_to(self.bob)65        message.add_cc(self.frank)66        message.add_cc(self.alice)67        message.add_cc(self.bob)68        message.add_bcc(self.bob)69        message.add_bcc(self.alice)70        message.add_bcc(self.frank)71        return message72    def test_address_map(self):73        message = self.get_sample_message()74        addresses = message._address_map('BUNK', [])75        self.assertEqual(addresses, {})76        exclude = []77        addresses = message._address_map('to', exclude)78        self.assertEqual(len(addresses), 3)79        self.assertEqual(self.alice_email, list(addresses.keys())[0], exclude)80        self.assertEqual(self.bob_email, list(addresses.keys())[2], exclude)81        exclude = [self.bob_email]82        addresses = message._address_map('to', exclude)83        self.assertEqual(len(addresses), 2)84        self.assertEqual(self.alice_email, list(addresses.keys())[0], exclude)85    def test_clean_data(self):86        message = self.get_sample_message()87        clean_data = message._clean_data()88        tos = clean_data['to']89        self.assertEqual(len(tos), 1)90        self.assertEqual(tos[0], self.alice)91        ccs = clean_data['cc']92        self.assertEqual(len(ccs), 0)93        bccs = clean_data['bcc']94        self.assertEqual(len(bccs), 1)95        self.assertEqual(bccs[0], self.frank)96    def test_cc(self):97        # Construct a message with the FROM and TO in the CC98        frm = "from@example.com"99        to = "to@example.com"100        cc = "cc@example.com"101        message = MailgunMessage(frm, to, "Test Subject", body_text="this is a test")102        message.add_cc(frm)103        message.add_cc(to)104        message.add_cc(cc)105        # Make sure the FROM and TO got stripped out of the CC106        cc_list = message.get_mailgun_data()["cc"]107        self.assertEqual(1, len(cc_list))108        self.assertTrue(cc in cc_list)109        self.assertFalse(to in cc_list)110        self.assertFalse(frm in cc_list)111    def test_bcc(self):112        # Construct a message with the FROM and TO in the BCC113        frm = "from@example.com"114        to = "to@example.com"115        bcc = "bcc@example.com"116        message = MailgunMessage(frm, to, "Test Subject", body_text="this is a test")117        message.add_bcc(frm)118        message.add_bcc(to)119        message.add_bcc(bcc)120        # Make sure the FROM and TO got stripped out of the BCC121        bcc_list = message.get_mailgun_data()["bcc"]122        self.assertEqual(1, len(bcc_list))123        self.assertTrue(bcc in bcc_list)124        self.assertFalse(to in bcc_list)125        self.assertFalse(frm in bcc_list)126    def test_multiple_to(self):127        # Construct a message with the FROM and another email are in TO128        frm = "from@example.com"129        to = "to@example.com"130        to2 = "to2@example.com"131        cc = "cc@example.com"132        bcc = "bcc@example.com"133        message = MailgunMessage(frm, to, "Test Subject", body_text="this is a test")134        message.add_to(frm)135        message.add_to(to2)136        message.add_cc(cc)137        message.add_bcc(bcc)138        # Make sure CC and BCC didn't get removed139        mailgun_data = message.get_mailgun_data()140        self.assertEqual(1, len(mailgun_data["cc"]))141        self.assertTrue(cc in mailgun_data["cc"])142        self.assertEqual(1, len(mailgun_data["bcc"]))143        self.assertTrue(bcc in mailgun_data["bcc"])144        # Make sure TO, TO2 is in TO and FROM is not145        self.assertEqual(2, len(mailgun_data["to"]))146        self.assertTrue(to in mailgun_data["to"])147        self.assertTrue(to2 in mailgun_data["to"])148        self.assertFalse(frm in mailgun_data["to"])...solution-prabowo.py
Source:solution-prabowo.py  
...3def add_edge(u, l, r):4    if r < l:5        return6    ls.append((u + 1, l + 1, r + 1))7def add_cc(K, N):8    k, n = 0, 09    while (n + 1) * (n * (n - 1) * (n - 2) // 6) <= K:10        add_edge(N + n, N, N + n - 1)11        n += 112    k = n * (n - 1) * (n - 2) * (n - 3) // 613    14    for i in range(n, 0, -1):15        while k + i * (i - 1) * (i - 2) // 6 + i * (n - 1) * (n - 2) // 2 <= K:16            add_edge(N + n, N, N + i - 1)17            k += i * (i - 1) * (i - 2) // 6 + i * (n - 1) * (n - 2) // 218            n += 119    return k, n20N = 021while K > 0:22    k, n = add_cc(K, N)23    K -= k24    N += n25print(len(ls))26for row in ls:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
