Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. object mainRun {
  2. def main(args: Array[String]): Unit = {
  3. val a = (new dataStr).take(45697600)
  4. a.grouped(100).grouped(1000).foreach(println)
  5. }
  6.  
  7. class dataStr extends Iterator[String] {
  8. private val itr: Iterator[BigInt] = Iterator.iterate(0:BigInt)(_ + 1)
  9. private val alpha = ('A' to 'Z').toList
  10. private val digits = ('0' to '9').toList
  11.  
  12. override def hasNext = true
  13. override def next = {
  14. val na = itr.next; val ca: Char = ('A' + na%26).toChar
  15. val nb = if(na/26 < 26) BigInt(0) else na/26; val cb: Char = ('A' + (na/26)%26).toChar
  16. val nc = nb/26; val cc: Char = digits(nc.toInt%10)
  17. val nd = nc/10; val cd: Char = ('A' + ((nc/10)%26)).toChar
  18. val ne = nd/26; val ce: Char = digits(ne.toInt%10)
  19. val nf = ne/10; val cf: Char = ('A' + (ne/10)%26).toChar
  20. s"$cf$ce$cd$cc$cb$ca"
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement