Anime Screenshot Series – SKET Dance

Hello Everyone!

It’s been a long time now, right? Yeah.. The reason is that I had sone serious health issues and lost my password while I was at it.

I only have a couple of screenshots right now because I was in between my two computers. Enjoy what I have!

Onihime

Screen Shot 2018-04-04 at 11.14.02 PM

 

Image result for onihime sket dance

See you later ^_^

 

How to solve ‘removeDuplicateAdjacents’ in CodeFights

The Problem

Given a string s, recursively remove any adjacent duplicate characters that it contains.

Example

  • For s = "cooodefightssforrrcodee", the output should be
    removeDuplicateAdjacent(s) = "cdefightfocod".
  • For s = "acaaabbbacdddd", the output should be
    removeDuplicateAdjacent(s) = "acac".

Input/Output

  • [time limit] 4000ms (py)
  • [input] string s

    A string composed of lowercase English letters.

    Constraints:

    1 ≤ s.length ≤ 50.

  • [output] string

    A string obtained by removing all adjacent duplicates from the input string.

The Solution

asddasdasdas8.png

The Explanation

Continue reading “How to solve ‘removeDuplicateAdjacents’ in CodeFights”

CodeFights Problems

Stay tuned for more solution/explanations.

If you have a question you want to see the solution of, comment below so that I can help you!

Also, I figured out how to put actual code snippets with indentation and all, so, the newer ones will have the code as a text instead of an image.

How to solve “sumOfTwo” in CodeFights

The Problem:

You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.ExampleFor a = [1, 2, 3], b = [10, 20, 30, 40], and v = 42, the output should be
sumOfTwo(a, b, v) = true. Continue reading “How to solve “sumOfTwo” in CodeFights”

How to Solve ‘DifferentRightmostBit’ in CodeFights

The Problem

You’re given two integers, n and m. Find position of the rightmost bit in which they differ in their binary representations (it is guaranteed that such a bit exists), counting from right to left.

Return the value of 2position_of_the_found_bit (0-based).

Example

For n = 11 and m = 13, the output should be
differentRightmostBit(n, m) = 2.

1110 = 10112, 1310 = 11012, the rightmost bit in which they differ is the bit at position 1 (0-based) from the right in the binary representations.
So the answer is 21 = 2.

Input/Output

  • [time limit] 4000ms (py)
  • [input] integer nConstraints:
    0 ≤ n ≤ 230.
  • [input] integer mConstraints:
    0 ≤ m ≤ 230,
    n ≠ m.
  • [output] integer

Continue reading “How to Solve ‘DifferentRightmostBit’ in CodeFights”

A little Python!

The programming language one, not the snake one!

Hello pals!
Some time ago, I came across a problem in which I had to flatten an array of objects. That is, the elements of the array can be primitives or arrays. The end results is to be an array of primitives.

I used python to implement this since it allows much more compact snippets for such jobs.

Here is the code 🙂

def flatten(lst):
 return sum( ([x] if not isinstance(x, list) else flatten(x)
 for x in lst), [] )
 
lst = [[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]
print flatten(lst)

Continue reading “A little Python!”