Teacup rim text: Difference between revisions

Content added Content deleted
(Added Swift solution)
(Added 11l)
Line 11: Line 11:
Display one line for each set of teacup rim words.
Display one line for each set of teacup rim words.
<br><br>
<br><br>

=={{header|11l}}==
<lang 11l>F rotated(String s)
R s[1..]‘’s[0]

V s = Set(File(‘unixdict.txt’).read().rtrim("\n").split("\n"))
L !s.empty
L(=word) s // `=` is needed here because otherwise after `s.remove(word)` `word` becomes invalid
s.remove(word)
I word.len < 3
L.break

V w = word
L 0 .< word.len - 1
w = rotated(w)
I w C s
s.remove(w)
E
L.break
L.was_no_break
print(word, end' ‘’)
w = word
L 0 .< word.len - 1
w = rotated(w)
print(‘ -> ’w, end' ‘’)
print()

L.break</lang>

{{out}}
<pre>
apt -> pta -> tap
arc -> rca -> car
ate -> tea -> eat
</pre>


=={{header|AWK}}==
=={{header|AWK}}==