| Bytes | Lang | Time | Link |
|---|---|---|---|
| 032 | APLNARS | 250821T055115Z | Rosario |
| 013 | Pip P | 211215T175147Z | DLosc |
| 053 | Python 3 | 220919T203318Z | Pandu |
| 011 | Pyth | 220919T220501Z | hakr14 |
| 014 | Brachylog | 211221T135811Z | Hjulle |
| 163 | SimpleTemplate 0.84 | 211218T171754Z | Ismael M |
| 062 | C | 211216T134331Z | Lucas Em |
| 027 | X8664 Machine Code | 211217T071141Z | me' |
| 007 | Jelly | 211215T174644Z | caird co |
| 112 | Scratch | 211217T154311Z | Nolan |
| 033 | Perl 5 | 211217T011040Z | Xcali |
| 045 | Clojure | 211216T225228Z | wintermu |
| 008 | Jelly | 211216T211420Z | lynn |
| 055 | Python 3 | 211215T160336Z | Joseph W |
| 010 | Vyxal | 211216T120311Z | lyxal |
| 036 | Python 2 | 211215T161523Z | G B |
| 031 | Desmos | 211216T080745Z | Aiden Ch |
| 010 | 05AB1E | 211215T171023Z | Kevin Cr |
| 023 | Wolfram Language Mathematica | 211216T064633Z | att |
| 046 | Python 3 with NumPy | 211216T012755Z | Gavin S. |
| 012 | Husk | 211215T174114Z | Dominic |
| 037 | Retina 0.8.2 | 211215T210044Z | Neil |
| 016 | BQN | 211215T182955Z | DLosc |
| 035 | JavaScript V8 | 211215T154724Z | Arnauld |
| 038 | APOL | 211215T181835Z | Ginger |
| 014 | Charcoal | 211215T174029Z | Neil |
| 012 | MathGolf | 211215T172246Z | Kevin Cr |
| 017 | R | 211215T155617Z | Giuseppe |
| 022 | R | 211215T153610Z | Dominic |
| 014 | APL Dyalog Unicode | 211215T161344Z | ovs |
| 027 | Ruby | 211215T161002Z | G B |
| 024 | APL+WIN | 211215T155438Z | Graham |
APL(NARS), 32 chars
a/⍨{∧/(9+⍳8)(⍳8)∊¨⍨0 18⊤⍵}¨a←⍳!7
This 0 18⊤⍵ it seems convert omega to a cople of numbers x,y: that y=⍵ mod 18 x=floor(⍵÷18) test:
a/⍨{∧/(9+⍳8)(⍳8)∊¨⍨0 18⊤⍵}¨a←⍳!7
181 182 183 184 185 186 187 188 199 200 201 202 203 204 205 206 217 218 219 220 221
222 223 224 235 236 237 238 239 240 241 242 253 254 255 256 257 258 259 260 271
272 273 274 275 276 277 278 289 290 291 292 293 294 295 296 307 308 309 310 311
312 313 314
Pip -P, 13 bytes
181+18*_+BMC8
Explanation
181+18*_+BMC8
MC Map the following function to coordinate pairs
8 from an 8x8 grid:
181+ 181 plus
18*_ 18 times the row number
+B plus the column number
Here's a 15-byte solution that uses base conversion:
_FD18Mt,18CP\,8
t,18 Range from 10 to 18 (not including 18)
CP Cartesian product with
\,8 Range from 1 to 8 (including 8)
M To each of the resulting pairs, map:
_FD18 Convert from list of digits in base 18
Python 3, 53 bytes
b=181
while b<308:[print(b+x)for x in range(8)];b+=18
I believe this straightforward solution is currently the shortest vanilla Python 3 solution. :)
Pyth, 12 11 bytes
iR18*}T17S8
-1 byte thanks to Steffan!
Explanation:
iR18*}T17S8 | Full code
------------+--------------------------
* | Cartesian product of
}T17 | [10..17]
S8 | [1..8]
iR18 | Convert each from base 18
Brachylog, 14 bytes
8⟦₁+₉ᶻ\↔ẋ~ḃ₁₈ᵐ
8⟦₁ Range [1..8]
+₉ᶻ Add 9 to each element [[1,10],[2,11],..,[8,17]]
\↔ Transpose and swap [[10..17],[1..8]]
ẋ Cartesian product [[10,1],[10,2]..]
~ḃ₁₈ᵐ Convert each element from base 18
SimpleTemplate 0.84, 163 bytes
This code simply outputs a space separated list of numbers.
{@setN 181}{@for to314}{@if_ matches"@18[2-8]|199|2([09][0-6]|3[5-9]|4[012]|5[3-9]|60|7[1-8]|89|9[0-6])|(21|30)[789]|(22|31)[0-4]@"}{@setN N,_}{@/}{@/}{@echoj" "N}
It looks yucky, but works!
How it works?
The code loops from 0 to 314, and then verifies if the number matches the following regular expression:
@18[2-8]|199|2([09][0-6]|3[5-9]|4[012]|5[3-9]|60|7[1-8]|89|9[0-6])|(21|30)[789]|(22|31)[0-4]@
If it matches, it is added to the array of numbers we need.
The generated array looks like this:
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[181,182],183],184],185],186],187],188],199],200],201],202],203],204],205],206],217],218],219],220],221],222],223],224],235],236],237],238],239],240],241],242],253],254],255],256],257],258],259],260],271],272],273],274],275],276],277],278],289],290],291],292],293],294],295],296],307],308],309],310],311],312],313],314]
And this is the final output:
181 182 183 184 185 186 187 188 199 200 201 202 203 204 205 206 217 218 219 220 221 222 223 224 235 236 237 238 239 240 241 242 253 254 255 256 257 258 259 260 271 272 273 274 275 276 277 278 289 290 291 292 293 294 295 296 307 308 309 310 311 312 313 314
The {@echo} will automatically flatten the array internally, before printing it.
Ungolfed:
The code is pretty nasty to look at, so, here's an ungolfed version that does the same:
{@set numbers 181}
{@for i from 0 to 314}
{@if i matches "@18[2-8]|199|2([09][0-6]|3[5-9]|4[012]|5[3-9]|60|7[1-8]|89|9[0-6])|(21|30)[789]|(22|31)[0-4]@"}
{@set numbers numbers, i}
{@/}
{@/}
{@echo separator " " numbers}
About the language
There are a few things that are important to know to fully understand how it works.
- Almost all whitespace is optional.
- It is required to start with
181in the variable.
If the variable isn't set to 181, the output will be incorrect, because the first value in the array will benull. - The
{@for to314}is the same as{@for i from 0 to 314}.
The variable is optional, and automatically assigns to_.
Thefrom 0isn't required, as the loop will automatically start from 0 to the final number. - Both
{@echo separator " " numbers}and{@echoj" "N}do the same:
Output the variable values separated by" ". Thejstands for "join", inechoj.
Running the code:
You can run the code on: http://sandbox.onlinephpfunctions.com/code/117ed06567a1d0e710e75b963566b86b510ca7ab
Please pick a version between 5.6 and 7.4.13. Can't fix the 8.0.0 compatibility issue without invalidating this answer.
C, 64, 62 bytes
Thank you @JustinFinnerty for the improvement
j;main(i){for(i=9;++i%18;)while(++j%9)printf("%d ",i*18+j%9);}
Less golfed version:
i,j;
main(){
for(i=9;++i%18;)
while(++j%9)
printf("%d ",i*18+j%9);
}
X86-64 Machine Code, Microsoft Calling Convention, 27 bytes
33 C0 xor eax,eax
B0 B5 mov al,0B5h
B2 08 mov dl,8
outerLoop:
B6 08 mov dh,8
innerLoop:
89 01 mov dword ptr [rcx],eax
48 83 C1 04 add rcx,4
FF C0 inc eax
FE CE dec dh
75 F4 jne innerLoop
04 0A add al,0Ah
FE CA dec dl
75 EC jne outerLoop
C3 ret
Which has the following function signature:
extern "C" void chessNumbers(uint32_t* out);
Jelly, 8 7 bytes
9Ṗ+pṖḅḤ
-1 byte thanks to Lynn by combining our answers, so make sure to upvote their answer as well!
How it works
9Ṗ+pṖḅḤ - Main link. Takes no arguments
9 - Set the return value to 9, and execute with 9 on the left
Ṗ - Pop, yielding [1,2,3,4,5,6,7,8]
+ - Add 9 to each: [10,11,12,13,14,15,16,17]
Ṗ - Pop, yielding [1,2,3,4,5,6,7,8]
p - Cartesian product: [[10,1],[10,2],...,[17,8]]
Ḥ - Unhalve; Yield 18
ḅ - Unbase; Convert [a, b] to 18a+b
Scratch, 112 bytes
Not much room for improvement
when gf clicked
set[N v]to(170
delete all of[C v
repeat(8
change[N v]by(10
repeat(8
change[N v]by(1
add(N)to[C v
Commentated:
when gf clicked Initiates code
set[N v]to(170 Sets N to 98 (in base-18)
delete all of[C v Clears the list
repeat(8 Loops code for each column of the chessboard
change[N v]by(10 Increases the tens digit by 1 and decreases the ones digit by 8
repeat(8 Loops code for each row of the chessboard
change[N v]by(1 Increases the ones digit by 1
add(N)to[C v Adds N to the list
Clojure, 59 45 bytes
(map read-string(for[x"abcdefgh"y"12345678"](str"18r"x y)))
(for[x(range 10 18)y(range 1 9)](+(* 18 x)y))
Jelly, 8 bytes
18⁵rṖp8ḅ
18 18
⁵r Range from ⁵=10: [10..18]
Ṗ Remove last element: [10..17] ([a..h])
p8 Cartesian product with [1..8]
ḅ Convert from base 18
Python 3, 55 bytes
Edit: Was 56 bytes, now 55. Thanks to Dronir for proposing printing the numbers as a list.
Edit: Was 57 bytes, now 56. Thanks to Neil for proposing the -~j modification.
print([18*i-~j for i in range(10,18)for j in range(8)])
Python 2, 53 bytes
Thanks to Kevin Cruijssen for propsing switching to Python 2 to save a couple of bytes.
print[18*i-~j for i in range(10,18)for j in range(8)]
Vyxal, 11 10 bytes
8:Ẋ18vβ⁺=+
I actually didn't port anything for once lol 05ab1e porting go brrr.
Explained
8:Ẋ18vβ⁺=+
8:Ẋ # The cartesian product of the range(1, 9) and range(1, 9)
18vβ # convert each pair from arbitrary base 18
⁺=+ # add 162 to each (128 + the index of `=` in the vyxal codepage)
11 bytes
8ƛ₀*9ɾM18vβ
8ƛ₀*9ɾM18vβ
8ƛ # For each item n in the range [1, 8]:
₀* # Mulitply n by 10
9ɾM # [[n * 10, x] for x in range(1, 10)]
18vβ # and convert each from arbitrary base 18 to base 10
Desmos, 37 31 bytes
[a+bfora=[1...8],b=[10...17]18]
Try It On Desmos! - Prettified
Finally got a chance to utilize the new list comprehension feature in Desmos!
Explanation:
[ for ] initiate list comprehension for loop
a=[1...8], loop from a=1 to a=8, incrementing by 1
b=[10...17]18 loop from b=10*18 to b=17*18, incrementing by 18
(essentially creates a nested for loop)
a+b calculate a+b
05AB1E, 11 10 bytes
8Lã18δβƵz+
-1 byte thanks to @ovs.
A port of @JosephWalker's Python 3 answer is 11 bytes: 7ÝT+18*8LâO - Try it online.
A port of @Arnauld's JavaScript first answer is 12 bytes: ƵΔƵÖŸʒ<18%8‹ - Try it online.
A port of @GB's Ruby answer is 12 bytes as well: 63ÝD8÷T*ƵΘ++ - Try it online.
A port of @ovs' APL answer is 13 bytes: ƵgLD18%9›ÏƵη+ - Try it online.
A port of @Giuseppe's R answer is 14 bytes: 80ƵgŸ8÷18*8LÞ+ - Try it online.
Explanation:
8L # Push a list in the range [1,8]
ã # Create all possible pairs with the cartesian product
δ # Map over each pair:
18 β # Convert it from a base-18 list to an integer
Ƶz+ # And add 162 to each
# (after which the result is output implicitly)
See this 05AB1E answer of mine (section How to compress large integers?) to understand why Ƶz is 162.
Python 3 with NumPy, 62 52 46 bytes
lambda:18*r_[10:18]+c_[1:9]
from numpy import*
Utilizing the option to return output in a 2d array. I'm a little fuzzy on how I/O is allowed in python so let me know if this is unacceptable / I need more boilerplate.
Thanks to loopy wait for r_ and c_
Husk, 12 bytes
ṠṪ+mo*18+9ḣ8
ḣ8 # get the range from 1..8
Ṡ # Ṡfgx = f(g(x),x)
# so we use the range 1..8 twice
# once directly as an argument to f
# and once after applying g to it
Ṫ+ # f = Ṫ+ = outer product by addition
mo*18+9 # g =
mo # map over each element
+9 # add 9
*18 # and then multiply by 18
Retina 0.8.2, 37 bytes
63$*¶
$.`
.+
$*_181$*
_{8}
18$*
%`.
Try it online! Explanation:
63$*¶
$.`
Insert the numbers from 0 to 63.
.+
$*_181$*
Convert to unary and add 181.
_{8}
18$*
Add an extra 10 for each multiple of 8 in the original number.
%`.
Convert to decimal.
BQN, 16 bytes
(181+⊢+18×⊣)⌜˜↕8
Run it online! Outputs an 8x8 array of numbers.
Explanation
A port of my Pip solution.
(181+⊢+18×⊣)⌜˜↕8
↕8 Range(8)
( )⌜˜ Generate a table, using that range twice, with this function:
18×⊣ 18 times left argument
⊢+ plus right argument
181+ plus 181
JavaScript (V8), 35 bytes
Test modulo \$18\$.
for(n=180;n<314;)n++%18<8&&print(n)
JavaScript (V8), 36 bytes
Expanding \$[0\dots63]\$ in reverse order to \$[181\dots314]\$.
for(n=64;n--;)print(314-(n>>3)*10-n)
APOL, 38 bytes
Port of Joeph Walker's genius answer, all credit goes to him.
ḟ(10 18 v(0 ∋) ḟ(1 9 p(*(18 +(∋ ⁰)))))
Sadly, APOL doesn't support nested for counters, so I have to use a clunkier solution. Maybe I'll implement them and come back to this later.
Charcoal, 14 bytes
I⁺¹⁸¹E⁶⁴↨¹⁸↨ι⁸
Try it online! Link is to verbose version of code. I had three 15 byte solutions (including one which generated the range a1..h8 and converted them from base 18) but I was able to golf one of them down to 14. Explanation:
⁶⁴ Literal integer `64`
E Map over implicit range
ι Current integer
↨ ⁸ Divmod by 8 using base conversion
↨¹⁸ Interpret as base 18
⁺¹⁸¹ Vectorised add 181
I Cast to string
Implicitly print
MathGolf, 12 bytes
8r♂+G*mÉ8╒+─
Explanation:
8r # Push a list in the range [0,8)
♂+ # Add 10 to each to make the range [10,18)
G* # Multiply each by 18
m # Map over this list,
É # Using 3 characters as inner code-block:
8╒ # Push range [1,8]
+ # Add the map-integer to each
─ # After the map: flatten the list of lists
# (after which the entire stack is output implicitly as result)