Sort by

recency

|

33 Discussions

|

  • + 0 comments

    Never posted one of these so sorry if the formatting isn't right but I didn't see a clojure solution yet so here is mine below.(def my_func (memoize (fn [n] (condp = n 0 0 1 1 2 1 (mod (+ (my_func (dec n)) (my_func (- n 2))) 100000007))))) (def a (Integer/parseInt (read-line))) (doseq [a-itr (range a)] (println (my_func (Integer/parseInt (read-line)))) )

  • + 0 comments

    had to write it in a REPL

    import Control.Monad
    
    nthFib i = let fib = 0 : 1 : zipWith (+) fib (tail fib) in (fib !! i)
    main = getLine >>= (`replicateM_` (getLine >>= print . (`mod` 100000007) . nthFib . read)) . read
    
  • + 0 comments

    f# my first attempt hand with made cache no modulo property used: (a + b) % n = ((a % n) + (b % n)) % n.

    open System
    open System.Collections.Generic
    
    let rec fib =
        let dict = new Dictionary<_, _>()
    
        fun n ->
            match dict.TryGetValue(n) with
            | true, v -> v
            | false, _ ->
                let temp =
                    if n = 0I then 0I
                    elif n = 1I then 1I
                    else fib (n - 1I) + fib (n - 2I)
    
                dict.Add(n, temp)
                temp
    
    [ 1 .. Console.ReadLine() |> int ]
    |> List.iter (fun _ ->
        Console.ReadLine()
        |> int
        |> bigint
        |> fib
        |> (fun x -> x % 100000007I)
        |> string
        |> Console.WriteLine)
    
  • + 0 comments

    memoized_fib :: Int -> Integer memoized_fib = (map fib [0 ..] !!) where fib 0 = 0 fib 1 = 1 fib n = memoized_fib (n-2) + memoized_fib (n-1)

    mymod :: Integer -> Integer mymod x = mod x ((10^8) + 7)

    atoi :: String -> Int atoi = read

    main = interact $ unlines . map (show. mymod) . map memoized_fib . map atoi . tail .lines

  • + 0 comments

    This help me a lot in making multiple bills functions. duplicatebills.com lesco bill online check(wapda bill online check) page. If you are a Citizen of the internationally famous city its surrounding cities then you are on the right website. Here you will find an easy method to check your lesco bill online and lots of useful information and latest news related to lesco.