Spelling Bee Acceptable
up vote
1
down vote
favorite
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or uppercase) ASCII letters, remove the words containing eight or more different letters.
Any input and output format is acceptable.
Standard loophole rules apply.
Shortest byte count wins.
Clever solutions are better, and faster is better as well.
My solution (implementing a quite clever O(n) algorithm, noncompetitive ref implementation):
#include <stdio.h>
#include <stdint.h>
int main(void) {
char str[1024];
while(scanf("%sn", str) == 1) {
uint32_t st = 0;
int s = 0;
for(char *p = str; *p && s <= 7; p++) {
s += ~st >> (*p - 'a') & 1;
st |= 1 << (*p - 'a');
}
if(s <= 7)
printf("%sn", str);
}
}
code-golf
|
show 1 more comment
up vote
1
down vote
favorite
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or uppercase) ASCII letters, remove the words containing eight or more different letters.
Any input and output format is acceptable.
Standard loophole rules apply.
Shortest byte count wins.
Clever solutions are better, and faster is better as well.
My solution (implementing a quite clever O(n) algorithm, noncompetitive ref implementation):
#include <stdio.h>
#include <stdint.h>
int main(void) {
char str[1024];
while(scanf("%sn", str) == 1) {
uint32_t st = 0;
int s = 0;
for(char *p = str; *p && s <= 7; p++) {
s += ~st >> (*p - 'a') & 1;
st |= 1 << (*p - 'a');
}
if(s <= 7)
printf("%sn", str);
}
}
code-golf
5
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
12
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or uppercase) ASCII letters, remove the words containing eight or more different letters.
Any input and output format is acceptable.
Standard loophole rules apply.
Shortest byte count wins.
Clever solutions are better, and faster is better as well.
My solution (implementing a quite clever O(n) algorithm, noncompetitive ref implementation):
#include <stdio.h>
#include <stdint.h>
int main(void) {
char str[1024];
while(scanf("%sn", str) == 1) {
uint32_t st = 0;
int s = 0;
for(char *p = str; *p && s <= 7; p++) {
s += ~st >> (*p - 'a') & 1;
st |= 1 << (*p - 'a');
}
if(s <= 7)
printf("%sn", str);
}
}
code-golf
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or uppercase) ASCII letters, remove the words containing eight or more different letters.
Any input and output format is acceptable.
Standard loophole rules apply.
Shortest byte count wins.
Clever solutions are better, and faster is better as well.
My solution (implementing a quite clever O(n) algorithm, noncompetitive ref implementation):
#include <stdio.h>
#include <stdint.h>
int main(void) {
char str[1024];
while(scanf("%sn", str) == 1) {
uint32_t st = 0;
int s = 0;
for(char *p = str; *p && s <= 7; p++) {
s += ~st >> (*p - 'a') & 1;
st |= 1 << (*p - 'a');
}
if(s <= 7)
printf("%sn", str);
}
}
code-golf
code-golf
edited Nov 9 at 19:52
asked Nov 9 at 1:57
NoLongerBreathedIn
643
643
5
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
12
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25
|
show 1 more comment
5
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
12
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25
5
5
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
12
12
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25
|
show 1 more comment
19 Answers
19
active
oldest
votes
up vote
4
down vote
APL (Dyalog Unicode), 11 bytes
{⍵/⍨8>≢∪⍵}¨
Takes input as a list of strings.
Explanation:
{⍵/⍨8>≢∪⍵}¨
{ ⍵}¨ for each word
∪ take unique letters
8>≢ length less than 8 as a boolean (0 or 1)
⍵/⍨ repeat word that many times
Try it online!
the result contains empty strings. you can fix that preserving the byte count:⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
add a comment |
up vote
3
down vote
Perl 6, 20 bytes
*.grep(8>*.comb.Set)
Try it online!
Filters by words that have a set of letters with size less than 8.
add a comment |
up vote
3
down vote
05AB1E, 5 bytes
ʒÙg8‹
Try it online.
Explanation:
ʒ # Filter the (implicit) input-list by:
Ù # Only leave distinct letters of the word
g # Take its length
8‹ # And only leave those with a length smaller than 8
# (And output implicitly after we're done filtering)
add a comment |
up vote
2
down vote
Jelly, 6 bytes
Qṫ¥Ðḟ8
Try it online!
How it works
Qṫ¥Ðḟ8 Main link. Argument: A (array or words)
Ðḟ Filterfalse; only keep the words W of A for which the chain to the left
returns a falsy value.
¥ Combine the two links to the left into a dyadic chain.
Q Unique; remove duplicate letters from W.
ṫ 8 Tail 8; remove the first 7 letters of the result.
add a comment |
up vote
2
down vote
MathGolf, 6 bytes
Ç{▀£7>
Try it online!
Explanation
Really similar to the 05AB1E solution, but I lose one byte thanks to explicitly having to define the code block for filtering.
Ç Implicit faulty filter by block
{ Start block
▀ Get unique characters of string
£ Get length
7> Is greater than 7
add a comment |
up vote
2
down vote
JavaScript, 33 bytes
a=>a.filter(s=>new Set(s).size<8)
Try it online, using Dennis' test cases
add a comment |
up vote
2
down vote
J, 10 bytes
#~8>#@~.@>
explanation
#~ 8 > #@~.@>
#~ NB. filter the input based on...
8 > NB. is 8 greater than...
#@ NB. the length of...
~.@ NB. the unique characters of...
> NB. the unboxed input.
Try it online!
1
Shouldn't9
be8
?
– Galen Ivanov
Nov 9 at 8:03
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
add a comment |
up vote
2
down vote
Java 8, 46 bytes
s->s.filter(w->w.chars().distinct().count()<8)
Try it online.
Explanation:
s-> // Method with String-Stream as both parameter and return-type
s.filter(w-> // Filter the words in the input-Stream by:
w.chars() // Convert the String to characters
.distinct() // Only leave distinct characters
.count()<8) // Only leave words with less than 8 distinct characters
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)s->s
is implicit input in 05AB1E;filter(w->
isʒ
;.chars()
is implicitly again;.distinct()
isÙ
;.count()
(or length) isg
;<8
is8‹
; and the closing)
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with}
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD
– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
add a comment |
up vote
1
down vote
Python 2, 40 bytes
lambda i:[x for x in i if len(set(x))<8]
Try it online!
Test cases borrowed from @Dennis. Input and output are both lists.
add a comment |
up vote
1
down vote
Red, 54 bytes
func[b][foreach a b[if 8 > length? unique a[print a]]]
Try it online!
The first test set was taken from Dennis'
add a comment |
up vote
1
down vote
C# (.NET Core), 58 bytes
a=>a.Where(x=>x.GroupBy(y=>y).Count()<8)
Try It Online!
add a comment |
up vote
1
down vote
C (gcc), 104 95 bytes
Dennis's word set was also used here.
Thanks to nwellnhof for the suggestions.
char*s,*t;f(i,j,k){for(;~scanf("%ms",&s);i<8&&puts(s))for(i=j=0,t=s;*t;j=k)k=j|1<<*t++,i+=j<k;}
Try it online!
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
add a comment |
up vote
1
down vote
perl -nlE, 32 bytes
my%h;@h{/./g}=();say if keys%h<8
This reads words from STDIN
, printing out those with less than 7 different characters.
1
25 bytes:my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)
– nwellnhof
Nov 12 at 12:25
add a comment |
up vote
0
down vote
Racket, 95 bytes
(require racket/set)(define(f l)(filter(lambda(x)(<(set-count(list->set(string->list x)))8))l))
Try it online!
The test set was taken from Dennis'
add a comment |
up vote
0
down vote
Charcoal, 12 bytes
ΦA›⁸LΦι⁼μ⌕ιλ
Try it online! Link is to verbose version of code. Explanation:
A Input array
Φ Filter strings where
⁸ Literal 8
› Is greater than
L Length of
ι Current string
Φ Filtered on characters where
μ Inner index
⁼ Equals
λ Current character's
⌕ First index in
ι Current string
Implicitly print matching strings
10?
– ASCII-only
Nov 18 at 5:12
add a comment |
up vote
0
down vote
Japt -f
, 6 bytes
¬â Ê<8
Try it, using Dennis' test cases
add a comment |
up vote
0
down vote
JavaScript (ES6), 53 bytes
Without using a set:
a=>a.filter(w=>[...w].every(o=c=>o[c]=o[c]||--k,k=8))
Try it online! (using Dennis' test set)
add a comment |
up vote
0
down vote
Snap! 4, scratchblocks2 syntax
(pretending that Snap! exclusive blocks are valid in scratchblocks2 but functions use the Scratch define
)
69 bytes
b
takes a list of strings.
define((b)
report((#)keep items such that(<(length of )<[7]>)from(b
add a comment |
up vote
0
down vote
C++ (gcc), 105 104 bytes
#import<bits/stdc++.h>
f(){for(char*n;~scanf("%ms",&n);)std::set<int>(n,n+strlen(n)).size()<8&&puts(n);}
Try it online!
-1 byte thanks to @ceilingcat
add a comment |
19 Answers
19
active
oldest
votes
19 Answers
19
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
APL (Dyalog Unicode), 11 bytes
{⍵/⍨8>≢∪⍵}¨
Takes input as a list of strings.
Explanation:
{⍵/⍨8>≢∪⍵}¨
{ ⍵}¨ for each word
∪ take unique letters
8>≢ length less than 8 as a boolean (0 or 1)
⍵/⍨ repeat word that many times
Try it online!
the result contains empty strings. you can fix that preserving the byte count:⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
add a comment |
up vote
4
down vote
APL (Dyalog Unicode), 11 bytes
{⍵/⍨8>≢∪⍵}¨
Takes input as a list of strings.
Explanation:
{⍵/⍨8>≢∪⍵}¨
{ ⍵}¨ for each word
∪ take unique letters
8>≢ length less than 8 as a boolean (0 or 1)
⍵/⍨ repeat word that many times
Try it online!
the result contains empty strings. you can fix that preserving the byte count:⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
add a comment |
up vote
4
down vote
up vote
4
down vote
APL (Dyalog Unicode), 11 bytes
{⍵/⍨8>≢∪⍵}¨
Takes input as a list of strings.
Explanation:
{⍵/⍨8>≢∪⍵}¨
{ ⍵}¨ for each word
∪ take unique letters
8>≢ length less than 8 as a boolean (0 or 1)
⍵/⍨ repeat word that many times
Try it online!
APL (Dyalog Unicode), 11 bytes
{⍵/⍨8>≢∪⍵}¨
Takes input as a list of strings.
Explanation:
{⍵/⍨8>≢∪⍵}¨
{ ⍵}¨ for each word
∪ take unique letters
8>≢ length less than 8 as a boolean (0 or 1)
⍵/⍨ repeat word that many times
Try it online!
edited Nov 9 at 23:28
answered Nov 9 at 2:27
Quintec
1,195518
1,195518
the result contains empty strings. you can fix that preserving the byte count:⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
add a comment |
the result contains empty strings. you can fix that preserving the byte count:⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
the result contains empty strings. you can fix that preserving the byte count:
⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
the result contains empty strings. you can fix that preserving the byte count:
⊢(/⍨)8>≢∘∪¨
– ngn
Nov 11 at 7:44
add a comment |
up vote
3
down vote
Perl 6, 20 bytes
*.grep(8>*.comb.Set)
Try it online!
Filters by words that have a set of letters with size less than 8.
add a comment |
up vote
3
down vote
Perl 6, 20 bytes
*.grep(8>*.comb.Set)
Try it online!
Filters by words that have a set of letters with size less than 8.
add a comment |
up vote
3
down vote
up vote
3
down vote
Perl 6, 20 bytes
*.grep(8>*.comb.Set)
Try it online!
Filters by words that have a set of letters with size less than 8.
Perl 6, 20 bytes
*.grep(8>*.comb.Set)
Try it online!
Filters by words that have a set of letters with size less than 8.
answered Nov 9 at 2:06
Jo King
19.3k245102
19.3k245102
add a comment |
add a comment |
up vote
3
down vote
05AB1E, 5 bytes
ʒÙg8‹
Try it online.
Explanation:
ʒ # Filter the (implicit) input-list by:
Ù # Only leave distinct letters of the word
g # Take its length
8‹ # And only leave those with a length smaller than 8
# (And output implicitly after we're done filtering)
add a comment |
up vote
3
down vote
05AB1E, 5 bytes
ʒÙg8‹
Try it online.
Explanation:
ʒ # Filter the (implicit) input-list by:
Ù # Only leave distinct letters of the word
g # Take its length
8‹ # And only leave those with a length smaller than 8
# (And output implicitly after we're done filtering)
add a comment |
up vote
3
down vote
up vote
3
down vote
05AB1E, 5 bytes
ʒÙg8‹
Try it online.
Explanation:
ʒ # Filter the (implicit) input-list by:
Ù # Only leave distinct letters of the word
g # Take its length
8‹ # And only leave those with a length smaller than 8
# (And output implicitly after we're done filtering)
05AB1E, 5 bytes
ʒÙg8‹
Try it online.
Explanation:
ʒ # Filter the (implicit) input-list by:
Ù # Only leave distinct letters of the word
g # Take its length
8‹ # And only leave those with a length smaller than 8
# (And output implicitly after we're done filtering)
answered Nov 9 at 7:59
Kevin Cruijssen
34.4k554182
34.4k554182
add a comment |
add a comment |
up vote
2
down vote
Jelly, 6 bytes
Qṫ¥Ðḟ8
Try it online!
How it works
Qṫ¥Ðḟ8 Main link. Argument: A (array or words)
Ðḟ Filterfalse; only keep the words W of A for which the chain to the left
returns a falsy value.
¥ Combine the two links to the left into a dyadic chain.
Q Unique; remove duplicate letters from W.
ṫ 8 Tail 8; remove the first 7 letters of the result.
add a comment |
up vote
2
down vote
Jelly, 6 bytes
Qṫ¥Ðḟ8
Try it online!
How it works
Qṫ¥Ðḟ8 Main link. Argument: A (array or words)
Ðḟ Filterfalse; only keep the words W of A for which the chain to the left
returns a falsy value.
¥ Combine the two links to the left into a dyadic chain.
Q Unique; remove duplicate letters from W.
ṫ 8 Tail 8; remove the first 7 letters of the result.
add a comment |
up vote
2
down vote
up vote
2
down vote
Jelly, 6 bytes
Qṫ¥Ðḟ8
Try it online!
How it works
Qṫ¥Ðḟ8 Main link. Argument: A (array or words)
Ðḟ Filterfalse; only keep the words W of A for which the chain to the left
returns a falsy value.
¥ Combine the two links to the left into a dyadic chain.
Q Unique; remove duplicate letters from W.
ṫ 8 Tail 8; remove the first 7 letters of the result.
Jelly, 6 bytes
Qṫ¥Ðḟ8
Try it online!
How it works
Qṫ¥Ðḟ8 Main link. Argument: A (array or words)
Ðḟ Filterfalse; only keep the words W of A for which the chain to the left
returns a falsy value.
¥ Combine the two links to the left into a dyadic chain.
Q Unique; remove duplicate letters from W.
ṫ 8 Tail 8; remove the first 7 letters of the result.
answered Nov 9 at 2:13
Dennis♦
184k32295731
184k32295731
add a comment |
add a comment |
up vote
2
down vote
MathGolf, 6 bytes
Ç{▀£7>
Try it online!
Explanation
Really similar to the 05AB1E solution, but I lose one byte thanks to explicitly having to define the code block for filtering.
Ç Implicit faulty filter by block
{ Start block
▀ Get unique characters of string
£ Get length
7> Is greater than 7
add a comment |
up vote
2
down vote
MathGolf, 6 bytes
Ç{▀£7>
Try it online!
Explanation
Really similar to the 05AB1E solution, but I lose one byte thanks to explicitly having to define the code block for filtering.
Ç Implicit faulty filter by block
{ Start block
▀ Get unique characters of string
£ Get length
7> Is greater than 7
add a comment |
up vote
2
down vote
up vote
2
down vote
MathGolf, 6 bytes
Ç{▀£7>
Try it online!
Explanation
Really similar to the 05AB1E solution, but I lose one byte thanks to explicitly having to define the code block for filtering.
Ç Implicit faulty filter by block
{ Start block
▀ Get unique characters of string
£ Get length
7> Is greater than 7
MathGolf, 6 bytes
Ç{▀£7>
Try it online!
Explanation
Really similar to the 05AB1E solution, but I lose one byte thanks to explicitly having to define the code block for filtering.
Ç Implicit faulty filter by block
{ Start block
▀ Get unique characters of string
£ Get length
7> Is greater than 7
answered Nov 9 at 10:51
maxb
2,1081923
2,1081923
add a comment |
add a comment |
up vote
2
down vote
JavaScript, 33 bytes
a=>a.filter(s=>new Set(s).size<8)
Try it online, using Dennis' test cases
add a comment |
up vote
2
down vote
JavaScript, 33 bytes
a=>a.filter(s=>new Set(s).size<8)
Try it online, using Dennis' test cases
add a comment |
up vote
2
down vote
up vote
2
down vote
JavaScript, 33 bytes
a=>a.filter(s=>new Set(s).size<8)
Try it online, using Dennis' test cases
JavaScript, 33 bytes
a=>a.filter(s=>new Set(s).size<8)
Try it online, using Dennis' test cases
answered Nov 9 at 10:54
Shaggy
18.2k21663
18.2k21663
add a comment |
add a comment |
up vote
2
down vote
J, 10 bytes
#~8>#@~.@>
explanation
#~ 8 > #@~.@>
#~ NB. filter the input based on...
8 > NB. is 8 greater than...
#@ NB. the length of...
~.@ NB. the unique characters of...
> NB. the unboxed input.
Try it online!
1
Shouldn't9
be8
?
– Galen Ivanov
Nov 9 at 8:03
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
add a comment |
up vote
2
down vote
J, 10 bytes
#~8>#@~.@>
explanation
#~ 8 > #@~.@>
#~ NB. filter the input based on...
8 > NB. is 8 greater than...
#@ NB. the length of...
~.@ NB. the unique characters of...
> NB. the unboxed input.
Try it online!
1
Shouldn't9
be8
?
– Galen Ivanov
Nov 9 at 8:03
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
add a comment |
up vote
2
down vote
up vote
2
down vote
J, 10 bytes
#~8>#@~.@>
explanation
#~ 8 > #@~.@>
#~ NB. filter the input based on...
8 > NB. is 8 greater than...
#@ NB. the length of...
~.@ NB. the unique characters of...
> NB. the unboxed input.
Try it online!
J, 10 bytes
#~8>#@~.@>
explanation
#~ 8 > #@~.@>
#~ NB. filter the input based on...
8 > NB. is 8 greater than...
#@ NB. the length of...
~.@ NB. the unique characters of...
> NB. the unboxed input.
Try it online!
edited Nov 9 at 14:18
answered Nov 9 at 3:48
Jonah
1,981816
1,981816
1
Shouldn't9
be8
?
– Galen Ivanov
Nov 9 at 8:03
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
add a comment |
1
Shouldn't9
be8
?
– Galen Ivanov
Nov 9 at 8:03
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
1
1
Shouldn't
9
be 8
?– Galen Ivanov
Nov 9 at 8:03
Shouldn't
9
be 8
?– Galen Ivanov
Nov 9 at 8:03
1
1
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
Fixed. Weird, I could have sworn the OP said 8 was the max length allowed before. Anyway, ty...
– Jonah
Nov 9 at 14:19
add a comment |
up vote
2
down vote
Java 8, 46 bytes
s->s.filter(w->w.chars().distinct().count()<8)
Try it online.
Explanation:
s-> // Method with String-Stream as both parameter and return-type
s.filter(w-> // Filter the words in the input-Stream by:
w.chars() // Convert the String to characters
.distinct() // Only leave distinct characters
.count()<8) // Only leave words with less than 8 distinct characters
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)s->s
is implicit input in 05AB1E;filter(w->
isʒ
;.chars()
is implicitly again;.distinct()
isÙ
;.count()
(or length) isg
;<8
is8‹
; and the closing)
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with}
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD
– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
add a comment |
up vote
2
down vote
Java 8, 46 bytes
s->s.filter(w->w.chars().distinct().count()<8)
Try it online.
Explanation:
s-> // Method with String-Stream as both parameter and return-type
s.filter(w-> // Filter the words in the input-Stream by:
w.chars() // Convert the String to characters
.distinct() // Only leave distinct characters
.count()<8) // Only leave words with less than 8 distinct characters
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)s->s
is implicit input in 05AB1E;filter(w->
isʒ
;.chars()
is implicitly again;.distinct()
isÙ
;.count()
(or length) isg
;<8
is8‹
; and the closing)
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with}
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD
– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
add a comment |
up vote
2
down vote
up vote
2
down vote
Java 8, 46 bytes
s->s.filter(w->w.chars().distinct().count()<8)
Try it online.
Explanation:
s-> // Method with String-Stream as both parameter and return-type
s.filter(w-> // Filter the words in the input-Stream by:
w.chars() // Convert the String to characters
.distinct() // Only leave distinct characters
.count()<8) // Only leave words with less than 8 distinct characters
Java 8, 46 bytes
s->s.filter(w->w.chars().distinct().count()<8)
Try it online.
Explanation:
s-> // Method with String-Stream as both parameter and return-type
s.filter(w-> // Filter the words in the input-Stream by:
w.chars() // Convert the String to characters
.distinct() // Only leave distinct characters
.count()<8) // Only leave words with less than 8 distinct characters
edited Nov 10 at 10:16
answered Nov 9 at 9:42
Kevin Cruijssen
34.4k554182
34.4k554182
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)s->s
is implicit input in 05AB1E;filter(w->
isʒ
;.chars()
is implicitly again;.distinct()
isÙ
;.count()
(or length) isg
;<8
is8‹
; and the closing)
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with}
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD
– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
add a comment |
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)s->s
is implicit input in 05AB1E;filter(w->
isʒ
;.chars()
is implicitly again;.distinct()
isÙ
;.count()
(or length) isg
;<8
is8‹
; and the closing)
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with}
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD
– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
Wow, w.chars.distinct.count. Turn each of those words into a symbol and you have a golfing language! xD
– Quintec
Nov 9 at 12:56
@Quintec Hehe, it's what I do in my 05AB1E answer. :)
s->s
is implicit input in 05AB1E; filter(w->
is ʒ
; .chars()
is implicitly again; .distinct()
is Ù
; .count()
(or length) is g
; <8
is 8‹
; and the closing )
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with }
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD– Kevin Cruijssen
Nov 9 at 13:06
@Quintec Hehe, it's what I do in my 05AB1E answer. :)
s->s
is implicit input in 05AB1E; filter(w->
is ʒ
; .chars()
is implicitly again; .distinct()
is Ù
; .count()
(or length) is g
; <8
is 8‹
; and the closing )
is implicitly since it's at the end of the 05AB1E program (if I wanted to do something after the filter I'd have to close it with }
); and finally outputting is implicitly again. So my Java and 05AB1E are similar, one is a 46 bytes function and the other a 5 bytes full program, though. xD– Kevin Cruijssen
Nov 9 at 13:06
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
Hehe, also basically same for my APL answer. It meets in the middle: 11 bytes :P
– Quintec
Nov 9 at 15:24
add a comment |
up vote
1
down vote
Python 2, 40 bytes
lambda i:[x for x in i if len(set(x))<8]
Try it online!
Test cases borrowed from @Dennis. Input and output are both lists.
add a comment |
up vote
1
down vote
Python 2, 40 bytes
lambda i:[x for x in i if len(set(x))<8]
Try it online!
Test cases borrowed from @Dennis. Input and output are both lists.
add a comment |
up vote
1
down vote
up vote
1
down vote
Python 2, 40 bytes
lambda i:[x for x in i if len(set(x))<8]
Try it online!
Test cases borrowed from @Dennis. Input and output are both lists.
Python 2, 40 bytes
lambda i:[x for x in i if len(set(x))<8]
Try it online!
Test cases borrowed from @Dennis. Input and output are both lists.
answered Nov 9 at 7:05
ElPedro
3,4131023
3,4131023
add a comment |
add a comment |
up vote
1
down vote
Red, 54 bytes
func[b][foreach a b[if 8 > length? unique a[print a]]]
Try it online!
The first test set was taken from Dennis'
add a comment |
up vote
1
down vote
Red, 54 bytes
func[b][foreach a b[if 8 > length? unique a[print a]]]
Try it online!
The first test set was taken from Dennis'
add a comment |
up vote
1
down vote
up vote
1
down vote
Red, 54 bytes
func[b][foreach a b[if 8 > length? unique a[print a]]]
Try it online!
The first test set was taken from Dennis'
Red, 54 bytes
func[b][foreach a b[if 8 > length? unique a[print a]]]
Try it online!
The first test set was taken from Dennis'
answered Nov 9 at 8:04
Galen Ivanov
5,94711032
5,94711032
add a comment |
add a comment |
up vote
1
down vote
C# (.NET Core), 58 bytes
a=>a.Where(x=>x.GroupBy(y=>y).Count()<8)
Try It Online!
add a comment |
up vote
1
down vote
C# (.NET Core), 58 bytes
a=>a.Where(x=>x.GroupBy(y=>y).Count()<8)
Try It Online!
add a comment |
up vote
1
down vote
up vote
1
down vote
C# (.NET Core), 58 bytes
a=>a.Where(x=>x.GroupBy(y=>y).Count()<8)
Try It Online!
C# (.NET Core), 58 bytes
a=>a.Where(x=>x.GroupBy(y=>y).Count()<8)
Try It Online!
answered Nov 9 at 13:34
LiefdeWen
2,502936
2,502936
add a comment |
add a comment |
up vote
1
down vote
C (gcc), 104 95 bytes
Dennis's word set was also used here.
Thanks to nwellnhof for the suggestions.
char*s,*t;f(i,j,k){for(;~scanf("%ms",&s);i<8&&puts(s))for(i=j=0,t=s;*t;j=k)k=j|1<<*t++,i+=j<k;}
Try it online!
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
add a comment |
up vote
1
down vote
C (gcc), 104 95 bytes
Dennis's word set was also used here.
Thanks to nwellnhof for the suggestions.
char*s,*t;f(i,j,k){for(;~scanf("%ms",&s);i<8&&puts(s))for(i=j=0,t=s;*t;j=k)k=j|1<<*t++,i+=j<k;}
Try it online!
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
add a comment |
up vote
1
down vote
up vote
1
down vote
C (gcc), 104 95 bytes
Dennis's word set was also used here.
Thanks to nwellnhof for the suggestions.
char*s,*t;f(i,j,k){for(;~scanf("%ms",&s);i<8&&puts(s))for(i=j=0,t=s;*t;j=k)k=j|1<<*t++,i+=j<k;}
Try it online!
C (gcc), 104 95 bytes
Dennis's word set was also used here.
Thanks to nwellnhof for the suggestions.
char*s,*t;f(i,j,k){for(;~scanf("%ms",&s);i<8&&puts(s))for(i=j=0,t=s;*t;j=k)k=j|1<<*t++,i+=j<k;}
Try it online!
edited Nov 9 at 17:15
answered Nov 9 at 9:36
ErikF
1,25917
1,25917
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
add a comment |
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
96 bytes, if you're OK with implementation- and undefined behavior.
– nwellnhof
Nov 9 at 10:15
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
@nwellnhof What's a little UD between friends for code golf? :-)
– ErikF
Nov 9 at 17:16
add a comment |
up vote
1
down vote
perl -nlE, 32 bytes
my%h;@h{/./g}=();say if keys%h<8
This reads words from STDIN
, printing out those with less than 7 different characters.
1
25 bytes:my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)
– nwellnhof
Nov 12 at 12:25
add a comment |
up vote
1
down vote
perl -nlE, 32 bytes
my%h;@h{/./g}=();say if keys%h<8
This reads words from STDIN
, printing out those with less than 7 different characters.
1
25 bytes:my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)
– nwellnhof
Nov 12 at 12:25
add a comment |
up vote
1
down vote
up vote
1
down vote
perl -nlE, 32 bytes
my%h;@h{/./g}=();say if keys%h<8
This reads words from STDIN
, printing out those with less than 7 different characters.
perl -nlE, 32 bytes
my%h;@h{/./g}=();say if keys%h<8
This reads words from STDIN
, printing out those with less than 7 different characters.
answered Nov 10 at 17:13
Abigail
41717
41717
1
25 bytes:my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)
– nwellnhof
Nov 12 at 12:25
add a comment |
1
25 bytes:my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)
– nwellnhof
Nov 12 at 12:25
1
1
25 bytes:
my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)– nwellnhof
Nov 12 at 12:25
25 bytes:
my%h;@h{/./g}=1;%h<8&&say
(%h<8
requires Perl 5.26)– nwellnhof
Nov 12 at 12:25
add a comment |
up vote
0
down vote
Racket, 95 bytes
(require racket/set)(define(f l)(filter(lambda(x)(<(set-count(list->set(string->list x)))8))l))
Try it online!
The test set was taken from Dennis'
add a comment |
up vote
0
down vote
Racket, 95 bytes
(require racket/set)(define(f l)(filter(lambda(x)(<(set-count(list->set(string->list x)))8))l))
Try it online!
The test set was taken from Dennis'
add a comment |
up vote
0
down vote
up vote
0
down vote
Racket, 95 bytes
(require racket/set)(define(f l)(filter(lambda(x)(<(set-count(list->set(string->list x)))8))l))
Try it online!
The test set was taken from Dennis'
Racket, 95 bytes
(require racket/set)(define(f l)(filter(lambda(x)(<(set-count(list->set(string->list x)))8))l))
Try it online!
The test set was taken from Dennis'
answered Nov 9 at 8:45
Galen Ivanov
5,94711032
5,94711032
add a comment |
add a comment |
up vote
0
down vote
Charcoal, 12 bytes
ΦA›⁸LΦι⁼μ⌕ιλ
Try it online! Link is to verbose version of code. Explanation:
A Input array
Φ Filter strings where
⁸ Literal 8
› Is greater than
L Length of
ι Current string
Φ Filtered on characters where
μ Inner index
⁼ Equals
λ Current character's
⌕ First index in
ι Current string
Implicitly print matching strings
10?
– ASCII-only
Nov 18 at 5:12
add a comment |
up vote
0
down vote
Charcoal, 12 bytes
ΦA›⁸LΦι⁼μ⌕ιλ
Try it online! Link is to verbose version of code. Explanation:
A Input array
Φ Filter strings where
⁸ Literal 8
› Is greater than
L Length of
ι Current string
Φ Filtered on characters where
μ Inner index
⁼ Equals
λ Current character's
⌕ First index in
ι Current string
Implicitly print matching strings
10?
– ASCII-only
Nov 18 at 5:12
add a comment |
up vote
0
down vote
up vote
0
down vote
Charcoal, 12 bytes
ΦA›⁸LΦι⁼μ⌕ιλ
Try it online! Link is to verbose version of code. Explanation:
A Input array
Φ Filter strings where
⁸ Literal 8
› Is greater than
L Length of
ι Current string
Φ Filtered on characters where
μ Inner index
⁼ Equals
λ Current character's
⌕ First index in
ι Current string
Implicitly print matching strings
Charcoal, 12 bytes
ΦA›⁸LΦι⁼μ⌕ιλ
Try it online! Link is to verbose version of code. Explanation:
A Input array
Φ Filter strings where
⁸ Literal 8
› Is greater than
L Length of
ι Current string
Φ Filtered on characters where
μ Inner index
⁼ Equals
λ Current character's
⌕ First index in
ι Current string
Implicitly print matching strings
answered Nov 9 at 9:33
Neil
78.1k744175
78.1k744175
10?
– ASCII-only
Nov 18 at 5:12
add a comment |
10?
– ASCII-only
Nov 18 at 5:12
10?
– ASCII-only
Nov 18 at 5:12
10?
– ASCII-only
Nov 18 at 5:12
add a comment |
up vote
0
down vote
Japt -f
, 6 bytes
¬â Ê<8
Try it, using Dennis' test cases
add a comment |
up vote
0
down vote
Japt -f
, 6 bytes
¬â Ê<8
Try it, using Dennis' test cases
add a comment |
up vote
0
down vote
up vote
0
down vote
Japt -f
, 6 bytes
¬â Ê<8
Try it, using Dennis' test cases
Japt -f
, 6 bytes
¬â Ê<8
Try it, using Dennis' test cases
answered Nov 9 at 10:57
Shaggy
18.2k21663
18.2k21663
add a comment |
add a comment |
up vote
0
down vote
JavaScript (ES6), 53 bytes
Without using a set:
a=>a.filter(w=>[...w].every(o=c=>o[c]=o[c]||--k,k=8))
Try it online! (using Dennis' test set)
add a comment |
up vote
0
down vote
JavaScript (ES6), 53 bytes
Without using a set:
a=>a.filter(w=>[...w].every(o=c=>o[c]=o[c]||--k,k=8))
Try it online! (using Dennis' test set)
add a comment |
up vote
0
down vote
up vote
0
down vote
JavaScript (ES6), 53 bytes
Without using a set:
a=>a.filter(w=>[...w].every(o=c=>o[c]=o[c]||--k,k=8))
Try it online! (using Dennis' test set)
JavaScript (ES6), 53 bytes
Without using a set:
a=>a.filter(w=>[...w].every(o=c=>o[c]=o[c]||--k,k=8))
Try it online! (using Dennis' test set)
edited Nov 9 at 11:23
answered Nov 9 at 10:32
Arnauld
69.5k586294
69.5k586294
add a comment |
add a comment |
up vote
0
down vote
Snap! 4, scratchblocks2 syntax
(pretending that Snap! exclusive blocks are valid in scratchblocks2 but functions use the Scratch define
)
69 bytes
b
takes a list of strings.
define((b)
report((#)keep items such that(<(length of )<[7]>)from(b
add a comment |
up vote
0
down vote
Snap! 4, scratchblocks2 syntax
(pretending that Snap! exclusive blocks are valid in scratchblocks2 but functions use the Scratch define
)
69 bytes
b
takes a list of strings.
define((b)
report((#)keep items such that(<(length of )<[7]>)from(b
add a comment |
up vote
0
down vote
up vote
0
down vote
Snap! 4, scratchblocks2 syntax
(pretending that Snap! exclusive blocks are valid in scratchblocks2 but functions use the Scratch define
)
69 bytes
b
takes a list of strings.
define((b)
report((#)keep items such that(<(length of )<[7]>)from(b
Snap! 4, scratchblocks2 syntax
(pretending that Snap! exclusive blocks are valid in scratchblocks2 but functions use the Scratch define
)
69 bytes
b
takes a list of strings.
define((b)
report((#)keep items such that(<(length of )<[7]>)from(b
answered Nov 9 at 23:49
Silas Reel
316
316
add a comment |
add a comment |
up vote
0
down vote
C++ (gcc), 105 104 bytes
#import<bits/stdc++.h>
f(){for(char*n;~scanf("%ms",&n);)std::set<int>(n,n+strlen(n)).size()<8&&puts(n);}
Try it online!
-1 byte thanks to @ceilingcat
add a comment |
up vote
0
down vote
C++ (gcc), 105 104 bytes
#import<bits/stdc++.h>
f(){for(char*n;~scanf("%ms",&n);)std::set<int>(n,n+strlen(n)).size()<8&&puts(n);}
Try it online!
-1 byte thanks to @ceilingcat
add a comment |
up vote
0
down vote
up vote
0
down vote
C++ (gcc), 105 104 bytes
#import<bits/stdc++.h>
f(){for(char*n;~scanf("%ms",&n);)std::set<int>(n,n+strlen(n)).size()<8&&puts(n);}
Try it online!
-1 byte thanks to @ceilingcat
C++ (gcc), 105 104 bytes
#import<bits/stdc++.h>
f(){for(char*n;~scanf("%ms",&n);)std::set<int>(n,n+strlen(n)).size()<8&&puts(n);}
Try it online!
-1 byte thanks to @ceilingcat
edited yesterday
answered Nov 9 at 19:19
Logern
70546
70546
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f175559%2fspelling-bee-acceptable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Could you include a test case?
– Dennis♦
Nov 9 at 2:05
12
It's generally bad practice to have an upper limit on the score. The reason is that some languages are especially verbose or difficult to program in, and the 307 byte requirement would arbitrarily disallow them from competing.
– Nathan Merrill
Nov 9 at 2:05
Honestly, this is the easy part. Finding words that fit a partially revealed word is harder
– Jo King
Nov 9 at 11:19
I meant, this is the hard part of finding words that could ever be solutions.
– NoLongerBreathedIn
Nov 9 at 19:56
"quite clever O(n) algorithm": you'd have to be really clever to come up with an algorithm which does worse than a linear program. There's no need to compare different words, and you'd spend a constant time per word.
– Abigail
Nov 10 at 17:25