Posts

Defeated by Ugly Numbers

Now I am out of Code Jam 2008. Though I did the Text Messaging Outrage quite easily I've bet my solution to the use of the 'bc' command as a helper in Ugly Numbers for computing strings like "12123+324234+232342-234234". For these numbers it does not seem to be any need, but to be able to solve the large data set of the same problem arbitrary (or at least 40 digits) precision was a requirement. 'bc' can work with these, but unfortunately the computing speed I've got was not up to the task. I was piping each line to 'bc' and reading the proper answer. Unfortunately it took more than half an hour on my laptop to finish calculation. I run out of time and I failed both small and large datasets. Later on, once the contest was over and the problems were in practice mode I uploaded my solution file for the small problem and it was Correct! (too late). Still my routing for checking ugly numbers was only dealing with Java longs (n Now I've changed...

My laptop's Gutsy meets vodafone

Sunday morning I'd like to be able to join CodeJam round 1. But I'm attending a wedding out of town. I asked for some help and I've borrowed a Huawi e220 UTMS modem from my university. Just pluging it in did not do the trick though. Ubuntu showed a CD-ROM-like icon on my desktop that contained the device's Windows drivers. I was told to do some dark magic that did the trick for Spanish Vodafone prepaid service: umount /dev/sr0 rmmod usb-storage rmmod usbserial modprobe usbserial vendor=0x12d1 product=0x1003 #now disconnect the modem and reconnect it again #wait a few seconds ls -la /dev/ttyUSB* # three devices should show up # now fire wvdial I've created this wvdial.conf file: [Dialer Defaults] Init2 = ATZ Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Stupid Mode = 1 Modem Type = Analog Modem ISDN = 0 Phone = *99***1# Modem = /dev/ttyUSB0 Username = user Dial Command = ATDT Password = pass Baud = 460800 Init4 = AT+CGDCONT=1,"IP","ac.vodafone.es...

CodeJam Qualification Round

It took place yesterday. It was made of three interesting problems. Not too difficult I would say, but 24h were not long enough for me to finish on time. I did the first too problems: Saving the world and Train Timetable, but I failed the third one: Fly Swatter (I chose Montecarlo approach and I did not get accurate enough results). I think being familiar with the contest site helped and every time the site was responsive. Being behind of several thousands of more talented guys is good to keep you humble. I loved the mental exercise and it felt great every time you get a Correct! answer. Still this morning I've been discussing with my colleagues how to get the Fly Swatter right and I have an idea to test, that hopefully will work: Calculate the area of the openings but modifying the value of g so now g is min(0,g-f) . One minus the quotient of this area and the circle area should be the answer to the problem (or so I think till I test it).

Arduino talk

Image
I am giving a talk at an Arduino workshop next Saturday 17:00. There is no attendance fee and people will be able to try their own code on the available Arduinos. Contact was made through the Arduino Forum and Vicent Ferrer proved to be quite an entrepreneurial person. Presentation will be held in Spanish and hopefully it will include a lot of Q&A and user experimentation. If you bring your own laptop you will be sure you'll get the development environment installed.

Photoshop degrees

We have some international programs at our university. Besides European students, many students from Spanish-speaking countries from South America are attending too. I am sure there is a good amount of paperwork (yes, in the paperless era it is when paper usage is skyrocketing) to go through the admission process. The twist is that now some people are thinking this international programs can be used as an excuse to get a visa to enter the country. Some doctored documents are sent in the hope they will go undetected, but while the Photoshop work is good, the background checks on the side of the fraudsters are not: They have created fake titles of real world universities, but they have selected degrees that have never been taught at those universities. You know that the Euro currency is now used in many (but not all) European countries (Denmark, Sweden and Norway come to my mind now) but if you are handed over an Euro from, let's say, Brazil, you are sure it is forged note. Fraudster...

New tricks to an old dog

Image
Some time ago I developed a small project that put together a few software pieces to create a monitoring system. I've used for development a great graphics library built in PHP called JpGraph . It did the work but I realized that the software license required payment of $600 for each website that use it commercially. As my system was like an Internet appliance and each customer had a different unit (and address) it seemed that I would need to add $600 to the price tag of the system to be compliant with JpGraph license. It was time to look for an alternative, as there was no way the product price could support that extra cost. So I found libchart library that worked nicely with PHP5 (provided you already have GD support built-in). The end result looks ok too, though libchart lacks many of the features of JpGraph, it is still good enough for my application. Libchart author licenses the software with GPL3 and while the software is free, he's accepting donations.

Shopping list problem

Image
Definitely this has been the most challenging problem I've found on the Code Jam practice site. It asks you to determine the optimal selection of what to buy where. With a couple of twists: the cost of going from one place to another is factored in; plus a rule that forces you to drive back home whenever you're buying perishable goods. The approach that worked for me was to first consider the different combinations of articles from different shops, just to obtain the list of shops to visit for each instance. Each one of list of shops to visit is a traveling salesman problem (perishable rule just changes the cost of some of the links). Combine both costs, the article's prices at selected shops and the transportation costs to determine how much each realization will amount. The minimum case is the answer you're looking for. The main problem I faced with the large set is that unless the code is quite efficient (and mine was not) it will take a long long time to finish the...

Google Code Jam '08

Image
I've just got a notice about the new edition of Google Code Jam . I guess if you like challenges it is a place to go. I've spent part of the evening solving the "Alien Numbers" problem just to discover how rusted I am. It was fun though, and it was satisfying to make it right (though not very fast I would say).

Single data packet TCP

Image
For Ethernet enabled devices I've used in the past (and I was happy with) the cores from Rabbit Semiconductor. They offer a lot of data and program memory and a royalty-free TCP/IP stack. Not in the same league but still surprisingly useful is the Ethernet shield I've bought from Nuelectronics (a UK-based company). The shield plugs-in nicely on an Arduino board and it can easily allow you to create a simple network appliance. In the picture I have my sample system that using a DS18B20 digital temperature sensor offers the temperature reading as a web page. All the code used is the sample code and TCP/IP library provided by Nuelectronics. I had some minor trouble with my setup as I am using the so-called parasitic power on the temperature sensor and a few lines of code where added to the original code to make it work. The symptom of the problem is that I was getting +85.00 C no matter what the temperature was. The cause was that the sensor did not get enough power from the 1...

Kudos to Canon

Image
I dumped my old Epson color printer, an Epson Stylus Photo Color 830, after playing any trick to get a decent printing performance for quite a while (I failed). As we needed a new printer at home I searched and browsed around and I settled with Canon's IP4300 that also had good Linux support. Unfortunately that model was no longer available (I learned this at the computer shop) so it was not an option. I guessed the next model, Canon's IP4500 won't be that different. It was cool as it could do duplex printing automatically. I was wrong: While the printer worked like a charm ("New" is the best printer brand!) I was disappointed to discover there was not Linux driver. And when I tried the IP4300's driver it did not work at all. Time to go to the Ubuntu forums: There I was referred to a Canon's portal . In there I downloaded and install a couple of .deb files and next I restarted cups. I connected the printer's USB cable to my computer and it was automagi...

Another format for arduino

Image
I've just bought another arduino board for a project. My main complaint with arduino standard board is that it is not prototype board friendly. I am afraid this was a 'feature' and not an error: This way people would have to buy special prototype boards for arduino. This was a design error that later on has survived to maintain compatibility with existing shields (thanks for shedding some light on this, David) There are other solutions like Modern Device BBB, but the new iDuino does include the USB adapter that may power and interface to a PC your project. And iDuino kit costs less than $18 so it seems quite cost effective. The main con is that the kit includes a resonator instead of crystal. I haven't used it yet but it seems another development to have a look at. If you plan to buy one I think you better use Fundamental Logic website instead of eBay.

Dead router

Image
Yesterday night my router died on me. Apparently it is no longer coming up after powering it up. Minutes later it seemed that a hardware reset had brought it back to life: It was not true, while DHCP and router lights were working, only a firmware reload web page was available. After downloading several versions of firmware it became apparent that the damage to the router was beyond the original firmware. Time to buy a new one (or to check with SMC whether a lifetime warranty was included). However, hours later I came across this news . I know it may sound a bit paranoid on my side but timing was just perfect. While I wait the new unit to be delivered, I've borrowed an ASUS WL-500G from the lab. I've been told this unit has a lot of potential once you reflash it with new firmware. A couple of cool projects are possible: OpenWRT or DD-WRT .

Awesome web service

I was browsing this photography blog when I learned about a cool and very useful service . The image below describes better than I would do it what it is about. In the past I featured a similar service but I've found this new service better. Assignment #4 - Get more documents Please note I throw at it the first document I've found on my desktop. It seems to handle many different type of popular office files. I think I'll be using this system for my students in the future. In order not to change my site CSS code I've shrunk the width of the embedded object a bit too much :-( You may use the link on the left bottom side of the image to go to the home page of the document where it will be shown full width.

More on RGB LEDs

I was thinking about controlling multiple color LEDs to make an elaborate panel with different light areas that can be contolled remotely from a laptop. As each LED needs three PWM outputs and many microcontrollers have just a few of them (I mean PWM outputs) the use of a microcontroller per LED makes sense. It did for this project . I've just changed the LED type for a Superflux RGB LED to get what you can see in the video. The next step is to make a version that can be addressed (also available from the same site) so as each LED can be commanded to show a certain color. (One PIC 12F675 plus a Superflux LED cost less than $2!). I'll be using an Arduino board with an XBee wireless module to control a bunch of leds. Alternatively I could use a Wi-port to control the panel via wifi.

Adobe's Lightroom

Image
A friend of mine brought to my attention this great software tool from Adobe. There is a new version 2 on development and I've tried both 1.3 and 2.0 beta. One of the reasons I've bought a Digital SLR camera was to be able to shot in RAW mode. Doing so gives you more choice in terms of development options than shooting JPEG. Lightroom software allows you to give a similar treatment to your photos, no matter your shoot RAW or JPEG. The software main aim is to help you make your good photos great. You may wonder why don't you just use Photoshop or GIMP instead. These other tools are just not designed to help you do that easily. However Lightroom has a simple but yet very powerful interface with an astonishing fast calculation that make it very pleasant to use. You can always easily compare the "Before" and "After" pictures. You can get a trial version from Adobe website so you may try by yourself.

Running circles with Ipod Touch

Image
I've recently bought one iPod Touch 16GB for my wife. A few days later I bought another one for my youngest kid (a clear case of iPod envy). I was quite dissapointed when I've learned that the Touch did not support enterprise WPA nor it does include a VPN client. This renders it useless for any serious network use (so I'm not buying one for me till this is corrected). After the initial excitement my kid was kind of bored with the lack of new applications for his iPod Touch so he asked me to do something about it. I was not eager to get into that fight, but I was told that Ziphone was a safe bet to install an application installer on the iPod Touch so new applications can be installed. They even claimed on their website that even a caveman can do it with Ziphone. So I decided to give it a go.  I dowloaded the application to our iMac and selected Jailbreak. A few messages indicated that files were copied to the Touch and a message told me to wait 1'10''. Nothing ...

Cool OCR software

Image
I'm trying out new tools all the time. Many times this action is triggered by the need of doing something new, better and faster. Some days ago I needed to get the text of some book pages typed in at the computer. Old fashion was is likely faster but not very exciting (it was not much more than a thousand words). However I do like challenges. First stop was to use my old Acer S2W 3300U Scanner . It is working nicely with Ubuntu (well, it was last time I used with Feisty, but now with Gutsy it was not working). The trouble with this in Linux scanner is that, although it works nicely, it uses proprietary firmware that cannot be included in Linux distributions. That means every time you update your Linux distribution you need to copy the new firmware (and to add the proper line to /etc/sane.d/snapscan.conf file). Once the first problem was fixed I tried to OCR the scanned page: It did not work. I needed to install gocr (that unfortunately was not installed by default). Not a big prob...

rdesktop missunderstanding

Image
Every now and then I need to use Windows-only software for a project. I try to avoid it as much as I can but sometimes there is not other way. Over the years I've tried different approaches with mixed success: Dual-boot machine. A virtual machine running the second OS (i.e: using VMware ). Running Windows applications over Wine or even better CrossOver Office . Recently I tried a new approach (not that I claim it is any type of innovation though) which is the use of a Windows 2003 server and Terminal Services. This way you can connect a remote terminal over the network. This is similar to Windows XP remote desktop but multiuser. While you can use a thin-client to access your new desktop I am using rdesktop client software. It is very responsive even over the Internet and it allows you to share folders with the remote desktop. This way you can exchange files securely and easily. The feature that was driving me mad was remote audio. You can also import audio output from the remote ...

iPod Touch trouble

I'll first start telling you that I just love it: The iPod Touch is the coolest PDA-like device I've used. The size seems just right and though it's a bit pricey I ended up buying a couple of them as one of my kids wanted to get rid of his Creative ZEN-V that needs to be reseted every few songs (crap). However I am really disappointed to discover that while the iPod works nicely with WEP or WPA-PSK wifi protected networks, it does not support Enterprise WPA (that uses a Radius server for user authentication). That renders the unit almost useless in our campus. I've been told that if I pay $20 for an additional software then I'll be able to use a VPN client software that comes with it, but still no Enterprise WPA. Unfortunately I am not in the mood of shelling out a dollar more to Apple. I do think that they are too driven to make even more money out of us, unsuspecting customers, which does not improve their brand image in my mind. I am afraid I'll have to do th...

Reviving an old laptop

Image
Not sure what is the proper adjective for a three year old laptop. But apart from the language issue the thing is that I was asked to give a clean start to an HP nc6000 laptop. It seemed a no-brainer to install Windows XP SP2 or so I thought. While the install worked as expected, there were bad news afterwards: The system booted but nothing worked as expected: Graphics card,Ethernet, SD memory slot, Cardbus slots and Wifi adapter did not work at all. I am not sure whether the laptop was shipped with a driver's CD-ROM or not. The owner told me he had nothing like that. A few Google searches later I've discovered several drivers websites trying to make a buck out of the poor souls that could not find the drivers CDs. Some users also complained about HP not making the drivers available and, of course, standard drivers on SP2 not working with HP hardware. Later on I did find an entry on an HP website that contained the drivers . The problem is that it actually contained too many dr...