Click here to Skip to main content
16,011,500 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: java or C# , which better? Pin
_Erik_11-Mar-11 2:38
_Erik_11-Mar-11 2:38 
AnswerRe: java or C# , which better? Pin
Alan Balkany11-Mar-11 4:46
Alan Balkany11-Mar-11 4:46 
AnswerRe: java or C# , which better? Pin
Luc Pattyn11-Mar-11 5:17
sitebuilderLuc Pattyn11-Mar-11 5:17 
GeneralRe: java or C# , which better? Pin
Anwar Isaed23-Mar-11 23:15
Anwar Isaed23-Mar-11 23:15 
GeneralRe: java or C# , which better? Pin
R. Erasmus24-Mar-11 21:18
R. Erasmus24-Mar-11 21:18 
AnswerRe: java or C# , which better? Pin
R. Erasmus24-Mar-11 21:16
R. Erasmus24-Mar-11 21:16 
Questioncompression Pin
khomeyni1-Mar-11 5:32
khomeyni1-Mar-11 5:32 
AnswerRe: compression Pin
Luc Pattyn1-Mar-11 6:03
sitebuilderLuc Pattyn1-Mar-11 6:03 
at the command level, use a ZIP utility, such as WinZip.

When programming an application, create a binary file. Assuming all digit values have same probability, you could:
- create a binary file with BinaryWriter class; it will be filled with ulong values;
- the first value to write would be the number of digits to be stored;
- then have a loop that reads 19 digits, turns them into a single ulong (use ulong.Parse or TryParse), and outputs that ulong in binary;
- when reaching the end of the input data, which probably did not have a length evenly divisible by 19, just imagine the few missing digits are all zero, and generate the last ulong as you did all the others.

That is it; you have turned N characters (probably bytes in an ASCII text file) into a sequence of N/19*8 bytes, giving a compression factor of 2.37

You could do better if something was known about the distribution of the digits; otherwise that is about the best you could get.

Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

GeneralRe: compression Pin
Bernhard Hiller2-Mar-11 3:14
Bernhard Hiller2-Mar-11 3:14 
AnswerRe: compression PinPopular
Luc Pattyn2-Mar-11 5:31
sitebuilderLuc Pattyn2-Mar-11 5:31 
GeneralRe: compression Pin
Bernhard Hiller2-Mar-11 22:49
Bernhard Hiller2-Mar-11 22:49 
AnswerRe: compression Pin
Luc Pattyn3-Mar-11 0:50
sitebuilderLuc Pattyn3-Mar-11 0:50 
QuestionBackup Algorithm Pin
Richard Andrew x6422-Feb-11 14:04
professionalRichard Andrew x6422-Feb-11 14:04 
AnswerRe: Backup Algorithm Pin
Richard MacCutchan22-Feb-11 23:12
mveRichard MacCutchan22-Feb-11 23:12 
QuestionRe: Backup Algorithm Pin
Tadeusz Westawic27-Feb-11 3:13
Tadeusz Westawic27-Feb-11 3:13 
AnswerRe: Backup Algorithm Pin
Richard Andrew x6427-Feb-11 6:20
professionalRichard Andrew x6427-Feb-11 6:20 
QuestionBasic Aging Algorithm for Insurance Premiums Pin
Brady Kelly18-Feb-11 6:18
Brady Kelly18-Feb-11 6:18 
AnswerRe: Basic Aging Algorithm for Insurance Premiums Pin
Roger Wright18-Feb-11 7:00
professionalRoger Wright18-Feb-11 7:00 
AnswerRe: Basic Aging Algorithm for Insurance Premiums Pin
Yusuf18-Feb-11 11:03
Yusuf18-Feb-11 11:03 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly18-Feb-11 21:43
Brady Kelly18-Feb-11 21:43 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
riced19-Feb-11 0:51
riced19-Feb-11 0:51 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly19-Feb-11 1:55
Brady Kelly19-Feb-11 1:55 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Yusuf19-Feb-11 2:05
Yusuf19-Feb-11 2:05 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Brady Kelly19-Feb-11 2:17
Brady Kelly19-Feb-11 2:17 
GeneralRe: Basic Aging Algorithm for Insurance Premiums Pin
Roger Wright19-Feb-11 4:35
professionalRoger Wright19-Feb-11 4:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.