Pick six cities or villages, one from each of the populated continents, Asia, Africa, North America, South America, Europe and Australia. The forecasts cover 8351174 places, more than 2 million in the US, 150000 in Pakistan, 10000 in Uganda, and 16 places in the Shefa province in Vanuatu, so I think you'll find a place near you.

Make a table where the weather for each of the cities are listed, for the coming ten 6-hour periods. The cities should be listed in the order above (first an Asian city, then an African city ...).

The information that should be listed is:

  • City: Name, CC (CC is the first two letters of the country name)
  • Time: yyyy-mm-dd
  • Period: 1
  • Weather: Cloudy
  • Temperature: 24

The output format has the following restrictions:

The order is given as below (Time, Period, Weather, Temperature, Weather Temperature, Weather, Temperature ...). The city name and country code are headers

                Kyoto, JA          Addis Ababa, ET     Minneapolis, US     Rio de Janeiro, BR    Genoa, IT          Perth, AU 
2015-11-05, 3,  Cloudy, 15         Clear sky, 18       Heavy rain, 24      Cloudy, 12            Fair, 14           Rain, 26
2015-11-06, 0,  Cloudy, 12         Fair, 14            Rain, 26            Cloudy, 12            Fair, 14           Rain, 26    
2015-11-06, 1,  Heavy rain, 14     Clear sky, 17       Rain, 22            Heavy rain, 14        Clear sky, 17      Rain, 22            
2015-11-06, 2,  Rain, 15           Clear sky, 12       Rain, 25            Heavy rain, 14        Clear sky, 17      Rain, 22              
2015-11-06, 3,  Partly cloudy, 9   Fair, 8             Heavy rain, 30      Clear sky, 8          Fair, 14           Partly cloudy, 25
2015-11-07, 1,  Clear sky, -8      Fair, 14            Partly cloudy, 25   Clear sky, 8          Fair, -14          Partly cloudy, 25
2015-11-07, 2,  Fog, 13            Partly cloudy, 15   Fair, 22            Clear sky, 8          Fair, 14           Partly cloudy, 25

The weather forecast can be found on www.yr.no. The weather data can be found on xml-format on urls such as:


Yes, there are apparently two places called "Cockburn Town". You can search for places on the main page (yr.no), and simply append /forecast.xml when you've found your place. (You can select language in the top right corner, the website might be shown in Norwegian).

The data has the following format:

<time from="2015-11-05T19:00:00" to="2015-11-06T00:00:00" period="3">
 Valid from 2015-11-05T19:00:00 to 2015-11-06T00:00:00 
<symbol number="4" numberEx="4" name="Cloudy" var="04"/>
<precipitation value="0" minvalue="0" maxvalue="0.4"/>
<!--  Valid at 2015-11-05T19:00:00  -->
<windDirection deg="131.5" code="SE" name="Southeast"/>
<windSpeed mps="3.7" name="Gentle breeze"/>
<temperature unit="celsius" value="12"/>
<pressure unit="hPa" value="1014.2"/>
<time from="2015-11-06T00:00:00" to="2015-11-06T06:00:00" period="0">...</time>
<time from="2015-11-06T06:00:00" to="2015-11-06T12:00:00" period="1">...</time>

As you can see, each 6 hour period has a period number "0", "1", "2" or "3". The table must have the date followed by the period number, 2015-11-06, 3 (might be separated by a comma, tab or whatever).

You must, for each of the periods list what type of weather it is, and the temperature, in this case: Cloudy, 12 (not 12 Cloudy). The values can be separated by a comma, tab, or whatever.

Each city must be separated from the others in such a way that they form distinct "blocks", as in the example output. The output should be on a table like format.

The details of the output format is optional.

These parts: Italy/Liguria/Genoa/, Brazil/Rio_de_Janeiro/Rio_de_Janeiro/ of the code can be subtracted from the byte count (no need to chose the shortest city names). Url-shorteners are prohibited.

It must be possible to run your code a year from now, so you can't hard code dates etc.

The weather data is free and publicly available, as long as the following attribution is shown, so please include it in the bottom of your answer.

This is code golf, so the shortest answer in bytes win.

Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK.

  • 6
    \$\begingroup\$ if (I_am_camping()) return "Heavy rain"; \$\endgroup\$ Nov 7, 2015 at 12:06
  • 7
    \$\begingroup\$ if (I_am_at_work()) return "Clear sky"; \$\endgroup\$ Nov 7, 2015 at 12:13
  • 1
    \$\begingroup\$ if(is_in_Ireland()) return "Slightly rainy, 54 degrees Fahrenheit \$\endgroup\$ Nov 12, 2015 at 19:12

1 Answer 1


Mathematica 418 bytes

These are the URL's. We will assume they are contained in variables and thus not count them.

t="http://www.yr.no/place/Japan/Tokyo/Tokyo/forecast.xml"; a="http://www.yr.no/place/Algeria/Alger/Algiers/forecast.xml"; b="http://www.yr.no/place/United_States/Massachusetts/Boston/forecast.xml"; r="http://www.yr.no/place/Brazil/Pernambuco/Recife/forecast.xml"; p="http://www.yr.no/place/France/Île-de-France/Paris/forecast.xml"; c="http://www.yr.no/place/Australia/Australian_Capital_Territory/Canberra/forecast.xml";

This is the code used.

z@{s_,k_}:=Cases[s~Import~"XML",XMLElement["time",{"from"-> d_,b_,"period"->p_},
___}]:>{" "->Row[{d~StringTake~10,p},", "],k->Row[{w, t},", "]},Infinity];
w=Join@@(z/@{{t,"Tokyo, JA"},{a,"Algiers, AL"},{b,"Boston, US"},{r,"Recife, BR"},
{p,"Paris, FR"},{c,"Canberra, AU"}});


  • 2
    \$\begingroup\$ I'm not looking forward to 2015-11-10, 3 at all. That seems to be a crappy time all over the world (almost). \$\endgroup\$ Nov 8, 2015 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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