LoginSignup
1
1

More than 3 years have passed since last update.

ほとんどのエンジニアには解けるパズル3を解けませんでした

Posted at

解く問題

【パズル3】ほとんどのエンジニアには解けるパズル3 - ベルリンのITスタートアップで働くジャバ・ザ・ハットリの日記
Challenge3

背景

下位20%のダメなエンジニアにだけ解けないパズルを解いた - Qiitaの続編です。

自分ルール

curlコマンドに関してはググってもよい。
解答を記載しているようなページは参照しない。

最初に結果から

アイスランドの緯度、経度がわからず、正解までたどり着けませんでした…

解答

$ curl http://challenge-your-limits3.herokuapp.com/call/my/lovely/APIs
{"message":"Let's get started! (1) Input whole numbers into '/input/is/:x' You can do it as much as you want.  (2) Guess what is formula from the outcomes.  (3) Put your formula into 'formula/is/:answer' e.g. 'formula/is/x+3' Good luck!"}

さぁ始めよう!
(1)./input/is/:xに整数を入力してみて。何回でも入力できるよ。
(2).結果から式を予想してみて。
(3).答えはformula/is/x+3のように、answerを書き換えてね。

みたいなことを言われました。
:xにいろいろ入れて、curlを叩いてみます。

$ curl http://challenge-your-limits3.herokuapp.com/input/is/1
{"output":6}
$ curl http://challenge-your-limits3.herokuapp.com/input/is/2
{"output":7,"clue":"URL encoding"}
$ curl http://challenge-your-limits3.herokuapp.com/input/is/3
{"output":8}
$ curl http://challenge-your-limits3.herokuapp.com/input/is/4
{"output":9,"clue":"URL encoding"}
$ curl http://challenge-your-limits3.herokuapp.com/input/is/5
{"output":10}

「5を加算しているだけだけかぁ、x+5だな!」となりました。
というわけで、

$ curl http://challenge-your-limits3.herokuapp.com/formula/is/x+5
{"error":"Nope. Keep trying. clue === http://bit.ly/1UwaCkv"}

エラーしました。
URLエンコーディングすればいいかと思い、+をエンコーディングしてみます。

$ curl http://challenge-your-limits3.herokuapp.com/formula/is/x%2B5
{"error":"Nope. Keep trying. clue === http://bit.ly/1UwaCkv"}

結果変わらず。
だめでした。
xを大文字にすればイケるのでは??と思いましたが、

$ curl http://challenge-your-limits3.herokuapp.com/formula/is/X%2B5
{"error":"It should be 'x'. Not 'X' Ok?"}

気のせいでした。
30分くらい悩んでいましたが、input/is/20をたたいたときに、25ではなく5になりました。
あ、除算してる…余りかこれ…と閃き、

$ curl http://challenge-your-limits3.herokuapp.com/formula/is/x%2520%2b5
{"message":"Good Job!! === Please register your lovely profile as /challengers"}

x%20+5という数式になりました。
xを20で割った余りに5を加算する。という意味です。
そうすると、/challengersでプロフィールを登録してください。というメッセージになりました。

前回、前々回と同様にusernameとemailを入力して、上記のURLでcurlをたたきます。

$ curl -X POST -d 'username=riekure&email=qwertyuio@fuga.com' http://challenge-your-limits3.herokuapp.com/challengers
{"message":"Thanks for your registration! Let's go to '/welcome/to/Iceland'","id":5438,"username":"riekure","email":"qwertyuio@fuga.com","password":"RWTqD76EBZa3xQs1","latitude":139.692,"longitude":35.6895,"created_at":"2019-02-20T01:20:23.

次たたくURLとid、passwordなどなど返ってきました。
username:passwordを付与して、curlをたたきます。
これも前回、前々回とだいたい同じ。

$ curl -u riekure:RWTqD76EBZa3xQs1 http://challenge-your-limits3.herokuapp.com/welcome/to/Iceland
{"error":"uh-oh. Sorry. This page can only be accessed within Iceland. You're accessing from Tokyo JP. Only from Iceland is allowed. You wanna know why? Just ask 'why/Iceland'"}

Icelandからしかアクセスできないらしいです。
何故か知りたいならば、why/Icelandを叩けばよさそうです。

$ curl -u riekure:RWTqD76EBZa3xQs1 http://challenge-your-limits3.herokuapp.com/why/Iceland
{"message":"Iceland is here === http://bit.ly/1OM90Vx  You know? There is NO NEED to use Iceland VPN. You can update your location from PATCH '/challengers/:id' Don't be so serious!"}

Iceland VPNは必要ないよ。locationをPATCHでアップデートできる。らしいです。
curlはさっぱり分からないのでググりました。
curlでPATCH動詞を使用する方法 - コードログ
--request PATCHをつければいいらしいので、とりあえず叩きます。

$ curl -u riekure:RWTqD76EBZa3xQs1 --request PATCH http://challenge-your-limits3.herokuapp.com/challengers/5438
{"message":"Do you know how to set your location as Iceland? Check this out === http://bit.ly/1O82eUE"}

アイスランドがどこか分からないなら、ここをチェックしようとURLがありました。
ただ、これが謎の企業?のページに飛ばされて、緯度/経度がさっぱり分からんです。
Wikipediaみて緯度/経度を調べて、ヤケクソで緯度/経度をPATCHしようと試みます。

$ curl -u riekure:RWTqD76EBZa3xQs1 --request PATCH --header 'Content-Type: application/json' --data '{"latitude": 64.08,"longitude": -21.56}' http://challenge-your-limits3.herokuapp.com/challengers/5438

お?何も返ってこないから上手くいった??
というわけで、もう一度welcome/to/Icelandを叩きます。

$ curl -u riekure:RWTqD76EBZa3xQs1 http://challenge-your-limits3.herokuapp.com/welcome/to/Iceland
{"error":"uh-oh. Sorry. This page can only be accessed within Iceland. You're accessing from Tokyo JP. Only from Iceland is allowed. You wanna know why? Just ask 'why/Iceland'"}

はい。何も変わりませんでした。
そこから、いろいろと緯度/経度変えたり、header変えて叩きましたが変わらず……

合計して半日くらい格闘しましたが諦めました…

終わりに

解けなかった、他の方がまとめてくれていた答えを見ました。

下位10%のダメなエンジニアシリーズ

アプローチは合っていました。
悔しい……。

1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1