<commit_before>class StringFibonacciSequence: SequenceType {
  func generate() -> GeneratorOf<String> {
    var last = "0"
    var current = "1"
    
    return GeneratorOf<String> {
      let next = addStringInteger(last, current)
      last = current
      current = next
      return next
    }
  }
}

class Problem25: EulerProblem {
  override func run() {
    let seq = LimitSequence(sequence: StringFibonacciSequence()) { $1.length < 1000 }
    let items = Array(seq)
    let n = items.count
    // our fib sequence spits out the 3rd value the first time it is pumped, so we add 2
    println("fib(\(n+2)) is longer than 1000 digits")
  }
}

//
// Use JKBigInteger
//

class BigNumFibonacciSequence: SequenceType {
  func generate() -> GeneratorOf<JKBigInteger> {
    var last = JKBigInteger(string:"0")
    var current = JKBigInteger(string:"1")

    return GeneratorOf<JKBigInteger> {
      let next = last.add(current) as JKBigInteger
      last = current
      current = next
      return next
    }
  }
}

class Problem25BigNum: EulerProblem {
  // problem finished in 3.19666504859924 seconds
  override func run() {
    let fibSeq = BigNumFibonacciSequence()
    let limitSeq = LimitSequence(sequence: fibSeq) { ($1.stringValue() as NSString).length) < 1000 }
    let items = Array(limitSeq)
    // our fib sequence spits out the 3rd value the first time it is pumped, so we add 2
    println("fib(\(items.count+2)) is longer than 1000 digits")
  }
}

func thousandDigitBigNum() -> JKBigInteger {
  //
  // a = "1"
  // 999.times { a += "0" }
  //
<commit_msg>auto-commit on file save at 2015-01-02 00:47:35<commit_after>class StringFibonacciSequence: SequenceType {
  func generate() -> GeneratorOf<String> {
    var last = "0"
    var current = "1"
    
    return GeneratorOf<String> {
      let next = addStringInteger(last, current)
      last = current
      current = next
      return next
    }
  }
}

class Problem25: EulerProblem {
  override func run() {
    let seq = LimitSequence(sequence: StringFibonacciSequence()) { $1.length < 1000 }
    let items = Array(seq)
    let n = items.count
    // our fib sequence spits out the 3rd value the first time it is pumped, so we add 2
    println("fib(\(n+2)) is longer than 1000 digits")
  }
}

//
// Use JKBigInteger
//

class BigNumFibonacciSequence: SequenceType {
  func generate() -> GeneratorOf<JKBigInteger> {
    var last = JKBigInteger(string:"0")
    var current = JKBigInteger(string:"1")

    return GeneratorOf<JKBigInteger> {
      let next = last.add(current) as JKBigInteger
      last = current
      current = next
      return next
    }
  }
}

class Problem25BigNum: EulerProblem {
  // problem finished in 3.19666504859924 seconds
  override func run() {
    let fibSeq = BigNumFibonacciSequence()
    let limitSeq = LimitSequence(sequence: fibSeq) { ($1.stringValue() as NSString).length < 1000 }
    let items = Array(limitSeq)
    // our fib sequence spits out the 3rd value the first time it is pumped, so we add 2
    println("fib(\(items.count+2)) is longer than 1000 digits")
  }
}

func thousandDigitBigNum() -> JKBigInteger {
  //
  // a = "1"
  // 999.times { a += "0" }
  //

{'fraction_non_alphanumeric': 0.1100975149418056, 'fraction_numerical': 0.03711859075180875, 'mean_word_length': 2.925925925925926, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1338302', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1005, 'n_words': 306}