Longest substrings without repeating characters: Difference between revisions

Added Easylang
(Added Easylang)
 
(3 intermediate revisions by 2 users not shown)
Line 372:
Original string: ''
Longest substrings: <empty></pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">LongUniq ← ⌈´⊸=∘(≠¨)⊸/ ∧`∘∊⊸/¨∘↓</syntaxhighlight>
Alternative:
<syntaxhighlight lang="bqn">LongUniq ← ⊢´∘⊔∘(≠¨)⊸⊏ ∊⊸⊐⟜0⊸↑¨∘↓</syntaxhighlight>
Test:
<syntaxhighlight lang="bqn">LongUniq¨ "a"‿""‿"zzz"‿"xyzyab"‿"xyzyabcybdfd"</syntaxhighlight>
{{out}}
<pre>┌─
· ⟨ "a" ⟩ ⟨ ⟨⟩ ⟩ ⟨ "z" "z" "z" ⟩ ⟨ "zyab" ⟩ ⟨ "zyabc" "cybdf" ⟩
┘</pre>
 
=={{header|C}}==
Line 531 ⟶ 542:
Longest substring with no repeats found in 'unixdict.txt': ['mbowel
disgrunt']
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
func$[] longstr s$ .
subr maxtest
if len sub$ >= max
if len sub$ > max
max = len sub$
max$[] = [ ]
.
max$[] &= sub$
.
.
s$[] = strchars s$
len empty[] 255
len pos[] 255
pos = 1
while pos <= len s$[]
c = strcode s$[pos]
if pos[c] > 0
maxtest
pos = pos[c] + 1
pos[] = empty[]
sub$ = ""
c = strcode s$[pos]
.
pos[c] = pos
sub$ &= strchar c
pos += 1
.
maxtest
return max$[]
.
for s$ in [ "xyzyabcybdfd" "xyzyab" "zzzzz" "a" "thisisastringtest" "" ]
print longstr s$
.
</syntaxhighlight>
{{out}}
<pre>
[ "zyabc" "cybdf" ]
[ "zyab" ]
[ "z" "z" "z" "z" "z" ]
[ "a" ]
[ "astring" "ringtes" ]
[ "" ]
</pre>
 
Line 1,450 ⟶ 1,507:
=={{header|Wren}}==
{{libheader|Wren-seq}}
<syntaxhighlight lang="ecmascriptwren">import "./seq" for Lst
 
var substrings = Fn.new { |s|
2,016

edits