#Scala, (削除) 491 (削除ここまで) 477 chars, (削除) 491 (削除ここまで) 477 bytes
Scala, (削除) 491 (削除ここまで) 477 chars, (削除) 491 (削除ここまで) 477 bytes
This challenge was fun; thanks.
var c=Seq("O","B","b","R")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : 14 bytes saved thanks to comments, I take O B b R for ORANGE BLACK BLUE RED.
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, (削除) 491 (削除ここまで) 477 chars, (削除) 491 (削除ここまで) 477 bytes
This challenge was fun; thanks.
var c=Seq("O","B","b","R")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : 14 bytes saved thanks to comments, I take O B b R for ORANGE BLACK BLUE RED.
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
Scala, (削除) 491 (削除ここまで) 477 chars, (削除) 491 (削除ここまで) 477 bytes
This challenge was fun; thanks.
var c=Seq("O","B","b","R")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : 14 bytes saved thanks to comments, I take O B b R for ORANGE BLACK BLUE RED.
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, (削除) 493491 (削除ここまで) 491477 chars, (削除) 493491 (削除ここまで) 491477 bytes
This challenge was fun; thanks.
var c=Seq("ORANGE""O","BLACK""B","BLUE""b","RED""R")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : 14 bytes saved thanks to comments, I take O B b R for ORANGE BLACK BLUE RED.
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, (削除) 493 (削除ここまで) 491 chars, (削除) 493 (削除ここまで) 491 bytes
This challenge was fun; thanks.
var c=Seq("ORANGE","BLACK","BLUE","RED")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, (削除) 491 (削除ここまで) 477 chars, (削除) 491 (削除ここまで) 477 bytes
This challenge was fun; thanks.
var c=Seq("O","B","b","R")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if t.forall(_._1==x)=>true
case _ if t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : 14 bytes saved thanks to comments, I take O B b R for ORANGE BLACK BLUE RED.
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, 493(削除) 493 (削除ここまで) 491 chars, 493(削除) 493 (削除ここまで) 491 bytes
This challenge was fun; thanks.
var c=Seq("ORANGE","BLACK","BLUE","RED")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if(t.forall(_._1==x))=>true
case _ if(t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3)))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs
#Scala, 493 chars, 493 bytes
This challenge was fun; thanks.
var c=Seq("ORANGE","BLACK","BLUE","RED")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ if(t.forall(_._1==x))=>true
case _ if(t.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3)))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
#Scala, (削除) 493 (削除ここまで) 491 chars, (削除) 493 (削除ここまで) 491 bytes
This challenge was fun; thanks.
var c=Seq("ORANGE","BLACK","BLUE","RED")
t match{case _ if t.length<3=>false
case _ if t.exists(x=>x._1==0)=>{var b=false
if(t.filter(q=>q._1!=0).exists(q=>q._1==0))b else{for(y<-1 to 13)for(u<-c)b=b|f(t.takeWhile(q=>q._1!=0)++:(y,u)+:t.reverse.takeWhile(q=>q._1!=0).reverse)
b}}
case _::(x,_)::_ ift.forall(_._1==x)=>true
case _ ift.forall(_._2==c(0))|t.forall(_._2==c(1))|t.forall(_._2==c(2))|t.forall(_._2==c(3))=>(t(0)._1 to t(0)._1+t.length-1).toList equals t.map(_._1)
case _=>false}
So f at line 4 is a recursive call where I try replacing "JOKER" by every other tile. See tio for a clearer view of the code.
I chose taking as input a sequence of 2-tuples (Int,String) - called t in my code, see tio - so "JOKER" is represented by a 2-tuple (0,"JOKER").
EDIT : -2 bytes, deleted useless ( around conditions of the case _ ifs