Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 1 character in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 202 chars

next←1
r←n rndu ×ばつ⍳(w<n)∨(n≤0)∨(w≥1E9)∨w≤0⋄r←⍬
next←2147483648∣12345+ne×ばつ1103515245
t←1+w∣⌊ne×ばつ⍳0<n-←1
f←{⍪{M←⊃(×ばつ0..4)+{5 rndu ⍵} ×ばつ⍵⍴1⋄M[3;3]←⊂'free'⋄⍉'BINGO',M} ̈⍵⍴5}

//7+13+36+38+41+67 rndu would return n random numbernumbers in 1..w without repetition, or ∅ if n>w. Reference is the function rand in the book "The C language"Language" Brian W. Kernignan, Dennis M. Ritchie. This seems ok even if I m not 100% sure.

test:

 f 3
 B I N G O 
 8 26 35 48 74 
 1 17 31 60 67 
12 21 free 47 75 
 7 20 44 58 61 
13 28 42 51 71 
 
 B I N G O 
 1 28 40 57 64 
10 23 45 55 62 
 9 20 free 52 72 
 3 29 39 48 70 
13 30 34 46 73 
 
 B I N G O 
10 20 39 59 67 
14 29 42 58 63 
12 23 free 60 68 
 5 25 41 51 72 
 3 21 31 52 66 
 f 1
 B I N G O 
15 30 34 50 73 
 7 16 44 46 72 
13 24 free 47 67 
 3 18 38 58 69 
10 26 35 52 66 
 

APL(NARS), 202 chars

next←1
r←n rndu ×ばつ⍳(w<n)∨(n≤0)∨(w≥1E9)∨w≤0⋄r←⍬
next←2147483648∣12345+ne×ばつ1103515245
t←1+w∣⌊ne×ばつ⍳0<n-←1
f←{⍪{M←⊃(×ばつ0..4)+{5 rndu ⍵} ×ばつ⍵⍴1⋄M[3;3]←⊂'free'⋄⍉'BINGO',M} ̈⍵⍴5}

//7+13+36+38+41+67 rndu would return n random number in 1..w without repetition, or ∅ if n>w. Reference is the function rand in the book "The C language" Brian W. Kernignan, Dennis M. Ritchie. This seems ok even if I m not 100% sure.

test:

 f 3
 B I N G O 
 8 26 35 48 74 
 1 17 31 60 67 
12 21 free 47 75 
 7 20 44 58 61 
13 28 42 51 71 
 
 B I N G O 
 1 28 40 57 64 
10 23 45 55 62 
 9 20 free 52 72 
 3 29 39 48 70 
13 30 34 46 73 
 
 B I N G O 
10 20 39 59 67 
14 29 42 58 63 
12 23 free 60 68 
 5 25 41 51 72 
 3 21 31 52 66 
 f 1
 B I N G O 
15 30 34 50 73 
 7 16 44 46 72 
13 24 free 47 67 
 3 18 38 58 69 
10 26 35 52 66 
 

APL(NARS), 202 chars

next←1
r←n rndu ×ばつ⍳(w<n)∨(n≤0)∨(w≥1E9)∨w≤0⋄r←⍬
next←2147483648∣12345+ne×ばつ1103515245
t←1+w∣⌊ne×ばつ⍳0<n-←1
f←{⍪{M←⊃(×ばつ0..4)+{5 rndu ⍵} ×ばつ⍵⍴1⋄M[3;3]←⊂'free'⋄⍉'BINGO',M} ̈⍵⍴5}

//7+13+36+38+41+67 rndu would return n random numbers in 1..w without repetition, or ∅ if n>w. Reference is the function rand in the book "The C Language" Brian W. Kernignan, Dennis M. Ritchie. This seems ok even if I m not 100% sure.

test:

 f 3
 B I N G O 
 8 26 35 48 74 
 1 17 31 60 67 
12 21 free 47 75 
 7 20 44 58 61 
13 28 42 51 71 
 
 B I N G O 
 1 28 40 57 64 
10 23 45 55 62 
 9 20 free 52 72 
 3 29 39 48 70 
13 30 34 46 73 
 
 B I N G O 
10 20 39 59 67 
14 29 42 58 63 
12 23 free 60 68 
 5 25 41 51 72 
 3 21 31 52 66 
 f 1
 B I N G O 
15 30 34 50 73 
 7 16 44 46 72 
13 24 free 47 67 
 3 18 38 58 69 
10 26 35 52 66 
 
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 202 chars

next←1
r←n rndu ×ばつ⍳(w<n)∨(n≤0)∨(w≥1E9)∨w≤0⋄r←⍬
next←2147483648∣12345+ne×ばつ1103515245
t←1+w∣⌊ne×ばつ⍳0<n-←1
f←{⍪{M←⊃(×ばつ0..4)+{5 rndu ⍵} ×ばつ⍵⍴1⋄M[3;3]←⊂'free'⋄⍉'BINGO',M} ̈⍵⍴5}

//7+13+36+38+41+67 rndu would return n random number in 1..w without repetition, or ∅ if n>w. Reference is the function rand in the book "The C language" Brian W. Kernignan, Dennis M. Ritchie. This seems ok even if I m not 100% sure.

test:

 f 3
 B I N G O 
 8 26 35 48 74 
 1 17 31 60 67 
12 21 free 47 75 
 7 20 44 58 61 
13 28 42 51 71 
 
 B I N G O 
 1 28 40 57 64 
10 23 45 55 62 
 9 20 free 52 72 
 3 29 39 48 70 
13 30 34 46 73 
 
 B I N G O 
10 20 39 59 67 
14 29 42 58 63 
12 23 free 60 68 
 5 25 41 51 72 
 3 21 31 52 66 
 f 1
 B I N G O 
15 30 34 50 73 
 7 16 44 46 72 
13 24 free 47 67 
 3 18 38 58 69 
10 26 35 52 66 
 

AltStyle によって変換されたページ (->オリジナル) /