2011-01-01ãã1å¹´éã®è¨äºä¸è¦§
çé¸ãããå ¨ãçµãããªãã£ãã main = print $ p p = map (d.(10^)) [0..6] d x = (g 190000)!!(x-1) g x = foldl f "" [1..x] where f x y = x++(show y)ã¡ãã£ã¨ã«ã³ãã³ã°ãã¦ä»¥ä¸ã Prelude Data.Char> product [digitToInt $ ([0..] >>= show) !! x |â¦
ã¾ãããã®ã¾ã¾ã sortByãªãmaximumByãªããData.Ordã®comparingã使ããªãã¨ãããªãã®ãrubyã¨æ¯è¼ãã¦é¢å import Data.List import Data.Ord main = print $ p p = maximumBy (comparing length) $ group $ sort [x+y+z|x<-[1..998],y<-[x..998-x],z<-[â¦
ãã³ãã¸ã¿ã«æ°ã«ãªãã®ã¯ å°ãªãã¨ãn é£çµãããæ°ã¯n=2ã®ã¨ããæåã4æ¡ã¨æ¬¡ã5æ¡ã«ãªãã®ã§ 4999 import Data.List main = print $ maximum $concat $ map g [9..9999] f::Int->Int->Int f x y = read $foldl (++) [] $map show $zipWith (*) [x,x..] [â¦
primesã¨tailsã使ã£ãã®ã§æ¥½ã«ã§ããã Prelude Data.List Data.Numbers.Primes> let f x= all (isPrime.read) $ filter (/=[]) $ tails (show x) ++ (map reverse (tails (reverse (show x)))) in sum $ take 11 [x|x<-primes,x>10,f x] 748317 it :: Inteâ¦
åºæ°å¤æãããµãã Prelude> let d2b x = if (div x 2)/=0 then (d2b (div x 2))++[mod x 2] else [mod x 2] in sum [x|x<-[1..1000000],show x==reverse (show x),d2b x==reverse (d2b x)] 872187 it :: Integer (1.20 secs, 877606456 bytes)
ãã¼ãã¼ãé¢æ°ãè¦ã¤ãããªãã£ãã®ã§èªä½ Prelude Data.Numbers.Primes> let g (x,y) = y++x ;f::Int->[Int];f x = map (read.g.(`splitAt` (show x))) [1..((length.show) x)-1] in length [x|x<-[1..1000000],isPrime x,all isPrime $ f x] 55 it :: Intâ¦
ãªãï¼æ¡ä»¥å ããè¨ãã¦ããªãã Prelude List> let f x=foldr (*) 1 [1..x]; g x=x==(sum $ map (f.read.(:[])) $show x) in sum [x|x<-[3..100000],g x] 40730 it :: Integer (5.22 secs, 3383707256 bytes)
ãã¾ãã¡ç¾ãããªãã Prelude List> let f a b c d = ((a==c && (a*10+b)/(c*10+d)==b/d)||(a==d&&(a*10+b)/(c*10+d)==b/c)||(b==c&&(a*10+b)/(c*10+d)==a/d)||(b==d&&(a*10+b)/(c*10+d)==a/c))&&(b/=0&&d/=0)&&(a/=c&&b/=d) in map product $ transpose [[â¦
chsh -s ã使ç¨ããã«ãã°ã¤ã³æã®ã·ã§ã«ãå¤ããzshã«å¤ããããªãã¨ã.bash_loginã«ä»¥ä¸ãè¿½è¨ if [ -f /bin/zsh ]; then exec zsh ; fiããã ã¨zshã®ç¡ããã·ã³ã§ãå®å¿.screenrcã«ä»¥ä¸ãè¿½è¨ shell zsh
rubyã® car,cdr ããã㯠haskellã«ããã head tail last initã«ã¤ãã¦haskellã«ããã head tail lastã¯ãããã >> [1, 2, 3, 4, 5].first => 1 >> [1, 2, 3, 4, 5].drop(1) => [2, 3, 4, 5] >> [1, 2, 3, 4, 5].last => 5ã ã¨ããããã§ããªããinitï¼æâ¦
String.scan(re){ãããã¯}ãstringãè¿ãã®ã§Stringãªãã¸ã§ã¯ããæ¡å¼µããã class String def scanA(exp) # scan(re)ãããã¯ç¡ãã¨åã r=[] scan(exp){|i|r.push(yield i)} r end endããããããããã¯ãªãã®scan(re)ã¯è¿ãå¤ãé åã ã£ãorz >> "abcdâ¦
sudoã§ãã¡ã¤ã«ã«è¿½è¨ããã¨ã $ sudo echo aaa >> aãã¼ããã·ã§ã³ããªãã¨ãã¨ã©ã¼ã«ãªã£ã¦ãã¾ãã®ã§ããããæã«ã¯ sudo tee -aã使ã $ echo aaa >> sudo tee -a a
terminalã«ã¦ç»åã表示ãã ã«ã©ã¼ã§è¡¨ç¤º % sudo apt-get install caca-utils % img2txt -W `tput cols` ubuntu_logo_blue.pngtputã«ã¦terminfoãã端æ«ã®è¡¨ç¤ºå¹ ãåå¾ãã¦ããã ã¡ãªã¿ã« è¡æ°ã¯lines ã¢ãã¯ãã§è¡¨ç¤º % sudo apt-get install imagemagick â¦
rubyã§uniq -cããã >> [1,2,2,1,2,3,4,2,1,2,4,3,1,3].inject(Hash.new(0)){|r,i|r[i]+=1;r} => {1=>4, 2=>5, 3=>3, 4=>2}æå¾ã«rãè©ä¾¡ããã®ã§ã¯ã¾ã£ãã >> {1=>2}[1]+=1 => 3ã ãããªâ¦å¥è§£ >> [4,1,2,2,1,2,3,4,2,1,2,4,3,1,3].group_by{|i|i}.map{|k,â¦
大éãã¡ã¤ã«ãæä½ããã¨ãã«ã¯ for㯠inã®å¾ãå±éãã¦ããåä½ããããã«å°ã£ã¦ããwhileã¨readãçµã¿åãããã° é¢æ°åè¨èªã®mapã®ããã«åä½ããã $ seq 1 10 | while read i ; do echo $(($i+2)) ; done | while read i ; do echo $(($i*2)) ; doneã¾â¦
ãªã¢ã¼ããã¹ã¯ããããæä½ããã¨ãã« ãã¹ã¯ã¼ãå ¥åãã¦ãã¾ãã¨ãªã¢ã¼ãããã®vncãã°ã¤ã³æã«ãã¹ã¯ã¼ãå ¥åå¾ã«ããã¹ã¯ã¼ããå ¥åãã¦ãã°ã¤ã³ã®ãã¼ãªã³ã°ã®ããã¯ã解é¤ãã¦ãã ãããã¨èããã¦ãã¾ãããããåé¿ããããã«ã¯ããã¹ã¯ã¼ãã¨æå·â¦
centOS5.5ã§puttyã«ã¦loginããéã«screenãåæèµ·åããã¨æ¼¢åãåããã¨ãputtyã§ã®loginæã«screen -xRãç«ã¡ãããã¨æä½ãããã便å©ãªã®ã ãcentOSã§ã¯æ¼¢åãåãã¦ããã ããã§screen -xRUã¨Uãªãã·ã§ã³ãæå®ããã¨åããªãããã«ãªããã¡ãªã¿ã«yumâ¦
kvm qemuã«ã¦ ã²ã¹ãã§ããwindowsããããã¹ãä¸ã®sambaããã¦ã³ãããã«ã¯ /etc/samba/smb.confã«ä»¥ä¸ã追å [mountpoint] comment = mountpoint path = /tmp/mountpoint guest ok = yesã²ã¹ãä¸ã®windowsããã¯ãã¹ã㯠10.0.2.2ãªã®ã§ ã¾ãcmd㧠ping 10â¦
ubuntu 10.10 ã«ã¦ capslock ã ctrlã«ããã ã¤ã¾ããcapsãctrlã両æ¹ctrlãã¼ã«ããã«ã¯ã·ã¹ãã ->è¨å®->ãã¼ãã¼ãã«ã¦ãªãã·ã§ã³ãã¯ãªãã¯ãctrlãã¼ã®ä½ç½®ã«ã¦ Make CapsLock an additional Ctrlãé¸æwin7ã http://d.hatena.ne.jp/kkomiyama/200912â¦
rubyã§ã® $ echo -e "abcde\nfghij\nklmn" | ruby -e 'puts STDIN.read(10)' abcde fghiãããããããã£ãperlã§ã¯readãå©ç¨ãã¦ä»¥ä¸ã®ããã«æ¸ã $ echo -e "abcde\nfghij\nklmn" | perl -e 'read(STDIN,$a,10);print $a,"\n"' abcde fghi
puttyãgnome-terminalã®ã¦ã¤ã³ãã¦ã¿ã¤ãã«ãã¼ã«screenã®IDãåºãããã«ã¯~/.screenrcã«ä»¥ä¸ãè¨è¿°ããã°ãã hardstatus string "[screen %n%?: %t%?] %h"ä¸ç¬ãtermcapãçã£ãããããªãã¨ã¯ãªãã£ãã ã㨠http://kjirou.sakura.ne.jp/mt/2008/08/scrâ¦