Questions About 11011
Given a binary digit count of n, and a maximum consecutive occurrence count of m, find the number of different possible binary numbers. Also, the leftmost and rightmost bit must be 1.
For example n = 5, and m = 3.
The count is 7: 10001 10011 10101 10111 11001 11011 11101
Notice we excluded 11111 because too many consecutive 1's exist in it.
This was an interview question I had recently, and It has been bothering me. I don't want to brute force check each number for legitimacy because m can be > 32.
I have the bits 101 and 110. I want to compare using some bitwise operator ignoring the first bit like 01 and 10.
I have: 101 110 === 01 & 10 <- How I want to consider x00 <- The result I want
10110 11011 ===== 0110 & 1011 <- How I want to consider x0010 <- The result I want
How could I achieve this using bitwise operators in java?
- The first bit will always be 1.
- The other bits are variable. Both sides of the comparison will have the same number of bits.
- I want to detect just how to make the comparison considering the other bits and ignoring the first.
- I have 2 permission values. The first is 5/101 (The permission required) and the second is 6/110 (The permission the user has).
- Excluding the first block, which will always be 1, I want to compare the third block that represents a ce
I've got a FreeBSD 9.0 server. It has several jails, but they all have this same issue. They can not initiate connections to the outside world. They communicate with each other and the host fine.
firewall_enable="YES" # IPFW firewall_type="/etc/ipfw.rules" # Rule script for IPFW natd_enable="YES" # NAT for Internet Routing natd_interface="wan0" # NAT Card natd_flags="-f /etc/natd.conf -dynamic" # NAT Conf ifconfig_lo1_name="jail1" ifconfig_jail1="inet 192.168.1.101/32" jail_asdf_rootdir="/jails/asdf" jail_asdf_hostname="asdf.example.net" jail_asdf_ip="192.168.1.101" jail_asdf_devfs_enable="YES"
# XXX 00050 divert natd ip4 from any to any via wan0 add 00060 check-state # Allow me out add 00135
Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same?
As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let's say I get 3. I'll Take the first 3 characters of the first string and the remaining characters of the second string (so I'd have to slice both) and create a new string out of it.
Would this be more efficiently done by cutting the substrings or by representing it as a list ( [1, 1, 0, 1, 1] ) rather than a string?