11
$\begingroup$

Two junior colleagues of mine came to me today morning. Both of them wearing a broad smile. I asked what the matter, what mischief are you guys planning. One of them just typed a URL on my computer. It opened up a JSFiddle page with title, 'Countries of World', where countries were divided in three columns list.

Other said, "Use your knowledge & find out why these countries are divided in these three columns!"

Guys, please have a look & help me solve the challenge. My reputation is at stake!

Link to JSFiddle : https://jsfiddle.net/21zrbz7m/2/


Here is some of the countries copied from link (To reduced clustering, I copied only some of the countries. You can view full list on the link, though countries listed here are more than enough to solve this puzzle):

Group #100

Afghanistan, Angola, Australia, Bahrain, Belarus, Benin, Bolivia, Brazil, Burundi, China, Costa Rica, Cyprus, Djibouti, East Timor, England, Eritrea, Fiji, French Guiana, Hong Kong, Laos, Lithuania, Mauritania, Nauru, Panama, Togo, Vietnam

Group #010

American Samoa, Armenia, Central African Republic, Gambia, Greece, Honduras, India, Iran, Jamaica, Kuwait, Luxembourg, Malaysia, Morocco, New Zealand, Nigeria, Palestine, Pitcairn, Senegal, Slovakia, Spain, Sweden, Turkmenistan, United Arab Emirates, Venezuela, Zimbabwe

Group #001

Chile, Grenada, Iceland, Jordan, Liechtenstein, Malta, Mexico, Mongolia, Namibia, Norway, Poland, Russian Federation, Samoa, Seychelles, South Korea, Swaziland, Tajikistan, Tunisia, Ukraine, Yugoslavia


Note:

There is tiny bits of maths concepts involved, but knowledge in programming is a necessity to solve this challenge, or maybe not because the concept used is much basic than that! I still feel that this requires some knowledge about a particular branch of programming, thus I'll add hints one by one to move the users in right direction.

Hint 1:

Those two colleagues are web developers!

Hint 2:

There is no complex operation required to solve this puzzle only if you know what to do.

Country List Credit

https://github.com/samayo/country-json

$\endgroup$
  • 1
    $\begingroup$ "Congo, Congo, The Democratic Republic of the," $\endgroup$ – Donnelle Feb 20 '17 at 21:37
  • $\begingroup$ Smells of binary arithmetic... $\endgroup$ – Mordechai Feb 21 '17 at 1:10
  • $\begingroup$ @Donnelle Thanks, I overlooked it, I updated question & fiddle to remove such ambiguous entities. $\endgroup$ – demonofthemist Feb 21 '17 at 5:22
  • $\begingroup$ @MouseEvent No its not binary, but yes number system involved. Though answer can be obtained by without performing any complex operations. $\endgroup$ – demonofthemist Feb 21 '17 at 5:23
  • $\begingroup$ Is there a real reason #100 is longer than #010 and this one is longer than #001, or is it an artefact of the rules you specified ? If the group were sorted another way, would the rule be false ? (column 1 = #001, etc) $\endgroup$ – Lilian Delaveau Feb 21 '17 at 8:20
8
$\begingroup$

This question is all about HTML background colours. There's a page over at Stack Overflow that explains the situation better than I can:

Why does HTML think "chucknorris" is a color?

Basically, the countries are classified according to what sort of colour you get when the country name (minus any spaces) is specified as the bgcolor attribute of an HTML page.

For example, <body bgcolor="Afghanistan"> will give your document an orangey-yellow background colour, while <body bgcolor="VaticanCity"> is bright green and <body bgcolor="Scotland"> is shocking pink.

The rule is that the countries are grouped according to whether the resulting colour is dominated by red, green or blue. For example, the colour for Afghanistan is rgb(175, 160, 10), which has more red than anything else, so Afghanistan is in group #100. The colour for VaticanCity is rgb(10, 202, 0), where green is dominant, hence #010. And likewise, Scotland is rgb(192, 10, 208), which has more blue and is thus in group #001.

In the case of a tie, red takes precedence over green, and green takes precedence over blue. This is why Andorra (rgb(160, 0, 160)) is in group #100 and UnitedKingdom (rgb(0, 208, 208)) is in group #010.

Here's another JSFiddle that shows you the colour corresponding to each country.

$\endgroup$
  • $\begingroup$ This is it! You got it right. $\endgroup$ – demonofthemist Feb 22 '17 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.