golf
permutater (http://golf.shinh.org/p.rb?permutater)が237Bになりました。よっしゃ。
ロジックを変えればまだまだ行けそう。
golf
Dancing Kids (http://golf.shinh.org/p.rb?Dancing+Kids)、170B。
using C=System.Console;class P{static void Main(){int l=C.ReadLine().Length;C.Write(@"{0}('-'){1} {2}|_|{3} | | ",l>4?"\\":" ",l==5?"":"/",l<5?"/":" ",l==5?"\\":"");}}
nattowさんが遠い……
golf
id:siokoshouさんやid:nattowさんに張り合っていますがなかなか敵いません。
tennis ( http://golf.shinh.org/p.rb?tennis ) も晒す。1位じゃないからね。
using C=System.Console;class P{static void Main(){int p=0,q=0;bool f=true;for(;f;){f=(C.ReadLine()=="1"?++p:++q)<7;C.WriteLine(p==q?"Set is tied at "+p:"Player"+(p>q?1:2)+(f?" leads ":" wins the set ")+(p>q?p:q)+" - "+(p>q?q:p));}}}
(追記)削ったら232Bが224Bになって1位になった。
(追記2)siokoshouさんが223Bを出したのに発奮して222B達成。3項演算子の?:が4個になりました。
(追記3)ギブアップ!もう抜けないだろう。というのも、for文の使い方やカンマ演算子の使い方以外はもう同じコードのようだから……と思ったんですが、まだ2B縮まる。
224Bは以下。fが消えました。
using C=System.Console;class P{static void Main(){int p=0,q=0,r=0;for(;r<7;){r=C.ReadLine()=="1"?++p:++q;C.WriteLine(p==q?"Set is tied at "+p:"Player"+(p>q?1:2)+(r<7?" leads ":" wins the set ")+(p>q?p:q)+" - "+(p>q?q:p));}}}
222Bは以下。
using C=System.Console;class P{static void Main(){int p=0,q=0,r=0;for(;r<7;){r=C.ReadLine()=="1"?++p:++q;r=p>q?p:q;C.WriteLine(p==q?"Set is tied at "+p:"Player"+(q/r+1)+(r<7?" leads ":" wins the set ")+r+" - "+(p+q-r));}}}
ということで、合作コード。
using C=System.Console;class P{static void Main(){for(int x=0,y=0,b=0;b<7;b=x>y?x:y,C.WriteLine(x==y?"Set is tied at "+x:"Player"+(y/b+1)+(b>6?" wins the set ":" leads ")+b+" - "+(x+y-b)))b=C.ReadLine()=="2"?y++:x++;}}
218B。
golf
smiley triangle
http://golf.shinh.org/p.rb?Smileys+Triangle
class P{static void Main(){string s=@": :- :-)";string t=@" :-)";while(t.Length<65)s+=(t+="))");System.Console.Write(s);}}
これで(改行をLFにして)122B。107Bとか、どうするんだ。
(追記)nattowさんのエントリに110Bのコードが。
iを使い、string変数を1つだけにしている。おもしろいなあ。
そういや上のコードは少し削れますね。
class P{static void Main(){string s=@": :- :-)",t="\n:-)";while(t.Length<65)s+=(t+="))");System.Console.Write(s);}}
それか、nattowさんのコードを参考に、sの初期化を少し変えて
class P{static void Main(){string s=":\n:-",t="\n:-)";do s+=t;while((t+="))").Length<67);System.Console.Write(s);}}
でも両方とも115B。sとtで攻めるのは厳しいかな。
golf
transpose lines ( http://golf.shinh.org/p.rb?transpose+lines ) で184B。楽しくなってきた。
(追記)174Bになったけど1位じゃない。晒し。
using C=System.Console;class P{static void Main(){string t=C.In.ReadToEnd();int i=0,j,w=t.IndexOf('\n');for(;i<w;){for(j=i++;j<t.Length;j+=w+1)C.Write(t[j]);C.WriteLine();}}}
(追記2)ループのロジックを変えて170Bになりました。
(追記3)ループを整理して163Bになりました。
WMI
現在の制限事項
現在のバージョンの System.Management.Instrumentation では、次の WMI 機能をサポートしていません。この制限事項はマネージ コードで実装されたオブジェクトにだけ適用されます。ネイティブ C++ WMI プロバイダを通じて公開されたオブジェクトではこれらの機能を公開でき、System.Management クラスを通じてマネージ コードからアクセスできます。
System.Management 名前空間と System.Management.Instrumentation 名前空間
- 実装されたオブジェクトは、書き込み可能なプロパティまたはメソッドを公開できません。
- 実装されたオブジェクトの修飾子の作成はサポートされていません。
- 実装されたオブジェクトのプロパティはキーとして定義できません。
にゃーす。これじゃstopできないじゃないか。
以下サンプル。実行前にInstallUtilでWMIに登録。ただし、InstallUtil /u してもWMIの登録は削除されない。なんじゃそりゃ。
using System; using System.Management.Instrumentation; using System.Threading; [assembly:Instrumented(@"root\FooBar\Counter")] [System.ComponentModel.RunInstaller(true)] public class MyInstaller : DefaultManagementProjectInstaller {} [InstrumentationClass(InstrumentationType.Instance)] public class Counter { volatile bool stop = false; volatile int counter = 0; public int Count { get {return counter;} } [IgnoreMember()] public void Service() { Instrumentation.Publish(this); while (!stop) { counter++; Thread.Sleep(10000); } Instrumentation.Revoke(this); } [IgnoreMember()] public static void Main() { Counter c = new Counter(); c.Service(); } }
wbemtest.exeでroot\FooBar\Counter名前空間のクラスを見てみたところ。