Hi,
In a certain system we are left with only 6 bits, which can store a no. of range 0 to 63.
We want to store two numbers each ranging from 0 to 12, which will take 4 bits each.
Does anyone know of any algorithm that can store these two 4 bit number in optimized way together into 6 bits.
I initially thought of old Birth date trick: 1.Ask your friend to multiply the number of his month of birth by 5.
2.To this add 6.
3.Now,multiply by 4.
4.Add 9.
5.Multiply again by 5 and add to it his date of birth.
6.Ask him/her to subtract 165 from this and tell the answer.
The last two digits of this number will give you the date and the first 1 or 2 digit/s give the month. May be some combination of XOR/AND/OR operation can compress it into 6 bit.
Any weird working idea is welcome.
Thanks in advance.
6 1972
It can't be done....see Pidgeon Hole Principle
0-12 yield 13 possible values
and you need to store 2 which gives you 13*13 combinations or 169 unique combination which would need 7 bits.
Compression won't help, because some combinations are not compressible.
Use a map:
000000 == 0
000001 == 1
000010 == 2
000011 == 3
000100 == 4
001100 == 12
etc...
010000 == 0 //the other number
010001 == 1
etc...
011100 == 12
It looks like you can map 4 numbers between 0 and 12 into the 6 bits.
Use a map:
000000 == 0
000001 == 1
000010 == 2
000011 == 3
000100 == 4
001100 == 12
etc...
010000 == 0 //the other number
010001 == 1
etc...
011100 == 12
It looks like you can map 4 numbers between 0 and 12 into the 6 bits.
Nice try, but uh...No
He needs to store BOTH numbers not one or the other, for instance he might need to store the numbers 11 AND 12.
11 = 001011 and 12 = 001100, so how do i combine them unambiguously, so that when I am ready to extract I get 11 and 12 back?
As I've stated already, you can't.
Nice try, but uh...No
He needs to store BOTH numbers not one or the other, for instance he might need to store the numbers 11 AND 12.
11 = 001011 and 12 = 001100, so how do i combine them unambiguously, so that when I am ready to extract I get 11 and 12 back?
As I've stated already, you can't.
13*13 possibile pigeons in 6 bits == 64 pigeon holes; not much privacy for some
of them according to the Pigeon Hole Principle.
kind regards,
Jos
Nice try, but uh...No
He needs to store BOTH numbers not one or the other, for instance he might need to store the numbers 11 AND 12.
11 = 001011 and 12 = 001100, so how do i combine them unambiguously, so that when I am ready to extract I get 11 and 12 back?
Numbers in the range 0-12 need 4 bits. You use the the reamnining 2 bits as map keys:
001100 --> a 12
011100 --> another 12
111100 ---> yet another 12
101100 -- > even one more 12
Just write code that works with these 6 bits. What you really have here is a resgister of 4 numbers.
Nice try, but uh...No
He needs to store BOTH numbers not one or the other, for instance he might need to store the numbers 11 AND 12.
11 = 001011 and 12 = 001100, so how do i combine them unambiguously, so that when I am ready to extract I get 11 and 12 back?
My apologies to Darryl. The light just went on. Boy, do I feel sheepish.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: DJTB |
last post by:
zodb-dev@zope.org]
Hi,
I'm having problems storing large amounts of objects in a ZODB.
After committing changes to the database, elements are not cleared from
memory. Since the number of...
|
by: Andreas Suurkuusk |
last post by:
Hi,
I just noticed your post in the "C# memory problem: no end for our problem?"
thread.
In the post you implied that I do not how the garbage collector works and
that I mislead people. Since...
|
by: mosfets |
last post by:
Hi,
I'm having a little trouble figuring out the difference in terms of
memory allocation between:
class person_info;
class A {
private:
|
by: CptDondo |
last post by:
I am working on an embedded platform which has a block of battery-backed
RAM. I need to store various types of data in this block of memory -
for example, bitmapped data for control registers,...
|
by: Peter Olcott |
last post by:
What can anyone:
(1) Tell Me about
(2) Provide Links to
(3) Recommend Books
Pertaining to Memory Performance Optimization?
The main thing that I am looking for is rules-of-thumb
that maximize...
|
by: monika.saxena |
last post by:
Hi all,
In one of my projects which is a web based application in asp.net, a
third party tool - "Frontline Solver DLL" (It is an unmanaged DLL and
..NET is calling it using the PInvoke) is used....
|
by: Simon Johnson |
last post by:
Dear All,
I have decided to take the big plunge and drop the Microsoft platform
and use Mod_Python and Apache in it's place.
I've never used Linux before this project so it's a really big...
|
by: per9000 |
last post by:
Hi all,
I want to create an encryption program and started thinking about not
storing sensitive information in the memory since I guess someone
might steal my computer an scan my memory.
So I...
|
by: Lambda |
last post by:
I'm trying to develop several interesting components
of a simple search engine follow some text books.
A book introduces some ways to compress dictionary,
allow it to stay on main memory.
In...
|
by: cham |
last post by:
Hi,
I am working on c++ in a linux system ( Fedora core 4 ),
kernel version - 2.6.11-1.1369_FC4
gcc version - 4.0.0 20050519 ( Red Hat 4.0.0-8 )
In my code i am creating a vector to store...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |