Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.{PrintWriter, FileWriter}
- import scala.annotation.tailrec
- import scala.io.StdIn
- object Main extends App {
- GenFilesFromWAP(StdIn.readInt,StdIn.readLine)
- }
- object GenFilesFromWAP{
- def apply(n:Int,output:String): Unit ={
- val wap = scala.io.Source.fromFile(new java.io.File( "." ).getCanonicalPath+"/ВИМ/ВИМ.txt","UTF-8").mkString
- @tailrec
- def f(i:Int,s:String,l:List[(Int,String)]=List()): List[(Int,String)] ={
- if(i==1) ((n-1,s)::l)
- else {
- val partL = scala.util.Random.nextInt(s.length/i)
- f(i-1,s.drop(partL),(n-i,s.take(partL))::l)
- }
- }
- for((i,s) <- f(n,wap)){
- val out = new PrintWriter(new FileWriter(s"$output/$i.txt"))
- out.print(s)
- out.close()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement