# Encode Antarctic claims

Seven countries lay official claims to parts of Antarctica: Argentina, Australia, Chile, France, New Zealand, Norway, and the United Kingdom. We will focus only on the claims of the main Antarctic landmass south of 60° S, which are:

• Chile: between 90° W and 53° W
• United Kingdom: between 80° W and 20° W
• Argentina: between 74° W and 25° W
• Norway: between 20° W and 44°38 E
• Australia: between 44°38 E and 136°11 E; and between 142°2 E and 160° E
• France: between 136°11 E and 142°2 E
• New Zealand: between 160° E and 150° W

The region between 150° W and 90° W is unclaimed. Note also that Chile's, the UK's, and Argentina's claims overlap to some degree.

Here is a map:

The above image modified from work at https://w.wiki/4e3R; used under CC-BY-SA 3.0.

All of these claims extend northwards from the South Pole at 90° S. It is unclear where Norway's stops, but it does not matter because we will only ask about the claims just north of the South Pole.

Your task is to encode the information about the claims in the fewest bytes possible: given an input $$\ x \$$, output the set of countries which claim Antarctica at longitude $$\ x \$$° and latitude 89.9° S.

You should represent outputs of countries using any seven distinct values, within reason.

For the areas where multiple claims overlap (which are variously those of Argentina, Chile, and the United Kingdom), you should output the multiple values representing those countries. These multiple outputs may be in any order.

For the unclaimed region between 150° W and 90° W, you should output an empty list.

## Test cases

     Input     ->  Output(s)
--------------------------------------
0.0 /  360.0 ->  [Norway]
180.0 / -180.0 ->  [New Zealand]
223.2 / -136.8 ->  []
270.1 /  -89.9 ->  [Chile]
280.5 /  -79.5 ->  [Chile, United Kingdom]
296.6 /  -63.4 ->  [Argentina, Chile, United Kingdom]
337.6 /  -22.4 ->  [United Kingdom]
340.3 /  -19.7 ->  [Norway]
44.6          ->  [Norway]
44.7          ->  [Australia]
139.4          ->  [France]
142.0          ->  [France]
142.1          ->  [Australia]
161.8          ->  [New Zealand]
190.5 / -169.5 ->  [New Zealand]


## Rules

• Your code must support non-integer longitudes. Small errors due to floating-point precision errors are acceptable
• You may choose to require input $$\ x \$$ between -180° and 180° (with negative values representing west of the Prime Meridian), or between 0° and 360°. You only need to support one of the two edges of whichever range you choose
• Behaviour exactly on the boundaries of claims (e.g. at exactly 20° W) is undefined
• You may use any standard I/O method
• Standard loopholes are forbidden
• This is , so the shortest code in bytes wins

# Charcoal, 137 bytes

≔×⁶⁰ＮθＥΦＥ⪪”}∧¡8↥″⟧ＭＸ⬤～m→⊖⊗9⁸'DQζF%f¹ψz‖aνy("⟲?⎚‹3Ｉ‹4↥GNＯk³▷Ｈ!Ｊ;⁵´j‹Ｚ*I:↷¡!β↑}1⊞↘≦ＱêY(¦≔πω/_²≔▶⁶ω≧N4Þ⁰^⊕﹪ＷÞ｜l⎚Ｖ2⊖¬|η&f≔”¶⪪ι ››Ｉ⊟ιθ›Ｉ⊟ιθ⪫ι


Try it online! Link is to verbose version of code. Assumes input is non-negative but less than 360. Not much shorter than the JS version because I output country names.

≔×⁶⁰Ｎθ


Multiply the input by 60 to convert it into minutes.

ＥΦＥ⪪”...”¶⪪ι ››Ｉ⊟ιθ›Ｉ⊟ιθ⪫ι


Split the compressed data string on newlines and again on spaces. Keep only those where the input is between the boundaries or on the lower boundary. Fix up "United Kingdom" back into a single string (using "UK" would save a byte, and double-spacing the output would save a further 3 bytes).

78 bytes using custom output:

