Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Test if a string can be made with substrings!
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
with s as( select n,s from(values(1,'Hello, world!'), (2,'la lal al '), (3,'this is a string'), (4,'thi is a string'), (5,'aaaaa'), (6,'foo bar foobar'), (7,'ababab'), (8,''))s(n,s)), l as( select n,l from(values(1,'l'),(1,'He'),(1,'o, wor'),(1,'d!'), (2,'la'),(2,' l'),(2,'al '), (3,'this should return falsy'), (4,'this'),(4,'i i'),(4,' a'),(4,' string'), (5,'aa'), (6,'foo'),(6,'bar'),(6,' '),(6,'spam'), (7,'a'),(7,'ba'),(7,'ab'), (8,'The string can be constructed with nothing!'))l(n,l)), --The solution starts from the next line. u as( select s.n, s collate Latin1_General_BIN s, l collate Latin1_General_BIN l, row_number()over(partition by l.n order by len(l)desc)r from s,l where s.n=l.n), v as( select n,s,l,replace(s,l,'')c,r from u where r=1 union all select u.n,u.s,u.l,replace(v.c,u.l,''),u.r from v,u where v.n=u.n and v.r+1=u.r ) select s,iif(min(c)='',1,0)u from v group by n,s
View schema
Execution time: 0,02 sec, rows selected: 8, rows affected: 0, absolute service time: 0,16 sec
edit mode
|
history
|
discussion
s
u
1
1
2
Hello, world!
1
3
aaaaa
0
4
ababab
1
5
foo bar foobar
1
6
la lal al
1
7
thi is a string
0
8
this is a string
0