Sort by

recency

|

32 Discussions

|

  • + 0 comments

    Searching for a pattern in a compressed file traditionally involves uncompressing the file on-the-fly and performing a regular search. On occasion it will be possible to compress the search pattern instead and to search for the compressed pattern in the compressed file. When possible, this is a double win since compressing the smaller search pattern is quicker than decompressing the file, and the pattern-matching itself is quicker as search-time is proportional to the file-size

  • + 1 comment

    f# solution

    open System
    
    let rec find res left right =
        match (left, right) with
        | ([], rs) -> [ List.rev res; []; rs ]
        | (ls, []) -> [ List.rev res; ls; [] ]
        | (l :: ls, r :: rs) when l = r -> find (l :: res) ls rs
        | (l :: _, r :: _) when l <> r ->
            [ List.rev res; left; right ]
    
    [<EntryPoint>]
    let main _ =
        let left = Console.ReadLine() |> Seq.map string |> List.ofSeq
        let righ = Console.ReadLine() |> Seq.map string |> List.ofSeq
    
        find [] left righ
        |> List.map (fun results ->
            (results |> List.length |> string)
            + " "
            + (results |> String.concat ""))
        |> List.map Console.WriteLine
    
        0
    
  • + 0 comments

    Searching for a pattern in a compressed file traditionally involves uncompressing the file on-the-fly and performing a regular search. On occasion it will be possible to compress the search pattern instead and to search for the compressed pattern in the compressed file. When possible, this is a double win since compressing the smaller search pattern is quicker than decompressing the file, and the pattern-matching itself is quicker as search-time is proportional to the file-size. https://wordmaker.info/how-many/prefix.html

  • + 0 comments

    What is data compression in data warehouse? wazifa to make someone do what you want

  • + 0 comments

    use list to solve this problem in fsharp

    let main argv =
    	let s1 = System.Console.ReadLine() |> Seq.toList
    	let s2 = System.Console.ReadLine() |> Seq.toList
    	let pps (ss:List<char>) =
    		ss |> System.String.Concat
    			|> (fun s ->
    				if s.Length <= 0 then
    					printfn "0"
    				else
    					printfn "%d %s" s.Length s)
    
    	let zips =
    		( (if s1.Length < s2.Length then (s1 @ [for i in 1..(s2.Length-s1.Length) do yield System.Char.MinValue]) else s1),
    			(if s1.Length > s2.Length then (s2 @ [for i in 1..(s1.Length-s2.Length) do yield System.Char.MinValue]) else s2))
    		||> Seq.zip
    	zips
    		|> Seq.takeWhile (fun (c1,c2) -> c1 = c2)
    		|> Seq.map fst
    		|> Seq.toList
    		|> pps
    
    	zips
    		|> Seq.skipWhile (fun (c1,c2) -> c1 = c2)
    		|> Seq.fold (fun (o1,o2) (c1,c2) ->
    			((if c1=System.Char.MinValue then o1 else c1::o1),
    				(if c2=System.Char.MinValue then o2 else c2::o2)))
    			([], [])
    		|> (fun (o1, o2) ->
    			o1 |> List.rev |> pps
    			o2 |> List.rev |> pps)