DI(Dependency Injection)について
たまにDI不要論とかがネットで話題になったりしてて,ふわっとDIの考え方は知ってたんだけど実際にDIパターンみたいな実装をしたことなかったのでちょっと触ってみた.
続きを読むたまにDI不要論とかがネットで話題になったりしてて,ふわっとDIの考え方は知ってたんだけど実際にDIパターンみたいな実装をしたことなかったのでちょっと触ってみた.
続きを読む[SRM 598 div1 250]
容量300のビンがあります. 100-300の大きさのアイテムがリストで渡されます.
ビンにアイテムを詰めるために少なくとも何本のビンが必要でしょうか
(問題の原文は下にあります)
引数:
例:
アイテムのリスト (150,150,150,150,150)
容器数 3つ
実装の方針
(修正しました)
原文:
PROBLEM STATEMENT
Fox Ciel has some items. The weight of the i-th (0-based) item is item[i]. She wants to put all items into bins.
The capacity of each bin is 300. She can put an arbitrary number of items into a single bin, but the total weight of items in a bin must be less than or equal to 300.
You are given the tuple (integer) item. It is known that the weight of each item is between 100 and 300, inclusive. Return the minimal number of bins required to store all items.
DEFINITION
Class:BinPacking
Method:minBins
Parameters:tuple (integer)
Returns:integer
Method signature:def minBins(self, item):
CONSTRAINTS
-item will contain between 1 and 50 elements, inclusive.
-Each element of item will be between 100 and 300, inclusive.
一昨日からtopcoderという競技プログラミングの有名な大会の過去問(SRM)を解くのにハマってる
まだまだ自分のレベルだと解けないことも結構あるけど,
友達と競いながらやってみるとかなり楽しくて,他の人のコード解説してもらうと参考になるし,自分のコード晒すことでアドバイスがもらえて満足感あった(・∀・)
いつも誰かと時間を合わせてできるわけではないので一人で解いたりもしてて
ただ一人でやると誰からもアドバイスがもらえないのでもっと良い実装があるんじゃないかとモヤモヤする
というのが前置きで,
自分の実装をブログに載せることで,あわよくばレビューしていただけるんじゃないかという下心でtopcoderの回答を定期的に晒します.
こんな感じで動きました.
<?php $link = "http://piyopiyo.com" if($_SERVER["QUERY_STRING"] !== ""){ $link = $link.$_SERVER["QUERY_STRING"]; } header($link); exit; ?>
├── Gemfile ├── Gemfile.lock ├── config.ru ├── log │ ├── unicorn.stderr.log │ └── unicorn.stdout.log ├── myapp.rb ├── tmp │ ├── pids │ │ └── unicorn.pid │ └── sockets │ └── unicorn.sock └── unicorn.rb続きを読む