Sunday, November 29, 2015

Proceedings…

At this time of war, we need to come up with new solutions to maintain status quo. Not in the sense you’re thinking, but in the sense that there can be another post per another week.

But really! The weeks nowadays really seem to fly off. As they say, for a kid, a year could feel too long but for its grandparents, the same year may feel fleeting. The measure, of course, being the ratio of the years one has been alive on this miserable planet to this particularly sad, impressively sad & impeccably sad year, and nobody needs reminding that it is, 20, as you rightly recall, 15.

However, an unexpected drop of 4 chapters of Sketchbook has cheered me up incredibly this week! Here’s the start if you like. But these chapters were not done by the usual scanlator group named ‘Musashi Quality’ and as such the quality of this release is not quite ‘Musashi’. It leaves something to be desired… like complete sentences that make sense. Anyway, it is great nonetheless that someone (or some group) has taken it up and are doing their best with the scanlating job. A sample (LYHOL):

Sketchbook_v09_ch123_062

I was also reminded of a new acronym this week (which I had heard in one of the episodes of DG:MLiG earlier): WTF ⇒ With Tender Feelings. As anyone would agree, it is a great way to end my emails to my tenderly Superpartner. Smile

Just to make sure you understand that this is not a filler post, I will leave you with a question. Describe the purpose and origin of the following machine:

Guess What?

HSR

Sunday, November 22, 2015

Brute Force

This is a declaration of war against time. We will reach 24 posts in this year no matter what! If you think why is that a big deal, you obviously haven’t spent much time here on our blog. Check the right sidebar and you will notice the total number of posts in any given year is a multiple of 12… (ignoring the issue of time zones, which makes some odd numbers appear), get it now? Another issue which tells us you have NOT spent much time here is the fact that you have not yet voted on the poll sitting right at your eye-level slightly to the right!

Now that we have gotten past that, let me get on to the agenda of this post: Brute Force Algorithm (BFA) to solve a Sudoku. Actually, Smart Brute Force Algorithm (SBFA). In fact, so smart that it is slightly better than this ‘official’ one here. But also so damn smart that it makes me look stupid by making me ask why didn’t I come up with it in the first place! OK, that’s all the smartass comments from me… let’s have some concrete discussions.

As you know, the ‘SuDoKu Solver’ tab exists above but till about a few weeks ago, the v6.9 that you could get from there had a BFA that took nearly 11 minutes to solve one of the “world’s hardest” Sudokus on my SP1:

Hard (655s)

This was because I was wading through all the possible values of a particular cell starting with the first empty cell in row 1 and then stepping through subsequent cells row-wise linearly. Now that I have updated SS to v7.0 with SBFA, it gets solved in about 1.5 minutes!

Hard (91s)

This is because now I (still) wade through all the possible values of a particular cell but starting with the one that has the least number of those values and then stepping through similar least-possible-values-possessing-cells. So the difference with previous algorithm is non-linearity! This is still the same effort as the ‘official’ one linked above… difference is that I figure out the possible values only once… then keep updating this 3d (cell) array at each recursive level whereas in the other code, this 3d array is constructed at each level. Sadly, the overhead of constructing it every time doesn’t quite catch up to keeping up-to-date a single array till very large number of recursions. I will give examples of both cases below.

So now, we basically forget the GUI and measure the time that only the bare-bones SBFA code takes. First, let’s take the “world’s hardest” Sudoku and compare against the ‘official’ solver:

Hardest

See… Just 3.5s! Doubly faster than the other one… Yo Yoo Yooo!

But, and there’s always a but, SBFA is not all that great for Sudokus that can be solved logically! This is the second example:

Solving with Logic

Solving with SBFA and GUI onscreen

Solving with SBFA and GUI minimized

Logic needs 4.5s to solve this Sudoku but SBFA takes a whopping 2.5 minutes (with GUI onscreen) or 32s (with GUI minimized). Of course, you are more interested in running the bare-bones code and mine takes only 2.5s compared to just 1.5s by the ‘official’ solver. Sad smile

Solving with bare SBFA

But why would you run the bare-bones code and miss all this fun:

Brute Force vs. Logic

So go get the new, improved and smart solver! Smile

SS v7.0

Sunday, November 15, 2015

Ad hoc-ish…

This post is about a number of things (they are not routine) that I got involved in of late. Let me tell beforehand what they are so that you may decide whether you want to continue reading the post or not. I attended a traditional cum western wedding in China. I have recently rented an imported second hand Piano (80’s Piano of Apollo) from Europe. We faced a Typhoon while I was in Taipei and when I came back to Guangzhou, there was another typhoon here.

With the above agenda in mind, let me write about the many unique elements of the wedding. The auspicious time of any wedding here is set to 4:30 in the morning. That means, the bride, groom and the immediate family members have a sleepless night on the day of the wedding. The groom starts from his home at around 2AM (which means he gets ready around midnight) while the bride and bridesmaids also try to look their best and wait. The groom arrives with his close family and friends and he is required to prove himself worthy of the bride! He is tested by bridesmaids and her family members on different parameters – health, wealth, education and talent after which he is allowed to meet his partner (who has already been given information about how they have tormented her would-be husband).

A bridesmaid sitting on the Groom's back

A few rituals take place at the auspicious time and the bride wears golden jewelry of specific kinds. The cutest among them is a necklace of Pig with a lot of piglets. This necklace is a wishful reminder of the fact that the marriage should lead to many beautiful children.

After some light breakfast, the bride and groom are led to the Reception hall where the non-immediate family members and friends also start gathering up. People gift lucky money to the couple (no gifts or other material items) and have their seats around round tables. These round tables are where the lunch is served later. I have told Him that we will have these round tables in our home some day. One doesn’t need to pass items from one corner of the table to the other, just rotate the table-top and they come to you.

In olden days, the women and men would be dressed in traditional red garments but these days, women dress in white gowns and men in suits. People willing to perform on the stage entertain rest of the guests. Special performers are hired to sing in different Chinese languages. The couple do the usual things – cutting the cake, giving a speech, having a drink from each other’s glasses, exchanging rings and sharing the long-awaited wedding kiss while the guests says ‘Ganbei’ (meaning ‘Cheers’).

Couple on the stage

Food on a round table

Food is an important part of the wedding and waiters start to serve various dishes as soon as the above described ceremony is over. Buffet system isn’t preferred here and people eat slowly while drinking and smoking, seems to be a part of the culture. I enjoyed the music, photo sessions and the celebration as a whole.

Now, let me show you the picture of my Piano. I have learnt to move my fingers on the keys and I can read the piano notes. I can also sing and play some nursery rhymes but that’s all that I can do at the moment. If you think that’s not much, then let me be specific and tell you that these rhymes are in Chinese Smile. I want to play ‘Tujhe dekha to ye...’ from my favorite movie DDLJ, sometime soon. That song was my inspiration to learn Piano.

Apollo Piano

I go back to Taipei now. We were at home on a Sunday and thought it was the usual rain that poured throughout the day but next day, when we went to office we realized it had been a typhoon and that the Mayor of the city had declared Monday a public holiday. I saw uprooted trees on the roads, leaves everywhere as if there was a ‘Fall’ in Taiwan. After working in a silent office with just a couple of other colleagues, I rushed back to NTU. We went to Longshan temple in Taipei on the last day of my trip and that’s the only new place that we went to. Below are some pictures from that visit:

In front of the temple

Offerings

Dragon embellished pot

The big Golden pot    Long incense sticks in hand

Bright red candles

The temple from outside

That’s all for this post, wishing you all a Belated Happy Diwali.