54

Python, no string manipulation def f(n): n += 1 p = 1 m = n while m: if m % 1000 == 666: n += p - n % p p *= 10 m /= 10 return n Works by finding powers of 10, p, where 666 appears, and adding p - n % p to n which replaces 666xxxxx with 66700000.


51

Python, 32 bytes lambda n:eval('['*n+'n'+']*n'*n) Try it online! Makes a string like "[[[n]*n]*n]*n" with n multiplcations, and evaluates it as Python code. Since the evaluation happens within the function scope, the variable name n evaluates to the function input.


50

JavaScript (updated to work with all test cases) The little-known truth is that there are actually four 6s, but one of the betrayed the others and polymorphed into code form to eradicate them from the world digits of the numbers. Here is that traitorous six: x=prompt(''+ 'Enter number'); alert( ( (~x[ 'ind'+ 'exOf']('666')))?(x .replace(/666(.*...


50

Funciton, 1222 bytes Apart from numeric literals, there are two ways I can produce a value (any value at all) in Funciton: stdin and lambda expressions. Stdin is a single box while a full lambda expression requires more syntax, so I’m going with stdin. However, while stdin could be anything, all of the following work regardless of what input is provided. ...


31

J, 4 bytes $~#~ Try it online! Explanation $~#~ Input: integer n #~ Create n copies of n $~ Shape n into an array with dimensions n copies of n


26

JavaScript, 144 141 140 138 132 125 123 bytes With help from @edc65, @Sjoerd Job Postmus, @DocMax, @usandfriends, @Charlie Wynn and @Mwr247! result.textContent = [ +[] ,// 0 (3 bytes) -~[] ,// 1 (4 bytes) -~-~[] ,// 2 (6 bytes) -~-~-~[] ,// 3 (8 bytes) ...


22

Funciton, non-competitive UPDATE! Massive performance improvement! n = 7 now completes in under 10 minutes! See explanation at bottom! This was good fun to write. This is a brute-force solver for this problem written in Funciton. Some factoids: It accepts an integer on STDIN. Any extraneous whitespace breaks it, including a newline after the integer. It ...


20

Applescript This site doesn't have enough Applescript answers. Lets banish some demons! property demon : "666" property trinity : 1 on exorcise above possessed set possessed to possessed as text set relic to AppleScript's text item delimiters set AppleScript's text item delimiters to demon set deliverance to possessed's first text ...


20

Hexagony, 13 bytes 1 2 3 4 5 6 7 8 9 10 42 Try it online! In Hexagony, 0 through 9 are functions that multiply the current memory by 10, and then add the number represented by the function name. Therefore, the first snippet is empty as memories start off as 0. For example, if the current memory is 65, executing the function 3 will make the current memory ...


16

Mouse-2002, 27 26 17 14 bytes The first snippets push 0-10, and ZR+ pushes 25 then 17 and 25 17 + 42 = is 1. A B C D E F G H I J K ZR+


16

Octave, 29 bytes @(n)accumarray((x=1:n)'+!x,1) Try it online!


16

Python 3.8 (pre-release), 218 bytes n=[(t:=[x for s in l.split('|')if(x:=s.strip())],max(map(len,t)))for l in open(0)] del n[1] j=''.join f=lambda c:j(f'|{l[c]:{w}}'for l,w in n) print(f(0),j('|'+w*'-'for _,w in n),*map(f,range(1,len(n[0][0]))),sep='\n') Try it online! -12 bytes thanks to basic code golfing advice by @cairdcoinheringaahing :) -25 bytes ...


15

APL, 53 49 43 42 40 39 36 I managed to replicate J's ;. in APL, and used Gareth's approach, saving 13 chars. {×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1 Sample run: {×5⌷⍵:5⌷⍵⋄+/⍵}¨3,⌿3,/×∘?∘9¨∘.∨⍨9⍴0 1 9 9 6 1 7 5 6 7 55 5 39 9 54 9 9 8 2 1 8 1 9 2 43 8 41 6 42 5 7 3 4 4 8 3 2 2 29 1 26 2 35 8 6 4 2 3 2 3 7 Explanation: ∘.∨⍨9⍴0 1 generates a ...


15

Perl You said we must not increment in a loop. I'm not using any mathematical operators at all! Here is a pure regex-substitution approach (no guarantees it's safe for your sanity). #!/usr/bin/perl $_ = <>; s/$/ ~0123456789/; s/(?=\d)(?:([0-8])(?=.*\1(\d)\d*$)|(?=.*(1)))(?:(9+)(?=.*(~))|)(?!\d)/$2$3$4$5/g; s/9(?=9*~)(?=.*(0))|~| ~0123456789$/$1/g; ...


15

CJam, 27 24 bytes U e# 0 X e# 1 Y e# 2 Z e# 3 Z) e# 3 + 1 YZ+ e# 2 + 3 ZZ+ e# 3 + 3 AZ- e# 10 - 3 YZ# e# 2³ A( e# 10 - 1 A e# 10 EZ* e# 14 × 3 Thanks to @MartinBüttner for -1 byte! Try it online!


15

Jelly, 1 byte ṡ Jelly has a single byte dyadic atom for this very operation Try it online! (the footer splits the resulting list with newlines, to avoid a mushed representation being printed.)


12

J, 63 61 59 55 52 51 49 47 39 37 characters 3 3(4&{+4{*|+/)@,;._3(**1+?)+./~9$0 9 With thanks to Volatility for his 10 character saving. Explanation (each step will have different random numbers...): Generate the mask for generating the random numbers (uses $: 9 9$9$0 9 0 9 0 9 0 9 0 9 0 0 9 0 9 0 9 0 9 0 0 9 0 9 0 9 0 9 0 0 9 0 9 0 9 0 9 0 0 9 0 ...


12

bash (95 chars) Save the script as m in a folder in your PATH with execute bit set. Run as bash m. The plates are stored in file p l(){ tr -dc $1</dev/urandom|head -c3;};egrep -ve"ASS|666|69|KKK|SHT" -fp>>p<<<`l 0-9`-`l A-Z`;m This is equivalent to running the following: # Print three random numbers and three random letters echo $(tr -...


12

Perl 5, 86 75 71 66 bytes All ^Fs are literal control characters (0x06 in ASCII), and hence a single byte. $[ # array start index, defaults to 0 2 !$[ # !0 is 1 3 $^F # max sys file descriptor number, 2 on all sane systems 2 ++$^F ...


12

Brainfuck, 70 bytes + ++ +++ ++++ +++++ ++++++ +++++++ ++++++++ +++++++++ ++++++++++ --[>+<++++++]>- Each line must be run individually. The first 10 are self explanatory: we increment the value of the cell via each plus. The 42 is a lot more complex. It relies on the fact the most brainfuck interpreter use 8-bit cells, meaning that all ...


12

Darkness, 339 303 bytes This is where Darkness really shines. Get it? :~)! Without printing (replaced the space with \s in the first line since it won't show otherwise): \s █ ██ ███ ████ █████ ██████ ███████ ████████ █████████ ██████████ ██████████████████████████████████████████ With printing: ■ █■ ██■ ███■ ████■ █████■ ███...


12

APL (Dyalog APL), 4 bytes ⍴⍨⍴⊢ Try it online!


12

Mathematica, 22 20 bytes (t=Table)@@t[#,#+1]& (* or *) Table@@Table[#,#+1]&


11

NetLogo to go type one-of [ "Print" "Calculate" "Find" "Determine" "Output" ] type " the " type one-of [ "sum" "mean" "average" "median" "standard deviation" "product" "geometric mean"] type " of all " type one-...


10

Prolog, 113 99 bytes Snippets: e-e % 0.0 e/e % 1.0 e/e+e/e % 2.0 ceil(e) % 3 ceil(pi) % 4 ceil(e*e-e) % 5 ceil(e+e) % 6 floor(e*e) % 7 ceil(e*e) % 8 ceil(pi*e) % 9 ceil(pi*pi) % 10 ceil(e^e*e) % 42 Combines the mathematical constants e and pi in different ways ...


10

MATL, 30 bytes O l H I K Kl+ HI* KYq HK* IH^ K:s IH^:sI- H, I, and K are predefined constants for 2, 3, and 4 (like pi). O and l are functions that returns a matrix of zeros (O) or ones (l), the default size is 1x1. : makes a vector, and s sums it, so K:s makes a vector from 1 to 4 and sums it to get 10. Yq is the n-th prime function, so KYq is the 4th ...


9

APL (30) {' x'[1+(⍎⍵⌷'⌽+⍉⊖')≤/¨⍳2⍴⍺]}/⎕ Explanation: {...}/⎕: reduce given function over the input (so if the input has 2 numbers, just calls the function with those two numbers, ⍺ being the left number and ⍵ the right number) ≤/¨⍳2⍴⍺: Make an ⍺-by-⍺ coordinate matrix and set those positions where the X coordinate is not greater than the Y coordinate, ...


9

C,129 f(){int i,n,m,r,s,t;for(i=26;i--;i<25&&printf("%c%c","URFDLB"[s%6],"'2"[r%3])){for(n=m,t=1;t;t=m*n==9)m=(r=rand()%15)/3+1;s+=m;}} The inner loop generates a value of m in the range 1..5 which when added to s and taken modulo 6, ensures that no two consecutive moves are on the same side of the cube. The old ...


9

C#, no usings, 234 bytes new int() // 0 -~new int() // 1 -~-~new int() // 2 -~-~-~new int() // 3 -~-~-~-~new int() // 4 -~-~-~-~-~new int() // 5 -~-~-~-~-~-~new int() // 6 -~-~-~-~-~-~-~new int() // 7 -~-~-~-~-~-~-~-~new int() // 8 (...


Only top voted, non community-wiki answers of a minimum length are eligible