練習記録の画面に、実際より3割ぐらい時間が短く記録されるバグがあるみたいです。
なので、描いた合計時間が短くても気にしないでください。ごめんなさい。
「線を描いた時間」は特に短く表示されて、見るとやる気をなくすかもしれません。
open System | |
open System.Collections.Generic | |
let solve precision goods wmax = | |
let indices = | |
goods | |
|> List.zip [0..goods.Length - 1] | |
|> List.sortBy (fun(_, (w,v)) -> - v / w) | |
|> List.map fst | |
let ws, vs = goods |> Array.ofList |> Array.unzip |
;;;; library ;;;; | |
@iscript | |
f.kag = window.TYRANO.kag | |
f.replace = function (arr, v, d) { | |
arr.forEach(function(x) { if(x === v) d = x }) | |
return d } | |
f.extract = function(mp, arr, d) { | |
for(var x in mp) d = f.replace(arr, x, d) |
{-# LANGUAGE ScopedTypeVariables #-} | |
import qualified Data.IntSet as Set | |
import Data.List(foldl') | |
sieve n = step [2] (Set.fromList [3, 5 .. n]) | |
where | |
step ps cs = | |
case Set.minView cs of | |
Just (p, cs) -> |
open System.Collections.Generic | |
type Variable = A | B | C | D | E | F | G | |
type Quaternion = W | X | Y | Z | |
type Term = Quaternion * Variable list * float | |
type Number = Term list | |
let normalize (n:Number) = | |
let n = n |> List.map (fun (q, vs, m) -> (q, List.sort vs, m)) | |
let d = Dictionary() |
<div>problem5 (10) = <p id="a10"></p></div> | |
<div>problem5 (20) = <p id="a20"></p></div> | |
<script> | |
function problem5 (x) { | |
var primes = []; | |
for(i = 2; i < x; i++) { | |
var isPrime = true; | |
for(j = 0; j < primes.length; j++) { | |
if(i % primes[j] == 0) | |
isPrime = false; |
open System | |
let problem5 x = | |
let primes = ResizeArray() | |
for i in 2 .. x do | |
if primes |> Seq.forall(fun p -> i % p <> 0) then | |
primes.Add i | |
primes | |
|> Seq.map(fun p -> int(Math.Pow(float p, floor(Math.Log(float x, float p))))) | |
|> Seq.reduce (*) |
open MathNet.Numerics | |
type BigRational with | |
member __.s = | |
let n, d = __.Numerator, __.Denominator | |
sprintf "%Aと%A/%A" (n / d) (n % d) d | |
type Human = Y | M | |
type Point = A | B | C | D |
// 結果 | |
// 100000000回試行しました | |
// 自分は生き、他に0人が生きた回数は27902回で確率は0.027902%でした | |
// 自分は生き、他に1人が生きた回数は6924回で確率は0.006924%でした | |
// 自分は生き、他に2人が生きた回数は848回で確率は0.000848%でした | |
// 自分は生き、他に3人が生きた回数は87回で確率は0.000087%でした | |
// 自分は生き、他に4人が生きた回数は4回で確率は0.000004%でした | |
// 自分は生き、他に5人が生きた回数は0回で確率は0.000000%でした | |
// 自分は生き、他に6人が生きた回数は1回で確率は0.000001%でした | |
// 自分は生き、他に7人が生きた回数は0回で確率は0.000000%でした |
// 参考URL: http://www.fssnip.net/7U | |
// Async.FromContinuations: | |
// 成功後の継続、例外発生後の継続、キャンセル後の継続を引数を介して受け取れる非同期ワークフローを作る | |
// Async.StartWithContinuations: | |
// 非同期ワークフローを今のスレッドで実行する、成功後の継続、例外発生後の継続、キャンセル後の継続が受け取れる | |
let callcc (f: ('a -> 'b Async) -> 'a Async) : 'a Async = | |
Async.FromContinuations(fun (cont, econt, ccont) -> | |
Async.StartWithContinuations(f (fun a -> Async.FromContinuations(fun (_, _, _) -> cont a)), cont, econt, ccont)) |