Sep 30, 2008

Qt got rebranded

Trolltech web site got a rebranding and there was also a Qt 4.4.3 release dedicated to the rebranding only.
Qt 4.4.3 is a rebranding-only release. In all other aspects, it is the
same release as Qt 4.4.2. It maintains both forward and backward
compatibility (source and binary) with Qt 4.4.2, 4.4.1 and 4.4.0.


In June 2008 Nokia acquired Trolltech ASA to enable the acceleration of their cross-platform software strategy for mobile devices and desktop applications, and to develop its Internet services business. On September 29, 2008 Nokia renamed Trolltech to Qt Software.

Jul 29, 2008

Google Code Jam 2008 - Alien Numbers

As many of your may know Google Code Jam 2008 has been recently launched.
I found some free time and decided to have a look at the tasks of this competition. Just out of curiosity... :)

Today's morning I solved the first task - "Alien Numbers".
The task is just for practice and has almost nothing to do with the real competition. I mean, it is a simple problem, but it was very interesting to solve it as fast as possible :)
Problem

The decimal numeral system is composed of ten digits, which we represent as "0123456789" (the digits in a system are written from lowest to highest). Imagine you have discovered an alien numeral system composed of some number of digits, which may or may not be the same as those used in decimal. For example, if the alien numeral system were represented as "oF8", then the numbers one through ten would be (F, 8, Fo, FF, F8, 8o, 8F, 88, Foo, FoF). We would like to be able to work with numbers in arbitrary alien systems. More generally, we want to be able to convert an arbitrary number that's written in one alien system into a second alien system.

Input

The first line of input gives the number of cases, N. N test cases follow. Each case is a line formatted as

alien_number source_language target_language

Each language will be represented by a list of its digits, ordered from lowest to highest value. No digit will be repeated in any representation, all digits in the alien number will be present in the source language, and the first digit of the alien number will not be the lowest valued digit of the source language (in other words, the alien numbers have no leading zeroes). Each digit will either be a number 0-9, an uppercase or lowercase letter, or one of the following symbols !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~

Output

For each test case, output one line containing "Case #x: " followed by the alien number translated from the source language to the target language.

Limits

1 ≤ N ≤ 100.

Small dataset

1 ≤ num digits in alien_number ≤ 4,
2 ≤ num digits in source_language ≤ 16,
2 ≤ num digits in target_language ≤ 16.

Large dataset

1 ≤ alien_number (in decimal) ≤ 1000000000,
2 ≤ num digits in source_language ≤ 94,
2 ≤ num digits in target_language ≤ 94.

Sample

Input
4
9 0123456789 oF8
Foo oF8 0123456789
13 0123456789abcdef 01
CODE O!CDE? A?JM!.

Output
Case #1: Foo
Case #2: 9
Case #3: 10011
Case #4: JAM!


The following is my solution in C++, be advised and don't blame me, there are many missing checks, I know that, and safety procedures. That is because I tried to solve this problems and get result as fast as possible. So, here you go with the solution I came up first.

#include <fstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

typedef vector<int> IntVect_t;

size_t to_num( const string &_base_set, const string &_val)
{
size_t NumRes(0);
size_t PositionPower(1);
string::const_reverse_iterator iter = _val.rbegin();
string::const_reverse_iterator iter_end = _val.rend();
for(; iter != iter_end; ++iter)
{
NumRes += _base_set.find(*iter) * PositionPower;
PositionPower *= _base_set.size();
}
return NumRes;
}

int main(int argc, const char* argv[])
{
ifstream f(argv[1]);
if( !f.is_open() )
return 1;

string outfile(argv[1]);
ofstream f_out( (outfile+".out").c_str() );

size_t nCase;
f >> nCase;
for(size_t i = 1; i <= nCase; ++i)
{
string _src;
string _dest;
string _to_convert;
f >> _to_convert >> _src >> _dest;

IntVect_t pos_dest;
size_t NumRes = to_num( _src, _to_convert );
for(; NumRes > _dest.size()-1;)
{
pos_dest.push_back( NumRes % _dest.size());
NumRes /= _dest.size();
}
pos_dest.push_back( NumRes );

f_out << "Case #"<< i <<": ";
IntVect_t::const_reverse_iterator iter = pos_dest.rbegin();
IntVect_t::const_reverse_iterator iter_end = pos_dest.rend();
for(; iter != iter_end; ++iter)
{
f_out << _dest[*iter];
}
f_out << endl;
}
return 0;
}

Jun 12, 2008

StatSVN 0.4.0

A new version of StatSVN has been released. See changes.
Download StatSvn 0.4.0.

 
New Features:

o Added support for an XML export of the main reports, just use option -xml,
based on patched proposed by Nilendra Weerasinghe. Thanks to Nilendra
Weerasinghe.
o Applied patch for [ 1639462 ] Added TRAC Support. Fixes 1639462. Thanks to
Jean-Francois Burdet.
o Applied patch to StatCVS to show the Head Revision (had to change it to
hide it for CVS as it does not make sense for CVS). Fixes 1932689. Thanks
to Martin Majlis.
o Performance enhancement. If SVN 1.4 is available, do one diff per revision
instead of one diff per file per revision. Added -force-legacy-diff option
to retain previous functionality.
o Applied patch to StatCVS to add Affected files count per commit. Thanks to
Martin Majlis.
o Applied patch to StatCVS to add Revision number on commit page. Fixes
1839303. Thanks to Martin Majlis.
o I have added a validation mechanism that checks the Repository object once
the log is parsed, if root is null, it will terminate the execution.
o I have added a small project attribute which makes it more obvious which
cache belongs to what project in the repositories.xml and xml cache files.
Fixes 1687928.
o Added support for tags-dir as a way to specify 'top' directory where the
tags are stored, defaulted to "/tags/". Fixes 1692245.
o Added support for a '-anonymize' command line option, to anonymize
committer names. Fixes 1743119.

Fixed bugs:

o Changed RSS to use the common one:
http://feeds.feedburner.com/ObjectlabOpenSourceNews

Changes:

o The RepoMap and LOCChurn reports have been promoted to StatCVS and hence,
removed from the StatSVN source tree.

May 21, 2008

stropts.h: No such file or directory

If during compilation your compiler complains about missing "stropts.h", don't wary. Most probably you are running on MacOS X 10.3 or FreeBSD 6.0 or NetBSD 3.0 or OpenBSD 3.8 or Cygwin or mingw or BeOS... or Fedora 9 (probably all modern Linux'es).

Simply to say, your system doesn't support STREAMS.

Linux espesially:
Linux doesn't support STREAMS (many years ago it was available as a third party module, but it hasn't worked for years). stropts.h is part of a POSIX XSR option, which Linux now, matching reality, says it is not supported.
and here we have the POSIX recommended check:

#include <unistd.h>
#if defined _XOPEN_STREAMS && _XOPEN_STREAMS == -1
/* XSR option is not available, headers, data types etc. may not be available. */
#endif
Hope it helps.