development

Codility: Maxed Counters Problem

Problem You are given N counters, initially set to 0, and you have two possible operations on them: > – _increase(X)_ − counter X is increased by 1, > – _max counter_ − all counters are set to the maximum value of any counter. A non-empty array A of M integers is given. This array […]

Read more
development

Assertion failed: (!STR_EMBED_P(shared)), function str_new_frozen, file string.c, line 1075.

Solution If you workflow has Docker container, please stop the containers. Check with $docker ps and verify that all containers are in exited state. Set the right Ruby version. Find out from the project repo Makefile, build scripts. Update the bundler to same version as of Ruby. Reference https://bugs.ruby-lang.org/issues/11946 https://github.com/rbenv/rbenv https://philna.sh/blog/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv/

Read more
development

Python Cheatsheet: Part III

Lists my_list = [1,42,3,54,3,56,2] Delete an element # If you know the index del my_list[0] # Or you want to delete a slice del my_list[2:4] # if you want to delete the first occurrence my_list.remove(3) Concatenation >>> list1 = [34, 65] >>> list1 = list1 + [44, 77] >>> print(list1) [34, 65, 44, 77] Add […]

Read more
development

Python Cheatsheet: Part II

Strings Since strings are immutable, each function creates a new string as output. – index(‘pat’) # return ValueError if pat not exist – find(‘pat’) # index or -1 x = “junkstringjunk” print(x.strip(“junk”)) # o/p = string String Slicing x = ‘mytestdata’ start = 0 end = 2 # One more than the needed index step […]

Read more
development

Python Cheatsheet: Part I

Math Functions import math n = math.floor(1.5) m = math.ceil(1.5) k = abs(-19) Input string_data = input(‘Enter your data: ‘) print(type(string_data)) # String Formatting # 0 & 1 are index of the parameters text = “My planet is {0} in the {1}” print(text.format(‘Earth’, ‘galaxy’)) String text = “hello world! It’s lovely 2019” freq = text.count(‘lo’) […]

Read more