## How do you convert bits into a different alphabet?

I have forgotten how to do this. How do I figure out what the requirements are for a 128-bit string using a certain alphabet?

That is to say, I want to generate a UUID (128-bit) value, using only the 10 numbers for the alphabet. How many numbers do I need, and what is the general equation so I can figure this out for any alphabet of any size?

What is the equation for any n-bit value with any x-letter alphabet?

The way I do it is to guess and slowly iterate until I arrive at a close number. For powers of 10 it’s easy:

Math.pow(2, 128) 3.402823669209385e+38 Math.pow(10, 39) 1e+39 

For other numbers, it takes a little more guessing. Would love to know the equation for this.

## How can I get 8 bits output from 4 bit CPU?

I am very new to Computer architecture. I am thinking to add one more output register to this 4 bit CPU as shown below. However, I am not sure should I connect the output register to the current CPU. Should I connect it just the same way as the current one and label the 2 output register as output A and output B? But if I connect it the same way, the input data from ALU to output registers will always be only 4 bits, how should I get 8 bits output from the two output registers?

## How do I calculate the required bits for a direct-mapped cache with 16KiB of data and four word blocks, assuming a 64-bit address?

This is the question I’m having trouble with all data provided,

## I can verify solutions to my problem in polynomial time, how would a non-deterministic algorithm arrive to a solution if it always takes $2^n$ bits?

Decision Problem: Given integers as inputs for $$K$$ and $$M$$. Is the sum of $$2^k$$ + $$M$$ a $$prime$$?

## Verifier

m = int(input('Enter integer for M: ')) sum_of_2**K+M=int(input('enter the sum of 2^k+m: '))  if AKS.sum_of_2**K+M == True:    # Powers of 2 can be verified in O(N) time   # make sure there is all 0-bits after the 1st ONE-bit      # Use difference to verify problem    if sum_of_2**K+M - (M) is a power_of_2:     OUTPUT Solution Verified 

The powers of 2 have approximately $$2^n$$ digits. Consider $$2^k$$ where $$K$$ = 100000. Compare the amount of digits in $$K$$ to the amount of digits in it’s solution! Also take note that the powers of 2 have $$2^n$$ bits as its 0-bit Unary essentially for the exponent $$n$$.

## Question

How would a non-deterministic machine solve this problem in polynomial time?

## Counting one’s in a stream of bits

I have to count the number of one’s in last $$m$$ bits in a stream of bits and $$m \leq n,$$ where $$n$$ is the window size and it should take polylogarithmic space in $$n$$. I could only store last $$n$$ bits and then count the number of one’s in those $$n$$ bits but it takes $$O(n)$$ space. How to achieve it in $$O(\log^k n)$$, $$k>0$$.
Any hint would be appreciated.

## Why NAT is a disadvantage when TCP source port field is 16 bits?

Here is an excerpt from Andrew S. Tanenbaum, Computer Networks, 5th edition, Chapter 5 (The Network layer), Page 455:

My question is on the second paragraph. From what I understand, basically this part talks disadvantage of using NAT(Network Address Translation). I don’t understand what second paragraph is trying to say about disadvantage of using NAT because it seems to me that the second paragraph is saying about benefit of using NAT because by using NAT, we can solve the problem of depletion of IP address.

Can anyone explain to me what the second paragraph is trying to convey?

## Novice question: Limiting number of combo attempts with Fail2ban and 128 bits of entropy

Apps such as Fail2ban and DenyHosts enable unix administrators to limit username/password combo attempts to typically 3 attempts. But why 3? Some admins enable more, like 6 or 8 giving honest users a little more slack when making different attempts at a password they may not recall exactly. But why not 18? Or even 30?

If a sophisticated cracker wanted to brute force a combo with a scheme involving 128 bits of entropy, s/he would need to make trillions of attempts a second. So if an admin limited the total number of attempts to 100 using Fail2ban, wouldn’t the authentication system still be secure and robust, as long as the admin sets up their username/password scheme to require 128 bits of entropy?

## Uniquely identifying bits

Query: Given $$m$$ unique integers smaller than $$2^n$$, can we keep at most $$k$$ the same bits of each number to uniquely identify them?

Is this problem NP-Hard?

For example, given the $$4$$ unique numbers smaller than $$2^3$$

011 100 101 110  ^^ 

The numbers are still unique if we remove the leftmost bit from each number. So for $$k = 2$$, the answer is yes: we keep bits {0, 1} (the rightmost bit is here defined as the bit with index 0).

I want to solve the above problem as a precomputation step for integers less than 20 bits, so for my application an exponential algorithms could be allowed. Then it would be great to minimize $$k$$ and then break ties in such a way that the number of gaps between the indices that are kept is minimized. For example, {0, 1, 2, 5, 7} has two gaps: between 2 and 5 and between 5 and 7. This precomputation should lead to a great hash function for a set of integers. In my application the sets of integers don’t change later.

## Encoding System that Assign Same Number of Bits for Each Character

I am trying to get a binary string that has been converted from text of a text file, I am able to get that but the problem is, I need each character to be represented by same number of bits, but that is not what I get (please see the below python code and corresponding output). For example, character i is represented by 1101001, which is 7 bits long, but character ! is represented by 100001, which is 6 bits long.

Is there any encoding/decoding system where each character takes same amount of bits?

content = open('a.txt', 'r').read() test_str = content # using join() + ord() + format()  ... Converting String to binary   Binary = ' '.join(format(ord(i), 'b') for i in test_str)  #Decimal=int(Binary, 2)    # printing original string   print("The original string is : " + str(test_str))  # printing result   print("The string after Binary conversion : \n" + str(Binary)) 

Output:

The original string is : Hi! Is there a solution? The string after Binary conversion :  1001000 1101001 100001 100000 1001001 1110011 100000 1110100 1101000 1100101 1110010 1100101 100000 1100001 100000 1110011 1101111 1101100 1110101 1110100 1101001 1101111 1101110 111111