How to write a Chain Adding Function in Python
The challenge
We want to create a function that will add numbers together when called in succession.
add(1)(2);
# returns 3
We also want to be able to …
Read Article →329 articles about python development, tools, and best practices
We want to create a function that will add numbers together when called in succession.
add(1)(2);
# returns 3
We also want to be able to …
Read Article →Create a function that takes a positive integer and returns the next bigger number that can be formed by rearranging its digits. For …
Read Article →As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to …
Read Article →You are given three piles of casino chips: white, green and black chips:
An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a …
Read Article →Write a function to find the longest common prefix string amongst an array of strings. This string manipulation challenge requires …
Read Article →he count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1 2. 11 3. 21 4. 1211 …Read Article →
Given a non-empty array of digits representing a non-negative integer, increment one to the integer. This challenge involves array …
Read Article →Given a non-empty array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have …
Read Article →You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image …
Read Article →Given two arrays, write a function to compute their intersection.
Example 1:
Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] …Read Article →
Given an array, rotate the array to the right by k steps, where k is non-negative.
Example 1:
Input: nums = [1,2,3,4,5,6,7], k = 3 …Read Article →
Python has a fantastic feature called slices. It allows you to work with a list, set or string by it’s index items.
E.g.:
string_sample = …
Read Article →
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input …
Read Article →Write a function:
def solution(A)
that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does …
Read Article →Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Find all the …
Read Article →Java has a built-in called HashMap. It allows you to store and very quickly retrieve key value pairs.
In Python, this is called a …
Read Article →In an N by N square grid, each cell is either empty (0) or blocked (1).
A clear path from top-left to bottom-right has length k if and …
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s …
Read Article →Say you have an array prices for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum …
Read Article →A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % …
Today I got a really dumb error from Python.
RuntimeError: thread.init() not called
But luckily it’s really easy to fix!
Below is the code …
Read Article →All dates in your server applications should be stored in the UTC timezone.
This is because you always want to store time without the offset of the …
Read Article →The requests module for Python is very useful in helping simplify HTTP/s requests from Python, but how would you use it in an AWS Lambda script? …