# Tag Info

41

Python3, 21 27 values Characters: 3479% Unique numbers: [1,2,3,4,5,6,7,8,9,11,12,19,20,21,24,29,34,35,36,37,39,43,46,47,49,73,74] As it was requested, here are the permutations that fell in the range [1, 120]. Try it online! 347%9 5 349%7 6 34%79 34 34%97 34 374%9 5 379%4 3 37%49 37 37%94 37 394%7 2 397%4 1 39%47 39 39%74 39 3%479 ...

34

Ruby, 46 ?A.upto(?M*9){|s|s[/(.)\1{3}|[N-Z]/]||puts(s)} My original, similar solution was longer and wrong (it output base13 numbers, which isn't quite all of them due to leading zeroes), but I'll leave it here because it got votes anyway. 1.upto(13**9){|i|(s=i.to_s 13)[/(.)\1{3}/]||puts(s)}

34

05AB1E, 27 38 41 numbers 4·>Ìn Generates the unique numbers: [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 25, 27, 32, 33, 34, 35, 36, 37, 38, 49, 50, 52, 54, 64, 65, 66, 67, 72, 73, 74, 81, 83, 98, 100, 101, 102] Uses the constant 4 with the operations +1, +2, *2 and ^2.

32

Python 2.7, 44 -> 36 bytes lambda x:x/4&42|x*2&128|x*4&84|x/2&1

32

Python, 18 numbers 237#- Produces as valid results: 1, 2, 3, 4, 5, 7, 16, 23, 24, 25, 27, 32, 35, 37, 69, 71, 72, 73 EDIT: I can attest that TuukkaX's solution is optimal for Python. I ran the following code bruteforcing all possible combinations of 5 printable ASCII characters: from itertools import permutations,combinations_with_replacement def perms(...

31

Retina, 20 bytes Byte count assumes ISO 8859-1 encoding. $.' S> %O#\d+ ¶ > Try it online! (The first line enables a linefeed-separated test-suite.) Explanation A simple way to find a valid permutation is to start by inserting the numbers from 0 to N in order, and then to reverse the numbers surrounding each substring of >s. Take <><<>... 30 34 Languages, 19 bytes, Score: 38,832,018,459,912,437,760,000 Here is a quick answer I threw together to show that it is possible to get an answer scoring better than 1. 12233echo*+--@#..; 1. NTFJ #*22331+..@o;-- ech This outputs via character code, which is allowed by meta consensus. Try it here 2. Tcsh echo 2;#..1@2+33*-- 3. 05AB1E 2231*+..@echo ... 29 Pyth, 2 bytes )( Outputs () Try it online! ) # Ends statement, does nothing in this program ( # Create an empty tuple # Implicitly print the empty tuple 25 ><>, 46 43 35 + 4 for -s= = 39 bytes 0&l?!v:3%?\&:n1+$o! +nf0.>&n; >l&:@ This is an implementation of xnor's algorithm in ><>. It takes the input string on the stack (-s flag with the standard interpreter). You can try it out on the online interpreter.

24

C 140 177 235 Good old procedural style, no fancyness. It counts (no write) 11,459,252,883 names in 8 minutes. Next edit with the runtime and size of names file. Watch the sky... Runtime 57 minutes, file size 126,051,781,713 (9 chars+crlf per row). Please tell me the monks' email address, so that I can send them the zipped file, for manual check... Edit ...

23

><>, 26 + 4 = 30 bytes l22pirv 1+$2po>:3%::2g:n$- Try it online! +4 bytes for the -s= flag - if just -s is okay (it would mean that the flag would need to be dropped entirely for empty input), then that would be +3 instead. Assumes that STDIN input is empty so that i produces -1 (which it does on EOF). The program errors out trying to print this -1 ...

23

Jelly, 5 bytes ṢŒ!QY Try it online! Explanation Ṣ Sort Œ! All permutations Q Unique Y Join by linefeeds

23

Java 8, 2 4 numbers n->12 // returns 12 n->21 // returns 21 n1->2 // returns 2 n2->1 // returns 1 Weren't expecting a Java answer, were you? This is a lambda that can only be arranged one of two ways (and with any two different digits!) for a total of two unique numbers. Everything else isn't a valid lambda. Actually improved the answer, ...

21

><>, 52 45 bytes Esolangs page for ><> i:&&:&1-?vn; 2*1-*+20.>:&:&%1(&:&*{:}&:1-&,2% There's a lot of copying and moving elements around, thanks to the several modulo and multiplications needed. The logic is exactly the same as my Python solution. Takes input via a code point from STDIN, e.g. "!" = 33 -> 75....

21

Python 3, 46 bytes, Lynn lambda x0223334566789:(x0223334566789*89)//178

20

Dyalog APL, 25 24 bytes First for the 25-character solution: i{⊃a[⍺⍵]←a[⍵⍺]}¨?i←⌽⍳⍴a←⎕ a←⎕ ⍝ evaluated input, assign to "a" ⍴a ⍝ length ⍳⍴a ⍝ 1 2 .. length ⌽⍳⍴a ⍝ length .. 2 1 i← ⍝ assign to "i" ?i ⍝ random choices: (1.....

20

Python 3, 64 bytes lambda a:[*{*permutations(a)}-{*a}] from itertools import* Try it online!

20

Jelly, 5 bytes ṁ4IṠS Try it online! Algorithm Let's consider the differences j-i, k-j, i-k. If (i, j, k) is a rotation of (1, 2, 3), the differences are a rotation of (1, 1, -2). Taking the sum of the signs, we get 1 + 1 + (-1) = 1. If (i, j, k) is a rotation of (3, 2, 1), the differences are a rotation of (-1, -1, 2). Taking the sum of the signs, we ...

19

Golfscript, 58 47 characters "A"13 9?,{13base{65+}%n+}%{{\4*/,}+78,1/%1-!}, Thanks to Peter Taylor, I am spared from the seppuku from not beating the Ruby solution! Run the code up to 10 yourself, and here is proof it skips the four-in-a-row numbers.

19

vim, 62 59 54 qrma50%mb:norm@q<cr>ggqOjdd'apjma'b@q<esc>0"qDJ<C-a>D@"i@r<esc>xxdd@" Wow. This is possibly the hackiest thing I've written for PPCG, and that's saying something. Input is taken as N on the first line followed by the elements of the array, each on its own line. qr first, we're going to record the contents of ...

19

Funciton, 336 bytes Byte count assumes UTF-16 encoding with BOM. ┌─╖┌─╖ ┌─╖ │f╟┤♭╟┐┌┤♭╟┐ ╘╤╝╘═╝├┘╘═╝├────┐ │┌─╖ │ ┌┐┌┘╔═╗╓┴╖ ││f╟─┴┐└┴┼─╢0║║f║ │╘╤╝ │ │ ╚═╝╙─╜ │┌┴╖ ┌┴╖┌┴╖ ╔═╗ ││+╟┐│×╟┤?╟┐║1║ │╘╤╝│╘╤╝╘╤╝┘╚╤╝ └─┘ └─┘ └───┘ This defines a function f which takes one integer and outputs another integer at a 90 degree turn to the left. It works for ...

19

Mathematica, 58 bytes, polynomial(n) time Abs[Sum[(k-1)Hypergeometric2F1[k,k-#,2,2](#-k)!,{k,#}]-1]& How it works Rather than iterating over permutations with brute force, we use the inclusion–exclusion principle to count them combinatorially. Let S be the set of all permutations of [1, …, n] with σ1 = 1, σn = n, and let Si be the set of permutations ...

18

Bash+Linux command line utils, 43 bytes jot -w%x $[16**9]|egrep -v "[0ef]|(.)\1{3}" This uses a similar technique to my answer below, but just counts in base 16, and strips out all "names" containing 0, e or f as well those with more than 3 same consecutive digits. Convert to the monk's alphabet as follows: jot -w%x$[16**9]|egrep -v "[0ef]|(.)\1{3}" | ...

18

Pyth, 43 bytes ?}QKhu?Jf}QTGJsm+Ld+yedsMfnhT\0.pedGQ]]1KY Demonstration. This is starts by generating all possible double or rearrange sequences. However, since I actually wanted to see it finish, I added a short circuit. It either runs until it finds a solution, or for a number of iterations equal to the input, at which point it gives up and returns []....

18

CJam (56 bytes) q~4@:Nm*:$_&{:+1$\-N),&},f{1$1$:+-\0-:(_e`0f=+++:m!:/}:+ Online demo This is an optimised version of the reference implementation I wrote for the sandbox. Note: I use N in the code because in a Real Combinatorics Question™ the parameters are $n$ and $k$, not m and n, but I'll use $M$ and $N$ in the explanation to ...

18

Pyth, 7 bytes /y+_QQS Try it online. (Only small test cases are included due to exponential run-time.) Outputs 2 for Truthy, 0 for Falsey. / Count the number of occurences of S the sorted input (implicit Q) y in the order-preserved power set +_QQ of the input prepended by its reverse In other words, lambda l: subseq(...

17

Python 2, 58 bytes i=n=input() while~-i:n+=(n%i<1)*i*(n/i%2*2-1);i-=1 print n Like most of the other answers, the idea is to work backwards. Let's call step k+1 step i, so that on step i all the multiples of i are swapped. We need two simple observations: Position n in the array is only swapped at step i if n is divisible by i, To tell whether you're ...

17

Brachylog, 21 bytes :1fz:da|,[] :2a#d :Am Try it online! Try it online! Predicate 0 (main predicate) :1fz:da|,[] :1f Find all solutions of Predicate 1 using Input as Input. z Transpose :da Deduplicate each. |,[] If there is no solution, return [] instead. Predicate 1 (auxiliary predicate 1) :2a#d :2a ...

17

R, 92 91 Can't comment yet so I'm adding my own answer albeit very similar to @Andreï Kostyrka answer (believe it or not but came up with it independently). s=strsplit(readline(),"")[];v=s%in%c("a","e","i","o","u");s[v]=sample(s[v]);cat(s,sep="") Ungolfed s=strsplit(readline(),"")[] # Read input and store as a vector v=s%in%c("a","e","i","o","u")...

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