Post History
Scala, 119 bytes Saved 26 bytes after porting Moshi's solution! _ sortBy("y gree br sc bla oc pe rub ol v f li go ch m cre c s ro a l ru g pu w p o b"split " "indexWhere _.startsWith) Original...
Answer
#7: Post edited
# Scala, <s>145</s> 130 bytes- Saved 15 bytes after looking at [Moshi](https://codegolf.codidact.com/users/53196)'s [solution](https://codegolf.codidact.com/posts/283376/283383#answer-283383)!
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,h,ac,b,iv,ol,w,la,ld,o,uv,ea,im,l,se,ur,m,s,e,r,i,n,a,u"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/n8cyjLAVRjy3wAso4yQTrQ)
- It turns out that after dropping the first 2 letters, the first 2 letters after that (and in some cases 1 or 3) are enough to identify colors.
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
- # Scala, 119 bytes
- Saved 26 bytes after porting [Moshi](https://codegolf.codidact.com/users/53196)'s [solution](https://codegolf.codidact.com/posts/283376/283383#answer-283383)!
- ```scala
- _ sortBy("y gree br sc bla oc pe rub ol v f li go ch m cre c s ro a l ru g pu w p o b"split " "indexWhere _.startsWith)
- ```
- ## Original solution, <s>145</s> 130 bytes
- Saved 15 bytes after looking at [Moshi](https://codegolf.codidact.com/users/53196)'s [solution](https://codegolf.codidact.com/posts/283376/283383#answer-283383)!
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,h,ac,b,iv,ol,w,la,ld,o,uv,ea,im,l,se,ur,m,s,e,r,i,n,a,u"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/n8cyjLAVRjy3wAso4yQTrQ)
- It turns out that after dropping the first 2 letters, the first 2 letters after that (and in some cases 1 or 3) are enough to identify colors.
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
#6: Post edited
# Scala, 145 bytes- ```scala
_ sortBy("d,ll,ee,ow,ar,ack,hr,ach,b,iv,ol,wn,la,ld,oco,uve,eam,im,lv,se,ur,m,ss,ey,rp,it,nk,an,ue"split ","indexWhere _.substring(2).startsWith)- ```
[Try it in Scastie!](https://scastie.scala-lang.org/lNNNJjFhRo2XLVVrBNWhxA)- It turns out that after dropping the first 2 letters, the first 2 letters after that (and in some cases 1 or 3) are enough to identify colors.
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
- # Scala, <s>145</s> 130 bytes
- Saved 15 bytes after looking at [Moshi](https://codegolf.codidact.com/users/53196)'s [solution](https://codegolf.codidact.com/posts/283376/283383#answer-283383)!
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,h,ac,b,iv,ol,w,la,ld,o,uv,ea,im,l,se,ur,m,s,e,r,i,n,a,u"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/n8cyjLAVRjy3wAso4yQTrQ)
- It turns out that after dropping the first 2 letters, the first 2 letters after that (and in some cases 1 or 3) are enough to identify colors.
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
#5: Post edited
- # Scala, 145 bytes
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,hr,ach,b,iv,ol,wn,la,ld,oco,uve,eam,im,lv,se,ur,m,ss,ey,rp,it,nk,an,ue"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/lNNNJjFhRo2XLVVrBNWhxA)
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
- # Scala, 145 bytes
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,hr,ach,b,iv,ol,wn,la,ld,oco,uve,eam,im,lv,se,ur,m,ss,ey,rp,it,nk,an,ue"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/lNNNJjFhRo2XLVVrBNWhxA)
- It turns out that after dropping the first 2 letters, the first 2 letters after that (and in some cases 1 or 3) are enough to identify colors.
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
#4: Post edited
# Scala, 171 bytes- ```scala
_ sortBy("d,llow,een,own,arlet,ack,hre,ach,by,ive,olet,wn,lac,ld,ocolate,uve,eam,imson,lver,se,ure,mon,sset,ey,rple,ite,nk,ange,ue".split(",")indexWhere _.substring(2).==)- ```
[Try it in Scastie!](https://scastie.scala-lang.org/agliQBgdRTGjkJcOvDLRaQ)- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
indexWhere //And find the index of_.substring(2).== //The current string with the 1st 2 chars removed- )
- ```
- # Scala, 145 bytes
- ```scala
- _ sortBy("d,ll,ee,ow,ar,ack,hr,ach,b,iv,ol,wn,la,ld,oco,uve,eam,im,lv,se,ur,m,ss,ey,rp,it,nk,an,ue"split ","indexWhere _.substring(2).startsWith)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/lNNNJjFhRo2XLVVrBNWhxA)
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index where
- _.substring(2) //The current string with the 1st 2 chars removed
- .startsWith //Starts with that color prefix
- )
- ```
#3: Post edited
- # Scala, 171 bytes
- ```scala
- _ sortBy("d,llow,een,own,arlet,ack,hre,ach,by,ive,olet,wn,lac,ld,ocolate,uve,eam,imson,lver,se,ure,mon,sset,ey,rple,ite,nk,ange,ue".split(",")indexWhere _.substring(2).==)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/agliQBgdRTGjkJcOvDLRaQ)
Explanation coming soon.
- # Scala, 171 bytes
- ```scala
- _ sortBy("d,llow,een,own,arlet,ack,hre,ach,by,ive,olet,wn,lac,ld,ocolate,uve,eam,imson,lver,se,ure,mon,sset,ey,rple,ite,nk,ange,ue".split(",")indexWhere _.substring(2).==)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/agliQBgdRTGjkJcOvDLRaQ)
- ```scala
- _ sortBy( //Sort the input by this function:
- "..." //Take the comma separated string of colors
- .split(",") //Split on commas
- indexWhere //And find the index of
- _.substring(2).== //The current string with the 1st 2 chars removed
- )
- ```
#2: Post edited
# Scala, 198 bytes- ```scala
"red,yellow,green,brown,scarlet,black,ochre,peach,ruby,olive,violet,fawn,lilac,gold,chocolate,mauve,cream,crimson,silver,rose,azure,lemon,russet,grey,purple,white,pink,orange,blue" split ","filter _- ```
[Try it in Scastie!](https://scastie.scala-lang.org/r6aoA9GAQGW2dzZCBpkgxw)Very simple.
- # Scala, 171 bytes
- ```scala
- _ sortBy("d,llow,een,own,arlet,ack,hre,ach,by,ive,olet,wn,lac,ld,ocolate,uve,eam,imson,lver,se,ure,mon,sset,ey,rple,ite,nk,ange,ue".split(",")indexWhere _.substring(2).==)
- ```
- [Try it in Scastie!](https://scastie.scala-lang.org/agliQBgdRTGjkJcOvDLRaQ)
- Explanation coming soon.
#1: Initial revision
# Scala, 198 bytes ```scala "red,yellow,green,brown,scarlet,black,ochre,peach,ruby,olive,violet,fawn,lilac,gold,chocolate,mauve,cream,crimson,silver,rose,azure,lemon,russet,grey,purple,white,pink,orange,blue" split ","filter _ ``` [Try it in Scastie!](https://scastie.scala-lang.org/r6aoA9GAQGW2dzZCBpkgxw) Very simple.