Skip to main content
2 of 2
added 73 characters in body
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13

Scala, 56 bytes

Golfed version. Try it online!

def c(i:Int)=for(_<-1 to i){print(if(i%2<1)"\\"else"/")}

Ungolfed version. Try it online!

object M {
  implicit class IntExtensions(val i: Int) extends AnyVal {
    def times[T](f: => T): Unit = {
      for (_ <- 1 to i) {
        f
      }
    }
  }
  //def c(i:Int)=print(Iterator.fill(i)(if(i%2<1)"\\"else"/").mkString)
  //def c(i:Int)=Iterator.fill(i)(if(i%2<1)"\\"else"/").foreach(print)
  def c(i: Int) = i.times { print(if (i % 2 < 1) "\\" else "/") }
  def main(args: Array[String]): Unit = {
    for (i <- 0 until 10) {
      c(i)
      println()
    }
  }
}
138 Aspen
  • 6.6k
  • 1
  • 4
  • 13