security override の問題
まだ簡単な問題しか解けないです。すいません。
programming.1
In order to complete Programming Challenge 1, you must code a script that
will reverse the string below, while maintaining the first letter at the
beginning.
Example: chicken -> cnekcih
例を見る限りでは、
chicken という文字列を 逆順して、 最初の文字だけをそのままにする。
って感じなので、 pythonで書きました。
答えです
ついでに答えも…。本当に汚いソースです。
まぁ汚いですが、出来るだけ短く書こうとした結果です。
programming.2
In order to complete Programming Challenge 2, you must code a script that
will convert each character in the string below into its ascii value equivalent,
and add all 10 values together.
Example: abc -> 979899 -> 97 + 98 + 99 -> 294
例を見る限りでは、
abcという文字列を ASCIIコードに変換して、すべてを足す。的な?感じですね。
答え>です
ついでに答えも…。本当に汚いソースです。
programming.3 の仕方が分かないので、あきらめて programming.4をしました。
programming.4
In order to complete Programming Challenge 4, you must code a script that
will find the distance of the figure below...
Take this 3-dimensional figure into account:
Given the the figure above is indeed a cube (that is, length, width, and height
are all equivalent), and also that the cube is a solid object (that is, you can
not go through the cube to get from point 1 to point 2), you must find the
shortest distance from point 1 to point 2, moving around the cube.
Note1: Part of the challenge is figuring out how to find the shortest distance.
Note2: Enter the final number rounded down to the nearest whole number.
Example: side length = 3 -> shortest distance = 6
この問題を見る限り 1 ~ 2 の最短距離を求める。 って思って、
英語を読むのを怠って、ソースを書きました。
( ̄∇ ̄*)余裕じゃんwww
これが悪魔の罠ダということも知らずに…。
中学校で習った三角形の奴(名前忘れた…てへ)でポイント1からポイント2の距離を
はかりました。
あれ? 3 って入力しても 5 にしかなりません。…
( ๑・ิټ・ิ๑)…。もしかして、
小数点ついてたら、+1してやるのか??
Note2: Enter the final number rounded down to the nearest whole number.
この note2 の意味が曖昧だけど、 多分そういうことだろう…。
そこで、僕は提出したら、 WA でした…。
絶望に陥った僕は ちゃんと英語を読みました。 すると、
you must find the shortest distance from point 1 to point 2, moving around the cube.
って書いてありました。
MOVING AROUND THE CUBE ????
✌( ՞ਊ ՞)✌イェェェェェェェそういうことか!!
中を通るのじゃなくて、周辺?の最短と。
理解した僕は、すぐにソースを書き直しました。
結構 このソースは簡潔にかけていて『お気に入り』w
汚くても良いだろ!!
⬆しょーもない問題に10分もかけてしまったww(;´Д`)'`ァ'`ァ…。
解けたから良いだろ?
とりあえず3門解いてテンション上がってるので writeupしました。
解いていったらどんどん書いていきます。
programming.5 をやったのですが…。
In order to complete Programming Challenge 5, you must code a script that will find the line number and position of the @ symbols in the text below.
0000000@00
00@0000000
00000000@0
Answer would be:
1-7, 2-2, 3-8
Please note that the syntax of the answer is line-position (example: 1-2).
Also note that each of the 5 lines below contains 50 characters.
Finally, note that the first line is 1, while the first position is 0. That means that the very first character is 1-0.
ぜ・・・ったい合ってるのに、
Error を吐かれます。
今それで不機嫌です。
答えです
答えは フォームを送るので、 最後の 余分な [ , ] は消して、
送れば ぜっったいに正解なのに…。
ちょー頭に血が上っています。(;´Д`)'`ァ'`ァ。
ゆいにゃんに助けてもらう必要がありそうです。o(;*´Д`)o
ゆいにゃん助けてちょ!!
もう1門解けました。
programming.6
In order to complete Programming Challenge 6, you must code a script that will factor the trinomial below.
Example: x^2 + 4x + 3 -> (x+3)(x+1)
x^2 + 4907x + 5155692
この問題の重要なところは
x^2 + 4x + 3 -> (x+3)(x+1)
x^2 + 4x + 3 自体を1つの文字列として僕は入力して、プログラムを作りました。
Pythonには便利なメソッド?がありまして、
a = map(str,raw_input().split()) としてやると、
要素を分けれるので便利ですw
1つ目の要素の x^2 を無視して、 3つ目の要素 4x を書くのが大変でした…。
もっといい方法があるんだろうけど、 分からなかったので、すごい原始的にやり(ry
b = int(b[0:len(b)-1]) ってしてやったら、 x を消せるなって。
はい。
( -b√(b^2 - 4ac) ) / 2 という中学校で習ったやつ(名前忘れた)を使うことにより、
できますね〜。( ̄∇ ̄*)
( ๑・ิټ・ิ๑):これは簡単過ぎやろ?
問題の値が
x^2 + 4907x + 5155692
と結構大きいので解けるか分かりませんでしたが、
こうやってやると、簡単です(*´・ω・)(・ω・`*)ネー
さっきの公式は あくまで 『解』の公式 なので、
マイナス(-)をかけなければなりません。
では自と出来ますねw(( ՞ٹ՞)
ここが結構恥ずかしいのですが、
print "%d"がなぜか ちゃんということ聞いてくれなくて
typeErrorばっかり怒るので " "+str(hoge)+" " という原始的な(ry
で、答えが出ましたぁ〜。
Programming の面白いのは毎回答えが分かるので、
答えを書いても意味ねぇな。って言う所です。
とりあえず 答えです
これがソースです。※汚いので真似しないでください!(;´Д`)!
Programming.7