# How to Solve ‘isMAC48Address’ in CodeFights

## The Problem:

A media access control address (MAC address) is a unique identifier assigned to network interfaces for communications on the physical network segment.

The standard (IEEE 802) format for printing MAC-48 addresses in human-friendly form is six groups of two hexadecimal digits (`0`

to `9`

or `A`

to `F`

), separated by hyphens (e.g. `01-23-45-67-89-AB`

).

Continue reading “How to Solve ‘isMAC48Address’ 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 `2`

(0-based).^{position_of_the_found_bit}

**Example**

For `n = 11`

and `m = 13`

, the output should be

`differentRightmostBit(n, m) = 2`

.

`11`

, _{10} = 10**1**1_{2}`13`

, the rightmost bit in which they differ is the bit at position _{10} = 11**0**1_{2}`1`

(0-based) from the right in the binary representations.

So the answer is `2`

.^{1} = 2

**Input/Output**

**[time limit] 4000ms (py)**

**[input] integer n***Constraints:*

`0 ≤ n ≤ 2`

.^{30}

**[input] integer m***Constraints:*

`0 ≤ m ≤ 2`

,^{30}

`n ≠ m.`

**[output] integer**

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

# How to Solve “secondRightmostZeroBit” in CodeFights

## The Problem:

Presented with the integer `n`

, find the 0-based position of the second rightmost zero bit in its binary representation (it is guaranteed that such a bit exists), counting from right to left.

Return the value of `2`

.^{position_of_the_found_bit}

**Example**

For `n = 37`

, the output should be

`secondRightmostZeroBit(n) = 8`

.

`37`

. The second rightmost zero bit is at position _{10} = 10**0**101_{2}`3`

(0-based) from the right in the binary representation of `n`

.

Thus, the answer is `2`

.^{3} = 8

**Input/Output**

**[time limit] 4000ms (py)**

**[input] integer n***Constraints:*

`4 ≤ n ≤ 2`

.^{30}**[output] integer**

Continue reading “How to Solve “secondRightmostZeroBit” in CodeFights”

# Interesting Image

Focus at the center of the image for a while and it disappears.

# CodeFights – Powers Of Two

Every positive integer can be uniquely represented as a sum of different positive powers of two.

Given a number n, return a sorted array of different powers of two that sum up to n.

Example

For n = 5, the output should be

powersOfTwo(n) = [1, 4].

Input/Output

[time limit] 4000ms (py)

[input] integer n

A positive integer.

Constraints:

5 ≤ n ≤ 6000.

[output] array.integer

An array of different powers of two, in ascending order.

Solution

def powersOfTwo(n): a=[] x=1 while n: if n&1: a.append(x) x*=2 n/=2 return a

# CodeFights

Given a string of lowercase English letters, find the length of its longest contiguous substring that doesn’t contain any character more than once.

# CodeFights – Search Algorithms Quiz Answers

Wiki Pages for Some Algorithms:

Boyer–Moore string search algorithm

1)What type of search algorithm is used in this representation?

Continue reading “CodeFights – Search Algorithms Quiz Answers”

# What’s normal?

# Anime Screenshot Series – Resurrection Efforts

Hi pals!

It’s been real long time since I did this.

Here are two screenshots from my computer. Tho, I have some in my phone, I am too lazy to reach to my phone now

First one is from Bakuon!! Continue reading “Anime Screenshot Series – Resurrection Efforts”

# 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)