≔×⁶⁰ＮθＩ﹪⌕ＡＥＥ⪪”←＆!ω\⟧≕Ｇ⁵↑³yυ~r,S⦃›F⁷ω(Ｄ⧴aM↖G≕%›"‽.⊞⭆↓‽ⅈ0ÀG→\$”¶⪪ι ››Ｉ⊟ιθ›Ｉ⊟ιθ¹¦⁷


Try it online! Link is to verbose version of code. Explanation: Obtains the indices of the matching ranges and reduces modulo 7 to output digits according to the following key:

0 Norway
1 Australia
2 France
3 New Zealand
4 Chile
5 United Kingdom
6 Argentina


(Note that the ranges are ordered slightly differently in this version.)

# JavaScript (ES10), 128 bytes

Expects a signed value.

Returns 0 for New Zealand, 2 for Argentina, 32 for Norway, 34 for Chile, 64 for United Kingdom, 65 for France, 98 for Australia.

v=>[90,100,106,160,a=13478/60,b=19322/60,c=18971/60,0,340].flatMap((x,i)=>v<x|v>[127,160,155,a,c,340,b,30][i]?[]:x*29&99,v+=180)


Try it online!

• when you input '337.6', shouldnt you get 3 countries instead of 1? your solution seems flawed Jan 7 at 11:44
• @Luke_ As mentioned, this expects a signed value, i.e. in -180 ... 180. Jan 7 at 13:52

# C (gcc), 247 172 bytes

• -7 thanks to pxeger
• -3 by changing the output values (and fixed a bug)
• -6 thanks to gastropner
• -8 by changing the range format to (offset, starting longitude)
• -61(!) thanks to Neil

Takes a floating-point longitude from [0, 360) degrees, but performs all the computations using integer minutes. For Norway, I split up the range into two sections to make calculations easier.

Countries are expressed in the following format:

• 0: Norway
• 1: Australia
• 2: Chile
• 3: United Kingdom
• 4: Argentina
• 5: France
• 6: New Zealand
g[]={1078,8522,2678,0,3e3,9600,351,8171,2940,17160,3600,16800,2220,16200,5493,2678,1201,20400},i,j,*a;f(float l){for(i=l*60,j=9,a=g;j--;)*a+++0u>i-*a++&&printf("%d,",j%7);}


Try it online!

Ungolfed:

g[]={
1078,8522, // Australia
2678,0, // Norway
3000,9600, // New Zealand
351,8171, // France
2940,17160, // Argentina
3600,16800, // United Kingdom
2220,16200, // Chile
5493,2678, // Australia
1201,20400 // Norway
},
i,j,*a;

f(float l) {
for(i=l*60, // Convert input into minutes
j=9,a=g;j--;)
*a+++0u>i-*a++&& // (Input-start longitude) within range?
printf("%d,",j%7);
}

• You don't need the (int) cast because i is declared as an int already, saving 7 bytes (...for(i=l*60,...) Jan 7 at 7:48
• Thanks! My original solution involved using modulos, which required casting. I missed the cast when I simplified the code. Jan 7 at 7:52
• Flipping high/low values in the list (x(16200,18420) -> x(18420,16200)) and changing the test to i<*a++&&i>=*a allows you to reuse 0 as a sentinel, making the macro (int[]){a,0}, and the loop test *a, saving two more bytes. Jan 7 at 8:53
• g[]={20400,21600,2678,8171,16200,18420,16800,20400,17160,20100,8171,8522,9600,12600,0,2678,8522,9600},i,j,*a;f(float l){for(i=l*60,j=0,a=g;j<9;a++,j++)i>=*a++&&i<*a&&printf("%d,",j%7);} is only 185 bytes, and I think it should be possible to eliminate j to save 4 more bytes.
– Neil
Jan 7 at 9:08
• 172 bytes (Order of output reversed.) Jan 8 at 8:25

# 05AB1E, 55 54 bytes

60*ò•1ζ_ʒǝ=¶Ò´™p]·ÐΘä¥ËrªÞ÷Â0[₁µÑ…εC£•Ž≠¶в2ô€ŸQOƶ0K7%


-1 byte thanks to @Neil by also using modulo-7.

Input as a longitude float in the range $$\[0,360)\$$. Outputs $$\0\$$ for Argentina, $$\1\$$ for Australia, $$\2\$$ for Norway, $$\3\$$ for France, $$\4\$$ for New Zealand, $$\5\$$ for Chile, and $$\6\$$ for the United Kingdom.

Explanation:

60*              # Multiply the (implicit) input by 60
ò             # (Bankers) round it to the nearest integer
•1ζ_ʒǝ=¶Ò´™p]·ÐΘä¥ËrªÞ÷Â0[₁µÑ…εC£•
# Push compressed integer 129995249012016373632115353299026583238712674313934551571472125857818360468822
Ž≠¶             # Push compressed integer 21601
в            # Convert the larger integer to base-21601 as list:
#  [2678,8171,0,2678,8171,8522,9600,12600,16200,18420,16800,20400,17160,20100,8522,9600,20400,21600]
2ô          # Split it into parts of size 2:
#  [[2678,8171],[0,2678],...]
€Ÿ        # Map each pair to an inclusive ranged list
#  [[2678,2679,2680,...,8170,8171],[0,1,2,...,2677,2678],...]
Q       # Check for each inner integer if its equal to the round(input*60)
O      # Sum each inner list, resulting in 1 if it was within that range
ƶ     # Multiply each by its 1-based index
0K   # Remove all 0s
7% # Modulo-7 to transform the 8 to 1 and 9 to 2
# (after which the result is output implicitly)


See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •1ζ_ʒǝ=¶Ò´™p]·ÐΘä¥ËrªÞ÷Â0[₁µÑ…εC£• is 129995249012016373632115353299026583238712674313934551571472125857818360468822; Ž≠¶ is 21601; and •1ζ_ʒǝ=¶Ò´™p]·ÐΘä¥ËrªÞ÷Â0[₁µÑ…εC£•Ž≠¶в is [2678,8171,0,2678,8171,8522,9600,12600,16200,18420,16800,20400,17160,20100,8522,9600,20400,21600].

Outputting with the actual title-cased countries from the dictionary would be 85 bytes instead, by removing the no longer necessary 7% and adding some additional trailing bytes:

60*ò•1ζ_ʒǝ=¶Ò´™p]·ÐΘä¥ËrªÞ÷Â0[₁µÑ…εC£•Ž≠¶в2ô€ŸQOƶ0K”²Ðˆ‚¬ìˆÖ€¢1¸ŽƒŠ0”#sèεT”™ÆŠß”#1ú‡


Explanation:

”²Ðˆ‚¬ìˆÖ€¢1¸ŽƒŠ0”
# Push dictionary string "Argentina Australia Norway France New1 Chile United0"
#           # Split on spaces
sè         # Modular 0-based index the calculated value into this list
ε        # Map over each result:
T       #  Push 10
”™ÆŠß” #  Push dictionary string "Zealand Kingdom"
#     #  Split it on spaces
‡  #  Transliterate the "1" to " Zealand" and "0" to " Kingdom"
# (after which the resulting list is output implicitly)


See the same 05AB1E tip I linked earlier (section How to use the dictionary?) to understand why ”²Ðˆ‚¬ìˆÖ€¢1¸ŽƒŠ0” is "Argentina Australia Norway France New1 Chile United0" and ”™ÆŠß” is "Zealand Kingdom".

• Can you not arrange for positions 0 and 1 to refer to the same two countries as 7 and 8 thus allowing you to use mod 7 to collapse them to the same result?
– Neil
Jan 7 at 9:09
• @Neil I can, but I'm afraid it won't save any bytes because the ƶ0K would then also require a -1 (<) before the modulo 7: try it online. Jan 7 at 9:20
• That's just a numbering issue; if you remove the -1` then the first and last two countries still collapse to the same result, they're just off by 1 from my 0-based indexing attempt.
– Neil
Jan 7 at 9:43
• @Neil Ah, I'm an idiot. You're complete right! Thanks for -1, I'll update my answer. Jan 7 at 9:47