Skip to main content
Commonmark migration
Source Link

#APL+WIN, 33 26 bytes

APL+WIN, 33 26 bytes

Prompts for vector of integers:

+/,((↑v)⍴2)⊤(1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(↑v)⍴2 set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

#APL+WIN, 33 26 bytes

Prompts for vector of integers:

+/,((↑v)⍴2)⊤(1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(↑v)⍴2 set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

APL+WIN, 33 26 bytes

Prompts for vector of integers:

+/,((↑v)⍴2)⊤(1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(↑v)⍴2 set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum
added 2 characters in body
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11

#APL+WIN, 33 2526 bytes

Prompts for vector of integers:

+/,(v⍴2(↑v)⍴2)⊤(v←1↓v1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dyalog ClassicTry it online! Courtesy of Dalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(v⍴2↑v)⍴2 set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

#APL+WIN, 33 25 bytes

Prompts for vector of integers:

+/,(v⍴2)⊤(v←1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dyalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(v⍴2) set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

#APL+WIN, 33 26 bytes

Prompts for vector of integers:

+/,((↑v)⍴2)⊤(1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(↑v)⍴2 set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum
deleted 6 characters in body
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11

#APL+WIN, 33 2425 bytes

Prompts for vector of integers max first:

+/,(v⍴2)⊤(v←↑vv←1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dyalog ClassicTry it online! Courtesy of Dyalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(↑vv←1↓v)+0,⍳-/ create a vector of integers from maxmin to minmax

(v⍴2) set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

#APL+WIN, 33 24 bytes

Prompts for vector of integers max first:

+/,(v⍴2)⊤(v←↑v)+0,⍳-/v←⎕

Try it online! Courtesy of Dyalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(↑v)+0,⍳-/ create a vector of integers from max to min

(v⍴2) set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum

#APL+WIN, 33 25 bytes

Prompts for vector of integers:

+/,(v⍴2)⊤(v←1↓v)+0,⍳-/v←⎕

Try it online! Courtesy of Dyalog Classic

Explanation:

v←⎕ prompt for input of a vector of two integers max first

(v←1↓v)+0,⍳-/ create a vector of integers from min to max

(v⍴2) set max power of 2 to max 

⊤ convert integers to a matrix of binaries

+/, convert matrix to a vector and sum
deleted 13 characters in body
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11
Loading
added 298 characters in body
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11
Loading
added 314 characters in body
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11
Loading
Source Link
Graham
  • 6.8k
  • 1
  • 15
  • 11
Loading