入力 The quick brown fox jumps over a lazy dog. The jay, pig, fox, zebra and my wolves quack! Pack my box with seven dozen liquor jugs. The horse, pig, fox, zebra and my wolves quack! Jackdaws love my small sphinx of quartz. Jackdaws love my big sphinx of quartz. The quick brown fox jumps over a lazy cat. Pack my box with five dozen liquor jugs.
出力 Jackdaws love my big sphinx of quartz. 0004デフォルトの名無しさん2023/08/06(日) 17:47:37.64ID:RhhSFLLO>>3 Kotlin https://paiza.io/projects/cmJpXwaAhFH6jYozb0bb2g0005デフォルトの名無しさん2023/08/06(日) 18:08:09.04ID:RhhSFLLO>>3 C https://paiza.io/projects/McLPuKlM4c-1C9EgarDGjw0006デフォルトの名無しさん2023/08/06(日) 19:07:03.27ID: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"); } } 0007デフォルトの名無しさん2023/08/06(日) 20:04:54.35ID:pJXl8PQk>>3 R https://ideone.com/ZdKsPa0008デフォルトの名無しさん2023/08/07(月) 01:25:47.55ID:dolrRGoi>>6 それなんて言語? 000992023/08/07(月) 01:46:18.23ID:PMO8D1QO>>3 Perl5
for (<DATA>) { my %h = map{$_ => 1} grep{/[a-z]/i} split ''; push @a, $_ if 26 == keys %h; } @s = sort{length($a) <=> length($b)} @a; print $s[0]; __DATA__ The quick brown fox jumps over a lazy dog. The jay, pig, fox, zebra and my wolves quack! Pack my box with seven dozen liquor jugs. The horse, pig, fox, zebra and my wolves quack! Jackdaws love my small sphinx of quartz. Jackdaws love my big sphinx of quartz. The quick brown fox jumps over a lazy cat. Pack my box with five dozen liquor jugs.
※ 見易くするためインデントを全角スペースに置換してあります。
実行結果:
$ perl 22_3_az26.pl Jackdaws love my big sphinx of quartz. 0010デフォルトの名無しさん2023/08/07(月) 01:57:03.56ID:PMO8D1QO>>9 ゴメン、2行目に間違いあり…orz
my %h = map{$_ => 1} grep{/[a-z]/i} split ''; ↓正しくは my %h = map{$_ => 1} map{lc} grep{/[a-z]/i} split '';
>>3 Perl5 use List::Util 'first'; for (<DATA>) { my %h = map{lc $_ => 1} /([A-Za-z])/g; $a[length $_] = $_ if 26 == keys %h; } print first{defined} @a; __DATA__ The quick brown fox jumps over a lazy dog. The jay, pig, fox, zebra and my wolves quack! Pack my box with seven dozen liquor jugs. The horse, pig, fox, zebra and my wolves quack! Jackdaws love my small sphinx of quartz. Jackdaws love my big sphinx of quartz. The quick brown fox jumps over a lazy cat. Pack my box with five dozen liquor jugs.
実行結果 ~ $ perl 22_3_az26_a.pl Jackdaws love my big sphinx of quartz. 0027デフォルトの名無しさん2023/08/11(金) 02:52:08.14ID:45O+1i6X そう、haskellの評価戦略はcall by need (の一種) で必要に応じて展開される、head . sort では 「sortした後の最初の項」を求めているのでそれを出すための必要最小限の事しかしない
fn common_next(start_year: u32, is_before: bool) -> Option<u32> { let mut day = 0; let mut year = start_year; while year > 0 { if is_before { year -= 1; } day += 1 + leap(year); if day >= 7 { day -= 7; } if !is_before { year += 1; } if day == 0 && leap(year) == leap(start_year) { return Some(year); } } None }
fn main() { let n = 10; for year in [2000, 2023, 2024, 2025, 2100] { println!("{year}年より前: {:?}", SameCalendarYear(year).rev().take(n).collect::<Vec<_>>()); println!("{year}年より後: {:?}", SameCalendarYear(year).take(n).collect::<Vec<_>>()); } }
fn len_of_eq(s: &str, index: usize, even: usize) -> usize { let mut len = 0; for (p, q) in std::iter::zip(s[(index + even)..].chars(), s[0..=index].chars().rev()) { if p != q { break; } len += 1; } return len; }
fn print_kaibun(s: &str) { for index in 0..s.len() { for even in 0..=1 { for len in 1..=len_of_eq(s, index, even) { let first = index + 1 - len; let last = index + len - 1 + even; println!("{first}~{last}: {}", &s[first..=last]); } } } }
kaku = ".mp4" fn = "abc" main = do files <- glob (fn <> "*" <> kaku) zipWithM_ (\a b -> renameFile a b) files (map f files) where f l = let r1 = reverse $ takeWhile ((/=) '/') $ reverse l in let r2 = (r1 \\ fn) \\ kaku in fn <> printf "%03d" (read r2 :: Int) <> kaku 0088デフォルトの名無しさん2023/09/22(金) 11:23:46.58ID:R2SvRL0Z お題:celeronで快適に動作するwebブラウザを作れ 008992023/09/22(金) 16:53:16.55ID:8M97O6g7>>85 Perl5
rename "abc$_.mp4", sprintf 'abc%03d.mp4',$_ for 1..20;
s = input() s = s.replace("、", ",") s = s.replace("。", "\n") print(s) 0099デフォルトの名無しさん2023/09/27(水) 13:01:54.91ID:9Ywamwi5 Haskell
import Data.List.Utils
main = do s <- getContents putStrLn $ replace "。" "\n" $ replace "、" "," s コンパイルはしてないので動かないかも 0100デフォルトの名無しさん2023/09/27(水) 20:48:13.39ID:hJUMqAFS>>97 R https://ideone.com/syZ9JI