ubuntu14.04 32bit にAndroidStudioの環境構築する。
来月Android携帯に乗り換え予定なので、面白そうだからAndroidアプリ作ってみようかと思いました。
と、いうわけでAndroid Studioの環境構築です。
OS: Ubuntu14.04(LTS) 32bit
①:Android StudioのlinuxバージョンをDLしてきてインスコする。これはエラーも対して出ないので割愛。
②:出てきたエラーに対処する。
32bitは時代遅れなので、色々とエラーが出ます。自分が出たエラーは以下の2つ。
1.エミュレーター立ち上げようとしたら、そもそも立ち上がらない。
ADB in Android Studio (Ubuntu) ERROR : Unable to detect adb version, adb output: /home/hamid/Android/Sdk/platform-tools/adb: 1: /home/hamid/Android/Sdk/platform-tools/adb: Syntax error: ")" unexpected
というエラーが出る。
以下の方法を参考にして解決
askubuntu.com
2.エミュレーターが32bitに対応していないらしくて、エラーが出る。
ANDROID_EMULATOR_FORCE_32BIT=true
とすれば解決するはずなんだが、なぜかずっとエラー吐くので仕方ないからシェルスクリプトから起動時に設定してやることに。
#!/bin/bash # #set export ANDROID_EMULATOR_FORCE_32BIT=true export ANDROID_EMULATOR_FORCE_32BIT=true $HOME/android-studio/bin/studio.sh
これでとりあえずAndroidStudioが動くようになった。
めでたい。
春休み中に読んだ本と、やったゲームメモ
- 作者: ガウラヴスリ,ハートシュ・シンバル,Gaurav Suri,Hartosh Singh Bal,東江一紀
- 出版社/メーカー: 草思社
- 発売日: 2013/02
- メディア: 単行本
- この商品を含むブログ (2件) を見る
ペトロス伯父と「ゴールドバッハの予想」 (ハヤカワ・ノヴェルズ)
- 作者: アポストロスドキアディス,Apostolos Doxiadis,酒井武志
- 出版社/メーカー: 早川書房
- 発売日: 2001/03
- メディア: 単行本
- 購入: 6人 クリック: 94回
- この商品を含むブログ (14件) を見る
- 作者: 海羽超史郎,ふゆの春秋
- 出版社/メーカー: KADOKAWA/アスキー・メディアワークス
- 発売日: 2014/09/10
- メディア: 文庫
- この商品を含むブログ (5件) を見る
- 作者: 旭蓑雄,おぐち
- 出版社/メーカー: KADOKAWA/アスキー・メディアワークス
- 発売日: 2014/09/10
- メディア: 文庫
- この商品を含むブログ (1件) を見る
レターズ/ヴァニシング2 精神侵食<レターズ/ヴァニシング> (電撃文庫)
- 作者: 旭蓑雄
- 出版社/メーカー: KADOKAWA / アスキー・メディアワークス
- 発売日: 2015/06/03
- メディア: Kindle版
- この商品を含むブログを見る
- 作者: マリオリヴィオ,Mario Livio,千葉敏生
- 出版社/メーカー: 早川書房
- 発売日: 2011/10/21
- メディア: 単行本
- クリック: 5回
- この商品を含むブログ (2件) を見る
- 作者: らきるち,あさぎり
- 出版社/メーカー: KADOKAWA/メディアファクトリー
- 発売日: 2014/03/22
- メディア: 文庫
- この商品を含むブログ (9件) を見る
- 作者: アーシュラ・K・ル・グィン,Ursula K. Le Guin,小尾芙佐
- 出版社/メーカー: 早川書房
- 発売日: 1978/09
- メディア: 文庫
- 購入: 12人 クリック: 388回
- この商品を含むブログ (102件) を見る
【合本版】オイレンシュピーゲル 全4巻<オイレンシュピーゲル> (角川スニーカー文庫)
- 作者: 冲方丁
- 出版社/メーカー: KADOKAWA / 角川書店
- 発売日: 2015/01/09
- メディア: Kindle版
- この商品を含むブログ (3件) を見る
【合本版】スプライトシュピーゲル 全4巻<【合本版】スプライトシュピーゲル> (富士見ファンタジア文庫)
- 作者: 冲方丁
- 出版社/メーカー: KADOKAWA / 富士見書房
- 発売日: 2015/03/05
- メディア: Kindle版
- この商品を含むブログを見る
ゲームはほとんどsteam 一部エロゲと同人ゲー
steamでは、portal1&2と、タロスの原理(現在プレイ中)、final exam,The fall,
エロゲはsense off
同人ゲーはworld end economica(1~3) をプレイした。
医師国家試験合格しました
無事110回 医師国家試験合格しました。
登録に必要な書類は揃っているので、週明けに提出してきます。
お世話になった先生への挨拶、部屋の整理、買い出し等は今週中に済ませてしまいたいと思います。
研修先が市内なので引っ越しの必要がないだけかなり楽です。
Letter Queue
In computer science, a queue is a particular kind of data type in which the entities in the collection are kept in order and the principal operations on the collection are the addition of entities to the rear terminal position (enqueue or push), and removal of entities from the front terminal position (dequeue or pop). This makes the queue a First-In-First-Out (FIFO) data structure. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that once a new element is added, all elements that were added before have to be removed before the new element can be removed.
We will emulate the queue process with Python. You are given a sequence of commands:
- "PUSH X" -- enqueue X, where X is a letter in uppercase.
- "POP" -- dequeue the front position. if the queue is empty, then do nothing.
The queue can only contain letters.
You should process all commands and assemble letters which remain in the queue in one word from the front to the rear of the queue.
Let's look at an example, here’s the sequence of commands:
["PUSH A", "POP", "POP", "PUSH Z", "PUSH D", "PUSH O", "POP", "PUSH T"]
Command Queue Note
PUSH A A Added "A" in the empty queue
POP Removed "A"
POP The queue is empty already
PUSH Z Z
PUSH D ZD
PUSH O ZDO
POP DO
PUSH T DOT The result
Input: A sequence of commands as a list of strings.
Output: The queue remaining as a string.
Example:
letter_queue(["PUSH A", "POP", "POP", "PUSH Z", "PUSH D", "PUSH O", "POP", "PUSH T"]) == "DOT"
letter_queue(["POP", "POP"]) == ""
letter_queue(["PUSH H", "PUSH I"]) == "HI"
letter_queue([]) == ""
How it is used: Queues provide services in computer science, transportation, and operations research where various entities such as data, objects, persons, or events are stored and held to be processed later. In these contexts, the queue performs the function of a buffer.
Precondition:
0 ≤ len(commands) ≤ 30;
all(re.match("\APUSH [A-Z]\Z", c) or re.match("\APOP\Z", c) for c in commands)
def letter_queue(commands): result = [] for command in commands: if command.startswith("PUSH"): result.append(command[-1]) elif command == "POP" and len(result) != 0: result.pop(0) return "".join(result) if __name__ == '__main__': #These "asserts" using only for self-checking and not necessary for auto-testing assert letter_queue(["PUSH A", "POP", "POP", "PUSH Z", "PUSH D", "PUSH O", "POP", "PUSH T"]) == "DOT", "dot example" assert letter_queue(["POP", "POP"]) == "", "Pop, Pop, empty" assert letter_queue(["PUSH H", "PUSH I"]) == "HI", "Hi!" assert letter_queue([]) == "", "Nothing"
以前同じような課題を解いたので、それと同様にといた。
前回は与えられた文字列(例えば"PUSH A")をstr.split() でわけてから判別していた。
以前の一位の人のコードでstartswithという便利な関数があることを知ったので、今回はそれを使って解いてみた。
pythonはpop()関数で、リストのどこからpopするかを指定することができる。今回はpop(0)で添字0つまり、先頭の要素をpopした。
popは要素がないのに、呼ばれた場合にはエラーを返すのでリストが空でないことは確かめなくてはならないというところで、一回つまづいた。
はやめにエラーだしてくれるのはpythonのいいところな気がします。
さすが、委員長キャラですわ…。
しかし、なぜjoinはstr.join(シーケンス)
ではなく、(シーケンス).join(str) なんだろう。なんか、スッキリしないなぁ…。
一位の人は
def letter_queue(commands): import collections queue = collections.deque() for command in commands: if command.startswith("PUSH"): queue.append(command[-1]) elif queue: queue.popleft() return "".join(queue)
pythonでキューを実装しようとしたら、collections.dequeを用いると良いみたいです。
Xs and Os Referee
Xs and Osとしても知られているTic-Tac-Toe(訳注:三目並べ)は二人のプレイヤー(XとO)が3x3のマスの空きマスに交代で書き込むゲームです。 水平、垂直、対角線の列(NW-SEとNE-SW)に自分のマークを3つ並べるのに成功したプレイヤーがゲームに勝ちます。
しかし我々はこのゲームをプレイしません。 あなたはこのゲームの結果の審判になってください。 ゲームの結果を与えられて、ゲームが勝利または引き分けで終わったのかと同時に誰が勝利者だったかを判定しなければいけません。 Xのプレイヤーが勝ったときは"X"を返し、Oのプレイヤーが勝ったときは"O"を返し、ゲームが引き分けのときは"D"を返すことを確実にしてください。
x-o-referee
ゲームの結果は文字列のリストとして表現されます、ここで"X"と"O"はプレイヤーのマークで"."は空きのマスです。
入力: あるゲームの結果、文字列のリスト (unicode)
出力: "X", "O" または "D"、文字列
例:
checkio([
"X.O",
"XX.",
"XOO"]) == "X"
checkio([
"OO.",
"XOX",
"XOX"]) == "O"
checkio([
"OOX",
"XXO",
"OXX"]) == "D"
どのように使われるか: このタスクのコンセプトは、データ型を繰り返すときにあなたの役に立つでしょう。 結果をチェックする方法を知ることをあなたに可能にすることで、ゲームのアルゴリズムにも使うことができます。
def checkio(game_result): for row in game_result: if row[0] == row[1] == row[2] and row[0] != ".": return row[0] if game_result[0][0] == game_result[1][0] == game_result[2][0] and game_result[0][0] != ".": return game_result[0][0] if game_result[0][1] == game_result[1][1] == game_result[2][1] and game_result[0][1] != ".": return game_result[0][1] if game_result[0][2] == game_result[1][2] == game_result[2][2] and game_result[0][2] != ".": return game_result[0][2] if game_result[0][0] == game_result[1][1] == game_result[2][2] and game_result[0][0] != ".": return game_result[0][0] if game_result[0][2] == game_result[1][1] == game_result[2][0] and game_result[0][2] != ".": return game_result[0][2] return "D" if __name__ == '__main__': #These "asserts" using only for self-checking and not necessary for auto-testing assert checkio([ "X.O", "XX.", "XOO"]) == "X", "Xs wins" assert checkio([ "OO.", "XOX", "XOX"]) == "O", "Os wins" assert checkio([ "OOX", "XXO", "OXX"]) == "D", "Draw" assert checkio([ "O.X", "XX.", "XOO"]) == "X", "Xs wins again" ||< 動きます。動くけど、あまりにも無駄が多すぎる。読んだら何してるか一瞬でわかるという意味では良いコードなのかもしれないけどね…。 さて、一位のコード >|python| def checkio(result): rows = result cols = map(''.join, zip(*rows)) diags = map(''.join, zip(*[(r[i], r[2 - i]) for i, r in enumerate(rows)])) lines = rows + list(cols) + list(diags) <200b> return 'X' if ('XXX' in lines) else 'O' if ('OOO' in lines) else 'D'
mapはシーケンスのすべての要素を関数の引数として実行し、その実行結果から新しいlistを作成する。
zipとenumerateは
forループで便利な zip, enumerate関数 » Python Snippets
ということらしい。
二重になっているリストを扱うときに便利な関数らしい。
python cookbook 3rd
タダで読めるとは知りませんでした。
英語苦手なんだけど、コード動かせば何をしようとしているのかわかるので少しずつ進めてます。