softnshare / kata

Code Kata 這個概念是由 The Pragmatic Programmer 的作者之一Dave Thomas提出的, 想要提升自己的coding skill嗎? 歡迎加入這個slack channel, 加入請參考右邊網頁說明
https://softnshare.wordpress.com/slack/kata/
38 stars 4 forks source link

Coordinates Validator #14

Open vampireneo opened 8 years ago

vampireneo commented 8 years ago

題目 You need to create a function that will validate if given parameters are valid geographical coordinates.

Valid coordinates look like the following: "23.32353342, -32.543534534". The return value should be either true or false.

Latitude (which is first float) can be between 0 and 90, positive or negative. Longitude (which is second float) can be between 0 and 180, positive or negative.

Coordinates can only contain digits, or one of the following symbols (including space after comma) -, .

There should be no space between the minus "-" sign and the digit after it.

Here are some valid coordinates:

And some invalid ones:

翻譯 請建立一個函式,驗證參是否一個正確的地理坐標。

http://www.codewars.com/kata/5269452810342858ec000951

bucker commented 8 years ago

Pass 有 regex 的概念即可輕鬆過關。Solution 有個一行結束的好像有點神...

vampireneo commented 8 years ago

用一行 regex 結束的真是 crazy...

jawayang commented 8 years ago

Pass