Skip to main content
Commonmark migration
Source Link

MATL, 19 bytes

Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 bytes

Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 bytes

Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients. This gives a number s.
  5. Output whether c+s ≥ 4.

Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display
Rollback to Revision 6
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 19 1819 bytes

Oh!5:=s4&\w4:)hs3>ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test casesverify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. SumCount how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients for all resources. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 18 bytes

Oh!5:=s4&\w4:)hs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Sum the remainders for the first four resources (letters BLWS). This gives a number c.
  4. Sum the quotients for all resources. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 bytes

Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display
deleted 65 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

MATL, 1919 18 bytes

Oh!5:=s4&\w4:)ghs3>hs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test casesverify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many ofSum the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients for all resources. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 bytes

Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
  4. Sum the quotients. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

MATL, 19 18 bytes

Oh!5:=s4&\w4:)hs3>

Input is a numeric row vector where the letters are represented as numbers as follows:

B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.

Try it online!: verify all test cases.

###How it works

  1. Count ocurrences of each resource.
  2. Div-mod them by 4.
  3. Sum the remainders for the first four resources (letters BLWS). This gives a number c.
  4. Sum the quotients for all resources. This gives a number s.
  5. Output whether c+s ≥ 4.

###Commented code

Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display
deleted 9 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
deleted 9 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
added 1 character in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
added 762 characters in body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
edited body
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading
Source Link
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372
Loading