プログラミングのお題スレ Part22 (858レス)
プログラミングのお題スレ Part22 http://mevius.5ch.net/test/read.cgi/tech/1691038333/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
レス栞
6: デフォルトの名無しさん [sage] 2023/08/06(日) 19:07:03.27 ID:Md+pNxjw use std::io::{self, BufRead, BufReader}; const FULL_BITS: u32 = (1 << 26) - 1; fn main() { let mut shortest: Option<String> = None; for line in BufReader::new(io::stdin()).lines() { let line = line.unwrap(); let mut bits = 0; for b in line.as_bytes() { let index = match b { b'A'..=b'Z' => b - b'A', b'a'..=b'z' => b - b'a', _ => continue, }; bits |= 1 << index; } if bits != FULL_BITS { continue; } if let Some(ref shortest) = shortest { if shortest.len() < line.len() { continue; } } shortest = Some(line); } if let Some(shortest) = shortest { println!("{shortest}"); } else { eprintln!("ERROR: no matched lines"); } } http://mevius.5ch.net/test/read.cgi/tech/1691038333/6
35: デフォルトの名無しさん [] 2023/08/11(金) 17:25:08.27 ID:I5t9Gg6x 遅延評価は馴染みない人にはわからんからしょうがない http://mevius.5ch.net/test/read.cgi/tech/1691038333/35
209: デフォルトの名無しさん [sage] 2024/02/02(金) 22:48:33.27 ID:UezRkqGy >>206 ruby https://ideone.com/eF5lww f = -> a { w = a.map {|s| s.split('=')}.flatten.uniq.map.with_index.to_h a.each_with_object([]) {|s, acc| x, xa, y, ya = s.split('=').map {|k| [k, acc.find {|b| b.include? k}]}.flatten(1) if xa && ya then xa.concat (acc.delete ya) << x << y elsif xa then xa << x << y elsif ya then ya << x << y else acc << [x, y] end }.map {|a| a.uniq.sort_by {|s| w[s]}}.sort_by {|a| w[a[0]]} } http://mevius.5ch.net/test/read.cgi/tech/1691038333/209
280: デフォルトの名無しさん [sage] 2024/02/24(土) 00:25:03.27 ID:f2xn4abB >>234 Ruby https://paiza.io/projects/2G8vPQJQOBZecXPD5ZIFTQ?language=ruby http://mevius.5ch.net/test/read.cgi/tech/1691038333/280
319: デフォルトの名無しさん [] 2024/04/13(土) 11:43:17.27 ID:itq2kjOw ヘロンの公式を実装せよ 使用言語:C http://mevius.5ch.net/test/read.cgi/tech/1691038333/319
424: デフォルトの名無しさん [sage] 2024/09/04(水) 03:34:25.27 ID:k+9kMn3u REM zorome.bat ruby -x "%~f0" exit #~ #!ruby while 1 print "input a > " a=$stdin.gets.chomp exit if a=="" a=a.to_i print "input b > " b=$stdin.gets.to_i ar=(a..b).to_a z=0 ar.each{|e| n=e.to_s.gsub(/^-/,"") m=n.split("").uniq if n.size>1 && m.size==1 z=1 break end } ar=[] if z==1 p ar end __END__ a=0;b=10 => [0,1,2,3,4,5,6,7,8,9,10] a=0;b=11 => [] http://mevius.5ch.net/test/read.cgi/tech/1691038333/424
559: 警備員[Lv.20] [] 2025/02/11(火) 05:48:25.27 ID:Y4Uu1QjJ それはお題なのか?それともただの誤爆か? http://mevius.5ch.net/test/read.cgi/tech/1691038333/559
729: デフォルトの名無しさん [] 2025/04/02(水) 14:31:23.27 ID:vIYRPSqy >>725 変数名がa、b、cの時点でプロじゃねえな http://mevius.5ch.net/test/read.cgi/tech/1691038333/729
755: デフォルトの名無しさん [sage] 2025/04/12(土) 21:26:41.27 ID:csJOBVaF >>754 それに気づいたけど まだ>>750と比べて20倍遅いからメモ化の方針が徒となってるのかな http://mevius.5ch.net/test/read.cgi/tech/1691038333/755
809: デフォルトの名無しさん [] 2025/08/19(火) 21:08:19.27 ID:zFi0pntB >>799 問題A perl use v5.42; sub nthPermutation($digits, $rank) { my @figures = (1..$digits); my @fact = (1); push @fact, $_ * $fact[-1] for @figures; return join "", map { splice(@figures, $_, 1) } sub($n, $r) { $n-- ? (int($r / $fact[$n]), __SUB__->($n, $r % $fact[$n])) : (); }->($digits, $rank - 1); } for my $i (1, 2, 3, 123456, 234567, 362880) { say "$i -> " . nthPermutation(9, $i); } 1 -> 123456789 2 -> 123456798 3 -> 123456879 123456 -> 416589732 234567 -> 684753219 362880 -> 987654321 http://mevius.5ch.net/test/read.cgi/tech/1691038333/809
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
1.422s*