text
stringlengths
180
608k
[Question] [ Today is November 11th, which for many regions is [Remembrance Day](https://en.wikipedia.org/wiki/Remembrance_Day). If you don't know anything about the history or context of Remembrance Day, you can read about it in the wiki page, but it's not relevant for this challenge. *In Flanders Fields* is a poem that is pretty well-known relating to this day. It opens like so: ``` In Flanders fields the poppies blow Between the crosses, row on row ``` # Challenge You will be given a grid with crosses (represented below as `+`) on it. Your task is to grow poppies between all crosses. That is, fill the space between any two crosses that are on the same row or column with poppies (represented below as `*`). # Example ``` ....+.... ...+.+... ......... ....+.... ..+...+.. ......... ..+...+.. ``` This becomes: ``` ....+.... ...+*+... ....*.... ....+.... ..+***+.. ..*...*.. ..+***+.. ``` Rigorously defined, on a non-cylindrical grid, each grid space is `+` if it was `+`, and becomes `*` if it has a `+` in the same column above and below it, or in the same row to its left and right. # Test Cases ``` .....+... .....+... +......+. +******+. ....+.+.. -> *...+*+.. +.+...+.. +*+***+.. ...++.+.. ...++*+.. .+..... .+..... ....+.. .*..+.. ...+..+ .*.+**+ .+++... .+++*.* ....... -> .****.* .+++.+. .+++*+* .++.++. .++*++* ....... .*....* .+....+ .+****+ ....... ....... ...+... ...+... .....++ .....++ ++..... ++...** +....+. -> +****+* .....+. .....+* ....... ......* ....... ......* ..+...+ ..+***+ .+.+.. .+*+.. .....+ .*.*.+ +..... +*.*.* .+.... .+.*.* ...+.+ -> ...+*+ ...... ...... ...... ...... ....+. ....+. ``` # Rules and Specifications Input requires a grid of two distinct values. You can take this in any convenient format, and you can choose to use any reasonable convenient values, like `0` and `1`, for example. Output requires a grid of three distinct values. Again, you can deliver this in any reasonable, convenient format. Standard loopholes apply. This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge, so the shortest solution in each language wins. No answer will be accepted. (Sorry for posting another challenge, especially another [ascii-art](/questions/tagged/ascii-art "show questions tagged 'ascii-art'") one, so soon, but I really wanted to do something for 11/11 and I thought of it after my pattern expansion one) [Answer] # [Python 2](https://docs.python.org/2/), ~~131~~ 125 bytes ``` f=lambda A,p=1:map(''.join,zip(*[re.sub('\+.+\+',lambda x:re.sub('\.','*',x.group()),s)for s in p and f(A,0)or A])) import re ``` [Try it online!](https://tio.run/##ZY8xDoMwDEXncgqLxQmJrLYjEkPOAQwgoE1VkiiARHt5Sgp0qeXB/78vy3av8W7NdVm67Fn1dVOBki67pH3lGCI9rDbyrR1Lct/SMNUMC0GiECj3@Jz@AKHEBOVMN28nxziXA@@shwG0AQeVaaBjSp756qmS80j3zvoRfLuEmAqxPEciERpLGWb6ynU1oKBdBrFN4iBiy@1EbKQs0@jkvDYjxNla8aGwMNtvTPHd@0frrfxHlw8 "Python 2 – Try It Online") Input is a list of strings; as is output. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` ẒT.ịr/Ṭ»)Z$⁺ ``` A monadic Link accepting a list of lists where: * crosses, `+`, are `2` * spaces, `.`, are `0` which yields a list of lists as above with poppies, `*`, as `1`. **[Try it online!](https://tio.run/##y0rNyan8///hrkkheg93dxfpP9y55tBuzSiVR427/v//Hx1toKNgpKNggIxidRSikQWMsAjD9RhBhY1gCIchqMLIqo3QhREMgoagODM2FgA "Jelly – Try It Online")** Or see [one which translates IO](https://tio.run/##y0rNyan8///hrkkheg93dxfpP9y55tBuzSiVR427/j/cvcX2UcNc7cPTjQ63A2UfNczR0tYDikT@/6@nrQcCXCBCG0IDKW0uPW1tbZg4mAbxtcE0CCGJg3UCAA). ### How? ``` ẒT.ịr/Ṭ»)Z$⁺ - Link: list of lists $ - last two links as a monad - i.e. f(Rows): ) - for each Row in Rows: Ẓ - is prime? (vectorises) (isCross() that work's once poppies are planted) T - truthy indices e.g. [0,0,1,0,0,1,1,0] -> [3,6,7] . - literal one half ị - index into (the truthy indices) -- non-integer indices reference the - items on either side of that location & indexing is 1-based and - modular, so [last,first] e.g. [3,6,7]->[7,3] or [8] -> [8,8] / - reduce by: r - inclusive range e.g. [7,3]->[7,6,5,4,3] or [8,8]->[8] Ṭ - un-truth e.g. [7,6,5,4,3]->[0,0,1,1,1,1,1] or [8]->[0,0,0,0,0,0,0,1] » - maximum (with Row) (vectorises) (keep crosses, plant poppies) Z - transpose ⁺ - repeat the last link (plant the remaining column poppies and transpose back) ``` [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 96 bytes ``` param($a)$a=&($g={($a=$a-replace'(?<=\+.*)\.(?=.*\+)','*')[0]|% t*y|%{-join$a.chars($i++)}});&$g ``` [Try it online!](https://tio.run/##rZXRboJAEEXf@YoNrgIzuOl7S/SpP1GbZgOr0iBQwLQG/XYLrNYWBksbNwbleGdyZ8aRNHlXWb5WUXTkS688pjKTG5tLh0tvYvOVV1Y3HpfTTKWR9JVlzx68BQpwFsKeeQIW6FiuBZbzdPe8H7MCdvtxOX1NwphL4a9llts8RHQOB@d@wlfHg2HMbYNVx9Vv9ZlfPlqiOlhfLPcHxIa2oD5tSISjxgPCz8ov5riD7AFlD4baA4COPdAJaOXFnnG50i3Vkdiu9bsfAlcUOxgRe5JQuFYjhevX4CSNxZ5xXC0N6NKg7iFZGgjoqqtD4FqNFAYkcPMzINR1cvz7KEXfKHuHg516kW6a7nZPksEz68P46yhvVhp02q27DXQSGovhGP83SuzZPmL58Mp@kA1D2vxwiuL62gG9XkB4rymxACRt/kxv6v00DIft2ZiVzR1fRjIOqmffY6iiIHcZVx@p8gsVMI/xF63JVL6NigpM@LId0SjMk8Sc@urN/EphNl@OzvFstI39ZLNRccGKdZizKIwVKxIWhHn1VN0xrcuNw/ET "PowerShell – Try It Online") [Answer] # [J](http://jsoftware.com/), 44 bytes ``` '.*+'{~[:(+:+-.*](+.|:)&(>./\.*>./\)|:)=&'+' ``` [Try it online!](https://tio.run/##XU49C8IwFNzzKx4OTdKzz@KYUhEEJyfXWhykpbg42E3xr8d8CamP5OXeHXd5d7tiOVJrSNKaajLuVkyH8@loJZeQr09nFAwqLnsFfhtdqB1vLlz6rt3cFhLSajEPz7ll6gwNt@mxVz01NGrqG75uRVB9fi3YFXwTASChWAsVES/UH6f/EmMOOOGUg8BlOUBy53Ysvo5rMRyPfLk4I7z@ZHxwCm2/ "J – Try It Online") No regex used: * Takes the product of the max scan of the prefixes and the max scan of the suffixes to turn the in-between cells to 1. * Does this for both the input and its transpose (to get both directions) * "Or"s these two matrices. * Multiplies by one minus the input, to get rid of endpoints (ie, original crosses) * Add double the original matrix to that. * After all this, in-between points in both directions are 1, original points are 2, rest are 0. * We use that to index into `'.*+`. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~18~~ 14 bytes ``` UÄUaÄa2 ZÇZoÇ_ ``` [Try it online!](https://tio.run/##y0rNyan8/z/0cEto4uGWRCOuqMPtUfmH2@P/P9yxyfZRw1ztw@0Pd3c/apijraUH5Ea6cR1uf9S0JutR4z4urv//lfSAQBtEKIAZ2lAWBCggy2pD2CiyUDElHbA5EN3aelA2VLc2WAxJt7Y2TI82ii0QF@hpKwBVILsDwtcG0yCEJA7WCbMdbgJUhba2gjbUBm0kF@khm4DqE4ib4J7UVtBGtggaQgooeqGOVwIA "Jelly – Try It Online") -4 bytes because I figured out what I did wrong with my cumulative sums Input and output is as two-dimensional lists with `.` mapped to 0, `+` mapped to 1, and `*` mapped to 2. (The footer on TIO converts automatically for convenience.) ``` Helper link: a2 Fill in 2s wherever Ä there's at least one truthy value to the left UÄUa and at least one truthy value to the right. This fills in poppies between (and on) all crosses horizontally. oÇ Overlay the horizontal poppies ZÇZ on the vertical poppies, _ and subtract the crosses out to recover them. ``` [Answer] # [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), 16 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ``` 2Æ=Õ®Ëd0E©nFÊÉ}S ``` No regex! [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg&code=MsY91a7LZDBFqW5Gysl9Uw&input=WyIwMDAwIDAwMDAiLCIwMDAgMCAwMDAiLCIwMDAwMDAwMDAiLCIwMDAwIDAwMDAiLCIwMCAwMDAgMDAiLCIwMDAwMDAwMDAiLCIwMCAwMDAgMDAiXQotUg) ``` 2Æ=Õ®Ëd0E©nFÊÉ}S U = input 2Æ 2 times do: = Set U to Õ U transposed ® Map each row: Ë }S Split each row on spaces (crosses), and pass each chunk through the following function, then rejoin on spaces For each chunk: d0 Replace all 0's (empty spaces) E©nFÊÉ And replace with 1 if this chunk wasn't the first or last chunk -h Take final result of second iteration ``` [Answer] # [Ruby](https://www.ruby-lang.org/), 101 bytes ``` ->s{g=->x{x.map(&:chars).transpose.map(&:join).map{|l|l[w=/\+.+\+/]&&l[w]=l[w].tr(?.,?*);l}};g[g[s]]} ``` [Try it online!](https://tio.run/##NYvBDoMgDIbvewpPIqvifQZ9EOTAlsm2OCWgmQvy7AyCa9Lm//q1er1@/UB91RoradVudiNvoYr8cnsIbTBZtJiMms39WL/m54Rjtvu4j@xD6x4I9FDzPA/IaRzhq@hI2Z1xMzrXSCaZ4dx5tS4mGxhDJBaERmWGgBwYISX4G0h3h4FkOD/5Hw "Ruby – Try It Online") Not really satisfied with it, but it's a starting point. [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 80 bytes ``` +`#( *)# #$.1$**# +ms`^(((.))*#.*^(?<-2>.)*(?(2)$)) (.*^(?<-3>.)*(?(3)$)#) $1*$4 ``` [Try it online!](https://tio.run/##TYwxDsIwDEV3nyKSPdj@qqW2jKi9ROcqDAwMMAD3D0koEpblp/8k/@f1fXtcypYDOXFBZk1uTCwxijsT7q@8q2qYOYfvup6HaQlzXXUyMUt62Pmwc7VsJKPLqRYnrt0lEG2oHXxZAQoAP9/ZMjrb/vn@@QE "Retina 0.8.2 – Try It Online") Includes header/footer that translates input/output between `.` and `+` to something more regex-friendly for the actual code. Explanation: ``` +`#( *)# #$.1$**# ``` Repeatedly horizontally fill all s between `#`s. (Since this requires an unbroken run of s, this has to repeat until completion before the second stage runs.) ``` +ms` ``` Repeat as many times as necessary, allow `^` to match after a newline, and allow `.` to match newlines. ``` ^(((.))*#.* ``` Look for a `#` and capture its indent twice. ``` ^(?<-2>.)*(?(2)$)) (.* ``` Look for a at the same indent. ``` ^(?<-3>.)*(?(3)$)#) ``` Look for another `#` at the same indent. ``` $1*$4 ``` Replace the with a `*`. [Answer] # [Japt](https://github.com/ETHproductions/japt) v2.0a0 [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), ~~22~~ ~~21~~ ~~19~~ 13 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) Uses `<space>` for `+`, `*` for `.` & `1` for `*`. ``` 2Æ=Õr/ .+ /È× ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LWg&header=ci9cLi8nKiByL1wrL1M&code=MsY91XIvIC4rIC/I1w&footer=Vq5yKicuIHJTJysgcjEnKg&input=Ii4uLi4uKy4uLgorLi4uLi4uKy4KLi4uLisuKy4uCisuKy4uLisuLgouLi4rKy4rLi4i) (Header & footer convert I/O to characters used in spec) ``` 2Æ=Õr/ .+ /È× :Implicit input of string U 2Æ :Map the range [0,2) = :Reassign to U Õ :Transpose U r/ .+ / :Global RegEx replacement È :Pass each match through a function × : Replace all * with 1 :Implicit output of last element in array ``` [Answer] # [JavaScript (Node.js)](https://nodejs.org), 85 bytes ``` a=>(g=m=>m[0].map((_,i)=>m.map(l=>l.join``.replace(/(?<=x.*)-(?=.*x)/g,8)[i])))(g(a)) ``` [Try it online!](https://tio.run/##dVJLb5wwEL77V/hSYXsW016qqArk1ENPOfQY0q61ZQkRLy0k2n@/nRkbw@ZhIZj55vXNZ57dq5sOp2ac0374V12OMr@4vFB13uVF9/D10XZuVOrvrtHos9PmRWufh6bf7@2pGlt3qFSm7m7zszU6VXe5NWed1bsb/dA8aq1VrZzWl7maZplLJ/NCOjuNbTOrrOzLHjJtj8Pppzs8qYmiQsrD0E9DW9l2qBW6Uia/@vFl/lH2XyaquX@Zty69kx0nTshxxk7Zn/I3ZF2tmapKMEH7jKOa7HxqOqUDC4751Wh8u25VWtwjSTG6QkDQmQt4Dm2Os4zGXNx228dP3lafqRi2SEqI3SI3hJhEv2eOTCitcrP69l0jpIUWgoRVe2HxAL0EGxAsf66i4O2r6ILhsUsujYyOABtsgsHwgaUxBmVaSEOOAc4OHX02cLKnBgvMjlmm@v6MwxVnhkykjB8IEHYFLIRIFk1jzbIYMbJEkyDguTELGKInQAZgLQwTLRcyDZ/FO0eNNgpFanGxKD/AqiMIWNdk0xgvLDBbP8CIjdLeNO8nfgJBZMt0IWi76Agm3vyiIuooNqwIWNYOtxE0xS4sKd@xeDv8Y2BdAv@Vvb78Bw "JavaScript (Node.js) – Try It Online") Input / Output as character matrix. Use `x` for `+`, `-` for `.`, `8` for `*`. First, convert dots `.` between two crosses `+` in a row into star `*`. ``` l.join``.replace(/(?<=\+.*)\.(?=.*\+)/g,'*') ``` Then. rotate the matrix ``` a=>m=>m[0].map((_,i)=>m.map(l=>l[i])) ``` Repeat twice, and get the result. [Answer] # [Red](http://www.red-lang.org), ~~160~~ 154 bytes ``` func[b][loop 2[t: collect[until[parse keep rejoin collect[forall b[keep take b/1]][any[thru"+"change copy p to"+"(replace/all p".""*")]]empty? b/1]]b: t]] ``` [Try it online!](https://tio.run/##lVK7bsQgEOz9FSuqJCv5lJRu8g9pVxSYW8fOEUAcLvz1jp/oTJLCyEKzD3aYwYGv4wdfSRZNNTa91VRLMs55eKNYgXbGsI7U29gZ8ircGW7MHgJ/uc4We71xQRkDNS3FqG4M9eVVSlJ2oNiGXqDQrbKfPB3xA0w9bko9BfZGab7Mh70ohXgRz1Lyt4/D@zqhriBKOU4ErHQLprMMDVAhymnhvIkF4xKseF0i78E1@tWz50EC@dDZuLBI2HBTFH@z74xYblFixC1/YEQ8z4KZkl1riTNCPGrec7ih@cuqy5zzSh@Y00Sc74DphnjwoMyZc7/P@vDwcJg8T5LSP5CocoD/Oz/@AA "Red – Try It Online") [Answer] # [Perl 5](https://www.perl.org/) (`-p`), 80 bytes ``` / /;$l="."x"@-";1while s/(\+\S*)\.(\S*\+)|(\+$l(.$l)*)\.($l(.$l)*\+)/$1$3*$2$5/s ``` [Try it online!](https://tio.run/##VY7BCsIwDIbveQopPWz7WbopOw3Bd/Da68BBccMJevDZrV3TaS0tf/olf5J5uLnOe0Om1@6oWD3VqVZ9@7iMbtgtprCw56q0XASxKF8BaFewdmWkWxxSRrf6UOm97sziPa8H4RE4xSSCyCDplUEYsVSmMkmFGziw8aiIDopG5Dw66QfSBjIfhDQA2T6cN/gqUiNsi6xf5GOkOejPmlZ/T/N9nK6Lr5tm/gA "Perl 5 – Try It Online") [Answer] # [Python 3.8](https://docs.python.org/3.8/), 354 bytes ``` e,r=enumerate,range def f(s): s=s.split('\n') t=[(x,y) for y,i in e(s) for x,c in e(i) if c=='+'] #t is the '+'es coordinates m=sum((l for x,y in t for u,v in t if (x==u)!=(y==v)and x<=u and y<=v and (l:=[[(y,j)for j in r(x+1,u)],[(i,x)for i in r(y+1,v)]][x==u]) and #l is coordinates of cells between two '+'es all(s[i][j]=='.' for i,j in l)),[]) return '\n'.join(''.join([c,'*'][(y,x) in m]for x,c in e(i))for y,i in e(s)) ``` [Try it online!](https://tio.run/##bVLLjtswDDxHX6Ge9KBWaNAeimC1P6LVwU3sVoatGH4E9tenlKzYabBEkFCjITlDpVvGv9fw41fX3@@l6k0ZprbsixHzIvwpyaWsaMUHcSKHwQx66Bo/cvYZmCCH0Vg@q0XQ6trTRXnqAy2Rm86zOq9nL6iv6NkYBsyRQ2uGqeW8yaQlksZ0mNRtPSCdz8ZM4pvhizE3UYQLnd/NRGOyvJtbTHhzMtbyRdUiVtextuczHNUknLLcqzld@PViwYubcM7Gzk6kVkXT8MF6Z2uH8jRLMrxKrRohlHXosi/HqQ80etb11QfO8q89KyaZixJmEUta92JcvCxG3Lveh5HHuRXeG1M/j2yLjjdF@/tS0OE0Tl1T8n2qf@yeMoF66Wbtv0dZd5@62e/q7eiEIj1jjGjQMShGTkn8ggzJlJIVgQyBlICFAFshgNQyFUbo7QNZGBGKLNhZkKD4yZAE2AvzRJ0Kk4yVFZsBwXgm6k0t7BA8DGDrjQVAYLeZUinJOiCpXQdkHbC3f5Gms7SvINjUJrmrWtj2iD43Ydkm7pE8qYrAw3Z@jbxT7JJWGjsDeR3@NbCbAI3PbI8n9/R3kD8Fxv0f "Python 3.8 (pre-release) – Try It Online") (without comments or unnecessary white-space) [Answer] # [Japt](https://github.com/ETHproductions/japt) [`-R`](https://codegolf.meta.stackexchange.com/a/14339/), 19 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ``` yV=_gZa0 oZb0)_p yV ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LVI&code=eVY9X2daYTAgb1piMClfcAp5Vg&footer=Vm1fbUBYKzEgZyIgK1x1MjVjYiI&input=WwogWy0xLC0xLDAsMCwtMSwtMV0sCiBbLTEsMCwwLC0xLDAsMF0sCiBbLTEsMCwwLC0xLDAsLTFdLAogWy0xLC0xLC0xLC0xLC0xLC0xXSwKIFswLC0xLDAsLTEsMCwtMV0KXQ) ``` U = U.y // for each columns (V = function(Z) { return Z.g // modify (Z.a(0).o(Z.b(0)), // indexes from first cross to Last cross function(Z) { return Z.p() // power of 2: -1 => 1 }) }); V = U.y(V); // repeat transposing Outputs a matrix of values: -1 -> ground, 1 -> poppies, 0 -> cross Footer maps to [' ','○','+'] ``` With the help of @Shaggy and @Embodiment of Ignorance ]
[Question] [ This challenge is about writing code to solve the following problem. Given two strings A and B, your code should output the start and end indices of a substring of A with the following properties. * The substring of A should also match some substring of B. * There should be no longer substring of A that satisfies the first property. For example: ``` A = xxxappleyyyyyyy B = zapplezzz ``` The substring `apple` with indices `4 8` (indexing from 1) would be a valid output. **Functionality** You can assume the input will be on standard in or in a file in the local directory, that is your choice. The file format will simply be two strings, separated by a new line. The answer should be a full program and not just a function. I would eventually like to test your code on two substrings taken from the strings in <http://hgdownload.cse.ucsc.edu/goldenPath/hg38/chromosomes/> . **Score** This is code-golf with a twist. Your code must be run in `O(n)` time, where `n` is the total length of the input. **Languages and libraries** You can use any language which has a freely available compiler/interpreter/etc. for Linux. You should only use standard open source libraries not designed to solve this task. In case of dispute, I will count this as any library which either comes as standard with your language or one that you can install in a default ubuntu machine from a default repository. **Useful information** There are at least two ways to solve this problem in linear time. One is to first compute the suffix tree and the second is to first compute the suffix array and the LCP array. * [Here](http://web.stanford.edu/~mjkay/gusfield.pdf) is a full and (perhaps over-)detailed explanation of linear time suffix tree construction (it turns out some of the figures are messed up unfortunately). There is also a very nice SO answer about linear time suffix tree construction at <https://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english> . It includes a link to source code too. Another detailed explanation can be found [here](http://programmerspatch.blogspot.com.au/2013/02/ukkonens-suffix-tree-algorithm.html), this time giving a full solution in C. * Section 2 of <http://www.cs.cmu.edu/~guyb/realworld/papersS04/KaSa03.pdf> gives a linear time suffix array construction algorithm and Appendix A has C++ source code. This answer tells you how then to compute the longest common substring <https://cs.stackexchange.com/questions/9555/computing-the-longest-common-substring-of-two-strings-using-suffix-arrays> . Section 5 of <https://courses.csail.mit.edu/6.851/spring12/scribe/lec16.pdf> which also has an associated video lecture <https://courses.csail.mit.edu/6.851/spring12/lectures/L16.html> also explains the same algorithm starting at 1:16:00. [Answer] ## Python 2, 646 bytes ``` G=range;w=raw_input;z=L,m,h=[0]*3 s=w();t=len(s);s+='!%s#'%w();u=len(s);I=z*u def f(s,n): def r(o): b=[[]for _ in s];c=[] for x in B[:N]:b[s[x+o]]+=x, map(c.extend,b);B[:N]=c M=N=n--~n/3;t=n%3%2;B=G(n+t);del B[::3];r(2);u=m=p=r(1)>r(0);N-=n/3 for x in B*1:v=s[x:x+3];m+=u<v;u=v;B[x/3+x%3/2*N]=m A=1/M*z or f(B+z,M)+z;B=[x*3for x in A if x<N];J=I[r(0):n];C=G(n) for k in C:b=A[t]/N;a=i,j=A[t]%N*3-~b,B[p];q=p<N<(s[i:i-~b],J[i/3+b+N-b*N])>(s[j+t/M:j-~b],J[j/3+b*N]);C[k]=x=a[q];I[x]=k;p+=q;t+=1-q return C S=f(map(ord,s)+z*40,u) for i in G(u): h-=h>0;j=S[I[i]-1] while s[i+h]==s[j+h]:h+=1 if(i<t)==(t<j)<=h>m:m=h;L=min(i,j) print-~L,L+m ``` [Try it online](https://tio.run/##RZFLk@IgFIXXza9gaspqCMn4yKxCrlXqwrJLs@klRXUZTSaowZiH0ln41x2w58EG7rkczgdUn21x1pPHYwn1Vv/K@M3Otw@lq67lPaz90i9AjKQXogZuhPIWTpkmDeUNg9dvg@b768DJ3V95Bb3XoX2W45w0vqYRwq6oydkuX1IQQubnGn9gpXEj@Q6ERC9OMU6ZiyiRUSoaYdhZSgbGRy/ltiK7H5lpM733U8qfm2CH8AYS0EFw18PQculBOJjwOSyJZi3l@@zkjotCyWsycYQlVFCTMZ3WZER5EoD1Ifw/2xtHV7DJkWHWVDLo4qu1XW2gGYbMDMLhxLPJJcIzGA83Xo@tNydz1vsbynqbLYwX/jtwhlWOTZxI/gYr4UIjLfnCAdKv3KPbtohSmIlWDhO@BeUfnsUg8cLgnvpzUUl@gSpOYtIIFSkrSv9NKAuUsiRILRCd2taBtcNNdPjTPri2a/GFOEowsBUXyVfCSDjyisGFtwzGwQXhOmu72kKgd8iJe@lzvfcbexvv58jvKHKYymEuSec@swigmI74Ad7FSigZjCXCt0KdMmzxWCEBHEsho8IGIPsCRMUtBSBtfKCx9ZZRCQVfQ6k0sbelqKqVboP72l@z8vEwxmyr6pR9fg3UP6u@738D "Python 2 – Try It Online") This uses the skew algorithm described in "Simple Linear Work Suffix Array Construction" by Kärkkäinen and Sanders. The C++ implementation included in that paper already feels a little "golfy", but there is still plenty of room for making it shorter. For example, we can recurse until arriving at an array of length one, instead of short circuiting as in the paper, without violating the `O(n)` requirement. For the LCP part, I followed "Linear-Time Longest-Common-Prefix Computation in Suffix Arrays and Its Applications" by Kasai et al. The program outputs `1 0` if the longest common substring is empty. Here is some development code that includes an earlier version of the program that follows the C++ implementation a bit more closely, some slower approaches for comparison, and a simple test case generator: ``` from random import * def brute(a,b): L=R=m=0 for i in range(len(a)): for j in range(i+m+1,len(a)+1): if a[i:j] in b: m=j-i L,R=i,j return L+1,R def suffix_array_slow(s): S=[] for i in range(len(s)): S+=[(s[i:],i)] S.sort() return [x[1] for x in S] def slow1(a,b): # slow suffix array, slow lcp s=a+'!'+b S=suffix_array_slow(s) L=R=m=0 for i in range(1,len(S)): x=S[i-1] y=S[i] p=s[x:]+'#' q=s[y:]+'$' h=0 while p[h]==q[h]: h+=1 if h>m and len(a)==sorted([x,y,len(a)])[1]: m=h L=min(x,y) R=L+h return L+1,R def verify(a,b,L,R): if L<1 or R>len(a) or a[L-1:R] not in b: return 0 LL,RR=brute(a,b) return R-L==RR-LL def rand_string(): if randint(0,1): n=randint(0,8) else: n=randint(0,24) a='zyxwvutsrq'[:randint(1,10)] s='' for _ in range(n): s+=choice(a) return s def stress_test(f): numtrials=2000 for trial in range(numtrials): a=rand_string() b=rand_string() L,R=f(a,b) if not verify(a,b,L,R): LL,RR=brute(a,b) print 'failed on',(a,b) print 'expected:',LL,RR print 'actual:',L,R return print 'ok' def slow2(a,b): # slow suffix array, linear lcp s=a+'!'+b+'#' S=suffix_array_slow(s) I=S*1 for i in range(len(S)): I[S[i]]=i L=R=m=h=0 for i in range(len(S)): if I[i]: j=S[I[i]-1] while s[i+h]==s[j+h]: h+=1 if h>m and len(a)==sorted([i,j,len(a)])[1]: m=h L=min(i,j) R=L+h h-=h>0 return L+1,R def suffix_array(s,K): # skew algorithm n=len(s) s+=[0]*3 n0=(n+2)/3 n1=(n+1)/3 n2=n/3 n02=n0+n2 adj=n0-n1 def radix_pass(a,o,n=n02): c=[0]*(K+3) for x in a[:n]: c[s[x+o]+1]+=1 for i in range(K+3): c[i]+=c[i-1] for x in a[:n]: j=s[x+o] a[c[j]]=x c[j]+=1 A=[x for x in range(n+adj) if x%3]+[0]*3 radix_pass(A,2) radix_pass(A,1) radix_pass(A,0) B=[0]*n02 t=m=0 for x in A[:n02]: u=s[x:x+3] m+=t<u t=u B[x/3+x%3/2*n0]=m A[:n02]=1/n02*[0]or suffix_array(B,m) I=A*1 for i in range(n02): I[A[i]]=i+1 B=[3*x for x in A if x<n0] radix_pass(B,0,n0) R=[] p=0 t=adj while t<n02: x=A[t] b=x>=n0 i=(x-b*n0)*3-~b j=B[p] if p==n0 or ((s[i:i+2],I[A[t]-n0+1])<(s[j:j+2],I[j/3+n0]) if b else (s[i],I[A[t]+n0])<(s[j],I[j/3])):R+=i,;t+=1 else:R+=j,;p+=1 return R+B[p:n0] def solve(a,b): # linear s=a+'!'+b+'#' S=suffix_array(map(ord,s),128) I=S*1 for i in range(len(S)): I[S[i]]=i L=R=m=h=0 for i in range(len(S)): if I[i]: j=S[I[i]-1] while s[i+h]==s[j+h]: h+=1 if h>m and len(a)==sorted([i,j,len(a)])[1]: m=h L=min(i,j) R=L+h h-=h>0 return L+1,R stress_test(solve) ``` ]
[Question] [ The [Cashier's Algorithm](https://en.wikipedia.org/wiki/Greedy_algorithm) is an algorithm for making change in the minimal number of coins that works quite well for most currency systems. However like most greedy algorithms it is not without its flaws. If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm will fail to find the optimal change. Take the following example: We have 4¢, 3¢, and 1¢ coins. We want to make 6¢. The Cashier's Algorithm will first select as many of the largest coin (one 4¢ to start) and subtract and repeat. This will result in one 4¢ coin and two 1¢ coins, for a total of 3 coins. Unfortunately for the Algorithm there is a way to make 6¢ with only two coins (two 3¢ coins). A system of change will be considered canonical iff for all integer values the Cashier's Algorithm will find the optimal number of coins. ## Task You task will be to take a system as a either an unordered container or sorted ordered container of integers representing coin values and output a truthy value if the system input is canonical and falsy otherwise. Your program should work for all systems that can create any value. (i.e. all systems will have a 1¢ coin) This is code golf least bytes wins. ## Test cases *This list is by no means exhaustive, your program should work for all valid input* ``` 1, 3, 4 -> 0 1, 5, 10, 25 -> 1 1, 6, 10, 25 -> 0 1, 2, 3 -> 1 1, 8, 17, 30 -> 0 1, 3, 8, 12 -> 0 1, 2, 8, 13 -> 0 1, 2, 4, 6, 8 -> 1 ``` [Answer] # Haskell, ~~94~~ ~~87~~ 82 bytes ``` f s=and[j i-2<j(i-x)|let j i=last$0:[1+j(i-x)|x<-s,x<i],i<-[1..2*last s],x<-s,x<i] ``` this solution works by defining a function `j` which perform's the cashier's algorithm and tells us how many coins the cashier used. we then check up to twice the biggest number in the list, assuming that the system has been canonical for all previous numbers, that taking the biggest possible coin is the right choice. this solution assumes the input is sorted. proof checking up to twice the biggest number is enough: assume that the system is not canonical for some number `i`, and let `k` be the biggest number in the list not bigger than `i`. assume that `i >= 2k` and the system is canonical for all numbers less than `i`. take some optimal way to make `i` out of coins, and assume it doesn't contain the coin `k`. if we throw away one of the coins, the new sum of coins must be bigger than `k` and smaller than `i` - but the cashier's algorithm on this number would use the `k` coin - and therefore, this set of coins can be replaced with an equal set of coins containing the coin `k`, and therefore there is a set of coins containing the coin `k` for the number `i`, and by induction the cashier's algorithm returns the optimal choice. this argument really shows that we only need to check until the sum of the two biggest elements - but it is lengthier to do so. Edit: five bytes off thanks to Ørjan Johansen! [Answer] # Pyth, ~~18~~ 15 bytes ``` !x#eST.gsky_S*e ``` [Test suite](https://pyth.herokuapp.com/?code=%21fxlDTeST.gsky_S%2ae&input=1%2C+8%2C+17%2C+30&test_suite=1&test_suite_input=1%2C+2%2C+3%0A1%2C+2%2C+4%0A1%2C+3%2C+4&debug=0) A different sort of brute force. This starts by forming all collections of coins with up to k of each, where k is the largest coin, which is assumed to be the last coin. I believe this always sufficient to form two sets of coins with the same sum, one greedy and one shorter, whenever such a pair exists. I then locate such a pair as follows: The subsets are generated in order of increasing size, and lexicographically by position in the input secondarily. Group the coin collections by their sums, stably. Each coin collection is generated in descending order, so the greedy solution will be the first element of the group if and only if the greedy solution is optimal, and it will be the last element of the group lexicographically. Thus, we find the greedy solution, and filter on a nonzero index in the group. If the coin set is cannonical, this will filter out everything, so we simply logically negate the result and output. Explanation: ``` !x#eST.gsky_S*e !x#eST.gsky_S*eQQ Variable introduction. Q = eval(input()) - sorted list of coins. eQ Greatest coin in the list * Q Repeat that many times. S Sort the coins _ Reverse, so we have the coins in descending order. y Form all subsets, in increasing size then decreasing lexicographic order. .gsk Group by sum x# Filter by the index in the group of eST The last element lexicographically (greedy solution). ! Logically negate. ``` [Answer] # PHP, 323 Bytes Same way as other count the coins until the sum of the two last elements in the array ``` <?function t($g){rsort($g);$m=array_slice($g,1);for($y=1,$i=$g[0];$i<$g[0]+$m[0];$i++){$a=$b=$i;$p=0;$r=$s=[];while($a||$b){$o=$n=0;$g[$p]<=$a?$a-=$r[]=$g[$p]:$o=1;($m[$p]??1)<=$b?$b-=$s[]=$m[$p]:$n=1;$p+=$o*$n;}$y*=count($r)<=count($s);}return$y;}for($i=0,$t=1;++$i<count($a=$_GET[a]);)$t*=t(array_slice($a,0,$i+1));echo$t; ``` # My best and longest answer I believe >370 Bytes I give only an expanded version cause it is longer then my answer before ``` for($x=1,$n=0,$f=[];++$n<count($a)-1;){ $z=array_slice($a,0,$n+1); $q=$a[$n]-$a[$n-1]; $i=array_fill(1,$c=max($a[$n+1]??1,11),"X");#$q*$a[$n] $f=range($a[$n],$c,$q); $f[]=2*$a[$n]; for($d=[$z[$n]],$j=0;$j<$n;){ $f[]=$a[$n]+$d[]=$z[$n]-$z[$j++]; } while($f){ $i[$t=array_pop($f)]="T"; foreach($d as $g) if(($l=$t+$g)<=$c)$f[]=$l; } foreach($i as$k=>$v){ if(in_array($k,$z))$i[$k]="S"; } #var_dump($i); if($i[$a[$n+1]]=="X")$x*=0; } echo$x; ``` ## Explanation for this answer [Online Version](http://sandbox.onlinephpfunctions.com/code/331bdc6675c34841bd322ec1adb0cd75dfd2eeb5) 1. Set all in the array to false == X 2. Set all numbers in the array you control to S 3. Found differences between the last S and the other S or 0 4. Start at last S in the array 5. Set all number to D Where Last S+ one of all differences 6. Begin at all D 7. SET "T" to D values in the array 8. GOTO 5 Repeat it with all found D I did it not really in the code 9. If next item in the Array has X it is a false case else True Additional Steps Difference is in the case in the snippet 3 Between 1 and 4 are 2 X This means you need the second D by Step 5. After this value in this case 10 are all cases true I could see so far that there is a relationship between difference and the count in the array you control to calculate how much D (Step 5) you need to get the point before you find the last false case. You set multiple values from the last item directly to true. These Points can make a difference to decide if it could been that the greedy count of coins with the next value is same then the multiple of the last in the array. On the other way you can set enemy 1. Set first enemy at 1+Last S 2. From this Point add each value in the array to set the next enemies 3. Start with last enemy Goto 2 If you now have enemies and true cases in it the probability grows that the counts can be the same With more D the probability sinks. ``` table{width:80%} td,th{width:45%;border:1px solid blue;} ``` ``` <table> <caption>Working [1,4]</caption> <tr><th>Number</th><th>Status</th></tr> <tr><td>1</td><td>S</td></tr> <tr><td>2</td><td>X</td></tr> <tr><td>3</td><td>X</td></tr> <tr><td>4</td><td>S</td></tr> <tr><td>5</td><td>X</td></tr> <tr><td>6</td><td>X</td></tr> <tr><td>7</td><td>D3</td></tr> <tr><td>8</td><td>D4</td></tr> <tr><td>9</td><td>X</td></tr> <tr><td>10</td><td>D3D3</td></tr> <tr><td>11</td><td>D4D3</td></tr> <tr><td>12</td><td>D4D4</td></tr> <tr><td>13</td><td>D3D3D3</td></tr> <tr><td>14</td><td>D4D3D3</td></tr> <tr><td>15</td><td>D4D4D4</td></tr> <tr><td>16</td><td>D4D4D3</td></tr> </table> <ul> <li>S Number in Array</li> <li>D Start|End point TRUE sum Differences from last S</li> <li>X False</li> </ul> ``` plus ? Bytes Thank You @JonathanAllan to give me wrong test cases 262 Bytes Nearly but not good enough 4 wrong testcase in the moment [test cases](http://sandbox.onlinephpfunctions.com/code/bb1b7985dec56dfc788bf54ce2e99e550b45e892) [1,16,256] before should true after false ``` <?for($q=[1],$i=0,$t=1,$w=[0,1];++$i<count($a=$_GET[v]);$w[]=$a[$i],$q[]=$m)($x=$a[$i]-$a[$i-1])>=($y=$a[$i-1]-$a[$i-2])&&((($x)%2)==(($m=(($a[$i]+$x)*$a[$i-1])%$a[$i])%2)&&$m>array_sum($q)||(($x)%2)==0&&(($a[$i]-$a[$i-2])*2%$y)==0||in_array($m,$w))?:$t=0;echo$t; ``` Ascending Order of the Array ## Explanation ``` for($q=[1],$i=0,$t=1,$w=[0,1] # $t true case $q array for modulos $w checke values in the array ;++$i<count($a=$_GET[v]) #before loop ;$w[]=$a[$i],$q[]=$m) # after loop $q get the modulo from the result and fill $w with the checked value ($x=$a[$i]-$a[$i-1])>=($y=$a[$i-1]-$a[$i-2]) # First condition difference between $a[i] and $a[$i-1] is greater or equal $a[$i-1] and $a[$i-2] # if $a[$-1] == 1 $a[$i-2] will be interpreted as 0 && ## AND Operator with the second condition ( (($x)%2)== # See if the difference is even or odd (($m=(($a[$i]+$x)*$a[$i-1])%$a[$i])%2)&&$m>array_sum($q) # After that we multiply the result with the lower value *$a[$i-1] # for this result we calculate the modulo of the result with the greater value %$a[$i] # if the difference and the modulo are both even or odd this belongs to true # and the modulo of the result must be greater as the sum of these before # Ask me not why I have make try and error in an excel sheet till I see this relation || (($x)%2)==0&&(($a[$i]-$a[$i-2])*2%$y)==0 # or differce modulator is even and difference $a[$i],$a[$i-1] is a multiple of half difference $a[$i-1],$a[$i-2] || in_array($m,$w) # if the modulo result is equal to the values that we have check till this moment in the array we can also neglect the comparison ) ?:$t=0; # other cases belongs to false echo$t; #Output ``` It looks like that what I have seen the table contains values from [1,2,3,4,5,6] and I change only the last item until 9. for 2to3 and 4to5 we create the value of the lower value in the modulo calculation ``` table{width:95%;}th,td{border:1px solid} ``` ``` <table><tr><th>difference</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr> <tr><th>difference modulo 2</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr> <tr><th>value</th><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr> <tr><th>result</th><td></td><td>3</td><td>8</td><td>15</td><td>24</td><td>35</td></tr> <tr><th>modulo value great</th><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr> <tr><th>modulo 2</th><td></td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> <tr><th></th><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><th>difference</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>2</td></tr> <tr><th>difference modulo 2</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>0</td></tr> <tr><th>value</th><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>7</td></tr> <tr><th>result</th><td></td><td>3</td><td>8</td><td>15</td><td>24</td><td>45</td></tr> <tr><th>modulo value great</th><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>3</td></tr> <tr><th>modulo 2</th><td></td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> <tr><th></th><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><th>difference</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>3</td></tr> <tr><th>difference modulo 2</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr> <tr><th>value</th><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>8</td></tr> <tr><th>result</th><td></td><td>3</td><td>8</td><td>15</td><td>24</td><td>55</td></tr> <tr><th>modulo value great</th><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>7</td></tr> <tr><th>modulo 2</th><td></td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> <tr><th></th><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><th>difference</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>4</td></tr> <tr><th>difference modulo 2</th><td></td><td>1</td><td>1</td><td>1</td><td>1</td><td>0</td></tr> <tr><th>value</th><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>9</td></tr> <tr><th>result</th><td></td><td>3</td><td>8</td><td>15</td><td>24</td><td>65</td></tr> <tr><th>modulo value great</th><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>2</td></tr> <tr><th>modulo 2</th><td></td><td>1</td><td>0</td><td>1</td><td>0</td><td>0</td></tr></table> ``` [Answer] # JavaScript (ES6), 116 ~~125 130~~ ``` l=>eval("r=(d,k)=>d?--k&&l.map(v=>v>d||r(d-v,k)):x=1;for(x=l[0]*2;--x>1;r(x,g))g=0,h=x,l.map(v=>(g+=h/v|0,h%=v));x") ``` This needs the input array sorted in descending order. For each value from 2N downto 2 (N being the max coin value), it find the number of coins from the greedy algorithm and try to find a smaller set of coins. *Less golfed* ``` l=>{ // recursive function to to find a smaller set of coins // parameter k is the max coin limit r = (d,k) => d // check if difference is not 0 ? --k // if not, and if the number of coins used will be less than limit && l.map(v => v>d || r(d-v, k)) // proceed with the recursive search : x=1 // if diff is 0, value found, set x to 1 to stop the loop for( x=l[0]*2; --x > 1; ) g=0, h=x, l.map(v=>(g += h/v|0, h %= v)), // find g with the greedy algorithm r(x,g) // call with initial difference equal to target value return x } ``` **Test** ``` f= l=>eval("r=(d,k)=>d?--k&&l.map(v=>v>d||r(d-v,k)):x=1;for(x=l[0]*2;--x>1;r(x,g))g=0,h=x,l.map(v=>(g+=h/v|0,h%=v));x") /* No eval f=l=>{ r=(d,k)=>d?--k&&l.map(v=>v>d||r(d-v,k)):x=1; for(x=l[0]*2;--x>1;r(x,g)) g=0,h=x,l.map(v=>(g+=h/v|0,h%=v)); return x; }*/ ;[ [[100,50,20,10,5,2,1],1], [[4,3,1],0], [[25,10,5,1],1], [[25,10,6,1],0], [[3,2,1],1], [[30,17,8,1], 0], [[12,8,3,1],0], [[13,8,2,1], 0] ].forEach(t=>{ var i=t[0],k=t[1],r=f(i), msg=((r==k)?'OK ':'KO ')+i+' -> '+r + (r==k?'':' (should be '+k+')') O.textContent += msg+'\n' }) function test() { var i=I.value.match(/\d+/g).map(x=>+x).sort((a,b)=>b-a) O.textContent = i+' -> '+f(i)+'\n'+O.textContent } ``` ``` #I { width:50% } ``` ``` <input id=I value='1 4 9'><button onclick='test()'>test</button> <pre id=O></pre> ``` [Answer] # Python, ~~218 211~~ 205 bytes -1 byte thanks to @TuukkaX (a space could be deleted between `<3` and `or`) ``` from itertools import* g=lambda x,c,n=0:x and g(x-[v for v in c if v<=x][0],c,n+1)or n lambda c:len(c)<3or 1-any(any(any(x==sum(p)for p in combinations(c*i,i))for i in range(g(x,c)))for x in range(c[0]*2)) ``` **[repl.it](https://repl.it/DvoH/4)** Input in descending order. Horribly brute force. Any set of a single unit coin and some other coin is canonical. For larger sets the smallest fail case, if one exists will be greater than or equal to the 3rd smallest coin (not sure myself how it could be equal!) and less than the sum of the two largest coins - see [this paper](https://ecommons.cornell.edu/bitstream/handle/1813/6219/94-1433.pdf?sequence=1&isAllowed=y) (which actually references another but also gives an O(n^3) method). `g` counts the coins used by the greedy method, and the unnamed function traverses the possible candidates (actually from 0 to one less than twice the largest coin to save bytes) and looks for any collection of less coins that also sum to that amount. `g` works by performing what a cashier would, it recursively takes the largest coin less than or equal to the amount still to make up, `[v for v in c if v<=x][0]` away, and counts up the number of coins used, `n`. The unnamed function returns 1 if `len(c)` is less than 3, and otherwise tests that it is not the case, `1-...`, that any values in the range of possibilities, `range(c[0]*2)))`, are possible with less coins, `i in range(g(x,c))`, by making a collection of that many of every coin, `c*i`, and examining all combinations of `i` coins, `combinations(c*i,i)`, to see if any sum to the same value. [Answer] # Jelly ([fork](https://github.com/miles-cg/jelly/tree/frobenius)), ~~15~~ 14 bytes ``` SRæFµS€Ṃ=$Ṫµ€Ȧ ``` This solution uses the bounds for counter-examples from this [paper](https://arxiv.org/PS_cache/arxiv/pdf/0809/0809.0400v1.pdf). There, the author uses a tight bound for the counter-example, but in the interests of golfing, the range of the sum of coin denominations is used which is larger and contains that bound. This program computes all test cases in less than a second on my machine. Unfortunately, this relies on a [branch](https://github.com/miles-cg/jelly/tree/frobenius) of Jelly where I was working on implementing a Frobenius solve atom so you cannot try it online. ## Usage ``` $ ./jelly eun 'SRæFµS€Ṃ=$Ṫµ€Ȧ' '1,2,4,6,8' 1 ``` The performance is good and can solve all test cases at once in less than a second. ``` $ time ./jelly eun 'SRæFµS€Ṃ=$Ṫµ€Ȧ¶Ç€' '[[1,3,4],[1,5,10,25],[1,6,10,25],[1,2,3],[1,8,17,30],[1,3,8,12],[1,2,8,13],[1,2,4,6,8]]' [0, 1, 0, 1, 0, 0, 0, 1] real 0m0.793s user 0m0.748s sys 0m0.045s ``` # Explanation ``` SRæFµS€Ṃ=$Ṫµ€Ȧ Input: list of integers C µ Start a new monadic chain S Sum R Range, [1, 2, ..., sum(C)] æF Frobenius solve for each X in the range using coefficients from C This generates all vectors where the dot product of a vector with C equals X, ordered by using values from the start to end of C µ€ Start a new monadic chain that operates on each list of vectors S€ Sum each vector $ Monadic hook on the sums Ṃ Minimum (This is the optimal solution) = Vectorized equals, 1 if true else 0 Ṫ Tail (This is at the index of the greedy solution) Ȧ All, returns 0 if it contains a falsey value, else 1 ``` [Answer] ## JavaScript (ES6), ~~144~~ ~~132~~ ~~124~~ ~~122~~ 110 bytes ``` a=>![...Array(a[0]*2)].some((_,i)=>(g=(a,l=0,n=i)=>[a.filter(c=>c>n||(l+=n/c|0,n%=c,0)),-l*!n])(...g(a))[1]>0) ``` Requires the array to be sorted in descending order. Uses the observation in the linked paper that if the system is not canonical then there is at least one value less than 2a[0] which takes fewer coins when decomposed using the unused coins from the initial greedy algorithm. Edit: Saved 12 bytes by realising that I could check all the coins even though I had already reached the target value. Saved 8 bytes by switching my intermediate output from `[l,b]` to `[b,-l]`; this allowed me to pass the first result directly as the parameter of the second call, plus also a small saving detecting whether the second call was successful. Saved 2 bytes by moving the definition of `g` into the `some` callback, allowing me to avoid unnecessarily passing in the loop variable twice. Saved 12 bytes by switching from my recursive helper function to a call to `filter` (made possible by my intermediate output switch). [Answer] # Perl, 69 bytes Includes +2 for `-pa` Give coins in descending order on STDIN. You can optionally leave out the `1` coin. ``` coins.pl <<< "4 3 1" ``` `coins.pl`: ``` #!/usr/bin/perl -pa $_=!map{grep$`>=$_&&($n=$G[$`-$_]+1)<($G[$`]||=$n),@F,/$/}1..2*"@F" ``` Builds up the number of coins used by the cashiers algorithm in `@G` for amounts 1 to twice the largest coin. For each amount checks that if that amount is reduced by 1 coin value the cashiers algorithm needs at most 1 less coin. If not this is a counterexample (or there was an earlier counterexample). I could stop at the first counterexample but that takes more bytes. So the time complexity is `O(max_coin * coins)` and space complexity is `O(max_coin)` ]
[Question] [ **Closed**. This question needs to be more [focused](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Update the question so it focuses on one problem only by [editing this post](/posts/22992/edit). Closed 7 years ago. [Improve this question](/posts/22992/edit) Your goal is to write "Hello, World!" (minus the quotes). This is a [popularity-contest](/questions/tagged/popularity-contest "show questions tagged 'popularity-contest'"), so most up votes wins. Code length will be used to break ties. Anything goes, as long as it is within the following rules: * All characters must be either letters or numbers, so you may only use characters in the string "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". * All code you use must be in one file, with the exception of imported modules/classes/whatever they're called in your favourite language. * Only the standard libraries/frameworks for your language of choice are allowed (for example, Python's Math module is allowed, but Numpy, Scipy, and Pygame are not). I will allow TkInter as it is the de facto standard for GUIs in Python. * No input is permitted, be it reading from stdin, reading a file, displying an image, or reading from the web. +10 brownie points if you figure out how to do it in Java without bending the rules. --- On your marks, get set, code! EDIT: braces ({}), brackets ([]), and parentheses (()) are allowed as this would be pretty much impossible for most languages without them. I'm also removing the character limit rule. Hopefully this will make it more interesting. EDIT^2: white space is also allowed. My brain isn't working properly, sorry. >.< [Answer] # Perl Some say perl is a language full of ascii noise and random symbols like `$`... That is not true :P ``` s zzHelloq worldmz and s zqzchr 44ze and s zmzchr 33ze and print ``` > > Let's break this up into subexpressions: > > ``` > (s zzHelloq worldmz) and (s zqzchr 44ze) and (s zmzchr 33ze) and (print) > ``` > > > It should be obvious that it executes from left to right as long as every expression returns true. But what on earth is `s zqzchr 44ze`? > In perl, there is a group of ["quote-like operators"](http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators) which includes `q(str)`, `qw(li st)`, `/regex/`, `s/from/to/` among other things. It turns out all of these operators can use almost any character as a delimeter, with a couple pecularities: opening parethesis has to be closed by a matching closing parenthesis, and if you wish to **use a letter as a delimiter** you have to put a space after the operator letter (to disambiguate it from a bareword). > In this case we see three uses of the `s///` (regex substitution) operator: > > ``` > s//Helloq worldm/ > s/q/chr 44/e > s/m/chr 33/e > ``` > > All delimited by the character `z`. The `/e` flag on the last two causes the substitution to be interpreted as code to be evaluated, rather literal text. > A fairly well-known fact about perl is that most operations default to operating on the `$_` builtin variable unless otherwise specified. All these three substitutions and the `print` operate on `$_` in this case, so first we put the words Hello world into the variable, then we fix the punctuation by using the numeric ascii values of the characters, then we print the contents of the variable. > > > > > > > > > [Answer] # C ``` int main(void) { if (putchar(72)) if (putchar(101)) if (putchar(putchar(108))) if (putchar(111)) if (putchar(44)) if (putchar(32)) if (putchar(87)) if (putchar(111)) if (putchar(114)) if (putchar(108)) if (putchar(100)) if (putchar(33)) { } } ``` [Answer] (edit - BBC basic moved to separate answer as suggested. Most of the votes on this are definitely for the LOGO answer.) # LOGO Interpreter at <http://www.calormen.com/jslogo/#> ``` TO h pd fd 100 rt 90 pu fd 50 rt 90 pd fd 100 rt 180 fd 50 lt 90 fd 50 rt 90 pu END TO e pu fd 25 rt 90 pd fd 25 rt 90 arc 270 25 lt 90 fd 25 lt 90 pu END TO l pd fd 100 pu END TO o rt 45 fd 35 pd arc 360 25 lt 45 pu END TO comma pd rt 90 arc 90 15 lt 90 pu END TO w l rt 180 l pd lt 135 fd 35 rt 90 fd 35 lt 135 l END TO r pd fd 25 rt 90 pu fd 25 rt 180 arc 180 25 rt 90 END TO d o rt 135 fd 35 lt 135 l END TO exclaim arc 360 5 fd 10 l END clearscreen setpencolor 4 pu setxy 0 150 h setxy 100 150 e setxy 200 150 l setxy 250 150 l setxy 300 150 o setxy 350 150 comma setpencolor 1 setxy 0 0 w setxy 100 0 o setxy 200 0 r setxy 300 0 l setxy 350 0 d setxy 450 0 exclaim fd 100 ``` Output (the green triangle is the turtle cursor) ![enter image description here](https://i.stack.imgur.com/akCwJ.png) [Answer] # Applescript No brackets `[]`, braces `{}` or parentheses `()` at all in this one: ``` set s to ASCII character 72 set s to s as list set end of s to ASCII character 101 set end of s to ASCII character 108 set end of s to end of s set end of s to ASCII character 111 set end of s to ASCII character 44 set end of s to space set end of s to ASCII character 87 set end of s to item 5 of s set end of s to ASCII character 114 set end of s to third item of s set end of s to ASCII character 100 set end of s to ASCII character 33 display dialog s as text ``` Output is: ![enter image description here](https://i.stack.imgur.com/x393P.png) [Answer] # Bash This sort of works, if you squint your eyes: ``` echo NN i NN i i i iNN NNi i i i i i i NN i NN i i i i i i i NNi i i NN NN echo NN i NNi i i i NN NN i i i i i i iNN i NN i i i i i i i NN i i iNN NN echo NN i NN iNNNNi NN NN iNNNNi i i i NN i NN iNNNNi NN NN iNN iNNN NN NN echo NNNNNNN NN iNN NN NN NN iNN i i i NN i NN NN iNN NNN iN NN NN iNNN N echo NN i NN NNNNNN NN NN NNi NN i i i NN N NN NNi NN NN i i NN NNi iNN N echo NN i NN NN i i NN NN NN iNN i i i NNN NNN NN iNN NN i i NN NN i NN echo NN i NN iNNNi iNN NN iNNNNi N i i NN i NN iNNNNi NN i i NN iNNNN N NN echo i i i i i i i i i i i i i i N ``` [Answer] ## base64 ``` SGVsbG8sIFdvcmxkIQ ``` Satisfies the original rules. [Answer] ## Python So what, we just assume everybody reads horizontally? For those users who like to read vertically: ``` print chr(72) print chr(101) print chr(108) print chr(108) print chr(111) print chr(44) print chr(32) print chr(87) print chr(111) print chr(114) print chr(108) print chr(100) print chr(33) ``` [Answer] # OMGROFL I'm a big fan of esoteric languages. Luckily OMGROFL is alphanumeric: ``` lol iz 72 rofl lol lol iz 101 rofl lol lol iz 108 rofl lol rofl lol lool iz 111 rofl lool loool iz 44 rofl loool loool iz 32 rofl loool loool iz 87 rofl loool rofl lool lool iz 114 rofl lool rofl lol lol iz 100 rofl lol lol iz 33 rofl lol stfu ``` The `iz` command sets a value to a variable, in this case `lol`, `lool` and `loool` serve as variables... The `rofl` command echoes out the ASCII equivalent to the number stored in the variable. The `stfu` command terminates the program ;) [Answer] ## COBOL ``` ID DIVISION DATA DIVISION 01 HELLOWORLDBINARY 05 HE COMP PIC 9999 05 LL COMP PIC 9999 05 OCOMMA COMP PIC 9999 05 SPACEW COMP PIC 9999 05 ORTEXT COMP PIC 9999 05 LD COMP PIC 9999 05 EXCLAMATION COMP PIC 9999 01 FILLER REDEFINES HELLOWORLDBINARY 05 HELLOWORLDTEXT PIC XXXXXXXXXXXXX 05 FILLER PIC X PROCEDURE DIVISION MOVE 51333 TO HE MOVE 37779 TO LL MOVE 38507 TO OCOMMA MOVE 16614 TO SPACEW MOVE 38553 TO ORTEXT MOVE 37764 TO LD MOVE 23104 TO EXCLAMATION DISPLAY HELLOWORLDTEXT GOBACK ``` Required some changes to become truly alphanumeric source only. PROGRAM-ID can be dropped. You get a generated program name (see messages). WORKING-STORAGE can be dropped. Again the compiler moans. Since both of these lines previously had missing full-stops/periods, which are no longer relevant now that the descriptions are entirely missing, the number of error messages is the same as before, and still does not affect the generated code for the program. In changing COMP-5 to COMP, the VALUE clauses are no longer allowed, as COMP 9999 is only four decimal digits whereas COMP-5 is a two-byte binary with all bit-values available. The values in the MOVEs are the decimal values which give the binary values which give the pairs of characters. Even though the COMP fields have four digits, and do not allow VALUE clauses with more than four digits, you can use more digits in the MOVE of a literal value without truncation at that point... don't ask me why. Compiler option DIAGTRUNC (which I have turned off) will produce Warning diagnostics for these. Compiler option TRUNC(BIN) could be used to treat COMP as COMP-5, but the MOVEs are another way to do it. Since it is COBOL, the output must be in UPPER CASE (a lie, but just for fun). ``` HELLO WORLD! ``` OK, relented, now produces: ``` Hello, World! ``` Which, being an odd-number of characters, required some further changes, since we can't have odd-number-byte binary fields with this compiler. Look at that line of 13 Xs! It would normally be written as X(13), but can be as I've shown... And ORTEXT is needed (or not OR, anyway) as a name because OR is a reserved word to the compiler (it means OR, of course). These are EBCDIC values, not ASCII, since it is running on an EBCDIC-aware, and Big Endian, box. Oh, COBOL requires lots of full-stops/periods. I left them out (they're banned) so got lots of compile messages. Just told the compiler to generate the code anyway (none of the messages relate to the object code). Even without DIAGTRUNC, the messages are now up to 17... ``` 1 IGYDS1003-E A "PROGRAM-ID" paragraph was not found. Program-name "CBLNAM01" was assumed. 2 IGYDS1082-E A period was required. A period was assumed before "DATA". 3 IGYDS1082-E A period was required. A period was assumed before "01". Same message on line: 11 3 IGYDS1040-E A data item was found in the "DATA DIVISION" before a section header was encountered. "WORKING-STORAGE SECTION" was assumed. 4 IGYDS1082-E A period was required. A period was assumed before "05". Same message on line: 5 6 7 8 9 10 12 13 14 IGYDS1082-E A period was required. A period was assumed before "PROCEDURE". 15 IGYPS2145-E A period was required. A period was assumed before "MOVE". 23 IGYSC1082-E A period was required. A period was assumed before "END OF PROGRAM". ``` [Answer] # Polyglot: HQ9+, H9+, HQ9++, CHIQRSX9+, HQ9+B and HQ9+2D (1 byte) ``` H ``` Thank you @victor for the list of languages. [Answer] # Javascript ``` with (function SGVsbG8sIFdvcmxkIQ(){}) atob(name) ``` Use browser's console to test. [Answer] # Ruby (using only alnums and whitespace) ``` putc 72 putc 101 putc 108 putc 108 putc 111 putc 44 putc 32 putc 87 putc 111 putc 114 putc 108 putc 100 putc 33 ``` Output: `Hello, World!` [Answer] # JavaScript ``` with (String) with ([]) { push(fromCharCode(72)) push(fromCharCode(101)) push(fromCharCode(108)) push(fromCharCode(108)) push(fromCharCode(111)) push(fromCharCode(44)) push(fromCharCode(32)) push(fromCharCode(87)) push(fromCharCode(111)) push(fromCharCode(114)) push(fromCharCode(108)) push(fromCharCode(100)) push(fromCharCode(33)) alert(join([])) } ``` [Answer] **C** Uses only alphanumeric characters, spaces and braces {}, brackets [] and parenthesis (). ``` main() { if(printf((long long []){0x202c6f6c6c6548})) if(printf((long long []){0x21646c726f57})){} } ``` printf( ) accepts a char \* as an argument, but since we can't use quotes("), I typecast the string as a long long array. The values seen here are ASCII strings, in little endian (0x48=H, 0x65=e, 0x6c=l, and so on). I typecast it to long long [] since that way I can pass an 8-byte argument and hence use only two printf( ) calls instead of four. [Answer] # [ferNANDo](http://esolangs.org/wiki/FerNANDo) ``` h E R e I S h E l L O w O r L d U S i N G o N L y L E t T E r S H e L L o W O R L d h E L l O w O r l D h e L L O w o R l d H E L l o W o r l d H E l L o w O R L D h E L L O W O r L d H e l l O w o R l d h e L l o w O R l D H e l L o w O R L d h E L l O W O R l D H E L l O w O r L d ``` [Answer] # BBC BASIC Emulator at bbcbasic.co.uk Split from my LOGO answer. **The easy way** The numbers on the right are just ASCII codes. This is just the same as printing. If I was allowed a comma I could do it on a single line (`VDU 72,101,108,etc.`) ``` 10 VDU 72 20 VDU 101 30 VDU 108 40 VDU 108 50 VDU 111 55 VDU 44 60 VDU 32 70 VDU 87 80 VDU 111 90 VDU 114 100 VDU 108 110 VDU 100 120 VDU 33 ``` **A more creative way** ``` 5 MODE 6 10 READ B 12 WHILE B 15 PROC1(B) 16 PRINT 17 READ B 18 ENDWHILE 20 END REM procedure prints first square on line, REM then calls itself recursively with A DIV 2 to print the next REM VDU 17 tell VDU controller we want to change colour REM Next line changes background colour. REM Then following line VDU 32 prints a space in that background colour. 110 DEFPROC1(A) 115 VDU 17 120 IF A AND 1 THEN VDU VPOS DIV 6 EOR 133 ELSE VDU 128 125 VDU 32 130 IF A THEN PROC1(A DIV2) 140 ENDPROC REM binary bitmap data for each row, least significant at left 150 DATA 463221 160 DATA 332053 170 DATA 332151 180 DATA 332053 190 DATA 2586485 200 DATA 1048576 210 DATA 4395895 220 DATA 4527447 230 DATA 4526935 240 DATA 333143 250 DATA 4420981 260 DATA 0 ``` ![enter image description here](https://i.stack.imgur.com/tgfa9.png) [Answer] # JavaScript! And they said that it couldn't be done... No assignment operators, no concatenators, no quotes! Arghhhh! Fear not... For the force is `with` you... ``` function w(x){ with(document){ with(String){ write(fromCharCode(x)) } } } w(72) w(101) w(108) w(108) w(111) w(44) w(32) w(87) w(111) w(114) w(108) w(100) w(33) Output (on browser screen): Hello, World! ``` [Answer] # DC DC is just about the perfect tool for the job. ``` 5735816763073854918203775149089P ``` DCs `P`-command pops one number from the stack and outputs its raw computer representation to STDIO. Seeing as `5735816763073854918203775149089 = 0x48656C6C6F2C20576F726C6421`, which is represented as `0x21, 0x64, 0x6C... = 'H', 'e', 'l'...` in a little-endian architecture, it outputs `Hello, World!`. [Answer] # Rebol Alphanumeric only solution: ``` prin quote Hello prin add space 12 prin space prin quote World print add space 1 ``` Above is an update which uses Dr Rebmu excellent suggestion of `add space 1` (which produces `!`) to get to all the characters. Below is the original version: ``` prin quote Hello prin pick mold system 264 prin space prin quote World print pick mold system 12 ``` Shorter version with brackets: ``` print rejoin [quote Hello pick mold system 264 space quote World pick mold system 12] ``` And even shorter version with braces: ``` print join {Hello} join pick mold system 264 join { World} pick mold system 12 ``` And shortest version with both brackets & braces: ``` print rejoin [{Hello} pick mold system 264 { World} pick mold system 12] ``` Rebol uses braces `{}` for multi-line quoting. So completely valid under rule changes but not quite in full spirit (IMHO) as my first two answers above. NB. Printing the `!` was a pain! Rebol allows and uses punctuation characters routinely for function names and datatypes. So options like `to-char 33` or `to char! 33` would not be allowed under the rules (even though these punctuations are not operators par se). Fortunately I found a cheeky way by turning the Rebol system object: `make object! [...]` into a string and cherry pick that `!` from it :) Update: And now also cherry picked comma from license text in system object. [Answer] ## Mathematica ``` Unprotect[Times] ClearAll[Times] Print[Hello FromCharacterCode[44] world FromCharacterCode[33]] ``` [Answer] ## Javascript *Update:* Managed to cut a bunch of characters by introducing a World function as well. Another Javascript solution that writes to console.log: ``` function World() { with (World) return name } function Hello() {} with (console) with (String) with (Hello) with (name) with (concat(fromCharCode(44))) with (concat(fromCharCode(32))) with (concat(World())) log(concat(fromCharCode(33))) ``` Inspired by [this entry](https://codegolf.stackexchange.com/a/23169/8555). First, I define functions named Hello and World. This will be used later on. Then I start my chain of nested withs. The `with (console)` and `with (String)` are used so that I can later on invoke `console.log` and `String.fromCharCode` without using a dot. The plan is now to build the string `Hello, World!` by abusing nested withs. Each time I invoked concat(), the resulting string will be the context in the next with-block. I take a short cut to quickly get `"Hello"` by accessing the `name` property of the `Hello` function. Then I concatenate the comma and space characters by using `String.fromCharCode`. The next trick is to get the `"World"` part of the string. I cannot use the same method I used to get `Hello`, since I cannot invoke World.name. Instead I put that logic inside the World method, and invoke it. Finally, I append the final exclamation mark and send the result right to the log function, which is of course console.log. [Answer] # Python: ``` import antigravity ``` causes "Hello, world!" to appear on your screen. Don't believe me? Try it out for yourself! Also, this doesn't actually use the web, it opens a browser, that might lookup a website. [Answer] # Perl In a modern Perl (5.10 or newer): ``` print q{Hello} and print chr 44 and print q{ World} and say chr 33 ``` In older Perl: ``` print q{Hello} and print chr 44 and print q{ World} and print chr 33 and print chr 10 ``` Both solutions above use Perl `q` quote-like operator and allows selective delimiters for quoting a string, for eg. `q{}` `q[]` `q()` `q//` This solution requires the rule change that allows braces, brackets or parens. So while totally valid I think `mniip` excellent Perl answer is more in the true spirit of the rules (+1). However taking a leaf out of `mniip` answer my solution could be written like so: ``` print q xHellox and print chr 44 and print q x Worldx and say chr 33 ``` and while harder on the eye it does work. [Answer] # Perl ``` print chr hex for qw z48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21z ``` [Answer] # dc, (26 bytes for the golfers) Whitespace and `[]` brackets are now allowed: ``` [Hello]n44P[ World]n33P[]p ``` Output: ``` $ dc <<< "[Hello]n44P[ World]n33P[]p" Hello, World! $ ``` [Answer] # Python: Pfff, who needs the numeric part of alphanumeric? ``` from string import lowercase from string import uppercase from string import punctuation print uppercase[len(str([[[len(str())]]]))] print lowercase[len(str([[]]))] print lowercase[len(str([[[[[len(str())]]]]]))] print lowercase[len(str([[[[[len(str())]]]]]))] print lowercase[len(str([[[[[[[]]]]]]]))] print punctuation[len(str([[[[[len(str())]]]]]))] print print uppercase[len(str([[[[[[[[[[[]]]]]]]]]]]))] print lowercase[len(str([[[[[[[]]]]]]]))] print lowercase[len(str([[[[[[[[len(str())]]]]]]]]))] print lowercase[len(str([[[[[len(str())]]]]]))] print lowercase[len(str([len(str())]))] print punctuation[len(str())] ``` This is locale-dependant, so your milage may vary. However, if you really want to replicate this result, you could use the following instead of the import statements: ``` lowercase="abcdefghijklmnopqrstuvwxyz" uppercase="ABCDEFGHIJKLMNOPQRSTUVWXYZ" punctuation="!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~" ``` (this is not part of my submission, it's just sharing my locals for recreatability) [Answer] ## [Rebmu](https://github.com/hostilefork/rebmu), 46 characters ``` pnUPPqHELLO01pnADsp12pnSPpnUPPqWORLD01pnADsp01 ``` Strongly parallels [@dragetun's solution in Rebol](https://codegolf.stackexchange.com/a/23054/57) *(Because Rebmu is a Rebol/Red teaching tool which is a "dialect" that aims to draw attention to the languages by rocking at Code Golf. :-P)* However, to get the missing characters, I did something more obvious. I just added to space, instead of going and looking through system strings. You can get **add space 1** to get character literal #"!" and **add space 12** to get character literal #",". If we run this we can see it get "unmushed": ``` >> rebmu/debug/stats "pnUPPqHELLO01pnADsp12pnSPpnUPPqWORLD01prADsp01" Original Rebmu string was: 46 characters. Rebmu as mushed Rebol block molds to: 46 characters. Unmushed Rebmu molds to: 62 characters. Executing: [pn upp q hello 1 pn ad sp 12 pn sp pn upp q world 1 pr ad sp 1] Hello, World! ``` Which is fairly logial: ``` ; print with no newline the result of doing an uppercase/part ; on the quoting of the symbolic word hello, of only the first ; N characters (where N is 1) pn upp q hello 1 ; print the character you get when you add 12 to the space ; character literal, a.k.a. comma...again no newline pn ad sp 12 ; print a space, no newline pn sp ; do the same trick of printing the quoted word hello with the ; first letter converted to uppercase pn upp q world 1 ; print the character you get when you add 1 to the space ; character literal, a.k.a. exclamation point...with newline now pr ad sp 1 ``` [Answer] # [Whitespace](http://compsoc.dur.ac.uk/whitespace/) Okay, we can use whitespace. It uses only `Space`, `Tab`, `LineFeed` and ignores any other characters. ```                                                                                                                                            ``` With comment: `S`, `T` or `L` means `Space`, `Tab` or `LineFeed` respectively. ``` S S S T S S T S S S L T L S S S S S T T S S T S T L T L S S S S S T T S T T S S L T L S S S S S T T S T T S S L T L S S S S S T T S T T T T L T L S S S S S T S T T S S L T L S S S S S T S S S S S L T L S S S S S T T T S T T T L T L S S S S S T T S T T T T L T L S S S S S T T T S S T S L T L S S S S S T T S T T S S L T L S S S S S T T S S T S S L T L S S S S S T S S S S T L T L S S L L L ``` With highlighting: [http://en.wikipedia.org/wiki/Whitespace\_(programming\_language)#Sample\_code](http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29#Sample_code) [Answer] ## T-SQL, 52 Ah, this is better! Direct binary conversion, only 52 characters. ``` SELECT CAST(0x48656C6C6F2C20576F726C6421 AS VARCHAR) ``` **Previously...** There's a much cleverer and golfier solution to this that would work *if* we could use `=` and `+` (Looking up standard built-in data in msdb and using that to construct an EXEC-able query string) But since we can't, you get this naive approach: ``` SELECT CHAR(72)SELECT CHAR(101)SELECT CHAR(108)SELECT CHAR(108)SELECT CHAR(111)SELECT CHAR(44)SELECT CHAR(32)SELECT CHAR(87)SELECT CHAR(111)SELECT CHAR(114)SELECT CHAR(108)SELECT CHAR(100)SELECT CHAR(33) ``` [Answer] # Groovy So updated. Much `wat`. ``` def wat(i) { print i this } def wat(int i) { wat i as char } def getProperty(String p) { p } wat Hello wat 44 wat 32 wat World wat 33 ``` ]
[Question] [ *This is the robbers' thread. The cops' thread is [here](https://codegolf.stackexchange.com/q/135363/58826).* Your challenge is to crack a cop's submission by finding an input that makes it halt. You don't have to find out why, or all inputs that make it halt if there's more than one, or the input the cop intended, just one input will do. Once you have cracked a submission, post a link to it in a comment or edit to the cop's post. You can also flag your submission for a mod to edit it in the cop's post. Also, post the input used and a link to the cop's post in an answer in this thread. The robber that cracks the most submissions wins. **Multiple people can post cracks to the same cop submission, as long as they are different.** (If SE converted your duplicate answer to a comment, you may want to vote on [this feature request](https://codegolf.meta.stackexchange.com/q/13437/58826)) --- # Looking for uncracked submissions? ``` fetch("https://api.stackexchange.com/2.2/questions/135363/answers?order=desc&sort=activity&site=codegolf&filter=!.Fjs-H6J36vlFcdkRGfButLhYEngU&key=kAc8QIHB*IqJDUFcjEF1KA((&pagesize=100").then(x=>x.json()).then(data=>{var res = data.items.filter(i=>!i.body_markdown.toLowerCase().includes("cracked")).map(x=>{const matched = /^ ?##? ?(?:(?:(?:\[|<a href ?= ?".*?">)([^\]]+)(?:\]|<\/a>)(?:[\(\[][a-z0-9/:\.]+[\]\)])?)|([^, ]+)).*[^\d](\d+) ?\[?(?:(?:byte|block|codel)s?)(?:\](?:\(.+\))?)? ?(?:\(?(?!no[nt][ -]competing)\)?)?/gim.exec(x.body_markdown);if(!matched){return;}return {link: x.link, lang: matched[1] || matched[2], owner: x.owner}}).filter(Boolean).forEach(ans=>{var tr = document.createElement("tr");var add = (lang, link)=>{var td = document.createElement("td");var a = document.createElement("a");a.innerText = lang;a.href = link;td.appendChild(a);tr.appendChild(td);};add(ans.lang, ans.link);add(ans.owner.display_name, ans.owner.link);document.querySelector("tbody").appendChild(tr);});}); ``` ``` <html><body><h1>Uncracked Submissions</h1><table><thead><tr><th>Language</th><th>Author</th></tr></thead><tbody></tbody></table></body></html> ``` [Answer] # [Malbolge, Doorknob](https://codegolf.stackexchange.com/a/135583/72703) [Try it online](https://tio.run/##S0oszvifnFiiYKeQkZhTopebmKNgY6Ogrqf@X8NWrchKOd@2Lsckq8o83bSspCSpqKAgLi8nJyorIyOMKy0lJSgpwd/aSkPdKzJCOSysLiu4OjDHLsvX29vS0z2Zyy3RJT4iNiY6KjIiPKzYz8zHxCsmOjvSNSPMKTU4OSmRSzXeNza2zjPS3di1ssLUxNhIG2iBbp52jmaWeoaqk8F/PS6uzOT8vDIF3RKFzOJ8XQsLU0tdQ4UaBf38ghJ9oGOT8nPSU@EMuB/@u8Uf3mJoZGxiamZuYWkAAA) (Thanks [Dennis](https://codegolf.stackexchange.com/users/12012/dennis)!) Input for Windows: `F_⌠1234567890` Input on Linux based system using ISO-8559-1: `F_ô1234567890` The heart of how the Malbolge program worked is that it depended on a behavior of the Malbolge interpreter which causes an infinite loop if it encounters any instruction which is not between 33 and 126. The program was constructed such that your input would allow you to modify a single instruction. I modified the interpreter to dump the program memory state at the beginning of execution and to also produce 'normalized' source code which takes the form of a list of [op codes](http://www.lscheffer.com/malbolge_spec.html) that will be run during the execution of the program. With that information you could (slowly) determine that even though the program took 13 inputs only the 1st and 3rd inputs actually mattered. Looking through the normalized code and memory dump (and a touch of debugger help) I devised the following: > > a = op(input 1, 29524) > > > b = op(input 3, a) > > > c = op(486, b) > > > d = op(c, 37) > > > e = d/4 + d%3 \* 3^9 > > > e must be between 33 and 126 > > > Where `op` is the so called tritwise "op" that is described in the specification. Using this information you can write a simple program which iterates over the possible inputs (0 to 255) and finds all solutions which meet the above criteria. I had found 2219 possible solutions, some of which will probably not be working solutions (you can't input the required characters). Specifically the above inputs are based on the solution: `(Input 1 = 70, Input 3 = 244)` [Answer] # [JavaScript (in Browser)](https://codegolf.stackexchange.com/a/135551/61875) ``` document.all ``` This is falsy, surprisingly Edit: [why is `document.all` falsy](https://stackoverflow.com/questions/10350142/why-is-document-all-falsy)? [Answer] # JS (ES6), [Juan Tonina](https://codegolf.stackexchange.com/a/135385/65836) ``` +0,-0 ``` Took a bit of looking in `Object.is` to find. Basically, `+0 === -0` since `===` checks them as numbers, and `0` is finite, but `Object.is` sees `+0` and `-0` as different objects. Very smart cop :) [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@1@jQqdS09auujwjMydVo0LR1raypsY/KSs1uUQvsxgoq1CpWVOjmFnslpmXWQJUgcKr1NS0rv2fpqFtoKNroPkfAA "JavaScript (Node.js) – Try It Online") [Answer] # [Python, Siphor](https://codegolf.stackexchange.com/a/135490/10894) ``` class A: i = True def __eq__(self, a): self.i = not self.i return self.i a = A() f(a) ``` We just redefine equality to behave exactly as required to get the program to terminate. [Answer] # [Braingolf](https://codegolf.stackexchange.com/a/135367/58826) ``` -1 ``` Any number less than `0` works. [Try it Online!](https://tio.run/##SypKzMxLz89J@/8/2lA79v///7qmAA) [Answer] # [PHP, Sisyphus](https://codegolf.stackexchange.com/a/135550) `(-0[0)> deal with it=1` The parse\_str function changes the spaces and other characters to underscores. If you put a [ used for Array delimiter without closing, it changes it to an underscore but has the effect of not translating the following spaces (I don't know why). [Try it online!](https://tio.run/##K8go@P/fxr4go4CrILGoODW@uKRIQyWxKL0s2jBWRyVe05qrPCMzJ1VDUSU@Wl1D1yDeQNNOISU1MUehPLMkQyGzRD1W0/r///9AqWh0KVtDAA "PHP – Try It Online") [Answer] # JavaScript (Node.js), [Adnan](https://codegolf.stackexchange.com/a/135408) `[]` and `[]` seem to work. I tried a bunch of them including `null`, `undefined`, `NaN`... `[] >= [] && [] <= [] && [] != []` evaluates to true. Moral of the story: JavaScript is *weird*. [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/C1q7S1q66PCMzJ1VDUaPCzrZSTa3CBkwq2lZqalrX/k/TiI7VBOH/AA "JavaScript (Node.js) – Try It Online") [Answer] # JavaScript (ES7), [Arnauld](https://codegolf.stackexchange.com/a/135398/71612) ## Standard `"8e7"` is solution ``` var crack_me = (x=0)=>{for(;~x/x.length**3!=-2962963;);} var key = "8e7" crack_me(key) console.log("stopped :)") ``` ## Hack No need to calculate this number, we can redefine `length` property This sets `~x/x.length**3!=-2962963` to `false` ``` var crack_me = (x=0)=>{for(;~x/x.length**3!=-2962963;);} var key = {toString:()=>"2962962",length:"1"} crack_me(key) console.log("stopped :)") ``` ## [Operators priority](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Operator_Precedence) `~` [bitwise not](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT) is first `** exponentiation` second `/ division` third [Answer] # [Bash, Veedrac](https://codegolf.stackexchange.com/a/135630/48931) ``` LD_TRACE_LOADED_OBJECTS ``` [Try it online!](https://tio.run/##S0oszvj/P7WiIL@oREFJxVDJNiM1p4BLPykzT78ytfj///8@LvEhQY7OrvE@/o4uri7x/k5ers4hwQA "Bash – Try It Online") From the `ld.so(8)` manpage: > > **LD\_TRACE\_LOADED\_OBJECTS** > > > If set (to any value), causes the program to list its dynamic > dependencies, as if run by `ldd(1)`, instead of running > normally. > > > [Answer] ## Mathematica, [JungHwan Min](https://codegolf.stackexchange.com/a/135505/8478) ``` Unevaluated@Throw@"hammertime" ``` No clue whether this is the intended solution, but it passes in an expression that doesn't get evaluated until it's referenced as `#` inside the function, which will cause it turn return from the function immediately without doing any further evaluation. You can see that the function is actually called (instead of just throwing the exception before even invoking the function) by changing the function to: ``` #0[Print@"stop";#;$IterationLimit=∞]& ``` Which will indeed print the `stop` before throwing the error. [Answer] # R, [Jarko Dubbeldam](https://codegolf.stackexchange.com/a/135857/53286) ``` function(x)if(is.list(x))return(1) ``` First time contributing anything, so do call out any mistakes I've made in format. Pretty sure this is valid. Just a rewrapping of is.list(), right? [Answer] # [Retina](https://github.com/m-ender/retina), [PunPun1000](https://codegolf.stackexchange.com/a/135382/41805) ``` 11111 ``` [Try it online!](https://tio.run/##K0otycxL/P8/jsuQSzshzlDDUFuTS8Xw0DYVNa7iBA17G9u4mkPbNEHCGva2IJa9op7WoW0xhtoqmlxch7YB@RBmHEgNSEKFC2iSIZeh4f//hiAAAA "Retina – Try It Online") Any input with *n* `1`s where the sum of the divisors of *n+1* is equal to *n+1* should work. [Answer] # Node.js, [Adnan](https://codegolf.stackexchange.com/a/135408/58826) `{}` and `{}` or any 2 objects are the two inputs. I don't even understand how this works. Here's JS's amazing object compare logics: ``` console.log({} == {}); console.log({} === {}); console.log({} > {}); console.log({} < {}); console.log(!!{}); console.log({} >= {}); console.log({} <= {}); ``` [Answer] # [Ruby](https://codegolf.stackexchange.com/a/135465/65905) ``` exit ``` without newline. `3.send('exit')` surely isn't equal to `5`, but it executes [`Kernel#exit`](https://ruby-doc.org/core-2.4.1/Kernel.html#method-i-exit): > > Initiates the termination of the Ruby script by raising the SystemExit > exception > > > It's possible to call `exit` on `3` [because](https://ruby-doc.org/core-2.4.1/Kernel.html): > > The Kernel module is included by class Object, so its methods are > available in every Ruby object [as private methods]. > > > [`abort`](https://ruby-doc.org/core-2.4.1/Kernel.html#method-i-abort) also works: > > Terminate execution immediately, effectively by calling > Kernel.exit(false). If msg is given, it is written to STDERR prior to > terminating. > > > [Answer] # [JavaScript (Node.js)](https://nodejs.org), [programmer5000](https://codegolf.stackexchange.com/a/135513/65836) Already cracked, but mine is slightly different :) Don't have enough rep to comment over in the cops. Also feel free to edit to fix formatting, my first post here. Mainly I set `__proto__` equal to a function that throws. Taken from looking at the Mozilla page for proto. (Sorry, low rep, can't post a link.) ``` x = {} let No = function () { throw 'halted' } x.__proto__ = new No() ``` ``` f = x=>{while(x.__proto__);} ``` [Try it online!](https://tio.run/##TYvBDYQgEAD/VrE/4aENXLgSbIEQXQIXwhpchYRQO/K830wy8zOPufbkT14iHdgLKKhtCsiw0WB7x509RRASKrBLlGF2JjAeM7SprFqfiZi0HnHEPC4hux1S1Ldm5wOKv0h@WreiyP4C "JavaScript (Node.js) – Try It Online") EDIT: Got some rep, so here's the link: [Mozilla `__proto__`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/proto) [Answer] # [Bash, Sisyphus](https://codegolf.stackexchange.com/a/135595/12012) ``` kill 0 ``` Fortunately, `kill` is a shell builtin. [Try it online!](https://tio.run/##S0oszvj/P7lAQT8pM0@/JLFIQY8rNa9MQTdTIcAxxMNWJSDcRcHTVsUeoiAJqFxBt0hBN1lBScVQias8IzMnVcHKOiUfTOSl/v//PzszJ0fBAAA "Bash – Try It Online") [Answer] # Javascript, [programmer5000](https://codegolf.stackexchange.com/a/135468) ## Max string length Uses a string with a length one less than what your engine supports. When adding `"h"` to this string, an error is thrown. [Try it online!](https://tio.run/##bZCxbsQgDIb3PoWVieiUUzsjTmrndup4uoFQJ6GiEIGTpjrl2VNIuIsqdQCL3/b/2XzKUQbldU9VLWs0lXUfuBgkaMQkTtfvThtk06HoipLPSzNYRdpZaJGezZcL9CanV7Tv5FkJ1weAUXroPY4vMmAAAecLz2odlSgUskgK@Z@1HmBDkB@wzArsDsd@CB1LrSXPudXnINa4aXO8Z1CSVMeSSXo3zgNLWB2Zu51B21JXPXHQJ/HIoar0jbpPtDPujWd9yayNA3dQOh5p8DZPNC83p4b9901xkT8msVA5G5zBo3EtS4vOyy8) ``` function getAlmostMaxLenStr() { var prevBases = []; var base = "a"; try { while(true) { prevBases.push(base); base += base; } } catch(e) {} for (var i = prevBases.length-1; i>=0; --i) { try { base += prevBases[i]; } catch (e) {} } return base; } f(getAlmostMaxLenStr()); ``` ## Cross-origin block Heavily inspired by [the answer from @jadkik94](https://codegolf.stackexchange.com/a/135874/72685), but works everywhere. Creates a cross-origin iframe, then passes the `.contentWindow` of said iframe. This fails when the function tries to use the value due to cross-origin safety. ``` let f=x=>{ try { console.log(x+"h"); // we don't want to lock up your browser, do we ;) } catch (e) { console.log("Halted!\n",e); } } let iframe=document.createElement("iframe"); const url = location.host.indexOf("google") === -1 ? "https://google.com" : "https://stackexchange.com"; iframe.src=url; iframe.onload=a=>f(iframe.contentWindow); document.body.appendChild(iframe); ``` ## Primitive value Variant of the `.toString()` answers - this just uses `toPrimitive` instead. It returns an object as the primitive value, which Javascript doesn't know how to handle (so it throws an error). [Try it online!](https://tio.run/##HYtLDoMgEED3nGLiCtLoBQw9Q5Mumy6AjgWDToNTqyGc3RK37zOa1SwuhQ@31liM7UwvPCIyDHrT1/zzIaLcLo1vVF9OQXYEDVkAPO77ZCl2TLcUpsBhxadUOSF/0wy5FFH6g9N@xoOso@pFAWfYeZCoTu5oXihiF@ldUfXHHw) ``` f({ [Symbol.toPrimitive](){return {}} }); ``` [Answer] # [JavaScript (Babel Node)](https://babeljs.io/), [Conor O'Brien](https://codegolf.stackexchange.com/a/135523/72664) (Repost, accidentally put in cops.) Not sure what was intended but positive decimals that aren't enormous all seem to work. Also I guess I still can't comment in Cops. ``` f(0.1) console.log('done') ``` [Try it online!](https://tio.run/##TdlNbl3HEYDReVaReCJyYOF19T8UesCdUPZTooARBVlxEMTZhBamLSk2@xSTybMAgR8sqc59t6v/9vDLw88/fnr/8fP3bx/eXh@///D00/Xbu7v7ux/@ff3l4fHmu/fvbj7/6@P16d0f7/909@rDP/7@9vrp1e393eXN/37n65f/@62vX377ve9ef7p@vD58vmm3@au4vX3zz7@@f7ze3P/57vLrr/d3d@X5M54/6/Nne/7sz5/j@XM@f67nz31@yg@fny7nx8v5@XIC5RTKSZTTKCdSTiVOJfw/nEqcSpxKnEqcSpxKnEqcSj2VeirVH@VU6qnUU6mnUk@lnko9lXYq7VTaqTR/I6fSTqWdSjuVdirtVPqp9FPpp9JPpfuLPZV@Kv1U@qn0UxmnMk5lnMo4lXEqw7/PqYxTGacyTmWeyjyVeSrzVOapzFOZ/plPZZ7KPJV1KutU1qmsU1mnsk5lncoyLaeyTmWfyj6VfSr7VPap7FPZp7JPZRu6nDpjdzF3F4N3MXkXo3cxexfDdzF9F@N30XsZY70c5JzkHOWc5RzmnOYcZ/NcDHSJdKFnpouhLqa6GOtirovBLia7GO1itktNaHrGu5jvYsCLCS9GvJjxYsiLKS/GvLSUq2fSi1EvZr0Y9mLai3Ev5r0Y@GLiS89HgZ6hL6a@GPti7ovBLya/GP1i9ovhLyOfLXrmvwBQCCgIFAYKBIWCgkHhoMx8WOmhUFgoMBQaCg6FhwJEIaIgUVY@/fSoKFgULgoYhYyCRmGjwFHoKDsfp/k89UDlI/gIPoKP4CP4CD6Cj@AjSj6g9fgIPoKP4CP4CD6Cj8jnfT7wX574evnMz4d@PvXzsZ/P/Xzw8xF8BB9R8ytEj4/gI/gIPoKP4CP4CD6Cj2j5naTHR/ARfAQfwUfwEXwEH8FH9PyS0@Mj@Ag@go/g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uq3FDxMfgYfAw@Bh@Dj8HHmLnv0uNj8DH4GHwMPgYfg4/Bx@BjrFyg6fEx@Bh8DD4GH4OPwcfgY/Axdm7kciVnJ8fH5GPyMfmYfEw@Jh@Tj8nHLLnj0@Nj8jH5mHxMPiYfk4/Jx@RjRi4N9fiYfEw@Jh@Tj8nH5GPyMfmYNbeQenxMPiYfk4/Jx@Rj8jH5mHzMlmtNPT4mH5OPycfkY/Ix@Zh8TD5mzz2pHh@Tj8nH5GPyMfmYfEw@Jh9z5OJVj4/Jx8wVbu5wc4mbW9xc4@YeNxe5L5tcvdzl8jH5mHxMPiYfk4/Jx@RjrlwN6/Ex@Zh8TD4mH5OPycfkY/Ixd@6ac9ls28zH4mPxsfhYfCw@Fh@Lj8XHKrm91uNj8bH4WHwsPhYfi4/Fx@JjRa7D9fhYfCw@Fh@Lj8XH4mPxsfhYNffrenwsPhYfi4/Fx@Jj8bH4WHyslgt7PT4WH4uPxcfiY/Gx@Fh8LD5WzxsAPT4WH4uPxcfiY/Gx@Fh8LD7WyCsFPT4WH4uPxcfiY/Gx@Fh8LD7WzDsKPT5WXnbkbUded@R9R1545I1HXnnkncfLpYceH4uPxcfiY/Gx@Fh8LD4WH2vnLUpeo7hH4WPzsfnYfGw@Nh@bj83H5mOXvJfR42PzsfnYfGw@Nh@bj83H5mNHXvTo8bH52HxsPjYfm4/Nx@Zj87Fr3hzp8bH52HxsPjYfm4/Nx@Zj87FbXkXp8bH52HxsPjYfm4/Nx@Zj87F73m3p8bH52HxsPjYfm4/Nx@Zj87FHXpbp8bH52HxsPjYfm4/Nx@Zj87Fn3r7p8bH52HxsPjYfm4/Nx@Zj87FXXufp5bVg3gvmxWDeDObVYN4N5uVg3g7m9eCzjx9@@@@@ffOfb@9uLq/L7R9@fPrw89Pj9fXj019uXv309OH66vbbt/8C "JavaScript (Babel Node) – Try It Online") [Answer] ## [Javascript (NOT node.js)](https://codegolf.stackexchange.com/a/135468/9365), programmer5000 This can't be added because it creates an object that has no toString because a new `Set` does not inherent prototypes from from `Object`. input: ``` new Set() ``` [Try it online!](https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38/7/CNi@1XCE4tURD05qrwtauujwjMydVo0JbKUNJ07r2/38A "JavaScript (SpiderMonkey) – Try It Online") [Answer] # Bash 4.2, [Dennis](https://codegolf.stackexchange.com/a/135590/21194) ``` PATH=1 ``` Clearly not the intended solution, because it works on newer bash as well. [Try it online.](https://tio.run/##S0oszvj/Pye1REHFkKsytfj///8BjiEetoYA) [Answer] # [Octave](https://www.gnu.org/software/octave/), [Stewie Griffin](https://codegolf.stackexchange.com/a/135415/20268) Input: `exit` Reasoning: `input` evalutes whatever is input. `exit` exits the program. [Try it online!](https://tio.run/##y08uSSxL/f@/wjYzr6C0RENdXdO6PCMzJ1XBsKZCJzUv5f//1IrMEgA "Octave – Try It Online") [Answer] # Python 2, [Foon](https://codegolf.stackexchange.com/a/135525/21194) ``` __import__("os")._exit(0) ``` What it says on the tin, basically. [Try it online.](https://tio.run/##K6gsycjPM/r/vzwjMydVwdCKS6GkqBJIKlQo2Cpk5hWUlmhocimkViSnFpSAhAsSi4v//4@Pz8wtyC8qiY/XUMovVtLUi0@tyCzRMNAEAA) [Answer] ## Python 3 (CPython), [Veedrac](https://codegolf.stackexchange.com/a/135565/967) ``` a=('',(type,),{}) X=type(*a)(*a) X.__class__=X ``` [Try it online!](https://tio.run/##HYuxCsMgFEX39xU2S94rUgrdBKf@QgY3EWOJNCSiD6qUfrttOtzhcM5NjZd9u/U@h4eYsErW3FIgBeK1xDUIxkqxCBZ7/vmDSF3BaRxHiUcqSb4/BOb/w7OjY2Au1vrVlWKtNsC5qQkNQag@JFYpx41xuGfnn2E@DdT7Fw "Python 3 – Try It Online") [Answer] # Python 3, [Siphor](https://codegolf.stackexchange.com/a/135606) This was fun. We need to make the `type(x) != str` check pass, so we need to control the return value of `type()`. We have to override the `__class__` attribute and replace it with a custom object, that extends `type`, which has the `__ne__` method replaced by one that always returns false. This makes it pass the type check, but the search will fail because `o` is not a str. ``` class m(type): def __ne__(a,b): return False class c:pass o=c() o.__class__=m("",(c,),{}) f(o) ``` [Answer] # R, [Jarko Dubbeldam](https://codegolf.stackexchange.com/a/135742/21194) Just an invalid regex. ``` "[" ``` [Try it online.](https://tio.run/##K/r/P802rTQvuSQzP0@jQrM8IzMnVcNQMzNNIyc1L70kAyimmV6UWqBRoaOursmVpqEUraT5/z8A) [Answer] # [Python, Siphor](https://codegolf.stackexchange.com/a/135606/10894) ``` f('t=False') ``` Crashes due to an `UnboundLocalError`. I think this is hapening because my `t=False` overrides the higher-scoped `t` with the local `t`, but it's not set at the time of the loop, causing the crash. [TIO](https://tio.run/##bY0/C8IwEMX3fIozS1IIXdwKnfwDLjq5uYR4oYXWhOTAFvGzx8vkoMPB@73HexdXGsJjW8odPXi9NJ0A6qWUlUlX/Cp4DuOEQF20OTO@3kLUSPBxRcA4x5AIErLk0hqRF2HTQ6YEIXHQZrTJDTrJW5ZmMexcz6fdZX/484DS2lHvwhzZ1dT6kGZLPGnUrIzCBZ1qBODiMNJvveaamuK1ov5op4yqKR8) [Answer] # Commodore 64 Basic, [Mark](https://codegolf.stackexchange.com/a/135554/21194) If I understood this correctly (and it's entirely plausible I have not), you just need to overflow the floating point variable. ``` 9999999999999999999999999999999999999999999999999999999999999999.9 ``` [Answer] # Bash 4.2, [Dennis](https://codegolf.stackexchange.com/a/135658/21194) ``` -9223372036854775808/-1 ``` Why though, Dennis? y u do dis? [Answer] # C#, [TheLethalCoder](https://codegolf.stackexchange.com/a/135696/15738) ``` System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] ``` Or any other nullable class. [Answer] # C#, [TheLethalCoder](https://codegolf.stackexchange.com/a/135834) ``` new char[0] ``` `string.Empty` (`""`) is always interned. Therefore, an empty array or `null` will work. ]
[Question] [ [The Sierpinsky Triangle](http://en.wikipedia.org/wiki/Sierpinski_triangle) is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the other two on a corner. This process is repeated over and over again with the resulting triangles to produce the Sierpinski triangle, as illustrated below. ![enter image description here](https://i.stack.imgur.com/MrjJN.png) Write a program to generate a Sierpinski triangle. You can use any method you want to generate the pattern, either by drawing the actual triangles, or by using a random algorithm to generate the picture. You can draw in pixels, ascii art, or whatever you want, so long as the output looks similar to the last picture shown above. Fewest characters wins. [Answer] ## HTML + JavaScript, 150 characters (see notes for 126 characters) Whitespace inserted for readability and not counted. ``` <title></title><canvas></canvas><script> for(x=k=128;x--;)for(y=k;y--;) x&y||document.body.firstChild.getContext("2d").fillRect(x-~y/2,k-y,1,1) </script> ``` The core of it is applying the rule of coloring pixels for which `x & y == 0` by the conditional `x&y||`, which produces a “Sierpinski right triangle”; and `x-~y/2,k-y` are a coordinate transformation to produce the approximately equilateral display. ![enter image description here](https://i.stack.imgur.com/QUkRS.png) A less correct (HTML-wise) version is 126 characters: ``` <canvas><script> for(x=k=128;x--;)for(y=k;y--;) x&y||document.body.firstChild.getContext("2d").fillRect(x-~y/2,k-y,1,1) </script> ``` (The way in which this is less correct is that it omits the `title` element and the end tag of the `canvas` element, both of which are required for a correct document even though omitting them does not change the *interpretation* of the document.) Three characters can be saved by eliminating `k` in favor of the constant `64`, at the cost of a smaller result; I wouldn't count the `8` option as it has insufficient detail. Note that a size of 256 or higher requires attributes on the `<canvas>` to increase the canvas size from the default. [Answer] ## GolfScript (43 42 chars) ``` ' /\ /__\ '4/){.+\.{[2$.]*}%\{.+}%+\}3*;n* ``` Output: ``` /\ /__\ /\ /\ /__\/__\ /\ /\ /__\ /__\ /\ /\ /\ /\ /__\/__\/__\/__\ /\ /\ /__\ /__\ /\ /\ /\ /\ /__\/__\ /__\/__\ /\ /\ /\ /\ /__\ /__\ /__\ /__\ /\ /\ /\ /\ /\ /\ /\ /\ /__\/__\/__\/__\/__\/__\/__\/__\ ``` Change the "3" to a larger number for a larger triangle. [Answer] **Mathematica - 32 characters** ``` Nest[Subsuperscript[#,#,#]&,0,5] ``` ![enter image description here](https://i.stack.imgur.com/4imXz.png) **Mathematica - 37 characters** ``` Grid@CellularAutomaton[90,{{1},0},31] ``` This will produce a 2D table of 0 and 1, where 1s are drawing Sierpinski Triangle. ![enter image description here](https://i.stack.imgur.com/yhyRK.png) [Answer] # Python (234) Maximal golfing, tiny image: ``` #!/usr/bin/env python3 from cairo import* s=SVGSurface('_',97,84) g=Context(s) g.scale(97,84) def f(w,x,y): v=w/2 if w>.1:f(v,x,y);f(v,x+w/4,y-v);f(v,x+v,y) else:g.move_to(x,y);g.line_to(x+v,y-w);g.line_to(x+w,y);g.fill() f(1,0,1) s.write_to_png('s.png') ``` Requires `python3-cairo`. To get a nice large image I needed **239** characters. ![Sierpinski Triangle](https://i.stack.imgur.com/dlT7C.png) [Answer] ## Python, 101 86 Uses the rule 90 automaton. ``` x=' '*31 x+='.'+x exec"print x;x=''.join(' .'[x[i-1]!=x[i-62]]for i in range(63));"*32 ``` This is longer, but prettier. ``` x=' '*31 x+=u'Δ'+x exec u"print x;x=''.join(u' Δ'[x[i-1]!=x[i-62]]for i in range(63));"*32 ``` Edit: playing with strings directly, got rid of obnoxiously long slicing, made output prettier. Output: ``` Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ Δ ``` [Answer] ## J ``` ,/.(,~,.~)^:6,'o' ``` Not ideal, since the triangle is lopsided and followed by a lot of whitespace - but interesting nonetheless I thought. Output: ``` o oo o o oooo o o oo oo o o o o oooooooo o o oo oo o o o o oooo oooo o o o o oo oo oo oo o o o o o o o o oooooooooooooooo o o oo oo o o o o oooo oooo o o o o oo oo oo oo o o o o o o o o oooooooo oooooooo o o o o oo oo oo oo o o o o o o o o oooo oooo oooo oooo o o o o o o o o oo oo oo oo oo oo oo oo o o o o o o o o o o o o o o o o oooooooooooooooooooooooooooooooo o o oo oo o o o o oooo oooo o o o o oo oo oo oo o o o o o o o o oooooooo oooooooo o o o o oo oo oo oo o o o o o o o o oooo oooo oooo oooo o o o o o o o o oo oo oo oo oo oo oo oo o o o o o o o o o o o o o o o o oooooooooooooooo oooooooooooooooo o o o o oo oo oo oo o o o o o o o o oooo oooo oooo oooo o o o o o o o o oo oo oo oo oo oo oo oo o o o o o o o o o o o o o o o o oooooooo oooooooo oooooooo oooooooo o o o o o o o o oo oo oo oo oo oo oo oo o o o o o o o o o o o o o o o o oooo oooo oooo oooo oooo oooo oooo oooo o o o o o o o o o o o o o o o o oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo oo o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo ``` **A quick explanation:** The verb `(,~,.~)` is what's doing the work here. It's a [hook](http://www.jsoftware.com/help/primer/hook.htm) which first stitches `,.` the argument to itself (`o` -> `oo`) and then appends the original argument to the output: ``` oo ``` becomes ``` oo o ``` This verb is repeated 6 times `^:6` with the output of each iteration becoming the input of the next iteration. So ``` oo o ``` becomes ``` oooo o o oo o ``` which in turn becomes ``` oooooooo o o o o oo oo o o oooo o o oo o ``` etc. I've then used the oblique adverb on append `,/.` to read the rows diagonally to straighten(ish) the triangle. I didn't need to do this, as [randomra](https://codegolf.stackexchange.com/users/7311/randomra) points out. I could have just reversed `|.` the lot to get the same result. Even better, I could have just used `(,,.~)^:6,'o'` to save the reverse step completely. Ah well, you live and learn. :-) [Answer] # 8086 Machine code - 30 bytes. NOTE: This is **not my code and should not be accepted as an answer**. I found this while working on a different CG problem [to emulate an 8086 CPU](https://codegolf.stackexchange.com/questions/4732/emulate-an-intel-8086-cpu/9044#9044). The included text file credits **David Stafford**, but that's the best I could come up with. I'm posting this because it's clever, short, and I thought you'd want to see it. It makes use of overlapping opcodes to pack more instructions in a smaller space. Amazingly clever. Here is the machine code: ``` B0 13 CD 10 B3 03 BE A0 A0 8E DE B9 8B 0C 32 28 88 AC C2 FE 4E 75 F5 CD 16 87 C3 CD 10 C3 ``` A straight-up decode looks like this: ``` 0100: B0 13 mov AL, 13h 0102: CD 10 int 10h 0104: B3 03 mov BL, 3h 0106: BE A0 A0 mov SI, A0A0h 0109: 8E DE mov DS, SI 010B: B9 8B 0C mov CX, C8Bh 010E: 32 28 xor CH, [BX+SI] 0110: 88 AC C2 FE mov [SI+FEC2h], CH 0114: 4E dec SI 0115: 75 F5 jne/jnz -11 ``` When run, when the jump at 0x0115 happens, notice it jumps back to 0x010C, right into the middle of a previous instruction: ``` 0100: B0 13 mov AL, 13h 0102: CD 10 int 10h 0104: B3 03 mov BL, 3h 0106: BE A0 A0 mov SI, A0A0h 0109: 8E DE mov DS, SI 010B: B9 8B 0C mov CX, C8Bh 010E: 32 28 xor CH, [BX+SI] 0110: 88 AC C2 FE mov [SI+FEC2h], CH 0114: 4E dec SI 0115: 75 F5 jne/jnz -11 010C: 8B 0C mov CX, [SI] 010E: 32 28 xor CH, [BX+SI] 0110: 88 AC C2 FE mov [SI+FEC2h], CH 0114: 4E dec SI 0115: 75 F5 jne/jnz -11 010C: 8B 0C mov CX, [SI] ``` Brilliant! Hope you guys don't mind me sharing this. I know it's not an answer per se, but it's of interest to the challenge. Here it is in action: ![Running](https://i.stack.imgur.com/XOidp.png) [Answer] ## Python (42) I originally wanted to post a few suggestions on [boothbys solution](https://codegolf.stackexchange.com/a/6310/4626) (who actually uses rule 18 :), but i didn't have enough reputation to comment, so i made it into another answer. Since he changed his approach, i added some explanation. My suggestions would have been: 1. use '%d'\*64%tuple(x) instead of ''.join(map(str,x) 2. shift in zeros instead of wraping the list around which would have led to the following code (93 characters): ``` x=[0]*63 x[31]=1 exec"print'%d'*63%tuple(x);x=[a^b for a,b in zip(x[1:]+[0],[0]+x[:-1])];"*32 ``` But i optimzed further, first by using a longint instead of an integer array and just printing the binary representation (75 characters): ``` x=2**31 exec"print'%d'*63%tuple(1&x>>i for i in range(63));x=x<<1^x>>1;"*32 ``` And finally by printing the octal representation, which is already supported by printf interpolation (42 characters): ``` x=8**31 exec"print'%063o'%x;x=x*8^x/8;"*32 ``` All of them will print: ``` 000000000000000000000000000000010000000000000000000000000000000 000000000000000000000000000000101000000000000000000000000000000 000000000000000000000000000001000100000000000000000000000000000 000000000000000000000000000010101010000000000000000000000000000 000000000000000000000000000100000001000000000000000000000000000 000000000000000000000000001010000010100000000000000000000000000 000000000000000000000000010001000100010000000000000000000000000 000000000000000000000000101010101010101000000000000000000000000 000000000000000000000001000000000000000100000000000000000000000 000000000000000000000010100000000000001010000000000000000000000 000000000000000000000100010000000000010001000000000000000000000 000000000000000000001010101000000000101010100000000000000000000 000000000000000000010000000100000001000000010000000000000000000 000000000000000000101000001010000010100000101000000000000000000 000000000000000001000100010001000100010001000100000000000000000 000000000000000010101010101010101010101010101010000000000000000 000000000000000100000000000000000000000000000001000000000000000 000000000000001010000000000000000000000000000010100000000000000 000000000000010001000000000000000000000000000100010000000000000 000000000000101010100000000000000000000000001010101000000000000 000000000001000000010000000000000000000000010000000100000000000 000000000010100000101000000000000000000000101000001010000000000 000000000100010001000100000000000000000001000100010001000000000 000000001010101010101010000000000000000010101010101010100000000 000000010000000000000001000000000000000100000000000000010000000 000000101000000000000010100000000000001010000000000000101000000 000001000100000000000100010000000000010001000000000001000100000 000010101010000000001010101000000000101010100000000010101010000 000100000001000000010000000100000001000000010000000100000001000 001010000010100000101000001010000010100000101000001010000010100 010001000100010001000100010001000100010001000100010001000100010 101010101010101010101010101010101010101010101010101010101010101 ``` Of course there is also a graphical solution (131 characters): ``` from PIL.Image import* from struct import* a='' x=2**31 exec"a+=pack('>Q',x);x=x*2^x/2;"*32 fromstring('1',(64,32),a).save('s.png') ``` ![very small sierpinsky triangle](https://i.stack.imgur.com/PJai5.png) :D [Answer] ## Haskell (291) I'm not very good at golfing haskell codes. ``` solve n = tri (putStrLn "") [2^n] n tri m xs 1 = do putStrLn (l1 1 xs "/\\" 0) putStrLn (l1 1 xs "/__\\" 1) m tri m xs n=tri m' xs (n-1) where m'=tri m (concat[[x-o,x+o]|x<-xs]) (n-1) o=2^(n-1) l1 o [] s t="" l1 o (x:xs) s t=replicate (x-o-t) ' '++s++l1 (x+2+t) xs s t ``` Output of `solve 4` is: ``` /\ /__\ /\ /\ /__\/__\ /\ /\ /__\ /__\ /\ /\ /\ /\ /__\/__\/__\/__\ /\ /\ /__\ /__\ /\ /\ /\ /\ /__\/__\ /__\/__\ /\ /\ /\ /\ /__\ /__\ /__\ /__\ /\ /\ /\ /\ /\ /\ /\ /\ /__\/__\/__\/__\/__\/__\/__\/__\ ``` [Answer] **QBasic 151 Characters** As an example, here is how it can be done in QBasic. ``` SCREEN 9 H=.5 P=300 FOR I=1 TO 9^6 N=RND IF N > 2/3 THEN X=H+X*H:Y=Y*H ELSEIF N > 1/3 THEN X=H^2+X*H:Y=H+Y*H ELSE X=X*H:Y=Y*H END IF PSET(P-X*P,P-Y*P) NEXT ``` ![enter image description here](https://i.stack.imgur.com/KErlU.png) [Answer] ## APL (51) ``` A←67⍴0⋄A[34]←1⋄' ○'[1+32 67⍴{~⊃⍵:⍵,∇(1⌽⍵)≠¯1⌽⍵⋄⍬}A] ``` Explanation: * `A←67⍴0`: A is a vector of 67 zeroes * `A[34]←1`: the 34th element is 1 * `{...}A`: starting with A, do: * `~⊃⍵:`: if the first element of the current row is zero * `⍵,∇`: add the current row to the answer, and recurse with: * `(1⌽⍵)≠¯1⌽⍵`: the vector where each element is the XOR of its neighbours in the previous generation * `⋄⍬`: otherwise, we're done * `32 67⍴`: format this in a 67x32 matrix * `1+`: add one to select the right value from the character array * `' ○'[`...`]`: output either a space (not part of the triangle) or a circle (when it is part of the triangle) Output: ``` ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ``` [Answer] # 80x86 Code / MsDos - 10 Bytes As a sizecoder specialized for very tiny intros on MsDos i managed to come up with a program that occupies only 10 bytes. in hex: ``` 04 13 CD 10 20 E9 B4 0C E2 F6 ``` [![enter image description here](https://i.stack.imgur.com/XIOJV.gif)](https://i.stack.imgur.com/XIOJV.gif) in asm: ``` X: add al,0x13 int 0x10 and cl,ch mov ah,0x0C loop X ``` The first version i coded was "Colpinski" which is 16 bytes in size, and even interactive in a way that you can change the color with the keyboard and the mouse. Together with "Frag" - another sizecoder - we brought that one down to 13 bytes, allowing for a 10 byte program which just contains the core routine. It gets a bit more interesting when things are animated, so i'll mention another version, [Zoompinski 64](http://www.pouet.net/prod.php?which=67594) - trying to mimic the exact behavior of "Zoompinski C64" in 512 bytes - also for MsDos, 64 bytes in size as the name suggests. It's possible to optimize this further downto 31 Bytes, while losing elegance, colors and symmetry (source and executable available behind the link above) [Download the original and comment on "Pouet"](http://www.pouet.net/prod.php?which=62079) [Answer] ## C ~~127~~ ~~119~~ ~~116~~ ~~108~~ 65 This one uses the trick of the HTML answer of `^ i & j` getting it to print pretty output would take 1 more char (you can get really ugly output by sacrificing the `a^`). ``` a=32,j;main(i){for(;++i<a;)putchar(a^i&j);++j<a&&main(puts(""));} ``` To make it pretty turn `(32^i&j)` to `(32|!(i&j))` and turn it from `++i<a` to `++i<=a`. However wasting chars on looks seems ungolfish to me. Ugly output: ``` ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! "" "" "" "" "" "" "" "" "# !"# !"# !"# !"# !"# !"# !"# $$$$ $$$$ $$$$ $$$$ !$%$% ! !$%$% ! !$%$% ! !$%$% ""$$&& ""$$&& ""$$&& ""$$&& "#$%&' !"#$%&' !"#$%&' !"#$%&' (((((((( (((((((( ! ! !()()()() ! ! ! !()()()() "" ""((**((** "" ""((**((** "# !"#()*+()*+ !"# !"#()*+()*+ $$$$((((,,,, $$$$((((,,,, !$%$%()(),-,- ! !$%$%()(),-,- ""$$&&((**,,.. ""$$&&((**,,.. "#$%&'()*+,-./ !"#$%&'()*+,-./ 0000000000000000 ! ! ! ! ! ! !0101010101010101 "" "" "" ""0022002200220022 "# !"# !"# !"#0123012301230123 $$$$ $$$$0000444400004444 !$%$% ! !$%$%0101454501014545 ""$$&& ""$$&&0022446600224466 "#$%&' !"#$%&'0123456701234567 ((((((((0000000088888888 ! ! !()()()()0101010189898989 "" ""((**((**0022002288::88:: "# !"#()*+()*+0123012389:;89:; $$$$((((,,,,000044448888<<<< !$%$%()(),-,-010145458989<=<= ""$$&&((**,,..0022446688::<<>> "#$%&'()*+,-./0123456789:;<=>? ``` I actually kind of like how it looks. But if you insist on it being pretty you can dock four chars. Pretty Output: ``` !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !! !! !! !! !! !! !! ! ! ! ! ! ! ! ! ! !! !!!! !!!! !!!! ! ! ! ! ! ! ! ! ! !! !! !! ! ! ! ! ! !!!!!! !!!!!!!! ! ! ! ! ! ! ! ! ! !! !! !! ! ! ! ! ! !! !!!! ! ! ! ! ! !! ! ! ! !!!!!!!!!!!!!! ! ! ! ! ! ! ! ! ! !! !! !! ! ! ! ! ! !! !!!! ! ! ! ! ! !! ! ! ! !!!!!! ! ! ! ! ! !! ! ! ! !! ! ! ! ! ! ``` Leaving up the older 108 char, cellular automata version. ``` j,d[99][99];main(i){d[0][31]=3;for(;i<64;)d[j+1][i]=putchar(32|d[j][i+2]^d[j][i++]);++j<32&&main(puts(""));} ``` ~~So I don't think I'm going to get it much shorter than this so I'll explain the code.~~ I'll leave this explanation up, as some of the tricks could be useful. ``` j,d[99][99]; // these init as 0 main(i){ //starts at 1 (argc) d[0][48]=3; //seed the automata (3 gives us # instead of !) for(;i<98;) // print a row d[j+1][i]=putchar(32|d[j][i+2]]^d[j][i++]); //relies on undefined behavoir. Works on ubuntu with gcc ix864 //does the automata rule. 32 + (bitwise or can serve as + if you know //that (a|b)==(a^b)), putchar returns the char it prints ++j<32&&main(puts("")); // repeat 32 times // puts("") prints a newline and returns 1, which is nice } ``` Some output ``` # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ``` [Answer] # PostScript, 120 chars ``` -7 -4 moveto 14 0 rlineto 7{true upath dup 2{120 rotate uappend}repeat[2 0 0 2 7 4]concat}repeat matrix setmatrix stroke ``` Ghostscript output: ![Rendered Ghostscript output](https://i.stack.imgur.com/FR0FX.png) This is drawing the figure by recursively tripling what's already drawn. First step is drawing a line. The line is saved as a userpath, then the userpath is added two more times after rotating 120 degrees each time. `[2 0 0 2 7 4]concat` moves the "rotation point" to the center of the next big white "center triangle" that is to be enclosed by replications of the triangle we already have. Here, we're back to step 1 (creating a upath that's tripled by rotation). The number of iterations is controlled by the first number in line 3. [Answer] # J (9 characters) Easily the ugliest, you really need to squint to see the output ;) ``` 2|!/~i.32 ``` produces the output ``` 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1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 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ``` of course you can display it graphically: ``` load 'viewmat' viewmat 2|!/~i.32 ``` [![Image](https://i.stack.imgur.com/Z2pZo.jpg)](https://i.stack.imgur.com/Z2pZo.jpg) [Answer] # Python (75) I'm two years late to the party, but I'm surprised that nobody has taken this approach yet ``` from pylab import* x=[[1,1],[1,0]] for i in'123':x=kron(x,x) imsave('a',x) ``` ![level7](https://i.stack.imgur.com/ZYv1I.png) Uses the [Kronecker product](http://en.wikipedia.org/wiki/Kronecker_product) to replace a matrix by multiple copies of itself. I could save two chars by using `x=kron(x,x);x=kron(x,x)` in line three to get a 16x16 pixel image with three visible levels or add another char to the iterator and end up with a 2^16 x 2^16 = 4.3 Gigapixel image and 15 triangle levels. [Answer] # APL, ~~37~~ 32 (~~28~~ 23) ### Upright triangle (~~37~~ 32-char) ``` ({((-1⌷⍴⍵)⌽⍵,∊⍵)⍪⍵,⍵}⍣⎕)1 2⍴'/\' ``` **Explanation** * `1 2⍴'/\'`: Create a 1×2 character matrix `/\` * `{((-1⌷⍴⍵)⌽⍵,∊⍵)⍪⍵,⍵}`: A function that pad the right argument on both sides with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom. E.g. `/\` would become ``` /\ /\/\ ``` * `⍣⎕`: Recur the function (user input) times. **Example output** ``` /\ /\/\ /\ /\ /\/\/\/\ /\ /\ /\/\ /\/\ /\ /\ /\ /\ /\/\/\/\/\/\/\/\ /\ /\ /\/\ /\/\ /\ /\ /\ /\ /\/\/\/\ /\/\/\/\ /\ /\ /\ /\ /\/\ /\/\ /\/\ /\/\ /\ /\ /\ /\ /\ /\ /\ /\ /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ ``` ### Skewed Triangle (~~28~~ 23-char) ``` ({(⍵,∊⍵)⍪⍵,⍵}⍣⎕)1 1⍴'○' ``` **Explaination** * `1 1⍴'○'`: Create a 1×1 character matrix `○` * `{(⍵,∊⍵)⍪⍵,⍵}`: A function that pad the right argument on the right with blanks to create a matrix double as wide, then laminates the right argument itself doubled onto the bottom. E.g. `○` would become ``` ○ ○○ ``` * `⍣⎕`: Recur the function (user input) times. **Example output** ``` ○ ○○ ○ ○ ○○○○ ○ ○ ○○ ○○ ○ ○ ○ ○ ○○○○○○○○ ○ ○ ○○ ○○ ○ ○ ○ ○ ○○○○ ○○○○ ○ ○ ○ ○ ○○ ○○ ○○ ○○ ○ ○ ○ ○ ○ ○ ○ ○ ○○○○○○○○○○○○○○○○ ``` [Answer] **matlab 56** ``` v=[1;-1;j];plot(filter(1,[1,-.5],v(randi(3,1,1e4))),'.') ``` ![enter image description here](https://i.stack.imgur.com/fXJNh.png) [Answer] **Logo, 75 characters** 59 characters for just the first function, the second one calls the first with the size and the depth/number of iterations. So you could just call the first function from the interpreter with the command: e 99 5, or whatever size you want to output ``` to e :s :l if :l>0[repeat 3[e :s/2 :l-1 fd :s rt 120]] end to f e 99 5 end ``` [Answer] # J (18 characters) ``` ' *'{~(,,.~)^:9 ,1 ``` ## Result ``` * ** * * **** * * ** ** * * * * ******** * * ** ** * * * * **** **** * * * * ** ** ** ** * * * * * * * * **************** * * ** ** * * * * **** **** * * * * ** ** ** ** * * * * * * * * ******** ******** * * * * ** ** ** ** * * * * * * * * **** **** **** **** * * * * * * * * ** ** ** ** ** ** ** ** * * * * * * * * * * * * * * * * ******************************** ``` [Answer] # Python (90 chars) ``` from turtle import* def l():left(60) def r():right(60) def f():forward(1) def L(n): if n:n-=1;R(n);l();L(n);l();R(n) else:f() def R(n): if n:n-=1;L(n);r();R(n);r();L(n) else:f() l();L(8) ``` [**Try it online**](https://trinket.io/python/8acda70c9b) Draw fractal line filling Sierpinsky Triangle [Answer] # [APL (Dyalog Classic)](https://www.dyalog.com/), 12 bytes ``` ×.≥∘⍉⍨↑,⍳⎕⍴2 ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob2pm/qO2CQZcjzra0/4fnq73qHPpo44Zj3o7H/WueNQ2UedR72agoke9W4z@A5X8T@MyBQA "APL (Dyalog Classic) – Try It Online") [Answer] # Asymptote, 152 bytes I'll add this, mostly since I've seen more or less no answers in asymptote on this site. A few wasted bytes for nice formatting and generality, but I can live with that. Changing A,B and C will change where the corners of the containing triangle are, but probably not in the way you think. Increase the number in the inequality to increase the depth. ``` pair A=(0,0),B=(1,0),C=(.5,1);void f(pair p,int d){if(++d<7){p*=2;f(p+A*2,d);f(p+B*2,d);f(p+C*2,d);}else{fill(shift(p/2)*(A--B--C--cycle));}}f((0,0),0); ``` or ungolfed and readable ``` pair A=(0,0), B=(1,0), C=(.5,1); void f(pair p, int d) { if (++d<7) { p *= 2; f(p+A*2,d); f(p+B*2,d); f(p+C*2,d); } else { fill(shift(p/2)*(A--B--C--cycle)); } } f((0,0),0); ``` So asymptote is a neat vector graphics language with somewhat C-like syntax. Quite useful for somewhat technical diagrams. Output is of course in a vector format by default (eps, pdf, svg) but can be converted into basically everything imagemagick supports. Output: [![Sierpinski triangle](https://i.stack.imgur.com/1XyYE.png)](https://i.stack.imgur.com/1XyYE.png) [Answer] # [Mathematica](https://www.wolfram.com/mathematica/), 29 bytes ``` Image@Array[BitAnd,{2,2}^9,0] ``` ![Image@Array[BitAnd,{2,2}^9,0]](https://i.stack.imgur.com/7IR6g.jpg) The Sierpinski tetrahedron can be drawn in a similar way: ``` Image3D[1-Array[BitXor,{2,2,2}^7,0]] ``` ![Image3D[1-Array[BitXor,{2,2,2}^7,0]]](https://i.stack.imgur.com/TUzsq.jpg) [Answer] # [J](http://jsoftware.com/), ~~37~~ 35 bytes *-2 bytes thanks to FrownyFrog* ``` (,.~,~' '&,.^:#)@[&0' /\',:'/__\'"_ ``` [Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/NXT06nTq1BXU1XT04qyUNR2i1QzUFfRj1HWs1PXj42PUleL/a3Il2uoZKZiogCQUQKIK6lx@TnoKqckZ@QqJXGAqTcFQAcJSV4eJGKELGKMLmHBx/QcA "J – Try It Online") This is Peter Taylor's ascii art version converted to J. Could save bytes with a less pretty version, but why? ``` /\ /__\ /\ /\ /__\/__\ /\ /\ /__\ /__\ /\ /\ /\ /\ /__\/__\/__\/__\ ``` [Answer] # [Lua](http://golly.sourceforge.net/Help/lua.html) script in [Golly](http://golly.sourceforge.net/), 54 bytes ``` g=golly() g.setrule("W60") g.setcell(0,0,1) g.run(512) ``` Golly is a cellular automata simulator with Lua and Python scripting support. This script sets the rule to Wolfram Rule 60, sets the cell at (0,0) to 1, and runs 512 steps. [![enter image description here](https://i.stack.imgur.com/kTOs5.png)](https://i.stack.imgur.com/kTOs5.png) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes ``` 1=IGx^Db, ``` [Try it online!](https://tio.run/##yy9OTMpM/f/f0NbTvSLOJUnn/39jIwA "05AB1E – Try It Online") The number of rows is equal to the input. # Explanation: ``` 1=IGx^Db, 1= print "1" and push 1 IG for N in range(1, I): (where I is the input) x push last element on stack multiplied by 2 ^ pop last two elements, push their bitwise xor (output is in decimal) D duplicate last element of stack b, replace last element of stack with its binary representation, then print/pop ``` This takes advantage of the fact that a(n+1) = a(n) XOR 2\*a(n), which I found on [this relevant OEIS page](https://oeis.org/A001317) [Answer] **Mathematica 63** ``` ListPlot@ReIm@NestList[#/2+RandomChoice[{0,1,-1}^(1/3)]&,0.,8!] ``` [![enter image description here](https://i.stack.imgur.com/zF0bb.png)](https://i.stack.imgur.com/zF0bb.png) **Mathematica 67** ``` Region@Polygon@ReIm@Nest[Tr/@Tuples[{p,#}/2]&,{p={0,1,-1}^(1/3)},6] ``` [![enter image description here](https://i.stack.imgur.com/WbSgv.png)](https://i.stack.imgur.com/WbSgv.png) [Answer] # 8086 Machine code - 18 bytes (unknown author) / 27 bytes (mine) In early 1990s, I organized a small competition on programmer's board on a Croatian BBS, who can write the smallest program to draw the Sierpinski triangle. My best solution was 27 bytes long, but there were several even smaller and unique solutions, with smallest one being only 18 bytes of machine code. Unfortunately, I forgot the name of the person who wrote it - so if the original author is reading this, please contact me. :) --- **18 bytes solution by an unknown Croatian programmer**: ``` Bytes: B0 13 CD 10 B5 A0 8E D9 30 84 3F 01 AC 32 04 E2 F7 C3 0100 B013 MOV AL,13 0102 CD10 INT 10 0104 B5A0 MOV CH,A0 0106 8ED9 MOV DS,CX 0108 30843F01 XOR [SI+013F],AL 010C AC LODSB 010D 3204 XOR AL,[SI] 010F E2F7 LOOP 0108 0111 C3 RET ``` Which draws this: [![Sierpinski triangle in 18 bytes of 8086 machine code](https://i.stack.imgur.com/xH4s2.png)](https://i.stack.imgur.com/xH4s2.png) --- **My 27 bytes solution**: ``` Bytes: B0 13 CD 10 B7 A0 8E C3 8E DB BF A0 00 AA B9 C0 9E BE 61 FF AC 32 04 AA E2 FA C3 0100 B013 MOV AL,13 0102 CD10 INT 10 0104 B7A0 MOV BH,A0 0106 8EC3 MOV ES,BX 0108 8EDB MOV DS,BX 010A BFA000 MOV DI,00A0 010D AA STOSB 010E B9C09E MOV CX,9EC0 0111 BE61FF MOV SI,FF61 0114 AC LODSB 0115 3204 XOR AL,[SI] 0117 AA STOSB 0118 E2FA LOOP 0114 011A C3 RET ``` Which draws this: [![Sierpinski triangle in 27 bytes of 8086 machine code](https://i.stack.imgur.com/UXaO2.png)](https://i.stack.imgur.com/UXaO2.png) [Answer] ## C, 106 chars ``` i,j;main(){for(;i<32;j>i/2?puts(""),j=!++i:0) printf("%*s",j++?4:33-i+i%2*2,i/2&j^j?"":i%2?"/__\\":"/\\");} ``` (It still amuses me that `puts("")` is the shortest way to output a newline in C.) Note that you can create larger (or smaller) gaskets by replacing the `32` in the `for` loop's test with a larger (smaller) power of two, as long as you also replace the `33` in the middle of the `printf()` with the power-of-two-plus-one. ]
[Question] [ **Task:** Output the Swiss flag. Happy Swiss National Day / Schweizer Bundesfeiertag / Fête nationale suisse / Festa nazionale svizzera / Fiasta naziunala svizra! **Details:** The flag consists of a white (`#FFFFFF`) cross on a red (`#FF0000`) background. The cross consists of a 6x6 square with arms of size 6x7 glued to each side. The cross is in the center of the 32x32 square background having a distance of 6 units to each side. ([Source](https://www.admin.ch/opc/en/classified-compilation/20091656/index.html)) The output size can be chosen by the participant, but the image must exactly match these proportions, this means its size must be a multiple of 32. ![](https://i.stack.imgur.com/6FhuZ.png) A minimal version would look like so: ![](https://i.stack.imgur.com/D267d.png) [Answer] ## SVG (HTML5), ~~94~~ ~~83~~ ~~82~~ 64 bytes ``` <svg><path d=M0,0V32H32V0M6,13h7V6h6v7h7v6H19v6H13V19H6 fill=red ``` Saved 2 bytes thanks to @ThePirateBay. Saved 1 byte thanks to @ATaco. Saved 18 bytes thanks to @CraigAyre pointing out that a 32×32 image was acceptable. As pointed out by @Shaggy, this assumes your default background is white; add 22 bytes for a flag that works on any background: ``` <svg><path d=M0,0V32H32V0 fill=red /><path d=M6,13h7V6h6v7h7v6H19v6H13V19H6 fill=#FFF ``` [Answer] # x86-16 Machine Code for DOS, 43 bytes ``` ; Draw 32x32 red square B8 0C 28 mov ax, 0x0C28 ; AL == color red, AH == set pixel function B9 00 1F mov cx, 31 DrawBox: BA 00 1F mov dx, 31 DrawRow: CD 10 int 0x10 4A dec dx 75 FB jnz DrawRow E2 F6 loop DrawBox ; Draw the interior white cross B0 0F mov al, 0x0F ; high byte already set B1 06 mov cl, 6 ; high byte already 0 DrawCross: B2 0D mov dl, 13 ; high byte already 0 DrawCrossInner: CD 10 int 0x10 ; plot CX, DX 87 D1 xchg dx, cx CD 10 int 0x10 ; plot DX, CX 87 D1 xchg dx, cx 42 inc dx 80 FA 12 cmp dl, 13+6 75 F2 jne DrawCrossInner 41 inc cx 80 F9 19 cmp cl, 6+(32-6-6) 75 EA jne DrawCross C3 ret ``` The above code is designed to be assembled as a COM file and then run under DOS. It invokes the ROM BIOS video services to plot the individual pixels of the flag, forming a 32×32 representation of the Swiss flag in the upper-left corner of the screen. The code assumes that the video mode is already set to mode 0x13, which also means that it requires a VGA display. Other video modes could be used, but requiring VGA gives you two things: (1) square pixels, and (2) a default palette that includes a true 100% red (`0xFF0000`) (meaning you don't have to waste bytes changing the palette colors). Before running this program, you will therefore need to switch your display to mode 0x13; the following code is all you need to do that: ``` mov ax, 0x13 int 0x10 ``` The code makes no other assumptions, and should run on any x86-compatible hardware under a DOS-compatible operating system. However, the program terminates immediately after drawing the flag, so the DOS prompt will normally be re-printed at the top-left corner of the screen, covering up the top few lines of the flag. Therefore, if you want to marvel at the true output, you need to hang/pause the system before it `RET`urns. Here's a screenshot of what that looks like, running in a FreeDOS virtual machine: [![](https://i.stack.imgur.com/NagTX.png)](https://i.stack.imgur.com/NagTX.png) It might be possible to golf this down further by writing pixel data directly to the video buffer, especially since I'm already assuming mode 0x13. I haven't tried that yet. `INT 0x10` is already a pretty short instruction, *but* if I can use the one-byte string instructions to write pixel data directly to memory, then that could result in a significant code savings. [Answer] # [MATL](https://github.com/lmendo/MATL), 29 bytes ``` 2Y66t&Y"OJQht3$)6thYaQK7hBoYG ``` Try it at [**MATL Online!**](https://matl.io/?code=2Y66t%26Y%22OJQht3%24%296thYaQK7hBoYG&inputs=&version=20.2.2) ### Explanation ``` 2Y6 % Push predefined literal: 3×3 matrix [0 1 0; 1 1 1; 0 1 0] 6t&Y" % Repeat each entry 6 times in the two dimensions. Gives an 18×18 matrix OJQh % Push [0 1j+1]. Used as an index, this means [0 1 ... end+1]. Indexing % is 1-based and modular, so 0 is the same as end t3$) % Apply that index in the two dimensions. This extends by 1 entry in % each dimension, so that the arms have length 7. Gives a 20×20 matrix 6thYa % Pad with 6 zeros in the two dimensions. Gives a 32×32 matrix Q % Add 1. The matrix now contains values 1 (will become red) and 2 (white) K7hBo % Convert array [4 7] to binary. Gives [1 0 0; 1 1 1], to be used as % colormap. First row is red, second is white YG % Show image using colormap ``` [Answer] # Java 8, 246 + 42 = 288 bytes *Thanks to @Aaron for -64 bytes.* *-4 bytes by outputting to file `a` without extension.* ``` import java.awt.*;import java.awt.image.*; x->{BufferedImage i=new BufferedImage(32,32,1);Graphics g=i.getGraphics();g.setColor(Color.RED);g.fillRect(0,0,32,32);g.setColor(Color.WHITE);g.fillRect(13,6,6,20);g.fillRect(6,13,20,6);javax.imageio.ImageIO.write(i,"png",new java.io.File("a"));} ``` A lamba expression that can be assigned to a functional interface method that throws an exception. Creates an image file named `a` (an image file) in the directory running this file. Surrounding code used to run it: [Try it online!](https://tio.run/##bZFRa8IwEMff@ykOn9IRY1XwJbiHOd36MAQ32MPYQ6zXNl1MSppaofjZu7RjA2VcyJFf7o5//inESYxNibo4fHXyWBrroPCMicaxO35L5FFk6HkQlPVeyQQSJaoKXoTUbRBI7dCmIkHYtCcjD5CS7b7AxIEJXW5NU8H6nGDppNH88jejcsL5NHQc/STy6qzU2cenCOG2DdpgAyksu/P4vn2o0xQtHuJeFcilxgauGJnPqF/TkD9ZUeYyqSBbSpah@z2TkGesQrcyylgy7Gy3fuxpKpXaefEkohEdBv1T@/4cv62vqqdzuvAxi67ogno@i@gi5L2Z5x8npWGDznjLGisdEklHpc5GtH/JYLqv2EiFZCRGYcgvHQ9SlhJdKxXy4OJjMoGV0No4EEmC/i9cjmCxqpXzHoIXgOBte4u31F@ZOssZY903) ## Ungolfed ``` x->{ BufferedImage i=new BufferedImage(32,32,1); Graphics g=i.getGraphics(); g.setColor(Color.RED); g.fillRect(0,0,32,32); g.setColor(Color.WHITE); g.fillRect(13,6,6,20); g.fillRect(6,13,20,6); javax.imageio.ImageIO.write(i,"png",new java.io.File("a")); } ``` ## Result [![](https://i.stack.imgur.com/EjS3tm.png)](https://i.stack.imgur.com/EjS3t.png) Grid provided by the IntelliJ IDEA image preview (apparently). [Answer] # Excel VBA, ~~86~~ ~~85~~ 79 Bytes ## Code Anonymous VBE immediate window function that takes no input and outputs the Swiss flag onto the range `[A1:F32]` of the `ActiveSheet` object. This works by first making the cells square, then drawing the red region and finally drawing in the white cross. ``` Cells.RowHeight=48:[A1:AF32].Interior.Color=255:[G14:Z19,N7:S26].Interior.Color=-1 ``` *Note that arrangements which that remove the step of coloring the "cross" of the Swiss flag after putting in the red background are actually longer than the above configuration, as they require at least 16 cell addresses, which coordinate to the 8 distinct regions of the flag* -1 Byte thanks to @Greedo's for `RowHeight=48` over `ColumnWidth=2` -6 Bytes thanks to @Greedo's for `-1` instead `rgbWhite` ## Output [![enter image description here](https://i.stack.imgur.com/LkA5o.png)](https://i.stack.imgur.com/LkA5o.png) [Answer] ## C++, SFML, ~~406~~ ~~399~~ 394 bytes -2 bytes thanks to pdpi -10 bytes thanks to Zacharý [SFML ( Simple and Fast Multimedia Library )](https://www.sfml-dev.org/index.php) is a C++ library written to ease the developpement of video games and multimedia programs The code : ``` #include<SFML\Graphics.hpp> using namespace sf;int main(){for(RenderWindow t(VideoMode(128,128),"");t.isOpen();){t.clear();RectangleShape r({128.f,128.f});r.setFillColor(Color::Red);t.draw(r);r.setFillColor(Color::White);r.setPosition({24.f,52.f});r.setSize({80.f,24.f});t.draw(r);r.rotate(90);r.setPosition({76.f,24.f});t.draw(r);t.display();for(Event e;t.pollEvent(e);)if(!e.type)t.close();}} ``` The flag get displayed in a 128x128 window. Your OS have to be able to display a 128x128 window ( my Win8.1 can't display with smaller width ) **WARNING** : you may want to add these 2 lines of code : `t.setFramerateLimit(60);t.setVerticalSyncEnabled(true);`, so your CPU won't heat when you run the code. I did not put them in the original code for golfing reasons. [Answer] # Braindraw, 227 bytes (Non-competing) (Updated to actually work) Ungolfed version (241 bytes) ``` r<<^++++++++[-^++++v]^[->>[>]>++++++++[-<++++>]<[<]<]>>[[-vv[v]-[^]^]>]vv<[<]>>>>>>>>>>>>>>vvvvvvg<<^^++++++[->>[>]>+++++[-<++++>]<[<]<]>>[[-vv[v]b-g-[^]^]>]<vv[<]><<<<<<<vvvvvvv<<^^++++++[-vv[v]++++++++++++++[^]^]vv[[->>[>]b[+]-g[+]-[<]<]v] ``` Lightly golfed version (227 bytes) ``` r<<^++++++++[-^++++v]^[->>[>]>++++++++[-<++++>]<[<]<]>>[[-vv[v]-[^]^]>]vv<[<]g>>>>>>>>>>>>vvvv++++++[->>[>]>+++++[-<++++>]<[<]<]>>[[-vv[v]b-g-[^]^]>]<vv[<]<<<<<<vvvvv<<++++++[-vv[v]++++++++++++++[^]^]vv[[->>[>]b[+]-g[+]-[<]<]v] ``` Braindraw is a programming language of my own design. As of 3:08 pm today, I do have a working interpreter and have checked that the program runs properly. However, the interpreter did not exist before this competition began, so I am not competing. Braindraw is the same as Brainf\*\*\*, except that it operates on three two-dimensional arrays, rather than one one-dimensional array. These arrays are called r, g, and b, and act as the red green and blue color channels. The operator r moves the pointer to the red channel, etc etc. Up is ^, down is v. [Answer] # Mathematica, 83 bytes ``` R=Rectangle;Graphics[{Red,{0,0}~R~{32,32},White,{6,13}~R~{26,19},{13,6}~R~{19,26}}] ``` next one is from @ASCII-only (I thought it was a joke but it works!) # Mathematica, 23 bytes ``` "CH"~CountryData~"Flag" ``` -10 bytes from @Jonathan Frech [Answer] # TI-BASIC (TI-84 Plus C(S)E only), 58 [bytes](http://tibasicdev.wikidot.com/tokens) ``` :For(A,0,31 :For(B,0,31 :Pxl-On(A,B,RED :End :End :For(A,6,25 :For(B,13,18 :Pxl-Off(A,B :Pxl-Off(B,A :End :End ``` [Answer] # HTML + CSS, 15 + 117 bytes = 132 bytes Using a flexbox wrapper with an `inset` `box-shadow`. ``` b{display:flex;box-shadow:red 0 0 0 6px inset;padding:2px;width:28px;flex-wrap:wrap}a{border:solid red 4px;margin:3px ``` ``` <b><a><a><a><a> ``` --- # HTML + CSS, 18 + ~~139~~ ~~137~~ 122 bytes = 140 bytes Previous answer using `border` and an intermediate flexbox wrapper with negative `margin`. ``` i,b,a{display:inline-flex}i{border:solid red 6px}b{margin:-4px;width:28px;flex-wrap:wrap}a{border:solid red 4px;margin:3px ``` ``` <i><b><a><a><a><a> ``` [Answer] # JavaScript + HTML, 99 + 13 = 112 bytes *Saved 2 bytes thanks to [user2428118](https://codegolf.stackexchange.com/users/13486/user2428118)* *Saved 2 bytes thanks to [Matheus Avellar](https://codegolf.stackexchange.com/users/66000/matheus-avellar)* [JSFiddle](https://jsfiddle.net/yrhhzjuf/) ``` with(c.getContext`2d`)fillStyle='red',fillRect(0,0,32,32),clearRect(6,13,20,6),clearRect(13,6,6,20) ``` ``` <canvas id=c> ``` --- # Pure JavaScript, ~~194~~ 129 bytes [JSFiddle](https://jsfiddle.net/g6ba035h/) ``` with(document.write`<canvas id=c>`,c.getContext`2d`)fillStyle='red',fillRect(0,0,32,32),clearRect(6,13,20,6),clearRect(13,6,6,20) ``` [Answer] # [GraphicsMagick](http://www.graphicsmagick.org) (?), 96 bytes ``` gm convert -size 32x32 xc:red -fill #fff -draw "rectangle 13,6 18,25 rectangle 6,13 25,18" 1.bmp ``` Not sure how to golf with GM (should this be considered as a language?). Also not sure how to count bytes here... With GM installed, type the given code in windows cmd, you will get an image with name `1.bmp`. You may want change double quote to single quote if you are using bash (it should work, but i had not tested this). Thanks to Digital Trauma. use only one `-draw` save 8 bytes [Answer] # [GFA BASIC](https://en.wikipedia.org/wiki/GFA_BASIC) (Atari ST), ~~ 62 ~~ 55 bytes A manually edited listing in .LST format. All lines end with `CR`, including the last one. ``` DEFF 2 PB 0,0,31,31 DEFF 0 PB 13,6,18,25 PB 6,13,25,18 ``` Expanded and commented: ``` DEFFILL 2 ! set fill color: default system color #2 is red (&H700) PBOX 0,0,31,31 ! draw the red square DEFFILL 0 ! set fill color: default system color #0 is white (&H777) PBOX 13,6,18,25 ! draw a vertical white rectangle PBOX 6,13,25,18 ! draw a horizontal white rectangle ``` ###Output The output is 32x32. [![GFA output](https://i.stack.imgur.com/CGyzR.png)](https://i.stack.imgur.com/CGyzR.png) *NB: This is indeed using the 'white' color, although it's gray-looking on the emulator (and on the real thing as well, unless you turn the brightness quite high).* [Answer] # JavaScript (ES6) in HTML4(?), ~~178~~ 176 bytes ``` document.write('<table cellspacing=0>'+[...Array(32)].map((_,y,p)=>p.map((_,x)=>`<td bgcolor=${x>5&&x<26&&y>12&&y<19||y>5&&y<26&&x>12&&x<19?'#fff':'red'}>`).join``).join`<tr>`) ``` Yes! We do not need `<canvas>` nor `<svg>` or even `<img>`! Thanks to Justin Mariner, save 2 bytes. [Answer] # [Löve2D](http://love2d.org/), ~~139~~ 138 Bytes ``` l=love g=l.graphics c=g.setColor r=g.rectangle f="fill"w=255 l.draw=loadstring"c(w,0,0)r(f,0,0,32,32)c(w,w,w)r(f,13,6,6,20)r(f,6,13,20,6)" ``` Saved one byte thanks to [ThePirateBay](https://codegolf.stackexchange.com/users/72349/thepiratebay) ## Ungolfed ``` function love.draw() love.graphics.setColor(255,0,0) love.graphics.rectangle("fill",0,0,32,32) love.graphics.setColor(255,255,255) love.graphics.rectangle("fill",13,6,6,20) love.graphics.rectangle("fill",6,13,20,6) end ``` [Answer] # [Python 3](https://docs.python.org/3/), 190 bytes Save output as `image.xpm` and open with your favorite text editor. ``` r=range;print('! XPM2\n32 32 2 1\nr c #FF0000\nw c #FFFFFF\n');d=[bytearray(b'r'*32)for _ in r(32)] for i in r(20): for j in r(6):d[i+6][j+13]=d[j+13][i+6]=119 print(b'\n'.join(d).decode()) ``` [Try it online!](https://tio.run/##JY7BCoMwEETvfsWWHpJUEJOAUCVXb4UeC0aKmrSNh1UWofj1VpthYXjvsjOvy2dCvW1kqMO3r2YKuHB2gsf9pixqBfspkBYJBjjXdb7H4jfCEYtMVM40/br4jqhbec@IXbQSr4ngCQGB@E5tcnCIrHJRJnCIMYpClK4JadE2Yyp1a1zsvzJSXpM4rGf7u2ycAnInMueHyXkuxLb9AA "Python 3 – Try It Online") Output: ``` ! XPM2 32 32 2 1 r c #FF0000 w c #FFFFFF rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrwwwwwwwwwwwwwwwwwwwwrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrwwwwwwrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr ``` [Answer] ## R, 171 140 bytes. ``` x = rep(c(6,13,19,26,19,13),e=2) l=c(0,32) par(bg="red",mar=0*1:4) plot(0,0,'n',l,l,xaxs="i",yaxs="i") polygon(x,c(x,x)[4:15],c="white",b=0) ``` (somewhat) ungolfed: ``` x <- rep(c(6,13,19,26,19,13),each=2) y <- c(x,x)[4:15] # index by 3 positions par(bg="red",mar=c(0,0,0,0)) # prepare the plot space plot(0,type='n', xaxs="i",yaxs="i",xlim=c(0,32),ylim=c(0,32)) polygon(x,y,col="white",border=0) ``` Thanks to @gregor for saving some bytes [Run it!](http://www.r-fiddle.org/#/fiddle?id=UWMjeIJF&version=4) [Answer] # Octave, ~~105 bytes~~ 73 bytes *Note: line feeds added for clarity, not included in byte count* ``` x(32,32,3)=0; x(:,:,1)=1; x(7:26,14:19,:)=1; x(14:19,7:26,:)=1; imshow(x*255) ``` EDIT: thanks to [flawr](https://codegolf.stackexchange.com/users/24877/flawr) for saving quite a lot of bytes! Here is the result on octave-online.net, thanks to [sanchises](https://codegolf.stackexchange.com/users/32352/sanchises) [![Results](https://i.stack.imgur.com/QZBXJ.png)](https://i.stack.imgur.com/QZBXJ.png) [Answer] # GIF, 97 Bytes ``` GIF87a ð ÿ ÿÿÿ, @„©Ëí£œ´Ú;ƒÞXmÞ!ŸŠcyŒj¨,àZê<Cô :8nïtï‹é‚BJ1tì$1ËKSvb=_ÔªõŠe ; ``` Cheap and byte-heavy, but worth it. EDIT: Some characters aren't in the code above, [here's](https://pastebin.com/4w90RqC1) a pastebin for the GIF's hexdump. EDIT: compressed down to 97 bytes with online tool. [Answer] # [Perl 5](https://www.perl.org/) + `-p0513`, 80 bytes ``` print"P6 32 32 1",$_=($}="A..")x192,$\=($}x13 .1x18 .$}x13)x7,($}x6,1x60,$}x6)x6 ``` [Try it online!](https://dom111.github.io/code-sandbox/#eyJsYW5nIjoid2VicGVybC01LjI4LjEiLCJjb2RlIjoicHJpbnRcIlA2IDMyIDMyIDFcIiwkXz0oJH09XCJBXHUwMDAwXHUwMDAwXCIpeDE5MiwkXFw9KCR9eDEzIC4xeDE4IC4kfXgxMyl4NywoJH14NiwxeDYwLCR9eDYpeDYiLCJhcmdzIjoiLXAwNTEzIiwibWltZSI6ImltYWdlL3gtcG9ydGFibGUtYml0bWFwIn0=) Outputs a PBM file. --- # [Perl 5](https://www.perl.org/) + `-p0513 -M5.10.0`, 82 bytes ``` say"P6 32 32 1",map{($|--||"A..")x$_}205,@a=((18,26)x6,18),20,(54,14)x6,0,6,@a,205 ``` [Try it online!](https://dom111.github.io/code-sandbox/#eyJsYW5nIjoid2VicGVybC01LjI4LjEiLCJjb2RlIjoic2F5XCJQNiAzMiAzMiAxXCIsbWFweygkfC0tfHxcIkFcdTAwMDBcdTAwMDBcIil4JF99MjA1LEBhPSgoMTgsMjYpeDYsMTgpLDIwLCg1NCwxNCl4NiwwLDYsQGEsMjA1IiwiYXJncyI6Ii1wMDUxM1xuLU01LjEwLjAiLCJtaW1lIjoiaW1hZ2UveC1wb3J0YWJsZS1iaXRtYXAifQ==) Also outputs a PBM file. This is a slightly more interesting approach, but I can't get it to beat the above. --- # [Perl 5](https://www.perl.org/) + `-Mutf8 -p0513 -M5.10.0`, 149 bytes ``` say"",$\=($l=$"x32 ." ")x3,$_=(($s=$"x13).($}='█')x6 ."$s ")x3,$l=($"x=6).($a='▄'x7).$}x6 .$a.$",(" ",$",$}x20,$")x2," ",$l=~y;▄;▀;r ``` [Try it online!](https://tio.run/##LYxBCsIwEEX3XsGNDANNIIakoa1ScgRPoCBdKAjRlqZCuqi4cOEJPKAHMU7ExTDzH@9Pd@hdEaNvRphvtdL1ujqDwJ1l6CxCMPlCwgx4MAL3ljH0iWrDJcPJZu/XM@OhJAf933JUhWDLZDTJeGSh4hKnpGEjEQSjj4I2sVzRwUMufsjZ21hTg@Ze9zF@2m44tRcfl5vrcFzFZacKbSgVUiupvg "Perl 5 – Try It Online") Output is to the terminal via ANSI escape codes and looks like this: [![swiss swoo](https://i.stack.imgur.com/cgPok.png)](https://i.stack.imgur.com/cgPok.png) Proportions should be to scale based on one character space being two vertical 'pixels'. You can preview the output by copying from TIO and [pasting in here (this shows the control characters when hovered over the element)](https://codepen.io/dom111/full/RZaOVe/). [Answer] # HTML + JavaScript (ES6), 13 + 112 = 125 bytes ``` C=c.getContext`2d` C[s='fillStyle']='red' C[r='fillRect'](0,0,32,32) C[s]='#fff' C[r](6,13,20,6) C[r](13,6,6,20) ``` ``` <canvas id=c> ``` # HTML + JavaScript (ES6), 13 + 114 = 127 bytes ``` with(c.getContext`2d`)fillStyle='red',fillRect(0,0,32,32),fillStyle='#fff',fillRect(6,13,20,6),fillRect(13,6,6,20) ``` ``` <canvas id=c> ``` [Answer] # C# ~~265/266~~ 209 bytes ``` using System;using c=System.Console;class P{static void Main(){for(int i=0,j;i<32;i++){for(j=0;j<32;j++){if((6<i&&i<26&&j>13&&j<19)||(6<j&&j<26&&i>13&&i<19))c.BackgroundColor=ConsoleColor.White;else c.BackgroundColor=ConsoleColor.Red;c.Write(" ");}c.WriteLine();}}} ``` I wrote "space" characters into console while changing Background Color. But if you think it is too tall and you count single character as 8 x 16 pixels, you simply double values near "j" like this (+ 1 byte and + `c.ReadKey();` so it stops): ``` using System;using c=System.Console;class P{static void Main(){for(int i=0,j;i<32;i++){for(j=0;j<64;j++){if((6<i&&i<26&&j>26&&j<38)||(12<j&&j<52&&i>13&&i<19))c.BackgroundColor=ConsoleColor.White;else c.BackgroundColor=ConsoleColor.Red;c.Write(" ");}c.WriteLine();} c.ReadKey(); }} ``` 56 bytes saved thanks to [TheLethalCoder](https://codegolf.stackexchange.com/users/38550/thelethalcoder) ``` namespace System{using static Console;class P{static void Main(){for(int i=0,j;i<32;i++,WriteLine())for(j=0;j<32;Write(""))BackgroundColor=(ConsoleColor)((6<i&i<26&j>13&j<19)|(j++<26&i>13&i<19&6<j​)?15:12);}}} ``` [Answer] # Tikz, ~~145~~ 143 bytes ``` \documentclass[tikz]{standalone}\begin{document}\tikz{\def~{)rectangle(}\fill[red](,~33,33);\fill[white](7,14~27,20)(14,7~20,27)}\end{document} ``` Here it is "ungolfed" ``` \documentclass[tikz]{standalone} \begin{document} \tikz{ \def~{)rectangle(} \fill[red](,~33,33); \fill[white](7,14~27,20)(14,7~20,27) }\end{document} ``` Here it is ungolfed a little more ``` \documentclass[tikz]{standalone} \begin{document} \tikz{ \fill[red](1,1)rectangle(33,33); \fill[white](7,14)rectangle(27,20)(14,7)rectangle(20,27) }\end{document} ``` This makes 3 rectangles a big red one and two smaller white ones for the plus. Here's what it looks like. It doesn't really look any different than the others. [![flag](https://i.stack.imgur.com/nOzq0.png)](https://i.stack.imgur.com/nOzq0.png) [Answer] # R, 109 bytes ``` par(mar=0*1:4,bg=2,xaxs="i",yaxs="i") frame() rect(a<-c(6,13)/32,rev(a),b<-c(26,19)/32,rev(b),c="white",b=NA) ``` Uses `frame` to avoid presetting a plot, but default plotting region is on interval [0,1] instead of [0,32]. Also uses the fact that `rect` is vectorized. The default size of the plotting window is 7in x 7in. It outputs the following: [![Swiss flag in plotting window](https://i.stack.imgur.com/mHWKhm.png)](https://i.stack.imgur.com/mHWKh.png) # R, 125 bytes ``` png() par(mar=0*1:4,bg=2,xaxs="i",yaxs="i") frame() rect(a<-c(6,13)/32,rev(a),b<-c(26,19)/32,rev(b),c="white",b=NA) dev.off() ``` Default for `png` is a square of 480x480 pixels. Output is the following png file: [![Swiss flag](https://i.stack.imgur.com/9m43bs.png)](https://i.stack.imgur.com/9m43b.png) [Answer] # R, 112 bytes ``` par(bg=2,mar=0*1:4) plot(0:32,0:32,'n',xaxs="i",yaxs="i") rect(c(6,13),c(13,6),c(26,19),c(19,26),c="white",b=NA) ``` Though, to guarantee the aspect ratio, we need 5 more bytes for a total of 117: ``` par(bg=2,mar=0*1:4) plot(0:32,0:32,'n',xaxs="i",yaxs="i",as=1) rect(c(6,13),c(13,6),c(26,19),c(19,26),c="white",b=NA) ``` With lots of inspiration from [Alex Axthelm's answer](https://codegolf.stackexchange.com/a/137092/62252), and thanks to Rift for saving a few more bytes. [Answer] # Postscript, ~~301 286~~ 187 bytes ``` /m{moveto}def /s{setrgbcolor}def /r{rlineto}def /c{closepath fill}def 1 0 0 s 0 0 m 0 320 r 320 0 r 0 -320 r c 1 1 1 s 130 60 m 60 0 r 0 200 r -60 0 r c 60 130 m 0 60 r 200 0 r 0 -60 r c ``` Thanks to the anonymous editor who suggested a *99 byte reduction!* [Answer] # [Red](http://www.red-lang.org/), 79 Bytes ## Code: ``` view[base 32x32 red draw[fill-pen white pen off box 6x13 26x19 box 13x6 19x26]] ``` ## Result: [![window](https://i.stack.imgur.com/VWfol.png)](https://i.stack.imgur.com/VWfol.png) ## Explanation: ``` view [ ; activate view engine base 32x32 red ; draw a 32 by 32 red box as base draw [ ; draw on top of the base fill-pen white ; fill color is white pen off ; turn off outline, alternatively could use white box 6x13 26x19 ; draw a horizontal rectangle, specified as 2 corners XxY box 13x6 19x26 ; draw vertical rectangle ]] ``` [Answer] ## Bitmap, 160 bytes Here's a bitmap with 1-bit colour depth, using a 24-bit colour definition. The last six bytes of the second line is the palette and following that is the pixel array. Every four bytes contains a whole row of pixels. ``` 42 4D A0 00 00 00 00 00 00 00 20 00 00 00 0C 00 00 00 20 00 20 00 01 00 01 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 03 FF FF C0 03 FF FF C0 03 FF FF C0 03 FF FF C0 03 FF FF C0 03 FF FF C0 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 07 E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ``` I tried to truncate the trailing zeroes, but image viewers require there are enough pixels defined for the entire canvas. [![Swiss.bmp](https://i.stack.imgur.com/6b1tZ.png)](https://raw.githubusercontent.com/Hand-E-Food/public/master/files/Swiss.bmp) [Answer] # Python 2, ~~92~~ ~~91~~ 89 bytes ``` r,w=' \0\0',' '*3 A,B=192*r,(13*r+6*w+13*r)*7 print"P6 "+"32 "*3+A+B+(6*r+20*w+6*r)*6+B+A ``` Output as binary ppm, usage: ``` python golf_swiss.py > swiss.ppm ``` Increasing the color depth allowed me to use space for maximum value [Answer] # Tcl/Tk, 94 If it runs on the interactive shell, one can abbreviate `canvas` to `can` and `grid` to `gri` ``` gri [can .c -bg red -w 32 -he 32] lmap R {{8 15 28 21} {15 8 21 28}} {.c cr r $R -f #FFF -w 0} ``` # Tcl/Tk, 98 If it runs on the interactive shell, one can abbreviate `canvas` to `can` ``` grid [can .c -bg red -w 32 -he 32] .c cr r 8 15 28 21 -f #FFF -w 0 .c cr r 15 8 21 28 -f #FFF -w 0 ``` # Tcl/Tk, 101 ``` pack [canvas .c -bg red -w 32 -he 32] .c cr r 8 15 28 21 -f #FFF -w 0 .c cr r 15 8 21 28 -f #FFF -w 0 ``` [![enter image description here](https://i.stack.imgur.com/zlRvE.png)](https://i.stack.imgur.com/zlRvE.png) ]
[Question] [ Your task is to compute the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of two given integers in as few bytes of code as possible. You may write a program or function, taking input and returning output [via any of our accepted standard methods](http://meta.codegolf.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) (including STDIN/STDOUT, function parameters/return values, command-line arguments, etc.). Input will be two non-negative integers. You should be able to handle either the full range supported by your language's default integer type, or the range `[0,255]`, whichever is greater. You are guaranteed that at least one of the inputs will be non-zero. You are not allowed to use built-ins that compute either the GCD or the LCM (least common multiple). Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. ### Test Cases ``` 0 2 => 2 6 0 => 6 30 42 => 6 15 14 => 1 7 7 => 7 69 25 => 1 21 12 => 3 169 123 => 1 20 142 => 2 101 202 => 101 ``` [Answer] # [Retina](https://github.com/mbuettner/retina), 16 ``` ^(.+)\1* \1+$ $1 ``` This doesn't use Euclid's algorithm at all - instead it finds the GCD using regex matching groups. [Try it online.](http://retina.tryitonline.net/#code=XiguKylcMSogXDErJAokMQ&input=MTExMTExMTEgMTExMTExMTExMTEx) - This example calculates GCD(8,12). Input as 2 space-separated integers. Note that the I/O is in unary. If that is not acceptable, then we can do this: # Retina, 30 ``` \d+ $* ^(.+)\1* \1+$ $1 1+ $.& ``` [Try it online.](http://retina.tryitonline.net/#code=XGQrCiQqCl4oLispXDEqIFwxKyQKJDEKMSsKJC4m&input=NCA4) As @MartinBüttner points out, this falls apart for large numbers (as is generally the case for anything unary). At very a minimum, an input of INT\_MAX will require allocation of a 2GB string. [Answer] ## i386 (x86-32) machine code, 8 bytes (9B for unsigned) +1B if we need to handle `b = 0` on input. ## amd64 (x86-64) machine code, 9 bytes (10B for unsigned, or ~~14B~~ 13B for 64b integers signed or unsigned) ## ~~10~~ 9B for unsigned on amd64 that breaks with either input = 0 --- Inputs are 32bit non-zero *signed* integers in `eax` and `ecx`. Output in `eax`. ``` ## 32bit code, signed integers: eax, ecx 08048420 <gcd0>: 8048420: 99 cdq ; shorter than xor edx,edx 8048421: f7 f9 idiv ecx 8048423: 92 xchg edx,eax ; there's a one-byte encoding for xchg eax,r32. So this is shorter but slower than a mov 8048424: 91 xchg ecx,eax ; eax = divisor(from ecx), ecx = remainder(from edx), edx = quotient(from eax) which we discard ; loop entry point if we need to handle ecx = 0 8048425: 41 inc ecx ; saves 1B vs. test/jnz in 32bit mode 8048426: e2 f8 loop 8048420 <gcd0> 08048428 <gcd0_end>: ; 8B total ; result in eax: gcd(a,0) = a ``` This loop structure fails the test-case where `ecx = 0`. (`div` causes a `#DE` hardware execption on divide by zero. (On Linux, the kernel delivers a `SIGFPE` (floating point exception)). If the loop entry point was right before the `inc`, we'd avoid the problem. The x86-64 version can handle it for free, see below. **Mike Shlanta's answer was the starting point for this**. My loop does the same thing as his, but for signed integers because `cdq` is one byter shorter than `xor edx,edx`. And yes, it does work correctly with one or both inputs negative. Mike's version will run faster and take less space in the uop cache (`xchg` is 3 uops on Intel CPUs, and [`loop` is really slow on most CPUs](https://stackoverflow.com/questions/35742570/why-is-the-loop-instruction-slow-couldnt-intel-have-implemented-it-efficiently)), but this version wins at machine-code size. I didn't notice at first that the question required **unsigned** 32bit. Going back to `xor edx,edx` instead of `cdq` would cost one byte. `div` is the same size as `idiv`, and everything else can stay the same (`xchg` for data movement and `inc/loop` still work.) Interestingly, for 64bit operand-size (`rax` and `rcx`), signed and unsigned versions are the same size. The signed version needs a REX prefix for `cqo` (2B), but the unsigned version can still use 2B `xor edx,edx`. In 64bit code, `inc ecx` is 2B: the single-byte `inc r32` and `dec r32` opcodes were repurposed as REX prefixes. `inc/loop` doesn't save any code-size in 64bit mode, so you might as well `test/jnz`. Operating on 64bit integers adds another one byte per instruction in REX prefixes, except for `loop` or `jnz`. It's possible for the remainder to have all zeros in the low 32b (e.g. `gcd((2^32), (2^32 + 1))`), so we need to test the whole rcx and can't save a byte with `test ecx,ecx`. However, the slower `jrcxz` insn is only 2B, **and we can put it at the top of the loop to handle `ecx=0` on entry**: ``` ## 64bit code, unsigned 64 integers: rax, rcx 0000000000400630 <gcd_u64>: 400630: e3 0b jrcxz 40063d <gcd_u64_end> ; handles rcx=0 on input, and smaller than test rcx,rcx/jnz 400632: 31 d2 xor edx,edx ; same length as cqo 400634: 48 f7 f1 div rcx ; REX prefixes needed on three insns 400637: 48 92 xchg rdx,rax 400639: 48 91 xchg rcx,rax 40063b: eb f3 jmp 400630 <gcd_u64> 000000000040063d <gcd_u64_end>: ## 0xD = 13 bytes of code ## result in rax: gcd(a,0) = a ``` --- Full runnable test program including a `main` that runs `printf("...", gcd(atoi(argv[1]), atoi(argv[2])) );` **[source and asm output on the Godbolt Compiler Explorer](http://gcc.godbolt.org/#compilers:!((compiler:g510,options:%27-xc+-Wall+-Wextra+-std%3Dgnu11+-fverbose-asm+-O3+-m32+-masm%3Dintel+-mtune%3Dintel%27,sourcez:PTAEEMBtNBLA7Azk0BXRBTAJhATh0DWAFwAsNdREEBzSDAWgHsAHC8eHJygDwGNSNADRUmoMrEQQ%2BxVFEgBPUAHduAaynKSpUADpwxYgH1EC%2BMXA9Q8VvgBmsHgCgQoAEKpioPkwC2LWHoVbVAGX3BEXwBeBGIMGAAjDD5wdAIyAiYMygA3CmomeFAACgQ%2BSFQsbFA7blB7Cgx4PgwAShUmVEgcBPxwNV0XMDDZeAwY83jQGib2OKlIQppQADkAeQAFKQREOPAuO1Bw%2BCVqeDpGBIU41c3EEVrKDNAEhHBcJU7iFk8nIdAAMJ%2BAL0KQcHCqXAabzcfAyRQ1OphADMACYSmjXl4fFVWiI6gA2AAsWJhVQAXKFfDw0aAkb5iYMnLsDLA%2BHBzNM%2B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miMxrnwH2TA/rGrPEQI7YavQOACCRZWcABBzQ2Hg%2BAFgtp32oYMQJB9z733cO8BwFONRJwtmaV4fhjslAbuw8NLQZBAO4sanYDAylKBXHmN8zDTBmMXvw6Cs9PZxTWkfS%2Bv8Q8r2obqgQTe3JxN4dnQClTKrWUifUxKEGGStrdM5UdfJoBpP7VwPy9or0XhWUTsnLw3o8hriSMmUsMcxD0DNnwOZ0HlDejiH2f1jtzCIEWmU%2BAT0jM2ZqejKQrrGkkFo0DUpaSOkQ2eotSVrChm1oxk4bGuMyi0wIIzYgfomCsw5tTcolRStMztgkKrYzit1YZhETAslmuCkcbyOjuALwiAEO8Fa7waA5HvU%2Bm6urxQdYoMQY6A2%2BBs1RNl8Ugp%2BGWQMEwWAi3xv3pKlNiMLltu7bGxN1EU2y0Sjzt7YojLijWiwCIJ77RLJPbpJQbOn2s6oHtDfCMIhRrHSENdIHs9lkcAsCDsHXIsAmBVTD9oAy8YExuaAYmpNyZEkpvqHOoSXINkAuLPbE3DsiBWE6M0ZoRCXkcpAHslkiedGgKT%2B9l2KdU5p6AOn13xS3eIHYe7wPrTQFQC9sXb2s5i9AFz/7cURAM/B1geexRQlCAZ8jpG4zOCTKlblool5RlAAAA%3D)),filterAsm:(binary:!t,commentOnly:!t,directives:!t,intel:!t,labels:!t),version:3)**, for the 32 and 64b versions. Tested and working for 32bit (`-m32`), 64bit (`-m64`), and the [x32 ABI (`-mx32`)](https://en.wikipedia.org/wiki/X32_ABI). Also included: a version using [repeated subtraction only](http://www.naturalnumbers.org/EuclidSubtract.html), which is 9B for unsigned, even for x86-64 mode, and can take one of its inputs in an arbitrary register. However, it can't handle either input being 0 on entry (it detect when `sub` produces a zero, which x - 0 never does). GNU C inline asm source for the 32bit version (compile with `gcc -m32 -masm=intel`) ``` int gcd(int a, int b) { asm (// ".intel_syntax noprefix\n" // "jmp .Lentry%=\n" // Uncomment to handle div-by-zero, by entering the loop in the middle. Better: `jecxz / jmp` loop structure like the 64b version ".p2align 4\n" // align to make size-counting easier "gcd0: cdq\n\t" // sign extend eax into edx:eax. One byte shorter than xor edx,edx " idiv ecx\n" " xchg eax, edx\n" // there's a one-byte encoding for xchg eax,r32. So this is shorter but slower than a mov " xchg eax, ecx\n" // eax = divisor(ecx), ecx = remainder(edx), edx = garbage that we will clear later ".Lentry%=:\n" " inc ecx\n" // saves 1B vs. test/jnz in 32bit mode, none in 64b mode " loop gcd0\n" "gcd0_end:\n" : /* outputs */ "+a" (a), "+c"(b) : /* inputs */ // given as read-write outputs : /* clobbers */ "edx" ); return a; } ``` Normally I'd write a whole function in asm, but GNU C inline asm seems to be the best way to include a snippet which can have in/outputs in whatever regs we choose. As you can see, GNU C inline asm syntax makes asm ugly and noisy. It's also a [really difficult way to *learn* asm](https://stackoverflow.com/questions/34520013/using-base-pointer-register-in-c-inline-asm/34522750#34522750). It would actually compile and work in `.att_syntax noprefix` mode, because all the insns used are either single/no operand or `xchg`. Not really a useful observation. [Answer] ## [Hexagony](https://github.com/mbuettner/hexagony), 17 bytes ``` ?'?>}!@<\=%)>{\.( ``` Unfolded: ``` ? ' ? > } ! @ < \ = % ) > { \ . ( . . ``` [Try it online!](http://hexagony.tryitonline.net/#code=Pyc_Pn0hQDxcPSUpPntcLig&input=MzAgNDI) Fitting it into side-length 3 was a breeze. Shaving off those two bytes at the end wasn't... I'm also not convinced it's optimal, but I'm sure I think it's close. ### Explanation Another Euclidean algorithm implementation. The program uses three memory edges, which I'll call **A**, **B** and **C**, with the memory pointer (MP) starting out as shown: [![enter image description here](https://i.stack.imgur.com/FqWtR.png)](https://i.stack.imgur.com/FqWtR.png) Here is the control flow diagram: [![enter image description here](https://i.stack.imgur.com/xI54F.png)](https://i.stack.imgur.com/xI54F.png) Control flow starts on the grey path with a short linear bit for input: ``` ? Read first integer into memory edge A. ' Move MP backwards onto edge B. ? Read second integer into B. ``` Note that the code now wraps around the edges to the `<` in the left corner. This `<` acts as a branch. If the current edge is zero (i.e. the Euclidean algorithm terminates), the IP is deflected to the left and takes the red path. Otherwise, an iteration of the Euclidean algorithm is computed on the green path. We'll first consider the green path. Note that `>` and `\` all acts as mirrors which simply deflect the instruction pointer. Also note that control flow wraps around the edges three times, once from the bottom to the top, once from the right corner to the bottom row and finally from the bottom right corner to the left corner to re-check the condition. Also note that `.` are no-ops. That leaves the following linear code for a single iteration: ``` { Move MP forward onto edge C. '} Move to A and back to C. Taken together this is a no-op. = Reverse the direction of the MP so that it now points at A and B. % Compute A % B and store it in C. )( Increment, decrement. Taken together this is a no-op, but it's necessary to ensure that IP wraps to the bottom row instead of the top row. ``` Now we're back where we started, except that the three edges have changed their roles cyclically (the original **C** now takes the role of **B** and the original **B** the role of **A**...). In effect, we've relpaced inputs `A` and `B` with `B` and `A % B`, respectively. Once `A % B` (on edge **C**) is zero, the GCD can be found on edge **B**. Again the `>` just deflects the IP, so on the red path we execute: ``` } Move MP to edge B. ! Print its value as an integer. @ Terminate the program. ``` [Answer] # T-SQL, 153 ~~169~~ bytes Someone mentioned worst language for golfing? ``` CREATE FUNCTION G(@ INT,@B INT)RETURNS TABLE RETURN WITH R AS(SELECT 1D,0R UNION ALL SELECT D+1,@%(D+1)+@B%(D+1)FROM R WHERE D<@ and D<@b)SELECT MAX(D)D FROM R WHERE 0=R ``` Creates a table valued function ~~that uses a recursive query to work out the common divisors. Then it returns the maximum~~. Now uses the euclidean algorithm to determine the GCD derived from my answer [here](https://codegolf.stackexchange.com/a/58831/31347). Example usage ``` SELECT * FROM (VALUES (15,45), (45,15), (99,7), (4,38) ) TestSet(A, B) CROSS APPLY (SELECT * FROM G(A,B))GCD A B D ----------- ----------- ----------- 15 45 15 45 15 15 99 7 1 4 38 2 (4 row(s) affected) ``` [Answer] ## 32-bit little-endian x86 machine code, 14 bytes Generated using `nasm -f bin` `d231 f3f7 d889 d389 db85 f475` ``` gcd0: xor edx,edx div ebx mov eax,ebx mov ebx,edx test ebx,ebx jnz gcd0 ``` [Answer] # Jelly, 7 bytes ``` ṛß%ðḷṛ? ``` Recursive implementation of the Euclidean algorithm. [Try it online!](http://jelly.tryitonline.net/#code=4bmbw58lw7DhuLfhuZs_&input=&args=MTI+MTU) If built-ins weren't forbidden, `g` (1 byte, built-in GCD) would achieve a better score. ### How it works ``` ṛß%ðḷṛ? Main link. Arguments: a, b ð Convert the chain to the left into a link; start a new, dyadic chain. ß Recursively call the main link... ṛ % with b and a % b as arguments. ṛ? If the right argument (b) is non-zero, execute the link. ḷ Else, yield the left argument (a). ``` [Answer] # Python 3, 31 Saved 3 bytes thanks to Sp3000. ``` g=lambda a,b:b and g(b,a%b)or a ``` [Answer] ## Haskell, 19 bytes ``` a#0=a a#b=b#rem a b ``` Usage example: `45 # 35`-> `5`. Euclid, again. PS: of course there's a built-in `gcd`, too. [Answer] # [MATL](https://esolangs.org/wiki/MATL), ~~11~~ 9 bytes No one seems to have used brute force up to now, so here it is. ``` ts:\a~f0) ``` Input is a column array with the two numbers (using `;` as separator). [**Try it online!**](https://tio.run/##y00syfn/v6TYKiaxLs1A8///aGMDaxOjWAA) or [**verify all test cases**](https://tio.run/##HYoxEoAgDAR7f2KXBJDRa32CHTAjjZVWUvv1GGhu5/buqe3WU9u75fpdNOt@aCJImdICsnQE3xsHsDdGxL6tkGAUBo/VBIvrhuw3FDGEpPw). ### Explanation ``` t % Take input [a;b] implicitly. Duplicate s % Sum. Gives a+b : % Array [1,2,...,a+b] \ % Modulo operation with broadcast. Gives a 2×(a+b) array a~ % 1×(a+b) array that contains true if the two modulo operations gave 0 f0) % Index of last true value. Implicitly display ``` [Answer] # Julia, ~~21~~ 15 bytes ``` a\b=a>0?b%a\a:b ``` Recursive implementation of the Euclidean algorithm. [Try it online!](http://julia.tryitonline.net/#code=YVxiPWE-MD9iJWFcYTpiCgpmb3IgKGEsYikgaW4gKCgwLDIpLCAoNiwwKSwgKDMwLDQyKSwgKDE1LDE0KSwgKDcsNyksICg2OSwyNSksICgyMSwxMiksICgxNjksMTIzKSwgKDIwLDE0MiksICgxMDEsIDIwMikpCiAgICBAcHJpbnRmKCIlM2QgJTNkID0-ICUzZFxuIixhLGIsYVxiKQplbmQ&input=) If built-ins weren't forbidden, `gcd` (3 bytes, built-in GCD) would achieve a better score. ### How it works ``` a\b= Redefine the binary operator \ as follows: a>0? : If a > 0: b%a\a Resursively apply \ to b%a and a. Return the result. b Else, return b. ``` [Answer] # C, 38 bytes ``` g(x,y){while(x^=y^=x^=y%=x);return y;} ``` [Answer] ## TI-Basic, 27 bytes ``` Prompt A,B:While B:B→T:BfPart(A/B→B:T→A:End:A ``` --- **35 byte** recursive solution without `gcd(` or `lcm(` built-ins (requires 2.53 MP operating system or higher, *must be named* `prgmG`): ``` If Ans(2:Then:{Ans(2),remainder(Ans(1),Ans(2:prgmG:Else:Disp Ans(1:End ``` You would pass arguments to the recursive variant as `{A,B}` so for example `{1071, 462}:prgmG` would yield `21`. # TI-Basic, 10 bytes ``` Prompt A,B:gcd(A,B ``` *Not allowed due to new rule forbidding gcd built-ins* --- **17 byte** solution without `gcd(` built-in ``` Prompt A,B:abs(AB)/lcm(A,B ``` *Not allowed due to new rule forbidding lcm built-ins* --- [Answer] # C, 28 bytes A rather straightforward function implementing Euclid's algorithm. Perhaps one can get shorter using an alternate algorithm. ``` g(a,b){return b?g(b,a%b):a;} ``` If one writes a little main wrapper ``` int main(int argc, char **argv) { printf("gcd(%d, %d) = %d\n", atoi(argv[1]), atoi(argv[2]), g(atoi(argv[1]), atoi(argv[2]))); } ``` then one can test a few values: ``` $ ./gcd 6 21 gcd(6, 21) = 3 $ ./gcd 21 6 gcd(21, 6) = 3 $ ./gcd 6 8 gcd(6, 8) = 2 $ ./gcd 1 1 gcd(1, 1) = 1 $ ./gcd 6 16 gcd(6, 16) = 2 $ ./gcd 27 244 gcd(27, 244) = 1 ``` [Answer] ## [Labyrinth](https://github.com/mbuettner/labyrinth/), 18 bytes ``` ?} : )"%{! ( = }:{ ``` Terminates with an error, but the error message goes to STDERR. [Try it online!](http://labyrinth.tryitonline.net/#code=P30KOgopIiV7IQooID0KfTp7&input=MzAgNDI) This doesn't feel quite optimal yet, but I'm not seeing a way to compress the loop below 3x3 at this point. ### Explanation This uses the Euclidean algorithm. First, there's a linear bit to read input and get into the main loop. The instruction pointer (IP) starts in the top left corner, going east. ``` ? Read first integer from STDIN and push onto main stack. } Move the integer over to the auxiliary stack. The IP now hits a dead end so it turns around. ? Read the second integer. The IP hits a corner and follows the bend, so it goes south. : Duplicate the second integer. ) Increment. The IP is now at a junction. The top of the stack is guaranteed to be positive, so the IP turns left, to go east. " No-op. % Modulo. Since `n % (n+1) == n`, we end up with the second input on the stack. ``` We now enter a sort of while-do loop which computes the Euclidean algorithm. The tops of the stacks contain `a` and `b` (on top of an implicit infinite amount of zeros, but we won't need those). We'll represent the stacks side to side, growing towards each other: ``` Main Auxiliary [ ... 0 a | b 0 ... ] ``` The loop terminates once `a` is zero. A loop iteration works as follows: ``` = Swap a and b. [ ... 0 b | a 0 ... ] { Pull a from aux. [ ... 0 b a | 0 ... ] : Duplicate. [ ... 0 b a a | 0 ... ] } Move a to aux. [ ... 0 b a | a 0 ... ] () Increment, decrement, together a no-op. % Modulo. [ ... 0 (b%a) | a 0 ... ] ``` You can see, we've replaced `a` and `b` with `b%a` and `a` respectively. Finally, once `b%a` is zero, the IP keeps moving east and executes: ``` { Pull the non-zero value, i.e. the GCD, over from aux. ! Print it. The IP hits a dead end and turns around. { Pull a zero from aux. % Attempt modulo. This fails due to division by 0 and the program terminates. ``` [Answer] # [Cubix](https://github.com/ETHproductions/cubix), 10 ~~12~~ bytes ``` ?v%uII/;O@ ``` [Try it here](https://ethproductions.github.io/cubix) This wraps onto the cube as follows: ``` ? v % u I I / ; O @ . . . . . . . . . . . . . . ``` Uses the Euclidean Method. `II` Two numbers are grabbed from STDIN and put on the stack `/` Flow reflected up `%` Mod the Top of Stack. Remainder left on top of stack `?` If TOS 0 then carry on, otherwise turn right `v` If not 0 then redirect down and `u` turn right twice back onto the mod `/` If 0 go around the cube to the reflector `;` drop TOS, `O` output TOS and `@` end [Answer] ## C#, 24 bytes ``` x=(a,b)=>b<1?a:x(b,a%b); ``` [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 5 bytes ``` ḋˢ⊇ᵛ× ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3w/@GO7tOLHnW1P9w6@/D0//@jFaINdIxidaLNdAyApLGBjgmIZ2iqY2gCpM11zEFyljpGpkDayFDHECwLFDA0MgaJGADVgYUMDHWMDIxiFWIB "Brachylog – Try It Online") Takes input as a list through the input variable and outputs an integer through the output variable. If you use it as a generator, it actually generates all common divisors, it just does so largest first. ``` The output is × the product of the elements of ⊇ the maximal sublist ᵛ which is shared by ḋ the prime factorization ˢ s of the elements of the input which have them. ``` [Answer] # Windows Batch, 76 bytes Recursive function. Call it like `GCD a b` with file name `gcd`. ``` :g if %2 equ 0 (set f=%1 goto d) set/a r=%1 %% %2 call :g %2 %r% :d echo %f% ``` [Answer] # MATL, 7 bytes ``` pG1$Zm/ ``` [**Try it Online!**](http://matl.tryitonline.net/#code=cEcxJFptLw&input=WzE1LDNd) **Explanation** Since we can't explicitly use the builtin GCD function (`Zd` in MATL), I have exploited the fact that the least common multiple of `a` and `b` times the greatest common denominator of `a` and `b` is equal to the product of `a` and `b`. ``` p % Grab the input implicitly and multiply the two elements G % Grab the input again, explicitly this time 1$Zm % Compute the least-common multiple / % Divide the two to get the greatest common denominator ``` [Answer] ## ARM machine code, 12 bytes: assembly: ``` gcd: cmp r0, r1 sublt r0, r0, r1 bne gcd ``` Currently can't compile this, but each instruction in ARM takes 4 bytes. Probably it could be golfed down using THUMB-2 mode. [Answer] # Racket (Scheme), 44 bytes Euclid implementation in Racket (Scheme) ``` (define(g a b)(if(= 0 b)a(g b(modulo a b)))) ``` Edit: Didn't see @Numeri 's solution lol. Somehow we got the exact same code independently [Answer] # [><>](https://esolangs.org/wiki/Fish), 32 bytes ``` ::{::}@(?\=?v{:}- .!09}}${{/;n/> ``` Accepts two values from the stack and apply the euclidian algorithm to produce their GCD. You can try it [here](https://fishlanguage.com/playground)! For a much better answer in ><>, check out [Sok's](https://codegolf.stackexchange.com/a/81126/41881) ! [Answer] # R, ~~39~~ 33 bytes Surprised not to see an R answer on here yet. A recursive implementation of the Euclidean algorithm. Saved 2 bytes due to Giuseppe. ``` g=pryr::f(`if`(o<-x%%y,g(y,o),y)) ``` And here is a vectorized version (**35 bytes**) which works well for problems like [Natural pi calculation](https://codegolf.stackexchange.com/a/95256/59052). ``` g=pryr::f(ifelse(o<-x%%y,g(y,o),y)) ``` [Answer] # [ReRegex](https://github.com/TehFlaminTaco/ReRegex), 23 bytes Works identically to the Retina answer. ``` ^(_*)\1* \1*$/$1/#input ``` [Try it online!](https://tio.run/##K0otSk1Prfj/P04jXkszxlBLAYhV9FUM9ZUz8wpKS/7/j4cChXgkAAA "ReRegex – Try It Online") [Answer] # [Proton](https://github.com/alexander-liao/proton), 21 bytes ``` f=(a,b)=>b?f(b,a%b):a ``` [Try it online!](https://tio.run/##RY7BCsMgEETvfsVeCm7Zg5qkIQHbDyk9KFTwEoPxVvrt1jRo9jTDmxl2jSGFJWenuSGL@m4fjlsyF4uzyem9pQ00PBmU44JAIR36RiCq7groG5EDgeyrGwnG1pnKwFCdkiV3tnYoVdeo2FdOLEpaCYXsxZgLETzMcLz3@SfW6JfEHb96RPbNPw "Proton – Try It Online") Shush you, this is totally not a port of the Python answer. [Answer] # [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 26 bytes ``` D,g,@@#~,%A$p%+ L,MRBCþgbM ``` [Try it online!](https://tio.run/##S0xJKSj4/99FJ13HwUG5TkfVUaVAVZvLR8c3yMn58L70JN//KjmJuUkpiQqGdvZ29lz@//8bG/w3MQIA "Add++ –Try It Online") Generates the range \$1, 2, 3, ..., \max(a, b)\$, then filters out elements that don't divide either \$a\$ or \$b\$, Finally, we return the maximum value of the filtered elements. [Answer] ## [ARMv7](https://www.arm.com/) ([OakSim](https://github.com/Wunkolo/OakSim)), 28 bytes Hexdump: ``` 0x00010000: 01 00 80 E0 00 10 81 E0 01 00 50 E1 01 00 40 C0 ..........P...@. 0x00010010: 00 10 41 B0 FB FF FF 1A 1E FF 2F E1 00 00 00 00 ..A......./..... ``` ## Explanation Callable function, expects the arguments in `r0` and `r1`, output is in `r0`. Expects address of caller stored in `lr`. This is the standard method of procedure calling as per the ATPCS (ARM Thumb Procedure Call Standard). ``` gcd: add r0, r0, r1 /* Make sure r0 is nonzero */ add r1, r1, r0 /* Make sure r1 is nonzero */ /* We're basically doing the inverse afterwards */ loop: /* main loop: */ cmp r0, r1 /* Compare r0 and r1 */ subgt r0, r0, r1 /* If r0 > r1: r0 = r0 - r1 */ sublt r1, r1, r0 /* If r0 < r1: r1 = r1 - r0 */ bne loop /* If r0 != r1: jump back to main loop */ bx lr /* return to caller */ ``` ### Example call ``` b caller /* jump to the caller */ gcd: /* omitted to save space */ caller: mov r0, 30 /* first operand = 30 */ mov r1, 42 /* second operand = 42 */ mov lr, pc /* link register = program counter */ b gcd /* branch to function */ ``` [Answer] # [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), ~~37~~ 34 bytes ``` : f dup if tuck mod recurse then ; ``` [Try it online!](https://tio.run/##TY5BDoIwEEX3c4of95JOQYgaPYkbAkWISMlQ9Pg4khTtpnnzX@e38RLa/b35XstyQoN6HtE1CHP1wNPXEFfNMjmE1g04qxLcFAjwLydIVj3BDaN0Q0B4e5Ryn9AN8FI7UTHZ4XLFDuuJYini3xpqX4JKYliVfa@zcqjjwtbpD6a5D3QmMrBrvZqWcpgIOaUGmf0hH8BZRKYCRYSC8iPs4ZdZBm8vU2KN2aZ/udFVf7VsGNZsA8XlAw "Forth (gforth) – Try It Online") Same as the code below, but using recursion instead. Turns out that the combination `if then recurse` is shorter than `begin while repeat` by 3 chars, even though the word `recurse` looks quite bulky. --- ### Previous solution, 37 bytes ``` : f begin dup while tuck mod repeat ; ``` [Try it online!](https://tio.run/##TY3NboNADITvfopR7kXrJQG1UfskuWzZ5UelLDJLeHzqIm0SX6zxfJ5po6T@rWv/175/oMV36IYJfp2x9cMYkNbmB7/RQ8IcXMJVqRSWREC8B0FxsAVumGWYEtIW4aRboClRfBAFixM@v3DCMRl0InFTs4Uv0Eg2GzeOenOTz4F90O5lHRNdiQzsUa@kpQomi4pKg7N9Sr6Az1ky1aizqKl6h708Pcvgx2dJrDbb8sU3GvVSy4ZhzeOgcv8D "Forth (gforth) – Try It Online") Input is two single-cell integers, output is one double-cell integer. ### How it works A "cell" means a space for one item on the stack. A double-cell integer in Forth takes two cells, where the most significant cell is on the top. For this challenge, the GCD of two single-cell integers always fits in a cell, so the upper cell is always 0. ``` : f ( a b -- d ) \ Define a function f which takes two singles and gives a double begin \ Start a loop dup while \ While b is not zero... tuck \ Copy b under a ( stack: b a b ) and mod \ Calculate a%b ( stack: b a%b ) \ That is, change ( a b ) to ( b a%b ) repeat ; \ End loop \ The result is ( gcd 0 ) which is gcd in double-cell ``` [Answer] # GML, 57 bytes ``` a=argument0 b=argument1 while b{t=b;b=a mod b;a=t}return a ``` [Answer] # Delphi 7, 148 Well, I think I've found the new worst language for golfing. ``` unit a;interface function g(a,b:integer):integer;implementation function g(a,b:integer):integer;begin if b=0then g:=a else g:=g(b,a mod b);end;end. ``` ]
[Question] [ Your challenge is to draw/plot one of the hearts below. The size must be at least 50x50 pixels (vector graphics is OK). You may choose which of the hearts you want to draw/plot. Axes, grid lines etc. are accepted. There must be **at least** 100 distinct coordinates/points on the graph. The heart can be filled with color if you want to. [![enter image description here](https://i.stack.imgur.com/Vnin0.jpg)](https://i.stack.imgur.com/Vnin0.jpg) The equations are either: [![enter image description here](https://i.stack.imgur.com/Kgehc.gif)](https://i.stack.imgur.com/Kgehc.gif) **or** [![enter image description here](https://i.stack.imgur.com/DCI6L.gif)](https://i.stack.imgur.com/DCI6L.gif) [![enter image description here](https://latex.codecogs.com/gif.latex?y=%7Bcos(t)%7D%5E%7B0.5%7D%5Ccdot|t|%5E%7B0.3%7D)](https://latex.codecogs.com/gif.latex?y=%7Bcos(t)%7D%5E%7B0.5%7D%5Ccdot|t|%5E%7B0.3%7D) `t` is in the range `[-1, 1]`. **or** [![enter image description here](https://i.stack.imgur.com/fFH5v.gif)](https://i.stack.imgur.com/fFH5v.gif) **or** [![enter image description here](https://latex.codecogs.com/gif.latex?r=%5Cfrac%7Bsin(t)%5Csqrt%7B|cos(t)|%7D%7D%7Bsin(t)+%5Cfrac%7B7%7D%7B5%7D%7D-2sin(t)+2)](https://latex.codecogs.com/gif.latex?r=%5Cfrac%7Bsin(t)%5Csqrt%7B|cos(t)|%7D%7D%7Bsin(t)+%5Cfrac%7B7%7D%7B5%7D%7D-2sin(t)+2) This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the shortest code (in each language) in bytes wins. Please provide the output (or link to an online interpreter). [Answer] # TI-80 BASIC, ~~45~~ ~~43~~ ~~41~~ 39 bytes ``` LBL 1 RAND4-2->X RAND4-2 IF (X²+ANS²-1)³<X²ANS³ PT-ON(X,ANS GOTO 1 ``` [![enter image description here](https://i.stack.imgur.com/Zyfmp.jpg)](https://i.stack.imgur.com/Zyfmp.jpg) This took a while, and my battery is low so I didn't want to keep going. I tried to use the second equation, but ~~couldn't get it to work~~ it actually turned out to be longer, so I just adapted the other answer I had. EDIT: I just noticed the 50x50 pixel requirement, unfortunately the screen is only 47 pixels high so this isn't possible. [Answer] ## Perl, 86 bytes ``` $y=1-$_/25,say+map$y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0?$|--?v60:3:$",-40..40for-6..50 ``` Run with `perl -E`. Plots a filled ASCII heart, using the first equation. Note that the x-axis is stretched by a factor of ~1.265: this is to counteract the fact that terminal fonts are usually much bigger vertically than horizontally. Output: ``` 3<3<3<3<3<3<3< 3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3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3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3<3<3<3<3 <3<3<3<3<3<3<3<3<3< 3<3<3<3<3<3<3<3 <3<3<3<3<3< 3<3<3<3 <3<3< 3 ``` Explanation (since OP asked for it): ``` condition := $y**3*($_*=$_/1e3)-($_+$y**2-1)**3>0 ``` This is simply the first equation, slightly rearranged to make it shorter. $y directly represents the y in the formula. $\_ is initially proportional to x, but is multiply-assigned with itself (`$_*=$_/1e3`), making it proportional to x². Since x² is used twice in the formula, this saves a few bytes. `1e3` means 1000, and was picked because it’s short and the result looks good. `**` is Perl’s power operator. I use `>0` rather than `==0` because I want a filled heart. ``` flip_flop := $|--?v60:3 ``` v60 is an abuse of the archaic version-string syntax to denote the character with ASCII code 60: '<'. $| is a magical variable that can only ever be 0 or 1. Decrementing when it’s already 0 sets it to 1. Decrementing when it’s 1 naturally sets it to 0. Thus, $|-- is often used as a flip-flop: each time it’s evaluated, it alternates between true and false. As a whole, this expression returns alternatively '<' and 3. ``` inner_loop := <condition> ? <flip_flop> :$" ``` Nested ternaries. If condition is false (→ we’re outside the heart), evaluates to $", which is a magical variable that defaults to " " (a single space). If condition is true (→ we’re inside the heart), it evaluates flip\_flop. ``` outer_loop := say+map <inner_loop> ,-40..40 ``` Evaluates inner\_loop repeatedly, with $\_ (Perl’s “default” variable) going from -40 to 40, in increments of 1. It collects the results of those evaluation in a temporary list, then prints them all, concatenated, ending with a new line. ``` $y=1-$_/25, <outer_loop> for-6..50 ``` This runs outer\_loop repeatedly, with $y going from 1.24 (1 - (-6 / 25)) to -1 (1 - 50 / 25), in decrements of 0.04. Note that y is divided by 25, while x² is divided by 1000, which is the same as dividing x by sqrt(1000). The ~1.265 factor I mentioned is sqrt(1000) / 25. [Answer] # Mathematica WolframAlpha, 17 15 13 11 bytes Shaved off 2 bytes thanks to Martin Ender (1st heart curve -> heart curve 1) Shaved off another 2 bytes thanks to Martin Ender (heart curve 1 -> heartcurve1) This is probably cheating (the obvious solution), but here goes. ``` heartcurve1 ``` [Try it here!](https://www.wolframalpha.com/input/?i=heartcurve1) I'm sure there's a way to shorten 1st, heart or curve such that Wolfram still accepts it. Well it's free of spaces now, maybe some sort of abbreviation for heart? Do I get bonus points for plotting 2 of them? ``` heartcurves ``` [Try that here!](https://www.wolframalpha.com/input/?i=heartcurves) [Answer] ## Mathematica, 52 bytes ``` RegionPlot[(x^2+y^2-1)^3-x^2y^3<0,{x,-2,2},{y,-2,2}] ``` [![enter image description here](https://i.stack.imgur.com/wpOOf.png)](https://i.stack.imgur.com/wpOOf.png) We could save one more byte with `ContourPlot` but then the background gets a bit trippy: ``` ContourPlot[(x^2+y^2-1)^3-x^2y^3,{x,-2,2},{y,-2,2}] ``` [![enter image description here](https://i.stack.imgur.com/1rKZp.png)](https://i.stack.imgur.com/1rKZp.png) For one *additional* byte we could use the fourth formula and `PolarPlot` instead: ``` PolarPlot[(x=Sin@t)Abs@Cos@t^.5/(x+7/5)-2x+2,{t,0,7}] ``` [![enter image description here](https://i.stack.imgur.com/Xm75X.png)](https://i.stack.imgur.com/Xm75X.png) [Answer] # Casio fx-7700GH, 21 bytes ``` sin θ √ Abs cos θ ÷ ( sin θ + 7 ÷ 5 ) - 2 sin θ + 2 ``` Unnamed graph function to be entered into one of the polar coordinate graphing function slots, then does what it says on the tin. The graphing range must be manually set (unless it happens to fit to the current set range), I set it to `Xmin=-2.75, Xmax=2.75, Ymin=-4, Ymax=1`. Should work on other Casio Power Graphic Series calculators too, and quite possibly later Casio graphic calculators. [![A heart drawn by a Casio fx-7700GH calculator](https://i.stack.imgur.com/DRSPt.jpg)](https://i.stack.imgur.com/DRSPt.jpg) (yep ~~I'm~~ pretty old and dusty) [Answer] # MATLAB / Octave, 31 bytes ``` ezplot('(x^2+y^2-1)^3-x^2*y^3') ``` [![enter image description here](https://i.stack.imgur.com/gDK58.png)](https://i.stack.imgur.com/gDK58.png) [Answer] ## [Desmos](https://www.desmos.com/calculator), 20 16 15 bytes V 2: ``` xx).3y=xx+yy-1 ``` ( = `xx)^.3y=xx+yy-1`) V 1: ``` xx+yy-1)3=xxy3 ``` V 0: ``` (x2+y2-1)3=x2y3 ``` [Answer] # SmileBASIC, ~~85~~ 81 bytes ``` X=RNDF()*4-2Y=RNDF()*4-2GPSET X*50+99,Y*50+99,-(-X*X*Y*Y*Y>POW(X*X+Y*Y-1,3))EXEC. ``` [![enter image description here](https://i.stack.imgur.com/dgCEK.jpg)](https://i.stack.imgur.com/dgCEK.jpg) [Answer] # MATL, 36 bytes ``` 1e4t:w/EqXJX,JY,J|Yl**JX,X^J|.3^*&XG ``` Try it at [MATL Online](https://matl.io/?code=1e4t%3Aw%2FEqXJX%2CJY%2CJ%7CYl%2a%2aJX%2CX%5EJ%7C.3%5E%2a%26XG&inputs=&version=19.7.4) [![enter image description here](https://i.stack.imgur.com/gQJha.png)](https://i.stack.imgur.com/gQJha.png) [Answer] # Python, ~~119~~ 116 bytes ``` from turtle import* from math import* t=1 while-t<1:a=abs(t);c=cos(t);goto(sin(t)*c*log(a)*99,c**.5*a**.3*99);t-=.01 ``` [**Try it online**](https://trinket.io/python/cdbc87c4f3) ![x=sin(t)*cos(t)*log(abs(t))](https://i.stack.imgur.com/DCI6L.gif) ![y=cos(t)**.5*abs(t)**.3](https://latex.codecogs.com/gif.latex?y=%7Bcos(t)%7D%5E%7B0.5%7D%5Ccdot|t|%5E%7B0.3%7D) [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 31 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` *3× ²+’*3<çị⁾* 25µNr÷21µ²ç@þUY ``` **[Try it online!](https://tio.run/nexus/jelly#ATEAzv//KjPDlwrCsivigJkqMzzDp@G7i@KBviogCjI1wrVOcsO3MjHCtcKyw6dAw75VWf//)** or **[35 bytes](https://tio.run/nexus/jelly#ATcAyP//KjPDlwrCsivigJkqMzzDp8OXOTgyOeG7jMK74oG2CjI1wrVOcsO3MjHCtcKyw6dAw75VWf//)** with a `♥`, rather than `*` fill: change middle line to `²+’*3<ç×9829Ọ»⁶`. ``` ♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥♥♥ ♥♥♥♥♥♥♥ ♥♥♥ ♥ ``` ### How? Implements: [![equation](https://i.stack.imgur.com/Kgehc.gif)](https://i.stack.imgur.com/Kgehc.gif) over a 51 by 51 line feed separated grid of characters. ``` *3× - Link 1: y, xSquared *3 - cube y × - multiply the result by xSquared ²+’*3<çị⁾* - Link 2: y, xSquared ² - square y + - add xSquared to the result ’ - subtract one *3 - cube the result < - less than? (1 if True, 0 if False) ç - the result of the last link (1) as a dyad: f(y, xSquared) ị - index into (1-based): ⁾* - the string "* " (there is a trailing space on this line) ×9829Ọ»⁶ - alternative ending of link 2 ×9829 - multiply (vectorises) by 9829 Ọ - cast to character (vectorises) (9829 is the ♥, 0 is the null-byte) » - maximum (vectorises) of that and: ⁶ - space character (ordinal of space is 32, greater than the null-byte, less than ♥) 25µNr÷21µ²ç@þUY - Main link: no arguments 25 - 25 µ - monadic chain separation call that i N - negate i r - inclusive range(negated i, i) -> [-25, -24, ..., 24, 25] ÷21 - divide by 21 (vectorises) -> [-1.1904761904761905, -1.1428571428571428, ..., 1.1428571428571428, 1.1904761904761905] µ - monadic chain separation call that r ² - square r (vectorises) (make the xSquared values, left to right) U - upend r (make the y values, top to bottom) þ - outer product using: ç@ - last link (2) as a dyad with reversed arguments: f(y, xSquared) Y - join with line feeds - implicit print ``` [Answer] ## SageMath, 66 bytes ``` polar_plot(sin(x)*abs(cos(x))^.5/(sin(x)+7/5)-2*sin(x)+2,(0,2*pi)) ``` [Try it online](http://sagecell.sagemath.org/?z=eJwryM9JLIovyMkv0SjOzNOo0NRKTCrWSM4vBjI14_RM9aHC2ub6ppq6RlpQnpGOhoGOkVZBpqYmANUwE4E=&lang=sage) Unfortunately, the long names of `implicit_plot` and `parametric_plot` (plus the need to define a variable other than the implicitly-defined `x` for the former) make the first three options much too long to be considered. Thanks to busukxuan and Andrea Lazzarotto for a byte [Answer] # C, ~~137~~ 133 bytes ``` p;float x,y,f;v(){for(p=4e3;p;x=(float)(p%99-50)/35,y=(float)(p/40-45)/40,f=x*x+y*y-1)putchar(p--%99?f*f*f-x*x*y*y*y<1e-3?35:32:10);} ``` <http://codepad.org/zqqYUui8> Thanks @AlbertRenshaw, I also changed the 100s to 99s for 2 more bytes [Answer] ## Ruby, 80 bytes Show Ruby some love. ``` -2.step(2,0.2){|y|-2.step(2,0.1){|x|$><<'. O'[(y*y-1+x*=x)**3+x*y**3<=>0]};puts} ``` ### Output: ``` OOOOO OOOOO .OOOOOOOOO.OOOOOOOOO. OOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOOOO .OOOOOOOOOOOOOOOOOOO. OOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOO OOOOOOOOOOO OOOOO . ``` with some empty lines above and below [Answer] ## JavaScript (ES6), ~~151~~ 147 bytes ``` document.write`<canvas id=c>`;for(i=0;x=2-i/24,i<97;i++)for(j=0;y=2-j/24,z=x*x+y*y-1,j<97;j++)z*z*z-x*x*y*y*y<0&&c.getContext`2d`.fillRect(i,j,1,1) ``` Edit: Saved 4 bytes thanks to @user2428118. ES7 version for 143 bytes: ``` document.write`<canvas id=c>`;for(i=0;i<97;i++)for(x=2-i/24,j=0;j<97;j++)x*x*(y=2-j/24)**3-(x*x+y*y-1)**3>0&&c.getContext`2d`.fillRect(i,j,1,1) ``` [Answer] # BBC BASIC, 80 Will finish golfing tomorrow. Download interpreter at <http://www.bbcbasic.co.uk/bbcwin/bbcwin.html> ``` ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N. ``` Draws a filled heart using the first equation, which we rearrange and take the cube root of (there are 3 cube roots of a real number, one real and 2 complex but we only interested in the real root here.) We then rearrange again to get a quadratic in `y` ``` x^2+y^2-1=(x^0.66)y y^2-(x^0.66)y+x^2-1=0 ``` Using the standard quadratic formula for expressions of the type `ay^2+by+c=0`, and taking advantage of the fact that `a`=1 we get ``` y = -b/2 +/- sqrt((b/2)^2-c) y = -b/2 +/- sqrt((b/2)^2-x^2+1) ``` where `-b/2 = (x^0.66)/2` (represented by `b` in the program.) We simply scan through the values of `x` from left to right, drawing a vertical line between each pair of valid values for `y` to build up a solid shape. ``` ORIGIN99,99F.u=-56TO56x=u/50b=x^2^.33/2r=(b^2-x^2+1)^.5*50L.u,b*50-r,u,r+b*50N. ``` **ungolfed** ``` ORIGIN99,99 FORu=-56TO56 x=u/50 b=x^2^.33/2 r=(b^2-x^2+1)^.5*50 LINEu,b*50+r,u,b*50-r NEXT ``` [Answer] ## Processing.js: ~~123~~ 119 bytes ungolfed: ``` t = 0; void setup() { size(99, 300); } void draw() { point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3)); t+=0.01; } ``` --- golfed: ``` t=0;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(t),350-400*sqrt(cos(t))*pow(t,0.3));t+=0.01;} ``` this one is quite cheaty as it plots #2 from 0 to infinity instead of from -1 to 1 as shown in the picture to save on the two abs(t). But it's technically correct as there are more than 100 points. --- 130 bytes "correctier" one ``` t=-1;void setup(){size(99,300);}void draw(){point(59+99*sin(t)*cos(t)*log(abs(t)),350-400*sqrt(cos(t))*pow(abs(t),0.3));t+=0.01;} ``` --- [try it online](http://sketchpad.cc/sp/pad/view/aPbRMgtCTz/latest) note : there's probably a way to get 100 points on the default 100x100 canvas and shave the setup off. [Answer] # TI-84 Basic, ~~40~~ 38 bytes Similar to @12Me21's answer & output, but for the TI-83/84 series instead. ``` While 1:2rand-1→A:2rand-1:If (A²+Ans²-1)³>A²Ans³:Pt-On(A,Ans:End ``` [Answer] # BBC BASIC (BBC Micro) (126 bytes) This is a variation of [Level River Street's](https://codegolf.stackexchange.com/users/15599/level-river-st) [answer](https://codegolf.stackexchange.com/a/110000), but for the original BBC Micro's iteration of BBC BASIC. You can copy and paste either of the following into JSBeeb's new paste functionality at <https://bbc.godbolt.org/> (A JavaScript powered BBC Micro emulator), once it has pasted, press Enter inside the 'screen' to show a new prompt, then type RUN, then press Enter to run either version. golfed. (126 bytes) ``` 1MO.1:V.29,64;64;:MOVE-57,20:GC.0,1:F.U=-56TO56:X=U/50:IFX<>0TH.B=X^2^.33/2 2R=(B^2-X^2+1)^.5*50:DRAWU,B*50+R:DRAW U,B*50-R:N. ``` ungolfed. (176 bytes) ``` 1 MODE 1 2 VDU 29,64;64; 3 MOVE -57,20 4 GCOL 0,1 5 FOR U = -56 TO 56 6 X = U/50 7 IF X <> 0 THEN B = X^2^.33/2 8 R = (B^2-X^2+1)^.5*50 9 DRAW U,B*50+R 10 DRAW U,B*50-R 11 NEXT ``` Line 7 requires a check for X, to prevent a "Log range" error when X becomes 0 half way through the loop. Other than this, it's pretty much the same. It's a lot slower to draw on a real machine, which JSBeeb emulates pretty well. [Answer] # Google Sheets (Conditional Formatting), 73 Set conditional formatting on range A1:CV100: ``` =(2500/9-(Column()-25)^2-(ROW()-25)^2)^3>(Column()-25)^2*(ROW()-25)^3/.06 ``` You'll have to adjust your columns/rows so that 100x100 cells fit on your screen. (10 pixels is a good value.) Colors the cells in the cardioid. ]
[Question] [ *Disclaimer:* This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and stop. We do this for each letter in a string and there's a pretty pattern at the end of it. # The task * Start with a string of characters + The input string may only contain the lower-case letters a-z and the space character. * For each letter, produce a line of text (terminal output or variable or whatever) + Print out the letter + Print out the previous letter (on the same line) + Print out the previous letter (on the same line) + Print out the previous letter (on the same line) + ... + If the letter is 'a', print it out and move to the next line. + If it's a space, print out an empty line (or one just containing the space character. # The rules * It's golf, try and make your code short. * Any language you like. * Please include a link to an online interpreter. * The output should be human-readable (e.g. I can't work it out from a list of bytes. * Follow the rules of the standard loopholes `¯\_(ツ)_/¯` * Recursion is not mandated by the rules, but it's probably necessary. # Test Cases Input: 'abcdefghijklmnopqrstuvwxyz' Output: ``` a ba cba dcba edcba fedcba gfedcba hgfedcba ihgfedcba jihgfedcba kjihgfedcba lkjihgfedcba mlkjihgfedcba nmlkjihgfedcba onmlkjihgfedcba ponmlkjihgfedcba qponmlkjihgfedcba rqponmlkjihgfedcba srqponmlkjihgfedcba tsrqponmlkjihgfedcba utsrqponmlkjihgfedcba vutsrqponmlkjihgfedcba wvutsrqponmlkjihgfedcba xwvutsrqponmlkjihgfedcba yxwvutsrqponmlkjihgfedcba zyxwvutsrqponmlkjihgfedcba ``` Input: 'zyxwvutsrqponmlkjihgfedcba' ``` zyxwvutsrqponmlkjihgfedcba yxwvutsrqponmlkjihgfedcba xwvutsrqponmlkjihgfedcba wvutsrqponmlkjihgfedcba vutsrqponmlkjihgfedcba utsrqponmlkjihgfedcba tsrqponmlkjihgfedcba srqponmlkjihgfedcba rqponmlkjihgfedcba qponmlkjihgfedcba ponmlkjihgfedcba onmlkjihgfedcba nmlkjihgfedcba mlkjihgfedcba lkjihgfedcba kjihgfedcba jihgfedcba ihgfedcba hgfedcba gfedcba fedcba edcba dcba cba ba a ``` Input: 'hello world' Output: ``` hgfedcba edcba lkjihgfedcba lkjihgfedcba onmlkjihgfedcba wvutsrqponmlkjihgfedcba onmlkjihgfedcba rqponmlkjihgfedcba lkjihgfedcba dcba ``` [Answer] # [Dyalog APL Extended](https://github.com/abrudz/dyalog-apl-extended), 4 bytes ``` ⌽∘⍳¨ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/P@1R24RHPXsfdcx41Lv50AqggIJ6RmpOTr5CeX5RToo6AA "APL (Dyalog Extended) – Try It Online") ``` ∘ the function composition of ⍳ iota - 'a'..input for alphabet chars, empty array for space ⌽ and after, reverse ¨ applied to each ``` [Answer] # [Haskell](https://www.haskell.org/), ~~26~~ 24 bytes *-2 bytes thanks to [FrownyFrog](https://codegolf.stackexchange.com/users/74681).* ``` map(\i->reverse['a'..i]) ``` [Try it online!](https://tio.run/##Fc3LEYMgFADAVt5wUWeiHZgOUoF6QP6CgIDf4kPIeQ8rcdTMmMz7Ma/Y16Nq34EdLEQ2VLjqOjU1BZSFHop/oPZB2QQd8AYGhGdCGRdSLdqs1vktxLQf53U/6AXoua9jTzFs3tnV6EVJwRklM/6jLK2D0wVD0ZS/hBssYm6J9z8 "Haskell – Try It Online") Pointless (or pointfree :P) for you. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~58~~ 56 bytes *Saved 2 bytes thanks to @KritixiLithos* ``` c;f(char*s){while(c=c&&putchar(c>96?c:10)^10?c-1:*s++);} ``` [Try it online!](https://tio.run/##FchBCoMwEAXQvacILmRGCZhNoYbWmwjha0wgbYppm4V4dVP6lg9yBUqBtgRntjbxnp0PC@GGpnl93v8l3K@XEYPqeVL9CKmGNnUd66N8o5/Fw/gnsdgrISzVbgkhihy3MNesq6OcsMGsqcj8Aw "C (gcc) – Try It Online") [Answer] # [Malbolge20](https://esolangs.org/wiki/Malbolge20) and [Malbolge Unshackled](https://esolangs.org/wiki/Malbolge_Unshackled) polyglot, around 2MB, 107KB compressed. Alright. I spent around 30 minutes on this answer (current record). It's really optimal answer. Albeit not so fast and not so memory-exhausting (only ~512 megabytes), it's still a Malbolge answer so please keep that noted. The program is packed using 7zip and PPMd compression algorithm. You can download it [here](https://github.com/KrzysztofSzewczyk/codegolf-submissions/raw/master/196192.7z). ## Interpreter that works the best with the program. ``` #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> const char* translation = "5z]&gqtyfr$(we4{WP)H-Zn,[%\\3dL+Q;>U!pJS72Fh" "OA1CB6v^=I_0/8|jsb9m<.TVac`uY*MK'X~xDl}REokN:#?G\"i@"; typedef struct Word { unsigned int area; unsigned int high; unsigned int low; } Word; void word2string(Word w, char* s, int min_length) { if (!s) return; if (min_length < 1) min_length = 1; if (min_length > 20) min_length = 20; s[0] = (w.area%3) + '0'; s[1] = 't'; char tmp[20]; int i; for (i=0;i<10;i++) { tmp[19-i] = (w.low % 3) + '0'; w.low /= 3; } for (i=0;i<10;i++) { tmp[9-i] = (w.high % 3) + '0'; w.high /= 3; } i = 0; while (tmp[i] == s[0] && i < 20 - min_length) i++; int j = 2; while (i < 20) { s[j] = tmp[i]; i++; j++; } s[j] = 0; } unsigned int crazy_low(unsigned int a, unsigned int d){ unsigned int crz[] = {1,0,0,1,0,2,2,2,1}; int position = 0; unsigned int output = 0; while (position < 10){ unsigned int i = a%3; unsigned int j = d%3; unsigned int out = crz[i+3*j]; unsigned int multiple = 1; int k; for (k=0;k<position;k++) multiple *= 3; output += multiple*out; a /= 3; d /= 3; position++; } return output; } Word zero() { Word result = {0, 0, 0}; return result; } Word increment(Word d) { d.low++; if (d.low >= 59049) { d.low = 0; d.high++; if (d.high >= 59049) { fprintf(stderr,"error: overflow\n"); exit(1); } } return d; } Word decrement(Word d) { if (d.low == 0) { d.low = 59048; d.high--; }else{ d.low--; } return d; } Word crazy(Word a, Word d){ Word output; unsigned int crz[] = {1,0,0,1,0,2,2,2,1}; output.area = crz[a.area+3*d.area]; output.high = crazy_low(a.high, d.high); output.low = crazy_low(a.low, d.low); return output; } Word rotate_r(Word d){ unsigned int carry_h = d.high%3; unsigned int carry_l = d.low%3; d.high = 19683 * carry_l + d.high / 3; d.low = 19683 * carry_h + d.low / 3; return d; } // last_initialized: if set, use to fill newly generated memory with preinitial values... Word* ptr_to(Word** mem[], Word d, unsigned int last_initialized) { if ((mem[d.area])[d.high]) { return &(((mem[d.area])[d.high])[d.low]); } (mem[d.area])[d.high] = (Word*)malloc(59049 * sizeof(Word)); if (!(mem[d.area])[d.high]) { fprintf(stderr,"error: out of memory.\n"); exit(1); } if (last_initialized) { Word repitition[6]; repitition[(last_initialized-1) % 6] = ((mem[0])[(last_initialized-1) / 59049]) [(last_initialized-1) % 59049]; repitition[(last_initialized) % 6] = ((mem[0])[last_initialized / 59049]) [last_initialized % 59049]; unsigned int i; for (i=0;i<6;i++) { repitition[(last_initialized+1+i) % 6] = crazy(repitition[(last_initialized+i) % 6], repitition[(last_initialized-1+i) % 6]); } unsigned int offset = (59049*d.high) % 6; i = 0; while (1){ ((mem[d.area])[d.high])[i] = repitition[(i+offset)%6]; if (i == 59048) { break; } i++; } } return &(((mem[d.area])[d.high])[d.low]); } unsigned int get_instruction(Word** mem[], Word c, unsigned int last_initialized, int ignore_invalid) { Word* instr = ptr_to(mem, c, last_initialized); unsigned int instruction = instr->low; instruction = (instruction+c.low + 59049 * c.high + (c.area==1?52:(c.area==2?10:0)))%94; return instruction; } int main(int argc, char* argv[]) { Word** memory[3]; int i,j; for (i=0; i<3; i++) { memory[i] = (Word**)malloc(59049 * sizeof(Word*)); if (!memory) { fprintf(stderr,"not enough memory.\n"); return 1; } for (j=0; j<59049; j++) { (memory[i])[j] = 0; } } Word a, c, d; unsigned int result; FILE* file; if (argc < 2) { // read program code from STDIN file = stdin; }else{ file = fopen(argv[1],"rb"); } if (file == NULL) { fprintf(stderr, "File not found: %s\n",argv[1]); return 1; } a = zero(); c = zero(); d = zero(); result = 0; while (!feof(file)){ unsigned int instr; Word* cell = ptr_to(memory, d, 0); (*cell) = zero(); result = fread(&cell->low,1,1,file); if (result > 1) return 1; if (result == 0 || cell->low == 0x1a || cell->low == 0x04) break; instr = (cell->low + d.low + 59049*d.high)%94; if (cell->low == ' ' || cell->low == '\t' || cell->low == '\r' || cell->low == '\n'); else if (cell->low >= 33 && cell->low < 127 && (instr == 4 || instr == 5 || instr == 23 || instr == 39 || instr == 40 || instr == 62 || instr == 68 || instr == 81)) { d = increment(d); } } if (file != stdin) { fclose(file); } unsigned int last_initialized = 0; while (1){ *ptr_to(memory, d, 0) = crazy(*ptr_to(memory, decrement(d), 0), *ptr_to(memory, decrement(decrement(d)), 0)); last_initialized = d.low + 59049*d.high; if (d.low == 59048) { break; } d = increment(d); } d = zero(); unsigned int step = 0; while (1) { unsigned int instruction = get_instruction(memory, c, last_initialized, 0); step++; switch (instruction){ case 4: c = *ptr_to(memory,d,last_initialized); break; case 5: if (!a.area) { printf("%c",(char)(a.low + 59049*a.high)); }else if (a.area == 2 && a.low == 59047 && a.high == 59048) { printf("\n"); } break; case 23: a = zero(); a.low = getchar(); if (a.low == EOF) { a.low = 59048; a.high = 59048; a.area = 2; }else if (a.low == '\n'){ a.low = 59047; a.high = 59048; a.area = 2; } break; case 39: a = (*ptr_to(memory,d,last_initialized) = rotate_r(*ptr_to(memory,d,last_initialized))); break; case 40: d = *ptr_to(memory,d,last_initialized); break; case 62: a = (*ptr_to(memory,d,last_initialized) = crazy(a, *ptr_to(memory,d,last_initialized))); break; case 81: return 0; case 68: default: break; } Word* mem_c = ptr_to(memory, c, last_initialized); mem_c->low = translation[mem_c->low - 33]; c = increment(c); d = increment(d); } return 0; } ``` ## It works! [![It works!](https://i.stack.imgur.com/TdDi4.png)](https://i.stack.imgur.com/TdDi4.png) [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~37~~ 28 bytes -9 bytes thanks to mazzy ``` $args|%{-join($_..'a'-le$_)} ``` [Try it online!](https://tio.run/##NcrLDYMgAADQO1MQQ0t70A1MuolB@YugoIJaZ6dpjOf3RheZD5IZkxGvj4yIF@H7OErtlH2hpqowwaVhqHmf@QQAJVjD4v8djM4bWoAn4vCTAMYX4n1LcV3m4KfR2cH0WknBGe1agu97RdJ2lHEhle7NYN04@TAva0zbfsf8Aw "PowerShell – Try It Online") Takes input via splatting and uses char ranges introduced in PS v6. The range is then filtered out by only taking elements that are less than the current character. This in turns means decreasing ranges are unaffected (e.g. 'z'..'a') whereas increasing ranges (e.g. ' '..'a') will filter out everything except the space. [Answer] # [Python 3](https://docs.python.org/3/), 65 bytes ``` lambda s:print([''.join(map(chr,range(ord(c),96,-1)))for c in s]) ``` Outputs a list of strings as clarified in @Arnauld's comment. If we could assume that a string `s` existed with the content it would be 56 bytes. [Try it online!](https://tio.run/##BcFRCsMgDADQq@TPBGxhDAYd9CSlH07rtNhEojB6evdevXsSfo4R1@KuT3DQ3lUzd9yMmU/JjJer6JNadfw9UDSgJ7u87PQgoigKHjJD22lENOkoReAnWoKh8Qc "Python 3 – Try It Online") [Answer] # Sed (with `-r` switch), ~~65~~ ~~61~~ ~~60~~ 59 characters ``` s/./&zyxwvutsrqponmlkjihgfedcba \n/g s/(.).*\1/\1/gm s/ //g ``` Thanks to: * [Kritixi Lithos](https://codegolf.stackexchange.com/users/41805/kritixi-lithos) for finding an unnecessary capturing (-3 characters) * [Kritixi Lithos](https://codegolf.stackexchange.com/users/41805/kritixi-lithos) for ~~anchoring to line start~~ not anchoring instead of word start (~~-1~~ 2 characters) * [Kritixi Lithos](https://codegolf.stackexchange.com/users/41805/kritixi-lithos) for combining the 2 solutions advantages (2 characters) Sample run: ``` bash-5.0$ sed -r 's/./&zyxwvutsrqponmlkjihgfedcba \n/g;s/(.).*\1/\1/gm;s/ //g' <<< 'cg cc' cba gfedcba cba cba ``` [Try it online!](https://tio.run/##DcdLDkAwEADQvVN0JUh04j42aLVoO9XxP7wheZtHWjETSMif@zqPfaO0RgzeLfNkzajV0HeiDWAygkKWsmob@Bn/XwAYZqudE2jFicmpF@M2YSCu0wc "sed 4.2.2 – Try It Online") ### Sed (with `-r` switch), ~~53~~ 52 characters ``` s/./&zyxwvutsrqponmlkjihgfedcba \n/g s/(.).*\1/\1/gm ``` In case trailing spaces are acceptable. [Try it online!](https://tio.run/##DcJJDoAgDADAu6/gZNREGv/DRQVxAYrU/fFWJ0NGMxNIyJ/7Oo99o7RGDN4t8zTawei@a4UKYDOCQpayUg38rWcejXMoTkxOvxi3CQNxnT4 "sed 4.2.2 – Try It Online") [Answer] # [JavaScript (Node.js)](https://nodejs.org), 56 bytes Takes input as a list of characters. Returns a list of strings. ``` s=>s.map(g=c=>(c|=(B=Buffer)(c)[0])>96?B([c--])+g(c):'') ``` [Try it online!](https://tio.run/##DcjBCgIhEADQX4m9OEMonYKCMfA3zIO4aruYs@hWl/7dese3@rfvoS3bLivPcSQanXRXT79BpkAawpfAkHmlFBtCQHtyqC/nmwEbpHR4zP@8CoEjcO1coiqcIYFVSk2PWAofPtzKPDlUKy8VxL0KxPED "JavaScript (Node.js) – Try It Online") ### Commented ``` s => // s[] = input characters s.map(g = c => // for each character c in s[], using the recursive function g: ( c |= // update c: (B = Buffer) // on the first iteration, c is a character and Buffer(c)[0] (c)[0] // returns its ASCII code; on later iterations, c is an // integer and Buffer(c) creates a buffer filled with NUL bytes ) > 96 ? // if c is greater than 96: B([c--]) // append the character of ASCII code c and decrement c + g(c) // append the result of a recursive call : // else: '' // stop recursion ) // end of map() ``` [Answer] # [R](https://www.r-project.org/), ~~63~~ ~~62~~ 61 bytes -16 bytes thanks to Giuseppe -7 more bytes, again, thanks to Giuseppe -1 byte adding a line break in place of `\n` -1 byte thanks to Robin Ryder ``` for(l in utf8ToInt(scan(,""))-96)cat(letters[l:0],' ',sep="") ``` [Try it online!](https://tio.run/##DcoxCsMwDADAva8QXmKDA5lCW8gDumcLHYSjOAZFKrb6frc3X@390OoZisDXjvuqLzHfEoqPzoUwPuaQ0DyTGdW28XN6x@E2xEaf5R@6O6kSFMALku5FMiBk1R3SicwkmVz/AQ "R – Try It Online") # [R](https://www.r-project.org/), 86 bytes (my original answer) ``` x=utf8ToInt(scan(,''));s=sapply;cat(gsub(" .+"," ",s(s(x,`:`,97),intToUtf8)),sep="\n") ``` Ungolfed: ``` x=utf8ToInt(scan(,'')) #Takes input, converts to ASCII s=sapply; #Alias sapply function to save a byte s(x,`:`,97) #Create vector from 97 to respective ASCII value s( ,intToUtf8) #Convert to character gsub(" .+"," ", ) #Removes everything after space cat( ,sep="\n") #Outputs to console ``` [Try it online!](https://tio.run/##Dcw7DsMgDADQq1heYqtW136iHKB7snUIJZQgUUAxkdLT074DvK21Y9jr@zrmR6qk1iSSrmPudVBTSvz21lTyur8I4XxCQUBRUjpkvs9yu7CEVMc8/Q9mUVcGfCbkhqvbHAQwH7B5CcmDAZ/zAnY1MbrkHbYf "R – Try It Online") Could likely be golfed. NOTE: It does not use recursion. I do not know whether that would be shorter or not. I'll experiment later. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~56~~, 53 bytes ``` c;f(char*s){for(c=*s;c;)putchar(c<97?c=*++s,10:c--);} ``` [Try it online!](https://tio.run/##S9ZNT07@/z/ZOk0jOSOxSKtYszotv0gj2Var2DrZWrOgtAQkrJFsY2luDxTU1i7WMTSwStbV1bSu/Z@ZV6KQm5iZp6HJVc3FmaahlJGak5OvUJ5flJOipGnNVfsfAA "C (gcc) – Try It Online") Now down to 53 bytes! It can probably be golfed more though... [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 24 bytes ``` *.comb>>.&{[R~] 'a'..$_} ``` [Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPtfSy85PzfJzk5PrTo6qC5WQT1RXU9PJb72vzVXcWKlQpqGekZqTk6@Qnl@UU6KuqZeVn5mnoZSTJ6SpvV/AA "Perl 6 – Try It Online") Returns a list of strings. ### Explanation ``` *.comb # Split into characters >>.&{ } # Map to 'a'..$_ # Range 'a' to current character [R~] # Reverse concat ``` [Answer] # [K (oK)](https://github.com/JohnEarnest/ok), ~~17~~ 14 bytes -3 bytes thanks to streetster -3 bytes thanks to ngn ``` `c$96-!:'0&96- ``` [Try it online!](https://tio.run/##DclJDkAwFADQq9CIYSGxkuAy6Eg/X2uo9vJl9RZP16hjFP1Is66t075o8t8oipJMM2VcSLWsGrYdD2PP637c6wMZSPCve@7rtObAfQO9LkoKzug8/ak4ACYOLTBSxQ8 "K (oK) – Try It Online") [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~8~~ 7 bytes A monadic link returning a list of strings. ``` ḲOr97ỌK ``` [Try it online!](https://tio.run/##y0rNyan8///hjk3@RZbmD3f3eP8/3B75/38GUDxfoTy/KCcFAA "Jelly – Try It Online") ``` ḲOr97ỌK - a monadic link taking a string, e.g. "ab c" Ḳ - split at spaces --> ["ab", "c"] O - get ASCII codes --> [[97, 98], [99]] r97 - build descending range to 97 --> [[[97], [98, 97]], [[99, 98, 97]]] Ọ - turn back into ASCII --> [["a", "ba"], ["cba"]] K - join with spaces --> ["a", "ba", " ", "cba"] ``` [Answer] # [GolfScript](http://www.golfscript.com/golfscript/), 12 bytes ``` {),97>-1%n}% ``` [Try it online!](https://tio.run/##S8/PSStOLsosKPn/v1pTx9LcTtdQNa9W9f//jNScnHyF8vyinBQA "GolfScript – Try It Online") ## Explanation ``` { }% # Map over the implicit input ), # Generate range to 0x00 97> # Remove all that is less than 97 -1% # Reverse the string n # Add a newline ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ ~~12~~ 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` AAηí‡ ``` -2 bytes by outputting as a list of strings. -7 bytes (byte-count more than halved) thanks to *@Grimy*. Input as a list of characters. [Try it online](https://tio.run/##yy9OTMpM/f/f0fHc9sNrHzUs/P8/WilDSUcpFYhzoDgfiBWAuBzKLoKKpyjFAgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TpuSZV1BaYqWgZF8Z7KLDpeRfWgLh6/x3dDy3/fDaRw0L/@sc2mb/PzEpOSU1LT0jMys7Jzcvv6CwqLiktKy8orKKq6qyorystKS4qLAgPy83JzsrMyM9LTUlOSmRKyM1JydfoTy/KCcFAA). Or alternatively: ``` AÂ.s‡ ``` [Try it online](https://tio.run/##yy9OTMpM/f/f8XCTXvGjhoX//0crZSjpKKUCcQ4U5wOxAhCXQ9lFUPEUpVgA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TpuSZV1BaYqWgZF8Z7KLDpeRfWgLh6/x3PNykV/yoYeF/nUPb7P8nJiWnpKalZ2RmZefk5uUXFBYVl5SWlVdUVnFVVVaUl5WWFBcVFuTn5eZkZ2VmpKelpiQnJXJlpObk5CuU5xflpAAA). **Explanation:** ``` A # Push the lowercase alphabet Aη # Push a list of prefixes of the lowercase alphabet í # Reverse each prefix ‡ # Transliterate all characters of the alphabet to these reversed prefixes in # the (implicit) input-list # (after which the resulting string-list is output implicitly) A # Push the lowercase alphabet  # Bifurcate it; short for Duplicate & Reverse copy .s # Get the suffixes of that reversed alphabet ‡ # Transliterate all characters of the alphabet to these reversed suffixes in # the (implicit) input-list # (after which the resulting string-list is output implicitly) ``` [Answer] # Ruby, 41 characters ``` ->s{s.chars{|c|puts [*?a..c].reverse*''}} ``` or ``` ->s{s.gsub(/./){[*?a..$&].reverse*''+$/}} ``` No recursion here. Sample run: ``` irb(main):001:0> ->s{s.chars{|c|puts [*?a..c].reverse*''}}['cgcc'] cba gfedcba cba cba ``` [Try it online!](https://tio.run/##KypNqvyfpmD7X9euuLpYLzkjsai4uia5pqC0pFghWss@UU8vOVavKLUstag4VUtdvbb2f1q0ekZqTk6@Qnl@UU6Keux/AA "Ruby – Try It Online") [Answer] # PostgreSQL, 119 characters ``` \prompt s select(select string_agg(chr(s),'')from generate_series(ascii(c),97,-1)s)from regexp_split_to_table(:'s','')c ``` (Those verbose function names are killing me…) Sample run: ``` bash-5.0$ psql -Atf pointlessly-recurse.sql <<< 'hello world' hgfedcba edcba lkjihgfedcba lkjihgfedcba onmlkjihgfedcba wvutsrqponmlkjihgfedcba onmlkjihgfedcba rqponmlkjihgfedcba lkjihgfedcba dcba ``` [Answer] # [V (vim)](https://github.com/DJMcMayhem/V), 15 bytes ``` \Óçá/A¬za ͈…± ``` [Try it online!](https://tio.run/##ASgA1/92//9cw5PDp8OhL0HCrHphCsONwojCgcKFwrH//2hlbGxvIHdvcmxk "V (vim) – Try It Online") Hexdump: ``` 00000000: 5cd3 e7e1 2f41 ac7a 610d cd88 8185 b1 \.../A.za...... ``` Fun fact: Recursion is the only form of looping that V has, yet this submission doesn't use any. [Answer] # [Befunge-98 (PyFunge)](https://pythonhosted.org/PyFunge/), 18 bytes ``` #@~#;:'``j;:,1-;a, ``` [Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//9XdqhTtrZST0jIsrbSMdS1TtT5/z8jNScnX6E8vygnBQA "Befunge-98 (PyFunge) – Try It Online") [Answer] # [PHP](https://php.net/), 88 bytes ``` <?php for(;$i<strlen($s=$argv[1]);){for($j=ord($s[$i++]);$j>96;)echo chr($j--);echo" ";} ``` [Try it online!](https://tio.run/##FcpNDoMgGEXRuaswhgSJcdBJkwbbLsR0oIACoh@C/03XTnX47nlW2hCKt5U2asClFKnCT86IIUX@iSrXLuXtQyj5Xor0Exw/pUQqy86M9Otxp0QwCTGT1yHPCb1mEiX0F0LAVc24aFqpdGf6Aezo/DQv67YfOMLHvq3LPHk3Whh602kl20ZwVlcnSmEMxCs4w/Ef "PHP – Try It Online") Thanks to Shaggy for -21 bytes! :) [Answer] # [Wren](https://github.com/munificent/wren), 103 bytes Hopefully this beats the Lua answer. ``` Fn.new{|x| for(i in x)System.print(i==" "?"":(i.bytes[0]..97).map{|j|String.fromCodePoint(j)}.join()) } ``` [Try it online!](https://tio.run/##FY29CsIwGAD3PsVHpmT5cBOF4CA4Cx3FIbaJJuSnpNG0NH322G433HE5Sl9/IoL6@g441JtHL/NSptKoEKkG7WFi7Twm6XCI2ieqOSdALoScqcbXnOT4ODwRT0eGTgxLMaVNm/hGFYO7hl7ew54ZtqLZiDLWrHX/YSespeQjrQ2QQ7Q9YfUP "Wren – Try It Online") # [Wren](https://github.com/munificent/wren), 159 bytes I am not having enough fun. ``` Fn.new{|x| for(i in 122..97)x=x.replace(String.fromCodePoint(i),String.fromCodePoint(i)+String.fromCodePoint(i-1)) return x.replace("`"," ").replace(" "," ") } ``` [Try it online!](https://tio.run/##dc6xCsIwEIDhPU9xZMqhBtpFHDoJzkJfwNJeNZBe5ExNxfrsEXHoous3/PxJiPO9EehHbqGCfGDLlJ7zNKs@iHHgGIqytHa3xamarNDVNy2ZOorjs@0lDPvQ0TE4jsbh@o@vfvumQFRCcRSGpa1Peq2VxgXgC@qV68ct0mCTuEjmM23bxnujL@R9gBTEdxoxvwE "Wren – Try It Online") [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` Øa>Ðḟ)U ``` A monadic link accepting a list of characters which yields a list of lists of characters. **[Try it online!](https://tio.run/##y0rNyan8///wjES7wxMe7pivGfr/cHvk//8ZQPF8hfL8opwUAA "Jelly – Try It Online")** (adds newlines, since as a full program Jelly will print a smashed version of the lists) ### How? ``` Øa>Ðḟ)U - Link: list of characters, S ) - for each (character, c, in S): Øa - yield the lowercase alphabet ['a', 'b', ..., 'z'] Ðḟ - filter discard those for which: > - greater than (c)? U - reverse each resulting list (each line) ``` [Answer] **Brainfuck, 240 chars** `,[>,[>+>+<<-]>------------------------------------------------------------------------------------------------[>.-<-]++++++++++.---------->------------------------------------------------------------------------------------------------<<<-]` [Try it online!](https://fatiherikli.github.io/brainfuck-visualizer/#LFs+LApbPis+Kzw8LV0KPi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQpbPi4tPC1dCisrKysrKysrKysuLS0tLS0tLS0tLQo+LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tPDw8LV0=) *Explanation:* , takes an input for the length of the input for the loop [>,[>+>+<<-]> takes an input and duplicates it ------------------------------------------------------------------------------------------------ takes 97 from the ascii value of the input to iterate over [>.-<-] outputs the ascii character and then takes one away from the pointer, ready for the next loop ++++++++++.----------> outputs the newline ------------------------------------------------------------------------------------------------<<<-] resets everything ready for another iteration [Answer] # [Lua](https://www.lua.org), 94 bytes ``` function r(l)return l:find"[` ]"and"\n"or l..r(l.char(l:byte()-1))end print((...):gsub(".",r)) ``` [Try it online!](https://tio.run/##HYrLDsIgEEX3fgVhBYmSuO2vqIm8WminQ51CXz@P1bs5JzkXiq61LWhzTMhIgCSfCyGDpo3o@OPNXlyf8kSeiIFS50fZoE80Zs9eyNtdSo/uMlHELIRSSjbdXIzgil9JylrrsW/rUvJMnynhCEMfQ9d6Z41mv2ljnW@7EPsBRkzTh@ZclnXbj38OHiCxNRG4Lw "Lua – Try It Online") Only works if we can have redundant output, else +1 byte. ## Explanation Creates a recursive function `r` that returns what each letter should turn into. When the input letter of this function is a space or the character before `a` (which is `) then this should not be printed, but a new line instead. Replace each character in the input string (the first command-line argument) with the output of the function r called with this character. [Answer] # [Japt](https://github.com/ETHproductions/japt) [`-mR`](https://codegolf.meta.stackexchange.com/a/14339/), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) Takes input as an array of characters. ``` ;CÔk>U ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW1S&code=O0PUaz5V&input=WyJhIiwiYiIsIiAiLCJ5IiwieiJd) [Answer] # [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), 94 bytes ``` I =INPUT S I LEN(1) . X REM . I :F(END) Y = &LCASE ARB . Y X OUTPUT =X REVERSE(Y) :(S) END ``` [Try it online!](https://tio.run/##FcuxCsIwFIXhOXmKM0myCIJTIUPVKwRqlKaVdmw1tIWYQBV8/Bin88Phe4c4Rr9PiWkobW5tw23OiozYSWzRoaZLXs2KsyBzkpz1UJxtqmNpCWV9yGePjrNr22QN9Rd3qi2JXrJCWMkzS2l2q8OC4YXvunyWMGHAFOMTj3nw3oXJ/QA "SNOBOL4 (CSNOBOL4) – Try It Online") [Answer] # [Julia 1.0](http://julialang.org/), ~~36~~ 29 bytes ``` f(s)=[join(i:-1:'a') for i=s] ``` [Try it online!](https://tio.run/##yyrNyUw0rPj/P02jWNM2Ois/M08j00rX0Eo9UV1TIS2/SCHTtjj2v0NxRn65QpqGUkZqTk6@Qnl@UU6KkuZ/AA "Julia 1.0 – Try It Online") Note: Outputs as an array of strings. To display in a nice output format, use, for example, `println.(f("hello world"))` [Answer] # [Poetic](https://mcaweb.matc.edu/winslojr/vicom128/final/index.html), 482 bytes ``` transmit a letter or two,a-z enter in letters from a-z+space i did a print,i say a letter&go down i am moving in a cycle i get to letter a,and maybe to space i then create lines as i output the ten,a ASCII N/L char i figure x>y,and i do admire a way i check it if indeed x>y,then i rerun;if not,i finish it to output N/L char i write it out&i follow it up until no char i input is here o,et cetera as i run i do admit,i do run relatively longish o,i say,i do loads of BS deriving it ``` [Try it online!](https://mcaweb.matc.edu/winslojr/vicom128/final/tio/index.html?TVBLTsQwDN33FG/FhiIOgIQErEZCbOYEnsZtLdJ4lLhTyuUHp/MRu8Tva1umVCYxECKbcYZm2KItPf02nOpA0hUq6LNOcOSxHKnjRhAkuPKYJVkrKLTefR4GRdAlOYkmTHqSNFQrQrd2sWoHNpjeYqmlFDDReuA6vQXYyAldZjJGlMQFVCDQ2Y6zVRTGqSW87T92O3w9f6IbKbuwl2HOjJ/XdTP2qgoKk/iMsHhRcSZ33xBrpPdmgTls9C1SkDnP6cWhpHW3XpKU0dm13TX@X9ySxRs66tCDszVGXep/PmJOJtFtNq47S6piKRg5c6Ot36FjvwFddvPY5l63RvvTZ14oksmJ44qoafA2rt2OfuFEpVCgPd73CJzlcnE706E7Hyj8AQ) Not sure why no one's posted a pure brainfuck solution yet, the brainfuck program I made this poem from amounts to only 108 bytes. [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 13 bytes ``` ẹ{;Ẓ↔⟨a₁h⟩|}ᵐ ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6kUFCUn1KanFpsxaX0cFen/aO2DY@amoCsh1snPOpY/nDHNiC7Fsj5/3DXzmrrh7smPWqb8mj@isRHTY0Zj@avrAHL/Y9WSkxKTklNS8/IzMrOyc3LLygsKi4pLSuvqKxS0lGqqqwoLystKS4qLMjPy83JzsrMSE9LTUlOSgRKZqTm5OQrlOcX5aQoxQIA "Brachylog – Try It Online") This feels... bad. ``` ẹ{ }ᵐ For each element of the input, a₁ output the suffix of Ẓ the lowercase alphabet reversed ; ↔⟨ h⟩ for which the first element is the input, | or the input if there is no such suffix. ``` A 9-byte [generator](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/10753#10753) is possible if spaces are completely ignored: [`∋;Ẓ↔⟨a₁h⟩`](https://tio.run/##SypKTM6ozMlPN/pfXa6kUFCUn1KanFpsxaX0cFen/aO2DY@amh5uWwDkPNw64VHH8oc7tgHZtUDO/0cd3dYPd0161Dbl0fwViY@aGjMezV/5/3@0UmJSckpqWnpGZlZ2Tm5efkFhUXFJaVl5RWWVko5SVWVFeVlpSXFRYUF@Xm5OdlZmRnpaakpyUiJQMiM1JydfoTy/KCdFKRYA). Accounting for spaces brings it up to the same byte count: # [Brachylog](https://github.com/JCumin/Brachylog), 13 bytes ``` ∋{;Ẓ↔⟨a₁h⟩!|} ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6kUFCUn1KanFpsxaX0cFen/aO2DY@amh5uWwDkPNw64VHH8oc7tgHZtUDO/0cd3dXWD3dNetQ25dH8FYmPmhozHs1fqVhT@/9/tFJiUnJKalp6RmZWdk5uXn5BYVFxSWlZeUVllZKOUlVlRXlZaUlxUWFBfl5uTnZWZkZ6WmpKclIiUDIjNScnX6E8vygnRSkWAA "Brachylog – Try It Online") [Answer] # [Scala](http://www.scala-lang.org/), 53 bytes ``` def f(s:String)=s.map(c=>('a'to c).reverse.mkString) ``` [Try it online!](https://tio.run/##LctBCsIwEEDRvacYummyyQGEFjxAV55gTCa2dpqEzKBC6dmjiOv/vnhkbPn2IK8w4ZKA3kopCFxKgb0FihCNnK9al3S3g7gNi/HDaHrsNYO3rtKTqpDb1j@CFk03E3OGV64cOvubyjcqJ3s62gc "Scala – Try It Online") Note: return the list of strings. To do the actual output, use `.map(println)` or so ]
[Question] [ In as few Unicode characters as possible, print the following (144 characters): ``` 1, 2, 3 o'clock, 4 o'clock rock, 5, 6, 7 o'clock, 8 o'clock rock, 9, 10, 11 o'clock, 12 o'clock rock, We're gonna rock around the clock tonight. ``` You must not use any numbers in your code, except the digit `1`. [Answer] ## Javascript - 140 132 ``` k=1,s=", ",t=" o'clock",x="";while(k<11)x+=k+++s+k+++s+k+++t+s+k+++t+" rock,\n";alert(x+"We're gonna rock around the clock tonight.") ``` The fact, that 11 is made out of two 1's let me pass the rules I guess. ### Explanation The k+++s is equal to (k++)+s, so it adds k first to x, then increments k and then it adds s to x. This process will be done three times before it adds the last sentence. [Answer] ## C# - 186 Best golf language or best golf language? ``` class P{static void Main(){var s="";for(int i=1;i<11;)s+=i+++", "+i+++", "+i+++" o'clock, "+i+++" o'clock rock,\n";System.Console.Write(s+"We're gonna rock around the clock tonight.");}} ``` [Answer] # Brainfuck (1574) Not a serious submission, but follows the rules. ``` -[----->+<]>--.-----.------------.[-->+++<]>++.------.------------.++[-->+++<]>.[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.++[-->+++<]>+.-[--->++<]>--.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.-[----->+<]>.---------.------------.-----[->++<]>.----------.------------.----[->++<]>-.+[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.----[->++<]>.[-->+<]>++++.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.+[->+++++<]>++.-------------.------------.[-->+++<]>+.-.----.------------.[-->+++<]>+..-[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.+++[----->++<]>.------------.[-->+++<]>+.+.--[--->++<]>.+++++[->+++<]>.[--->+<]>++.-[--->+<]>+.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[----->++<]>.---.------------.++++++++.+++[----->++<]>.>++++++++++.[------>+<]>.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------.-[->+++<]>.---[----->++<]>.---.------------.++++++++.-[++>---<]>+.[->+++<]>+.--[--->+<]>---.---.++++++.-------.----------.-[--->+<]>-.---[->++++<]>.------------.---.--[--->+<]>-.+[->+++<]>.+++++++++.+++.------------.++++++++.-[++>---<]>+.---[->++++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>. ``` Can be tested [here](http://www.nayuki.io/page/brainfuck-interpreter-javascript). [Answer] # Ruby, 100 ``` printf"%i, %i#{", %i o'clock"*r=-~1} rock, "*-~r+"We're gonna rock around the clock tonight.",*1..$$ ``` [Answer] # Perl 123 ``` $s="*, *, * o'(, * o'( ),";print"$s $s $s We're gonna ) around the ( tonight."=~s![(*)]!(clock,rock)[1+1+1&ord$&]||++$i!reg ``` The regular expression matches `(`, `)` and `*`. I used the fact that the ASCII code of `(` is 40, of `)` is 41 and `*` is 42. The `r` flag of the regular expression enables "in place substitution" and the `e` flag enables code evaluation (similar to `x.replace(/.../, function(m){...})` in JavaScript). `(clock,rock)` is an array of two "bare words". `$&` is the current match of the regular expression and `ord$&` is it's ASCII value. Masked by 3 or `1+1+1` the ASCII values are now 0, 1 and 2, so I can use them to retrieve the corresponding array element. As 2 is out of the array, the "short circuit" operator `||` evaluates `++$i`. In the first match `$i` is `undef` so incrementing it I get 1, then 2 and so on... In simple words. This replaces `*` with it's current occurrence, `(` with "clock" and `)` with "rock". [Answer] # Bash+coreutils, 120 ASCII, 92 Unicode ### ASCII: ``` c=clock f(){ echo $[++i], $[++i], $[++i] o\'$c, $[++i] o\'$c rock,;} f f f echo We\'re gonna rock around the $c tonight. ``` ### Unicode: ``` iconv -t unicode<<<挊挽潬正昻⤨⁻捥潨␠⭛椫ⱝ␠⭛椫ⱝ␠⭛椫⁝屯␧Ᵽ␠⭛椫⁝屯␧⁣潲正㬬㭽㭦㭦㭦捥潨圠履爧⁥潧湮⁡潲正愠潲湵⁤桴⁥挤琠湯杩瑨ਮ|sed 1d|bash ``` ### base64 encoded Unicode version (in case unicode renderings get messed up): ``` aWNvbnYgLXQgdW5pY29kZTw8POaMiuaMvea9rOato+aYiuKkqOKBu+aNpea9qOKQoOKtm+akq+Kx neKQoOKtm+akq+KxneKQoOKtm+akq+KBneWxr+KQp+Kxo+KQoOKtm+akq+KBneWxr+KQp+KBo+a9 suato+OsrOCpveCppuCppuCppuaNpea9qOWcoOWxpeeIp+KBpea9p+a5ruKBoea9suato+aEoOa9 sua5teKBpOahtOKBpeaMpOeQoOa5r+adqeeRqOCornxzZWQgMWR8YmFzaAo= ``` [Answer] # Brainfuck, 1299 ***Bleuuuurgh***. That was terrible. I don't know why I did this, it seemed quite easy at the start. First and probably last Brainfuck script. [Try it here.](http://copy.sh/brainfuck/) With some help from [an automated code generator](http://copy.sh/brainfuck/text.html), I was able to write a script which reused most of the characters instead of generating each one from scratch. It's only 275 characters shorter than the one automatically generated, posted [here](https://codegolf.stackexchange.com/a/34676/16402). The output isn't newline-terminated. I might put a bit of explanation in later on. Essentially, any long line which isn't something like `>>>>>>>` or `<<<<<<<` or `>>.>>.>>.>>.` generates a character or a series of them. ``` -[----->+<]>--. > ++[------>+<]>+.------------. [-]<<+.> ++[------>+<]>+.------------. [-]<<+.> ++++[->++++++++<]>. > +[------->++<]>+. > +[------->+++<]>++. > --[----->+<]>---. > +[------->++<]>--. > +[------->++<]>+. > --[----->+<]>---. > +[----->+++<]>++++. > ++[------>+<]>+. > ++++[->++++++++<]>. <<<<<<<<<<<<<<<<<<<<+. >>.>>.>>.>>.>>.>>.>>.>>.>>>>. > +[--------->++<]>. > +[------->++<]>+. > --[----->+<]>---. > +[----->+++<]>++++. <<<<<<<<<<. <++++++++++. <<<<<<<<<< <<<<<<< +. >>>>>>>>>> >>>>>>>>. <<<<<<<<<< <<<<<< .<<+. >>>>>>>>>> >>>>>>>>. <<<<<<<<<< <<<<<< .<<+. >>.>>.>>.>>.>>.>>.>>.>>.>>. <<<<<<<<<< <<<<<< .<<+. >>.>>.>>.>>.>>.>>.>>.>>.>>>>. >>.>>.>>.>>. <<<<<<<<<<. <. <<<<<<<<< <<<<<<<< +.[-]< ++[------>+<]>+. >>. [-]<<[-]< -[----->+<]>--.-. [-]< ++[------>+<]>+.------------. [-]< -[----->+<]>--.. > ++++[->++++++++<]>. >>.>>.>>.>>.>>.>>.>>.>>.>>. >>>>>>>>> -[----->+<]>--.+. <<<<<<<<< <<<<<<<<< <<<<<<<<< <. >>.>>.>>.>>.>>.>>.>>. >>>>. >>.>>.>>.>>. >>[-] ++[------>+<]>+.>++++++++++. > +[--->++<]>+.++[->++++<]>+.---[->+++<]>+.-[->+++<]>.-------------.--[--->+<]>-.++[->+++<]>+.++++++++.-..-------------. <<<<<<<<<< <<<<<<<<<. >>.>>.>>.>>. <<[-]<<[-]<<[-]<<. > --[----->+<]>-----.--[--->+<]>---.---.++++++.-------.----------. [-]<<<. > --------[-->+++<]>.------------.---. <<. <<<<<<<<<< <<. >>.>>.>>.>>. >>>>. >>[-] --------[-->+++<]>.-----.-.-----.--.+.++++++++++++.[++>---<]>. ``` [Answer] # Lua - ~~217~~ ~~164~~ ~~154~~ ~~151~~ ~~149~~ 143 Modified the old one to use a loop instead, saves a boat-load of characters. Thanks to TeunPronk for helping me shave off another 10 characters and to WilliamBarbosa for shaving off another 3 characters. 2 more characters can be saved by using the variable `k`. 6 more characters are saved by eliminating the variable `r=" rock,"` since it is used once. ``` o=" o'clock"c=", "w=io.write k=1+1 for i=1,11,k+k do w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")end w("We're gonna rock around the clock tonight.") ``` Ungolfed, ``` o=" o'clock" c=", " w=io.write k=1+1 for i=1,11,k+k do w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n") end w("We're gonna rock around the clock tonight.") ``` [Answer] # CJam - 90 ASCII / 54 Unicode ASCII: ``` {{T):T}:F~", ":CFCF" o'clock":OCFO" rock, "}Z*"We're gonna rock around the clock tonight." ``` Unicode: ``` "ξ漰㠬༳ᆧᶃ㸩씪咦⏚騤䖫퍃᰽薂ᴤਥ궋씻㱗㽫Ƶꐥ勋䎔䃱魠ꝯ朐酠礢璿狮꓈执낦덋觫ᥛ琚"GZ)#bBC*b:c~ ``` Try them at <http://cjam.aditsu.net/> [Answer] # Python (123) ``` print((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%tuple(range(1,11+1+1))+"We're gonna rock around the clock tonight.") ``` # PYG (112) ``` P((1+1+1)*"%i, %i, %i o'clock, %i o'clock rock,\n"%T(R(1,11+1+1))+"We're gonna rock around the clock tonight.") ``` [Answer] # Brainfuck - 680 test it here: [ideone.com/Wi9ftB](https://ideone.com/Wi9ftB) ``` >>>++++[>+++++++++[>+++[<<<<+<+>>>>>-]<<<+<<<+<+>>>>>>-]<-]+<++++++++<+++<---------<++++++++ ++++<----<++++++++++<+++[>>>+.>>>.<<<<.>>>>>>[>[<<<<<<--------.-.>>>.<<<<.>+..<.>>>.>-----.< ------------.+++++++++.+++.------------.++++++++.++++>+++++.<<<<.>.+.>>>>->>-]+<<+>-]+<[<<<< +.>>>.<<<<.>+.<.>>>.>-----.<<.>---.+++.<.>----.++++>+++++.<<<<.>+.>>>>-]<<<<<.>>>.>-----.<<. >---.+++.<.>----.<<<.>>>+++++++.---.<.>----.++++>+++++.<<<<<.<-]>[>>++++<<-]>>---.[-]<[>+<-] >>++.>>-----.<+++.<.<.>++.>---.-..<------.<.>>++++.---.<++.>----.<<.>--.>+++++++.---.++++++. -------.<+++.<.>>++++++.<++++.---.<.>--.>--------.+++.<.>----.<<.>>+++++++++.-----.-.-----.- -.+.>[>+++<-]>-.<<<---[>>+<<--]>>--. ``` as i promised, here's a better version. my brain feels like.. ooh so that's where the name comes from. **explanation:** (because it is unmaintainable and i don't want to forget how it works) firstly you have to choose the best data layout for this challenge. i came up with `-4 outmost loop` `-3 newline char` `-2 space` `-1 numbers` `1 lowercase #1` `2 lowercase #2` `3 comma, apostrophe, period` `4 condition (outmost loop < 3)` `5 inner loop` `6 second inner loop` We have to belive this is optimal unless there will be too many shifts (which case you have to rearrange the layout) After that I used a 4x9x3 loop to set the starting values for newline, number, the two lowercase letter and the comma. (all the smaller ascii codes got 4x9=36 and the two lowercase letter got 4x9x3=108, then I added and substracted some to get their real value) When the preset is done, the code enters the outmost loop that cycles 3 times. I explain it by pseudocode. ``` for 3 to 1 where i = numbers print '++i, ' while inner_loop != 0 # this is true after the first loop while second_inner_loop != 0 # and this is true after the second print '10, 11 o'clock, 12' # prints the difference condition = 0 # it prevents the printing below second_inner_loop += 1 inner_loop += 1 while condition != 0 print '++i, ++i o'clock, ++i' print ' o'clock rock,\n' ``` When this section is done I just have to print the last line. But we have an uppercase W that must be produced without using too many characters. At this point we are here: ``` Address Value Pointer -4 0 <-- -3 10 -2 32 -1 50 1 99 2 111 3 44 ``` so I put [-3] 4 times to [-1] and substract 3 to get 87 (W): `>[>>++++<<-]>>---.` then erase it `[-]` and move [-2] to this location [-1] so space will be close to the lowercase letters. `<[>+<-]` After that it just prints the letters. lowercase #1 is for the lower part 97-107 and lowercase #2 is for the above region. [Answer] ## JavaScript, ~~111~~ 107 chars, without using any number. Execute these snippets in your browser's JS console: 107 (inspired by <http://xem.github.io/obfuscatweet/> plus the other JS answer): ``` eval(unescape(escape('𩡯𬠨𬰽𘠬𘀢𛁴🐢𘁯𙱣𫁯𨱫𘠬𪐽𮀽𙰧𞰫𚱩🀽𜐱𞱸𚰽𪐫𚰫𬰫𪐫𚰫𬰫𪐫𚰫𭀫𬰫𪐫𭀫𘠠𬡯𨱫𛁜𫠢𚐻𮀫𘡗𩐧𬡥𘁧𫱮𫡡𘁲𫱣𪰠𨑲𫱵𫡤𘁴𪁥𘁣𫁯𨱫𘁴𫱮𪑧𪁴𛠢').replace(/uD./g,''))) ``` 111 (just packing all the string and removing the eval around): ``` unescape(escape('𜐬𘀲𛀠𜰠𫰧𨱬𫱣𪰬𘀴𘁯𙱣𫁯𨱫𘁲𫱣𪰬𒠵𛀠𝠬𘀷𘁯𙱣𫁯𨱫𛀠𞀠𫰧𨱬𫱣𪰠𬡯𨱫𛀊𞐬𘀱𜀬𘀱𜐠𫰧𨱬𫱣𪰬𘀱𜠠𫰧𨱬𫱣𪰠𬡯𨱫𛀊𥱥𙱲𩐠𩱯𫡮𨐠𬡯𨱫𘁡𬡯𭑮𩀠𭁨𩐠𨱬𫱣𪰠𭁯𫡩𩱨𭀮').replace(/uD./g,'')) ``` [Answer] # C - 145 - [try me](https://ideone.com/CYSgbI) ``` main(i){i<11?main(i-~1+1,printf("%d, %d, %d o'clock, %d o'clock rock,\n" ,i++,i,i-~1,i-~1+1)):puts("We're gonna rock around the clock tonight.");} ``` # C - 172 - [try me](https://ideone.com/zrTCfn) ``` #define l ,__LINE__+~1 #define f ;printf("%d, %d, %d o'clock, %d o'clock rock,\n" main(){f l l l l)f l l l l)f l l l l);puts("We're gonna rock around the clock tonight.");} ``` [Answer] # PHP - 125 129 **Version 1 (129)** ``` $i;while($i<11)echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight"; ``` **Version 2 (125)** ``` while($i++<11)echo"$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";echo"We're gonna rock around the clock tonight"; ``` Clean version: ``` while($i++<11) echo "$i, ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n"; echo "We're gonna rock around the clock tonight"; ``` [Answer] # Perl, 114 111 110 108 ``` $s=", X o'clock";$_="X, X$s$s rock, "x(1+1+1)."We're gonna rock around the clock tonight.";s/X/++$i/eg;print ``` 110: ``` $s=", X o'clock";print(("X, X$s$s rock, "x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr) ``` 111: ``` print(("X, X, X o'clock, X o'clock rock, "x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/egr) ``` 114: ``` ($s="X, X, X o'clock, X o'clock rock, "x(1+1+1)."We're gonna rock around the clock tonight.")=~s/X/++$i/ge;print$s ``` [Answer] ## C++ 261 203 ``` #include<iostream> #define x i++; #define y std::cout<< #define z y x y void m(){for(int i=1;i<11;){z", ";z", ";z" o'clock, ";z" o'clock rock, "<<"\n";}y"We're gonna rock around the clock tonight.";} ``` Edited my first attempt; it worked when I first tested it, but that seems to be a fluke; post-increment in a stream is "undefined behaviour", and it did weird things (including blue screening Windows 7!) when I tried re-running it. I think that using printf instead of std::cout could be used with post-increment to get a shorter program. Edited again, got it down to 231 by re-implementing the loop. Edited yet again, now down to 203...those #defines weren't all useful in the looping version. For those wondering how C++ can run a function "m", the entry point can be defined as any function with just a compiler option, as can setting all funcs to be stdcall; I used both switches when compiling the above. If you don't like the redefined entry point, add 3 to my character count. [Answer] # Swift - ~~136~~ 134 ``` var x=1 for;x<11;{print("\(x++), \(x++), \(x++) o'clock, \(x++) o'clock rock,\n")} print("We're gonna rock around the clock tonight.") ``` [Answer] ## Java, 228 A hardcoded solution would have probably been shorter. ``` public static void main(String[] a){ String s = ""; int i=1,j=1; for(i--,j--;i<=11;){ s += ++i + (j > 1 ? " o'clock rock, ":", "); if(j == "one".length()){ j -= j; s +="\n"; }else j++; } System.out.println(s+"We're gonna rock around the clock tonight"); } ``` [Answer] ## Befunge-98 (~~402~~ 268) Now a unefunge! ``` ".thginot kcolc eht dnuora kcor annog er'eW"a11+/a*1-> #;:,1+" ,",,:,1+" ,",,:,1+" ,kcolc'o "a1-k,:,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+-#;_:,a-1+" ,",,:a111++-:*,,1+" ,",,:a111++-:*,,1+" ,kcolc'o "a1-k,:a111++-:*,,1+a",kcor kcolc'o "ek,:a11+/a*b1111+++-+$$$aa*k,@ ``` [Answer] ## Groovy - 140 139 chars Golfed, influenced by [William Barbosa's answer](https://codegolf.stackexchange.com/a/34670/21004): ``` s="ock" i=1 f={->println "${i++}, ${i++}, ${i++} o'cl$s, ${i++} o'cl$s r$s,"} f();f();f() println "We're gonna r$s around the cl$s tonight" ``` Ungolfed: ``` s = "ock" i = 1 f = { -> println "${i++}, ${i++}, ${i++} o'cl$s, ${i++} o'cl$s r$s,"} } f();f();f() println "We're gonna r$s around the clock tonight" ``` [Answer] # Mathematica - 153 ``` i=1; StringReplace[ StringJoin[ Riffle[{s="X, X, X o'clock, X o'clock rock,",s,s},"\n"]]<> "\nWe're gonna rock around the clock tonight.","X":>ToString[i++]] ``` [Answer] ## C++ 252 ``` #define P(x) cout<<x #define Q cout<<", " #define N cout<<endl #define C P(" o'clock") #define R P(" rock") #define F P(++i);Q;P(++i);Q;P(++i);C;Q;P(++i);C;R;N; int i; main() { F F F P("We're gonna rock around the clock tonight."); } ``` [Answer] # Cobra - 193 ``` class P var i=1-1 def main print[.f,.f,.f,"We're gonna rock around the clock tonight."].join("") def f as String return"[[.i+=1,.i+=1,.i+=1].join(", ")] o'clock, [.i+=1] o'clock rock,\n" ``` [Answer] ## Java (v2) - 250 241 232 chars This is a complete running program, influenced by [William Barbosa's answer](https://codegolf.stackexchange.com/a/34670/21004). Golfed: ``` public class R{ static int o=1; static String c(){return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n";} public static void main (String[] a){System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight");}} ``` Ungolfed: ``` public class R { static int o = 1; static String c() { return o+++", "+o+++", "+o+++" o'clock, "+o+++" o'clock rock,\n"; } public static void main (String[] a) { System.out.println(c()+c()+c()+"We're gonna rock around the clock tonight"); } } ``` [Answer] # ECMAScript6 - ~~136~~ 135 Doesn't even use the allowed `1` digit: ``` alert([,...a=[s=", ",s,(c=" o'clock")+s,c+" rock,\n"],...a,...a].map((x,i)=>i+x).join("")+"We're gonna rock around the clock tonight.") ``` Tested in Firefox console. [Answer] # [Golflua](http://mniip.com/misc/conv/golflua/) -125 Basically a direct translation of [my Lua solution](https://codegolf.stackexchange.com/a/34671/11376): ``` k=1+1o=" o'clock"c=", "~@i=1,11,k+k I.w(i,c,i+1,c,i+k,o,c,i+k+1,o," rock,\n")$w("We're gonna rock around the clock tonight.") ``` [Answer] ## PowerShell, ~~123~~ ~~118~~ 109 ``` 1,1,1|%{"$('',''," o'clock"," o'clock rock"|%{"$((++$a))$_,"})"} "We're gonna rock around the clock tonight." ``` After a horrible start (167) I got rid of a few idioms I didn't even need and at least got it shorter than the reference. [Answer] ## Haskell -- ~~138~~ 137 chars As a standalone program: ``` r n=show n++s!!n s=" o'clock rock,\n":c:c:" o'clock, ":s c=", " main=putStr$(r=<<)[1..11+1]++"We're gonna rock around the clock tonight." ``` Edit: I used to have a helper function o used to define s by ``` s=o" rock,\n":c:c:o c:s;o=(" o'clock"++) ``` but it turns out to cost 1 extra character. Is there any way to compress all of the "o'clock"s / "rock"s / "ock"s? [Answer] ## JavaScript, 140 ``` a=", x o'clock",b="x, x"+a+a+" rock,\n",b+=b+=b+"We're gonna rock around the clock tonight.";for(i=1;i<=11+1;)b=b.replace("x",i++);alert(b) ``` I make a string like "x, x, x o'clock x o'clock rock,\n..." Then I replace the "x's" with numbers. [Answer] # PHP 150 No numbers, including the 11 which would not be two 1's stuck together, but the number value eleven. ``` function f(){static $i;echo++$i.", ".++$i.", ".++$i." o'clock, ".++$i." o'clock rock,\n";}f();f();f();echo"We're gonna rock around the clock tonight"; ``` ]
[Question] [ Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a `.`. Here is the full board: ``` rnbqkbnr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKBNR ``` Since this is a [kolmogorov-complexity](/questions/tagged/kolmogorov-complexity "show questions tagged 'kolmogorov-complexity'") question, you may not take any input and you must output this board by any default method, for example, saving a file, printing to STDOUT or returning from a function. You *may* optionally produce one trailing newline. Standard loopholes apply, and the shortest program in bytes! However, remember this is equally as much a competition between submissions in the same language. While it's unlikely that a languages like Java could beat a language like perl, or a golfing language like pyth or cjam, having the shortest Java answer is still really impressive! To help you track the shortest answer in each language, you may use this leaderboard, which will show the shortest submission by language and overall. ## Leaderboards To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` # Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` # Ruby, <s>104</s> <s>101</s> 96 bytes ``` If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header: ``` # Perl, 43 + 2 (-p flag) = 45 bytes ``` You can also make the language name a link which will then show up in the leaderboard snippet: ``` # [><>](http://esolangs.org/wiki/Fish), 121 bytes ``` ``` var QUESTION_ID=95745,OVERRIDE_USER=31716;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] # Vim, 26 bytes `irnbqkbnr<Esc>Y6p5Vr.VrpYGPgUj` Relies on a fresh Vim, or else `5V` may select the wrong area. * `irnbqkbnr<Esc>`: Write the top row. Easy enough. * `Y6p`: Make the rest of the rows, *except one*. Of course all but the top and bottom rows contain the wrong characters. * `5Vr.`: When you haven't used visual mode yet in the session, you can do things like this to select 5 lines. If you typed the same thing again right away, it would try to select 25 lines. Vim is weird like that. * `Vrp`: We're already on line 2, so let's make a pawn line. * `YGP`: Copy that pawn line into its place at the bottom. This is why I used `6p` instead of `7p` before. * `gUj`: Capitalize the white pieces. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~25~~ 24 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` “.“.“p“rnbqkbn”ṁ€8µṚ;ŒuY ``` [Try it online!](http://jelly.tryitonline.net/#code=4oCcLuKAnC7igJxw4oCccm5icWtibuKAneG5geKCrDjCteG5mjvFknVZ&input=) *Thanks to @Lynn for golfing off 1 byte!* ### How it works ``` “.“.“p“rnbqkbn”ṁ€8µṚ;ŒuY Main link. No arguments. “.“.“p“rnbqkbn” Yield [".", ".", "p", "rnbqkbnr"]. ṁ€8 Mold-each 8; reshape each string like the array [1, 2, 3, 4, 5, 6, 7, 8], i.e., cyclically repeat its contents to create strings of length 8. This yields the upper half of the board in reversed order, i.e., the string array A := "........", "........", "pppppppp", "rnbqkbnr"]. µ Begin a new, monadic chain. Argument: A Ṛ Reverse A. Œu Convert all characters in A to uppercase. ; Concatenate the results to both sides. Y Join the strings, separating by linefeeds. ``` [Answer] # [Brainfuck](https://esolangs.org/wiki/brainfuck), 224 bytes ``` +++++[>+++[>++++++<-]+<-]>>.[>>+>+<<<-]>>>[<<<+>>>-]<<<----.<+++[>---<-]>.>>-.------.<<.>>+++.++++.--<++++++++++>>++++++++++.<........>.[>+++++<-]>----<++++[>........<<<.>>-]<........<.>++.----.<<.>>+++.------.<<.>>+++.++++. ``` Took almost an hour to get this. [Answer] ## Python 2, 63 bytes ``` print"\n".join(["rnbqkbnr","p"*8]+["."*8]*4+["P"*8,"RNBQKBNR"]) ``` Unfortunately, the fairly simple approach was much shorter than the "clever" stuff I tried at first... Bonus answer, also 63 bytes: ``` print"\n".join(["rnbqkbnr"]+[c*8for c in"p....P"]+["RNBQKBNR"]) ``` [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), 24 bytes Uses [CP-1252](http://www.cp1252.com/) encoding. ``` "rnbqkbnr"'p8×'.8×D)Âu«» ``` [Try it online!](http://05ab1e.tryitonline.net/#code=InJuYnFrYm5yIidwOMOXJy44w5dEKcOCdcKrwrs&input=) **Explanation** ``` "rnbqkbnr" # push the string "rnbqkbnr" # STACK: "rnbqkbnr" 'p8× # push the char "p" repeated 8 times # STACK: "rnbqkbnr", "pppppppp" '.8× # push the char "." repeated 8 times # STACK: "rnbqkbnr", "pppppppp", "........" D # duplicate # STACK: "rnbqkbnr", "pppppppp", "........", "........" ) # wrap in list # STACK: ["rnbqkbnr", "pppppppp", "........", "........"]  # push a reversed copy of the list # STACK: ["rnbqkbnr", "pppppppp", "........", "........"], ["........", "........", "pppppppp", "rnbqkbnr"] u« # convert to upper-case and concatenate # STACK: ['rnbqkbnr', 'pppppppp', '........', '........', '........', '........', 'PPPPPPPP', 'RNBQKBNR'] » # join list by newline ``` [Answer] # [Actually](http://github.com/Mego/Seriously), 26 bytes ``` 'p8*"rnbqkbnr"│û@û4'.8*n(( ``` [Try it online!](http://actually.tryitonline.net/#code=J3A4KiJybmJxa2JuciLilILDu0DDuzQnLjgqbigo&input=) Explanation: ``` 'p8*"rnbqkbnr"│û@û4'.8*n(( 'p8* "p"*8 ["pppppppp"] "rnbqkbnr" that string ["rnbqkbnr", "pppppppp"] │ duplicate stack ["rnbqkbnr", "pppppppp", "rnbqkbnr", "pppppppp"] û@û uppercase the dupes ["RNBQKBNR", "PPPPPPPP", "rnbqkbnr", "pppppppp"] 4 '.8*n "."*8, 4 times ["RNBQKBNR", "PPPPPPPP", "........", "........", "........", "........", "rnbqkbnr", "pppppppp"] (( move the uppercase strings to the bottom of the stack, implicitly print ``` [Answer] ## PowerShell v2+, 44 bytes ``` 'rnbqknbr' 'p'*8 ,('.'*8)*4 'P'*8 'RNBQKNBR' ``` Strings left on the pipeline are implicitly printed with `Write-Output` at program execution. We couple that with the default newline behavior for an array to produce the four lines of periods with the comma-operator. ``` PS C:\Tools\Scripts\golfing> .\draw-ascii-chess-board.ps1 rnbqknbr pppppppp ........ ........ ........ ........ PPPPPPPP RNBQKNBR ``` [Answer] # Ruby, ~~45~~ 44 1 byte saved thanks to tuxcrafting. ``` puts"rnbqkbnr",?p*8,[?.*8]*4,?P*8,"RNBQKBNR" ``` This is 45 ``` puts s="rnbqkbnr",?p*8,[?.*8]*4,?P*8,s.upcase ``` Trying anything cleverer just seems to make it longer. [Answer] ## JavaScript (ES6), ~~69~~ 65 bytes *Saved 4 bytes thanks to edc65* ``` let f = _=>`rnbqkbnr p....PRNBQKBNR`.replace(/p|\./ig,c=>c.repeat(8)+` `) console.log(f()); ``` [Answer] # Cheddar, 56 bytes ``` a=['rnbqkbnr','p'*8]+['.'*8]*2->(a+a.rev=>@.upper).vfuse ``` Uses the new `=>` feature. ## Explanation ``` a= // set a to the first half ['rnbqkbnr','p'*8] + // First two rows ['.'*8]*2 // Next two dots ->( a + a.rev=>@.upper // Reverse and map all items to uppercase ).vfuse // Join on newlines ``` [Answer] ## Pyke, ~~28~~ ~~27~~ 26 bytes ``` "rnbqkbnr"i"P..p"1c8m*Xil3 ``` [Try it here!](http://pyke.catbus.co.uk/?code=%22rnbqkbnr%22i%22P..p%221c8m%2aXil3) I learned something new about my language today: `1c` can be used as a 2 char way of splitting a string into a list of characters. ``` "rnbqkbnr"i - i = "rnbqkbnr" stack = ["rnbqkbnr"]) "P..p"1c - chunk("P..p", 1) stack = ["rnbqkbnr", ["P", ".", ".", "p"]] 8m* - map(8*>, ^) stack = ["rnbqkbnr", ["PPPPPPPP", "........", "........", "pppppppp"]] X - splat(^) stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP"] il3 - i.changecase() stack = ["rnbqkbnr", "pppppppp", "........", "........", "PPPPPPPP", "RNBQKBNR"] - implicit join with newlines rnbqkbnr pppppppp ........ ........ PPPPPPPP RNBQKBNR ``` [Answer] # C#, 94 92 bytes *Edit: Thanks to [milk](https://codegolf.stackexchange.com/users/58106/milk) for saving 1 byte by changing string order to remove the return whitespace.* *Edit: Saved 1 more byte by adding a dummy parameter (**x** instead of **()**) for the anonymous function and calling it with any object.* ``` x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;}; ``` Full program using the above function: ``` using System; namespace DrawAnASCIIChessBoard { class Program { static void Main(string[] args) { Func<object,string>f= x=>{string a="RNBQKBNR\n",b="PPPPPPPP\n",c="........\n";return(a+b).ToLower()+c+c+c+c+b+a;}; Console.WriteLine(f(1)); } } } ``` C# is a very verbose language... --- # C# full program, 131 bytes ``` class P{static void Main(){string a="rnbqkbnr\n",b="pppppppp\n",c="........\n";System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper());}} ``` Ungolfed: ``` class P { static void Main() { string a="rnbqkbnr\n", b="pppppppp\n", c="........\n"; System.Console.Write(a+b+c+c+c+c+(b+a).ToUpper()); } } ``` [Answer] # Commodore BASIC V2/V7 (Commodore C64/128, VIC-20, TheC64Mini) - 129 tokenized and BASIC bytes ``` 0n$=cH(13):a$="{clear}{ctrl+h}{ctrl+n}rnbqkbnr"+n$:p$="pppppppp"+n$:?a$p$;:fOi=0to3:?"........":nE:goS1:?p$a$:end 1a$="RNBQKBNR"+n$:p$="PPPPPPPP"+n$:reT ``` This should be entered into BASIC on a Commodore 128 and saved, it will then load into the VIC/C64 okay (you may need `LOAD "CHESS",8,0` on the VIC-20), or use CBM PRG Studio. The reason for this is that I'm going over the 80/88 character limit in line `0` for the C64/VIC-20 respectively. The C128 allows a 160 PETSCII character limit, so with keyword abbreviations this could easily be > 160 character per BASIC line. The `{clear}` character is achieved by `SHIFT` + `CLR/HOME`, whereas (in a string) `CTRL+H` disables the `SHIFT+C=` key to toggle between graphics and business mode, and `CTRL+N` changes the case to business mode in BASIC. The resulting listing is as in the screen shot. Copy the listing above and paste it into `WinVICE` with a right-click on your mouse over the `VICE` window. I've added the resulting output on the VIC-20 to prove that it'll load on that mighty micro as well. [![Commodore 128 BASIC listing of PETSCII art chess board](https://i.stack.imgur.com/yNjDE.png)](https://i.stack.imgur.com/yNjDE.png) [![VIC-20 PETSCII chess board simulator](https://i.stack.imgur.com/QXjs1.png)](https://i.stack.imgur.com/QXjs1.png) [Answer] ## Haskell, 53 bytes ``` a="rnbkqbnr" unlines$a:map(<$a)"p....P"++["RNBKQBNR"] ``` `a` is used as the first line and to determine the length of strings made of `p`, `.` and `P` (-> `<$a`). . [Answer] # [MATL](http://github.com/lmendo/MATL), 26 bytes ``` 'rnbqkbnr' 'p..'!l8X"vtPXk ``` [Try it online!](http://matl.tryitonline.net/#code=J3JuYnFrYm5yJyAncC4uJyFsOFgidnRQWGs&input=) ### Explanation ``` 'rnbqkbnr' % Push this string (1×8 char array) 'p..'! % Push this string transposed (3×1 char array) l8X" % Repeat 1×8 times: gives 3×8 char array v % Concatenate the two arrays vertically into a 4×8 char array tP % Duplicate and flip vertically Xk % Convert to uppercase. Implicitly display the two 4×8 arrays ``` [Answer] # [J](http://jsoftware.com/), 34 bytes ``` (tolower,|.)4 8$'RNBQKBNR',8#'P..' ``` [Try it online!](https://tio.run/##y/r/PzU5I19BoyQ/J788tUinRk/TRMFCRT3IzynQ28kvSF3HQlk9QE9P/f9/AA) [Answer] # Ex, ~~66~~ 61 bytes (not a language per se, but reproductible line-oriented editor) ``` a rnbqkbnr . t. %t. %t. 2s/./p/g 7s/./P/g 8s/./\u&/g 3,6s/././g x ``` Second version, shorter, and sure there's room for improvement while staying POSIX. ``` a rnbqkbnr . t. %t. %t. 2,7s/./p/g 7,8s/./\u&/g 3,6s/././g x ``` ## usage notes To [try online](https://www.tutorialspoint.com/unix_terminal_online.php), just launch `ex yourfilename` then paste the lines. The result will be viewable with `cat yourfilename`. ## ungolfed/explanation It's a line oriented editor (which will serve our purpose here as we operate line by line), with commands following the general syntax "line/range command parameters" (so 3 colomns plus one for comment following) ``` a " append following lines until line with dot only rnbqkbnr . t . " duplicate current line "rnbqkbnr "rnbqkbnr % t . " duplicate the whole buffer (2 lines) "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr % t . " copy the whole buffer (4 lines) "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr "rnbqkbnr 2,7 s/./p/g " from line 2 to 7, replace each character with lower P "rnbqkbnr "pppppppp "pppppppp "pppppppp "pppppppp "pppppppp "pppppppp "rnbqkbnr 7,8 s/./\u&/g " on lines 7 and 8, replace each character with its uppercase "rnbqkbnr "pppppppp "pppppppp "pppppppp "pppppppp "pppppppp "PPPPPPPP "RNBQKBNR 3,6 s/././g " from line 3 to 6, replace each character with a dot "rnbqkbnr "pppppppp "........ "........ "........ "........ "PPPPPPPP "RNBQKBNR x " write the buffer into file and close the editor ``` Commands have a full name and a shortcut used here, as we're golfing. * `a` for `append`, to switch into input mode until a sole dot * `s` for `substitute`, with parameters /RegExp/replacement/flags where the flag `g` here means all occurrences (instead of default first only) * `t` initialy means *transfer* and is put for `copy` (the letter C was already used to *change*/replace line) with as parameter the line after one should copy (and the `.` is for the current) * `x` for `xit` and is put for *exit* (the letter E was already used to *edit* a file) That's all. [Answer] # Python 2, 68 bytes Posting anyway although the above Python 2 version is shorter. It would not have to be a one liner for the amount of bytes, just played with it. ``` x,y,z="rnbqkbnr\n","p"*8+"\n","."*8+"\n";print x,y,4*z,(y+x).upper() ``` [Answer] # JavaScript (ES6), 73 `.toUpperCase` is simply too long ``` _=>`rnbqkbnr ${r=c=>c[0].repeat(8)+` `,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR` ``` ``` O.textContent=( _=>`rnbqkbnr ${r=c=>c[0].repeat(8)+` `,r`p`+(b=r`.`)+b+b+b+r`P`}RNBQKBNR` )() ``` ``` <pre id=O></pre> ``` [Answer] # [V](http://github.com/DJMcMayhem/V), ~~27~~, 26 bytes ``` i¸P RNBQKBNRäkgujddppÒ.4Ä ``` [Try it online!](http://v.tryitonline.net/#code=acK4UApSTkJRS0JOUhvDpGtndWpkZHBww5IuNMOE&input=) This contains some unprintable characters, so here is the readable version: ``` i¸P RNBQKBNR<esc>äkgujddppÒ.4Ä ``` where `<esc>` represents `0x1B`. Explanation: ``` i " Enter insert mode ¸P " Enter 8 'P' characters " and a newline RNBQKBNR<esc> " Enter the first row and escape to normal mode. äk " Duplicate this line and the line above guj " Convert this line, and the line below to lowercase dd " Delete this line pp " And paste it twice below us Ò. " Replace this whole line with '.' chars 4Ä " And create four copies of this line ``` [Answer] # Emotinomicon, 89 bytes Sadly Emotinomicon has nothing like an duplicate stack function. Would be usefull. But at least shorter than Java. :) ``` 😭RNBKQBNR PPPPPPPP ........ ........ ........ ........ pppppppp rnbkqbnr😲⏪⏬⏩ ``` Explanation: ``` 😭(...)😲⏪⏬⏩ 😭(...)😲 String literal ⏪ ⏩ Loop ⏬ Pop one char and output ``` [Answer] ## Python 3.5, 56 bytes ``` for r in['rnbqkbn',*'p....P','RNBQKBN']:print((r*8)[:8]) ``` This uses [an idea by zawata](https://codegolf.stackexchange.com/a/95965/20260) to encode each line as `(r*8)[:8]`, with a string repeated 8 times and trimmed to length `8`. The pawns and empty rows are just `'p'*8`, `'.'*8`, and `'P'*8`, with no trimming. The first row uses `'rnbqkbn'`, with `('rnbqkbn'*8)[:8]` including another rook on the right when multiplied and trimmed. The last row is the same but capitalized. We express the list of row-parts compactly `['rnbqkbn','p','.','.','.','.','P','RNBQKBN']` using [Python 3.5's generalized unpacking](https://www.python.org/dev/peps/pep-0448/). We write out the first and last-entries, and the remaining single-character ones are unpacked from a string. In Python 2, we could settle for `split` instead for 60 bytes: ``` for i in'rnbqkbn p . . . . P RNBQKBN'.split():print(i*8)[:8] ``` [Answer] # C, 87 bytes ``` #define E "........\n" main(){puts("rnbqkbnr\npppppppp\n"E E E E"PPPPPPPP\nRNBQKBNR");} ``` This uses preprocessor and string literal joining. Sorry, Matthew Greci and CSM, I don't have any reputation here to comment on your solution [Answer] ## Python 3, 59 bytes ``` print('rnbqkbnr','p'*8,*['.'*8]*4,'P'*8,'RNBQKBNR',sep='\n') ``` Interesting that with better unpacking and print function, Python 3 can be much better than Python 2 for golf This was based on <https://codegolf.stackexchange.com/a/95758/2212> [Answer] # [Vyxal `J`](https://github.com/Vyxal/Vyxal), ~~26 24 31 28~~ 25 bytes -2 bytes thanks to the `j` flag. +7 bytes, added code to swap Q and K to make it valid. -3 bytes thanks to Aaron Miller! -3 bytes thanks to Kevin Cruijssen ``` «æ≠⁺tO«\p8*\.8*:W⁋Ḃ⇧‛KQḂV ``` ## Explanation ``` «æ≠⁺tO« - Push "rnbqkbnr" \p8* - Push "pppppppp" \.8*: - Push "........" twice W⁋ - Listify, then join by \n Ḃ⇧ - Bifurcate and uppercase the second half ‛KQḂV - Replace "KQ" with "QK" <flag> - Join by newlines and print entire stack implicitly ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=J&code=%C2%AB%C3%A6%E2%89%A0%E2%81%BAtO%C2%AB%5Cp8*%5C.8*%3AW%E2%81%8B%E1%B8%82%E2%87%A7%E2%80%9BKQ%E1%B8%82V&inputs=&header=&footer=) [Answer] # Powershell, ~~82~~ 73 bytes ``` $x=("rnbqkbnr",$("p"*8),$("."*8),$("."*8));$x+$x[3..0].ToUpper()-join"`n" ``` [Answer] # GNU sed, 54 bytes ``` s:^:rnbqkbnr:p;h s:.:p:gp;G h;s:[^\n]:.:gp;G s:.:\U&:g ``` [**Try it online!**](http://sed.tryitonline.net/#code=czpeOnJuYnFrYm5yOnA7aApzOi46cDpncDtHCmg7czpbXlxuXTouOmdwO0cKczouOlxVJjpn&input=) **Explanation:** The black pieces are printed first, saving the two associated board ranks in reverse order in the hold space. The white pieces are printed by converting the hold space to uppercase letters. ``` s:^:rnbqkbnr:p;h # change pattern and hold spaces to 'rnbqkbnr' and print string s:.:p:gp # replace each pattern space letter with a 'p', then print G;h # append hold space, then copy pattern space to hold space s:[^\n]:.:gp # replace each pattern space letter with a '.', then print G;s:.:\U&:g # append hold space and convert pattern space to uppercase # (automatic printing of pattern space at the end) ``` [Answer] # [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~366~~ 350 + 3 = 353 bytes [Try it online!](http://brain-flak.tryitonline.net/#code=KCgoKCgoKCgoKCgoKSgpKCkpKXt9KCgoKHt9KSkpe317fSgoWygoKHt9KSl7fSl7fV0oKFsoe30oKSldKCgoKCgoe30oKSl7fSl7fSl7fSgpKXt9KTw-KSk8Pik8Pik8PikpKTw8Pih7fTw-KTw-KHt9PD4pPD4oe308PikoW10oKSgpKT5bKCldKSkpKSkpKSkoKCkoKSgpKCkpeyh7fVsoKV08KCgoKCgoKCgoKCgoKCkoKSgpKCkoKSl7fSkoKSl7fSgpKXt9KSkpKSkpKSk-KX17fSgoKCgpKCkoKSgpKCkpe30pPCgoKCgoKCgoKFtdW10oKSgpKCkoKSkpKSkpKSkpPD4pPD4-KSgoKCgoKCkoKSgpKSkpe30pKCh7fXt9KSgoW3t9KHt9KV0oKFt7fSgpXSg8Pih7fSgpKCkpPD4pPD4pPD4pPD4pPD4pKSl7PD4oe308Pil9e30&input=&args=LUE+LWQ) ``` (((((((((((()()())){}(((({}))){}{}(([((({})){}){}](([({}())](((((({}()){}){}){}()){})<>))<>)<>)<>)))<<>({}<>)<>({}<>)<>({}<>)([]()())>[()]))))))))(()()()()){({}[()]<((((((((((((()()()()()){})()){}()){}))))))))>)}{}(((()()()()()){})<((((((((([][]()()()()))))))))<>)<>>)(((((()()()))){})(({}{})(([{}({})](([{}()](<>({}()())<>)<>)<>)<>)<>))){<>({}<>)}{} ``` This gets a plus 3 because it requires the `-A` flag to run properly. ## Explanation ``` First we push the last 5 letters to the active stack. We also push copies of last 3 numbers to the inactive stack. This is done with fairly simple methods I won't go into for the sake of brevity. (((()()())){}(((({}))){}{}(([((({})){}){}](([({}())](((((({}()){}){}){}()){})<>)<><>)<>)<>)<>))) We Move Everything from the offstack to the onstack. The first 3 letters are the same as the last 3 letters in the first line {<>({}<>)}{} We push 10 for a new line ((()()()()()){}) Using the value of Q we create a P and push it 8 times ((((((((<...>[()])))))))) We loop 4 times each time pushing 8 dots and a newline (()()()()) {({}[()]< ((((((((((((()()()()()){})()){}()){})))))))) >)}{} We push the last two lines in a very similar way to the first two. (((()()()()()){})<((((((((([][]()()()()))))))))<>)<>>)(((()()()){})(({}()()())(([{}(()()())](([{}()](<>({}()())<>)<>)<>)<>)<>))){<>({}<>)}{} ``` [Answer] # Python 3, 82 80 75 Bytes Not the shortest answer in python but it's my first and i think its pretty good for a first time ``` print('\n'.join((i*8)[:8]for i in'rnbqkbn p . . . . P RNBQKBN'.split())) ``` [Answer] # C, ~~112~~ 109 ``` char *e="rnbqkbnr";main(a){for(;a<65;)putchar((a++-1)%9?a<11?e[a-3]:a<20?112:a<48?46:a<57?80:e[a-57]-32:13);} ``` --- Readable: ``` char *e="rnbqkbnr"; main(a){ for(;a<65;) putchar((a++-1)%9?a<11?e[a-3]:a<20?112:a<48?46:a<57?80:e[a-57]-32:13); } ``` Notes: •char 13 = new line •char 112 = 'p' •char 46 = '.' •char 80 = 'P' •lowercase char-32 = UPPERCASE CHAR Thoughts: It's annoying because this is very well golfed for a short solution, but at the same time I could have gone sub-100 in my byte count by just hard coding in most of the chess board and just repeating the `.` `.` `.` part with a puts loop. But that's a very boring answer --- Thanks @Ahemone for 3 bytes off! ]
[Question] [ The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the square root of two) as output, rounded to a nonnegative integer. You may take your input and output in any reasonable format; for example stdin/stdout, files, or arguments/return values would all be acceptable. You are required to use, at minimum, the largest fixed-size integer type offered by your language, and if an **unsigned** variant of this is available, you must use it. If your language has no built-in integer type (e.g. JavaScript) you are allowed to use its default numerical type (e.g. floating point); for languages with no concept of a number (e.g. regex), input and output can be e.g. the length of a string. It is not required to reject negative integers; a submission that returns correct answers for negative inputs is allowed, but not required. Undefined behavior with negative inputs is allowed. You are allowed and encouraged to use arbitrary-precision integer types if you so desire, but the type must either be a built-in, part of a standard library, or implemented from scratch in your program. As such, there are two categories of competition in this challenge: 1. Precision limited by built-in types (fixed-size integer, floating point, etc.) 2. Arbitrary precision (recursion and memory allocation, if used, can be assumed to be unlimited, where appropriate to the language in question) Despite what the title might imply, you may use any rounding algorithm you want (floor, ceiling, nearest half up, nearest half even, arbitrary, or even random), as long as the difference between the integer returned value and the theoretical exact (irrational) value is always less than \$1\$ for all inputs that fit in your chosen integer type (but exactly 0 for an input of 0). All inputs up to the maximum representable value must return a correct output. In a way, the job of this program is to calculate the irrational number \$\sqrt{2}\$ to the requested precision, presenting it in the form of an integer. This is why solutions using arbitrary-precision types are encouraged, but not required. This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge. Standard loopholes are denied. The program with the least number of bytes wins. That said, this challenge is not only about which answer wins overall; it's also about seeing how concisely the challenge can be solved in each language, seeing how each language "prefers" to handle rounding, and how hard it is to solve in esoteric languages. And for those submissions that choose to use arbitrary precision, it's about seeing how concisely this can be done in the language. # Test cases Within the Precision-limited category, only the cases that are in range of the language's capability are required to pass. If your solution is too slow to demonstrably pass the larger inputs (or runs out of memory/stack), it becomes all the more important to explain it sufficiently well, so that it can be understood that it would pass. ``` Input → Floor or Ceiling 0 → 0 (this is the only input that can only result in one valid output) 1 → 0 or 1 2 → 1 or 2 3 → 2 or 3 4 → 2 or 3 5 → 3 or 4 10 → 7 or 8 32 → 22 or 23 500 → 353 or 354 1000 → 707 or 708 1000000 → 707106 or 707107 186444716 → 131836322 or 131836323 1000000000 → 707106781 or 707106782 2147483647 → 1518500249 or 1518500250 3037000499 → 2147483647 or 2147483648 4294967295 → 3037000499 or 3037000500 4503599627370496 → 3184525836262886 or 3184525836262887 9223372036854775807 → 6521908912666391105 or 6521908912666391106 18446744073709551615 → 13043817825332782211 or 13043817825332782212 10000000000000000000000000000000000000 → 7071067811865475244008443621048490392 or 7071067811865475244008443621048490393 956287480911872131784896176254337633353980911149964074434383 → 676197362516585909969655173274459790030028262421622111830069 or 676197362516585909969655173274459790030028262421622111830070 ``` [Answer] # Regex (ECMAScript+`(?*)`), ~~1169~~ ~~929~~ ~~887~~ ~~853~~ ~~849~~ 708 bytes *-141 bytes by using the second form of shortened division, where \$A^2 > C\$* Regex was never designed to do mathematics. It has no concept of arithmetic. However, when input is taken in the form of [bijective unary](https://en.wikipedia.org/wiki/Unary_numeral_system), as a sequence of identical characters in which the length represents a natural number, it is possible to do a wide range of operations, building up from the simple primitives available, which basically amount to addition, comparison, multiplication by a constant, and modulo. Everything must fit inside the input; it isn't possible to directly operate on numbers larger than that. In ECMAScript regex, it's especially difficult (and therefore interesting) to do even some of the simplest of operations, because of the limitation that all backrefs captured in a loop are reset to empty at the beginning of each iteration – which makes it impossible to count anything directly. It's nevertheless possible to match prime numbers, powers of N, Nth powers, arbitrary multiplication and exponentiation, Fibonacci numbers, factorial numbers, abundant numbers, and more, much of which is demonstrated in my other answers. One of the operations that turns out to be far more verbose than the rest is to "calculate an irrational number". I initially discussed this with teukon [back in 2014](https://gist.github.com/Davidebyzero/9735222#gistcomment-1209356). The only known way to do this is to *emulate* operations on numbers larger than the input, and probably the simplest way to do this is by working in a number base chosen based on what can fit into the input. It wasn't until late 2018 that I finally set about to implementing the theory I had sketched in 2014. Implementing it involved adapting the multiplication algorithm to work with factors of 0, which turned out to golf rather elegantly. (The underlying multiplication algorithm is explained [in this post](https://codegolf.stackexchange.com/questions/179239/find-a-rocco-number/179420#179420).) The basic algorithm is this: For input \$N\$, we want to calculate \$M=\lfloor{N\over\sqrt2}\rfloor\$. So we want the largest \$M\$ such that \$2M^2\le N^2\$. If we take the "number base" to be \$k=\lceil\sqrt N\rceil\$ or \$\lfloor\sqrt N\rfloor\!+\!1\$, all multiplication operations \$m\cdot n\$ on \$0\leq m,n<k\$ are guaranteed to fit in the available space. So if \$N=A k+B\$, where \$0\leq A,B\lt k\$, we can calculate \$N^2\$: $$N^2=(A k+B)^2=A^2 k^2+2 A B k+B^2$$ We must then do division, modulo, and carry to bring \$A^2\$, \$2 A B\$, and \$B^2\$ back into the range of a base \$k\$ "digit". A similar operation is then done to calculate \$2 M^2\$ iterated over the decreasing consecutive possible values of \$M\$, using digit-by-digit comparison to test for \$2M^2\le N^2\$, until the first \$M\$ is found that passes the test. So while the basic concept is simple enough, it adds up to a lot of calculations, and the regex is huge! And this is probably the *simplest* calculation of an irrational number that can be done in ECMAScript regex. (It is still unknown whether it's possible to calculate a transcendental number to arbitrary precision in regex.) This regex uses **molecular lookahead**, a.k.a. non-atomic lookahead, represented as `(?*`...`)`. Without this feature, it would be much harder (or at least much more verbose) to implement. A choice I made early on, to depart from pure code golf by going for mathematical aesthetics, turned out to be a very interesting. I chose to use \$k=\lceil\sqrt N\rceil\$ because it has the very neat property of making the calculations fit perfectly into \$N\$ if \$N\$ is a perfect square, whereas \$k=\lfloor\sqrt N\rfloor\!+\!1\$ is basically chaotic for all inputs. They both yield the same final outputs, but the former is just cleaner. A few golfs later, this choice ended up net increasing the total length of the regex by **8 bytes**, so I figured it was worth it. (This change is [in the git version history](https://github.com/Davidebyzero/RegexGolf/commit/b005d2f3713900212c0b2451c4912e3c2c1b605b).) But another golf later that day, unbeknownst to me, was actually dependent on that decision! The [skipping of a divisibility check in a division calculation](https://github.com/Davidebyzero/RegexGolf/commit/711a514cd6034ab099ce24870afbe82b09ea9c2a) makes \$N=25\$ return the incorrect output of \$M=11\$ instead of \$M=17\$ if \$k=\lfloor\sqrt N\rfloor\!+\!1\$, but works perfectly for all inputs if \$k=\lceil\sqrt N\rceil\$. So the *actual* net change in byte length was zero! It was a purely aesthetic decision for over two years. At the time I did not understand why that division optimization worked, but [this is now fully explained thanks to H.PWiz](https://codegolf.stackexchange.com/questions/114003/division-and-remainder/222932#222932). The shortened form of division ~~used at the beginning of the calculation of \$M^2\$~~ gives the correct quotient \$B\$ when \$A+2 < 4B\$, where \$C\$ is the dividend and \$A\$ is the divisor. Previously I believed that it was only guaranteed to work when \$A \le B\$. [This is no longer used, due to the number base switch.] And now, with the discovery of a second shortened form of division that gives the correct quotient when \$A^2 > C\$, I found a *major* opportunity to use it in this regex! It *only* works when \$k=\lfloor\sqrt N\rfloor\!+\!1\$, so now I've switched back to that number base. It's saving *141 bytes!* It's oddly convenient that this just happened to exist and works perfectly for this exact use. `(?=(x(x*)).*(?=\1*$)\2+$)(?=(x\1)+(x?(x*)))(?=\4(x(x*?))\1+$)(?=.*(?=(?=\4*$)\4\5+$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\9))(?=.*(?=(?=\4*$)(?=\6*$)(?=\4\7+$)\6\5+$|$\4)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\13))(?=.*(?=\12\12\9$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\17))(?*.*?(?=((?=\3*(x?(x*)))\21(x(x*?))\1+$)))(?=.*(?=\23*$)(\23\24+$))(?=.*(?=(?=\21*$)\21\22+$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\27))(?=.*(?=(?=\21*$)(?=\23*$)(?=\21\24+$)\23\22+$|$\21)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\31))(?=.*(?=\30\30\27$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\35))(?=.*(?=\26\26)(?=\3*(x*))(\1(x)|))(?=.*(?=\34\34\40)(?=\3*(x*))(\1(x)|))(?=(?=(.*)\13\13\17(?=\6*$)\6\7+$)\44(x+|(?=.*(?!\16)\41|(?!.*(?!\38)\8).*(?=\16$)\41$))(\25\31\31\35){2}\43$)\20|xx?\B|` [Try it on repl.it](https://repl.it/@Davidebyzero/regex-Shift-left-half-a-bit-ECMAScript) This regex is [on GitHub](https://github.com/Davidebyzero/RegexGolf/blob/master/regex%20for%20dividing%20by%20sqrt2%2C%20with%20molecular%20lookahead.txt) with a [full version history](https://github.com/Davidebyzero/RegexGolf/commits/master/regex%20for%20dividing%20by%20sqrt2%2C%20with%20molecular%20lookahead.txt). ``` # Given an input number N in the domain ^x*$, this regex returns floor(N / sqrt(2)) (?= (x(x*)) # \1 = will be the square root of the main number, rounded down; \2 = \1 - 1 .*(?=\1*$) \2+$ ) # Step 1: Calculate N*N in base floor(sqrt(N))+1. Thanks to this choice of number base to work in, we'll be able to use the # second shortened form of division in all places where the number base is the divisor, because it's guaranteed to give the # correct quotient when the dividend is less than the squared divisor, and N itself is less than this. This form of division # can be recognized by its lazy rather than greedy matching of the quotient, and only one divisibility test following that. (?=(x\1)+(x?(x*))) # \3 = \1+1 = floor(sqrt(N))+1, the number base to work in; \4 = N % \3; \5 = \4-1, or 0 if \4==0 (?= \4 (x(x*?)) # \6 = floor(N / \3); \7 = \6-1 \1+$ ) (?= .* (?= (?=\4*$) # tail = \4 * \4 \4\5+$ ) (x*?)(?=\3*$) # \8 = (\4 * \4) % \3, the base-\3 digit in place 0 of the result for N*N (x?(x*?)) # \9 = floor((\4 * \4) / \3); \10 = \9-1, or 0 if \9==0 ( \1+$ | $\9 # must make a special case for \9==0, because \1 is nonzero ) ) (?= .* (?= (?=\4*$) # tail = \4 * \6; must do symmetric multiplication, because \4 is occasionally 1 larger than \6 (?=\6*$) (?=\4\7+$) \6\5+$ | $\4 # must make a special case for \4==0, because \6 might not be 0 ) (x*?)(?=\3*$) # \12 = (\4 * \6) % \3 (x?(x*?)) # \13 = floor((\4 * \6) / \3); \14 = \13-1, or 0 if \13==0 ( \1+$ | $\13 # must make a special case for \13==0, because \1 is nonzero ) ) (?= .*(?=\12\12\9$) # tail = 2 * \12 + \9 (x*?)(?=\3*$) # \16 = (2 * \12 + \9) % \3, the base-\3 digit in place 1 of the result for N*N (x?(x*?)) # \17 = floor((2 * \12 + \9) / \3); \18 = \17-1, or 0 if \17==0 ( \1+$ | $\17 # must make a special case for \17==0, because \1 is nonzero ) ) # {\6*\6 + 2*\13 + \17} = the base-\3 digit in place 2 of the result for N*N, which is allowed to exceed \3 and will always do so; # Note that it will be equal to N iff N is a perfect square, because of the choice of number base. # Step 2: Find the largest M such that 2*M*M is not greater than N*N # Step 2a: Calculate M*M in base \3 (?* .*? # Determine value of M with backtracking, starting with largest values first (?= ( # \20 = M (?=\3*(x?(x*)))\21 # \21 = M % \3; \22 = \21-1, or 0 if \21==0 (x(x*?)) # \23 = floor(M / \3); \24 = \23-1 \1+$ ) ) ) (?= .* (?=\23*$) (\23\24+$) # \25 = \23 * \23 ) (?= .* (?= (?=\21*$) # tail = \21 * \21 \21\22+$ ) (x*?)(?=\3*$) # \26 = (\21 * \21) % \3, the base-\3 digit in place 0 of the result for M*M (x?(x*?)) # \27 = floor((\21 * \21) / \3); \28 = \27-1, or 0 if \27==0 ( \1+$ | $\27 # must make a special case for \27==0, because \1 is nonzero ) ) (?= .* (?= (?=\21*$) # tail = \21 * \23; must do symmetric multiplication, because \21 is occasionally 1 larger than \23 (?=\23*$) (?=\21\24+$) \23\22+$ | $\21 # must make a special case for \21==0, because \23 might not be 0 ) (x*?)(?=\3*$) # \30 = (\21 * \23) % \3 (x?(x*?)) # \31 = floor((\21 * \23) / \3); \32 = \31-1, or 0 if \31==0 ( \1+$ | $\31 # must make a special case for \31==0, because \1 is nonzero ) ) (?= .*(?=\30\30\27$) # tail = 2 * \30 + \27 (x*?)(?=\3*$) # \34 = (2 * \30 + \27) % \3, the base-\3 digit in place 1 of the result for M*M (x?(x*?)) # \35 = floor((2 * \30 + \27) / \3); \36 = \35-1, or 0 if \35==0 ( \1+$ | $\35 # must make a special case for \35==0, because \1 is nonzero ) ) # {\25 + 2*\31 + \35} = the base-\3 digit in place 2 of the result for M*M, which is allowed to exceed \3 and will always do so # Step 2b: Calculate 2*M*M in base \3 (?= .* (?=\26\26) # tail = 2*\26 (?=\3*(x*)) # \38 = (2*\26) % \3, the base-\3 digit in place 0 of the result for 2*M*M (\1(x)|) # \40 = floor((2*\26) / \3) == +1 carry if {2*\26} does not fit in a base \3 digit ) (?= .* (?=\34\34\40) # tail = 2*\34 + \40 (?=\3*(x*)) # \41 = (2*\34 + \40) % \3, the base-\3 digit in place 1 of the result for 2*M*M (\1(x)|) # \43 = floor((2*\34 + \40) / \3) == +1 carry if {2*\34 + \40} does not fit in a base \3 digit ) # 2*(\25 + 2*\31 + \35) + \43 = the base-\3 digit in place 2 of the result for 2*M*M, which is allowed to exceed \3 and will always do so # Step 2c: Require that 2*M*M <= N*N (?= (?= (.*) # \44 \13\13\17 (?=\6*$) # tail = \6 * \6 \6\7+$ ) \44 # tail = {\6*\6 + 2*\13 + \17}; we can do this unconditionally because our digits in place 2 are always greater than those in places 0..1 ( x+ | (?= .*(?!\16)\41 # \41 < \16 | (?!.*(?!\38)\8) # \38 <= \8 .*(?=\16$)\41$ # \41 == \16 ) ) (\25\31\31\35){2}\43$ # 2*(\25 + 2*\31 + \35) + \43 ) \20 |xx?\B| # handle inputs in the domain ^x{0,4}$ ``` --- # Regex (ECMAScript 2018), ~~861~~ 720 bytes This is a direct port of the ~~849~~ 708 byte molecular lookahead version, using variable length lookbehind. `(?=(x(x*)).*(?=\1*$)\2+$)(?=(x\1)+(x?(x*)))(?=\4(x(x*?))\1+$)(?=.*(?=(?=\4*$)\4\5+$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\9))(?=.*(?=(?=\4*$)(?=\6*$)(?=\4\7+$)\6\5+$|$\4)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\13))(?=.*(?=\12\12\9$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\17))(?=.*?(?=((?=\3*(x?(x*)))\21(x(x*?))\1+$))(?<=(?=(?=.*(?=\23*$)(\23\24+$))(?=.*(?=(?=\21*$)\21\22+$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\27))(?=.*(?=(?=\21*$)(?=\23*$)(?=\21\24+$)\23\22+$|$\21)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\31))(?=.*(?=\30\30\27$)(x*?)(?=\3*$)(x?(x*?))(\1+$|$\35))(?=.*(?=\26\26)(?=\3*(x*))(\1(x)|))(?=.*(?=\34\34\40)(?=\3*(x*))(\1(x)|))(?=(?=(.*)\13\13\17(?=\6*$)\6\7+$)\44(x+|(?=.*(?!\16)\41|(?!.*(?!\38)\8).*(?=\16$)\41$))(\25\31\31\35){2}\43$))^.*))\20|xx?\B|` [Try it online!](https://tio.run/##hVTdbtowFL7vU1CEGpuUKHYCtKQh0qRe9KYX2@W8qRGY4Ck4mWPaSITbPcAecS/Cjh0ymNYJ6Ui2z/m@7/zYybf0Na0WSpR6JIslP1Q6VZovYz9S8UeePdYl@qSVkJmn0reXA0piVKN6iLE3hD0jwwFm1B1gG2AEu6hObNx4WGjBCcaMtBjLshFDDNnYuA3C@IKhOSQtAxlKM2D3@B@eWSfHNWRTkGATowTo8IIaCU5yjFBj95cqINMjJzE1tLA/XTJK/uoRkA9xW2ubhFpNWBgN2/ipGdqOjzBKL86BTt/hnhJYT5vC5qItiVxQDcjZPALfGJ1eKiUYn5HoBAx3UxlaFKpxc64bGgv9/6GMeUOYX2Bt2t0v3Kq93BCekdsc5a4ZmYCLwPm6PQd3mN1173Fi8MTMmdExtGdtjHd0z8IA3F8hEUzIb@o6YR@aw4tX5WLBEbkdwSgixb9vheLIUTxd5kJyB3sL2Gv@JDVXqxSgOyHLrZ6VqljwqvIqvRRyj71CIscybvN4vsvi3KvKXGjkjBwciRVCMs68nMtMr/GcNo2ontNnJOIyVZVRR9ln/wvGXYCfB@ScJGRmwlivVfHWf5KvaS6WPZXKjM96fTePVoVCkXiIeSRcF0PCTdyv@57iJZSPBPY2qV6skcJ4d/zIb27Oeii22ntTQkPvTELF3Y@ARO@ChOv0fv342XPcDZTd9RXt9/jgj4jvX9GxfzWGFfZ24/8G "JavaScript (Node.js) – Try It Online") This regex is [on GitHub](https://github.com/Davidebyzero/RegexGolf/blob/master/regex%20for%20dividing%20by%20sqrt2%2C%20with%20variable-length%20lookbehind.txt). ``` # Given an input number N in the domain ^x*$, this regex returns floor(N / sqrt(2)) (?= (x(x*)) # \1 = will be the square root of the main number, rounded down; \2 = \1 - 1 .*(?=\1*$) \2+$ ) # Step 1: Calculate N*N in base floor(sqrt(N))+1. Thanks to this choice of number base to work in, we'll be able to use the # second shortened form of division in all places where the number base is the divisor, because it's guaranteed to give the # correct quotient when the dividend is less than the squared divisor, and N itself is less than this. This form of division # can be recognized by its lazy rather than greedy matching of the quotient, and only one divisibility test following that. (?=(x\1)+(x?(x*))) # \3 = \1+1 = floor(sqrt(N))+1, the number base to work in; \4 = N % \3; \5 = \4-1, or 0 if \4==0 (?= \4 (x(x*?)) # \6 = floor(N / \3); \7 = \6-1 \1+$ ) (?= .* (?= (?=\4*$) # tail = \4 * \4 \4\5+$ ) (x*?)(?=\3*$) # \8 = (\4 * \4) % \3, the base-\3 digit in place 0 of the result for N*N (x?(x*?)) # \9 = floor((\4 * \4) / \3); \10 = \9-1, or 0 if \9==0 ( \1+$ | $\9 # must make a special case for \9==0, because \1 is nonzero ) ) (?= .* (?= (?=\4*$) # tail = \4 * \6; must do symmetric multiplication, because \4 is occasionally 1 larger than \6 (?=\6*$) (?=\4\7+$) \6\5+$ | $\4 # must make a special case for \4==0, because \6 might not be 0 ) (x*?)(?=\3*$) # \12 = (\4 * \6) % \3 (x?(x*?)) # \13 = floor((\4 * \6) / \3); \14 = \13-1, or 0 if \13==0 ( \1+$ | $\13 # must make a special case for \13==0, because \1 is nonzero ) ) (?= .*(?=\12\12\9$) # tail = 2 * \12 + \9 (x*?)(?=\3*$) # \16 = (2 * \12 + \9) % \3, the base-\3 digit in place 1 of the result for N*N (x?(x*?)) # \17 = floor((2 * \12 + \9) / \3); \18 = \17-1, or 0 if \17==0 ( \1+$ | $\17 # must make a special case for \17==0, because \1 is nonzero ) ) # {\6*\6 + 2*\13 + \17} = the base-\3 digit in place 2 of the result for N*N, which is allowed to exceed \3 and will always do so; # Note that it will be equal to N iff N is a perfect square, because of the choice of number base. # Step 2: Find the largest M such that 2*M*M is not greater than N*N # Step 2a: Calculate M*M in base \3 (?= .*? # Determine value of M with backtracking, starting with largest values first (?= ( # \20 = M (?=\3*(x?(x*)))\21 # \21 = M % \3; \22 = \21-1, or 0 if \21==0 (x(x*?)) # \23 = floor(M / \3); \24 = \23-1 \1+$ ) ) (?<= (?= (?= .* (?=\23*$) (\23\24+$) # \25 = \23 * \23 ) (?= .* (?= (?=\21*$) # tail = \21 * \21 \21\22+$ ) (x*?)(?=\3*$) # \26 = (\21 * \21) % \3, the base-\3 digit in place 0 of the result for M*M (x?(x*?)) # \27 = floor((\21 * \21) / \3); \28 = \27-1, or 0 if \27==0 ( \1+$ | $\27 # must make a special case for \27==0, because \1 is nonzero ) ) (?= .* (?= (?=\21*$) # tail = \21 * \23; must do symmetric multiplication, because \21 is occasionally 1 larger than \23 (?=\23*$) (?=\21\24+$) \23\22+$ | $\21 # must make a special case for \21==0, because \23 might not be 0 ) (x*?)(?=\3*$) # \30 = (\21 * \23) % \3 (x?(x*?)) # \31 = floor((\21 * \23) / \3); \32 = \31-1, or 0 if \31==0 ( \1+$ | $\31 # must make a special case for \31==0, because \1 is nonzero ) ) (?= .*(?=\30\30\27$) # tail = 2 * \30 + \27 (x*?)(?=\3*$) # \34 = (2 * \30 + \27) % \3, the base-\3 digit in place 1 of the result for M*M (x?(x*?)) # \35 = floor((2 * \30 + \27) / \3); \36 = \35-1, or 0 if \35==0 ( \1+$ | $\35 # must make a special case for \35==0, because \1 is nonzero ) ) # {\25 + 2*\31 + \35} = the base-\3 digit in place 2 of the result for M*M, which is allowed to exceed \3 and will always do so # Step 2b: Calculate 2*M*M in base \3 (?= .* (?=\26\26) # tail = 2*\26 (?=\3*(x*)) # \38 = (2*\26) % \3, the base-\3 digit in place 0 of the result for 2*M*M (\1(x)|) # \40 = floor((2*\26) / \3) == +1 carry if {2*\26} does not fit in a base \3 digit ) (?= .* (?=\34\34\40) # tail = 2*\34 + \40 (?=\3*(x*)) # \41 = (2*\34 + \40) % \3, the base-\3 digit in place 1 of the result for 2*M*M (\1(x)|) # \43 = floor((2*\34 + \40) / \3) == +1 carry if {2*\34 + \40} does not fit in a base \3 digit ) # 2*(\25 + 2*\31 + \35) + \43 = the base-\3 digit in place 2 of the result for 2*M*M, which is allowed to exceed \3 and will always do so # Step 2c: Require that 2*M*M <= N*N (?= (?= (.*) # \44 \13\13\17 (?=\6*$) # tail = \6 * \6 \6\7+$ ) \44 # tail = {\6*\6 + 2*\13 + \17}; we can do this unconditionally because our digits in place 2 are always greater than those in places 0..1 ( x+ | (?= .*(?!\16)\41 # \41 < \16 | (?!.*(?!\38)\8) # \38 <= \8 .*(?=\16$)\41$ # \41 == \16 ) ) (\25\31\31\35){2}\43$ # 2*(\25 + 2*\31 + \35) + \43 ) ) ^.* ) ) \20 |xx?\B| # handle inputs in the domain ^x{0,4}$ ``` --- # Regex (ECMAScript) I have not yet ported this algorithm to basic ECMAScript. One way to do it would be to use \$k=\lceil\sqrt[\uproot{1}3]N\rceil\$ as the number base, and calculate: $$N^2=(A k^2+B k+C)^2=A^2 k^4 + 2 A B k^3 + (2 A C + B^2)k^2 + 2 B C k + C^2$$ Another way would be to stick with \$k=\lceil\sqrt N\rceil\$, capture \$M\$ encoded into two or more backrefs, and emulate the existing calculations within the smaller available space. I'm not sure which way would be more concise. Either way, I expect the regex would roughly double in length. [Answer] # Python 3, ~~19~~ 17 bytes A different python answer ``` lambda x:x//2**.5 ``` *-2 bytes* thanks to @Mukundan [try it online](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaHCqkJf30hLS8/0f0FRZl6JRpqGoYGm5n8A) [Answer] # Scratch 3.0, ~~7~~ 5 blocks/~~62~~ 36 bytes [![enter image description here](https://i.stack.imgur.com/xE8Ez.png)](https://i.stack.imgur.com/xE8Ez.png) [Try it on~~line~~ Scratch!](https://scratch.mit.edu/projects/455881031/) As SB Syntax: ``` define(n say(round((n)/([sqrt v]of(2 ``` It's always fun to usual visual languages! At least I have built-ins this time. *-26 bytes thanks to @att* [Answer] ## JavaScript (ES6), 12 bytes ``` i=>i/2**.5|0 ``` Uses a binary or to truncate the result [Try it online!](https://tio.run/##dc5JCoAgFAbgfSfJIHN4Dpu6S0SFIRkZrrq7rePp9oN/OOY0x@V219Mnm7cxu3Fyg@g6ql6Wl3DG4Ffqw95uLSOk@QtHIpBIJIBE4WY8JnG3YoVPrIJFtxoADNe1RCkkOBiwUoMhJH8) [Answer] # 8087 FPU machine code, 11 bytes Unassembled listing: ``` D9 E8 FLD1 ; load a 1 constant (need to make a 2) D8 C0 FADD ST, ST(0) ; ST = 1+1 = 2 D9 FA FSQRT ; ST = SQRT(2) DE F9 FDIVP ST(1), ST ; ST = N / ST DF 1F FISTP QWORD PTR [BX] ; *BX = ROUND(ST) C3 RET ; return to caller ``` Input in `ST0`, as a 80-bit extended precision value, output to `QWORD PTR [BX]`. Floating point operations done in x87 math coprocessor hardware with 80-bit extended precision. Correctly calculates values of `N` up to `13043817825332782211`, after which the result will exceed \$2^{63}-1\$ (overflowing a 64-bit signed integer return variable). Example test program with I/O: [![enter image description here](https://i.stack.imgur.com/ygVz3.png)](https://i.stack.imgur.com/ygVz3.png) (Test program now with 64 bit I/O routines thx to suggestions from @PeterCordes) Thanks to @PeterCordes for the suggestion take input in `ST(0)`, saving 2 bytes. [Answer] # Java 8, 18 bytes ``` n->n/=Math.sqrt(2) ``` Limited to a maximum of \$9{,}223{,}372{,}036{,}854{,}775{,}807\$ (signed 64-bit integer). [Try it online.](https://tio.run/##PZDBcoIwEIbvPsWOJxiRhiQkRMc@QfTi0fGQItpYDBainY7Ds9MFtJfd7Ld/9s/mbO5mfj58dXlpmgbWxrrHBMA6X9RHkxew6UuAsnInyIMhuXCJrJ1gaLzxNocNOFhB5@bv7m21Nv4zbr5rH9CwW/aq6@2jRNVTfK/sAS5oFGx9bd1ptwcTji7Hqh4tLCzAFT@D7W7/IDpKdER1xHTEdZRiiYghSEnfI684HjLBOZeJ@GcDpgmXPGOCS7xKmETIlcKBVHElJFU4lqeEpUoJKrGPVEeKUsYkJUxkKZcyzYjUbTi8FmD72/jiElc3H19xFV@6wM6mC5jOXJwHNnx@VNv9AQ) **Explanation:** ``` n-> // Method with long as both parameter and return-type n/= // Divide the input by: Math.sqrt(2) // The square-root of 2 // The `/=` sets the divided result back to `n`, which implicitly casts the resulting double // back to long. This saves bytes in comparison to `n->(long)(n/Math.sqrt(2))` ``` # Java 9, ~~76~~ 74 bytes ``` n->n.divide(n.valueOf(2).sqrt(new java.math.MathContext(n.precision())),4) ``` -2 bytes thanks to *@OlivierGrégoire*. Arbitrary I/O and precision. [Try it online.](https://tio.run/##fVFNbxshEL3nV4z2BApBfAywNEoOaa9JDzlWOdD1OsFds84udltV@e3u2HHVqKrCYRCP4b3HvFXapYvV4tu@G9I8w23K5dcZQC61n5ap6@HucARYUZ9cp/okb/Ljp77L6zRAx/4LF35Jb17OqMw11dzBHRS4gn25uC5ykXd50bMid2nY9p@XzHA5P0@Vlf77G5lbKh9HsvGDbuRmIu45j4VxzgXy/eWBfbP9OhD7SWQ35gWs6QPsvk65PH55gMRf3S/H6QRChg/QKKGFEVagcEIrYY1wijB1Kse99YgYtP@DHECjMWBrPQZhlQ0EYYwCTcTog4lOoFPWxehNoFsCRTTG2mCU9a3DEFyrAlEj@oCoDk3ROe21e6Py3hLRedOSBxW1boPRVocW2@h18MYhSXlrrbPx2KDJnScZRIu2tY2cN0OurBEN58e5ANz/nGu/luO20owp9aGwfN7QiM6L7P6J5G/ELFMMryG/7H8D) **Explanation:** ``` n-> // Method with BigDecimal as both parameter and return-type n.divide( // Divide the input by: n.valueOf(2) // Push a BigDecimal with value 2 .sqrt( // Take the square-root of that new java.math.MathContext(n.precision())), // with the same precision as the input 4) // With rounding mode HALF_UP ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 15 bytes ``` ³²:2_²:Ẹ¡:2+µƬṪ ``` [Try it online!](https://tio.run/##Hcq9DYNADAbQgWiwP59/WCZVGnQLME7aiAqElKS8InvcJAbRvOrNz1qXzLa3beLHRf992mvioR3/tX/fmRlF2U18DCI3JpC5eCiZchHAFEBB3IEkQmU0EQgcJw "Jelly – Try It Online") An arbitrary precision Jelly answer that uses the [Newton-Raphson](https://en.wikipedia.org/wiki/Newton's_method) method to find the correct answer. Uses only integer arithmetic operations so the intermediate values are all Python big ints rather than getting cast as floats which would lose precision. The integer result equates to the floor of what would be the floating point answer. A full program that takes a (possibly negative) integer as its argument and returns an integer. Now correctly handles inputs of 0 and 1; previously threw an error because of division of 0 by 0 being impermissible for integers. Useful comment from @PeterCordes about efficiency of this method and some detail on Python’s big integer implementation: > > Newton-Raphson converges quickly, like twice as many correct bits per iteration, given a decent first estimate. e.g. [one step refines a 12-bit-precision rsqrtps(x) FP result into nearly 24-bit.](https://stackoverflow.com/q/14752399) (In this case apparently the original input is close enough). You only pay Python interpreter overhead per operation, not per limb (aka chunk) of a very long number; extended-precision division is not cheap but it is implemented in C on chunks of 2^30 stored in an array of 32-bit integers. (I forget if Python uses 64-bit on 64-bit machines.) > > > ## Explanation ``` µƬ | Do the following as a monad until no new values seen, collecting up the intermediate values: ³ | - Original argument to program ² | - Squared :2 | - Integer divide by 2 _² | - Subtract current estimate squared Ẹ¡ | - If non-zero: : | - Integer divide by current estimate :2 | - Integer divide by 2 + | - Add to current estimate Ṫ | Finally, take the tail of the list of estimates ``` Note `Ẹ¡` is literally repeat the number of times indicated by applying the any function to current value, but it is effectively used here to mean if non-zero. A much shorter answer that is only accurate to float precision is: # [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes ``` 2½:@ ``` [Try it online!](https://tio.run/##y0rNyan8/9/o0F4rh////xsaGZsAAA "Jelly – Try It Online") [Answer] # Regex (.NET), ~~106~~ 90 bytes `(?=(x*)(\1x?))(x*).*$(?<=(?=(?<-5>x)*\1(?<=\3))^\2((?<=(?=\6?(\3)*(?<=(?=\3$)(x*))).*)x)*)` [Try it online!](https://tio.run/##ZVJda9swFH3fr1BDwVJiC9uhe4iieBDGGLR0LIU9NB2ojpIIZMmR7MyNm9e@b2Nv@3X5I5lsJ2VQP92rcz/OOdepDVJt@FGxjNucpRzMnmzBs7q0Qq3AlE61slpy0uV3vCrwV74qJTMfq9xwa4UrIKlk1oKstgUrRAq2WizADRMKQFRvmQGWfugdYUJh1UdwHlUJQk2I@5cwGdMGSMbB1aRC/XnUvMyHCH2fx/CEzt8n0D31z@nwsm1HbgByPejYI80WQxX/ARw9XkGLZ@WjLYxjDSPf4muuVsU6iJHf4rd50RDHU53lQvIFIgtdPkoONjG9YcUazzamgPgKkW4GkGSpDRSqAIqGBEo6dT6wxbVQHCJ0QVUpJVE0QrVYQjUJ0RR/M6LgXUFLL6cSz3IpCugFHiLNLOFz8s415Cd@k/j5@cIB@M48fWHGcpjfhw@@Ll0pegud24Koq@HovBb2Pqstk@4MhqkVH4E63Pd8iQiXlrcnqVqzZp1DXuX5Ar1K3DmJYkw5EYOBXw2og1HtbEnXIKMGtxGsnIQlzJzPaer@g1b47o3wHY2cQjdT0wx/MrrM7f3w4cTbBxvaLERQ9DfuNGDzfz4IG//Bq6I63jcywOHlF6gjJ0f42teUbhLv8PLbGzXhIGqSn97IO/z940zed98xDOIw/Ac "C# (.NET Core) – Try It Online") Takes its input in unary, as a sequence of `x` characters whose length represents the number. Returns its output in group `\3`. By the very nature of this solution, its best-golfed form rounds arbitrarily – sometimes up, sometimes down. As such, it's more complicated to explain why it works, so I suggest reading the explanation of the **104 byte** always-round-down solution below first. (This is oddly appropriate, given the order of operations in regexes that use right-to-left evaluated variable-length lookbehind.) Compared to the always-round-down solution, this regex takes a shortcut. Instead of counting the number of times the anti-remainder was subtracted, it uses \$\lfloor{N\over 2}\rfloor\$ in place of that count. For even values of \$N\$ this is \$1\$ greater than the actual number of times the anti-remainder was subtracted (since it's never subtracted on the first iteration, and always subtracted on each subsequent iteration). As such, sometimes it doesn't change the resulting returned value \$M\$, but sometimes it results in finding an \$M\$ that is \$1\$ greater than the value it would otherwise have, i.e. \$\lceil{N\over\sqrt 2}\rceil\$ instead of \$\lfloor{N\over\sqrt 2}\rfloor\$. For odd values of \$N\$, adding \$1\$ to that count effectively simulates the extra loop iteration done on \$\lfloor{N\over 2}\rfloor\$ in the always-round-down regex. The thing is, without actually doing that, we don't know whether the final value of the anti-remainder was greater than \$\lfloor{N\over 2}\rfloor\$ or not. Iff it was greater, then the anti-remainder subtraction count wouldn't have been incremented by \$1\$. Thus, by unconditionally effectively adding that \$1\$, we're doing the same thing for odd \$N\$ as we are for even \$N\$ – giving a return value of \$M\$ that is arbitrarily rounded up or down. ``` # tail = N = input number (?= (x*) # \1 = floor(N / 2) (\1x?) # \2 = ceil(N / 2) ) (x*) # \3 = guessed value of round(sqrt(N*N/2)) - may be rounded up or down .*$ # tail = 0; head = N (?<= # head = 0 (?= (?<-5>x)* # head += \5.capture_count \1 # head += \1; this is 1 more than the actual number of times # \6 was subtracted, which will change the \3 result for some # even values of N from rounded-down to rounded-up. But for # odd values of N, it simulates subtracting \6 from the last # half-chunk, which is not covered in the loop we did. Note # that depending on the final value of \6, it may be <= \1, # in which case we'll get a rounded-down \3, or > \1, in which # case we'll get a rounded-up \3. (?<=\3) # assert head ≥ \3 ) ^\2 # force the loop below to iterate \1 times; head = 0 ( (?<= # tail = N (?= \6? # tail -= \6, if \6 is set (\3)* # X = floor(tail / \3); tail -= \3*X; \5.capture_count += X; # note that in practice, 0 ≤ X ≤ 1; # Y = tail = remainder (?<= (?=\3$) # assert tail == \3 (x*) # \6 = \3 - Y ) ) .* # tail = N ) x # head -= 1; tail += 1 )* ) ``` # Regex (.NET), ~~166~~ ~~104~~ 99 bytes `(?=(x*)(\1x?))(x*).*$(?<=(?=(?<-5>x)*(?<=\3))^\1(x(?<=(?=(\6)?(?<5>\3)*(?<=(?=\3$)(x*)))(.+\2)?))*)` [Try it online!](https://tio.run/##ZVLRatswFH3fV6ihYMmxhe2QPdRRPAhjDFo2lsIe6g5UR0kEsmxLcufGzWs/YGNv@7r8SCbbSRlUT/fqXJ17z7nKtJ8Vih0lzZkuacbA8kkblre15nIDFmRRSF0IFg/5LWsM/sY2taDqY1MqpjW3BXEmqNYgb7WhhmfgseArcEO5BBC1j1QBTT6MjjAhsHERTMMmQagLsXsJkxnpgGTmT@cNcrs8nSD0Iw1hcwbT9yix8XRuEfd0mU4uew7LhMdphCyli46juGuniGQ/gZ2TNVDjZf2gjbLjw9DT@JrJjdn6EfJ6/EtpOgV4UeQlF2yF4lVRPwgGqojcULPFy0oZiKcoHjiAiNeFglwaIEkQQ0EW1hC6uuaSQYQuiKyFiCUJUcvXUM4DtMDfFTdsKOjHK4nAy1JwAx3fQXHHxT0Wv7MPytN88@j5@cIC@FY9faVKM1jeBfdeUdtS9BY6P/PDoYahc1s4@iwfqbD7UFRu2BVog/3IEyhmQrN@N01v1nJwyGkcj6NXiTsrkc8Ii/l47DVjYmHUWluyLciJwn0EGythDXPrc5bZD9EL370RviOhVWg5C5LjT6qoS303uT/N7YGKdA0R5G5lVwOq//Nx0PkPXhW10b6TAQ4vv0AbWjncK7yCkCpxDi@/nSvn8PeP9XU/nGPgR0HwDw "C# (.NET Core) – Try It Online") Takes its input in unary, as a sequence of `x` characters whose length represents the number. Returns its output in group `\3`. This solution always rounds down, returning \$M=\lfloor{N\over\sqrt 2}\rfloor\$. It accomplishes this by calculating \$M=\lfloor\sqrt{N^2\over 2}\rfloor\$, which is done by searching for the largest value of \$M\$ for which \$\lfloor{{N^2\over 2}/M}\rfloor\ge M\$. A regex can't directly operate on values larger than the input, so this must be done by looping multiple times over \$N\$ instead of directly operating on \$N^2\$. For even values of \$N\$ this is straightforward enough; we just loop over \$N/2\$ copies of \$N\$, subtracting \$M\$ from it as many times as will fit (which will be \$0\$ or \$1\$), taking note of the remainder, and then subtracting the corresponding "anti-remainder" (the remainder's difference from \$M\$) at the beginning of the next loop iteration. Then the value of \$\lfloor{{N^2\over 2}/M}\rfloor\$ is the sum of the number of times \$M\$ was subtracted and the number of times the anti-remainder was subtracted. This works because for even \$N\$, we have \$\lfloor{N^2\over 2}\rfloor = \lfloor{N\over 2}\rfloor N\$. For odd values of \$N\$, we do the above, but then do \$1\$ extra loop iteration, subtracting from \$\lfloor{N\over 2}\rfloor\$ instead of \$N\$. This works because for odd \$N\$, we have \$\lfloor{N^2\over 2}\rfloor = \lfloor{N\over 2}\rfloor N + \lfloor{N\over 2}\rfloor\$. The number of times \$M\$ and the anti-remainder were subtracted are counted using the .NET feature of balanced groups, with `(?<-5>x)*` below. ``` # tail = N = input number (?= (x*) # \1 = floor(N / 2) (\1x?) # \2 = ceil(N / 2) ) (x*) # \3 = guessed value of floor(sqrt(N*N/2)) .*$ # tail = 0; head = N (?<= # head = 0 (?= (?<-5>x)* # head += \5.capture_count (?<=\3) # assert head ≥ \3 ) ^\1 # force the loop below to iterate \2 times; head = 0 ( x # head -= 1; tail += 1 (?<= # tail = \1 if N is odd and this is the last iteration, or N otherwise (?= (\6)? # if \6 is set: tail -= \6; \5.capture_count += 1 (?<5>\3)* # X = floor(tail / \3); tail -= \3*X; \5.capture_count += X; # note that in practice, 0 ≤ X ≤ 1; # Y = tail = remainder (?<= (?=\3$) # assert tail == \3 (x*) # \6 = \3 - Y ) ) (.+\2)? # unless N is odd and this is the last iteration: head = 0; tail = N; # else: head = \2; tail = \1 ) )* ) ``` This algorithm would not work on a regex flavor lacking variable-length lookbehind (and lookinto), because to loop more than once with a count that scales with \$N\$, the regex needs to subtract at least \$1\$ from \$tail\$ on each iteration (a zero-width loop iteration would result in terminating the loop). Without lookbehind/lookinto, it would be impossible to operate directly on \$N\$ after the first iteration. And once the current value of \$tail\$ went below the currently tested value of \$M\$, it would no longer be possible to operate on the value of \$M\$ in any way. Thus forward-declared backreferences, while required by this algorithm, aren't enough on their own. So, a regex flavor with forward-declared backreferences but no variable-length lookbehind (or lookinto) could probably use an algorithm based on this one, but additional tricks would have to be used to emulate operating on larger numbers. I'm pretty sure it would not have to use the full-fledged algorithm of my [ECMAScript solution](https://codegolf.stackexchange.com/a/198428/17216), but I haven't worked out the details yet. # Regex (PCRE+`(?^=)`[RME](https://github.com/Davidebyzero/RegexMathEngine)), 81 bytes ``` (?=(x*)(\1x?))(x*)(?^1=(x(?^=\8?(\3(?^=(\6?x)))*(x*)(?^3=\7(x*))))*)(?^3!\6?+\1x) ``` [Try it on replit.com!](https://replit.com/@Davidebyzero/regex-Shift-left-half-a-bit-PCRE-round-any) This is a port of the 90 byte .NET regex that rounds arbitrarily. It uses features available in PCRE, in addition to **lookinto**, a feature just added to [RegexMathEngine](https://github.com/Davidebyzero/RegexMathEngine/). The fact that even after converting the use of .NET balancing groups to group-building, this regex is still 9 bytes smaller than the .NET version, demonstrates just how much expressibility is available with lookinto. The regex is also much easier understand in this form. (Lookinto is equal in power to variable-length lookbehind, i.e. there's nothing one can do that the other can't.) ``` # tail = N = input number (?= (x*) # \1 = floor(N / 2) (\1x?) # \2 = ceil(N / 2) ) (x*) # \3 = guess for round(sqrt(N*N/2)) - may be rounded up or down (?^1= # Lookinto: tail = \1 ( x # tail -= 1 (?^= # Atomic lookinto: tail = N \8? # tail -= \8, if \8 is set # X = floor(tail / \3); tail -= \3*X; \6 += X; # Note that in practice, 0 ≤ X ≤ 1 ( \3 # Assert tail ≥ \3; tail -= \3 (?^= ( # \6 = sum of the following: \6? # previous value of \6 if set, 0 otherwise x # 1 ) ) )* # Match the above as many times as possible, minimum 0 (x*) # \7 = tail = remainder = dividend % \3 (?^3= # Atomic lookinto: tail = \3 \7 # tail -= \7 (x*) # \8 = tail = \3 - \7 ) ) )* # Iterate as many times as possible, which will be exactly \1 ) (?^3! # Negative lookinto: tail = \3 # Assert \3 ≤ \6 + \1 (outside the negative lookinto), by asserting here # that tail ≥ \6 + \1 + 1. \6?+ # Take advantage of the fact that it is guaranteed \6 ≤ \3, # meaning we don't have to use "(?(6)\6)". \1x # Note that \6 + \1 is 1 more than the actual number of times \8 was # subtracted, which will change the \3 result for some even values of N # from rounded-down to rounded-up. But for odd values of N, it simulates # subtracting \8 from the last half-chunk, which is not covered in the loop # we did. Note that depending on the final value of \8, it may be ≤ \1, in # which case we'll get a rounded-down \3, or > \1, in which case we'll get # a rounded-up \3. ) ``` # Regex (PCRE+`(?^=)`[RME](https://github.com/Davidebyzero/RegexMathEngine)), ~~123~~ ~~113~~ ~~96~~ 95 bytes `(?=(x*)(\1x?))(x*)(?^=((?=(\2$|))x(?^=((?^=(\7?x))(^\10|\3))*\5(x*)(?^3=\9(x*))))*\1(?^7=\3)|$)` [Try it on replit.com!](https://replit.com/@Davidebyzero/regex-Shift-left-half-a-bit-PCRE-round-down) This is a port of the 99 byte .NET regex that rounds down. ``` # tail = N = input number (?= (x*) # \1 = floor(N / 2) (\1x?) # \2 = ceil(N / 2) ) (x*) # \3 = guess for floor(sqrt(N*N/2)) (?^= # Atomic lookinto: tail = N ( (?=(\2$|)) # \5 = \2 if tail == \2, 0 otherwise; # Note that if tail==\2, it means this is the last iteration # if N is odd – but if N is even, this iteration will fail to # match, as the last iteration will have already finished. x # tail -= 1 (?^= # Atomic lookinto: tail = N # if \10 is set: tail -= \10; \7 += 1; # X = floor((tail - \5) / \3); tail -= \3*X; \7 += X; # Note that in practice, 0 ≤ X ≤ 1 ( (?^= ( # \7 = sum of the following: \7? # previous value of \7 if set, 0 otherwise x # 1 ) ) ( ^\10 # On the first iteration, if \10 is set, tail -= \10 | \3 # Assert tail ≥ \3; tail -= \3 ) )* # Match the above as many times as possible, minimum 0 \5 # tail -= \5 (x*) # \9 = tail = remainder = dividend % \3 (?^3= # Atomic lookinto: tail = \3 \9 # tail -= \9 (x*) # \10 = tail = \3 - \9 ) ) )* \1 # Assert tail ≥ \1, forcing the loop above to iterate \2 times (?^7= # Lookinto: tail = \7 \3 # Assert \3 ≤ tail, i.e. \3 ≤ \7 ) | $ # or N == 0, in which case the output = the input; this needs to be # a special case because "(?^7=...)" cannot match if \7 is unset. ) ``` [Answer] # [dc](https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html), 5 bytes ``` d*2/v ``` [Try it online!](https://tio.run/##HcrJEYAwDAPAfvgQWfJVDymAV9o3M@x79zPtYZWq1UClgchSdSDDXGQGSWf/AeoOrZQoFmdfdp955wM "dc – Try It Online") Takes input and leaves output on the stack. dc automatically uses arbitrary-precision integers, and supports a precision of 0 decimal places by default, thus automatically "rounding". So taking the square-root of 2 will yield 1. Instead, this solution squares the input, by `d`uplicating it and `*` multiplying both the items at the top of the stack, `/` dividing it by `2` (reverse-polish) and takes the `v` square root of that. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes ``` 2t÷ ``` [Try it online!](https://tio.run/##yy9OTMpM/f/fqOTw9v//DQ0A "05AB1E – Try It Online") -1 byte thanks to @Grimmy Yet another port of my Keg answer for the sake of completion. ## Explained ``` 2t÷ 2t # Push the square root of two ÷ # Integer division ``` 🍟🍅 Still no ketchup. [Answer] # [Japt](https://github.com/ETHproductions/japt), 3 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ``` z2q ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=ejJx&input=NTAw) `z` is the floor division method and `q` is the nth-root method, defaulting to square root when it's not passed an argument. [Answer] # Mathematica, ~~17~~ ~~14~~ 13 bytes / ~~12~~ 7 characters ``` ⌊#/√2⌋& ``` [Try it online](https://tio.run/##y00syUjNTSzJTE78n2b7Pyi/NC8lWln/Uccso1i1/wFFmXkl0WnRhgbEgNjY/wA) -3 bytes because Mathematica accepts the char √, which I copied from [this](https://codegolf.stackexchange.com/a/198438/75323) MathGolf answer. -1 byte, -5 characters, as per @Mark S. suggestion, by using `⌊⌋`. For just one more byte (but 5 more characters) I can always round to the nearest integer with ``` Round[#/√2]& ``` [Answer] # TI-BASIC, 5 bytes ``` int(Ans√(2⁻¹ ``` Built-ins are great. Input is a number in `Ans`. Output is what is specified in the challenge. **Explanation:** ``` √(2⁻¹ ;get the square root of 1/2 Ans ;get the input (Ans) ;implicit multiplication int( ;truncate ;implicit print of Ans ``` --- **Note:** TI-BASIC is a tokenized language. Character count does *not* equal byte count. [Answer] # [C (gcc)](https://gcc.gnu.org/) -lm, ~~23~~ \$\cdots\$ ~~50~~ 27 bytes Saved 6 bytes thanks to [a'\_'](https://codegolf.stackexchange.com/users/85052/a)!!! Added 38 bytes to fix type error kindly pointed out by [S.S. Anne](https://codegolf.stackexchange.com/users/89298/s-s-anne). Saved 3 bytes thanks to [rtpax](https://codegolf.stackexchange.com/users/85545/rtpax)!!! ``` #define f(n)ceil(n/sqrt(2)) ``` [Try it online!](https://tio.run/##fVJtb4IwEP7ur7iwmIDWWEpLIc59WfYrpllMKY4Mq6OYkRn/@tjxInFLlISj99xz1@fuULOtUnX9kOg0MxpS13hKZ7lr5vazKF3mefVukxnXg9MI8Dkam22NTiDfm21nSm3LN/O6hiXGT5SAT4ARCAhwAgJdhAIEBG1i9GK7QxRyzqUfDlgLM59LHgUhl5hKA4kgj2MsyGIeh5LFWJYLGog4DpnEOKLnxS2BujpoVeqklfhHYKcxIgCs8QQ6kjaupNKneDn4gY86gibcYqGMWAMLP8J@mLgWGw1i21YxkwsmMMJCFkUXgep9U0zQavWhi06Ss6pe2KqKn/EVDoFrP3D6vHRfgJuZEjKT6ArT6KI/PoLNvvU@dS@NevMemAzIAqbTln1Z5I1ZGSzcL7Slrxf32BbZzS9zl6SRNKzgf9FDgS2lrjPO8yPMnqD9ju3K4BgMAUuGSdnlUq/7m86jc/2j0nyztfUs39Wzr18 "C (gcc) – Try It Online") [Answer] # [Brainlove](https://esolangs.org/wiki/Brainlove), 73 70 74 61 35 bytes ### Because brainfuck is too hard -3 bytes by myself, rearranging the memory and fixing some bugs +4 bytes by myself, fixing an error -13 bytes by myself -26 bytes by myself, actually using the Brainlove features properly. ``` [$[->+<]!-]+>[<$[>[-~]<-]!++>>+<]>- ``` [Try it online](https://tio.run/##lYwxCsNAEAPfYnDhQ2xeIPQRsUUCKQIhgRQp7@uX9RncZ6odidXtc328nu/vfWAyvDoE5hIJmavl6MnIBdBeKAYdKWyEorcwLJw4GJviRJKVMJM0DuOhyd5UQ3VJUY81qJlbO1UUPadsQG/GX9SYL8zxAw) First computes the sum $$ S = \sum\_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum\_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that. The input and output are on position 0 and 2 on tape, respectively. [Answer] # [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 5 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set") Full program. Prompts stdin for zero or more numbers. ``` ⌈⎕÷√2 ``` [Try it online!](https://tio.run/##NcuxDcIwFATQPlP8BSLZ3/f94wWoIzaIFIsmghQU0COIBEI0NCzCAGziRYwTwRV30pOuG4e6P3bDblPHwz5u@9jndH@u1un8sNwopeuJCrRtAYcqTZcxp9tU6PNO04tzkUxLxsqQJSZHICFryDGJKWZ@tWzjAaj1f5mRLRSN81ACBwSvHIQgxkkIntWpKVi@gFfAzBBErLdCXw "APL (Dyalog Extended) – Try It Online") `⌈` ceiling of `⎕` console input `÷` divided by `√` the square root of `2` two [Answer] # [Pyth](https://github.com/isaacg1/pyth), 6 bytes The division *auto-casts* the number to a decimal!? (In seriousness, is there a square root function in Pyth?) ``` /Q@2 2 ``` [Try it online!](https://tio.run/##K6gsyfj/Xz/QwUjB6P9/UwMDAA "Pyth – Try It Online") # Explanation ``` @2 2 to the power of 2 1/2 (effectively calculates math.sqrt(2)) /Q Divide the (evaluated) input by that number ``` [Answer] # [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), ~~122~~ 103 bytes ``` [S S T T N _Push_-1][S S S N _Push_0][S N S _Dupe_0][T N T T _Read_STDIN_as_integer][T T T _Retrieve_input][S N S _Dupe_input][N T S T N _If_0_Jump_to_Label_ZERO][N S S N _Create_Label_LOOP][S N T _Swap_top_two][S S S T N _Push_1][T S S S _Add][S N T _Swap_top_two][S N S _Dupe_input][S N S _Dupe_input][T S S N _Multiply][S T S S T S N _Copy_0-based_2nd_n][S N S _Dupe_n][T S S N _Multiply][S S S T S N _Push_2][T S S N _Multiply][S N T _Swap_top_two][T S S T _Subtract][N T T N _If_neg_Jump_to_Label_LOOP][S N T _Swap_top_two][N S S T N _Create_Label_ZERO][T N S T _Print_as_integer] ``` Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only. `[..._some_action]` added as explanation only. [Try it online](https://tio.run/##LYvRCYBADEO/kykywjmSyIH3Jyg4fm1aUygvJHnP9cz72o8ZIQGUxDwQlhlpqCY5kDuO3PsfemVXBj1ADWBkYXYitlH6AA) (with raw spaces, tabs and new-lines only). Output is rounded up. Inspired by the following mentioned in [*@Deadcode*'s Regex answer](https://codegolf.stackexchange.com/a/198428/52210): > > For input \$N\$, we want to calculate \$M=\left\lfloor\frac{N}{\sqrt2}\right\rfloor\$. So we want the largest \$M\$ such that \$2M^2<N^2\$. > > > EDIT: My program now implements \$2M^2\leq N^2\$ instead to save 19 bytes (\$\lt\$ vs \$\leq\$ is irrelevant, otherwise \$\sqrt{2}\$ would be rational). Although I see *@Deadcode* edited his Regex answer and he's actually using \$\leq\$ as well. **Explanation in pseudo-code:** ``` Integer n = -1 Integer input = STDIN as integer Start LOOP: n = n + 1 If(n*n*2 - input*input < 0): Go to next iteration of LOOP Print n (exit program with error since no exit is defined) ``` **Example program flow ([input `4`](https://tio.run/##LYvRCcBADEK/dQqH6EKlHFz/Dq7Q8dOYNEJ4or7zfsZe5zUiJICSmALhMyMN1SQHcseRe/9Dr@zKoAeoAYwszE7E8QE)):** ``` Command Explanation Stack Heap STDIN STDOUT STDERR SSTTN Push -1 [-1] SSSN Push 0 [-1,0] SNS Duplicate 0 [-1,0,0] TNTT Read STDIN as integer [-1,0] [{0:4}] 4 TTT Retrieve from heap #0 [-1,4] [{0:4}] SNS Duplicate 4 [-1,4,4] [{0:4}] NTSTN If 0: Jump to Label ZERO [-1,4,4] [{0:4}] (^ workaround for input=0, since it would otherwise output -1) NSSSN Create Label LOOP [-1,4] [{0:4}] SNT Swap top two [4,-1] [{0:4}] SSSTN Push 1 [4,-1,1] [{0:4}] TSSS Add top two: -1+1 [4,0] [{0:4}] SNT Swap top two [0,4] [{0:4}] SNS Duplicate 4 [0,4,4] [{0:4}] SNS Duplicate 4 [0,4,4,4] [{0:4}] TSSN Multiply top two: 4*4 [0,4,16] [{0:4}] STSSTSN Copy 0-based 2nd [0,4,16,0] [{0:4}] SNS Duplicate 0 [0,4,16,0,0] [{0:4}] TSSN Multiply top two: 0*0 [0,4,16,0] [{0:4}] SSSTSN Push 2 [0,4,16,0,2] [{0:4}] TSSN Multiply top two: 0*2 [0,4,16,0] [{0:4}] SNT Swap top two [0,4,0,16] [{0:4}] TSST Subtract top two: 0-16 [0,4,-16] [{0:4}] NTTN If neg: Jump to label LOOP [0,4] [{0:4}] SNT Swap top two [4,0] [{0:4}] SSSTN Push 1 [4,0,1] [{0:4}] TSSS Add top two: 0+1 [4,1] [{0:4}] SNT Swap top two [1,4] [{0:4}] SNS Duplicate 4 [1,4,4] [{0:4}] SNS Duplicate 4 [1,4,4,4] [{0:4}] TSSN Multiply top two: 4*4 [1,4,16] [{0:4}] STSSTSN Copy 0-based 2nd [1,4,16,1] [{0:4}] SNS Duplicate 1 [1,4,16,1,1] [{0:4}] TSSN Multiply top two: 1*1 [1,4,16,1] [{0:4}] SSSTSN Push 2 [1,4,16,1,2] [{0:4}] TSSN Multiply top two: 1*2 [1,4,16,2] [{0:4}] SNT Swap top two [1,4,2,16] [{0:4}] TSST Subtract top two: 2-16 [1,4,-14] [{0:4}] NTTN If neg: Jump to label LOOP [1,4] [{0:4}] SNT Swap top two [4,1] [{0:4}] SSSTN Push 1 [4,1,1] [{0:4}] TSSS Add top two: 1+1 [4,2] [{0:4}] SNT Swap top two [2,4] [{0:4}] SNS Duplicate 4 [2,4,4] [{0:4}] SNS Duplicate 4 [2,4,4,4] [{0:4}] TSSN Multiply top two: 4*4 [2,4,16] [{0:4}] STSSTSN Copy 0-based 2nd [2,4,16,2] [{0:4}] SNS Duplicate 2 [2,4,16,2,2] [{0:4}] TSSN Multiply top two: 2*2 [2,4,16,4] [{0:4}] SSSTSN Push 2 [2,4,16,4,2] [{0:4}] TSSN Multiply top two: 4*2 [2,4,16,8] [{0:4}] SNT Swap top two [2,4,8,16] [{0:4}] TSST Subtract top two: 8-16 [2,4,-8] [{0:4}] NTTN If neg: Jump to label LOOP [2,4] [{0:4}] SNT Swap top two [4,2] [{0:4}] SSSTN Push 1 [4,2,1] [{0:4}] TSSS Add top two: 2+1 [4,3] [{0:4}] SNT Swap top two [3,4] [{0:4}] SNS Duplicate 4 [3,4,4] [{0:4}] SNS Duplicate 4 [3,4,4,4] [{0:4}] TSSN Multiply top two: 4*4 [3,4,16] [{0:4}] STSSTSN Copy 0-based 2nd [3,4,16,3] [{0:4}] SNS Duplicate 3 [3,4,16,3,3] [{0:4}] TSSN Multiply top two: 3*3 [3,4,16,9] [{0:4}] SSSTSN Push 2 [3,4,16,9,2] [{0:4}] TSSN Multiply top two: 9*2 [3,4,16,18] [{0:4}] SNT Swap top two [3,4,18,16] [{0:4}] TSST Subtract top two: 18-16 [3,4,2] [{0:4}] NTTN If neg: Jump to label LOOP [3,4] [{0:4}] SNT Swap top two [4,3] [{0:4}] NSSTN Create Label ZERO [4,3] [{0:4}] TNST Print as integer to STDOUT [4] [{0:4}] 3 error ``` Program stops with an error because no exit is defined. [Answer] # [C (gcc)](https://gcc.gnu.org/), Precision limited by built-in types, ~~42~~ 36 bytes ``` __int128 f(__int128 n){n/=sqrtl(2);} ``` [Try it online!](https://tio.run/##nY5fa8MgFMXf/RSSUVDoOv9cNdJun6CveyuUEZtMyMzWJHsp/eyZKeniuj3tgnI4/s49FvdVUQzDfu9Dx0WOS/ItAz2Fh8f249jVRND1ebjzoah7d8CbtnO@Wb0@IRRZ/PbiA/lsvKPohHCc92O0S5It3C7852SXLdNki3q0k6uPxDJFSKyjJWF0eZV8lmKWcpYwS5XEkhUyCSoWH/5o5IylpewyiZFrADBc/2J@YIKDgVxqMDcldROq8SdMmhgAa8fMZIKwYLURVqWmYlJZq4WJifh8s68Pra/CweEJ5zmANgBsxK1SXHP1vN1Sukbn4Qs "C (gcc) – Try It Online") Floor for the most part but the last output is ceiling. Uses GCC's `__int128` type: shorter in text length than `unsigned long`, can represent every value in `unsigned long`, and determined to not be a builtin type. Stay tuned for 6-8 weeks to get arbitrary precision. *-6 bytes thanks to [Peter Cordes](https://codegolf.stackexchange.com/users/30206/peter-cordes)!* [Answer] ## [wx](https://github.com/w-golflang/w), 3 bytes It's [W](https://github.com/a-ee/w), with just one instruction added: square root. Turns out that this is very useful! (P.S. the built-in was added before the challenge.) ``` 2Q/ ``` ## Explanation ``` 2Q % Find the square root of 2 a / % Divide the input by it % If one operand is an integer, % the program will automatically % try to trunctuate to an integer ``` [Answer] # [PHP](https://php.net/), 17 bytes ``` <?=$argn/2**.5|0; ``` [Try it online!](https://tio.run/##K8go@P/fxt5WJbEoPU/fSEtLz7TGwPp/anJGvoJSTF5Mnoaff4irlUJ@nkJJRmaxQnFlcUlqro5CbmKFQmZeiUJmsZWCkl6AR0C8p19IvK9jhJ6SppL1fxNTA2NTS0szI3NjcwMTS7N/@QUlmfl5xf913QA "PHP – Try It Online") Uses @Niphram's truncate method (which in PHP also has the ability to convert the float to an int) I know it's trendy to say PHP is to be hated, but I kinda came to like its oddities, and it gives me a chance to add an original answer EDIT: saved 4 bytes using `<?=` php tag (no need to echo) EDIT2: basically it's just a port of @Niphram's answer now [Answer] # [Canvas](https://github.com/dzaima/Canvas), 4 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md) ``` 2√n┐ ``` [Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjEyJXUyMjFBJXVGRjRFJXUyNTEw,i=MTAwMA__,v=8) [Answer] # [Dart](https://www.dartlang.org/), 33 bytes ``` import'dart:math';f(a)=>a~/sqrt2; ``` [Try it online!](https://tio.run/##NYxBCoMwFET3nuIjggl8aKLRloq9SOkiIKF/kcSmwY3Yq6ep1LeYYYZhJh1iSmRnH2I95XC1Oj7rwTDNx5v@nN6vEJshLZ4msJoc47AWkDE@sEUHICAHd4ESG2xRYYdSYNtgJ3In/rL7pVdKnWV/NJnH8fZjDuQiKw2riMMI1WoY8a3kw77Yii19AQ "Dart – Try It Online") [Answer] # [Keg](https://github.com/JonoCode9374/Keg), 6 bytes ``` 21½Ë/ℤ ``` [Try it online!](https://tio.run/##y05N/@@QZljz38jw0N7D3fqPWpb8PzaJy8DQyNjE9FHDQkMDIGFsBCRMDQzAfDgFBHFcGlZ6CQq6dgoJOg5pxybpJcTkJeho/v@vm5kHAA "Keg – Try It Online") This defines the function `f` as: * Taking a single parameter, then * Calculating the square root of 2 by raising it to the power of 0.5, then * Dividing the parameter by root 2, then * Casting the result to an integer (truncating / flooring the result) and returning it. The footer is to define the test cases in a nice way. ## Explained in a usual way ``` 21½Ë/ℤ 2 # Push 2 to the stack 1½ # Push 1 and halve it to get 0.5 Ë # Push 2 ** 0.5 (x ** 1/2 = sqrt(x)) /ℤ # Divide and cast to integer (floor) ``` 🍟🍅 Sorry, we're all out of ketchup. You'll have to squeeze your own. [Answer] # Haskell, 20 bytes ``` f n=round$n/(sqrt 2) ``` [Try it online](https://tio.run/##y0gszk7Nyfn/P00hz7YovzQvRSVPX6O4sKhEwUjzf25iZp6CrUJBaUlwSZFPnoKKQnFGfrmCRpqCiamBsamlpZmRubG5gYmlmeZ/AA) [Answer] # [Python 3](https://docs.python.org/3/), ~~22~~ 21 bytes ``` lambda x:int(x/2**.5) ``` [Try it online!](https://tio.run/##fVBNTwJBDL3zKxpOLJnodPo1JVn/iHpYYzaSwEKAEPz1awej8WQPbd9r@5r2@Hn5OEw0j/3LvBv2b@8D3Dbb6bK6PZb1@kG6@TrsztDDc06ACUoCSsAJJGBQFITkVss//jupysyG@svd6YJsXEnZQqQ4u1rxJlWZ1ZizkWUXQUX5O/mfJXDRUkM3O2K1goRWubqiaREmMiUiIb83ILtrLGImpkqvi/FwgjgStlML580Cwo6n9oTACZb90zLB2EDXzV8 "Python 3 – Try It Online") *-1 byte thanks to @RGS. Thanks for reminding me that implicit decimals exist* Just a port of my Keg answer. Nothing special here. [Answer] # [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 4 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py) ``` 2√/i ``` [Try it online.](https://tio.run/##fY3LDUJRCET3NCMwA1zKceMn0bixCGuwPBt53veiiStZQHLCzLnu76fj7XJYFn89nrvzsqiYuEAoIaYCl9DJ9LO2O5JkWX7JCt1YHEiW0Jud5R3CUER3eqF0wpkls0hdQUdYWvzU/BvpSB9Tom02yg1Wg6PTKj0IVAII9PZgnNqpIUEMvAE) **Explanation:** ``` 2√ # Take the square-root of 2 / # Divide the (implicit) input-integer by this i # Cast it to an integer, truncating any decimal values # (after which the entire stack joined together is output implicitly as result) ``` [Answer] # [CJam](https://sourceforge.net/p/cjam), 9 bytes CJam has `mQ`, but unfortunately it trunctuates to an integer ... Another port of Lyxal's answer. ``` q~2 .5#/i ``` [Try it online!](https://tio.run/##S85KzP3/v7DOSEHPVFk/8/9/UwMDAA "CJam – Try It Online") ## Explanation ``` q~ e# Take input & evaluate 2 e# Take 2 to the power of ... .5# e# ... 0.5 (equal to square root) / e# Divide the input by it i e# Convert to integer ``` [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 67 bytes ``` param([uint64]$n)($n/[math]::Sqrt(2)).ToString("G17")-replace'\..*' ``` [Try it online!](https://tio.run/##BcHtDkAgFADQdzGbsslXankBD8A//GjWsFVyZR7/Oidcn4HnMNYiBg3akfk9fRR8TT0lqS9np@Ox9v14QyQNpWy6xgin30ky1DKhBZhg9WayhbE8Q0TeVW2nlGhkKyuuxA8 "PowerShell – Try It Online") .NET (and thus, by extension, PowerShell) doesn't have a `BigDecimal`, so we're limited to [`Double`](https://docs.microsoft.com/en-us/dotnet/api/system.double?view=netframework-4.8) or [`Decimal`](https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=netframework-4.8). However, the `[math]::Sqrt()` function only works on `Double`, so there we're stuck. So far, so standard. We then specify precision with [`G17`](https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings?view=netframework-4.8#GFormatString), which successfully round-trips to give us 17 digits of precision on our `Double`, so we can pass everything but the last three test cases. We finish that off with a simple truncation `-replace`. [Answer] # [Burlesque](https://github.com/FMNSSun/Burlesque), 8 bytes ``` @2r@|/R_ ``` [Try it online!](https://tio.run/##SyotykktLixN/f/fwajIoUY/KP7/f1MDAwA "Burlesque – Try It Online") ``` @2 # Push 2.0 r@ # Sqrt it |/ # Cast input to number, divide input by 2 R_ # Round to nearest ``` ]
[Question] [ Draw the ionising-radiation-hazard-symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the [Federal Register](https://en.wikipedia.org/wiki/Federal_Register) of the US Government. ### Details * As output, writing to a file (raster and vector formats are permitted) or displaying on the screen are both allowed. * You can draw just the border or the filled shape. * If you use raster images, you should take a parameter (or two) as input that lets you adjust the resolution of the output (e.g. width/height). * The background must at least have the size of the bounding box of the symbol but may be larger. * Outputting the unicode symbol ☢ is [not sufficient](https://codegolf.meta.stackexchange.com/a/12155/24877). * The exact ratios of the used distances are given in following diagram (which was originally from [here](https://archive.org/stream/federalregister39kunit#page/n848/mode/1up)): ![](https://i.stack.imgur.com/E0D7f.png) Related: [Draw the ☣ (Biohazard Symbol)](https://codegolf.stackexchange.com/questions/191294/draw-the-biohazard-symbol) [Answer] # BBC BASIC, 200 bytes ``` f=500 g=1/SQR(3) CIRCLE FILLf,f,f GCOL15 MOVE-100,f MOVEf,f PLOT85,f*(1-g),0 MOVE1100,f MOVEf,f PLOT85,f*(1+g),0 MOVEf*(1-g),2*f MOVEf,f PLOT85,f*(1+g),2*f CIRCLE FILLf,f,150 GCOL0 CIRCLE FILLf,f,100 ``` Somehow outgolfing Python, this works by drawing a large black circle, filling in the white triangular sections, drawing a central white circle and finally drawing the central black circle. ![](https://i.stack.imgur.com/CsJfZ.png) [Answer] # [MATL](https://github.com/lmendo/MATL), ~~46~~ ~~44~~ 41 bytes ``` :t_0vSt!Yy1MZ;3*YP/koyG.3*>*yG<*wG5/<=3YG ``` Given an input `n`, the image has width `2*n+1` in pixels. Try it at [MATL Online](https://matl.io/?code=%3At_0vSt%21Yy1MZ%3B3%2aYP%2FkoyG.3%2a%3E%2ayG%3C%2awG5%2F%3C%3D3YG&inputs=200&version=22.0.0)! ### Explanation ``` : % Implicit input n. Range [1 ... n] t_ % Duplicate, negate. Gives [-1 ... -n] 0 % Push 0 v % Concatenate stack as a column vector: [1; ...; n; -1; ...; -n; 0] S % Sort. Gives [-n; -n+1; ... n] t! % Duplicate, transpose. Gives the row vector [-n -n+1 ... n] Yy % Hypotenuse, with implicit expansion. Gives a matrix containing radius % for all points in a grid from -n to -n 1M % Push the two inputs of the last function, again Z; % atan2, with implicit expansion. Gives a matrix containing angle between % -pi and pi, where 0 is real positive semiaxis 3*YP/k % Multiply by 3, divide by pi, round down. Gives an integer for each sextant o % Parity. This assigns 0 and 1 alternately to points in different sextants. % See this partial result as IMAGE 1 below. y % Duplicate from below: pushes the matrix of radii again G.3*> % Greater than 0.3*n?, element-wise. Gives 0 or 1 for each entry. This % realizes the "1.5R" circle from the specification. See IMAGE 2 * % Multiply, element-wise. See IMAGE 3 y % Duplicate from below: pushes the matrix of radii again G< % Less than n?, element-wise. Gives 0 or 1 for each entry. This realizes % the "5R" circle from the specification. See IMAGE 4 * % Multiply, element-wise. See IMAGE 5 w % Swap: pushes the original matrix of radii to the top G5/< % Mess than 0.2*n? This realizes the "R" circle in the spec. See IMAGE 6 = % Equal?, element-wise. This combines the two matrices so far to produce % the final result, with 0 for foreground pixels and 1 for background pixels. % See IMAGE 7 3YG % Show image. 0 is displayed as black, 1 as white ``` Intermediate results. 0 is shown as black, 1 as white: * Image 1: [![enter image description here](https://i.stack.imgur.com/HmxCtm.png)](https://i.stack.imgur.com/HmxCtm.png) * Image 2: [![enter image description here](https://i.stack.imgur.com/3uYD3m.png)](https://i.stack.imgur.com/3uYD3m.png) * Image 3: [![enter image description here](https://i.stack.imgur.com/NHGZMm.png)](https://i.stack.imgur.com/NHGZMm.png) * Image 4: [![enter image description here](https://i.stack.imgur.com/8pfSBm.png)](https://i.stack.imgur.com/8pfSBm.png) * Image 5: [![enter image description here](https://i.stack.imgur.com/AhfsVm.png)](https://i.stack.imgur.com/AhfsVm.png) * Image 6: [![enter image description here](https://i.stack.imgur.com/MviJLm.png)](https://i.stack.imgur.com/MviJLm.png) * Image 7 (final result): [![enter image description here](https://i.stack.imgur.com/6cMe9m.png)](https://i.stack.imgur.com/6cMe9m.png) [Answer] ## SVG(HTML5), 175 bytes ``` <svg viewBox=-24,-24,48,48><circle r=4 /><path id=b d=M3,-5.2A6,6,0,0,1,6,0H20A20,20,0,0,0,10,-17.32z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) ``` Originally based on @Arnauld's answer, but removes unnecessary characters, scales the numbers by 80% to make them golfier, and draws the curved section's lines in a different order so that I can use an `H` instead of an `L`. [Answer] # SVG(HTML5), ~~128~~ ~~126~~ ~~124~~ 120 bytes (Thanks *Wheat Wizard* for saving 2 bytes by using `.2` rather than `0.2`) (Drawing triangles from right to left saves 2 bytes) (Thanks *Grimmy* for saving 2 bytes by using a modified path) (And reduced another 2 bytes by using a different starting point on the path) ``` <svg viewbox=-2,-2,4,4> <circle r=1 /> <circle r=.3 fill=#FFF /> <path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF /> <circle r=.2 ``` ``` <svg viewbox=-2,-2,4,4><circle r=1 /><circle r=.3 fill=#FFF /><path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF /><circle r=.2 ``` Rather than basing the SVG on wikipedia's vector image - which is drawn in a reasonable way, this solution draws: 1. A black large circle `<circle r=1 />` 2. A smaller white circle `<circle r=.3 fill=#FFF />` 3. Three white triangles as a single continuous path `<path d=m2,3.4V0h-4v3.4l4,-6.8h-4 fill=#FFF />` 4. And a small black circle `<circle r=.2` Taking advantage of modern browsers forgiving interpretation which ignores unclosed tags (saved the final 9 bytes of `/></svg>` ) ### This is the result: [![SVG output](https://i.stack.imgur.com/bsiLE.png)](https://i.stack.imgur.com/bsiLE.png) And this is the same code with the path in yellow to demonstrate what's going on: [![enter image description here](https://i.stack.imgur.com/mXvQk.png)](https://i.stack.imgur.com/mXvQk.png) [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 42 bytes ``` ÷ÆṬ÷ØPḂ×3ḞḂ æịA©>5,1.5aç^/o®Ị¤ ×5ŒR÷µçþAZY ``` [Try it online!](https://tio.run/##AVEArv9qZWxsef//w7fDhuG5rMO3w5hQ4biCw5cz4bie4biCCsOm4buLQcKpPjUsMS41YcOnXi9vwq7hu4rCpArDlzXFklLDt8K1w6fDvkFaWf///zU "Jelly – Try It Online") A full program that takes an integer n that determines the radius of the central circle and implicitly outputs to STDOUT a \$10n+1\$ square with the desired image encoded as `1` for black and `0` for white. Per @flawr, this is a permitted output format. Note also that this is effectively a PBM file without the header. Adding `P1 L L` to the start (where L is replaced by \$10n+1\$) would make it a valid PBM file. Ta ## Explanation ### Helper link 2 Dyadic link taking y coordinate as left and x as right argument; returns whether the angle is within the filled outer area ``` ÷ | Divide (y by x) ÆṬ | Arc-tangent ÷ØP | Divide by pi Ḃ | Mod 2 ×3 | Times 3 Ḟ | Floor Ḃ | Mod 2 ``` ### Helper link 1 Dyadic link taking y coordinate as left and x as right argument ``` æị | Convert to complex A | Absolute (i.e. distance from origin) © | Copy to register >5,1.5 | Greater than 5,1.5 (vectorises, so will give two booleans) a | Logical and with: ç | - Result of helper link 2 applied to the input of this link ^/ | Reduce using exclusive or o ¤ | Or following as a nilad: ® | Value in register Ị | Absolute of this <= 1 ``` ### Main link ``` ×5 | Times 5 ŒR | Range from -this to +this ÷ | Divide by input µ | Start a new monadic chain çþ | Outer table using helper link 1 and: A | - Absolute of the range as the right argument Z | Transpose rows and columns ``` Sample image for `n=5` [![sample](https://i.stack.imgur.com/P5nw5.png)](https://i.stack.imgur.com/P5nw5.png) [Answer] # JavaScript (ES7), ~~118 113 98~~ 93 bytes *Saved 15 bytes thanks to [@tsh](https://codegolf.stackexchange.com/users/44718/tsh)!* Takes a parameter \$w\$ as input and draws an ASCII art of width \$2w-1\$ and height \$2w\$, using `0` and `1` for the 'pixels'. ``` f=(x,w=y=x)=>y+w?(--x+w?(r=x*x+y*y,4*x*x>r^y<0?1019:3)>>r**.5/w*10&1:(x=w,y--,` `))+f(x,w):'' ``` [Try it online!](https://tio.run/##FcxBDoIwEEDRvQeRTmmxjbiwccpNDASpkRBqirEzp6@y@m/15@E7bGN6vT96jY@plICCVEZGAvRc505oTXsSkqSaJatW/uXTnW@ms8Ze3Rm8T1I2l1OW1hytE4RZsdaqP/QAddiX4KqqjHHd4jI1S3yKIFoDUH4 "JavaScript (Node.js) – Try It Online") ### How? We compute the squared distance from the center: $$r=x^2+y^2$$ We use \$\sqrt{r}\$ to quantize the distance from the center into 10 bins of width \$w\$: $$\left\lfloor\frac{10\sqrt{r}}{w}\right\rfloor$$ We use \$r\$, \$x\$ and \$y\$ to determine in which kind of sector we are: $$(4x^2>r)\text{ xor }(y<0)$$ [See this graph!](https://www.desmos.com/calculator/vbhkf0fiip) We turn the above result into a drawing bit-mask, as summarized in the following schema: [![schema](https://i.stack.imgur.com/nJCnm.png)](https://i.stack.imgur.com/nJCnm.png) Hence the value of the pixel at \$(x,y)\$: ``` ( r = x * x + y * y, 4 * x * x > r ^ y < 0 ? 1019 : 3 ) >> r ** 0.5 / w * 10 & 1 ``` [Answer] # Google Sheets, 277 bytes ``` =ARRAYFORMULA((POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<A1*A1)+(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)>9/4*A1*A1)*(POW(COLUMN(A1:CV99)-5*A1,2)+POW(ROW(A1:CV99)-5*A1,2)<25*A1*A1)*IFERROR((MOD(3*ATAN2(COLUMN(A1:CV99)-5*A1,ROW(A1:CV99)-5*A1)/PI(),2)<1),0 ``` Creates a grid of `1`s and `0`s which can be coloured using a conditional format. It takes input in cell A1 as the value of R. Here's a [link](https://docs.google.com/spreadsheets/d/1CQPowY1OYGzglRjg4OuXRKprcz9OBY83CofLr45iR_0/edit?usp=sharing). [![enter image description here](https://i.stack.imgur.com/Hx88h.png)](https://i.stack.imgur.com/Hx88h.png) [Answer] # HTML / SVG, ~~201~~ 189 bytes A revamped version of [this file](https://commons.wikimedia.org/wiki/File:Radiation_warning_symbol2.svg) from Wikimedia Commons. ``` <svg viewBox=-30,-30,60,60><circle r=5 /><path id=b d=M7.5,0A7.5,7.5,0,0,0,3.7,-6.5L12.5,-21.6A25,25,0,0,1,25,0z /><use href=#b transform=rotate(120) /><use href=#b transform=rotate(240) /> ``` [Answer] # [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), 216 bytes ``` D::i</~1-:0)?;{:}ak$2?X2 8?1]$#'~~\1?7 c?1$ '~~\?3 L R:0)?/1-:̹{2,::}}-S{-2pS2p+'qA:{5,:}≮?/:}3,2*S:}S≯?/5,)?/]:̹{2,:}-S{-:̹'-A}'-A0)3*?P2?Z0]{{S:0)a*?:0(4*?~~10,'|A'aA{0)?S-:0≮4*?P2*+3*2P*%P)4*?'#2?' $] ``` [Try it online!](https://tio.run/##LY7BCsIwDIbvPkXBSV3tWJtNlCiGgUcPw15E3GF4EkFU8FTb59J38J1mJgYC@SBf/twfl9Ox69aIp2UebYYmpYXH0J4ToB0IrjnZJhnKGA@WZuJINhE9UCHEZrDthZy9z9uDRgwhcz6Dq4PrRN4q9FONYfl5UY6h0KAcBrfqcarZa/7aT@JZZlXgNmmhqAbam8Z7xwmtIjTjUlGM1mj5rGRbeQ52/C8fL/ttNSkU1GpUp4xyCCRF0nRdab4 "Runic Enchantments – Try It Online") *Dear god. Why. So much went wrong. It makes me cry.* Several major impediments that ended up making this both (a) a nearly unreadable mess and (b) *frustratingly difficult.* The first problem was the fact that Runic doesn't have `atan2(x,y)`, so I had to [*heckin' work that out myself*](https://tio.run/##KyrNy0z@/z8z0@rMTnVdx1ogNtA01rIPMLKPMoitrg7WUa9xVE90rDbQtA/Wdfj/30DBFAA). And oh yeah, make sure its reasonably golfed, it had to be dropped into an existing program with no alterations, so in-line conditional logic was preferable. The *second* problem was that I had a weird issue where I'd multiply the tangent value by 3, modulo to 2pi and get...[nonsense](https://tio.run/##rY6xCsIwFEX3fkXAQrQmpnm1Kk/xWXB0KGYRaYfSSQRRwSkm36X/4D/VdHT3wh3OcC73/ric2q7bIp5WymuJ6YiWFl1zjoEOwEIWpOt4wL2vNM1ZSzpmPVDG2C7a94IK3udtQSA6J42VcDVwHfNbgTYX6FafFyl0mYDEoDPrHnMRvPpXqyLF/hAVVWGXy8KFpqMsoRLomNbWGsGfBW8KG04bOUvK4TQhPgHim9j7uutAfwE). What even is that? Why is it not using angular values? Turned out I had a stray extra value at the bottom of the stack that was throwing the math off. Whoops. *THEN* ***AND THEN*** The program would just suddenly die after the [first four bytes of the outer wedges](https://tio.run/##pY5BasMwEEX3PsVABUpsKZLGDQ3j0KlJll0EaxOKvTBZhUJJC12p8rnSO@ROjhy67iYfBuYzvPn/6/vjeBjHLdFxbQanyc65ChT7d4G8R0hasevEgxyG1vETHNgJmAyXAK9ZMwEmcZffgIooRu2DxpPHUyE/awpLRXF9ObOhWCrMPUX/PNmlSlz3h92gNjNwt0zWpp9S1zGNnZc575DfbBeCV/Knln0dUmGvgWxq9Tid86Ls1Syt8gVZLkSXQSMkCFH9m9S4zWpf5DslqnFEewU). Oh my, what fun we had. Lets simplify, shall we? Lets just isolate the inputs at that point and... oh. [It works fine](https://tio.run/##KyrNy0z@/z8zs8jqzE51XcdaIDbQNNayDzCyjzKIra4O1lGvcVRPdKw20LQP1rUysDmzwwQkq6VtnKij4fD/v6WCAQA). I. Uh. Hmm. When in doubt, check the source code. Can you [spot](https://github.com/Draco18s/RunicEnchantments/blob/Console/RunicInterpreter/draco18s/runic/runes/RuneDivision.cs#L15-L18) the [difference](https://github.com/Draco18s/RunicEnchantments/blob/Console/RunicInterpreter/draco18s/runic/runes/RuneDivision.cs#L41-L47)? Yep. Integer values are *totes* allowed to divide by zero (and return infinity) and doubles aren't. Oh and [that's not even true in the original Unity C# code](https://github.com/Draco18s/RunicEnchantments/blob/master/Assets/draco18s/runic/runes/RuneDivision.cs#L15-L22) (which I use as a graphical debugger) as it was an *intentional design decision* to terminate on div-by-zero. Wot. Also, conversion to float instead of double for no reason. Just sittin' there. (╯°Д°)╯︵┻━┻ ### Explanation I need a drink first. [![dook dook](https://i.stack.imgur.com/ncofY.png)](https://i.stack.imgur.com/ncofY.png) That's better. ``` D::i< Set up the stack, we need a current position (X,Y) and total size. Init all to read value, counting down is easier than counting up. The D here, and the R below it, constitute the main loop entry R:0)?\1- Compare current X against zero, else decrement \~1-:0)?;{:}ak$ if zero, decrement Y. If Y is zero, terminate, else return to the D on the first line (there's a lot of skip-over-logic) :̹ {2,::}}-S{- dupe the entire stack, then translate origin by 1/2 width 2pS2p+'qA square root (x*x+y*y) :{5,:}≮?\:}3,2*S:}S≯?\ compare that against 1/20th the width and 1.5/20th the width (R and 1.5R) ]$#'~~L $ '~~L Print # or <space> for the inner circle (and return to D) skip-bypasses omitted 5,)?/ Compare against 1/10th the width (5R), print a space and return to D ]:̹ {2,:}-S{-:̹ '-A}'-A0)3*?P2?Z0]{{S:0)a*?:0(4*?~~10,'|A'aA{0)?S- Dupe the entire stack and compute atan2(x,y) :0≮4*?P2*+ Convert negative values to values greater than pi up to 2 pi 3*2P*%P)4*?'#2?' $] Multiply by 3, modulo 2pi, compare against pi. Less: print # else print space. Return to R. ``` Be wary of improperly stacking unicode combining characters. The little `̹` makes the command apply to the stack-of-stacks and `̸` is boolean-not; eg. `≮` is "not less than (aka greater-equals)." Looks like it costs bytes, but because of the upper line, there's a byte savings in that line being shorter, which pays for the +1 byte cost for an extended character in the lower line (typically assuming that the lower line could be `?!/` instead of `?/`). [Answer] # [Haskell](https://www.haskell.org/) (code.world dialect), ~~108~~ 86 bytes ``` drawingOf(c(2)&colored(c(3),white)&0%1&2%3&4%5) c=solidCircle a%b=sector(a*60,b*60,10) ``` [Run on code.world!](https://code.world/#Pkllu__B4YRoEe3hj_cocYg) [Answer] # [C (gcc)](https://gcc.gnu.org/) (MinGW), ~~245~~ ~~244~~ ~~242~~ ~~236~~ ~~223~~ 221 bytes -6 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat). Added `-lm` on TiO so that it works there. MinGW does not require it. Outputs a 3-shade PGM file to STDOUT. Takes width (height is the same) of image as a command line argument. ``` main(q,v,r,c,m)char**v;{*v=calloc(q+1,q=atoi(v[1]));float R=q/10.1,d;for(r=m=q/2;r--+m;)for(c=m;c--+m;m[*v+(r+m)*q+c]=d<R*5&&d<=R|d>=1.5*R&asin(r/d)+1.5707>(r>0?5:1)*0.5235?:2)d=hypot(c,r);printf("P5 %d %d 2 %s",q,q,*v);} ``` [Try it online!](https://tio.run/##HY7NisIwGEVfpQiW/LUmlSAYU19h6FZchC9UC4kxaQmIM68@mTrcszlndaG5AZTizfRAkWWWGDCP4W4SIVm9SdZgnAuAIhUsarOECeWLuGKsRhfMUg067gRvBbNqDAkl7dfQqdQ01Cv8SaC9gn/1F5IpStRjEilctT0NRNa1Penh2/ZatJIMtZnXK2lnMV39wA89Sj0/y6PAhLey28vzscNW31/PsCBgCatnmh7LiDZfstraD121nTcsriMZq59SSsf5L4zO3ObSOP8H "C (gcc) – Try It Online") [Answer] # TikZ, 170 bytes ``` \documentclass[tikz]{standalone}\begin{document}\tikz{\fill circle(10);\foreach\a in{0,120,240}{\fill[white]circle(3)--(\a-60:13)--(\a:13);}\fill circle(2)}\end{document} ``` [Answer] ## Logo, 96 bytes ``` circle 16 rt 90 repeat 3[arc 80 60 arc 24 60 pu repeat 2[fw 24 pd fw 56 pu backward 80 rt 60]pd] ``` [Try it online!](http://logo.twentygototen.org/IbEAJBpZ) Draws just the border. [Answer] # Desmos/Cartesian Plane, 103 97 86 84 bytes ## (23 arithmetic and comparison operators) `(abs(mod(arctan(x,-y)/\pi*6,4)-2)-1)*max(0,182-abs(x^2+y^2-218))+max(0,16-x^2-y^2)>0` [![enter image description here](https://i.stack.imgur.com/1gh8r.png)](https://i.stack.imgur.com/1gh8r.png) <https://www.desmos.com/calculator/hadw7gayfn> [![enter image description here](https://i.stack.imgur.com/UTpil.png)](https://i.stack.imgur.com/UTpil.png) [Answer] ## Mathematica (Wolfram Language) ~~76~~ 71 Bytes This solution draws the radiation symbol using only the `Disk[]` primitive, which allows for arcs. By default a `Graphics` object in Mathematica has a White background and objects are Black unless otherwise specified. So we first draw three black disk sectors, then a small white disk and finally a smaller inner black disk. Unlike @Mario Carneiro's solution (which is a nice use of RegionPlot), this comes without axes and without the artifacts produced by the inner workings of RegionPlot. Saved a byte by letting R=2 ``` Graphics@{(d={0,0}~Disk~##&)[10,{#,#+1}Pi/3]&/@{0,2,4},{White,d@3},d@2} ``` [![enter image description here](https://i.stack.imgur.com/z8x96.png)](https://i.stack.imgur.com/z8x96.png) [Answer] # [Mathematica](https://en.wikipedia.org/wiki/Mathematica), 93 88 85 76 74 70 bytes ``` RegionPlot[1.5<#<5&&Sin[3#2]>0||#<1&@@AbsArg[x+I y],{x,-5,5},{y,-5,5}] ``` -4 bytes thanks to [Roman](https://codegolf.stackexchange.com/users/87058/roman). It is not clear from the description whether it is required to get rid of the outline and make it black on white, but I think the submission looks best and is shortest like this. [![radiation symbol](https://i.stack.imgur.com/wkuzi.png)](https://i.stack.imgur.com/wkuzi.png) [Answer] # [PostScript](https://en.wikipedia.org/wiki/PostScript), ~~183~~ 175 bytes Code (compressed version): ``` 20 20 scale 9 6 translate<</f{closepath fill}/c{0 360 arc f}/l{10 0 lineto -60 rotate}>>begin 0 0 5 c 1 setgray 3{0 0 moveto l l f} repeat 0 0 1.5 c 0 setgray 0 0 1 c showpage ``` Code (uncompressed version): ``` 20 20 scale % over-all scale 9 6 translate % over-all shift % define some short-named procedures for later use << /f { closepath fill } /c { 0 360 arc f } % filled circle (x, y, radius are taken from stack) /l { 10 0 lineto -60 rotate } % long line + rotate by 60° >> begin 0 0 5 c % big black circle 1 setgray % set white color 3 { 0 0 moveto l l f % white triangle + rotate by 120° } repeat 0 0 1.5 c % white circle 0 setgray % set black color 0 0 1 c % small black circle showpage ``` Result (as animation to see how it is drawn): [![result](https://i.stack.imgur.com/DeABP.gif)](https://i.stack.imgur.com/DeABP.gif) [Answer] ## Python 3.8, 129 124 122 120 119 ``` def f(N):[print((abs(a:=(i%N+i//N*1j)*2/N-1-1j)<.2)+((a**3).imag<0<.3<abs(a)<1),end=(-i%N==1)*"\n")for i in range(N*N)] ``` Output (N=20): ``` 00000000000000000000 00000000000000000000 00000100000000010000 00011100000000011100 00011110000000111100 00111111000001111110 01111111000001111111 01111111100011111111 01111111000001111111 01111111011101111111 00000000011100000000 00000000011100000000 00000000000000000000 00000000010100000000 00000000111110000000 00000000111110000000 00000001111111000000 00000011111111100000 00000011111111100000 00000011111111100000 ``` The idea is to represent each point in the plane by a complex number \$x\$. Let the radius of the innermost circle be \$2\$. Then \$x\$ is inside the inner circle if \$|x|<2\$. The outer parts are a bit more involved. To lie in one of the outer parts, we have to have \$3=1.5\cdot 2< |x| < 5\cdot 2 = 10\$ so that the distance is neither too small nor too large. We also have an angle restriction: the polar angle of \$x\$ has to lie between \$60^\circ\$ and \$120^\circ\$, when taken mod \$120^\circ\$. But if we instead look at \$x^3\$, the angle is multiplied by three, so that the polar angle of \$x^3\$ has to lie between \$180^\circ\$ and \$360^\circ\$ (mod \$360^\circ\$). This is just equivalent to \$\Im(x^3)<0\$. To put it all together, we have to have \$|x|<2\$ or both of \$3<|x|<10\$ and \$\Im(x^3)<0\$ for \$x\$ to be inside the image. As both conditions are mutually exclusive, their truth values can just be added together. [Answer] # python 3.8, 220 ``` from PIL import Image as I from math import* d=300 h=d//2 r0=d/10 g=range(-h,h) i=I.frombytes('L',(d,d),bytes([255,0][1.5<(r:=(x*x+y*y)**.5)/r0<5 and(atan2(x,y)/pi+7/6)*1.5%1.>.5 or r<r0]for y in g for x in g)) i.show() ``` The idea behind is very simple: we count `(x,y)` from the center of image and `r=(x*x+y*y)**.5` is the distance between point and the center. The point is black if either `r<r0` where `r0` is `1/5` distance from center to a side or if `5*r0<r<1.5*r0` (see the diagram in the question) and the angle from center to the point (computed with `math.atan2`) is in selected ranges. `1.5` and `7/6` there were obtained almost empirically, but could be reasoned too. The other (most) part is a wrap-in. ![](https://i.stack.imgur.com/dhdkk.png) [Answer] # [Red](http://www.red-lang.org), ~~237~~ 218 bytes ``` Red[needs: 'View] g: func[n][a: compose[arc(s: n / 2.0 * 50x50)(s)60 60 closed rotate 120(s)]view compose/deep[base(s * 2)draw[(f: 'fill-pen)black(a)(a)(a) pen gray line-width(0.1 * s/1)(f)black circle(s)(s/1 / 4.0)]]] ``` [![enter image description here](https://i.stack.imgur.com/tndzR.png)](https://i.stack.imgur.com/tndzR.png) Takes a parameter `n` - the width/height in multiples of 50. [Answer] # [Desmos](https://desmos.com/calculator), 3+~~70~~ 64=~~73~~ 67 bytes After seeing [Will Chen's answer](https://codegolf.stackexchange.com/a/196374) and seeing that the online link no longer seemed to work, I figured I'd start at it from scratch, and ended up with 11 fewer bytes. ``` r<2 max(0,mod(-sign(x)arctan(y/x),120)-60)(x^2+y^2-9)(x^2+y^2-100)<0 ``` [View it online](https://www.desmos.com/calculator/uxwo9ont5p) Edit: realized `max` is unnecessary for the latter two functions. It's required for the first function to zero out a lot of areas, but this might be able to be improved. This makes this the shortest answer in a non-golfing language, beating out Mathematica, with some potential for improvement. This originally used a bunch of piecewise conditionals, which simply evaluate to 1 if true and undefined if false, making them handy for this purpose. However, by just multiplying them through and comparing to 0, we can check for polarity in a shorter way. The reason we do `<0` at the end instead of `>0` like you may expect is that the last block, checking if r>10, needs to evaluate to false (negative). The only other notable thing is the polarity check in the first part because `arctan(y/x)` doesn't necessarily work as well for angle-finding as you might hope. [Answer] **TikZ, 93 bytes** The last comma `;` at the end of the code can be missed. ``` \foreach\i in{0,120,240}\fill[rotate=\i](60:3)arc(60:0:3)--(0:10)arc(0:60:10);\fill circle(2) ``` **TikZ, 164 bytes** ``` \documentclass[tikz]{standalone}\begin{document}\tikz{\foreach\i in{0,120,240}\fill[rotate=\i](60:3)arc(60:0:3)--(0:10)arc(0:60:10);\fill circle(2)}\end{document} ``` [![enter image description here](https://i.stack.imgur.com/6heKx.png)](https://i.stack.imgur.com/6heKx.png) **Asymptote 109 bytes** ``` // Run on http://asymptote.ualberta.ca/ for(int i=0;i<3;++i)fill(rotate(i*120)*(arc((0,0),3,60,0)--arc((0,0),10,0,60)--cycle));fill(circle((0,0),2)); ``` **Asymptote 117 bytes** ``` // Run on http://asymptote.ualberta.ca/ for(int i: new int[]{0,120,240})fill(rotate(i)*(arc((0,0),3,60,0)--arc((0,0),10,0,60)--cycle));fill(circle((0,0),2)); ``` [Answer] # [Ruby](https://www.ruby-lang.org/), ~~91~~ 100 bytes ``` ->s{(w=-(s/=2)..s).map{|x|w.map{|r|a=x*x+r*=r;' O'[a<(b=s*s)/25||a>b/11&&a<b&&x*(r*4-a)<0?1:0]}*''}} ``` [Try it online!](https://tio.run/##JcZLDsIgEADQq3TFZwwUGk2MMvUIHqDpYlh0Z9IwbYopnB0XvtVLe/y2BZsZ@VQHGsU9Dtpa1vZD61lyOf5JhTBDviTA9JTdW04UVEQG1v1wK4XG2HsvBIUoRAaV4GpIB/fyDzdXkLLWtu4bd8t0d3P7AQ "Ruby – Try It Online") Accepting 1 parameter (size of the image). Example output for s=40: ``` O O OO OO OOOOO OOOOO OOOOOO OOOOOO OOOOOOOO OOOOOOOO OOOOOOOOO OOOOOOOOO OOOOOOOOOO OOOOOOOOOO OOOOOOOOOOOO OOOOOOOOOOOO OOOOOOOOOOOO OOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOO OOOOOOOOOOOOOOO OOOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOO OOOOOOOOOOOOOO OOOOOOOOOOOOOO OOOOOOO OOOOOOOOOOOOOO OOOOOOO OOOOOOO OOOOOOO OOOOO OOO OOO OOOOOOOOO OOOOOOOOO OOOOOOOOOOO OOOOOOOOOOO OOOOOOOOOOOOO OOOOOOOOOOOOO OOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOOOO OOOOOOOOOOOOOOOOO OOOOOOOOOOOOO ``` [Answer] # [OpenSCAD](http://openscad.net), 153 bytes ``` module a(){polygon([[0,0],[5,0],[5,10]]);}module b(){a();rotate(120)a();rotate(240)a();}circle();intersection(){difference(){circle(5);circle(1.5);}b();} ``` [![A low-poly radiation symbol](https://i.stack.imgur.com/v1gcq.png)](https://i.stack.imgur.com/v1gcq.png) Uncompressed: ``` module triangle() { polygon(points=[[0,0],[5,0],[5,10]]); } module triangles() { triangle(); rotate(120) triangle(); rotate(240) triangle(); } module radiation() { circle($fn = 100); intersection() { difference() { circle(5, $fn = 100); circle(1.5, $fn = 100); } triangles(); } } radiation(); ``` [![A high-poly radiation symbol](https://i.stack.imgur.com/sOHLv.png)](https://i.stack.imgur.com/sOHLv.png) Notice the extra `$fn = 100` in the circles, which are used to make them higher-resolution polygon. We could add `$fs=.1;` at the beginning of the file, which would also improve the resolution. [Answer] # SVG(HTML5), 114 bytes ``` <svg viewBox=-1,-1,2,2><circle r=.65 fill=none stroke=#000 stroke-width=.7 stroke-dasharray=0,.68,0 /><circle r=.2 ``` An alternative solution to the other SVG answers. Uses the stroke dash property to create the 'wings'. The value of the `.68` should be equal to `0.65 / 3 * PI`, or `0.680678408...` to be more accurate. If incorrect rotation is allowed, this can be reduced to 110 bytes: ``` <svg viewBox=-1,-1,2,2><circle r=.65 fill=none stroke=#000 stroke-width=.7 stroke-dasharray=.68 /><circle r=.2 ``` [Answer] # [GLSL / Shadertoy](https://www.shadertoy.com/new), 181 bytes ``` void mainImage(out vec4 o,vec2 c) { vec2 p=(c-iResolution.xy/2.)/iResolution.y; float k=length(p),h=acos(-1.)/3.; o=step(0.,min(k-.1,max(k-.5,.15-k)*step(mod(atan(p.y,p.x),h+h),h)))-o; } ``` Copy and paste this code into the editor then press the play button to run the shader. The shader uses the signed distance of the shapes to be able to use the union and intersection operations to generate the symbol. [Answer] # TI-BASIC (TI-84+), 1042 bytes ``` "000000000000000000000000000000000000000000000000000000000000000300000000000000780000006000001FC000000F800003FC000001FC00007FE000001FE0000FFE000003FF0001FFF000003FF8003FFF000007FFC003FFF80000FFFC007FFFC0000FFFE00FFFFC0001FFFF00FFFFE0001FFFF01FFFFE0003FFFF81FFFFF0007FFFF83FFFFF8007FFFFC3FFFFF800FFFFFC3FFFFFC00FFFFFC7FFFFFC01FFFFFE7FFFFFC01FFFFFE7FFFFF801FFFFFE7FFFFF0F0FFFFFEFFFFFE3FC7FFFFFFFFFFE7FE7FFFFFFFFFFC7FE3FFFFFFFFFFCFFF3FFFFFFFFFFCFFF3FFFFF000000FFF3FFFFF000000FFF0000000000007FE0000000000007FE0000000000003FC0000000000000F0000000000000000000000000000604000000000000FFE000000000001FFE000000000001FFF000000000003FFF800000000007FFF800000000007FFFC0000000000FFFFC0000000000FFFFE0000000001FFFFF0000000003FFFFF0000000003FFFFF8000000007FFFFF8000000007FFFFFC00000000FFFFFFC00000001FFFFFFE00000001FFFFFFF00000003FFFFFFF00000001FFFFFFF80000000FFFFFFF000000003FFFFFC0000000007FFFE000000000007FE000000→Str1 AxesOff 15→N 4→dim(∟A For(I,1,60N sub(Str1,I,1 inString("0123456789ABCDEF",Ans)-1→D For(B,4,1,-1 D≥2(B-1→∟A(B If ∟A(B D-2^(B-1→D End For(E,1,4 If ∟A(5-E Pxl-On(iPart(I/N),E+4remainder(I,N End End ``` Oh man, this one was rough. The TI series of calculators do have shading functionality between functions, but that just don't cut it. Furthermore, I was limited to 60x60 pixels, since drawing on the 62nd row or lower would result in **ERR: ARGUMENT** error being thrown and 60 fits the radii ratios mentioned in the challenge perfectly: $$ R = 12 \\ 1.5R = 18 \\ 5R = 60$$ So, I opted to convert a string of hexadecimal characters to pixels. The pixels drawn to the screen will look like this: [![Ionized Radiation Hazard symbol](https://i.stack.imgur.com/1QqaH.png)](https://i.stack.imgur.com/1QqaH.png) The *very* long string you see on the first line of the program looks like this when formatted: ``` 000000000000000 000000000000000 000000000000000 000000000000000 000300000000000 000780000006000 001FC000000F800 003FC000001FC00 007FE000001FE00 00FFE000003FF00 01FFF000003FF80 03FFF000007FFC0 03FFF80000FFFC0 07FFFC0000FFFE0 0FFFFC0001FFFF0 0FFFFE0001FFFF0 1FFFFE0003FFFF8 1FFFFF0007FFFF8 3FFFFF8007FFFFC 3FFFFF800FFFFFC 3FFFFFC00FFFFFC 7FFFFFC01FFFFFE 7FFFFFC01FFFFFE 7FFFFF801FFFFFE 7FFFFF0F0FFFFFE FFFFFE3FC7FFFFF FFFFFE7FE7FFFFF FFFFFC7FE3FFFFF FFFFFCFFF3FFFFF FFFFFCFFF3FFFFF 000000FFF3FFFFF 000000FFF000000 0000007FE000000 0000007FE000000 0000003FC000000 0000000F0000000 000000000000000 000000604000000 000000FFE000000 000001FFE000000 000001FFF000000 000003FFF800000 000007FFF800000 000007FFFC00000 00000FFFFC00000 00000FFFFE00000 00001FFFFF00000 00003FFFFF00000 00003FFFFF80000 00007FFFFF80000 00007FFFFFC0000 0000FFFFFFC0000 0001FFFFFFE0000 0001FFFFFFF0000 0003FFFFFFF0000 0001FFFFFFF8000 0000FFFFFFF0000 00003FFFFFC0000 000007FFFE00000 0000007FE000000 ``` Each hexadecimal digit encodes to a series of 4 pixels drawn to the screen. For each bit set in the digit, a pixel will be drawn. **Explanation:** ``` "000 ... 000→Str1 ;set the digit string to convert AxesOff ;get rid of the axes on the graph since ; it'll be in the way 15→N ;set N to 15 in order to save a few bytes 4→dim(∟A ;set the length of the list A to 4 elements For(I,1,60N ;loop 900 times. There are 60 lines to draw ; and 15 digits per line to convert sub(Str1,I,1 ;get the current hexadecimal digit inString("0123456789ABCDEF",Ans)-1→D ;convert it to base 10, store the result in D For(B,4,1,-1 ;convert number to its binary representation D≥2(B-1→∟A(B If ∟A(B D-2^(B-1→D End For(E,1,4 ;loop over each bit in said representation If ∟A(5-E ;and only draw the pixel if this bit is set ; (bit order is reversed) Pxl-On(iPart(I/N),E+4remainder(I,N ;pixel row (Y) is I/N, pixel column (X) is ; 4*(I%N)+E End End ``` --- **Note:** TI-BASIC is a tokenized language. Character count does *not* equal byte count. [Answer] # T-SQL, 185 bytes ``` DECLARE @ GEOMETRY='POINT(6 6)',@b GEOMETRY='POLYGON((12 6,9 0,3 12,9 12,3 0,0 6,12 6))'SELECT @.STBuffer(5).STDifference(@b.MakeValid().STUnion(@.STBuffer(1.5))).STUnion(@.STBuffer(1)) ``` I shifted the center from (0,0) to (6,6) to reduce the number of negative numbers needed; this saves a byte or two. This code isn't quite long enough to benefit from the `REPLACE()` trick that was needed for [the Biohazard symbol](https://codegolf.stackexchange.com/a/191323/70172). This was done using [SQL geo-spatial features](https://docs.microsoft.com/en-us/sql/relational-databases/spatial/spatial-data-sql-server?view=sql-server-2017) introduced in SQL 2008. Visual of output, with annotated code: [![enter image description here](https://i.stack.imgur.com/LoLcv.png)](https://i.stack.imgur.com/LoLcv.png) For more T-SQL drawing, see [my Biohazard symbol](https://codegolf.stackexchange.com/a/191323/70172) and [my Easter Bunny](https://codegolf.stackexchange.com/a/184653/70172). [Answer] # [Desmos](https://desmos.com), 60 bytes ``` w=hsv(0,0,1) r<5\{[0,3,6]40<\theta<[1,3,5]60\} xx+yy<9/4 r<1 ``` [Try it on Desmos](https://www.desmos.com/calculator/soaz9l0mlh) This is the version without scaling, now the shortest Desmos answer. # [Desmos](https://desmos.com), ~~178~~ ~~161~~ ~~153~~ ~~126~~ ~~119~~ ~~72~~ ~~68~~ 67 bytes ``` R=1 w=hsv(0,0,1) r<5R\{[0,3,6]40<\theta<[1,3,5]60\} xx+yy<9RR/4 r<R ``` [Try it on Desmos](https://www.desmos.com/calculator/njjgnloz39) -12 bytes thanks to @Steffan -27 bytes by switching to degrees and extracting the "arms" to a function -55 bytes and fix thanks to @Aiden Chow -1 byte thanks to emanresu A ~~By far the longest Desmos answer yet,~~ this is now the second shortest answer. Oh, and mine is scalable, just move the \$R\$ slider. [Answer] # [Processing](https://processing.org/), 172 bytes ``` noStroke();background(255);fill(0);for(float i=-60;i<=300;i+=120)arc(50,50,100,100,radians(i),radians(i+60),PIE);fill(255);circle(50,50,30);fill(0);circle(50,50,20); ``` Un-minified code: ``` noStroke(); background(255); fill(0); for(float i=-60;i<=300;i+=120)arc(50,50,100,100,radians(i),radians(i+60),PIE); fill(255); circle(50,50,30); fill(0); circle(50,50,20); ``` ## Output [![enter image description here](https://i.stack.imgur.com/E8MRP.png)](https://i.stack.imgur.com/E8MRP.png) ]
[Question] [ Given a positive integer n write some code to take its prime factorization and replace all of its factors of `2` with `3`. For example ``` 12 = 2 * 2 * 3 -> 3 * 3 * 3 = 27 ``` This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so the goal is to minimize the byte count of your answer. # Test cases ``` 1 -> 1 2 -> 3 3 -> 3 4 -> 9 5 -> 5 6 -> 9 7 -> 7 8 -> 27 9 -> 9 10 -> 15 11 -> 11 12 -> 27 13 -> 13 14 -> 21 15 -> 15 16 -> 81 17 -> 17 18 -> 27 19 -> 19 20 -> 45 21 -> 21 22 -> 33 23 -> 23 24 -> 81 25 -> 25 26 -> 39 27 -> 27 28 -> 63 29 -> 29 ``` [Answer] # [Fractran](https://esolangs.org/wiki/Fractran), 3 bytes ``` 3/2 ``` Fractran literally only has one builtin, but it happens to do exactly what this task is asking for. (It's also Turing-complete, by itself.) The language doesn't really have a standardised syntax or interpreter. [This interpreter](http://scienceblogs.com/goodmath/2006/10/28/more-fractran-a-trivial-interp-1/#comment-3759) (in a comment to a blog post ‚Äì it's a very simple language) will accept the syntax shown here. (There are other Fractran interpreters with other syntaxes, e.g. some would write this program as `3 2`, or even using `3` and `2` as command line arguments, which would lead to a score of 0+3 bytes. I doubt it's possible to do better than 3 in a pre-existing interpreter, though.) ## Explanation ``` 3/2 / Replace a factor of 2 2 3 with 3 {implicit: repeat until no more replacements are possible} ``` [Answer] # [Python 2](https://docs.python.org/2/), 28 bytes ``` f=lambda n:n%2*n or 3*f(n/2) ``` [Try it online!](https://tio.run/nexus/python2#@59mm5OYm5SSqJBnladqpJWnkF@kYKyVppGnb6T5Pw3IyVPIzFMoSsxLT9Uw1DE20LTi4iwoyswrUQCq0fwPAA "Python 2 ‚Äì TIO Nexus") Recursively divide the number by 2 and multiplies the result by 3, as long as the number is even. Odd numbers return themselves. **32 byte alt:** ``` lambda n:n*(n&-n)**0.58496250072 ``` [Try it online](https://tio.run/nexus/python2#S7ON@Z@TmJuUkqiQZ5WnpZGnppunqaVloGdqYWJpZmRqYGBu9D8tv0ghTyEzT6EoMS89VcNQx9hA04qLs6AoM69EIU0jT/M/AA "Python 2 ‚Äì TIO Nexus"). Has some float error. The constant is `log_2(3)-1`. Uses `(n&-n)` to find the greatest power-of-2 factor of `n`, the converts `3**k` to `2**k` by raising it to the power of `log_2(3)-1`. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 4 bytes ``` √í1~P ``` [Try it online!](https://tio.run/nexus/05ab1e#M7L0Kav8f3iSYV3A/0qlw/utFA7vV9L5DwA "05AB1E ‚Äì TIO Nexus") ### How it works ``` √í Compute the prime factorization of the input. 1~ Perform bitwise OR with 1, making the only even prime (2) odd (3). P Take the product of the result. ``` [Answer] ## Haskell, ~~24~~ 23 bytes ``` until odd$(*3).(`div`2) ``` The divide by two and multiply by 3 until odd trick in Haskell. [Try it online!](https://tio.run/nexus/haskell#@5@bmJmnYKtQUJSZV6KgopCbWKCgoVCaV5KZo5CfkqKioWWsqaeRkJJZlmCkqaCpEG2op2dkGfv/PwA "Haskell ‚Äì TIO Nexus") Alternative with a lambda instead of a pointfree function and with the same byte count: ``` odd`until`\x->div(x*3)2 ``` Edit: @ais523 saved a byte in the original version and @√òrjan Johansen one in the alternative version, so both version have still the same length. Thanks! [Answer] ## JavaScript (ES6), 19 bytes ``` f=x=>x%2?x:f(x*1.5) ``` While the input is divisible by two, multiplies it by 1.5, which is equivalent to dividing by 2 and multiplying by 3. [Answer] # [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 76 bytes ``` {{({}[()]<([({})]()<({}{})>)>)}{}([{}]()){{}((({})){}{})<>}<>}<>({}({}){}()) ``` [Try it online!](https://tio.run/nexus/brain-flak#HYrBDQAwCALXgX@fxkVMJyHObrHRyOVkJKgLvIEy8YLhNKXHiVJbUkZsg/8b2X9tVvqSM@cB "Brain-Flak ‚Äì TIO Nexus") ## Explanation This program works by dividing the number by two and tripling until it gets a remainder of one from the division. Then it stops looping and doubles and adds one to the final number. ### More detailed explanation eventually... [Answer] # Mathematica, ~~22~~ 19 bytes *Thanks to lanlock4 for saving 3 bytes!* ``` #//.x_?EvenQ:>3x/2& ``` Pure function that does the replacement repeatedly, one factor of 2 at a time. Works on all positive integers less than 265537. [Answer] # [Perl 6](https://perl6.org), 14 bytes ``` {1.5**.lsb*$_} ``` [lsb](https://docs.perl6.org/routine/lsb) returns the position of the least-significant bit, counted from the right. That is, how many trailing zeroes in the binary representation, which is the same as the number of factors of 2. So raise 3/2 to that power and we're done. ``` say {$_*1.5**.lsb}(24); > 81 ``` [Answer] # [Lean](https://leanprover.github.io/), ~~139~~ ~~82~~ 71 bytes *11 bytes saved by ovs.* ``` import data.nat.prime open list Œªx,prod$map(Œªp,p+1-p%2)$nat.factors x ``` [Try it online!](https://tio.run/##y0lNzPv/PzO3IL@oRCElsSRRLy@xRK@gKDM3lSu/IDVPISezuIQrJTVNIc3K9tzuCp2CovwUldzEAo1zuwt0CrQNdQtUjTRVQJrSEpNL8ouKFSr@K6eWJeYoaKQpGGlywdkmSGwjAySOpbnmfwA "Lean ‚Äì Try It Online") I'm really new to lean so, this answer is probably really inefficient in ways I don't yet know. But it works. We get a list of factors with `nat.factors` replace `2`s with threes using a `map` and roll it back up with `list.prod`. [Answer] # [MATL](https://github.com/lmendo/MATL), ~~7~~, 6 bytes ``` Yf1Z|p ``` [Try it online!](https://tio.run/nexus/matl#@x@ZZhhVU/D/v5EJAA "MATL ‚Äì TIO Nexus") *[1 byte saved thanks to Dennis's genius observation](https://codegolf.stackexchange.com/a/119003/31716)* --- The best way to explain this is to show the stack at various points. ``` Yf % Prime factors [2 2 2 3] 1Z| % Bitwise OR with 1 [3 3 3 3] p % Product 81 ``` Alternate solution: ``` Yfto~+p ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), ~~6~~ 5 bytes Saved a byte thanks to *Adnan*. ``` √íD√à+P ``` [Try it online!](https://tio.run/nexus/05ab1e#M7L0Kav8f3iSy@EO7YD/lUqH91spHN6vpPMfAA "05AB1E ‚Äì TIO Nexus") **Explanation** ``` √í # push list of prime factors of input D # duplicate √à # check each factor for evenness (1 if true, else 0) + # add list of factors and list of comparison results P # product ``` [Answer] # [Java](http://openjdk.java.net/), 38 bytes ``` int f(int n){return n%2>0?n:f(n/2*3);} ``` [Try it online!](https://tio.run/nexus/java-openjdk#JY5BC4JAFITP@iseQrDbklne2rJf0MljdNhM5YE@ZfdZhPjbbTUGZmDgG6Yfng0WUDTGObgZpHFGYqjE4iRHW/JgCWhzzJIrnSpB@@M2lXqa@z/p2LCPd4cvaD0vcrZI9f1hbO3kGAZVZ9cxvBw0ntNEo1JLH@Rfx2UbdwPHvUe4IYEqgl0GkaLys74RMvZXpNRhMIVe8w8) --- Previous 43-byte solution: ``` int f(int n){for(;n%2<1;)n=n/2*3;return n;} ``` [Try it online!](https://tio.run/nexus/java-openjdk#JY5BC4JAFITP@iseQrDbkmUeV/sHnTxGh81UHuhTdp9FiL/ddouBGRiYj5nmR4811L1xDq4GadmQGFoRnOTSjlZo2p2LTEsq6Xje59o2PFsC0us2/eeODft4jfiEwUNExRapu92N7Zxc4ihgAhHLTGORnzQqFfqo@jhuhnScOZ38hHsSqBI4XCBR1Lx/l4RM/R8pdRytsdf2BQ) [Answer] ## [Alice](https://github.com/m-ender/alice), 9 bytes ``` 2/S 3 o@i ``` [Try it online!](https://tio.run/nexus/alice#@2@kH6xgzJXvkPn/v6ERAA "Alice ‚Äì TIO Nexus") Alice has a built-in to replace a divisor of a number with another. I didn't think I'd actually get to make use of it so soon... Using the code points of characters for I/O, this becomes 6 bytes: `I23SO@`. ### Explanation ``` 2 Push 2 (irrelevant). / Reflect to SE. Switch to Ordinal. i Read all input as a string. The IP bounces up and down, hits the bottom right corner and turns around, bounces down again. i Try to read more input, but we're at EOF so this pushes an empty string. / Reflect to W. Switch to Cardinal. 2 Push 2. The IP wraps around to the last column. 3 Push 3. S Implicitly discard the empty string and convert the input string to the integer value it contains. Then replace the divisor 2 with the divisor 3 in the input. This works by multiplying the value by 3/2 as long as it's divisible by 2. / Reflect to NW. Switch to Ordinal. Immediately bounce off the top boundary. Move SW. o Implicitly convert the result to a string and print it. Bounce off the bottom left corner. Move NE. / Reflect to S. Switch to Cardinal. @ Terminate the program. ``` [Answer] # [Hexagony](https://github.com/m-ender/hexagony), ~~112~~ 91 bytes Grid size 6 (91 bytes) ``` ? { 2 . . < / = { * = \ " . & . . . { _ ' . . { . . } ' * 2 _ } { / . } & . ! " . > % . . < | . . @ | \ . . \ . | ~ . . 3 . . " . } . " . " . & . \ = & / 1 \ = { : = } . [ = { { { < ``` Compact version ``` ?{2..</={*=\".&...{_'..{..}'*2_}{/.}&.!".>%..<|..@|\..\.|~..3..".}.".".&.\=&/1\={:=}.[={{{< ``` Grid size 7 (112 bytes) ``` ? { 2 " ' 2 < / { * \ / : \ " . = . = . = | . 3 / & / { . . } { . " . > $ } { { } / = . 1 _ . . } . . _ . . & . { . > % < . . ~ & . . " . | | . . } - " . ' . @ | { . . . = & . . * ! . { . . . _ . . . _ . = > 1 . . . . . < [ . . . . . . . . . . . . . . . ``` [Try it online!](https://tio.run/##TY/BDoIwEETv/YqRKCQkloAXYgr6H5IQDkZPeoW0@ut12G2IbXa2ebuzbZ/3eXq8X0uM0HWBR4MMBdUZZRVZiYH5TM2UWnRbBOrJaGsu7Zb7I1naLXrsBXhqJbaahTE1rqrnnOGNGA5wgr4COYkRaArJdBRSMK5kXu@x8iA1lNjptK0y/uVO/9GjTnDdDrcYm/YH "Hexagony ‚Äì Try It Online") Compact Version: ``` ?{2"'2</{*\/:\".=.=.=|.3/&/{..}{.".>$}{{}/=.1_..}.._..&.{.>%<..~&..".||..}-".'.@|{...=&..*!.{..._..._.=>1.....<[ ``` Ungolfed Version for better readability: [![Ungolfed](https://i.stack.imgur.com/p6Umkm.png)](https://i.stack.imgur.com/p6Umk.png) Approximate Memory Layout [![enter image description here](https://i.stack.imgur.com/zT808.png)](https://i.stack.imgur.com/zT808.png) Grey Path (Memory initialization) ``` ? Read input as integer (Input) { Move to memory edge "Divisor left" 2 Set current memory edge to 2 " ' Move to memory edge "Divisor right" 2 Set current memory edge to 2 " Move to memory edge "Multiplier" 3 Set current memory edge to 3 " Move to memory edge "Temp 2" 1 Set current memory edge to 1 { { { Move to memory edge "Modulo" = Turn memory pointer around [ Continue with next instruction pointer ``` Loop entry ``` % Set "Modulo" to Input mod Divisor < Branch depending on result ``` Green Path (value is still divisible by 2) ``` } } { Move to memory edge "Result" = Turn memory pointer around * Set "Result" to "Temp 2" times "Multiplier" (3) { = & Copy "Result" into "Temp2" { { } } = Move to "Temp" : Set "Temp" to Input / Divisor (2) { = & Copy "Temp" back to "Input" " Move back to "Modulo" ``` Red Path (value is no longer divisible by 2) ``` } = & " ~ & ' Drag what's left of "Input" along to "Multiplier" * Multiply "Multiplier" with "Temp 2" ! @ Output result, exit program ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~8~~ 5 bytes ``` √Üf3¬ªP √Üf3¬ªP Main Link, argument is z √Üf Prime factors 3¬ª Takes maximum of 3 and the value for each value in the array P Takes the product of the whole thing ``` [Try it online!](https://tio.run/nexus/jelly#@3@4Lc340O6A////G1kAAA "Jelly ‚Äì TIO Nexus") -3 bytes thanks to a hint from @Dennis! [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 7 bytes ``` ~√ó‚ÇÇ√ó‚ÇÉ‚Ü∞| ``` [Try it online!](https://tio.run/nexus/brachylog2#@193ePqjpiYQ0fyobUPN//@GRv@jAA "Brachylog ‚Äì TIO Nexus") ## How it works ``` ~√ó‚ÇÇ√ó‚ÇÉ‚Ü∞| original program ?~√ó‚ÇÇ√ó‚ÇÉ‚Ü∞.|?. with implicit input (?) and output (.) added ?~√ó‚ÇÇ input "un-multiplied" by 2 √ó‚ÇÉ multiplied by 3 ‚Ü∞ recursion . is the output | or (in case the above fails, meaning that the input cannot be "un-multiplied" by 2) ?. the input is the output ``` [Answer] # [Hexagony](https://github.com/m-ender/hexagony), ~~28 27~~ 26 bytes ``` ?'2{{(\}}>='!:@=$\%<..>)"* ``` [Try it online!](https://tio.run/##y0itSEzPz6v8/99e3ai6WiOmttbOVl3RysFWJUbVRk/PTlNJ6/9/IwsA "Hexagony ‚Äì Try It Online") Laid out: ``` ? ' 2 { { ( \ } } > = ' ! : @ = $ \ % < . . > ) " * . . . . . . . . . . . ``` This basically runs: ``` num = input() while num%2 == 0: num = (num/2)*3 print num ``` At this point it's an exercise on how torturous I can get the loop path to minimise bytes. [Answer] # [Retina](https://github.com/m-ender/retina), 23 bytes ``` .+ $* +`^(1+)\1$ $&$1 1 ``` [Try it online!](https://tio.run/nexus/retina#4zI2UNHi0uM6tE1FL4HLyDGBS1XDPeG/njYXUFg7IU7DUFszxlCFS0VNxZDL8P9/AA "Retina ‚Äì TIO Nexus") Link is to test suite that runs automatically runs all inputs from 1 to 29. Explanation: ``` .+ $* ``` Convert to unary. ``` +`^(1+)\1$ $&$1 ``` While the value is even, multiply it by `3/2`. ``` 1 ``` Convert to decimal. Note that any FRACTRAN program is trivially convertible to a Retina program with unary I/O. The fraction itself is converted into a match for a string that appears an exact number of times given by the denominator, and the substitution is then `$1` repeated a number of times given by the numerator, although if this is greater than the denominator then `$&` can be used to golf down the code length. It then remains to loop each fraction back to the start of the script, so that the earliest possible fraction is always the next to be substituted. In the case of a single fraction no group is required of course. [Answer] # Pyth - ~~14~~ ~~10~~ 9 bytes ``` *^1.5/PQ2 ``` Counts the number of 2s in the prime factorization (/PQ2). Multiplies the input by 1.5^(# of 2s) [Try it](http://pyth.herokuapp.com/?code=%2a%5E1.5%2FPQ2&input=12&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A9%0A10%0A11&debug=0) [Answer] # [Risky](https://github.com/Radvylf/risky), 9 bytes ``` *\?+0+0+0__?\?+?:2 ``` [Try it online!](https://radvylf.github.io/risky?p=WyIqXFw_KzArMCswX18_XFw_Kz86MiIsIlsyOF0iLDBd) [Answer] # [BQN (CBQN)](https://mlochbaum.github.io/BQN/), 30 bytes ``` {0=2|ùï©?3√óùïäùï©√∑2;ùï©} ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704qTBvwfpH81ekPZq_UuFR2wQFIHtpaUmarsW-agNbo5oPc6eutDc-PB1Id4HYh7cbWYPoWoiibUBtXI8aFgVn5JcruB1aYaj9qG2qkSVEcsECCA0A) [Answer] # [J](http://jsoftware.com/), 11 bytes ``` [:*/q:+2=q: ``` [Try it online!](https://tio.run/nexus/j#@59maxVtpaVfaKVtZFto9f9/mpJBrKF2pp6RpYKfk55CYkFBTqVCmkJ@nkJqYnKGQn4aCJVkpCrkleYmpRYVK6QV5ecqGCqU5CsYWQIA "J ‚Äì TIO Nexus") `[:` cap (placeholder to call the next verb monadically) `*/` the product of `q:` the prime factors `+` plus (i.e. with one added where) `2` two `=` is equal to (each of) `q:` the prime factors [Answer] # [J](http://jsoftware.com/), ~~15~~ ~~12~~ 10 bytes ``` (+2&=)&.q: ``` [Try it online!](https://tio.run/nexus/j#NYyxCoMwFEX3fMUlgzEkPq1bX4mL0KlT104SYo1DpE3/PxXE4cI5w7mSoGY4hoJFB97XEManfdxLbfrK6Yo@XLQQfsohwxEuMIjUX0Xwy4YBtUIz7P26xZR/35jeeDEkI0x@wa3VJ@C4sIRZmkPKHw "J ‚Äì TIO Nexus") Works similar to below, just has different logic concerning replacement of `2` with `3`. # 15 bytes ``` (2&={,&3)"+&.q: ``` [Try it online!](https://tio.run/nexus/j#NYyxDoIwGAb3PsWXDi1Ny6/C5G/KYuLk5OpEmiJ1gEDdfPhKQhwuuVtOEvQAz9BwOII3asL14e63UjXKf51qjbSKFi5GiNDnmOEJJ1gkas4ihnFGh0qj7rbJe05T/qxpeuHJkIzYhxGXg/kL9oUjDNLuUX4) ## Explanation ``` (2&={,&3)"+&.q: &. "under"; applies the verb on the right, then the left, then the inverse of the right q: prime factors ( )"+ apply inside on each factor ,&3 pair with three: [factor, 3] 2&= equality with two: factor == 2 { list selection: [factor, 3][factor == 2] gives us 3 for 2 and factor for anything else &.q: under prime factor ``` [Answer] # PHP, 36 Bytes ``` for($a=$argn;$a%2<1;)$a*=3/2;echo$a; ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@ztbD@n5ZfpKGSaAvmW6skqhrZGFprqiRq2RrrG1mnJmfkqyRa//8PAA "PHP ‚Äì TIO Nexus") [Answer] ## CJam, ~~10~~ 9 bytes ``` rimf1f|:* ``` Really simple. Explanation: ``` ri e# Read integer: | 28 mf e# Prime factors: | [2 2 7] 1 e# Push 1: | [2 2 7] 1 f| e# Bitwise OR with each: | [3 3 7] :* e# Product: | 63 ``` [Answer] # [Japt](https://github.com/ETHproductions/japt), 7 bytes ``` k mw3 √ó ``` [Try it online!](https://tio.run/nexus/japt#@5@tkFturHB4@v//hiYA "Japt ‚Äì TIO Nexus") ### Explanation ``` k mw3 √ó k // Factorize the input. mw3 // Map each item X by taking max(X, 3). √ó // Take the product of the resulting array. // Implicit: output result of last expression ``` [Answer] # [Pyth](https://github.com/isaacg1/pyth), 9 bytes Integer output \o/ ``` *F+1.|R1P ``` [Test suite](http://pyth.herokuapp.com/?code=%2aF%2B1.%7CR1P&input=12&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A9%0A10%0A11&debug=0). ## How it works ``` *F+1.|R1P P prime factorization .|R1 bitwise OR each element with 1 *F+1 product ``` [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), 26 bytes ``` {‚çµ(‚ä£√ó(3*‚ä¢)√ó(√∑2*‚ä¢))2‚çü‚終à®2*‚çµ} ``` [Try it online!](https://tio.run/nexus/apl-dyalog#RY87DsJADERrOEXKhArP5lvmXIgWoUgr0VEhJGi4QJQD5Ca@SLAnyqZ7sj3z5KXX2@Oiccx1@M7PPJx0@BQG8wRiAY1v2@v9Z4M4Xpelz@Sg8SXHPoNDMAgblA6dQeVQGdTbpHFoDFoHOHXbTs6s9HtZ271ekC6FBnGF0AEeVHuMnpZTmoSx3SWUidtAW@kxSCrD@o0rQBuIZeoFbWCMtsCyJilAW80Ybej@ "APL (Dyalog Unicode) ‚Äì TIO Nexus") This is too verbose, I must be doing something wrong... [Answer] # R, 42 bytes The only right amount of bytes in an answer. ``` x=gmp::factorize(scan());x[x==2]=3;prod(x) ``` Pretty straightforward, uses the `gmp` package to factorize `x`, replaces 2s by 3s, and returns the product. [Answer] # [Japt](https://github.com/ETHproductions/japt), ~~19 16 10 9~~ 7 bytes ``` k ¬Æw3√É√ó ``` [Try it online!](https://tio.run/nexus/japt#@5@tcGhdufHh5sPT//83NAAA "Japt ‚Äì TIO Nexus") # Explanation ``` k ¬Æ w3√É √ó Uk mZ{Zw3} r*1 U # (input) k m # for every prime factor Z{Zw3} # replace it by the maximum of itself and 3 r*1 # output the product ``` ]
[Question] [ My colleague recently sent me the following piece of JavaScript as a joke: ``` let butScript = (nrOfButs) => { for(var i = 0; i < nrOfButs; i++){ if(i % 3 == 0){ console.log("Yeah") } if(i % 2 == 0){ console.log("But") } if(i % 3 == 1){ console.log("No") } } } ``` Since the code was written during work hours, it was obviously a huge waste of company resources. To prevent similar occurrences in the future, we must minimize the waste of worked hours. And since it is common knowledge that a shorter program is faster to write, we must golf this code to be as short as possible! ## Input A single non-negative integer. You must not handle faulty input. ## Output Your program must produce output identical to that of the script above. You should output one word per line, and the number of words should be consistent with the original script. It is permissible to include non-newline whitespace characters at the end of each line (but not at the beginning) since they are invisible. One additional newline character is permissible at the very end of the output. ## Examples ``` Input: 0 Output: Input: 1 Output: Yeah But Input: 2 Output: Yeah But No Input: 10 Output: Yeah But No But Yeah But No Yeah But No But Yeah ``` [Answer] # Excel, 78 bytes Assumes input in cell A1, and that Wordwrap formatting is turned on for cell. Use Alt+Enter to add line feeds within the string and note the whitespace. Only handles input up to 3570 due to limit of REPT function (Good luck getting a cell to be that tall, though). ``` =LEFT(REPT("Yeah But No But Yeah But No ",595),A1*9) ``` Reprinting, with periods for whitespace ``` =LEFT(REPT("Yeah But No...... But..... Yeah.... But No........... ",595),A1*9) ``` How it works: The pattern repeats every 6 numbers: ``` 0 = Yeah and But Yeah + linefeed + But + linefeed 1 = No No + 6 whitespace + line feed 2 = But But + 5 whitespace + linefeed 3 = Yeah Yeah + 4 whitespace + linefeed 4 = But and No But + linefeed + No + 3 whitespace 5 = Blank 8 whitespace + linefeed ``` Each of these can be expressed with 9 characters, so a string is made of 54 characters (9 \* 6), then repeated as large as Excel will allow. Then it takes the left 9 \* (number of input) characters as the output. Linefeed for the "but and no" one is placed after the blank so that the Yeah for #6, #12, (etc) is formatted to the left rather than the right, and so that there is no blank linefeed added every 6th line for that item. [![Output](https://i.stack.imgur.com/cWMSb.png)](https://i.stack.imgur.com/cWMSb.png) [Answer] # JavaScript (ES6), ~~59~~ 57 bytes ``` f=n=>n?f(n-1)+[s=n&1?`But `:'',`Yeah `+s,s+`No `][n%3]:'' ``` [Try it online!](https://tio.run/##Zc6xCsIwFIXhPU9xF01C0tLoZkkLgmt3KYWE2rRKuZGmuojPHoOjnvH/lnOzTxv65XpfM/SXIUanUVdYO4aZ4qINGreqNsfHSsyBUmnOg52IEUEGYRpPTNfiZt8limVbSCV3UhVd7vxysv3EEHQFLwLQewx@HvLZj4w2oIGCAOTlL2Xf0T9If3iKbx4/ "JavaScript (Node.js) – Try It Online") ### How? We use a recursive function which goes from \$n\$ to \$1\$ rather than from \$0\$ to \$n-1\$. As a result, the tests are off by \$1\$ compared to the reference code: * if \$n\equiv1\pmod 3\$, output *"Yeah"* * if \$n\equiv1\pmod 2\$, output *"But"* * if \$n\equiv2\pmod 3\$, output *"No"* This allows us to store the simpler case \$n\equiv0\pmod 3\$ as the first entry of our lookup array, where we can define \$s\$: a variable holding either `"But\n"` or an empty string. The two other entries are defined as `"Yeah\n" + s` and `s + "No\n"` respectively. *Note:* By iterating from \$n-1\$ to \$0\$, we could define \$s\$ in the first entry just as well, but that would cost [two extra parentheses](https://tio.run/##ZY49D4IwFAD3/oq36GvTloBukEJi4spuCEkbBNGQV0PRxfjb68eoN94td3F3F7r5fF00@WMf42DIlKR1NXASsrGH3o3MSh4MrbMKMbe728KsUEHa2jOrQtvQatvmiLFoUpWpjcrSNhn8vHfdyAlMCQ8G0HkKfuqTyZ841mAAQQKJ4jfpL/gXPj9v@RTxBQ). ### Commented ``` f = n => // n = input n ? // if n is not equal to 0: f(n - 1) + // prepend the result of a recursive call with n - 1 [ // define our lookup array: s = n & 1 ? // 1st entry: if n is odd: `But\n` // set s to "But" : // else: '', // set s to an empty string `Yeah\n` + s, // 2nd entry: "Yeah" followed by s s + `No\n` // 3rd entry: s followed by "No" ][n % 3] // append the correct entry for this iteration : // else: '' // return an empty string and stop recursion ``` [Answer] # [LOLCODE](http://lolcode.org/), 257 bytes ``` HAI 1.2 I HAS A B GIMMEH B B IS NOW A NUMBR I HAS A C ITZ 0 IM IN YR L UPPIN YR C TIL BOTH SAEM B AN C I HAS A D ITZ MOD OF C AN 3 D WTF? OMG 0 VISIBLE "Yeah" OIC MOD OF C AN 2 WTF? OMG 0 VISIBLE "But" OIC D WTF? OMG 1 VISIBLE "No" OIC IM OUTTA YR L KTHXBYE ``` [Try it online!](https://tio.run/##bY5NDoIwFIT37xQTDmAAD2Ba/voibQkUEXdGSVyQsNHzYwMJsnA3mflmMuM0PqbnMM9KMKJDTAwlGghIKljrTHkhwQ2M7bxrWi3rjUnA7oaQWIMN@hol2qpaZQLHJaR1Co3INCSEQbJV06WqbQqbe9ZnR0qpc/mJrC785oUblmWGoB/ur4AsJ7Sn47@s/LxXdDcV/WIzran/a1vnxHKZzk5dZZ/NcxR@AQ "LOLCODE – Try It Online") [Answer] # [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), ~~315~~ ~~304~~ ~~300~~ ~~277~~ 276 bytes Thanks to *@JoKing* for -11 bytes (reducing the amount of labels used from 8 to 7), and -24 more bytes (changing the general flow of the program and reducing the amount of labels used from 7 to 5 in the process). ``` [S S S N _Push_0][T N T T _Read_STDIN_as_integer][N S S N _Create_Label_LOOP][S S S N _Push_0][T T T _Retrieve][N T S S N _If_negative_jump_to_Label_PRINT][S S S N _Push_0][T T T _Retrieve][S S S T T N _Push_3][T S T T _Modulo][S S S T S N _Push_2][T S S T _Subtract][N T T T N _If_negative_jump_to_Label_SKIP_NO][S S T T S T T T T S N _Push_-94_\n][S S S T T T N _Push_7_o][S S T T T S T S N _Push_-26_N][N S S T N _Create_Label_SKIP_NO][S S S N _Push_0][T T T _Retrieve][S S S T S N _Push_2][T S T T _Modulo][N T S S S N _If_0_jump_to_Label_SKIP_BUT][S S T T S T T T T S N _Push_-94_\n][S S S T T S S N _Push_12_t][S S S T T S T N _Push_13_u][S S T T S S T T S N _Push_-38_B][N S S S S N _Create_Label_RETURN_FROM_BUT][S S S N _Push_0][S N S _Duplicate_0][S N S _Duplicate_0][T T T _Retrieve][S S S T N _Push_1][T S S T _Subtract][T T S _Store][T T T _Retrieve][S S S T T N _Push_3][T S T T _Modulo][N T S S T N _If_0_jump_to_Label_YEAH][N S N N _Jump_to_Label_LOOP][N S S S T N _Create_Label_YEAH][S S T T S T T T T S N _Push_-94_\n][S S S N _Push_0_h][S S T T T T N _Push_-7_a][S S T T T N _Push_-3_e][S S T T T T T N _Push_-15_Y][N S N N _Jump_to_Label_LOOP][N S S S N _Create_Label_PRINT][S S S T T S T S S S N _Push_104][T S S S _Add][T N S S _Print_as_character][N S N N _Jump_to_Label_LOOP] ``` Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only. `[..._some_action]` added as explanation only. [**Try it online**](https://tio.run/##ZY5RCoAwDEO/21PkCHokkYH@CQoev7Zpx0RhW7Mu6d697Vc7j2VtZgBUVES9UruUob2wkQrxJPRE35cfSk92JDyh3nkwH1H8Yui1JsaOAUUAYtUcfp7xgZVEbmTqy5VQxVaX4e5fk7XS8WY2Tw8) (with raw spaces, tabs and new-lines only). Whitespace is definitely not the right language for this challenge.. In Whitespace both loops and if-statements are made with labels and jumps to labels, and since they aren't if-elseif-else cases but multiple if-cases, ~~it means I will have to jump back after every if, making it quite long~~ it means I will have to slightly modify the checks to skip over some prints (thanks *@JoKing*). **Explanation in pseudo-code:** ``` Read STDIN as integer, and store it in the heap Start LOOP: Integer i = retrieve integer from heap If(i is negative): Call function PRINT If(i modulo-3 is NOT 2): Jump to Label SKIP_NO Push "\noN" to the stack Label: SKIP_NO If(i modulo-2 is 0): Jump to Label SKIP_BUT Push "\ntuB" to the stack Label: SKIP_BUT i = i - 1 Replace i in the heap with this updated value If(i modulo-3 is 0): Call function YEAH Go to next iteration of LOOP function YEAH: Push "\nhaeY" to the stack Go to next iteration of LOOP function PRINT: Print top of the stack as character to STDOUT Go to next iteration of LOOP (which will enter the if and then comes back to this PRINT again) ``` **Additional explanation:** In general, it loops from the input down to 0, pushing a newline and the word reversed (so in the order "\noN", "\ntuB", "\nhaeY" instead of "Yeah\n", "But\n", "No\n"). And after the input has looped down to 0 and all the characters are on the stack, it will print those characters in reverse (so the correct output order). More in depth however: Although we need to print words in the range `(input, 0]`, it will loop in the range `[input, 0)` instead. Because of this, we can use the check `if(i%3 == 2)` for "\noN" (or actually, `if(i%3 != 2)` skip the pushing of "\noN"), and we use the check `if(i%2 != 1)` for "\ntuB" (or actually, `if(i%2 == 0)` skip the pushing of "\ntuB"). Only after these two checks we decrease the iteration `i` by 1. And then do the check `if(i%3 == 0)` to push "\nhaeY", similar as in the JS example code in the challenge description. Skipping with if-not checks instead of going to a label and return from the label with if-checks saved 23 bytes. Also, in Whitespace character values are stored in the stack as their unicode values (i.e. `10` for new-lines, `65` for 'A', `97` for 'a', etc.). Since I already need to loop over the stack to print the characters, I am also able to [use my Whitespace tip](https://codegolf.stackexchange.com/a/158232/52210) to lower the byte-count by adding a constant to the number values, before printing them as characters. This constant is `104` in this case, which is generated with [this Java program](https://tio.run/##dVJNb9swDL37VxA8SVBqZMCKYUmEIhl2MLDkMHcfRVsMcqIm6hzZk@gCwZDf7sm1naRdepEgPvLxkXqP6kldPK5@1/UyV97DXBn7NwIoqyw3S/CkKFxPhVnBNkAsJWfs@vYeFG/SANoAOO2rnECCuh3ej58RYwn8VuW59g2QWNJr7eL59Oev79Mv3z4PIJEfLsenLH36154NscUfCscaPiOTsZm8uxyOjRCdgqMGiTigQSn7qrYu25GGbNQqjNeaZiHgGT@UA5AM5FP/Y2MCUqql/lSsNGs68rmiTawyz7ILw7nAO3sgh9CRUaz/VCr3rORXmC7ubIoj4sIdk0pJ/WPf3eaBuTjXdk0bxmFymPtE0n@rOGE82eqR5ggnIW5etmzPdOdJb@OiorgMG6PcMlwWNnyyJYkiEQgMxblVJGFyjl2PczStikByGOXN3DcQ9nLi56x9FI7Og90nn1PXOMO@8qPENEXB7GR4hdc4wrRX31spG/WOpGJmrHK7tpRZfs4kTshs8v5j@ONAdt15oF2r01Q5GzJwga3qfV3XN1ptollF0aKI/gE) that I've also used to golf [another Whitespace answer of mine before](https://codegolf.stackexchange.com/a/157709/52210). That's also the reason why this part of the code: ``` [S S T T S T T T T S N _Push_-94_\n][S S S T T T N _Push_7_o][S S T T T S T S N _Push_-26_N] ``` has the values `-94` for the newline, `7` for the 'o', and `-26` for the 'N'. Because adding the constant of `104` will correctly give our unicode values `10`, `111`, and `78` for these characters respectively. [Answer] # [Python 3](https://docs.python.org/3/), ~~85~~ 82 bytes ``` def f(n): for i in range(n):yield from['Yeah'][i%3:]+['But'][i%2:]+['No'][i%3^1:] ``` [Try it online!](https://tio.run/##K6gsycjPM/7/PyU1TSFNI0/TikshLb9IIVMhM0@hKDEvPRUkVpmZmpOikFaUnxutHpmamKEeG52pamwVqx2t7lRaAuYZgXl@@RCpOEOr2P8FRZl5JRo5mcUlGmkahgaampr/AQ "Python 3 – Try It Online") --- # [Python 3](https://docs.python.org/3/), ~~79~~ 76 bytes Port of [Keeta](https://codegolf.stackexchange.com/users/49088/keeta)'s [Excel answer](https://codegolf.stackexchange.com/a/172064/64121). ``` lambda n:(f"""Yeah But No But Yeah But No{'':11} """*n)[:9*n] ``` [Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPSiNNSUkpMjUxg8uptITLL18BDEAcCAMkBRMBSlerq1sZGtZyATVp5WlGW1lq5cX@LyjKzCvRSNMwNNDU/A8A "Python 3 – Try It Online") [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~63~~ 50 bytes ``` {<<"Yeah But"No But Yeah"But No">>[^$_ X%6].words} ``` [Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/2sZGKTI1MUPBqbREyS8fRCmA@Eoghl@@kp1ddJxKvEKEqlmsXnl@UUpx7f80DUMDTTs7veLEyv8A "Perl 6 – Try It Online") Anonymous code block that takes a number and returns a list of lines ### Explanation: ``` { } # Anonymous code block <<"Yeah But"No But Yeah"But No">> # Create the list of strings: # Yeah But # No # But # Yeah # But No [ ] # Index into this list ^$_ # The range from 0 to n-1 X%6 # All modulo 6 .words # Convert the list to a string # Which joins by spaces # And split by whitespace ``` [Answer] # [C (gcc)](https://gcc.gnu.org/), 75 bytes ``` f(o,_){for(_=0;o-_;_++%3-1||puts("No"))_%3||puts("Yeah"),1&_||puts("But");} ``` [Try it online!](https://tio.run/##S9ZNT07@/z9NI18nXrM6Lb9II97WwDpfN946Xltb1VjXsKamoLSkWEPJL19JUzNe1RjGj0xNzFDS1DFUi4eJOJWWKGla1/7PTczM0wCapWFoAOICAA "C (gcc) – Try It Online") --- # [C (gcc)](https://gcc.gnu.org/), 60 + 11 = 71 bytes (using `-D$=||puts(`) ``` f(o,_){for(_=0;o-_;_++%3-1 $"No"))_%3 $"Yeah"),1&_ $"But");} ``` [Try it online!](https://tio.run/##S9ZNT07@/z9NI18nXrM6Lb9II97WwDpfN946Xltb1VjXUEFFyS9fSVMzXtUYyIxMTcxQ0tQxVIsHcpxKS5Q0rWv/5yZm5mkANWsYGoC4/5LTchLTi//ruqjY1tQUlJYUawAA "C (gcc) – Try It Online") [Answer] # [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), ~~27~~ ~~25~~ 24 bytes Saved 1 byte thanks to *Kevin Cruijssen*. ``` F”¥æ€³€¸”#N3ÖNÈN3%‚‚˜Ï`» ``` [Try it online!](https://tio.run/##MzBNTDJM/f/f7VHD3ENLDy971LTm0GYQsQMooOxnfHia3@EOP2PVRw2zgOj0nMP9CYd2//9vaAAA "05AB1E (legacy) – Try It Online") **Explanation** ``` F # for N in [0 ... input] do: ”¥æ€³€¸”# # push ['Yeah', 'But', 'No'] N3Ö # push N % 3 == 0 NÈ # push N % 2 == 0 N3% # push N % 3 ‚‚˜ # add the 3 numbers to a list Ï # keep only the strings whose corresponding value # in the int list is true (1) `» # push strings separately to stack and join stack on newlines ``` [Answer] # [Python 2](https://docs.python.org/2/), 73 bytes ``` lambda n:'\n'.join((["Yeah\nBut","No","But","Yeah","But\nNo"]*n)[:n-n/6]) ``` [Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPSj0mT10vKz8zT0MjWikyNTEjJs@ptERJR8kvH0hAmCBhCCcmDygcq5WnGW2Vp5unbxar@b@gKDOvRCFNw0zzPwA "Python 2 – Try It Online") [Answer] # [Python 2](https://docs.python.org/2/), ~~97~~ ~~95~~ ~~92~~ ~~90~~ ~~83~~ 81 bytes ``` lambda n:[w for i in range(n)for w in'Yeah','But','No'if('N'in w)==i%(3-(w<'N'))] ``` [Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHPKrpcIS2/SCFTITNPoSgxLz1VI08TJFAOFFCPTE3MUNdRdyotAZJ@@eqZaRrqfupAleWatraZqhrGuhrlNkARTc3Y/wVFmXklCmkahgaa/wE "Python 2 – Try It Online") -2 bytes, thanks to ovs --- # [Python 3](https://docs.python.org/3/), ~~92~~ ~~90~~ ~~85~~ 83 bytes ``` lambda n:[w for i in range(n)for w in['Yeah','But','No']if('N'in w)==i%(3-(w<'N'))] ``` [Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHPKrpcIS2/SCFTITNPoSgxLz1VI08TJFAOFIhWj0xNzFDXUXcqLQGSfvnqsZlpGup@6kC15Zq2tpmqGsa6GuU2QBFNzdj/BUWZeSUaaRqGBpqa/wE "Python 3 – Try It Online") -4 bytes, thanks to ovs -4 bytes, thanks to Jo King [Answer] # [Canvas](https://github.com/dzaima/Canvas), 27 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md) ``` {╷⌐3%‽YeahP}2%‽ButP}3%╷‽NoP ``` [Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjVCJXUyNTc3JXUyMzEwJXVGRjEzJXVGRjA1JXUyMDNEWWVhaCV1RkYzMCV1RkY1RCV1RkYxMiV1RkYwNSV1MjAzREJ1dCV1RkYzMCV1RkY1RCV1RkYxMyV1RkYwNSV1MjU3NyV1MjAzRE5vJXVGRjMw,i=MTA_,v=8) [Answer] # [Groovy](http://groovy-lang.org/) (function), 79 bytes Since initially submitting my answer, I've looked through some historic discussions here about what constitutes a suitable answer. Since it seems commonly accepted to provide just a method in Java (including return type and parameter declarations), here is a shorter, Groovy, method which has the method return value be the answer. Use of `def` means that the return type is inferred. ``` def a(int n){n?a(--n)+(n%3?'':'Yeah\n')+(n%2?'':'But\n')+(n%3==1?'No\n':''):''} ``` Unlike the original answer below, which loops from 0 up to n-1, this one calls itself from n down to 1, but decrements the input for the rest of the line in the recursive call. [Try it online!](https://tio.run/##Sy/Kzy@r/P8/JTVNIVEjM69EIU@zOs8@UUNXN09TWyNP1dheXd1KPTI1MSMmTx0sYgQWcSotgQkY29oa2qv75QP5VurqmkBcCzavJLW4RCNPU6GaSwEICoqApufkKSip5FkpIUSAtuZpoiqwBQElrlouLrAJBpoQ2hBKG8H4QImi1JLSorz/AA "Groovy – Try It Online") # [Groovy](http://groovy-lang.org/) (program), 87 bytes Groovy scripts don't require certain common imports, so this can be a program printing the answer to Java's STDOUT without having to declare `System.out.` before `print`. It also provides some common utility methods, such as this `toLong()` which allows us to parse the input argument reasonably consicely. Essentially the Java 10 answer, but leveraging Groovy's shorter loop syntax and ability to evaluate truthy statements. ``` args[0].toLong().times{print((it%3?'':'Yeah\n')+(it%2?'':'But\n')+(it%3==1?'No\n':''))} ``` [Try it online!](https://tio.run/##Sy/Kzy@r/P8/sSi9ONogVq8k3yc/L11DU68kMze1uLqgKDOvREMjs0TV2F5d3Uo9MjUxIyZPXVMbJGQEFnIqLYGLGNvaGtqr@@UDBazU1TU1a////29oAAA "Groovy – Try It Online") [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 45 bytes ``` .+ $* 1 $`Yeah¶$`But¶$`11No¶ +`11B B 111 A`1 ``` [Try it online!](https://tio.run/##K0otycxL/P9fT5tLRYvLkEslITI1MePQNpUEp9ISEGVo6Jd/aBuXNpDhxOXEZWhoyMXlmGD4/7@hAQA "Retina 0.8.2 – Try It Online") Explanation: ``` .+ $* ``` Convert the input to unary. ``` 1 $`Yeah¶$`But¶$`11No¶ ``` For each integer `0...n-1`, generate three lines of text, one for each word, each with `i` `1`s before it, except for `No`, which has two extra `1`s so that we calculate `(i+2)%3==0` which is equivalent to `i%3==1`. ``` +`11B B ``` Remove pairs of `1`s before `B`s. ``` 111 ``` Remove `1`s in groups of three everywhere else. ``` A`1 ``` Delete all lines that still have a `1`. [Answer] # Java 10, ~~100~~ 99 bytes ``` n->{for(int i=0;i<n;)System.out.print((i%3<1?"Yeah\n":"")+(i%2<1?"But\n":"")+(++i%3>1?"No\n":""));} ``` -1 byte thanks to *@OlivierGrégoire*. [Try it online.](https://tio.run/##bY/NbsIwEITvPMUqUiVbEVGAGwYq9d5cOFVtD8aY1jRsoniDVKE8e7oxFuKnF0vzzXpndq@Perzf/vSm1N7Dq3Z4GgE4JNvstLFQDBLgWLktGMEcUCpG3YgfT5qcgQIQltDjeHXaVU0YcstcuQUquf71ZA9Z1VJWN@wI4Z5mi8lz8mb19wcm8ySRKbPpwF5auqA05cEVw6KKTKquV0Ns3W5Kjo3podqBi4s1ccLX@ydoeW5N1pPIQ98oJtdieuPkD3eFzcEMJ2HdUlx8f1WJItgpF41LMTNnFvU/X2Jg1/8B) **Explanation:** ``` n->{ // Method with integer parameter and no return-type for(int i=0;i<n;) // Loop `i` in the range [0, `n`) System.out.print( // Print to STDOUT: (i%3<1? // If `i` is divisible by 3: "Yeah\n" // Print "Yeah" with newline :"")+(i%2<1? // If `i` is even: "But\n" // Print "But" with newline :"")+(++i%3>1? // If `i` modulo-3 is 1: "No\n" // Print "No" with newline : // If none of the above three if's applied to the current `i`: ""));} // Print nothing for the current `i` ``` [Answer] # Powershell, ~~75~~ ~~74~~ ~~72~~ ~~67~~ 66 bytes *-1 byte thanks [TessellatingHeckler](https://codegolf.stackexchange.com/users/571/tessellatingheckler)* ``` param($n)(" Yeah But No But Yeah But No "*$n-split' ')[1..$n]-ne'' ``` Test script and explanation: ``` $f = { param($n)(" Yeah But No But Yeah But No "*$n-split' ')[1..$n]-ne'' # 1. repeat the string $n times # 2. split by space # 3. get elements from 1 to $n # some elements are multiline strings, some elements are $null: # ($null,"Yeah`nBut","But","No","But","Yeah","But`nNo",$null,...) # 4. remove $null elements from result array } # Output results @( 0,1,2,10 ) | % { &$f $_ "======" } # Advanced test @( ,(0,'') ,(1,'Yeah But') ,(2,'Yeah But No') ,(3,'Yeah But No But') ,(4,'Yeah But No But Yeah') ,(5,'Yeah But No But Yeah But No') ,(6,'Yeah But No But Yeah But No') ,(7,'Yeah But No But Yeah But No Yeah But') ,(8,'Yeah But No But Yeah But No Yeah But No') ,(9,'Yeah But No But Yeah But No Yeah But No But') ,(10,'Yeah But No But Yeah But No Yeah But No But Yeah') ,(20,'Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No') ) | % { $n,$e = $_ $r = &$f $n $r = $r-split"`n" # simplify test string "$($e-eq$r): $n : $r" } ``` Output: ``` ====== Yeah But ====== Yeah But No ====== Yeah But No But Yeah But No Yeah But No But Yeah ====== True: 0 : True: 1 : Yeah But True: 2 : Yeah But No True: 3 : Yeah But No But True: 4 : Yeah But No But Yeah True: 5 : Yeah But No But Yeah But No True: 6 : Yeah But No But Yeah But No True: 7 : Yeah But No But Yeah But No Yeah But True: 8 : Yeah But No But Yeah But No Yeah But No True: 9 : Yeah But No But Yeah But No Yeah But No But True: 10 : Yeah But No But Yeah But No Yeah But No But Yeah True: 20 : Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No But Yeah But No Yeah But No ``` Straightforward script, 72 bytes: ``` $args|?{$_}|%{0..--$_|%{@('Yeah')[$_%3] @('But')[$_%2] @{1='No'}[$_%3]}} ``` [Answer] # [Haskell](https://www.haskell.org/), 71 bytes ``` f n=[1..n]>>=(3?1)"Yeah"<>(2?1)"But"<>(3?2)"No" (a?b)c n=[c|n`mod`a==b] ``` [Try it online!](https://tio.run/##JYwxa8MwFIR3/4pDdJAgiNjZimVDmqXQtEOnkpjmxVZiE/vJ2DJd@t9diS7H3cfdtTQ/bN@v3TC6yeNAnvTRsesaSMi8UFDrDWxOqdZcFYWRuzJV4stSK/JCZjHsFx/9rsyUeHcikVReVR1H9S9fBtdcyJhrtQ7UMQwGGo/fkOPiP/30xtC4OxW079jOMHmOu/Uvjr1lP@OntZNNEDqY47p2XJPHSbxyeHiG2AS@gTjzx@IjOXNAC/@/adzwhMlSE1rVuk3SJEvS7R8 "Haskell – Try It Online") ### Explanation Pretty simple, saved two bytes by using `[1..n]` instead of `[0..n-1]` and adjusted the remainders: The operator `(?)` tests takes four arguments, returning an empty list or the provided string as a singleton if the result is correct. By currying the fourth argument of `(?)` we can make use of `(<>)` to concatenate the results of each function, ie.: ``` (3?1)"Yeah" <> (2?1)"But" <> (3?2)"No" ≡ \i-> (3?1)"Yeah" i ++ (2?1)"But" i ++ (3?2)"No" i ``` [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~105~~ ~~99~~ ~~94~~ ~~96~~ 89bytes ``` i=>{for(int x=0;x<i;)Write((x%3<1?"Yeah\n":"")+(x%2<1?"But\n":"")+(x++%3==1?"No\n":""));} ``` [Try it online!](https://tio.run/##Sy7WTS7O/O@YXJKZn2fjmVdibGSnkKhg@z/T1q46Lb9IIzOvRKHC1sC6wibTWjO8KLMkVUOjQtXYxtBeKTI1MSMmT8lKSUlTGyhmBBJzKi1BCGlrqxrb2gJF/fKhgprWtf@tubjA5vhk5qVqqCgZWClpWiskahgASYS4pjWKIkOoIkN8ioygiozwmgSzzxDdwv8A "C# (Visual C# Interactive Compiler) – Try It Online") [Answer] # [Pip](https://github.com/dloscutoff/pip), ~~37~~ ~~35~~ 33 bytes ``` "But Yeah No "<>5@:^[t2io02x]@<a ``` (Note the space after `But`.) Takes input as a command-line argument. [Try it online!](https://tio.run/##K8gs@P9fyam0RIErMjUxg8svn0vJxs7UwSouusQoM9/AqCLWwSbx////hgYA "Pip – Try It Online") ### Explanation *This explanation is for the previous version--see below for changelog* Inspired by [Jo King's Perl 6 answer](https://codegolf.stackexchange.com/a/172045/16766). We construct this list: ``` [ "Yeah But "; "No "; "But "; "Yeah "; "But No "; "" ] ``` and output the first `a` elements of it using cyclic indexing. ``` [t2io02x]R,3["But""Yeah""No"].n@<:a i is 0; o is 1; t is 10; x is ""; n is newline; a is 1st cmdline arg (implicit) [ ] Construct this list of scalars: t 10 2 2 i 0 o 1 02 02 x <empty string> R Treating each of these as a string, we're going to replace: ,3 0, 1, and 2 (respectively) with the corresponding values from this list: ["But""Yeah""No"].n These strings, each with a newline appended We now have constructed the list shown above @<:a Take the first a elements from this list, with cyclical indexing (the : is for parsing reasons) Concatenate them together and print (implicit) ``` **Update:** I realized that I don't need to use replace to change 0/1/2 into strings--I can use those numbers to index into a list directly. To do this, we have to make sure the multi-digit numbers are split into lists of their digits (otherwise, we'll be selecting index 10 instead of indexes 1 and 0). Fortunately, using an arbitrarily nested list as an index in Pip works as expected, giving a (nested) list of results. For input of 3, we get this data progression (where `_` represents a newline): ``` "But _Yeah_No_"<>5 ["But _"; "Yeah_"; "No_"] [t2io02x] [10; 2; 0; 1; 02; ""] @<a [10; 2; 0] ^ [[1; 0]; [2]; [0]] @: [["Yeah_"; "But _"]; ["No_"]; ["But _"]] ``` As before, the final result is concatenated together and autoprinted. [Answer] # [Attache](https://github.com/ConorOBrien-Foxx/Attache), 48 bytes ``` Flat##{Mask[_%3'2'3=0'0'1,$Yeah'$But'$No]}=>Iota ``` [Try it online!](https://tio.run/##SywpSUzOSP2fpmBl@98tJ7FEWbnaN7E4Ozpe1VjdSN3Y1kDdQN1QRyUyNTFDXcWptERdxS8/ttbWzjO/JPG/X2pqSnG0SkFBcnosV0BRZl5JSGpxiXNicWpxdJqOgoGVkbqRQex/AA "Attache – Try It Online") ## Explanation ``` Flat##{Mask[_%3'2'3=0'0'1,$Yeah'$But'$No]}=>Iota input: an integer { }=>Iota over each number from 0 to that integer exclusive Mask[ ,$Yeah'$But'$No] select values from that array according to: _%3'2'3 whether or not the input mod 3, 2, 3 =0'0'1 is 0, 0, 1 Flat## flatten the intermediate results ``` [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~77~~ ~~71~~ ~~74~~ ~~72~~ 69 bytes There's already a better **C** answer here but this one is recursive and it took me some time to get straight so I'm posting it. Down to 69 bytes thanks to both @ceilingcat and @JonathanFrech (I never think to use n-~-i in place of n-i+1) ``` i;f(n){i=n&&n-i>=~n/6&&f(n,i++,puts(i%7%4?i%7%2?"But":"No":"Yeah"));} ``` [Try it online!](https://tio.run/##LYpRC4IwFEbf/RVj4NhlG2VEQcuEfkDvgS9irS6jq5g@if31Na3zcPg4fLV51HUIaJ0kGDEnIcjgKf/QaidEjBqV0u3QvyWm@3RbzN4U/Dz0/MAvTdT1Xj05gJ3Cq0KSkIwJiyD1zNtluqZj0udr649ZZr1SsOSZtos/J3lJ5kd6@w9TEtcetJMebDKFLw "C (gcc) – Try It Online") [Answer] # Ruby, 69 ~~72~~ ~~74~~ Bytes ``` ->y{puts *(1..y).map{|i|[i%3==1&&:Yeah,i%2>0&&:But,i%3>1&&:No]-[!0]}} ``` Very straight-forward answer, checking for a shorter, recursive method right now. Saved two bytes thanks to @BWO :) Saved another three bytes by using symbols instead of strings [Answer] # Python 3, 93 bytes ``` [print("Yeah\n"*(i%3<1)+"But\n"*(i%2<1)+"No\n"*(i%3==1),end="")for i in range(int(input()))] ``` This isn't exactly the best solution but it's my take on it. [Try it online!](https://tio.run/##K6gsycjPM/7/P7qgKDOvREMpMjUxIyZPSUsjU9XYxlBTW8mptATKNwLz/fJh0ra2hpo6qXkptkpKmmn5RQqZCpl5CkWJeempGiCjMvMKSks0NDU1Y///NzQAAA) [Answer] ## R, 65 bytes ``` cat(c("yeah","but","no")[c(3,1:3,2,1,2)][1:scan()%%7+1],sep="\n") ``` Due to the fact that we are replicating a slightly flawed program (it misses out every fourth "but" — it should have used `%4 == 1` and `%4 == 3` rather than `%3` conditions), we have to use an awkward call to `c` and work in base seven. Still, it's shorter than LOLCODE... (I was hoping that (3,1,2,3,2,1,2) or a similar permutation might appear in the `lh` dataset somewhere but it doesn't look like it) [Answer] # [sed -E](http://www.grymoire.com/Unix/Sed.html), ~~179~~ 150 bytes ``` /^0/!s:$:g: :l;y:abcdefg:bcdefga: /[ae]/iYeah /[bdf]/iBut /[cg]/iNo s:.$:-&:;:s;s:0-:-9:;ts;h y:123456789:012345678:;G s:.*(.)-.*\n(.*).-:\2\1:;tl;c\ ``` The hardest part was not to construct the list but to actually parse the decimal number. 2 bytes may be saved if the newline at the end is not required: `c\` → `d`. Still requires optimization. [Try it online](https://tio.run/##NcvLCoJAAIXh/TxFgYQKc1G7eWYXRLv2kQWjjqMgGowufPmmiWh1vrP4ra6pGWbn@FPwtUUAA4JeLlBlVevG4DcKhN@VfvDuplXrXdaNP6d58q6M53UkFiwA3UDCSgtBQXPIycqWLEjSbLvbH445xJ@Ql28ShyyiLC6GkMURoyjSIvFZL6ti5ZwgKUkzkoj3@Jq6cbCOnj8). ### Explanation ``` /^0/! | if the input number doesn`t begin with a '0'… s:$:g: | …then append a 'g' to it and proceed | :l; | loop label 'l': y:abcdefg:bcdefga: | shift all occurences of [abcdef] 1 letter forward, and all 'g'-s to 'a'-s | /[ae]/ | if there`s an 'a' or 'e' in the input… iYeah | …output 'Yeah' | /[bdf]/ | if there`s a 'b' or 'd' or 'f' in the input… iBut | …output 'But' | /[cg]/ | if there`s a 'c' or 'g' in the input… iNo | …output 'No' | s:.$:-&:; | insert '-' before the last character :s; | loop label 's': s:0-:-9:; | transform the next consecutive '0' in the end of the number to '9', if any ts; | loop to 's' if more consecutive zeroes are available h | copy the result to the temporary buffer | y:123456789:012345678:; | decrement all digits except '0' (N.B.: digits, not numbers) G | append the temporary buffer to the result | s:.*(.)-.*\n(.*).-:\2\1:; | cut and replace the digit left to the last consecutive 0 in the original | number pasted from the temporary buffer, then discard all other digits decremented tl; | …then loop to 'l' if the number is ≥0 c\ | insert a carriage return and exit ``` [Answer] # [Clean](https://github.com/Ourous/curated-clean-linux), 116 bytes ``` import StdEnv,Data.List r=cycle $n=[e\\_<-[1..n]&a<-r["Yeah","",""]&b<-r["But",""]&c<-r["","No",""],e<-[a,b,c]|e>""] ``` [Try it online!](https://tio.run/##JY3LCoMwFET3fkUQcRWl7rWLYhcFKQVXRaVcr9EG8igxFoR@e9NUYRZzDgyDgoFyUg@LYEQCV47LlzaW1HY4qzctwUJa8dkGpsAVBQsiVTSsbR950mRpqroY8sQ04Z3BM6ThP13cb@q02B1xQ9@vehOU@THQnmL3YUcvXG3BfxYkItnBfXEUMM0uuVSuXBVIjjvcBNhRG/kD "Clean – Try It Online") [Answer] ## F#, 108 106 bytes ``` let v p=seq{for i=1 to p do if i%3=1 then yield"Yeah" if i%2=1 then yield"But" if i%3=2 then yield"No"} ``` [Try it online!](https://tio.run/##VY1BC4IwGIbv/oqXgVAHRe3aPARdI@gU4kF0q5FtOudAqt@@1CTqOz7P@/DxLiiVZs7VzMCioR1rH1xpCBrDKDSolAfBIfzNRK5MYhCsrsiZFVeyqORf7XpDvlHyaw6KvFy23Uujh6MS0qS5N32@F0Ki0BcL6mG8iZWqlwYU42pWYRbls7SLeqY4sTYUhmmseC9hRXkbEKRo9BhxCeJ35EPXcxk5F0dv) -2 bytes changing from `i=0 to p-1` to `i=1 to p` and adjusting modulos. Apart from that, pretty straight-forward. [Answer] # PHP, ~~65~~ 68 bytes ``` while($i<$argn)echo["Yeah "][$i%3],["But "][$i%2],["No "][~-$i++%3]; ``` Run as pipe with `-nR` or [try it online](http://sandbox.onlinephpfunctions.com/code/b65c92164b9e7d65fe21d983f1e9b11d6a497fae). [Answer] # VBA (Excel), ~~105, 101,~~ 99 Bytes Edit: -4 bytes from Keeta! Thanks! Edit 2: -2 bytes from Chronocidal! Woot! (Realized that test cases only worked for 10. Fixed now) **Yeah, Excel beat VBA this time. Whatever.** (We're coming for you) ``` d=vbCr:For i=1To[a1]:a=i Mod 3:?IIf(a=1,"Yeah"+d,"")IIf(i/2=i\2,"","But"+d)IIf(a=2,"No"+d,"");:Next ``` ^This is pasted into the Immediate window and outputs to the debug window Ungolfed ``` d = vbCr 'For 1 to the value in A1 (using 0 gave extra values, and VBA skips the for loop if 0) For i = 1 To [a1] 'aka: Range("A1").value a = i mod 3 '? is the same as Print (Debug.Print when not in the Immediate Window) Print IIf(a = 1, "Yeah" + d, "") _ '<-- Just a line continuation 'Keeta taught me that the \ operator is division with truncation, ' so if they are equal then there is no remainder! IIf(i / 2 = i \ 2, "", "But" + d) _ IIf(a = 2, "No" + d, ""); 'Print usually prints a newline, but it still outputs if the string is blank... ' So we append a newline -if true- and use a semi-colon to kill the newline Next ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 22 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` 5Rż7FṚṁị“'⁴\ÆẓNƇ»ḲŒP¤Ẏ ``` A monadic Link yielding a list of lines (which seems to have been allowed in comments) **[Try it online!](https://tio.run/##ATsAxP9qZWxsef//NVLFvDdG4bma4bmB4buL4oCcJ@KBtFzDhuG6k07Gh8K74biyxZJQwqThuo7/w4dZ//8xMA "Jelly – Try It Online")** (the footer calls the Link using `Ç` and joins with newlines using `Y` since implicit printing in Jelly smashes everything together if it can) ### How? First note that we have a period of \$2\times3=6\$ due to the modulo definition. Now note that the first six values are: ``` ["Yeah", "But"] ["No"] ["But"] ["Yeah"] ["But", "No"] [] ``` So the resulting list of lines should be these values repeated (or truncated) to length `n` concatenated together. Now note that the power-set of `"Yeah", "But", "No"` is: ``` [] ["Yeah"] ["But"] ["No"] ["Yeah", "But"] ["Yeah", "No"] ["But", "No"] ["Yeah", "But", "No"] ``` So each period is these 1-indexed values of the power-set of `"Yeah", "But", "No"`: ``` 5, 4, 3, 2, 7, 1 ``` The code makes this list, moulds it to length `n`, indexes into the power-set, and then removes the inner lists (which also removes the empty strings, since strings are lists in Jelly)... ``` 5Rż7FṚṁị“'⁴\ÆẓNƇ»ḲŒP¤Ẏ - Link: integer, n e.g. 10 5 - literal five 5 R - range [1,2,3,4,5] 7 - literal seven 7 ż - zip together [[1,7],[2],[3],[4],[5]] F - flatten [1,7,2,3,4,5] Ṛ - reverse [5,4,3,2,7,1] ṁ - mould like (n) [5,4,3,2,7,1,5,4,3,2] ¤ - nilad followed by link(s) as a nilad: “'⁴\ÆẓNƇ» - compressed string "Yeah But No" Ḳ - split at spaces ["Yeah","But","No"] ŒP - power-set [[],["Yeah"],["But"],["No"],["Yeah","But"],["Yeah","No"],["But","No"],["Yeah","But","No"]] ị - index into [["Yeah","But"],["No"],["But"],["Yeah"],["But","No"],[],["Yeah","But"],["No"],["But"],["Yeah"]] Ẏ - tighten ["Yeah","But","No","But","Yeah","But","No","Yeah","But","No","But","Yeah"] ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~93~~ ~~92~~ 83 bytes ``` lambda i:''.join('Yeah\n'*(x%3<1)+'But\n'*(x%2<1)+'No\n'*(x%3==1)for x in range(i)) ``` [Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSHTSl1dLys/M09DPTI1MSMmT11Lo0LV2MZQU1vdqbQEyjcC8/3yYdK2toaaaflFChUKmXkKRYl56akamZqa/wuKMvNKFJQ88wpKSxQMY/KUuCAiaRqGmlwokkbIkkZokoYGKFoNNP8DAA "Python 2 – Try It Online") A massive 9 bytes saved with thanks to @Jonathan Frech ]
[Question] [ # Briefing The difficulty of a Code Golf question can be calculated as such: $$\text{clamp} \left( \left\lceil \left( \frac v a \div 700 \right) \times 10 \right\rceil, 0, 10 \right)$$ Where \$v\$ is the number of views a question has and \$a\$ is the number of answers a question has and \$⌈x⌉\$ is the [ceiling operator](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions). Also: $$\text{clamp}(x, min, max) = \begin{cases} min & x < min \\ x & min \le x \le max \\ max & max < x \end{cases}$$ This question's current difficulty: `***` # Task Write a program that will take two integers `(v and a)` and output the difficulty in `asterisks (*)`. The input can be in the form of an array, a separated string or as separate function arguments # Test Data ``` Views Answers Difficulty Program Output 163 2 2 ** 548 22 1 * 1452 24 1 * 1713 37 1 * 4162 32 2 ** 3067 15 3 *** 22421 19 10 ********** ``` ### Example with pseudocode ``` v: 1713 a: 37 out = clamp(ceil(((v/a)/700)*10), 0, 10); // evaluates to 1 //program will output '*' ``` The shortest code in bytes wins! Trailing/ leading spaces are allowed. [Answer] ## JavaScript (ES6), ~~40~~ 39 bytes ``` v=>a=>"**********".substring(10-v/a/70) ``` Because `substring` provides the required clamping and "ceil"ing behaviour. Edit: Normally I'm too lazy to bother, but because it got 4 upvotes, I've followed @MarsUltor's advice to save 1 byte by currying. [Answer] I've been wanting to do this for a while... ## HTML + CSS ~~491~~ ~~487~~ 485 bytes *-4 bytes thanks to Conor O'Brien* *-2 bytes thanks to Releasing Helium Nuclei* Input is taken as the width and height of the page window; width being the number of Views, and height being the number of Answers. ``` <style>p{overflow:hidden;width:1ch}@media(max-aspect-ratio:70/2){p{width:1ch}}@media(max-aspect-ratio:70/3){p{width:2ch}}@media(max-aspect-ratio:70/4){p{width:3ch}}@media(max-aspect-ratio:70/5){p{width:4ch}}@media(max-aspect-ratio:70/6){p{width:5ch}}@media(max-aspect-ratio:70/7){p{width:6ch}}@media(max-aspect-ratio:70/8){p{width:7ch}}@media(max-aspect-ratio:70/9){p{width:8ch}}@media(max-aspect-ratio:7/1){p{width:9ch}}@media(max-aspect-ratio:70/11){p{width:10ch</style><p>********** ``` You can try it in your browser by entering ``` data:text/html,<style>p{overflow:hidden;width:1ch}@media(max-aspect-ratio:70/2){p{width:1ch}}@media(max-aspect-ratio:70/3){p{width:2ch}}@media(max-aspect-ratio:70/4){p{width:3ch}}@media(max-aspect-ratio:70/5){p{width:4ch}}@media(max-aspect-ratio:70/6){p{width:5ch}}@media(max-aspect-ratio:70/7){p{width:6ch}}@media(max-aspect-ratio:70/8){p{width:7ch}}@media(max-aspect-ratio:70/9){p{width:8ch}}@media(max-aspect-ratio:7/1){p{width:9ch}}@media(max-aspect-ratio:70/11){p{width:10ch</style><p>********** ``` as a url in a new tab. [Answer] ## 05AB1E, 11 bytes ``` /70/î'*T×s£ ``` **Explanation** ``` / # divide v by a 70/ # divide by 70 î # round up, call this n '*T× # push 10 asterisks s£ # take n up to 10 asterisk # implicitly print ``` [Try it online](http://05ab1e.tryitonline.net/#code=LzcwL8OuJypUw5dzwqM&input=MTUKMzA2Nw) [Answer] ## Javascript (ES6), ~~37~~ 36 bytes ``` v=>a=>"*".repeat((v/=a*70)<9?v+1:10) ``` *Saved 1 byte by currying, thanks to TheLethalCoder* ``` let F= v=>a=>"*".repeat((v/=a*70)<9?v+1:10) console.log("Test #1:", F(163)(2)) // ** console.log("Test #2:", F(548)(22)) // * console.log("Test #3:", F(1452)(24)) // * console.log("Test #4:", F(1713)(37)) // * console.log("Test #5:", F(4162)(32)) // ** console.log("Test #6:", F(3067)(15)) // *** console.log("Test #7:", F(22421)(19)) // ********** ``` [Answer] # Mathematica, ~~38~~ 35 bytes ``` StringRepeat["*",10,⌈#/#2/70⌉]& ``` *Thanks to @MartinEnder for 3 bytes* [Answer] ## EXCEL, 29 bytes If you count Excel as a representation of VBA Excel, then you can use ``` =REPT("*",MIN(1+v/(70*a),10)) ``` where `v` and `a` are the name of reference cells. [Answer] ## CJam, ~~18~~ ~~15~~ 14 bytes *Saved 1 byte thanks to Peter Taylor and 3 bytes thanks to Adnan* ``` '*A*q~d/70/m]< ``` [Try it online](http://cjam.aditsu.net/#code='*A*%20%20%20%20%20%20%20%20%20%20%20%20e%23%20Push%20%22**********%22%0A%20%20%20%20q~d%2F%20%20%20%20%20%20%20%20e%23%20Get%20the%20input%20and%20divide%20the%20two%20numbers%0A%20%20%20%20%20%20%20%2070%2F%20%20%20%20%20e%23%20Divide%20by%2070%0A%20%20%20%20%20%20%20%20%20%20%20m%5D%20%20%20e%23%20Ceil%2C%20yielding%20x%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%20%20e%23%20Slice%20the%20string%2C%20taking%20the%20first%20x%20elements&input=1452%2024) ``` '*A* e# Push "**********" q~d/ e# Get the input and divide the two numbers 70/ e# Divide by 70 m] e# Ceil, yielding x < e# Slice the string, taking the first x elements ``` [Answer] ## C#, ~~68~~ ~~49~~ 48 bytes ``` v=>a=>"**********".Substring((int)(10-v/a/70d)); ``` This is the C# version of [this excellent answer](https://codegolf.stackexchange.com/a/90138/38550) by Neil. *Saved another 19 bytes thanks to Neil* [Answer] # Java 8, 57 bytes Uses a lambda to save bytes, performs the calculation and substrings to return the answer. ``` (v,a)->"**********".substring(Math.max(0,(700*a-v)/70/a)) ``` --- Here is my class for testing it. ``` public class DifficultyCalculator{ static interface h{ String f(int v, int a);} static void g(h H){ System.out.print(H.f(163,2));System.out.println("\t**"); System.out.print(H.f(548,22));System.out.println("\t*"); System.out.print(H.f(1452,24));System.out.println("\t*"); System.out.print(H.f(1713,37));System.out.println("\t*"); System.out.print(H.f(4162,32));System.out.println("\t**"); System.out.print(H.f(3067,15));System.out.println("\t***"); System.out.print(H.f(22421,19));System.out.println("\t**********"); } public static void main(String[] args) { g( // 70 (v,a)->"**********".substring(java.lang.Math.max(0,(int)(10-v/70d/a))) ); } } ``` --- **Update** * **-3** [16-08-19] Utilized integer division * **-10** [16-08-18] Removed unnecessary import, thanks to *@OlivierGrégoire*! * **-18** [16-08-17] Return string instead of print [Answer] # [MATL](https://github.com/lmendo/MATL), 12 bytes ``` /70/0:9>42*c ``` [**Try it online!**](http://matl.tryitonline.net/#code=LzcwLzA6OT40Mipj&input=MzA2NwoxNQ) ### Explanation The rounding up and clamping are done simultaneously as follows: the number `x = v/a/70` is compared against each element of the array `[0 1 ... 9]`. The numbers of that array that are exceeded by `x` will become asterisks, and the rest will be spaces. ``` / % Take the two numbers implicitly. Divide. (Example: for inputs 3067, 15 % we get 204.47) 70/ % Divide by 70 (we get 2.92) 0:9 % Push array [0 1 ... 9] > % See which of those are exceeded by the previous number (2.92 exceeds % 0, 1 and 2, so we get [1 1 1 0 ... 0]). This does the rounding up % and the clamping 42* % Multiply by 42, which is the ASCII code of '*' (we get [42 42 42 0 ... 0]) % Char 0 will be displayed as space c % Convert to char. Implicitly display ``` [Answer] # Python2, 32 bytes saved 3 + 2 bytes and corrected off by one error thanks to Leaky Nun ``` lambda v,a:('*'*10)[:~-v/a/70+1] ``` similar to Neils answer. Uses the fact that Python2 does integer division. [Answer] # Haskell, 35 bytes ``` v#a=[1..min(ceiling$v/a/70)10]>>"*" ``` `[1..min(ceiling$v/a/70)10]` creates a range from 1 to the computed difficulty (an empty list for difficulty 0). `a>>b` repeats the list `b` `length a` often. [Answer] # [Pyth](https://github.com/isaacg1/pyth), ~~17~~ 13 bytes **4 bytes in credit to Luis Mendo for [his algorithm](https://codegolf.stackexchange.com/a/90141/48934).** ``` ~~\*\\*htS[0T.EccFQ70~~ *\*s>LccFQ70T ``` [Test suite.](http://pyth.herokuapp.com/?code=%2a%5C%2as%3ELccFQ70T&test_suite=1&test_suite_input=163%2C2%0A548%2C22%0A1452%2C24%0A1713%2C37%0A4162%2C32%0A3067%2C15%0A22421%2C19&debug=0) [Answer] ## Pyke, ~~13~~ 9 bytes ``` /70/\**T< ``` [Try it here!](http://pyke.catbus.co.uk/?code=%2F70%2F%5C%2a%2aT%3C&input=2%0A163&warnings=0) Explanation: ``` / - num_1 / num_2 70/ - ^ / 70 \** - "*" * ^ T< - ^[:10] ``` [Answer] ## C#, ~~97~~ ~~89~~ ~~87~~ ~~77~~ ~~42~~ 41 bytes ``` v=>a=>new string('*',(v/=a*70)<9?v+1:10); ``` *Saved 10 bytes thanks to Adám* *Saved a few bytes thanks to Arnauld* [Answer] # Perl, ~~35~~ 32 bytes ``` say"*"x(10-($-=10-pop()/70/pop)) ``` Use `-E` to activate `say` and give the arguments in the reverse order: ``` perl -E 'say"*"x(10-($-=10-pop()/70/pop))' 2 163 ``` If arguments on STDIN are allowed the following is 29 bytes: ``` (echo 163; echo 2) | perl -pe '$_="*"x(10-($-=10-$_/70/<>))' ``` [Answer] # R, 68, 50 52 bytes ``` f=function(v,a)cat(rep("*",1+min(v/a/70,10)),sep="") ``` `rep` implicitly places a min on number of 0. Thanks to @plannapus and @Anastasiya-Romanova秀 for spotting my error. [Answer] # Javascript ES6, 48 bytes ``` a=>b=>"*".repeat(Math.ceil(Math.min(a/b/70,10))) ``` [Answer] # m4, ~~136~~ 135 bytes ``` define(r,`ifelse($1,0,,eval($1>9),1,*`r(9)',*`r(decr($1))')')define(f,`r(ifelse(eval($1%($2*70)),0,eval($1/$2/70),eval($1/$2/70+1)))') ``` Defines a macro `f` which takes `v` and `a`, and expands to the correct output. Most of the program is an implementation of ceiling. [Answer] # C, ~~54~~, ~~51~~, ~~50~~, 49 bytes Assuming that `v` is positive or zero and `a` positive, the `x < min` clamping case is never met, since there is no way the result of the ceiling operation can be negative. Additionally, integer maths on non-negative values always yields the floor of the result, so we add `1` to get the ceiling. This solution requires a `write` function, works on Linux at least. ``` F(v,a){write(1,"**********",(v/=a*70)>9?10:v+1);} ``` Test main: ``` int main() { F(163, 2); putchar('\n'); F(548, 22); putchar('\n'); F(1452, 24); putchar('\n'); F(1713, 37); putchar('\n'); F(4162, 32); putchar('\n'); F(3067, 15); putchar('\n'); F(22421, 19); putchar('\n'); } ``` [Answer] ## javascript: ~~82~~ 73 bytes ``` (v,a)=>console.log("*".repeat(Math.min(Math.max(0,Math.ceil(v/a/70),10))) ``` * *saved some bytes after Adám pointed out I overlooked the /700\*10=/70*, and the removal of parens [Answer] # [Dyalog APL](http://goo.gl/9KrKoM), 15 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319) ``` '*'⍴⍨10⌊⌈⎕÷70×⎕ ``` `'*'⍴⍨` the character repeated this many times: `10⌊` min(10,... `⎕÷` input divided by `70×` seventy times `⎕` input [TryAPL online!](http://tryapl.org/?a=%u2191%u2191%7B%27*%27%u2374%u23680%u230810%u230A%u2308%u237A%F770%D7%u2375%7D/%A8%28163%202%29%28548%2022%29%281452%2024%29%281713%2037%29%284162%2032%29%283067%2015%29%2822421%2019%29&run) [Answer] ## [Jellyfish](https://github.com/iatorm/jellyfish), 18 bytes ``` P #'* mM/%i 10 %70 ``` Takes input in the format `[a v]`. [Try it online!](http://jellyfish.tryitonline.net/#code=UAojJyoKbU0vJWkKMTAgJTcw&input=WzIgMTYzXQ) ## Explanation * `%` is reciprocal, so `%70` is 1/70. * `i` is input, as a two-element array. * `/%` with inputs `i` and `%70` reduces the array `i` by flipped division with initial value `%70`. In other words, it computes **v/(a/(1/70))**, which is equal to **v / (70\*a)**. * `M` takes the ceiling of this value, and `m` takes the maximum of that and `10`. * `#'*` repeats the literal `*` character that many times. * `P` prints the result without quotes. [Answer] # MATLAB, 34 33 bytes Because I like this challange so much, here is one for MATLAB (outputs trailing whitespaces): ``` @(v,a)[(ceil(v/a/70)>0:9)*42,''] ``` Inspired by @Luis Mendo's answer. Thanks to @pajonk for saving one byte. [Answer] # dc, ~~110 108 104~~ 98 bytes This was a doozy since slicing isn't a thing. Also, dc doesn't manipulate strings. I just really was waiting for a string one that would be < 5 hours of coding. On the plus side, I finally started writing down common constructs, like for loops. Also had to formulate rounding/ceiling, so thanks for that. ``` [42P]sd[dsi[li0!=dli1-dsi0!=L]dsLx]sl[Isi[li0!=dli1-dsi0!=L]dsLx]sg[1+]saIk/70*0k1~0!=adI>ldI!>gIP ``` Invoked in bash: ``` echo 'v a (above)'|dc # Wholly: >> echo '163 2 [42P]sd[dsi[li0!=dli1-dsi0!=L]dsLx]sl[Isi[li0!=dli1-dsi0!=L]dsLx]sg[1+]saIk/70*0k1~0!=adI>ldI!>gIP'|dc # outputs: ** >> ``` Replacing (above) with the code, and `v` and `a` with their respective counterparts above. The single quotes are important (otherwise you get bash's history stuff). --- Explained: ``` [42P]sd # Here we store a macro in register d to print 1 * without a newline [dsi[li0!=dli1-dsi0!=L]dsLx]sl # Store the "less than" case, a for loop which # uses the top-of the stack as it's number of iterations. [Isi[li0!=dli1-dsi0!=L]dsLx]sg # Store the "greater than" case. It's the above, # but it puts 10 on the stack to use instead. [1+]sa # Store a macro to add 1 to whatever is the top-of-stack. Ik # Set precision at non-zero to allow decimal division /70* # Divide the top two of the stack, v/a; multiply by 70 (`/700*10` == `/70`) # dc is postfix and stack-based, so operators come after operands. 0k1~0!=a # This is a ceiling function. |> 0k # set precision to 0 to perform integer division |> 1~ # push the quotient of integer division by 1, and then the remainder. (r is top) |> 0!=a # If the top-of-stack (decimal part) is not 0, add 1 to the quotient dI>ldI!>g # Conditional statement |> dI>l # (d)uplicate the top, push 10 on. If 10 > the old top, execute the `l`ess-than # case, which loops top-of-stack times. |> dI!>g # Complement of the above, using the `g`reater-than to loop 10 times. IP # print a newline ``` This is probably more golf-able, but I was trying to get it finished to avoid premature optimization. * 2 bytes saved by duplicating-saving instead of saving-loading * 4 bytes saved dividing by 70 * 6 bytes from daniero's suggestions (non-strings, ASCII nums instead; 10 => I) [Answer] # Haskell, 35 bytes This solution is as completely different from *Laikoni*s answer as it gets for something this trivial. Yet the score (for now) is exactly the same. ``` v%a=take(ceiling$v/a/70)[0..9]>>"*" ``` This produces ten stars, then shaves off some. Easy to extend to arbitrary difficulty with an infinite list. I did manage to shave off one more byte. But while all test cases work, this shouldn't be correct in general. ``` v%a=take(1+div v(a*70))[0..9]>>"*" ``` [Answer] # TI-Basic, 39 bytes ``` Prompt V,A sub("**********",1,max(0,min(10,int(V/A/70)+1 ``` [Answer] # [Vyxal](https://github.com/Lyxal/Vyxal), 9 bytes ``` /70/ṙ›\** ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%2F70%2F%E1%B9%99%E2%80%BA%5C**&inputs=1%0A306&header=&footer=) [Answer] ## PowerShell v2+, 47 bytes ``` -join(('*'*11)[1..($args[0]/$args[1]/70+.499)]) ``` Somewhat a port of @Neil's [JavaScript answer](https://codegolf.stackexchange.com/a/90138/42963). Takes input `$args` and divides them, then divides that by `70`, and adds `.499`. Since PowerShell does [banker's rounding](https://msdn.microsoft.com/en-us/library/system.math.round(v=vs.110).aspx#Midpoint), this is effectively `ceil` to two decimal points of precision. If additional precision is required, tack on as many additional `9`s as required. Along with the `1..`, this forms a range index into a string. The string is `'*'*11`, i.e. `'***********'`. That results in a char-array, so we `-join` it together back into a string. That string is left on the pipeline and output is implicit. Like Neil's answer, this effectively "clamps" the output to be between 1 and 10 stars. ### Test Suite ``` PS C:\Tools\Scripts\golfing> @(@(163,2), @(548,22), @(1452,24), @(1713,37), @(4162,32), @(3067,15), @(22421,19))|%{($_-join', ')+" -> " +(.\difficulty-of-a-question $_[0] $_[1])} 163, 2 -> ** 548, 22 -> * 1452, 24 -> * 1713, 37 -> * 4162, 32 -> ** 3067, 15 -> *** 22421, 19 -> ********** ``` [Answer] # Python 3, ~~69~~ 68 bytes I didn't want to copy the Python 2 answer, so mine is slightly longer. ``` from math import* x=lambda v,a:print(max(0,min(ceil(v/a/70),10))*'*') ``` Saved 1 byte thanks to Program man ]
[Question] [ An *insignificant array* is an array of positive integers, where the absolute differences between consecutive elements are all smaller than or equal to **1**. For example, the following array is insignificant: ``` [1, 2, 3, 4, 3, 4, 5, 5, 5, 4] ``` Because the corresponding (absolute) differences are: ``` [1, 1, 1, 1, 1, 1, 0, 0, 1] ``` Which are all smaller than or equal to **1**. --- Your task is to determine whether a given array of integers is insignificant. * You may assume that the array always contains at least two elements. * [Standard input and output rules](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) apply. You may take input (and output) in any reasonable format. * [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden. * The truthy / falsy values have to be distinct and consistent. * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins. # Test cases ``` Input -> Output [1, 2, 3, 4, 3, 4, 5, 5, 5, 4] -> true [1, 2, 3, 4, 5, 6, 7, 8, 9, 8] -> true [3, 3, 3, 3, 3, 3, 3] -> true [3, 4, 4, 4, 3, 3, 3, 4, 4, 4] -> true [1, 2, 3, 4] -> true [5, 4, 3, 2] -> true [1, 3, 5, 7, 9, 7, 5, 3, 1] -> false [1, 1, 1, 2, 3, 4, 5, 6, 19] -> false [3, 4, 5, 6, 7, 8, 7, 5] -> false [1, 2, 4, 10, 18, 10, 100] -> false [10, 20, 30, 30, 30] -> false ``` I used the values `true` and `false`. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 3 bytes ``` IỊẠ ``` **[Try it online!](https://tio.run/##y0rNyan8/9/z4e6uh7sW/P//P9pQR8FIR8FYR8EERprCkEksAA "Jelly – Try It Online")** # How? Just the perfect challenge for Jelly. ``` IỊẠ Full program. I Increments; Get the difference between consecutive elements. Ị Insignificant; return abs(number) ≤ 1. Ạ All; returns 1 if all the elements are truthy, 0 otherwise. ``` [Answer] # JavaScript (ES7), ~~33~~ 29 bytes *Saved 4 bytes thanks to @JohanKarlsson* ``` a=>!a.some(v=>(a-(a=v))**2>1) ``` ### How? When coerced to `Number`, arrays of at least two elements are evaluated to `NaN`. By re-using the input ***a*** as the variable holding the previous value, the first iteration of ***some()*** always results in ***([v0, v1, ...] - a[0]) \*\* 2 = NaN***, no matter the value of ***a[0]***. So, the first test is always falsy and the actual comparisons start at the 2nd iteration, just as they're meant to. ### Test cases ``` let f = (a,p)=>!a.some(v=>(p-(p=v))**2>1) console.log(f([1, 2, 3, 4, 3, 4, 5, 5, 5, 4])) // true console.log(f([1, 2, 3, 4, 5, 6, 7, 8, 9, 8])) // true console.log(f([3, 3, 3, 3, 3, 3, 3] )) // true console.log(f([3, 4, 4, 4, 3, 3, 3, 4, 4, 4])) // true console.log(f([1, 2, 3, 4] )) // true console.log(f([5, 4, 3, 2] )) // true console.log(f([1, 3, 5, 7, 9, 7, 5, 3, 1] )) // false console.log(f([1, 1, 1, 2, 3, 4, 5, 6, 19] )) // false console.log(f([3, 4, 5, 6, 7, 8, 7, 5] )) // false console.log(f([1, 2, 4, 10, 18, 10, 100] )) // false console.log(f([10, 20, 30, 30, 30] )) // false ``` [Answer] # [Python 3](https://docs.python.org/3/), 40 bytes ``` f=lambda n,*t:t==()or-2<n-t[0]<=1==f(*t) ``` [Try it online!](https://tio.run/##hZHbCoMwDIav51MEdmNHBVt1U7FPIr1wbGWCq9J14J7edfUwD4OVPwmkH39I27z0rZZB1wlWFffzpQCJDzrVjLmoVh7NpKdzn2eMMCbcg0adqBW0UEpwHWeXEwwUQ4AhHHM0KuSA96DV87rizN0RwwlDjCExec4FFlqIw3QWXDhqQofO77kzm7UfGDAaregfkFgqsgskNke2Q/gAiqJ6DKN7rRYnCV@C21f5mPLv6JkjtSzxTcRD9X2@AU2fmgim4MtletBBKTSqlNo1X9si1L0B "Python 3 – Try It Online") [Answer] ## Mathematica, 24 bytes ``` Max@Abs@Differences@#<2& ``` [Answer] # [Haskell](https://www.haskell.org/), ~~34~~ 33 bytes ``` all((<2).abs).(zipWith(-)=<<tail) ``` [Try it online!](https://tio.run/##dVDNCoJAGLz7FINEGKzgrpYa2LFTt7rFFisqSmbhz6Gnt83afkyX@T6X2WFkJhXVKc7ztk0MsQyX5SxgK0OY4ezAptPEeDBagmNAV1Z7FlmBANEFGkwTVXpp8gi3LJZ7VzaxhmuZFTUmSLCnBIzAJnDUnis4fFQpXxcELoFH4Mv9q7Q72Q841OkrHYW3@MWM/f1jNeQ4V15sSNfU27rcFNB1DX/drEVe/ZVjd2HdLqbb3SVDOfq6J3oFUZ8PxP0u72HJgYGoUkgtOd7ra1m9QiTJ5Njv4e0d "Haskell – Try It Online") *-1 byte thanks to [@user1472751](https://codegolf.stackexchange.com/users/65900/user1472751)* --- The point-free solution is ~~one~~ ~~two~~ again only one byte (*thanks to -1 byte from [@Dennis](https://codegolf.stackexchange.com/users/12012/dennis)*) shorter than the recursive approach: ``` f(a:b:r)=2>(a-b)^2&&f(b:r) f _=1>0 ``` [Try it online!](https://tio.run/##dVDNCoJAGLz7FEOEGKzg@pMp6LFTt7rFEisqSabhz6Gnt81aK9Nlvs9ldhiZOfP6kuR516Ua9yO/WgVmyKNa43q0UtVUe1JKilNAQ6O78qxAgLiEAl1HfS7bPMY9S8Q@VG2i4FZlRYMlUhwpgUlgEdhyOxI2m1WK1zWBS7Ah8MT@VVq97AcM8oyVtsQgfjNzf/9YTTk60suc0rXNvql2BRYLBX/dbHle/5Vj9WHdPqbb3wVDGca6F0YFUY9NxP0u72nJgImoQkgNMZv31zBGhQjSFGMNw7oH "Haskell – Try It Online") [Answer] # [Octave](https://www.gnu.org/software/octave/), 21 bytes ``` @(x)all(diff(x).^2<2) ``` Anonymous function that inputs a numeric vector and ouputs `1` if insignificant or `0` otherwise. [**Try it online!**](https://tio.run/##dZFhC4MgEIa/9yvuY4FIaq1iC/Y/RoNoCYHUYDUGY7/d3SzbrCbvncf5qK/YVX15r7XMKaX66D@CUin/0kiJJT3zAw90016H/gY5POHECHACgkBkc2wVFR58h0Pi6o5AQiAlkGF2SWEwRysgspqZqfPvUrcf2718xQtjLzHGElNjh62wUYsXsWzL6O9rPyduWUSMhRjpNIfhgsImxxBzFPDae1WtlBxaXxIYfyXQbw "Octave – Try It Online") [Answer] # [Pyth](https://github.com/isaacg1/pyth), 6 bytes ``` ._MI.+ ``` **[Verify all the test cases.](https://pyth.herokuapp.com/?code=._MI.%2B&input=%5B1%2C+2%2C+3%2C+4%2C+3%2C+4%2C+5%2C+5%2C+5%2C+4%5D&test_suite=1&test_suite_input=%5B1%2C+2%2C+3%2C+4%2C+3%2C+4%2C+5%2C+5%2C+5%2C+4%5D%0A%5B1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7%2C+8%2C+9%2C+8%5D%0A%5B3%2C+3%2C+3%2C+3%2C+3%2C+3%2C+3%5D%0A%5B3%2C+4%2C+4%2C+4%2C+3%2C+3%2C+3%2C+4%2C+4%2C+4%5D%0A%5B1%2C+2%2C+3%2C+4%5D%0A%5B5%2C+4%2C+3%2C+2%5D%0A%5B1%2C+3%2C+5%2C+7%2C+9%2C+7%2C+5%2C+3%2C+1%5D%0A%5B1%2C+1%2C+1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+19%5D%0A%5B3%2C+4%2C+5%2C+6%2C+7%2C+8%2C+7%2C+5%5D%0A%5B1%2C+2%2C+4%2C+10%2C+18%2C+10%2C+100%5D%0A%5B10%2C+20%2C+30%2C+30%2C+30%5D&debug=0)** --- # [Pyth](https://github.com/isaacg1/pyth), 8 bytes ``` .A<R2aVt ``` [Try it online!](https://tio.run/##K6gsyfj/X8/RJsgoMazk//9oQx0FIx0FYx0FExhpCkMmsQA "Pyth – Try It Online") # Explanation ``` ._MI.+ Full program. .+ Deltas. I Is invariant under... ._M Mapping with Sign. 0 if n == 0, -1 if n < 0, 1 if n > 0. ``` --- [Answer] # [Python 2](https://docs.python.org/2/), 35 bytes ``` x=input() while-2<x.pop(0)-x[0]<2:1 ``` Exists with status code **1** for insignificant arrays, with status code **0** otherwise. [Try it online!](https://tio.run/##fZDBboMwDIbPzVNYXQ@tlCISoC1btp1222HabUI5ZJCOSFVAJdXo0zOWFAqsWvTbkexPv@N8iipvUmHgCZSu1JdWe5UKbbzyDIyB19SPSpcns1yh71wd5Jqy2iuLcumv1nXic0bvSeMh14SjFNkDZAWalWeTF5reMmUwX7y/vL1@zNFMpnkBi2eUFVo2CcFAMQQYwi5HnUIOd2COJ4lGVNvZYNhi2GGI23ylAouMxKE/Ayrs1IOXyq2JA4uJF6Ak6mzovxixTGSfHdsc2QrhDtuLQ@WGOk2WJTEfYn//4deQ90OvbtSSxG9jd7l9n0@wtkrbCPrgoxUc9gM "Bash – Try It Online") [Answer] # [Husk](https://github.com/barbuz/Husk), 4 bytes ``` ΛεẊ- ``` [Try it online!](https://tio.run/##yygtzv7//9zsc1sf7urS/f//f7ShjpGOsY4JGJuCoUksAA "Husk – Try It Online") Explanation: ``` ΛεẊ- 2-function composition Λ (x -> y):f -> [x]:x -> TNum: Check if f returns a truthy result for all elements of x ε f: TNum:x -> TNum: Check if abs(x) <= 1 (shamelessly stolen from Jelly) Ẋ x: (x -> x -> y):f -> [x]:x -> [y]: reduce each overlapping pair of x by f - f: TNum:x -> TNum:y -> TNum: y - x ``` [Answer] # [Japt](https://github.com/ETHproductions/japt), 6 bytes ``` äa e<2 ``` [Try it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=5GEgZTwy&input=WzEsIDIsIDMsIDQsIDMsIDQsIDUsIDUsIDUsIDRd) ## Explanation ``` ä Get all pairs of elements a Take absolute difference of each pair This results in the deltas of the array e Check if every element... <2 Is less than 2 ``` [Answer] # APL, 13 bytes ``` {×/(|2-/⍵)<2} ``` First APL answer \o/ Note: I am a bot owned by Hyper Neutrino. I exist mainly for chat testing. # Explanation ``` {×/(|2-/⍵)<2} { } Function; right argument is ⍵ ( ) Bracketed Expression / Reduce 2 Every pair (two elements) of ⍵ ⍵ - Using subtraction | Magnitude (Absolute Value) <2 For each element, is it less than two? / Reduce over × Multiplication (Product) (All) ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes ``` ¥Ä2‹P ``` [Try it online!](https://tio.run/##MzBNTDJM/f//0NLDLUaPGnYG/P8fbaijYKSjYKyjYAIjTWHIJBYA "05AB1E – Try It Online") **Explanation** ``` ¥ # calculate deltas Ä # absolute values 2‹ # smaller than 2 P # product ``` [Answer] # [Proton](https://github.com/alexander-liao/proton), 41 bytes ``` a=>all(-2<a[i]-a[i+1]<2for i:0..len(a)-1) ``` [Try it online!](https://tio.run/##NcRBCoAgEADAr@xxlzTS7BLWR8TDHgoEURH/v3URhmm9jlqk9VQGovB1c86oreeQov5bTPT2rR3Sua1rfgoyaUNCGIwCq2BX4ObH5CKRfA "Proton – Try It Online") -16 bytes thanks to Mr. Xcoder -2 bytes -6 bytes thanks to Mr. Xcoder [Answer] # [Ohm v2](https://github.com/MiningPotatoes/Ohm), 4 bytes ``` Δ2<Å ``` [Try it online!](https://tio.run/##y8/INfr//9wUI5vDrf//RxvqKBjpKBjrKJjoKJjqKJjpKJjrKFjoKFgCyVgA "Ohm v2 – Try It Online") # How? ``` Δ2<Å ~ Full program. Δ ~ Absolute deltas. 2< ~ Is smaller than 2? Å ~ Check if all elements are truthy. ``` [Answer] # [C# (.NET Core)](https://www.microsoft.com/net/core/platform), ~~51~~ ~~45~~ 44 + 18 bytes *-1 byte thanks to [Jeppe Stig Nielsen](https://codegolf.stackexchange.com/users/8727/jeppe-stig-nielsen)* ``` a=>a.Zip(a.Skip(1),(x,y)=>x-y).All(x=>x*x<4) ``` Byte count also includes: ``` using System.Linq; ``` [Try it online!](https://tio.run/##ZU9RT8IwEH5ef8XJA7SmNIxNgchIiIlPmhhHQqLxoY4ijaXDteiI4bdjuzEjmtz1Lt93993XzHSzvBAHzdfCbHgmIN0ZK9bsVup39IWCTHFjYIoC1wfGcisz@MjlAu641Jg40BPBzVZnY6nt0zOFlzxXE1hCcuDJhLNHucGcpW@uhITiku5IMim7O8KmSuHS9eflOCYHp3LlpYwtpH4FqTdbWwGfK6kExhUACVzn2uRKsAfBF86lwITAWQJ6qxS02/WeB1ot7y4Imvl5Ia2oFpa1Fks3SlrcoR0KHegQNl@JQuASkgmURwWWCiUyW4Puf@yeF8bNsFkh1@4yYbN8WhR853vvdo9c7A8hhT6FiELcvBdNxOg36YBLCgMKQwoj96KoYk4C1aNxoxY1y/GpGrpoJvoejSr1QaU7qHqHhJ6p44@HcIT@W/J7xwuOCXsuh8fa6yFf@y6jn/wG "C# (.NET Core) – Try It Online") Explanation: ``` a => // Take an array of integers as input a.Zip( // Combine each element with corresponding one from: a.Skip(1), // the input array without first element (x, y) => x - y // get their difference ) .All(x => x * x < 4) // Check if all differences are less than 2 // (We only care about 0 and 1, and so happens that when they're squared, it works like Abs! Magic!) ``` [Answer] # [Perl 6](https://perl6.org), 25 bytes ``` {?(2>all(.[]Z-.skip)>-2)} ``` [Try it online!](https://tio.run/##fVHLTsMwELznK0aih1ZyKj/zUCH8B5UFPTQSIogqgQOq@u1hs46bpCCys2trPJnNOqdj22T9@zdWNR7Qnx/Xujo0zXq790/ptnt7PW2qVG8u/S65ezmfk70S0AJGwMbqIqxHWuGz/TouZXSUCeQChUBJdSYzrFnA4/rMZTbiqhyZP5vOTG7dkOxdNNL/6xSLHH97ydUxo/yoqw9NF/oG3IysSr/Q/b6OwdJPfSc/zVIlKYtxldLf6ojWlOaafjlH0F0uSXcY/vB69bxB/dHiXkHDwHI6DluJiXbIkKNAiWKgDWYRCMsRKN7PXh@2jk91YA0Z5mSW02qgAjnE1E2V0Tf2JnH0tDQ83QNXKZmVNDjNG1Dt@h8 "Perl 6 – Try It Online") This should be pretty readable. The only less obvious thing here is that the zip operator `Z` will stop zipping when the shorter list is exhausted (we remove the first element of the list at the right) and that the empty subscript `.[]`, so called Zen slice, gives the whole list. `.skip` returns the list without the first element. [Answer] # [R](https://www.r-project.org/), ~~30~~ 26 bytes ``` cat(all(diff(scan())^2<2)) ``` [Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jUTMxJ0cjJTMtDciMM7Ix0vyfppGsYaqjYKKjYKyjYKSpyQUSMAYLAIXNdBTMdRQswKSppqbCfwA "R – Try It Online") [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 62 bytes ``` param($a)$l=$a[0];($a|?{$_-$l-in1..-1;$l=$_}).count-eq$a.count ``` [Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVRUyXHViUx2iDWGsipsa9WiddVydHNzDPU09M1tAZJxtdq6iXnl@aV6KYWqiRCmP///3fQMNRRMNZRMNVRMNdRsASTpmARQ00A "PowerShell – Try It Online") PowerShell doesn't have a `.map` or `.some` or similar command, so here we're individually checking each delta. We take input `$a` and set `$l` equal to the first element. Then we loop through `$a` and take out each element where `|?{...}` the difference `$_-$l` is `-in` the range `1,0,-1`. We then set `$l` equal to the current element. So now we have a collection of elements where the delta between their previous neighbor is 1. We take the `.count` of that and check whether it's `-eq`ual to the `.count` of the array as a whole. If it is, then every delta is 1 or less, so it's an insignificant array. That Boolean result is left on the pipeline, and output is implicit. [Answer] # Factor, ~~48~~ 33 bytes Saved 15 bytes thanks to @chunes! ``` [ dup rest v- vabs supremum 2 < ] ``` [Try it online!](https://tio.run/##XY6xDsIwDET3fMX9QFsKdABVbGVlQEyIIYQgliqRnXSgCr8empIuyDrZOvvp/OZXVNLhgE9VPqVyhgpSaFt0p6O4nLs9rCTWBOmdKTxrkRYLwsaT0hlcKDFiRI01GuwQ8ryZVGM1KVVyG2xnNyDEKx7egjQ7DAUGeWewt6R7308XLW6xlxalmMMrY131i8zt/5P4BQ "Zsh – Try It Online") (results are at the bottom) `dup rest` makes a copy of the inputted sequence without the first element. `v-` subtracts that from the original sequence (\$a\_n-a\_{n-1}\$). Then `vabs` gets the absolute values of that. `supremum` finds the maximum value in the sequence, and `2 <` makes sure it's 0 or 1. [Answer] # [Python 3](https://docs.python.org/3/), 45 bytes ``` lambda k:all(-2<x-y<2for x,y in zip(k,k[1:])) ``` **[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHbKjEnR0PXyKZCt9LGKC2/SKFCp1IhM0@hKrNAI1snO9rQKlZT839BUWZeiUaaRrShjoKRjoKxjoIJjDSFIROQQgA "Python 3 – Try It Online")** or **[Try the test suite.](https://tio.run/##XZDBDoMgDIbvPEWPmtREQOc0@iSOg8tiRmRqjAfdyztgoHPJXyj/B7TpuM7PoedbW9021bzujwa6olEqiFi5RGvJ2mGCBVeQPbzlGHTY1bQQYbgpqKCuKQJD4AiJX1OvRCA5ce1dEDKEK0KuV8O5hSc5O/HaiXPO35pT6u8xx7gtltkymc21Qx386q8rmh9lf/s0r4@CGtJYx9XtcWyZTpkOvocQhJjBSTM2VRAYJ9nPQRtIPbgP)** Thanks to [Jonathan Frech](https://codegolf.stackexchange.com/users/73111/jonathan-frech) for -2 bytes. [Answer] # [MATL](https://github.com/lmendo/MATL), ~~6~~ 5 bytes ``` d|2<A ``` -1 byte thanks to *Giuseppe* [Try it online!](https://tio.run/##y00syfn/P6XGyMbx//9oQx0FIx0FYx0FExhpCkMmsQA "MATL – Try It Online") or [Verify all test-cases](https://tio.run/##y00syfmf8D@lxsjG8b9LyP9oQx0FIx0FYx0FExhpCkMmsVwo0kAhMx0Fcx0FCx0FSyAJlDYGy6EgiKgJDMEloCIoZgI5pjBVRhAZY7A95mAbzMFsoIghRA6C0NxjaAm3EdmBIL1wu4ByhgZAbAGlDQxAUkCWERAbw3GsgoICAA "MATL – Try It Online") [Answer] # [anyfix](https://github.com/alexander-liao/anyfix), 9 bytes ``` I€A€2<»/& ``` [Try it online!](https://tio.run/##S8yrTMus@P/f81HTGkcgNrI5tFtf7f///9GGOgpGOgrGOgomMNIUhkxiAQ "anyfix – Try It Online") ``` I€A€2<»/& Main Link I Deltas € For each element A Take its absolute value € » For each element 2< Is it less than two? / Reduce over & Logical AND ``` This is mostly a port of the 05AB1E solution except terrible because anyfix doesn't have autovectorization and other cool things [Answer] # [Java (OpenJDK 8)](http://openjdk.java.net/), 60 bytes ``` a->{int r=1,p=a[0];for(int i:a)r|=(r=p-(p=i))*r;return r<2;} ``` [Try it online!](https://tio.run/##jVJtb4IwEP7ur7iYmMBSkBfZVMRkP2DJkn00fqgIpg4LaYuJcfx2VlogKmYZubvS63PPXZvniM/YyouEHvffdVHuMhJDnGHO4QMTCtcRQJvlAgu5nHOyh5M8M74EI/Sw2QJmB242SICjpLNLQTI7LWksSE7tT5bsSYxFsiJUbLZrSCGCGlvrq9wDi1xURHjjbMM0Z0aTIktssp/IYFFhGUVETPOFhSwRJaPAVl5Y1aHqpehke5FwwSWnngDg6iLwEPgIZl0MOptVCKZTEKxMnqEl4hXBG4I5goWMQ7SvoHcmQf03RM866wvazF@T3FI@ckMHDzpa719wV2EDdb2FioHKuLpawlOc8dthtD08jrtQ@Ef48P2aBv1gT9g9VeE60uft6jhtwQAuTz3pfu93V76DV1odUk1gKIkogSy1TMxeJV8XLpKTnZfCLqSORWqMJ5bv8SVMdhM6RjdSfmcMX7gtcq14o2EyEaR286N3pm5ajRqv6l8 "Java (OpenJDK 8) – Try It Online") * 5 bytes thanks to @Nevay! [Answer] # C, ~~61~~ 56 bytes *Thanks to @scottinet for saving five bytes!* ``` r;f(a,n)int*a;{for(r=1;--n;r=(*a-*++a)/2?0:r);return r;} ``` [Try it online!](https://tio.run/##fdPNboQgEADgu08x2aQJuJgC/peYPkjbg7Frs4fShtqT8dkt4GJ1MRhQA87nOGCXfHTdPCvRo5ZIfJVD3Iqx/1JINUwkiRSqQXGbxOdzix/5M31SWKjL8KskKDHNOgA@26tEOBoj0IcZGC4/A3t5gwZGRoATSAlk7py7lk3CRnwrHdOj08P7qzwR6JENJ8AoxiLaodxHNVQQKAlUBGp9DqH8EE0XNLXiroUsPV96VLZSmWurdhsJmdlhfvn9R4cIU1dPKBYhdwnxA2FjFM7YIeWaRmqrXtp6l/Zej7BQVuZZL6tqBZd2t6SsDonVkVhvy7/dGCbLkGY2jqcxui28XRvdq9uV0uD2pUfbg7mfQs9y3dO1e9a/pF@fG2ma/wA) # C (gcc), 47 bytes ``` r;f(a,n)int*a;{for(r=1;--n;r=(*a-*++a)/2?0:r);} ``` [Try it online!](https://tio.run/##fdPNboQgEADgu08x2aQJ7GIK@F9i@iBtD8bWZg@1DfVmfHY74GJ1MRhAw8/nOGAbf7btPGvVkYb19NoP50aN3bcmuhYqjnula3Ju4vPl0tBH@cyfNFXTjPPgq7n2hEZjBHiZjuHjdxAvb1DDKBhIBgmD1LWZK@mk7IofjWs6cnp4f@1PDDpilzMQnFIV7VDpowjlDAoGJYMK2xAqD9FkQRMr7krIwvHCo9KVSl1ZtVtPyEwP48vuPzpEmLx6Qr4ImQtIHggbI3fGDinWMBKb9cLmu7DP2CNCUZm5XlTlCi7lbktFFRLLI7Hapn97MEyUIc0cHE8TfJt4uzdYy9ud8@Dx5UfHQ7ifAkcl1mStnvUv4eszI03zHw) [Answer] # [Ruby](https://www.ruby-lang.org/), 36 35 33 bytes ``` ->b,*a{a.all?{|x|(b-(b=x))**2<2}} ``` Takes the input array as individual arguments. -1 byte thanks to MegaTom, -2 bytes thanks to Jordan. [Try it online!](https://tio.run/##KypNqvyfZvtf1y5JRyuxOlEvMSfHvrqmokYjSVcjybZCU1NLy8jGqLb2f0FpSbFCWrShjoKRjoKxjoIJjDSFIZNYLiyKgBJmOgrmOgoWOgqWQBKuyBisAgUhy5nAEFwaKoLFFriQKUyHEbIqY7ArzMH2m4PZQBFDZBUQhOZmQ0s09yB7BWQOmkuAKgwNgNgCShsYIBQA@UZAbAzHsf8B "Ruby – Try It Online") [Answer] # [Julia 0.6](http://julialang.org/), 21 bytes ``` ~x=all(diff(x).^2.<2) ``` [Try it online!](https://tio.run/##fZFha8MgEIa/51cc/aQgJZqka8YcDPYvwg3CkhQXyUq00H3pX8@sM1lcy@S9E86H9zz9OGlV76bpcpa11qRRXUfOdPsmtk@CTo18Ve@WJBVnIBhkDPI5F7NyBPkMdjy1LObc2Y7BA4M9g9LlNZd5KBLCsiIun7WgoXK/78rmjl8xO4n/Oe6hwl@/9LnwFY6B62ptAvijP2PzEmPw9k2upvjbeeUoPMtTF/uwpynegK4uXGRLYDxLAGmSHEc1WD2QzYvWYFtjDRxrY9RweIQNg@vPV5cepISm6hG6zxF6UAP07ZchDUVKp28 "Julia 0.6 – Try It Online") -1 byte thanks to MarcMush: pass a single argument to `all` [Answer] # [Java (OpenJDK 8)](http://openjdk.java.net/), 78 bytes ``` a->{int p=0,i=1;for(;i<a.length;p+=Math.abs(a[i]-a[i++-1])>1?1:0);return p<1;} ``` [Try it online!](https://tio.run/##Lc7NboMwEATgV9kjFGPF/ZNaA5Fy6K2nnCrEYUtMYgpryyypIsSzU6utNJrDN5fp8Yq584b609dmR@8CQx9NzmwH2c3UsnUk77QlNqHD1sDH8vbPRcS6EXBwbjBIFQQoYcO8WuIAvtwJWyrduZBoW6AcDJ35on1WviNfJH5OCda2yWNlWa6atFJ79bpLdTA8BwJfKL1uemJk28LV2ROMaCk5crB0rhtMl@NtYjNKN7P0EXmgJEj0frglZL7h99@iBPzlXsCDgEcBTwKeo7ysaarXdfsB "Java (OpenJDK 8) – Try It Online") [Answer] ## JavaScript (ES6), ~~37~~ 36 bytes ``` (a,u)=>!a.some(e=>(e-=(u=e))>1|e<-1) ``` Edit: Saved 1 byte by stealing @Arnauld's trick. [Answer] # Pyth, 7 bytes ``` ._I#I.+ ``` [Test Suite](http://pyth.herokuapp.com/?code=._I%23I.%2B&test_suite=1&test_suite_input=%5B1%2C+2%2C+3%2C+4%2C+3%2C+4%2C+5%2C+5%2C+5%2C+4%5D%0A%5B1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7%2C+8%2C+9%2C+8%5D%0A%5B3%2C+3%2C+3%2C+3%2C+3%2C+3%2C+3%5D%0A%5B3%2C+4%2C+4%2C+4%2C+3%2C+3%2C+3%2C+4%2C+4%2C+4%5D%0A%5B1%2C+2%2C+3%2C+4%5D%0A%5B5%2C+4%2C+3%2C+2%5D%0A%5B1%2C+3%2C+5%2C+7%2C+9%2C+7%2C+5%2C+3%2C+1%5D%0A%5B1%2C+1%2C+1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+19%5D%0A%5B3%2C+4%2C+5%2C+6%2C+7%2C+8%2C+7%2C+5%5D%0A%5B1%2C+2%2C+4%2C+10%2C+18%2C+10%2C+100%5D%0A%5B10%2C+20%2C+30%2C+30%2C+30%5D&debug=0) Returns true/false. Explanation: ``` .+ Deltas, returns differences between consecutive values. ._ Signum, returns the sign of a number (1, 0, or -1). Note that this should be equal to the input for insignificant arrays. I Tests if it is equal to the input... # For each in the input, and filter out those that aren't... I And make sure none have been filtered out. ``` [Answer] ## Mathematica, 34 bytes ``` Differences@#~MatchQ~{(1|0|-1)..}& ``` # Explanation ``` & (* Function *) Differences (* which takes the consecutive differences*) @# (* of the input list *) ~MatchQ~ (* and returns whether it matches *) {(1|0|-1)..} (* a list consisting of one or more 1s, 0s, or -1s *) ``` ]
[Question] [ [Deleted questions on Stack Overflow](https://stackoverflow.com/questions/23791278/write-a-function-that-takes-an-unsigned-integer-as-input-and-returns-true-if-al) sometimes make for great golf material. Write a function that takes a nonnegative integer as input, and returns true if all the digits in the base 10 representation of that number are unique. Example: ``` 48778584 -> false 17308459 -> true ``` Character count includes only the function. If you choose to answer in C or C++: no macros, no undefined behaviour; implementation-defined behaviour and compiler warnings are fine. [Answer] ## Golfscript, ~~8~~ 7 characters: ``` {`..&=} ``` * ``` - stringify the argument * `..` - clone twice * `&` - intersect with itself (remove duplicates) * `=` - check for equality. if the function needs to be named (**~~10~~ 9 characters**): ``` {`..&=}:a ``` if a program suffices (**~~5~~ 4 characters**): ``` ..&= ``` [Answer] # Python 2 (28) (32) ``` lambda n:10**len(set(`n`))>n ``` The backticks take the string representation. Converting to a set removes duplicates, and we check whether this decreases the length by comparing to 10^d, which is bigger than all d-digit number but no (d+1)-digit numbers. Old code: ``` lambda n:len(set(`n`))==len(`n`) ``` [Answer] ## APL (6) ``` ≡∘∪⍨∘⍕ ``` One of the few times where tacit style is shorter in APL too. It's 8 characters to give it a name, ``` f←≡∘∪⍨∘⍕ ``` but that's not necessary to use it: ``` ≡∘∪⍨∘⍕ 199 0 ≡∘∪⍨∘⍕ 198 1 f←≡∘∪⍨∘⍕ f¨ 198 199 200 201 1 0 0 1 ≡∘∪⍨∘⍕¨ 198 199 200 201 1 0 0 1 ``` [Answer] # Perl, 19 characters ``` print<>!~/(\d).*\1/ ``` [Answer] ### [Rebmμ](https://github.com/hostilefork/rebmu) (10 characters) ``` e? AtsAuqA ``` Rebmu's "mushing" trick is that it's case-insensitive, so characters are run together. Whenever a case *transition* is hit, that splits to the next token. By using transitions instead of a CamelCase kind of thing, the unique choice to start with a capital run means a "set-word" is made. (While set-words can be used for other purposes in symbolic programming, they are evaluated as assignments by default). So this "unmushes" to: ``` e? a: ts a uq a ``` The space is needed because once you've begun a series of runs of alternating cases, you can't use that trick to get a set-word after the first unless you begin a new run. So `e?AtsAuqA` would have gotten you `e? a ts a uq a`...no assignment. *(Note: For what may be no particularly good reason, I tend to prefer rethinking solutions so that there are no spaces, if character counts are equal. Since brackets, parentheses, and strings implicitly end a symbol...there are often a fair number of opportunities for this.)* In any case, when mapped to the Rebol that it abbreviates: ``` equal? a: to-string a unique a ``` Throwing in some parentheses to help get the gist of the evaluation order: ``` equal? (a: (to-string a)) (unique a) ``` So the prefix equality operator is applied to two arguments--the first the result of assigning to `a` of the string version of itself, and the second the result of `unique` being run against that string. It so happens that unique will give you back the elements in the same order you passed them...so unique of "31214" is "3124" for instance. Run it with: ``` >> rebmu/args "e? AtsAuqA" 17308459 == true ``` There's also some stats and debug information: ``` >> rebmu/args/stats/debug "e? AtsAuqA" 48778584 Original Rebmu string was: 10 characters. Rebmu as mushed Rebol block molds to: 10 characters. Unmushed Rebmu molds to: 15 characters. Executing: [e? a: ts a uq a] == false ``` If the requirement is that one must define a named/reusable function you can make an "A-function" which implicitly takes a parameter named a with `a|`. (A B-function would be created with `b|` and take a parameter named A then one named B). So that would add five more characters...let's say you call the function "f" ``` Fa|[e? AtsAugA] ``` *["You laugh! They laughed at Einstein! Or wait...did they? I...don't know."](https://www.youtube.com/watch?v=iDKaz1iB9wQ)* [Answer] # FRACTRAN - 53 38 fractions ``` 47/10 3/5 106/47 3599/54272 53/61 2881/27136 2479/13568 2077/6784 1943/3392 1541/1696 1273/848 1139/424 871/212 737/106 469/53 142/3953 67/71 5/67 1/147 1/363 1/507 1/867 1/1083 1/1587 1/2523 1/2883 1/4107 1/5547 1/7 1/11 1/13 1/17 1/19 1/23 1/29 1/31 1/37 1/43 ``` Uses division to count the number of occurrences of each digit. Call by putting n in register 2 and setting register 5 to 1, gives output in register 3 (0 if false, 1 if true). Also, make sure the rest of your program uses only registers > 71. --- Edit 25/12/14: It's been 7 months and we've since gotten Stack Snippets, so here's one to test the code (using my could-be-better interpreter [here](https://codegolf.stackexchange.com/a/40285/21487)). ``` var ITERS_PER_SEC=1E5;var TIMEOUT_MILLISECS=5E3;var ERROR_INPUT="Invalid input";var ERROR_PARSE="Parse error: ";var ERROR_TIMEOUT="Timeout";var ERROR_INTERRUPT="Interrupted by user";var running,instructions,registers,timeout,start_time,iterations;function clear_output(){document.getElementById("output").value="";document.getElementById("stderr").innerHTML=""};function stop(){running=false;document.getElementById("run").disabled=false;document.getElementById("stop").disabled=true;document.getElementById("clear").disabled=false}function interrupt(){error(ERROR_INTERRUPT)}function error(msg){document.getElementById("stderr").innerHTML=msg;stop()}function factorise(n){var factorisation={};var divisor=2;while(n>1){if(n%divisor==0){var power=0;while(n%divisor==0){n/=divisor;power+=1}if(power!=0)factorisation[divisor]=power}divisor+=1}return factorisation};function fact_accumulate(fact1,fact2){for(var reg in fact2)if(reg in fact1)fact1[reg]+=fact2[reg];else fact1[reg]=fact2[reg];return fact1};function exp_to_fact(expression){expression=expression.trim().split(/\s*\*\s*/);var factorisation={};for(var i=0;i<expression.length;++i){var term=expression[i].trim().split(/\s*\^\s*/);if(term.length>2)throw"error";term[0]=parseInt(term[0]);if(isNaN(term[0]))throw"error";if(term.length==2){term[1]=parseInt(term[1]);if(isNaN(term[1]))throw"error";}if(term[0]<=1)continue;var fact_term=factorise(term[0]);if(term.length==2)for(var reg in fact_term)fact_term[reg]*=term[1];factorisation=fact_accumulate(factorisation,fact_term)}return factorisation}function to_instruction(n,d){instruction=[];divisor=2;while(n>1||d>1){if(n%divisor==0||d%divisor==0){reg_offset=0;while(n%divisor==0){reg_offset+=1;n/=divisor}while(d%divisor==0){reg_offset-=1;d/=divisor}if(reg_offset!=0)instruction.push(Array(divisor,reg_offset))}divisor+=1}return instruction};function run(){clear_output();document.getElementById("run").disabled=true;document.getElementById("stop").disabled=false;document.getElementById("clear").disabled=true;timeout=document.getElementById("timeout").checked;var code=document.getElementById("code").value;var input=document.getElementById("input").value;instructions=[];code=code.trim().split(/[\s,]+/);for(i=0;i<code.length;++i){fraction=code[i];split_fraction=fraction.split("/");if(split_fraction.length!=2){error(ERROR_PARSE+fraction);return}numerator=parseInt(split_fraction[0]);denominator=parseInt(split_fraction[1]);if(isNaN(numerator)||isNaN(denominator)){error(ERROR_PARSE+fraction);return}instructions.push(to_instruction(numerator,denominator))}try{registers=exp_to_fact(input)}catch(err){error(ERROR_INPUT);return}running=true;iterations=0;start_time=Date.now();fractran_iter(1)};function regs_to_string(regs){reg_list=Object.keys(regs);reg_list.sort(function(a,b){return a-b});out_str=[];for(var i=0;i<reg_list.length;++i)if(regs[reg_list[i]]!=0)out_str.push(reg_list[i]+"^"+regs[reg_list[i]]);out_str=out_str.join(" * ");if(out_str=="")out_str="1";return out_str};function fractran_iter(niters){if(!running){stop();return}var iter_start_time=Date.now();for(var i=0;i<niters;++i){program_complete=true;for(var instr_ptr=0;instr_ptr<instructions.length;++instr_ptr){instruction=instructions[instr_ptr];perform_instr=true;for(var j=0;j<instruction.length;++j){var reg=instruction[j][0];var offset=instruction[j][1];if(registers[reg]==undefined)registers[reg]=0;if(offset<0&&registers[reg]<-offset){perform_instr=false;break}}if(perform_instr){for(var j=0;j<instruction.length;++j){var reg=instruction[j][0];var offset=instruction[j][1];registers[reg]+=offset}program_complete=false;break}}if(program_complete){document.getElementById("output").value+=regs_to_string(registers);stop();return}iterations++;if(timeout&&Date.now()-start_time>TIMEOUT_MILLISECS){error(ERROR_TIMEOUT);return}}setTimeout(function(){fractran_iter(ITERS_PER_SEC*(Date.now()-iter_start_time)/1E3)},0)}; ``` ``` <div style="font-size:12px;font-family:Verdana, Geneva, sans-serif;"><div style="float:left; width:50%;">Code:<br><textarea id="code" rows="4" style="overflow:scroll;overflow-x:hidden;width:90%;">47/10 3/5 106/47 3599/54272 53/61 2881/27136 2479/13568 2077/6784 1943/3392 1541/1696 1273/848 1139/424 871/212 737/106 469/53 142/3953 67/71 5/67 1/147 1/363 1/507 1/867 1/1083 1/1587 1/2523 1/2883 1/4107 1/5547 1/7 1/11 1/13 1/17 1/19 1/23 1/29 1/31 1/37 1/43</textarea><br>Input:<br><textarea id="input" rows="2" style="overflow:scroll;overflow-x:hidden;width:90%;">2^142857 * 5</textarea><p>Timeout:<input id="timeout" type="checkbox" checked="true"></input></p></div><div style="float:left; width:50%;">Output:<br><textarea id="output" rows="6" style="overflow:scroll;width:90%;"></textarea><p><input id="run" type="button" value="Run" onclick="run()"></input><input id="stop" type="button" value="Stop" onclick="interrupt()" disabled="true"></input><input id="clear" type="button" value="Clear" onclick="clear_output()"></input>&nbsp;<span id="stderr" style="color:red"></span></p></div></div> ``` Replace `142857` with another number. Output should be `3^1` if true, `1 = 3^0` if false. Takes a while for larger numbers (well, this *is* FRACTRAN...). [Answer] # JavaScript - 23 Characters As a function (ECMAScript 6): ``` f=x=>!/(.).*\1/.test(x) ``` Or taking input from a prompt (25 characters) ``` !/(.).*\1/.test(prompt()) ``` [Answer] # C# 73 60 59 First golfing for me ... > > Write a **function** that takes a **nonnegative integer** as input > > > ``` bool f(int i){return(i+"").Distinct().SequenceEqual(i+"");} ``` Could strip another character by converting `uint` to `int`, but I rather take the task too literally than the other way around. Here we go ... [Answer] # [Trilangle](https://github.com/bbrk24/Trilangle), 34 bytes UB is only disallowed in C, huh? ``` '0.<".@|>i\[[email protected]](/cdn-cgi/l/email-protection)'2#!>.(&,\,<.- ``` This works on x64, at least. Can't guarantee it'll work on other architectures. Expects the number on STDIN, immediately followed by EOF (no trailing newline). Prints "0" (with trailing newline) iff the digits are unique. Edit: there is now [an online interpreter](https://bbrk24.github.io/Trilangle/?i=17308459#%270.%3C%22.%40%7C%3Ei%5Cre%40..j..2%272%23!%3E.(%26%2C%5C%2C%3C.-). This code seems to work in wasm, too (but I still haven’t tested native ARM or other processors). ## High-level Overview Roughly equivalent to this C code: ``` #include <stdio.h> int main() { // A bitfield of the seen numbers: // e.g. if "12" is input, this is 0b0000'0000'0000'0110; // if "3" is input, this is 0b0000'0000'0000'1000; etc. int seen = 0; while (1) { // Get a number in. If EOF is read, // we haven't encountered a duplicate, so indicate success. int i = getchar(); if (i == EOF) { puts("0"); break; } // Check if the digit has already been seen. // If so, exit without printing anything. // If not, add this digit to the bitfield. i = 1 << (i - '0'); if (i & seen) break; seen = seen | i; } } ``` ## How does Trilangle work? Trilangle is a 2-D programming language laid out in a triangular grid (hence the name). The IP can move in one of six directions; it starts heading southwest. If it walks off the edge of the grid, it continues one row or diagonal to its left. The memory model is like a stack, but it's possible to index into it. ## Explanation of the Code The interpreter unfolds that code into this triangular grid: ``` ' 0 . < " . @ | > i \ r e @ . . j . . 2 ' 2 # ! > . ( & , \ , < . - . . ``` I hope this explanation makes any sense. Here goes nothing. Below is an image of the code, with the IP's paths highlighted in various colors. [![](https://i.stack.imgur.com/El0y9.png)](https://i.stack.imgur.com/El0y9.png) The IP starts on the red path, where it hits the following instructions: * `'0`: Push the number 0 to the stack * `<`: Change the direction of control flow * `i`: Get a character from STDIN and push it to the stack; pushes -1 on EOF * `>`: Branch on the sign of the top of the stack If the value is negative, EOF was read, and the IP continues on the green path: * `e`: Pop from the stack, and push `1 << value`. This is the UB: `1 << -1` is undefined. At least on x64, it evaluates to 0. * `.`: No-op * `!`: Print the top of the stack as a decimal integer * `,`: Pop from the stack * `i`: Attempt to read from STDIN again (always sees EOF on this path) * `@`: End program The `,i` aren't strictly necessary on this code path, but they're harmless to leave in. If a character was successfully read, control flow continues on the blue path: * `"0`: Push the value of the character '0' (i.e. 48) to the stack * `-`: Pop two values from the stack and push their difference * `..`: No-ops * `e`: Pop from the stack and push `1 << value` * `|`: Redirect control flow * `".,`: Push the value of the character '.' and immediately pop it, effectively a no-op * `2`: Duplicate the top of the stack * `.`: Another no-op * `\`: Redirect control flow * `'2`: Push the number 2 to the stack * `..`: Even more no-ops * `j`: The indexing function. After this, the stack contains `{ seen, i, i, seen }` (from the C code above), in that order. * `.`: Yet another no-op * `&`: Pop two values from the stack and push `a & b` (bitwise and) * `(`: Decrement the top of the stack. If `seen & i` is 0, the top of the stack is now negative; otherwise, it's still positive * `.`: Yep, still a no-op * `>`: Branch If `i` and `seen` have any bits in common, the IP follows the yellow path; otherwise, the IP follows the magenta path. The yellow path contains a harmless `r` (bitwise or) instruction, before the IP hits `@` and the program ends. On the magenta path, the IP continues as follows: * `<`: Redirect control flow * `,`: Pop from the stack * `\`: Redirect control flow * `#`: Ignore the next instruction (`j`) * `r`: Pop two values from the stack and push `a | b` (bitwise or) * `|`: Redirect control flow * `<`: Redirect control flow, merging with the red path From which it reads the next character from STDIN, and continues until it either reads the same character twice or reads EOF. ## Disassembly I recently added a `--disassemble` flag to the interpreter. The output is fairly straightforward if you understand the syntax: ``` 0.0: PSI #0 0.2: GTC 0.3: BNG 2.0 1.0: PSC '0' ; 0x30 1.1: SUB 1.4: EXP 1.6: PSC '.' ; 0x2e 1.7: POP 1.8: DUP 1.11: PSI #2 1.14: IDX 1.16: AND 1.17: DEC 1.19: BNG 4.0 JMP 3.0 2.0: EXP 2.2: PTI 2.3: POP 2.4: GTC 2.5: EXT 3.1: IOR 3.2: EXT 4.1: POP 4.4: IOR 4.7: JMP 0.2 ``` [Answer] # Ruby (24 bytes) Use a regular expression to match "some character, followed by zero or more characters, then the same character". ``` ->(s){!!(s !~/(.).*\1/)} ``` If truthy or falsy values are accepted, rather than literal `true` or `false`, then we get 20 characters: ``` ->(s){s !~/(.).*\1/} ``` [Answer] # C (87) Since I can't win, I'll go for efficiency. Function code: ``` int u(uint32_t d){short s=0,f;while(d){f=1<<d%10;if(s&f)return 0;s|=f;d/=10;}return 1;} ``` [Answer] ## Mathematica, ~~35~~ 25 characters (27 if the function needs a name.) ``` Unequal@@IntegerDigits@#& ``` **EDIT:** Saved 8 characters thanks to belisarius! [Answer] ## R, ~~53~~ ~~51~~ ~~48~~ 34 Bytes ``` function(n)!grepl("(.).*\\1",n,,T) ``` [Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jT1MxvSi1IEdDSUNPU08rJsZQSSdPRydE83@ahqGJmbmRsSZXmoaREZBpDmYampqCKHNzE1NzEMPS0MLUCKLG2NjERPM/AA "R – Try It Online") ~~Convert to a string and split. Convert to a table of counts minus 1, sum and negate~~ ~~Inspired by [Most common number](https://codegolf.stackexchange.com/a/42547/31347) answer by Alex and suggestion by Hugh.~~ A couple saved, thanks to @plannapus One more from @Gregor And a couple from making it an anonymous function Now with wonderful regex goodness thanks to @J.Doe. This looks for any single char in the number that matches itself else where in the string. The `grepl` command returns a logical that is then returned. Perl style regexes is set to True. [Answer] # J (9) Assumes the value to be tested is in variable `b` ~~(I know this can be made into a function, but don't have a clue on *how*. J is confusing. Any help on this is appreciated)~~ Thanks Marinus! ``` (-:~.)@": ``` Checks if the lenght of the string rep of the number with all the duplicates removed is the same as the lenght of the regular string rep. [Answer] ## R (70, 60, 53, 52) Thank you all for the useful comments! Your comments are incorporated in the answer. ``` ### Version 70 chars f=function(x)!any(duplicated(strsplit(as.character(x),split="")[[1]])) ### Version 60 chars f=function(x)all(table(strsplit(as.character(x),"")[[1]])<2) ### Version 53 chars f=function(x)all(table(strsplit(paste(x),"")[[1]])<2) ### Version 52 chars f=function(x)all(table(strsplit(c(x,""),"")[[1]])<2) f(48778584) f(17308459) ``` [Answer] # FRACTRAN, 15 fractions, 83 (or 32) bytes This beats [Sp3000's 38-fraction solution](/a/28395). $$\frac25,\frac{875}{88},\frac78,\frac{25{\cdot}17^c}{92},\frac14,\frac{15}{38},\frac{69}{2},\frac{23}{17},\frac{19}{3^b},\frac43,\frac{7}{23},\frac{26}{19},\frac{11}{7^c},\frac{1}{91},\frac{8}{11}$$ The initial state is \$3^n\cdot 13\cdot 23\$. It halts at \$1\$ if every digit in the base-\$b\$ representation of \$n\$ occurs fewer than \$c\$ times, and at some other value otherwise. Plug in \$b=10, c=2\$ to get the answer to the challenge as posed. The final state is actually \$13^{k - \mathrm{wt}\_c\left(\sum c^{d\_i}\right)}\$, where \$d\_1\cdots d\_k\$ are the base-\$b\$ digits of \$n\$, and \$\mathrm{wt}\_c\$ is the base-\$c\$ digit sum. Adding a power of \$c\$ increases the digit sum by \$1\$ if there is no carry, and doesn't increase it if there is a carry, so the final state is \$1\$ iff each digit occurs fewer than \$c\$ times. The length of the \$b=10, c=2\$ version is 83 bytes in the decimal coding (`2/5,875/88,`...) that seems to be standard here. With a more efficient coding ([Elias δ](https://en.wikipedia.org/wiki/Elias_delta_coding)), it's 32 bytes. There's a fast online interpreter [here](https://pimlu.github.io/fractran/). I see no way to encode a program in the URL, so you'll have to copy-paste this: ``` 2%5 875%88 7%8 25*17^2%92 1%4 15%38 69%2 23%17 19%3^10 4%3 7%23 26%19 11%7^2 1%91 8%11 ``` Then enter, e.g., `[3,48778584],[13,1],[23,1]` as the input. [Answer] # Mathematica (~~20~~ 19) (~~22~~ 21 if function needs a name) ``` Max@DigitCount@#<2& ``` or ``` Max@DigitCount@#|1& ``` where | ist entered as [Esc]divides[Esc] [Answer] # [Haskell](https://www.haskell.org/), 34 bytes ``` import Data.List ((==)=<<nub).show ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMElsSRRzyezuIQrzVZDw9ZW09bGJq80SVOvOCO//H9uYmaegq1CQVFmXomCikKagqGRscl/AA "Haskell – Try It Online") [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 1 byte ``` ≠ ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r//1Hngv//Dc2NDSxMTC0B "Brachylog – Try It Online") [Answer] # JavaScript, 22 bytes ``` s=>!s[new Set(s).size] ``` [Try it online](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1k6xODovtVwhOLVEo1hTrzizKjX2f3J@XnF@TqpeTn66RjSXkomFubmFqYWJko6Cvr5CWmJOcSqXkqG5sYGFiamlkgJIsKSoNJUrVi83sUAjTVPzPwA) [Answer] # C99, 59 chars ``` a(x){int r=1,f[10]={};for(;x;x/=10)r&=!f[x%10]++;return r;} ``` [Answer] ## Groovy (36 chars) ``` f={s="$it" as List;s==s.unique(!1)} ``` Tested it using: ``` println f(args[0].toInteger()) ``` [Answer] **Haskell:** ``` import Data.List all ((== 1) . length) . group . sort . show ``` [Answer] ## POSIX sh and egrep (47, 43, 40) ``` f()([ ! `echo $1|egrep '([0-9]).*\1'` ]) ``` * **[-1 char]:** Use `!` instead of `-z` with `test` - Thanks DigitalTrauma * **[-1 char]:** Use ``CODE`` instead of `$(CODE)` - Thanks DigitalTrauma * **[-2 chars]:** Use `fold -1` instead of `grep -o .`1 - Thanks DigitalTrauma. * **[-3 chars]:** Check for repeated digits with a backreferenced regular expression. If POSIX compliance is not important `echo PARAM |` can be replaced by `<<<PARAM`, reducing the functions length to **37**: ``` f()([ ! `egrep '([0-9]).*\1'<<<$1` ]) ``` Usage: ``` $ if f 48778584; then echo true; else echo false; fi false $ if f 17308459; then echo true; else echo false; fi true ``` --- 1 The `fold -N` notation is deprecated in some versions of `fold`. [Answer] # Java ( ~~131~~ ~~59~~ 57) ## 57 characters: removed ^ and $ as @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ suggested ``` boolean u(int n){return !(n+"").matches(".*(.).*\\1.*");} ``` ## 59 characters (works also with negative numbers!): ``` boolean u(int n){return !(n+"").matches("^.*(.).*\\1.*$");} ``` ## ~~79~~ 78 characters (thanks @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ ): Use for loop to save a few charachers and use int as a boolean array. Use & instead of && to save 1 character (It turns out that java allows it). ``` boolean u(int n){for(int x=0;n>0&(x>>n%10&1)==0;n/=10)x|=1<<n%10;return n==0;} ``` ## 131 characters (returns true for negative numbers): ``` boolean u(int n){int[] p=new int[]{2,3,5,7,11,13,17,19,32,29};double a=9001312320D;while(n>0){a/=p[n%10];n/=10;}return (long)a==a;} ``` with comments: ``` boolean unique(int n){ int[] p=new int[]{2,3,5,7,11,13,17,19,32,29};//list of 10 first primes double a=9001312320D;//10 first primes multiplied while(n>0){ a/=p[n%10];//divide by (n%10+1)th prime n/=10;//divide n by 10, next digit } return (long)a==a;//if a is integer then n has all digits unique } ``` And answer that is technically correct (character count includes only the function, not global variables), but I think it's cheating, 29 characters: ``` boolean u(int i){return m[i];} ``` m[] is boolean array that contains correct answers for all 32-bit integers. [Answer] # J (8) Competely sepertae from my previous answer. ``` */@~:@": ``` [Answer] ## R, ~~66~~ 65 characters ``` f=function(x)!sum(duplicated((x%%10^(i<-1:nchar(x)))%/%10^(i-1))) ``` Separate the digits using integer division and modulo, then check if they are duplicates. Usage: ``` > f(48778584) [1] FALSE > f(17308459) [1] TRUE ``` Or, as @MickyT suggested, for 63 characters: ``` f=function(x)!anyDuplicated((x%%10^(i<-1:nchar(x)))%/%10^(i-1)) ``` [Answer] # C, 58 bytes ``` f;a(x){for(f=0;x;x/=10)f+=1<<x%10*3;return!(f&920350134);} ``` Can keep a tally of up to 7 identical digits before rolling over. **in test program** (it's easier to see how it works with the constant in octal) ``` a(x){int f=0;for(;x;x/=10)f+=1<<x%10*3;return!(f&06666666666);} main(){ scanf("%d",&r); printf("%o\n",a(r));} ``` If you happen to have a large power of 2 handy the constant can be calculated like `f&(1<<30)/7*6` [Answer] # [J](http://jsoftware.com/), 8 bytes ``` -:~.&.": ``` Explanation: ``` ": - converts the integer to a string &. - "under" conjuction - uses the result from ": as operand to ~. then applies the inverse to the result, so converts the string back to integer ~. - removes duplicates -: - matches the operands ``` So, it first converts the number to a string, removes the duplicates and converts the resulting string to a number. Then the original number is matched against the transformed one. In fact it is a hook of two verbs: `-:` and `~.&.":` ``` ┌──┬──────────┐ │-:│┌──┬──┬──┐│ │ ││~.│&.│":││ │ │└──┴──┴──┘│ └──┴──────────┘ ``` [Try it online!](https://tio.run/##y/r/P81WT9eqTk9NT8nqf2pyRr5CmoKpmbmJJReUY2hkbAIS@A8A "J – Try It Online") [Answer] # [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 7 bytes ``` L,BDdq= ``` [Try it online!](https://tio.run/##S0xJKSj4/99Hx8klpdD2v0pOYm5SSqKCoZ09lz8XCu//fxMLc3MLUwuT/4bmxgYWJqaWAA "Add++ – Try It Online") ]
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/35372/edit). Closed 2 years ago. [Improve this question](/posts/35372/edit) Pick your favorite 6 letter common English word that has [no repeated letters](http://www.morewords.com/unique-letters), such as `wombat`. Write a program in an N×N grid of characters *without comments* such that **each row and column** contains all the letters of your word in lowercase in any order. The program must output a definition of your word **in 36 characters or more**. # Rules * Output to stdout. There is no input. * Your word must be on [Dictionary.com](http://dictionary.reference.com/) and only contain a-z. No proper nouns, no acronyms, no abbreviations, no contractions. * Your program and output may only contain [printable ASCII characters](http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) (hex codes 20 to 7E). (This isn't counting the necessary newlines in the program grid.) * Comments are anything that the compiler or interpreter traditionally ignores. You may use code that does not contribute to the output or doesn't officially get executed. * The output definition should be grammatical and accurate, but certainly may be funny or clever. * Any row or column that at least contains your word`s 6 unique letters in lowercase is valid. Diagonals do not matter. # Scoring This is code golf but since all submissions must be in the same square format you can simply specify your score with N. The lowest N wins, and of course an N below 6 is impossible. In case of ties, the highest voted answer wins. # Example If your word was `wombat` your program might look like this (N = 7): ``` wombatD ombatEw mbatFwo bat(wom atWwomb tBwomba )wombat ``` Notice that **every row *and every column*** has the characters `w` `o` `m` `b` `a` `t`. The output might be: (40 chararacters) ``` Cute short-legged Australian marsupials. ``` [Answer] ## Javascript - action - 15x15 "Definetly not the shortest one, but PEW PEW PEW." - James Bond ``` ction="action " ction+="means " actionac="PEW " ctionact="PEW " tionacti="PEW " ionactio="PEW " onaction="PEW " nactiona="PEW " ction+=actionac ction+=ctionact ction+=tionacti ction+=ionactio ction+=onaction ction+=nactiona alert(""+ction) ``` [Link to the jsfiddle](http://jsfiddle.net/LLZQF/1/) Output (37 chars): ``` action means PEW PEW PEW PEW PEW PEW ``` [Answer] # Befunge 93, n=13 This works by redirecting the string with `"v` and `>"`. This only works when the side-length and word-length are coprime and when the side-length is greater than 11. Right now, it works for the "word" `vwombat`, and therefore for `wombat`. ``` "laip"vwombat wombat>"usr"v "am "vwombat> ombat>"nai"vw lar"vwombat>" mbat>"tsu"vwo d"vwombat>"A bat>"egg"vwom -"vwombat>"el at>"tro"vwomb "vwombat>"hs t>"tuC"vwomba vwombat>:#,_@ ``` Outputs `Cute short-legged Australian marsupial` [Answer] # C (word : "finder", N = 16) ``` main() finder{ f printf(finder i "it's defined "r "as a t"finder d "hing t"finder e "hat ca"finder r "n find other t" "hings" finder); finder finder f\ inder finder fi\ nder finder fin\ der finder find\ er finder finde\ r finder finder finder finder n return 0;finder} ``` Compiled with GCC, with the options `-Dfinder="" -Df="" -Di="" -Dn="" -Dd="" -De="" -Dr=""`. It outputs `it's defined as a thing that can find other things` (50 characters). I believe it follows all the rules, but feel free to tell me if there is any mistake ! [Answer] ### GolfScript, N = 12 ``` wombat"Cute" ombat" sho"w mbat"rt-l"wo bat"egge"wom at"d Au"womb twomb"stra"a wom"lian "bt ttwomb"mar"t "sup"wbwomat "ia"womabbtt "ls"bawomtbt aaawomobt"." ``` The wombat example encoded in GolfScript. Output is ``` Cute short-legged Australian marsupials. ``` as given in the question. The interesting part is that you may use most words and answers and simply insert the corresponding letters into the solution as long as you don't produce a GolfScript built-in which are very rare, `p`, `n` being to obvious ones. All other combinations lead to valid GolfScript variables which are no-ops by default. [Answer] ## Perl - grapes - 11 **edit:** I accidently made this 12 lines... ``` $epagsr=$"; $,=$epagsr; /gaerp/;say grep!/a*s/, qw(A searpg purple sgar rpssg pear? No, a sgerp s great pse as grape; s eat prgpsga up! sgarse) ``` Output: ``` A purple pear? No, a great grape; eat up! ``` --- # Update! I eliminated a line to get it down to 11 but I had to change the sentence. Hopefully I didn't make any mistakes this time! ``` $gpasre=$"; $,=$gpasre; /paerg/;say grep!/a*s/, qw(A sgrpea purple sarg ressp game? No, a rgspe s great gsp as grape; s eat),$spegr ``` Output: ``` A purple game? No, a great grape; eat ``` The output is 37 characters. [Answer] ## Befunge-98 (n=12) I chose kelvin because it had a v in it. Outputs `kelvin is like celsius but it's lowe` ``` "ewol "vnlik "t's"ke<ilnv kelniv"t i"< elnik>"ub "v nkv"elsius"< ln>"c eki"vl v0ke"is l"<n >" nivlek" v ielnv,k4'k#< vivlevlnek< ilkkninevei elnkn vnle ``` [Answer] ## Python, n=15 Word is "canoes" ``` def canoe(s='S\ ecret weap',sno ='ce',a='ons o\ f the Can',oces =1,oesn=1,c='a\ dian navy',cose ="""aoenscanaen canceessanoeeca anoasanooscanoe noescccccaeescc oescneocaeoesca escaoescan"""): canoes=s + a+c print (canoes) s=1; canoe() ``` Output: ``` Secret weapon of the Canadian navy ``` [Answer] ## Perl - repeat - 11 ``` $repeat=qq( repeat);say "repeat\n"x length'pear repeatrepea epeatrepeat peatrepeatr eatrepeatre atrepeatrep trepeatrepe repeat....' ``` Output: ``` repeat repeat repeat repeat ...keeps going ``` Looking back maybe I should have made this a loop. [Answer] # [Ruby](https://www.ruby-lang.org/), `haters`, N = 10 After hours of attempts by hand, writing a generator program, and tweaking parameters, I have finally found a solution for N = 10! ``` aser=ts=?h tah=re=?\s sh='Haters nurse hate in hardest hearts.' rtse=erha= era=sh.tr' ',tah;aser puts erha ``` Outputs `Haters nurse hate in hardest hearts.`, exactly 36 characters. [Try it online!](https://tio.run/nexus/ruby#FYwxCsNADAT7fYW6a4w/EITbPMKNIAtKY4JWfv/lXA0Dw8wQy1t@JDrSi36cgtLHO5olXHeJlkvwvRbrQzWSUa19mGGRzspwsMKVe9fA2Nbu9dxhv7tlTzHnHw "Ruby – TIO Nexus") I chose Ruby because its variables don't need `$` (~~Perl~~), and single-quoted strings can contain newlines (~~Python~~). The fact that the `tr` method uses two of my word's letters was an unexpected bonus. The core of the program is straightforward: ``` # Store the definition, with newlines sh='Haters nurse hate in hardest hearts.' # Transliterate newline to space erha=sh.tr(' ',' ') # Output puts erha ``` Getting all the letters to line up, of course, was *not* simple. I went through several variations on the same structure and learned a couple things about Ruby in the process (`tr` doesn't need parentheses, and `?\s` is another way of getting a space). There were many dead ends and several false positives. And then... success! [Here's a gist](https://gist.github.com/dloscutoff/60ecc8b1a2d986a2c30d0e02a2dcde73) of my hacked-together generator program, if anyone's interested. [Answer] ## Golfscript (n=10) My first golfscript! It prints `kelvin is like celsius but it's lowe` ``` "kelvin is like ce"vn evn"lsiu"k k"s "elvni in"bu"kelv "t "knviel vl"it'"nke nevkil"s l o"ivnkel"w e"lnevik ``` [Answer] ## GolfScript, 13x13 Not the smallest... ``` squae"A squar "uarsquaresqu uareq"e has f "resuaresquar resqa"our equ "squresquares quars"al side "arequaresqua areuq"s and r "esqaresquare esqur"ight an "quaesquaresq quar"gles..." ``` ... **but** ... ``` A squar e has f our equ al side s and r ight an gles... ``` (Having the line-breaks within the words is intentional, because otherwise I'd have leading or trailing whitespace which would look less square.) [Answer] ## Python, N=11 Word is "parent". This code is not pretty, but it works. ``` eprnt=" a " at="person" rnep="that" nrpt="made" ea= " prnt" e="parent:" pa =(eprnt+ at+" "+rnep +ea[0]+nrpt + eprnt+at) print(e+pa) ``` Output: `parent: a person that made a person` Edit: Somehow I missed the fact that columns must also contain the word. In retrospect, a language that includes endline characters as part of the language was not well suited to this puzzle. [Answer] # [Pip](https://github.com/dloscutoff/pip), n=14 (noncompeting) The language is newer than the question. The word is `quines`.1 ``` n_n|quine say& qu ines qi as harle quin se?(equins)ns. plums|quinces |quicken bus++ iness|q++++i u u:++ingl es?eq ni*:u; s|qe:", which "Rns|que eRL:i|quotesne PUsn quiet! u|qe."print".s JW"quines" :) ``` Outputs the following (admittedly incomplete) definition: > > quines print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines, which print quines > > > [Try it online!](https://tio.run/nexus/pip#HY/BCsJADETv@Yq4B1Er/YD10Lt4kIJ4lFqCDdbYbRpE8N9rtnPJg8wMySw3@SVjIdTmu4Zk6KyYlRgap64Ze8LsAaVqQ5l0K1oCDr29dIm3pJChfZLg3bQoIPf4snAxGlj0KY8eSStKILyLdkA3UAx7@HTcdhhqyXUEVJ8iO70nUiE4X1SWi4xpWoF5qAzDyDKFUuF4DcsHGhDjdp7/ "Pip – TIO Nexus") The meaningful part of the code runs thus: ``` ++i Increment i (initially set to 0) ++++i Increment i twice u:++i Increment i again and assign to u (i & u are now 4) i*:u Multiply i by u in-place (i is now 16) e:", Assign the string ",\nwhich " to e... which "Rns after replacing the newline with a space eRL:i Make a list of 16 copies of e and assign back to e ePUs Push a space to the front of list e e."print".s Concatenate "print" and a space to each element of e... JW"quines" and join on "quines", wrapping the result in "quines" ``` The rest of the code is arbitrary no-ops. The main difficulty in the "filler" sections was never to evaluate `q`, since it will prompt the user for a line of input (not a problem on TIO, but I wanted to make it correct in all environments). I used short-circuiting logic operators `|` and `&`, and ternary `?`, to prevent `q`'s evaluation. 1 Dictionary.com has an entry for [quine](http://www.dictionary.com/browse/quine), with a section on the programming meaning at the bottom. Since "quine" is a countable noun, I would argue that "quines" is a valid word. [Answer] # Javascript, N = 8 My word is **alerts**. ``` s= alert alert(s+ s+alert) aaltrsee leraatts ertsalar rtsaaela tsaesarl ``` My code outputs the definition of the javascript alert function multiple times. Javascript's definition of alert is "function alert() { [native code] }". Only the first three lines of code actually contribute to the output. The last 5 lines are syntax errors but the original rules stated that not all the code has to be executed as long as the output is correct. Here is a link to the fiddle: <http://jsfiddle.net/tze76pum/> ]
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win. Closed 8 years ago. [Improve this question](/posts/4561/edit) **The challenge is to generate an image similar to the StackOverflow logo:** ![](https://i.stack.imgur.com/URSOY.png) **The output must contain:** * Image size 64\*64 or greater * A gray |\_\_| shaped base * A curved segmented stack coming up from the base. The segments will fade from gray to orange, and make a ~90 degree right turn. The number of segments should be between 5 and 7, with 6 being preferred. Note: For ascii displays that lack color, use a '0' character to represent gray, and '9' for orange. '1' to '8' would represent the shades in-between. **Restrictions:** * You must *generate* the image. Loading images or storing them in the code/binary is not allowed. **Additional rules/information:** * The image is not required to be identical to the logo, however it must be recognizable as it. * The method of display is up to you. Saving it to an image file or displaying on the screen are both acceptable. **Judging/winning criteria:** * Accuracy of the image is the primary condition * Elegance of generation is the secondary condition [Answer] # Mathematica ``` Graphics[{ Gray, Rectangle[{0, 0}, {78, 50}], White, Rectangle[{9, 9}, {69, 50}]} ~Join~ Table[{ Blend[{Gray, Orange}, x/5], Rotate[ Translate[ Rectangle[{16, 16}, {61, 25}], {0.25x^3 + 0.6x^2 - 0.4x, -0.53x^3 + 3.26x^2 + 12x}], -0.05x^2 - 0.04x]}, {x, 0, 5}]] ``` I decided to prettify my answer after realizing this isn't code golf. Whoops! Screenshot: ![Stack Overflow logo](https://i.stack.imgur.com/jZyFd.png) In related news, I also created what I think the Stack Overflow logo might look like in... ***THE FUTURE***: ![THE FUTURE IS NOW](https://i.stack.imgur.com/FF0vx.png) Here's the code if anyone wants to play around with it (sorry for the mess): ``` Graphics3D[{EdgeForm[], Opacity[1], RGBColor[0.2, 0.2, 0.2], Cuboid[{0, 0, 0}, {78, 4, 50}], Cuboid[{0, 4, 0}, {4, 45, 50}], Cuboid[{74, 4, 0}, {78, 45, 50}], Opacity[1]} ~Join~ Fold[Join, {}, Table[{Hue[0.15 - i/5/12, i/3, 1], Translate[ Rotate[ Scale[Cuboid[{16, 16, 16}, {61, 25, 25}], {1, .3, .3}], (-.05 ((i*2 - 1.5)*1.25)^2 - .04 ((i*2)*1.2)), {0.3, 0.8, -1}, {(16 + 61)/2, (16 + 25)/2, (16 + 25)/2}], {-((i*2)^2 - (i*2)*4)/2, (i*2)^2*3/2, 0}]}, {i, 0, 4.5, 0.05}]], Lighting -> "Neutral", Axes -> False, Background -> White, Boxed -> False] ``` [Answer] ## Javascript (650) I wrote a quine that reads the characters in the function, and replaces non-space characters with a number from 0-9. ``` (function a(){ l=[ 1, 1, 11, 1, 11, 1, 11, 1, 11, 11, 1, 11, 11, 11, 11, 1111, 1111, 0, 11111111, 0, 0, 11, 0, 0, 111111111111, 0, 0, 0, 0, 11111111111111, 0, 0, 0, 000000000000000000000] b=a.toString().split("[")[1].split("]")[0].split(""),i=-1 document.getElementById("output").innerHTML= b.map(function(c){ ++i if(c==" "||c=="\n")return c if(c!=0)c=9-Math.floor((i/b.length)*10) if(b[i-1]=="0")c=0 return"<span class='c"+c+"'>"+c+"</span>" }).join("") })() ``` This outputs this ASCII art: ``` 99 88 888 88 777 77 766 66 666 666 66 555 555 555 444 44444 44444 00 333333333 00 00 333 00 00 2222222222222 00 00 00 00 111111111111111 00 00 00 000000000000000000000 ``` which can be colored with a css stylesheet if you like ``` span{ font-weight: bold; } .c0, .c1{ color: #222; } .c2{ color: #765; } .c3{ color: #976; } .c4{ color: #A64; } .c6, .c5{ color: #D51; } .c8, .c9, .c7{ color: #F60; } ``` You can [see it in action on jsBin](http://jsbin.com/esunuc/8). Here is a screenshot, in case the link dies: ![enter image description here](https://i.stack.imgur.com/0IOlp.png) [Answer] ## SVG (347 characters) Based on [Sir\_Lagsalot's version](https://codegolf.stackexchange.com/a/4640), with strokes instead of fills. Besides shaving off a few chars, the code is simpler and the output looks better scaled up. ``` <svg width="66" height="85" xmlns="http://www.w3.org/2000/svg"> <g stroke-width="7" fill="none"> <path stroke="gray" d="m4,50v31h49V50M12,69h33"/> <path stroke="#a86" d="m12,57 33,3"/> <path stroke="#b95" d="m14,42 32,9"/> <path stroke="#c82" d="m22,24 27,19"/> <path stroke="#e80" d="m37,9 18,27"/> <path stroke="#f71" d="m58,1 4,32"/> </g></svg> ``` [Link to SVG image](http://vyznev.net/misc/so_logo.svg). Rendered to PNG (at natural size and scaled up x2 and x3): ![Natural size](https://i.stack.imgur.com/D6EJB.png)     ![Scaled up x2](https://i.stack.imgur.com/Set36.png)     ![Scaled up x3](https://i.stack.imgur.com/Aeh6B.png) **Edit:** Finally got around to fixing the off-by-one error that caused the sides of the box not to line up. Also tweaked the line thickness and end point placement a bit, and added explicit width and height to avoid the bottom and right edges being cropped too tight. It now looks a *lot* closer to the official logo. [Answer] ## Haskell w/Gloss ``` import Graphics.Gloss picture = translate 0 (-50) $ pictures [stack, base 150 60 20] stack = translate 0 30 $ pictures [item n | n <- [0..5]] item n = bend 200 (-10*n) $ color (fade grey orange (n/5)) box where box = rectangleSolid 110 20 base width height thickness = color grey $ pictures [left, right, bottom] where bottom = rectangleSolid width thickness left = translate (width / 2) (height / 2) side right = translate (-width / 2) (height / 2) side side = rectangleSolid thickness (height + thickness) bend radius angle = translate radius 0 . rotate angle . translate (-radius) 0 fade from to alpha = mixColors (1-alpha) alpha from to grey = greyN 0.5 ``` ![Screenshot](https://i.stack.imgur.com/lPNOv.png) [Paste the code here to see it in action](http://dac4.designacourse.com:8000/draw), or add the following line to compile it (requires [Gloss](http://hackage.haskell.org/package/gloss)). ``` main = display (InWindow "Stack Overflow" (512, 512) (10, 10)) white picture ``` [Answer] ## SVG (333 characters) I've created a SVG image that generates a 67x68 version of the logo in 333 characters: ``` <svg xmlns="http://www.w3.org/2000/svg"> <path fill="grey" d="m0,53v34h53V53h-5v29H5V53M9,69h33v6H11v-6"/> <path fill="#a86" d="m12,56 31,3-1,6-31-3"/> <path fill="#b95" d="m15,41 31,9-2,6-31-8"/> <path fill="#c82" d="m22,25 28,17-3,5-28-17"/> <path fill="#e80" d="m38,8 19,27-5,4-19-27"/> <path fill="#f71" d="m62,0 5,32-6,1-5-32"/> </svg> ``` [Link for small SVG image](http://lags.leetcode.net/logo.svg) [Link for large SVG image](http://lags.leetcode.net/logo_large.svg) ![Example](https://i.stack.imgur.com/SDgWI.png) [Answer] ## LaTeX Using the TikZ and PGF packages. ``` \documentclass{minimal} \usepackage{tikz} \pagestyle{empty} \begin{document} \xdefinecolor{col1}{RGB}{167, 149, 116} \xdefinecolor{col2}{RGB}{189, 153, 87} \xdefinecolor{col3}{RGB}{211, 157, 57} \xdefinecolor{col4}{RGB}{233, 161, 28} \xdefinecolor{col5}{RGB}{255, 165, 0} \begin{tikzpicture} \draw[gray, fill=gray] (-1,0.5) -- (-1,0) -- (0,0) -- (0,0.5) -- (-0.1,0.5) -- (-0.1,0.1) -- (-0.9,0.1) -- (-0.9,0.5) -- (-1,0.5); \draw[gray, fill=gray] (-0.8,0.3) rectangle(-0.2,0.2); \draw[col1, fill=col1, xshift=0.3pt, yshift=3pt, rotate around={-15:(0.2,0.2)}] (-0.8,0.3) rectangle(-0.2,0.2); \draw[col2, fill=col2, xshift=0.5pt, yshift=6pt, rotate around={-30:(0.2,0.2)}] (-0.8,0.3) rectangle(-0.2,0.2); \draw[col3, fill=col3, xshift=0.8pt, yshift=9pt, rotate around={-45:(0.2,0.2)}] (-0.8,0.3) rectangle(-0.2,0.2); \draw[col4, fill=col4, xshift=1.3pt, yshift=12pt, rotate around={-60:(0.2,0.2)}] (-0.8,0.3) rectangle(-0.2,0.2); \draw[col5, fill=col5, xshift=2.1pt, yshift=14pt, rotate around={-75:(0.2,0.2)}] (-0.8,0.3) rectangle(-0.2,0.2); \end{tikzpicture} \end{document} ``` ![LaTeX Logo](https://i.stack.imgur.com/p2fkP.png) [Answer] # CSS+JavaScript (HTML div based) ``` * { padding: 0; margin: 0; } div { position: absolute; width: 100px; height: 20px; background-color: red; } .s { background-color: gray; } #d0,#d2 { width: 20px; height: 70px; } #d0 { left: 20px; top: 160px; } #d1 { left: 20px; top: 230px; width: 160px; } #d2 { left: 160px; top: 160px; } .e { -moz-transform-origin: 200% center; -ms-transform-origin: 200% center; -o-transform-origin: 200% center; -webkit-transform-origin: 200% center; transform-origin: 200% center; } ``` ``` $(document).ready(function() { for (var i = 0; i < 9; i++) $('body').append($('<div/>').attr('id', 'd' + i).attr('class', i < 3 ? 's' : 'e')) $('.e').each(function(i) { $(this).css({ left: (50 - i * 3) + 'px', top: '200px', backgroundColor: '#' + (i + 10).toString(16) + 'a' + (10 - i * 2).toString(16), '-moz-transform': 'rotate(' + (i * 15) + 'deg)', '-ms-transform': 'rotate(' + (i * 15) + 'deg)', '-o-transform': 'rotate(' + (i * 15) + 'deg)', '-webkit-transform': 'rotate(' + (i * 15) + 'deg)', transform: 'rotate(' + (i * 15) + 'deg)' }); }); }); ``` Sample run: <http://jsfiddle.net/ryzBx/> Sample rendering (Firefox 14): ![StackExchange Logo](https://i.stack.imgur.com/JVX13.png) [Answer] ## Javascript (a lot of 814 characters) ``` window.onload = function() { var canvas = document.getElementById("cgCanvas"); var context = canvas.getContext("2d"); context.moveTo(60,140); context.lineTo(60,190); context.moveTo(57.5,190); context.lineTo(137.5,190); context.moveTo(135,140); context.lineTo(135,190); context.lineWidth = 5; context.strokeStyle = "rgb(94,94,94)"; context.stroke(); for(i=0;i<6;i++) { context.beginPath(); var b=1; var a=1; if(i==5) { a=3; b=1.3; } else if(i==4) a==2; x=94+i*9; y=94-i*5; z=95-i*19; context.moveTo(122.5+i*i,180-i*15); context.lineTo(72.5+i*i+i*i*b,180-i*15-i*i*i+i*i*a); context.lineWidth = 8; context.strokeStyle = 'rgb('+ x +','+ y +','+ z +')'; context.stroke(); } }; ``` It ain't pretty but looks a bit like the SO logo. Test fiddle here - <http://jsfiddle.net/elssar/jcYtg/2/> [Answer] ## C#/GDI+ I was surprised when I noticed there's no C# answer here. So here's one. This is not an ingenious way of drawing the logo, and is not a short solution either. But gets the required output. ![Generated logo and the original StackOverflow logo](https://i.stack.imgur.com/hQkLi.png) You can check my blog post out to download the full working solution → <http://guganeshan.com/blog/stackoverflow-logo-using-csharp-and-gdi.html> ``` public class SOLogo { private float _rotateValue; private float _xValueForTransformation; private float _yValueForTransformation; int _containerWidth; int _containerHeight; float _lineThickness; int _paddingWithinContainer; int _elementStartY; public SOLogo(float rotateValue, float xValueForTransformation, float yValueForTransformation) { // Values used to position and rotate the overflowing elements. _rotateValue = rotateValue; _xValueForTransformation = xValueForTransformation; _yValueForTransformation = yValueForTransformation; } public void DrawLogo(Graphics g, int startX, int startY) { // Backup the current smoothing mode to apply later. var SmoothingMoodBackup = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Values for the container box. _containerWidth = 94; _containerHeight = 61; _lineThickness = 11f; _paddingWithinContainer = 15; // Y value of the position where the 1st overflowing element starts. _elementStartY = 0; // Starting point of the 'container' - Top point of the line on the left-> |_| Point pointContainerLineStart = new Point(startX, startY); Point pointContainer1stLineEnd = new Point(pointContainerLineStart.X, pointContainerLineStart.Y); // Start with the previous pointContainer1stLineEnd.Offset(0, _containerHeight); // Offset "Y" Point pointContainer2ndLineEnd = new Point(pointContainer1stLineEnd.X, pointContainer1stLineEnd.Y); // Start with the previous pointContainer2ndLineEnd.Offset(_containerWidth, 0); // Offset "X" Point pointContainer3rdLineEnd = new Point(pointContainer2ndLineEnd.X, pointContainer2ndLineEnd.Y); // Start with the previous pointContainer3rdLineEnd.Offset(0, 0 - _containerHeight); // Offset "Y" (negative) GraphicsPath pathOfBox = new GraphicsPath(); pathOfBox.AddLine(pointContainerLineStart, pointContainer1stLineEnd); // Left line. Top to bottom pathOfBox.AddLine(pointContainer1stLineEnd, pointContainer2ndLineEnd); // Bottom line. Left to right pathOfBox.AddLine(pointContainer2ndLineEnd, pointContainer3rdLineEnd); // Right line. Bottom to top Pen thickPen = new Pen(Brushes.Gray, _lineThickness); Color elementColor = Color.FromKnownColor(KnownColor.Gray); // Draw the 'container' g.DrawPath(thickPen, pathOfBox); // Increase the size of the pen to draw the elements inside the container thickPen.Width = _lineThickness += 3; // "Y" - position of the 1st element _elementStartY = startY + 38; // The following section draws the overflowing elements Point pointElement1Left = new Point(startX + _paddingWithinContainer, _elementStartY); Point pointElement1Right = new Point((startX + _containerWidth) - _paddingWithinContainer, _elementStartY); // Six colors of the overflowing elements var colors = new Color[] { Color.Gray, Color.FromArgb(-6911615), Color.FromArgb(-4417693), Color.FromArgb(-2848227), Color.FromArgb(-554957), Color.FromArgb(-688847) }; for (int x = 0; x < 6; x++) { thickPen.Color = colors[x]; pointElement1Left = new Point(startX + _paddingWithinContainer, _elementStartY); pointElement1Right = new Point((startX + _containerWidth) - _paddingWithinContainer, _elementStartY); g.DrawLine(thickPen, pointElement1Left, pointElement1Right); g.RotateTransform(_rotateValue); g.TranslateTransform(_xValueForTransformation, _yValueForTransformation); } pathOfBox.Dispose(); thickPen.Dispose(); // Restore the smoothing mood that was backed up before we started this method. g.SmoothingMode = SmoothingMoodBackup; } } ``` [Answer] I know I'm **super** late to the game here, but I was surprised no one did a CSS version of this. This is definitely not a competitive answer when it comes to character count (1,195) but the final product is pretty accurate. Written in Safari (9.0) and tested in Chrome (45.0.2454.93) and Firefox (40.0.3). ``` body { padding: 100px 40px; } .base { width: 60px; height: 40px; border: 8px solid #818286; border-top: none; } .container { bottom: 28px; left: 6px; position: relative; } .line { width: 48px; height: 10px; position: relative; } .line:nth-child(1n) { background: #ff7a15; bottom: 23px; left: 45px; transform: rotate(80deg) } .line:nth-child(2n) { background: #ff8907; bottom: 25px; left: 25px; transform: rotate(55deg) } .line:nth-child(3n) { background: #d48c28; bottom: 19px; left: 10px; transform: rotate(30deg) } .line:nth-child(4n) { background: #c19653; bottom: 12px; left: 3px; transform: rotate(16deg) } .line:nth-child(5n) { background: #a78b6e; bottom: 5px; left: 0; transform: rotate(5deg); } .line:nth-child(6n) { background: #818286; bottom: 0; left: 0; transform: rotate(0deg); } ``` ``` <div class="base"> <div class="container"> <div class="line"></div> <div class="line"></div> <div class="line"></div> <div class="line"></div> <div class="line"></div> <div class="line"></div> </div> </div> ``` [Answer] ## JavaScript + jQuery & SVG - 250 ``` $('body').html('<svg><g stroke-width="6" fill="none"$grey" d="m3,51v31h47V53M10,70h33"/$#a86" d="m10,57 33,3"/$#b95" d="m13,42 31,9"/$#c82" d="m20,25 28,17"/$#e80" d="m34,9 19,27"/$#f71" d="m56,1 4,32"/></g></svg>'.replace(/\$/g, '><path stroke="'))​ ``` I took Ilmari Karonen's SVG and used JavaScript to replace `$`s with `><path stroke="` effectively shortening it even with the overhead of JavaScript. [Answer] # PHP w/ GD ``` <?php $img = imagecreatetruecolor(67,68); $white = imagecolorallocate($img,0xff,0xff,0xff); $grey = imagecolorallocate($img,0x80,0x81,0x85); $orng1 = imagecolorallocate($img,0xa6,0x8a,0x6e); $orng2 = imagecolorallocate($img,0xc0,0x95,0x53); $orng3 = imagecolorallocate($img,0xd3,0x8b,0x28); $orng4 = imagecolorallocate($img,0xfd,0x88,0x08); $orng5 = imagecolorallocate($img,0xfe,0x7a,0x15); imagefilledrectangle($img,0,0,67,68,$white); //container imagefilledrectangle($img,7,41,10,65,$grey); imagefilledrectangle($img,10,61,44,65,$grey); imagefilledrectangle($img,41,61,44,41,$grey); // stack levels imagefilledrectangle($img,14,52,37,56,$grey); //1st level imagefilledpolygon($img,array(14,42,14,47,37,49,37,44),4,$orng1); imagefilledpolygon($img,array(16,32,15,36,37,42,38,38),4,$orng2); imagefilledpolygon($img,array(22,21,20,24,39,35,41,32),4,$orng3); imagefilledpolygon($img,array(33,10,31,12,43,30,45,28),4,$orng4); imagefilledpolygon($img,array(45,5,48,5,51,27,48,27),4,$orng5); header("Content-type: image/png"); imagepng($img); ?> ``` Example: ![StackOverflow logo drawn in PHP](https://i.stack.imgur.com/mg2KS.png) [Answer] ## R Not the prettiest solution but it returns the requested output. ``` library(grid) my.palette <- colorRampPalette(c("grey57","orange"))(6) png("StackOverflow_Logo.png", width=300, height=300) pushViewport(viewport(x=0.5, y=0.5, w=unit(100, "points"), h=unit(100, "points"))) grid.polygon(x=unit(c(10, 0, 0, 100, 100, 90, 90, 10),"points"), y=unit(c(50, 50, 0, 0, 50, 50, 10, 10),"points"), default.units="points", gp=gpar(col = "grey57", fill="grey57")) grid.rect(vp=viewport(x=0.5, y=0.3, w=unit(70, "points"), h=unit(10, "points")), gp=gpar(col = "grey57", fill="grey57")) grid.rect(vp=viewport(x=0.52, y=0.52, w=unit(70, "points"), h=unit(10, "points"), angle=-10), gp=gpar(col = my.palette[2], fill=my.palette[2])) grid.rect(vp=viewport(x=0.58, y=0.78, w=unit(70, "points"), h=unit(10, "points"), angle=-20), gp=gpar(col = my.palette[3], fill=my.palette[3])) grid.rect(vp=viewport(x=0.70, y=1.05, w=unit(70, "points"), h=unit(10, "points"), angle=-35), gp=gpar(col = my.palette[4], fill=my.palette[4])) grid.rect(vp=viewport(x=0.90, y=1.25, w=unit(70, "points"), h=unit(10, "points"), angle=-55), gp=gpar(col = my.palette[5], fill=my.palette[5])) grid.rect(vp=viewport(x=1.15, y=1.38, w=unit(70, "points"), h=unit(10, "points"), angle=-70), gp=gpar(col = my.palette[6], fill=my.palette[6])) dev.off() ``` ![logo](https://i.stack.imgur.com/kq8EX.png) [Answer] ## Scala ``` object LogoCanvas extends javax.swing.JPanel { import java.awt._ def viereck (g: Graphics, points: scala.List[(Int, Int)]) = { val polygon = new Polygon () points.foreach (p => polygon.addPoint (10 * p._1, 400 - 10 * p._2)) g.fillPolygon (polygon) } override def paint (g: Graphics) = { g.setColor (Color.GRAY); // ablage viereck (g, scala.List ((2, 1), (2, 11), (3, 11), (3, 1))) viereck (g, scala.List ((2, 1), (2, 2), (23, 2), (23, 1))) viereck (g, scala.List ((23, 1), (23, 11), (24, 11), (24, 1))) // blaetter flach viereck (g, scala.List ((5, 5), (5, 6), (21, 6), (21, 5))) viereck (g, scala.List ((5, 9), (5, 10), (21, 10), (21, 9))) // blaetter schraeg g.setColor (Color.LIGHT_GRAY); viereck (g, scala.List ((7, 22), (8, 23), (21, 13), (21, 12))) viereck (g, scala.List ((12, 28), (13, 29), (22, 15), (21, 14))) // blaetter steil g.setColor (Color.ORANGE); viereck (g, scala.List ((18, 34), (19, 34), (23, 17), (22, 16))) viereck (g, scala.List ((24, 36), (25, 36), (25, 17), (24, 17))) } import javax.swing._ def main (args: Array [String]) : Unit = { val jf = new JFrame ("Stackoverflow!") jf.setSize (350, 520) jf.setLocationRelativeTo (null) jf.setBackground (Color.BLACK) jf.add (LogoCanvas) jf.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE) jf.setVisible (true) } } ``` ![Stackoverflow logo on black background](https://i.stack.imgur.com/kHPyC.png) [Answer] # JavaScript ``` var c=document.getElementById('c'),x=c.getContext('2d'),i=0 c.width=c.height=140 x.scale(5,5) x.fillStyle="#999" x.fillRect(3,26,14,2) x.fillRect(1,18,2,10) x.fillRect(17,18,2,10) for(;i<6;){x.fillStyle="#"+"999a96b95c94d93f90".substr(i*3,3) x.save() x.translate(i*i/2,22-i*6) x.rotate(i++/5) x.fillRect(5,0,10,2) x.restore()} ``` ``` <canvas id="c"></canvas> ``` ]
[Question] [ Write a [quine](http://en.wikipedia.org/wiki/Quine_%28computing%29) that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (`/[a-zA-Z]+/` in regex). To be "real" your word must be recognized by the [official Scrabble dictionary](https://play.hasbro.com/scrabble/dictionary). I'm using the Scrabble dictionary since it gives a definitive answer on what is and isn't valid. There are too many gray areas with a normal dictionary. Note that "A" and "I" (not to mention "quine") are not valid scrabble words. Since writing a quine *only* using letters and spaces is close to impossible in most programming languages, you have the option to replace the single spaces between words with a character of your choice. You also have the option to append characters to the front of the first word and the end of the last word. These added characters may be anything (including newlines and non-ASCII) **except letters (a-z, A-Z)**. There is a penalty for adding them though (see Scoring.) # Details * As usual, the quines may not read or access their own source code. (I'd say that [HQ9+'s](http://esolangs.org/wiki/HQ9+) Q command violates this.) * Output should go to stdout or a similar alternative. There is no input. * The words do not need to be capitalized correctly. They can have caps and lowercase anywhere. The sequence of words does not need to make any sense. * No word may be used more than 3 times in your program. Differently capitalized words are still the same word (e.g. 'DOG', 'dog', and 'dOg' are all the same word). * Using languages like PHP or HTML that can just [cat](http://en.wikipedia.org/wiki/Cat_%28Unix%29) out their contents is considered a trivial loophole and is not allowed. * The program must contain at least one word. # Scoring Your score is the number of "real words" in your program plus these penalties: * +1 for every space that was replaced with another character * nn for every n characters you added before the first word (yes, that's n to the power n) * nn for every n characters you added after the last word For example, the program ``` We all LIKE PROgraMmING ``` would score 4 because it contains 4 words; no characters were added or replaced any spaces. It's output would of course be `We all LIKE PROgraMmING`. The program ``` !We@all LIKE#PROgraMmING- = ``` would score 4 + 2 + 1 + 27 = 34; 4 for the words, 2 for the replaced spaces, 1 for the `!` at the front, and 27 for the `- =` at the end. It's output would of course be `!We@all LIKE#PROgraMmING- =`. **The lowest score wins.** Tiebreaker goes to the answer with the fewest penalty points. If there's still a tie the highest voted answer wins. [Answer] # [><>](http://esolangs.org/wiki/Fish), 25 words + (22 + 11 + 11) extra = ~~57~~ 49 Oh god, my brain. ``` 'brr3deep*clap6beep+orb5flap*leap4deep+clap5beep5flap*leap9deep9clap*beep+flap0placed apple alp0leap=clip?lob8blip*flip0clip. ``` Since the rules state "There is no input.", for this program to work you'll need to pipe in an empty file. Oh and yes, `brr` is a valid Scrabble word, as are `tsktsk` and `pfft`. ## Explanation First of all, the following words are no-ops: ``` deep clap beep flap leap clip blip flip ``` This is because of two reasons: * `abcdefl` push numbers (10, 11, 12, 13, 14, 15 and the length of the stack respectively). In addition, `i` pushes -1 if EOF is met, seeing as there is no input. * The `p` command pops three chars `v,y,x` and places `v` at the position `x,y`. Yes, ><> lets you modify the source code on the fly! We don't really make use of that though, as we only need the `p` for popping. If we get rid of these no-ops, we get: ``` 'brr3*6+orb5*4+55*99*+0placed apple alp0=?lob8*0. ``` In a similar way, the `laced app` part of `placed apple` and the `e alp` part of `apple alp` are also no-ops, and the `rr` of `brr` just reverses the stack twice, which we can also remove: ``` 'b3*6+orb5*4+55*99*+0pl0=?lob8*0. ``` Finally, something that looks like a regular ><> program! The idea is to make use of the standard ><> quine, which works like so: * The initial `'` starts string parsing, pushing every char met until we hit another `'` * We keep pushing chars until the end of the line, at which point we wrap the instruction pointer back to the start (since ><> is toroidal) * We land on the initial `'` again, and *stop* string parsing. The result is that we've pushed every single char in the program (except the initial `'`) onto the stack. Then the following happens: ``` b3*6+o Print the initial ' quote (ASCII 39) r Reverse the stack b5*4+ Push a ';' (ASCII 59) 55*99*+0p Replace the 'l' of 'lob' with ';' (print loop) l0=?; If the stack is empty, terminate. Otherwise... o Print the top of the stack b8*0. Jump back to the beginning of the loop ``` [Answer] # golfscript, 8 words + 8 symbols = ~~20~~ 16 (3?) ``` {four"words.written~twice"four}words.written~twice ``` The words are just a filler, the core is a tiny quine core: ``` {".~"}.~ ``` Duplicates and evaluates a function that just appends the instructions to duplicate and evaluate itself. When a function is printed, it is stringified automatically. This is the smallest quine that does *something*. Or we could just use a function literal that never gets evaluated. But it feels like cheating... ``` {whatever} ``` [Answer] # [Chicken](http://torso.me/chicken), 1 word I'm not normally into esolangs, but this one seemed perfect for this. I *think* this is a true quine: ``` chicken ``` Pushes 1 chicken to the stack. The stack is then displayed. [Answer] # Python 2, 58 = 37 words + 21 punctuation marks ``` programming=puzzle=hash and'fear=coerce and"programming=puzzle=hash and%rif reload else fire;exec prog"or English;ramming=None or"ramming"if license else pirate;print fear%puzzle+ramming'if reload else fire;exec programming ``` With some newlines added: ``` programming=puzzle=hash and'fear=coerce and"programming=puzzle=hash and%rif reload else fire;exec prog"or English;ramming=None or "ramming"if license else pirate;print fear%puzzle+ramming' if reload else fire;exec programming ``` The three uses per word restriction was what made this one difficult to write. I wanted to use the string with all the code more than 3 times, and every string had to be insulated with `if else and or` operators which I only had a limited supply of. [Answer] # R, 2 words + 1 replacement + 1¹ trailing = 4 Objects which aren't assigned to anything are just printed to stdout. Since an expression is an object, the following code prints itself: ``` expression(puppy) ``` --- Previous submission, 5 points: ``` function(hello)hello ``` [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 2 words + \$1^1 +1 = 4\$ ``` `qUEued`qUEued ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJgcVVFdWVkYHFVRXVlZCIsIiIsIiJd) Gosh this took ages to find. Vyxal's a SBCS language, meaning most of its characters are unicode ones that we cannot use here. But it's still fairly usable without those. The easiest way to make Vyxal quines is using the format ``code`code`, where the code prepends a backtick and doubles the result, or similar - this is pretty much exactly what the above program does. ``` `qUEued` # Data string q # Unevaluate; enclose in backticks U # Uniquify, removing the trailing backtick E # Evaluate as Python; NOP ue # Extend to length -1; NOP d # Double, creating the quine! ``` [Answer] # Julia, 1 word + 1¹ preceding = 2 Julia has objects called symbols which are defined using a preceding `:`. Much like my R solution, this just prints when submitted. ``` :puppy ``` [Answer] # DOS command line, 10 ``` & was unexpected at this time. ``` Error quine, not banned it seems [Answer] # [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), Score 4+3+11+11 = 9 ``` "hOt3OX4NOt+kNOt@ ``` [Try it online!](https://tio.run/##KyrNy0z@/18pw7/E2D/CxM@/RDsbSDj8/w8A "Runic Enchantments – Try It Online") Words: `hot ox not knot` (4) Replacements: `3 4 +` (3) Before: `"` (1) After: `@` (1) All of the characters `GNOQWghtxz` are no-op in Runic (as well as space and period, but more spaces doesn't help scoring). Including the `X` and `k` required for functionality, this gives the following available word list: ``` 5 Letter Word(s) thong 4 Letter Word(s) gong goth gowk gown hogg hong honk howk knot know nogg nowt tong town wonk wont zonk 3 Letter Word(s) got gox hog hon hot how nog noh not now nth own tho tog ton tow two who wok won wot 2 Letter Word(s) go ho no oh on ow ox to wo ``` I cherry picked based on the needs of the space it was going into and making it sound funny. Removing all NOP characters gives the following quine: ``` "3X4+k@ ``` [Try it online!](https://tio.run/##KyrNy0z@/1/JOMJEO9vh/38A "Runic Enchantments – Try It Online") [Answer] # [huh?](https://github.com/kade-robertson/pythuhn/blob/master/pythuhn.py) - 1 word + 1\*\*1/1^1=1 char after the word = 2 total score. ``` Ouch! ``` `Ouch!` is a valid quine in huh? Run it like `pythuhn.py Ouch!`, and there cannot be a file named `Ouch!` in the current directory. [Answer] # [Pip](https://github.com/dloscutoff/pip), 8 words + (6 + 11) = 15 ``` HA:saY"HA:saY eyRIE:HARPy"eyRIE:HARPy ``` Includes a trailing newline. [Try it online!](https://tio.run/##K8gs@P/fw9GqODFSCUIppFYGebpaeTgGBVQqIbG5/v8HAA "Pip – Try It Online") ### Explanation This is an expansion of the repr-based quine `Y"Y yRsRPy"yRsRPy`. ``` HA:saY"HA:saY eyRIE:HARPy"eyRIE:HARPy HA:s Assign space character to the variable HA a No-op Y"HA:saY eyRIE:HARPy" Yank that string into the y variable e No-op yR In y, replace HA HA (space) IE: (and also assign space character to IE) RPy with the repr of y (in this case, y wrapped in quotes) Autoprint (implicit) ``` The trailing newline is necessary because autoprint outputs a trailing newline. [Answer] # [Actually](https://github.com/Mego/Seriously), 10 + 9 + 1 = 20 ``` "AB9FAce+AE;Ah+AL"AB9FAce+AE;Ah+AL ``` [Try it online!](https://tio.run/##S0wuKU3Myan8/1/J0cnSzTE5VdvR1doxQ9vRB0OA6/9/AA "Actually – Try It Online") Invalid instructions do nothing in Actually, and removing them gives this: ``` "9FAc+;+"9FAc+;+ "9FAc+;+" # String literal 9FA # Push abs(9th fibonacci number) = 34 c # 34th ascii character is " + # Append the " to the start of the string ;+ # Append the string to itself ``` ]
[Question] [ **The Challenge** Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list. **Details** The list should be in descending order. Every built-in function to manipulate arrays and/or lists is allowed. Shortest code in bytes wins. When run this year `2016`, the output would be `2016, 2015, ..., 1897, 1896` When run next year `2017`, the output would be `2017, 2016, ..., 1898, 1897` Etc. **Update** * Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array. * Quasi superhumans like [Jeanne Calment](https://en.wikipedia.org/wiki/Jeanne_Calment) are an exception to the rule stated in my question. [Answer] ## Pyke, 6 bytes ``` wC7m- ``` [Try it here!](http://pyke.catbus.co.uk/?code=w%C2%99C7m-) ``` w - 121 m- - for i in range(^): C7 - current_year-i ``` (After `w`, the codepoint for 153 is present but it isn't printable) [Answer] # Pyth, ~~11~~ ~~9~~ 8 bytes ``` -L.d3C\y ``` Works by mapping over the range `[0...120]` and subtracting every number from the current year. The range is built implicitly by using `121` as the map argument. To avoid a separating whitespace between `.d3` and `121` we get this number by converting `y` to it's codepoint. Thanks to @FryAmTheEggman for coming up with this approach! [Try it here!](http://pyth.herokuapp.com/?code=-L.d3C%5Cy&debug=0) ***Old 9-byte solution:*** ``` _>121S.d3 ``` [Try it here!](http://pyth.herokuapp.com/?code=_%3E121S.d3&debug=0) Builds the range `[1...<current year>]` and only takes the last 121 elements of it. [Answer] # R, 34 bytes ``` (format(Sys.Date(),"%Y"):0)[1:121] ``` See [here](http://www.r-fiddle.org/#/fiddle?id=oVuj9wYz&version=1) on an online interpreter. **Edit** Could be reduced to 33 bytes by using `substr`. ``` (substr(Sys.Date(),1,4):0)[1:121] ``` but technically this solution will only work until the 9999-12-31. [Answer] # [AngularJS](https://angularjs.org/) + [Lodash](https://lodash.com/), 274 bytes ``` angular.module('x',[]).controller('x',['$scope',function(x){x.x=_.range(9,new Date().getFullYear()+1).slice(-121).reverse()}]) ``` ``` <script src=//goo.gl/M5LvGe></script><script src=//goo.gl/opljJl></script><select ng-app=x ng-controller=x multiple><option ng-repeat="x in x">{{x}} ``` Output [![enter image description here](https://i.stack.imgur.com/JXRPu.png)](https://i.stack.imgur.com/JXRPu.png) [Answer] # BASH + coreutils, ~~35~~ 33 bytes ``` x=`date +%Y`;seq $x -1 $((x-120)) ``` [Answer] # CJam, ~~14~~ ~~12~~ 11 bytes *Saved 2 bytes thanks to Sp3000 and 1 byte thanks to Martin Ender* ``` et0=121,f-p ``` [Try it online!](http://cjam.aditsu.net/#code=et0%3D%20%20%20%20%20%20%20%20%20e%23%20Push%20the%20current%20year%0A%20%20%20%20121%2C%20%20%20%20%20e%23%20Push%20the%20range%200%2C%201%2C%20...%2C%20120%0A%20%20%20%20%20%20%20%20f-%20%20%20e%23%20For%20each%20item%20in%20the%20range%2C%20subtract%20it%20from%20current%20year%0A%20%20%20%20%20%20%20%20%20%20p%20%20e%23%20Print%20the%20array) **Explanation** ``` et0= e# Push the current year 121, e# Push the range 0, 1, ..., 120 f- e# For each item in the range, subtract it from current year p e# Print the array ``` [Answer] # HP50g RPL, 97 bytes ``` 120 'S' STO DATE ->STR 6 9 SUB OBJ-> 'Y' STO {} S WHILE 0 >= REPEAT Y S - + 'S' DECR END REVLIST ``` Ungolfed: ``` 120 'span' STO @ Store the span of years to cover. DATE @ Get the date as number 11.082016. →STR @ Convert to string "11.082016". @ (Number format must allow all these decimal places.) 6 9 SUB @ "11.082016" Substring for the year. @ ^ ^ @ 123456789 OBJ→ @ Convert string to number. 'year' STO @ Store as the year to start at. {} span @ Start empty list to collect the years. @ Leave loop counter on the stack. WHILE 0 ≥ @ Loop until the counter goes negative. REPEAT year span - @ E.g. on first iteration: 2016 - 120 = 1896. + @ Append the year to the list on the stack. 'span' DECR @ Decrement loop counter and leave on stack. END REVLIST @ Put list in reverse chronological order. ``` Showing a list of 2016 down to 1896: [![2016 to 1896](https://i.stack.imgur.com/IGhgJ.png)](https://i.stack.imgur.com/IGhgJ.png) [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), ~~8~~ 7 bytes Code: ``` žg120Ý- ``` Explanation: ``` žg # Get the current year. 120Ý # Create the list [0, 1, ..., 119, 120]. - # Substract, which leaves [year - 0, year - 1, ..., year - 120]. ``` Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=xb5nMTIww50t&input=). [Answer] # PowerShell, 26 24 bytes @TimmyD improved version: ``` 0..120|%{(date).Year-$_} ``` Was: ``` ($d=(date).year)..($d-120) ``` where `date` runs `Get-Date` [Answer] # [Dyalog APL](http://goo.gl/9KrKoM), ~~11~~ 10 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319) ``` 120↑⌽⍳⊃⎕ts ``` `120↑` take 120 elements `⌽` of the reversed `⍳` indices until `⊃` the first element of `⎕TS` TimeStamp in the format [YYYY, M, D, h, m, s, t] [TryAPL online!](http://tryapl.org/?a=120%u2191%u233D%u2373%u2283%u2395ts&run) --- Old version: ``` (⊃⎕TS)-⍳120 ``` `⊃⎕TS` first element of [YYYY, M, D, h, m, s, t] `-` minus `⍳120` [0, 1, 2, ..., 118, 119] Requires `⎕IO←0`, which is default on many systems. [TryAPL online!](http://tryapl.org/?a=%u2395IO%u21900%20%u22C4%20%28%u2283%u2395TS%29-%u2373120&run) [Answer] # [Vitsy](http://github.com/VTCAKAVSMoACE/Vitsy) + \*sh ~~+ JavaScript~~, ~~33~~ ~~26~~ ~~21~~ 18 bytes Vitsy doesn't have native time/date retrieval, so I had to use shell and eval for this one. Thanks to @Caleb for helping me shear off another 3 bytes! ``` 'Y%+ etad',Dca*-HZ 'Y%+ etad' Push the string 'date +"%Y"' to the stack. , Execute through shell. Dca*- Dupe n, push n - 120. H Pop x, y, push range(x, y) to the stack. Z Output all stack as characters. ``` You can't try this one online, because it uses both shell AND eval. Output is as character codes. [Answer] **Mathematica/Wolfram Language, 28 bytes** ``` Date[][[1]]-#&/@Range[0,120] ``` [Answer] ## R, ~~47~~ 39 bytes ``` as.double(substr(Sys.Date(),1,4))-0:120 ``` If only someone invented a UTF-8 implementation of R with conveniently abbreviated frequently used system functions... UPD: shaved off 7 (!) bytes owing to [plannapus](https://codegolf.stackexchange.com/users/6741/plannapus), who suggested subrtacting a `0:120` vector rather than counting from `a` to `(a-120)` and 1 byte grâce à [user5957401](https://codegolf.stackexchange.com/users/58162/user5957401), who noticed that `double` would work as well as `numeric`. Old version: ``` a=as.numeric(format(Sys.Date(),"%Y"));a:(a-120) ``` [Answer] # [MATL](https://github.com/lmendo/MATL), 10 bytes ``` 1&Z'0:120- ``` [**Try it online!**](http://matl.tryitonline.net/#code=MSZaJzA6MTIwLQ&input=) ``` 1&Z' % Push first component of "clock" vector, which is year 0:120 % Literal vector [0, 1, 2, ..., 120] - % Subtract element-wise. Implicitly display ``` [Answer] # 05AB1E, 9 bytes `121FžgN-=` [Try online](https://tio.run/nexus/05ab1e#@29oZOh2dF@6n67t//8A) [Answer] # php, 73 66 58 42 bytes ``` <?=implode(', ',range($j=date(Y),$j-120)); ``` ## Output: > > 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, > 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995, > 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, > 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, > 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, > 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, > 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, > 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, > 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, > 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, > 1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896 > > > If we don't need to separate with `,`, then 58 57 41 bytes: ``` <?=implode(' ',range($j=date(Y),$j-120)); ``` Thanks to insertusernamehere for saving 16 bytes [Answer] ## Python 2, ~~64 62~~ 54 bytes ``` import time n=time.gmtime()[0] exec'print n;n-=1;'*121 ``` @KarlKastor thanks for 8 bytes! [Answer] # PostgreSQL, 57 bytes Who needs a `FROM` :-). Probably shouldn't work, but it does, try it at [sqlfiddle](http://sqlfiddle.com/#!15/9eecb7db59d16c80417c72d1e1f4fbf1/10620/0) ``` select date_part('y',current_date)-generate_series(0,120) ``` [Answer] # Bash on OS X, 23 ``` jot 121 `date +%Y` - -1 ``` This will also work on Linux if you have BSD `jot` installed (e.g. `sudo apt-get install athena-jot`. [Answer] ## Python 2, 62 bytes ``` import time for n in range(121):print int(time.ctime()[-4:])-n ``` And at 64 bytes: ``` for n in range(121):print int(__import__("time").ctime()[-4:])-n ``` [Answer] # Oracle SQL 11.2, 111 bytes ``` SELECT LISTAGG(TO_CHAR(SYSDATE,'YYYY')-LEVEL+1,', ')WITHIN GROUP(ORDER BY LEVEL)FROM DUAL CONNECT BY LEVEL<122; ``` [Answer] # Processing, ~~51~~ ~~42~~ 41 bytes ``` for(int i=0;i<121;)print(year()-i+++" "); ``` # Ungolfed ``` for(int i = 0; i < 121;) print(year() - i++ + " "); ``` Processing is just a wrapper for Java if you didn't know, and takes most of the boilerplate away, so the obvious solution is also super short compared to a Java version. Also opens a window for drawing graphics, but having that doesn't appear to disqualify me :) [Answer] # MATLAB, 18 bytes Assuming the output format doesn't matter (aside form descending order), the following program prints the last 121 years starting with the current one. ``` year(date)-(0:120) ``` It requires MATLAB version r2014a or higher. Earlier versions didn't include the `year` function. [Answer] ## JavaScript, ~~55~~ ~~52~~ ~~50~~ 49 bytes ``` for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d ``` +9 bytes to `alert` the data (not necessary if you run this in a console). ``` for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d;alert(a) ``` -4 bytes if the delimiter isn't necessary. ``` for(a=d=s=Date().substr(11,4);d-->s-120;)a+=d ``` ``` for (a = d = s = Date().substr(11, 4); d --> s - 120; ) a += " " + d; console.log(a); ``` [Answer] ## C, ~~87~~ ~~85~~ ~~76~~ ~~74~~ 65 bytes ``` main(int i,char**v){for(i=0;i<121;printf("%d,",atoi(v[1])-i++));} ``` Ungolfed: ``` main(int i,char**v){ for(i = 0; i < 121; printf("%d,", atoi(v[1])-i++)); } ``` My first code golf - Any pointers would be well received. Would be nice if I could cut out the argc/argv junk, but I'm not *that* skilled a C programmer. Improvements welcome. **EDIT**: The current year is obtained from the commandline - specifically by a group of automated, well trained drinking birds. **EDIT 2**: 85 bytes Thanks to Easterly Irk (removed spaces around arg function parameters) **EDIT 3**: 76 bytes Thanks to anatolyg for pointing out the obvious (removed verbose argc/argv param names) **EDIT 4**: 74 bytes Thanks to Yay295 (char\*\*v, changed year delimiter) **EDIT 5**: 65 bytes thanks to Yay295 and matt (re-used the variable i, removed variable x, changed while to for loop, updated printf to include atoi() read and i++) [Answer] # **JavaScript, ~~60~~ ~~53~~ 48 Bytes** ``` f=x=>x>Date().split` `[3]-121&&(alert(x),f(x-1)) ``` I used a recursive solution. [Answer] # [Go](https://go.dev), 71 bytes ``` import."time" func f(){for t,i:=Now().Year(),0;i<120;i++{println(t-i)}} ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70oPX_BmoLE5OzE9FSF3MTMvKWlJWm6FjfdM3ML8otK9JRKMnNTlbjSSvOSFdI0NKvT8osUSnQyrWz98ss1NPUiUxOLNDR1DKwzbQyNgKS2dnVBUWZeSU6eRolupmZtLcS4TWD9IOOBRnABzeGCSixYAKEB) Prints to STDERR. [Answer] ## Perl, 33 bytes ``` say+(gmtime)[5]-$_+1900for 0..120 ``` Run with `-M5.010` or `-E` : ``` perl -E 'say+(gmtime)[5]-$_+1900for 0..120' ``` [Answer] # k, 27 bytes Output as specified ``` 1@", "/:$(`year$.z.d)-!121; ``` Example: ``` k)1@", "/:$(`year$.z.d)-!121; 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, 1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896 ``` It can be shortened more by not formatting the output and merely returning the list of integers: ``` (`year$.z.d)-!121 ``` [Answer] # jq, 46 characters (45 characters code + 1 character command line option) ``` now|strftime("%Y")|tonumber|range(.;.-121;-1) ``` Sample run: ``` bash-4.3$ jq -n 'now|strftime("%Y")|tonumber|range(.;.-121;-1)' | head 2016 2015 2014 2013 2012 2011 2010 2009 2008 2007 ``` [On-line test](https://jqplay.org/jq?q=now|strftime(%22%25Y%22)|tonumber|range(.%3b.-121%3b-1)&j=null) ]
[Question] [ it's a-me! Today's task is simple: write a program, or a function that displays the idle small Mario sprite, from Super Mario Bros, on NES, over a blue background. Any kind of entry is valid as long as it displays those 12 \* 16 pixels anywhere on the screen / window / browser. (EDIT: the displayed image can be scaled up if your language can't do pixel art. You can also output ASCII art or HTML art, but using the right colors.) Image (zoomed 400%): ![](https://i.stack.imgur.com/wTIk0.png) You must use the following colors: * blue: #6B8CFF * red: #B13425 * green/brown: #6A6B04 * orange: #E39D25 Shortest program (in number of characters) wins! Standard loopholes apply (especially, no network connexion allowed), but hardcoding and displaying an image file in your program is allowed. (entries using this trick will be rank separately) Here we go! --- # Current Leaderboard **Shortest answer using code only:** * Mathematica, 141. <https://codegolf.stackexchange.com/a/39916/10732> (by Martin Büttner) * Bash, 158. <https://codegolf.stackexchange.com/a/40002/10732> (by hpsMouse) * ... **Shortest answer using some kind of hardcoded image:** * HTML, 102b. <https://codegolf.stackexchange.com/a/39923/10732> (by xem and NiettheDarkAbsol) * PHP, 131b. <https://codegolf.stackexchange.com/a/39926/10732> (by NiettheDarkAbsol) * ... [Answer] # HTML/JS, ~~206~~ ~~158~~ ~~153~~ 102 **102** Trick used: save the compressed GIF file as an HTML file, and add <img src=#> at the end Thanks to this entry: <https://codegolf.stackexchange.com/a/39926/10732> by @NiettheDarkAbsol ``` GIF87a ¡ kŒÿã%jk±4%, 6„‡héj„Af-ÕdÎy\% …R˜0”ŒÈJ­³I©±²û“ú=ª$±p%i¸•¤ <img src=#> ``` Demo: <http://meuziere.free.fr/mario/gif.html> Older versions: **153** Trick used: save the compressed PNG file as an HTML file, and add <img src=#> at the end ``` ‰PNG IHDR _v” PLTEjkkŒÿ±4%ã%ó’V IIDAT×c[ʵj%C€ÍUŸ?|ìíœÿ02„ÿÿÊÐÊàÐÄÈÀ°ŠáÓë~†«ö3üZµž!jÚR‡P x( s6ïåÇ<img src=#> ``` **158** Trick used: setting the trimmed dataURI of a compressed PNG as the SRC of an IMG tag and packing the whole thing in Unicode chars. Execute that in your JS console: ``` document.write(unescape(escape('🁩𫑧𘁳𬡣👤𨑴𨐺𪑭𨑧𩐻𨡡𬱥𝠴𛁩𥡂𣱒𭰰𢱇𩱯𠑁𠑁𣡓𥑨𡑕𩱁𠑁𠑷𠑁𠑁𤑁𩱍𠑁𠑂𩡄𜱡𥑁𠑁𠑄𡡂𣑖𡑖𬑡𭱒𬡪𤀫𮁎𠱘𪡮𤱘𮡫𩱨𥱁𠑁𠑓𥑬𡑑𥡑𢐱𜡍𢑗𮁘𢱅𣁖𬑊𥑏𠑺𥡕𡱮𮠹𛱇𦁺𬰷𤡭𨰯𮡁𮑨𤀯𛱹𪁄𤑅𣑲𩰰𣑔𢑷𣁃𢱧𩑈𥀶𜰶𡱦𝡶𜡍𛱸𨑴𦠴𪁡𭁰𤱂𫱤𤑯𢁧𫱁𭰾').replace(/uD./g,''))) ``` **206** Unpacked (206b): ``` <img src=data:image;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAQAgMAAABfD3aUAAAADFBMVEVqawRrjP+xNCXjnSXzkghWAAAASUlEQVQI12MIWxXKELVqJUOAzVUGnz9/GXzs7Rmc/zAyhP//yhDQEMrg0MTIwLCKgeHT636Gf6v2M/xatZ4hatpSBodQoHgoAw> ``` [Demo](http://xem.github.io/miniCodeEditor/1.1/#%7F%7F%3Cimg%20src%3Ddata%3Aimage%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAwAAAAQAgMAAABfD3aUAAAADFBMVEVqawRrjP+xNCXjnSXzkghWAAAASUlEQVQI12MIWxXKELVqJUOAzVUGnz9/GXzs7Rmc/zAyhP//yhDQEMrg0MTIwLCKgeHT636Gf6v2M/xatZ4hatpSBodQoHgoAw%3E1) Tools used: * <https://tinypng.com/> * <http://xem.github.io/miniURI/input.html> * <http://xem.github.io/obfuscatweet/> [Answer] ## Mathematica, ~~412~~ ~~292~~ ~~252~~ ~~212~~ ~~163~~ ~~148~~ ~~143~~ 141 characters ``` f=FromDigits[ToCharacterCode@#,2^16]~IntegerDigits~#2&;Image@Partition[f["넴╫賿橫ӣ鴥",256][[3#+1;;3#+3]]/256&/@"吀啐^A媾핮﻽溿뽫ﺩ埿⩕樨ꦪª⿼?ཐᐅ橕ꦪ喪"~f~4,12] ``` This uses caret notation `^A` for the control character at code point `1`. In Mathematica, I can actually embed the character literally, although that leads to all sorts of ugliness when copying things around. Anyway, the above is 2 characters shorter than my former version, and I got those to characters from using base-4 instead of base-5 to encode the colour palette indices. Right now I cannot be bothered to fix the explanation and screenshot below, so I'm leaving you here with the original base-5 version of my answer: --- ``` f=FromDigits[ToCharacterCode@#,2^16]~IntegerDigits~#2&;Image@Partition[f["넴╫賿橫ӣ鴥",256][[3#-2;;3#]]/256&/@"ᯱ曎㌟뱮䚻륏Σ襺ﺦ您汜豈塘ᙉ雬儥衰ꐰꃾ纔ㆯ쭴뫋澖ᕿ蓉"~f~5,12] ``` I'm encoding the pixels in Unicode characters (yay for counting by characters!). Here is what it looks like in Mathematica: ![enter image description here](https://i.stack.imgur.com/SelOL.png) Here's how it works: First we define a function `f` that turns Unicode strings (passed in as the first argument `#`) into lists of integers. First we obtain the character codes. Those can be interpreted as digits of a base 65536 number. And then we convert that number to another base, passed in as the second argument `#2`. Now let's do that for the longer Unicode string. `ToCharacterCode` yields this list: ``` {7153, 26318, 13087, 48238, 18107, 47439, 931, 35194, 62191, 65190, \ 24744, 57782, 27740, 35912, 22616, 5705, 38636, 20773, 34928, 42032, \ 41214, 32404, 12719, 52084, 47819, 28566, 5503, 33993} ``` Treating this as base 65536: ``` 7933607912575313477287527915733176998797205587959732019781370103381... 4831246938139171755469819519515972565671101475553962564506286523593 ``` And converting to base 5: ``` {2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 2, 2, 2, 3, 3, 3, 4, 4, 3, 4, 2, 2, 2, 2, 3, 4, 3, 4, 4, 4, 3, 4, 4, \ 4, 2, 2, 3, 4, 3, 3, 4, 4, 4, 3, 4, 4, 4, 2, 3, 3, 4, 4, 4, 4, 3, 3, \ 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 3, 3, 1, 3, 3, 3, \ 2, 2, 2, 2, 2, 3, 3, 3, 1, 3, 3, 1, 3, 3, 3, 2, 3, 3, 3, 3, 1, 1, 1, \ 1, 3, 3, 3, 3, 4, 4, 3, 1, 4, 1, 1, 4, 1, 3, 4, 4, 4, 4, 4, 1, 1, 1, \ 1, 1, 1, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 2, 2, 1, 1, 1, \ 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 3, 3, \ 2, 2, 2, 2, 3, 3, 3, 3} ``` Those are the colour indices of the pixels, in order blue, red, green, orange. We use those to index into that list of numbers, which is the colour palette. Now for the colour palette. That's `"넴╫賿橫ӣ鴥"`. We use the above indices to select the correct string. Then we apply our function again, but using base 256. That yields a list of 12 integers: ``` {177, 52, 37, 107, 140, 255, 106, 107, 4, 227, 157, 37} ``` We use `;;` range indexing to pull out the relevant slice for the current colour. Lastly, we just use `Partition` to split this into rows of `12` and feed it to `Image`. Voilà! **Edit:** With the Unicode packing the RLE was no longer worth it. Removing it saved 50 characters. **Edit:** Of course, without RLE, there's also no need to go to base 16. **Edit:** And while we're at it, why not Unicode-pack the colour palette, too? (I have a hunch that I can save a little bit more by make the entire colour palette also a single string and using `Partition` there too. I'll try that later.) **Edit:** Yes, that did shave off another 5 bytes. [Answer] # Java : ~~398~~ 377 ``` void s(){new java.awt.Frame(){public void paint(java.awt.Graphics g){int i=0,x,m[]={12226,44085194,467839834,0x5abea55a,0x5bbd5d50,0x5ffe9540,0x5ffe9540,0x5aee5d50,531408218,334277466,333492170,0xc02fc2},c[]={7048447,0xB13425,6974212,0xE39D25};for(setSize(99,99);i<192;g.setColor(new java.awt.Color(c[m[x]&3])),m[x]/=4,g.drawLine(x+40,60-i%16,x+40,60-i++%16))x=i/16;}}.show();} ``` Simply draws the sprite by unpacking an int for each column. Shown in a full program: ``` class P{ public static void main(String[]a){ new P().s(); } void s(){ new java.awt.Frame(){ public void paint(java.awt.Graphics g){ int i=0,x,m[]={12226,44085194,467839834,0x5abea55a,0x5bbd5d50,0x5ffe9540, 0x5ffe9540,0x5aee5d50,531408218,334277466,333492170,0xc02fc2}, c[]={7048447,0xB13425,6974212,0xE39D25}; for(setSize(99,99);i<192; g.setColor(new java.awt.Color(c[m[x]&3])),m[x]/=4, g.drawLine(x+40,60-i%16,x+40,60-i++%16) )x=i/16; } }.show(); } } ``` Obligatory screenshot: ![it's me, mario](https://i.stack.imgur.com/ohu2D.png) [Answer] # x86 Machine Code, 102 bytes How it works: The image is stored as a 2-bit image using a palette. Each row of the image is stored as 3 bytes, followed by one 1 byte of the color palette. This allows the data to be loaded as a single DWORD. The twelve pixels are output by masking off the lowest 2 bits of the value, writing them to video memory, and then right-shifting the entire value two bits. Once the pixels for the row have been outputted, the palette byte is written to the VGA palette. When the image is finished drawing, the program enters an infinite loop. Assembly code to generate the binary: ``` org 100h mov al,13h int 10h les ax,[bx] mov si,image_data draw: add di,320-12 lodsd xchg eax,ebx mov cl,12 row: mov ax,bx and al,3 stosb shr ebx,2 loop row xchg ax,bx mov dx,0x3c9 out dx,al test al,al jnz draw image_data: db 21,0,85,0xb1/4, \ 5,0,64,0x34/4, \ 165,190,87,0x25/4, \ 185,191,127,0x6b/4, \ 185,254,254,0x8c/4, \ 233,191,106,0xff/4, \ 213,255,95,0x6a/4, \ 165,168,85,0x6b/4, \ 169,40,106,0x4/4, \ 170,0,170,0xe3/4, \ 47,195,248,0x9d/4, \ 63,0,252,0x25/4, \ 15,0,240,111, \ 5,20,80,111, \ 169,85,106,111, \ 170,85,170 ``` Base-64 encoded binary, save it as Mario.com to run it: sBPNEMQHvigBgcc0AWatZpOxDInYJAOqZsHrAuL1k7rJA+6EwHXiwxUAVSwFAEANpb5XCbm/fxq5/v4j6b9qP9X/XxqlqFUaqShqAaoAqjgvw/gnPwD8CQ8A8G8FFFBvqVVqb6pVqg== Sample output: ![enter image description here](https://i.stack.imgur.com/k0OUE.png) [Answer] # [Octo/XO-Chip](http://johnearnest.github.io/Octo/), 70 bytes Octo is a high level assembly language that compiles down into bytecoded instructions for the [CHIP-8](https://en.wikipedia.org/wiki/CHIP-8) virtual machine. Octo provides some custom extensions called "XO-Chip" to the basic CHIP-8 bytecode, including the ability to draw 4-color bitmaps via overlaid bitplanes. The compiled bytes are as follows: ``` 0xA2 0x08 0xF3 0x01 0xD0 0x00 0x1F 0x00 0x3F 0xC0 0x39 0x00 0x51 0x00 0x58 0x80 0x21 0xE0 0x00 0x00 0x3F 0x00 0x7F 0xE0 0xFF 0xF0 0x36 0xC0 0x1F 0x80 0x3F 0xC0 0x39 0xC0 0x70 0xE0 0xF0 0xF0 0x00 0x00 0x00 0x00 0x3F 0x80 0x7F 0xE0 0x7F 0xF0 0x3F 0xE0 0x1F 0xC0 0x37 0x00 0x76 0xE0 0xF0 0xF0 0xE9 0x70 0xE0 0x70 0xC0 0x30 0x00 0x00 0x70 0xE0 0xF0 0xF0 ``` ![mario](https://i.stack.imgur.com/NsKVz.png) Run it here in your browser: <http://johnearnest.github.io/Octo/index.html?gist=33aa37d4717a425ccd4f> It is probably more illuminating to see the Octo assembly language which produces that bytecode: ``` : main i := mario plane 3 sprite v0 v0 0 : mario 0x1F 0x00 0x3F 0xC0 0x39 0x00 0x51 0x00 0x58 0x80 0x21 0xE0 0x00 0x00 0x3F 0x00 0x7F 0xE0 0xFF 0xF0 0x36 0xC0 0x1F 0x80 0x3F 0xC0 0x39 0xC0 0x70 0xE0 0xF0 0xF0 0x00 0x00 0x00 0x00 0x3F 0x80 0x7F 0xE0 0x7F 0xF0 0x3F 0xE0 0x1F 0xC0 0x37 0x00 0x76 0xE0 0xF0 0xF0 0xE9 0x70 0xE0 0x70 0xC0 0x30 0x00 0x00 0x70 0xE0 0xF0 0xF0 ``` The main program is three two-byte instructions. Set the memory index register `i` to the beginning of the data segment, select drawing plane 3 (3 is a bitmask; this indicates you wish to draw in 4 color mode with both bitplanes) and then draw a sprite at an x and y position given by register `v0` (initialized to zero). The final 0 provides the size of the sprite, which in the SuperChip and XO-Chip instruction sets will draw a 16x16 sprite. In 4 color mode, a bitmap for the first plane is followed immediately by a bitmap for the second plane. To see how the planes work, consider this modified program which scrolls one plane to the right after drawing mario: ![mario2](https://i.stack.imgur.com/TuEkM.png) ``` : main i := mario plane 3 sprite v0 v0 0 plane 2 scroll-right scroll-right scroll-right scroll-right : mario 0x1F 0x00 0x3F 0xC0 0x39 0x00 0x51 0x00 0x58 0x80 0x21 0xE0 0x00 0x00 0x3F 0x00 0x7F 0xE0 0xFF 0xF0 0x36 0xC0 0x1F 0x80 0x3F 0xC0 0x39 0xC0 0x70 0xE0 0xF0 0xF0 0x00 0x00 0x00 0x00 0x3F 0x80 0x7F 0xE0 0x7F 0xF0 0x3F 0xE0 0x1F 0xC0 0x37 0x00 0x76 0xE0 0xF0 0xF0 0xE9 0x70 0xE0 0x70 0xC0 0x30 0x00 0x00 0x70 0xE0 0xF0 0xF0 ``` If you enjoy this you might like one of my [other solutions](https://codegolf.stackexchange.com/questions/52547/minimal-nethack/52556#52556) written with Octo. There's actually a [game jam](http://octojam.com) going on for the month of October based around this tool. [Answer] # Bash + ImageMagick: ~~350~~ ~~331~~ 321 characters (Palette shamelessly stolen from [Martin Büttner](https://codegolf.stackexchange.com/users/8478/martin-b%c3%bcttner)'s [answer](https://codegolf.stackexchange.com/a/39916).) ``` p=(B13425 6B8CFF 6A6B04 E39D25) for c in 21 0 85 5 0 64 165 190 87 1{85,91,27,85} 254{,} 233 191 106 213 255 95 165 168 85 169 40 106 170 0 170 47 195 248 63 0 252 15 0 240 5 20 80 169 85 106 170 85 170;{ for j in 0 2 4 6;{ d+=(-fill \#${p[c>>j&3]} -draw point\ $[i%12],$[i++/12]) } } convert -size 12x16 xc: "${d[@]}" x: ``` Sample output: ![Mario](https://i.stack.imgur.com/qwUPw.png) To inspect it easily add `-scale 120` to `convert`'s parameters to get a 10x scaled version: ![Mario scaled 10](https://i.stack.imgur.com/Hn3Zr.png) [Answer] # GIF - 93 bytes Hardcoding the image is apparently okay now, so... yay? :D ``` GIF87a ¡ kŒÿã%jk±4%, 6„‡héj„Af-ÕdÎy\% …R˜0”ŒÈJ­³I©±²û“ú=ª$±p%i¸•¤ ; ``` As seen in Notepad++ ![screenshot in NP++](https://i.stack.imgur.com/NhHsM.png) # As PHP - 131 bytes ``` <? header("Content-Type:image/gif");?>GIF87a ¡ kŒÿã%jk±4%, 6„‡héj„Af-ÕdÎy\% …R˜0”ŒÈJ­³I©±²û“ú=ª$±p%i¸•¤ ; ``` [Answer] # Groovy 417 386 Fun as hell, but with a terrible char count. [GroovyFX](http://groovyfx.org/) needed ``` m=[b:'6B8CFF',r:'B13425',g:'6A6B04',o:'E39D25'];groovyx.javafx.GroovyFX.start{stage(visible:!0){scene(width:60,height:80){flowPane{"3b5r4b2b9r1b2b3g2o1g1o3b1b1g1o1g3o1g3o1b1b1g1o2g3o1g3o1b2g4o4g1b3b7o2b2b2g1r3g4b1b3g1r2g1r3g1b4g4r4g2o1g1r1o2r1o1r1g2o3o6r3o2o8r2o2b3r2b3r2b1b3g4b3g1b4g4b4g".toList().collate 2 each{l->(l[0]as int).times{rectangle(width:5,height:5,fill:"#"+m[l[1]])}}}}}} ``` ungolfed: ``` m=[b:'6B8CFF', r:'B13425', g:'6A6B04', o:'E39D25'] s=5 groovyx.javafx.GroovyFX.start {bd-> stage(visible: !0) { scene(width:s*12, height:s*16) { flowPane { "3b5r4b 2b9r1b 2b3g2o1g1o3b 1b1g1o1g3o1g3o1b 1b1g1o2g3o1g3o 1b2g4o4g1b 3b7o2b 2b2g1r3g4b 1b3g1r2g1r3g1b 4g4r4g 2o1g1r1o2r1o1r1g2o 3o6r3o 2o8r2o 2b3r2b3r2b 1b3g4b3g1b 4g4b4g" .replaceAll(" ", "") .toList() .collate(2) .each { l-> t=l[0] as int cr=m[l[1]] t.times { rectangle(width:s, height:s, fill:"#"+cr) } } } } } } ``` ![enter image description here](https://i.stack.imgur.com/ZILZn.png) [Answer] # HTML/JS, ~~427~~ ~~408~~ ~~264~~ ~~256~~ ~~239~~ 226 chars ### Obfuscatweet, ~~271~~ ~~270~~ ~~264~~ ~~256~~ ~~239~~ 226 chars Using obfuscatweet, managed to shorten this down to < 250 :D ``` document.write(unescape(escape('🁳𨱲𪑰𭀾𨰽𦰢𝡂𞁃𡡆𘠬𘡂𜐳𝀲𝐢𛀢𝡁𝡂𜀴𘠬𘡅𜰹𡀲𝐢𧐻𨐽𙰰𜐵𝐰𜀰𝐵𝐵𝀰𠑂𡑃𜀲𡑆𡑆𠰲𡑂𡡂𡠲𠡆𡑁𞀰𜱆𡡆𜀰𠐶𠐰𜀲𠐶𞑁𞁁𠐵𝑁𠑆𞑄𝰶𡡆𡀵𝐷𡡆𝐵𝐵𡠰𝐴𜐵𜀲𠐰𜁁𞁁𠐰𜁁𠐧𞱷𪑴𪀨𩁯𨱵𫑥𫡴𚑦𫱲𚁩🐰𞱩🀹𝠻𭱲𪑴𩐨𙰼𨡲🠧𚐩𮱨🐨𙰰𜀰𙰫𬁡𬡳𩑉𫡴𚁡𛡳𫁩𨱥𚁩𛁩𚰽𝠩𛀱𝠩𛡴𫱓𭁲𪑮𩰨𝀩𚐮𬱬𪑣𩐨𛐱𜠩𞱦𫱲𚁪🐰𞱪🀱𜠻𭱲𪑴𩐨𙰼𬡰𘁳𭁹𫁥🐢𬁡𩁤𪑮𩰺𜐠𞀻𨡡𨱫𩱲𫱵𫡤𞠣𙰫𨱛𪁛𪠫𚱝𧐫𙰢🠼𛱲𬀾𙰩𚐻𯐼𛱳𨱲𪑰𭀾').replace(/uD./g,''))) ``` Code below is what this consists of. Trick used: converted image to base4 String of color tiles, converted this into a hexadecimal String. Index of the base 4 denotes color (0=blue, 1=RED, etc.) CSS with an inline p is used to because divs need content to expand (also p is shorter). Because CSS needs to begin with a letter, 'A' is prepended before the CSS tags. Padding from the CSS gives pixels. None of this uses Unicode characters, which I'm not too familiar with anyways, though it'd probably go sub-300 in that case. The relative advantage to using the padding is that you can, as in this case, blow up the image to whatever size you want each pixel to be. I've used 9 pixels, but if you spend an extra character, you can get up to 99 pixels per represented pixel. ### CSS, ~~127~~ ~~119~~ ~~118~~ ~~114~~ ~~100~~ ~~13~~ 0 chars Switching from `p` to `rp` removes the need for `display:inline`, cost +1 char, -15! chars! Removed all the colors and put it into an array in JS -87 chars. Then I just removed all the css ### JS, ~~300~~ ~~289~~ ~~280~~ ~~275~~ ~~329~~ 325 chars ``` c=["6B8CFF","B13425","6A6B04","E39D25"];a='0155000555540ABEC02EFEFC2EBFBF2BFEA803FFF00A6A002A69A8AA55AAF9D76FFD557FF5555F0541502A00A8AA00AA';with(document)for(i=0;i<96;write('<br>')){h=('000'+parseInt(a.slice(i,i+=6),16).toString(4)).slice(-12);for(j=0;j<12;write('<rp style="padding:1 8;background:#'+c[h[j++]]+'"></rp>'));} ``` I tried to cut as much as I could out of this plain JS processing a hex string, but given as it's my first try, this is how far I got using only what I know. The HTML writing has been shortened by a function that adds tags, and the classes use the base 4 value to determine the color to display. Using additional shortening, replaced charAt with [] brackets, and removed the A0 class and set blue as default color for p, saving additional 10 characters. The additional cost to use `rp` tags is offset by a huge loss in CSS. Additional offset from removing the while loop pad to just adding '000' for the use case and slicing -12 from it. Added additional JS for colors, then put the padding in there. Noticed a bug with the padding that requires 2 extra characters to fix. Compacted a bunch of loops ### HTML File, ~~430~~ ~~429~~ ~~419~~ ~~399~~ ~~366~~ 342 chars [Demo](http://c99.nl/f/513968.html) ``` <script>c=["6B8CFF","B13425","6A6B04","E39D25"];a='0155000555540ABEC02EFEFC2EBFBF2BFEA803FFF00A6A002A69A8AA55AAF9D76FFD557FF5555F0541502A00A8AA00AA';with(document)for(i=0;i<96;write('<br>')){h=('000'+parseInt(a.slice(i,i+=6),16).toString(4)).slice(-12);for(j=0;j<12;write('<rp style="padding:1 8;background:#'+c[h[j++]]+'"></rp>'));}</script> ``` [Answer] # MATLAB, 194 193 bytes The code: ``` imagesc(dec2base(base2dec(reshape('5FVQL5VVVT50A4L4HA594GAHA45A015DAL551G2L41GO101VO0A7FMAANVVAAVVVQ5VLVL40L8100L80',5,[])',32),4)-48);colormap([106 107 4;107 140 255;227 157 37;177 52 37]/255) ``` And the output: [![Mario](https://i.stack.imgur.com/0Xv2l.png)](https://i.stack.imgur.com/0Xv2l.png) Basically I converted the Mario image so that each pixel is a 2 bit number. I then encoded that in base 32 which is the string shown in the code. This string is first reshaped to be 5 x 16 (each row (12px) of 2bit numbers was encoded into base 32), then converted back into base 10. The result is converted once again, this time into base 4 yielding a 12x16 array of 2 bit numbers. These numbers are plotted using `imagesc()`. Then the colours are assigned using `colormap()` with a custom colour map of the required hex values. Amusingly, a third of the number of bytes used are just to get MATLAB to set the correct colours *after* it has been plotted. The colour code is almost the same number of bytes as the entire base32 string!. Without correcting the colour (remove the `colormap()` call), it is **135** bytes, and this is the output for the default colour map on MATLAB R2013a: [![Mario, no mapping](https://i.stack.imgur.com/83iut.png)](https://i.stack.imgur.com/83iut.png) [Answer] # Excel VBA, ~~310~~ ~~307~~ 295 Bytes Anonymous VBE Immediates Window function that outputs a Mario to the Activesheet object at cells `A1:L16` ``` o=2465251:Cells.RowHeight=48:a[A1:L16],-29589:a[C4:K5,D3:I7,J7,L5,A11:L13],o:a[C3:E3,H3:H4,B4:B6,C6,D4:D5,E5,I5,H6:K6,C8:H8,B9:K10,A10:L10,C11,J11,B15:D16,A16,I15:K16,L16],289642:a[D1:H1,C2:K2,E8:E10,F10:H10,H9,D11:I13,C13:E14,H13:J14],2438321:a[E11,H11],o ``` Helper `Sub`Routine a ``` Sub a(r,c):r.Interior.Color=c:End Sub ``` **Ungolfed Version** ``` Public Sub b() o = 2465251 Cells.RowHeight = 48 a [A1:L16], -29589 a [C4:K5,D3:I7,J7,L5,A11:L13], o a [C3:E3,H3:H4,B4:B6,C6,D4:D5,E5,I5,H6:K6,C8:H8,B9:K10,A10:L10,C11,J11,B15:D16,A16,I15:K16,L16], 289642 a [D1:H1,C2:K2,E8:E10,F10:H10,H9,D11:I13,C13:E14,H13:J14], 2438321 a [E11,H11], o End Sub Private Sub a(ByRef r As Range, ByVal c As Integer) r.Interior.Color = c End Sub ``` -3 bytes for removing whitespace -12 bytes for using `[...]` notation over `Range(...)` notation; changing over from hex colors to int colors ## Output [![It'sa Me](https://i.stack.imgur.com/M5KG2.png)](https://i.stack.imgur.com/M5KG2.png) [Answer] # JavaScript/~~CSS~~/HTML ~~446~~ ~~430~~ ~~407~~ ~~353~~ ~~328~~ 316 I golfed as much as I could and ended up with some dirty HTML/JS, but whatever...it works. **Edit**: This is it...I'm done. **Edit** Seriously done this time. ## JavaScript ``` for(i=0;i<192;)document.body.innerHTML+=(i%12?"":"<br>")+"<font color=#"+["6B8CFF","B13425","6A6B04","E39D25"]["000111110000001111111110002223323000023233323330023223332333022333322220000333333300002212220000022212212220222211112222332131131233333111111333331111111133001110011100022200002220222200002222"[i++]]+">█" ``` [JSFiddle](http://jsfiddle.net/gcfnojv4/21/) [Answer] ## Matlab - ~~449 / 332~~ 305 bytes partial compression + Using the lower image symetry: ``` a=[0,0];b=[2,2];c=[3,3];d=[a,0];f=[b,2];g=[c,3];h=[b,b];i=[a,a];k=[1,1];l=[0,f,1,2;h,k;c,2,1,3,1;g,k,1;c,k,k;a,k,1,0;0,f,a;h,a];imshow(uint8([d,k,1,k,i;a,k,k,k,k,1,0;a,f,c,2,3,d;0,2,3,2,g,2,g,0;0,2,3,b,g,2,g;0,b,c,c,h,0;d,g,g,3,a;a,b,1,f,i;[l fliplr(l)]]),[107 140 255;177 52 37;106 107 4;227 157 37]/255) ``` -- Partially compressed version (332 bytes): ``` a=[0,0] b=[2,2] c=[3,3] d=[a,0] e=[1,1,1] f=[b,2] g=[c,3] h=[b,b] i=[a,a] imshow(uint8([d,e,1,1,i;a,e,e,e,0;a,f,c,2,3,d;0,2,3,2,g,2,g,0;0,2,3,b,g,2,g;0,b,c,c,h,0;d,g,g,3,a;a,b,1,f,i;0,f,1,b,1,f,0;h,e,1,h;c,2,1,3,1,1,3,1,2,c;g,e,e,g;c,e,e,1,1,c;a,e,a,e,a;0,b,2,i,f,0;h,i,h]),[107 140 255;177 52 37;106 107 4;227 157 37]/255) ``` --- Fully uncompressed version (449 bytes): ``` imshow(uint8([0,0,0,1,1,1,1,1,0,0,0,0;0,0,1,1,1,1,1,1,1,1,1,0;0,0,2,2,2,3,3,2,3,0,0,0;0,2,3,2,3,3,3,2,3,3,3,0;0,2,3,2,2,3,3,3,2,3,3,3;0,2,2,3,3,3,3,2,2,2,2,0;0,0,0,3,3,3,3,3,3,3,0,0;0,0,2,2,1,2,2,2,0,0,0,0;0,2,2,2,1,2,2,1,2,2,2,0;2,2,2,2,1,1,1,1,2,2,2,2;3,3,2,1,3,1,1,3,1,2,3,3;3,3,3,1,1,1,1,1,1,3,3,3;3,3,1,1,1,1,1,1,1,1,3,3;0,0,1,1,1,0,0,1,1,1,0,0;0,2,2,2,0,0,0,0,2,2,2,0;2,2,2,2,0,0,0,0,2,2,2,2]),[107 140 255;177 52 37;106 107 4;227 157 37]/255) ``` --- Output in both cases (magnified on screen obviously, the real one is 12x16pix): ![MarioMagnified](https://i.stack.imgur.com/A2ufN.png) [Answer] # C, 4999 bytes This absolutely cannot compete with some of the answers here, but I thought I'd give a C answer a shot. The code is one single long line, so [here](http://pastebin.com/RPQ9sY8A) is a pastebin link. If you'd prefer, here is a base64 encoding of the gzipped code: `H4sICAzFGFYCA21hcmlvLmMA3Zc9DsIwDIXv0qndUqchkXwUurAgdYiFEEyIu4NYaZBI7PzNT3Lsz4mf408bjdPjct3odh6HVeujdgg4K4vzohCM8esdjHOpkrVoALUtIrBX8y1R04DKNCGZmTp85CVdAHifYuxO3mElIlju6xaRICOgCo4pD64PoiTzHnkZcHYnRhAYcEEpFznxB1mXP4TdS/KeVGYPZbmVaQHlnRVZFi65OkhoGodq+RHrby4xsTj8i6RmapXrPvfa0Q8ZWZY1/UPbSiC7Z2bYA7r0zla57Xmo8sOEzxdNYIXFhxMAAA==` Notable in that it requires no external libraries to run. Requires xterm, Konsole, or GNOME terminal, because it uses the RGB expansion to the ANSI color escape codes to output the correct colors (ANSI doesn't define orange). For obvious reasons, ideone won't work. It can be run in Windows under Cygwin, which uses xterm (in fact, that's how I tested it). MSYS might work; I'm not sure. Output on my machine (xterm): ![it's a me, mario!](https://i.stack.imgur.com/5yzMR.png) [Answer] **Bash 346** *pure bash with VT100 like escape sequences ( sorry no orange in that palette )* ``` C=" " B="\033[44m$C" R="\033[41m$C" G="\033[42m$C" O="\033[43m$C" N="\033[00m\n" A="BBBRRRRRBBBBNBBRRRRRRRRRBNBBGGGOOGOBBBNBGOGOOOGOOOBNBGOGGOOOGOOONBGGOOOOGGGGBNBBBOOOOOOOBBNBBGGRGGGBBBBNBGGGRGGRGGGBNGGGGRRRRGGGGNOOGRORRORGOONOOORRRRRROOONOORRRRRRRROONBBRRRBBRRRBBNBGGGBBBBGGGBNGGGGBBBBGGGGN" while read -n1 v do printf "${!v}" done <<< "$A" ``` [Answer] # Pyth, 83 bytes Disclaimer: This isn't a winning candidate, because some of the language features were created after posting the question. ``` .wc16@Lc4CM"±4%kÿjkã%"jC"T\0UP\0Z¾Õnþýn¿¿kþ©WÿõZ*Uj(©ª\0ªøÃ/ü\0?ð\0PjU©ªUª"4 ``` Here's a hex-dump: ``` 00000000 2E 77 63 31 36 40 4C 63 34 43 4D 22 B1 34 25 6B .wc16@Lc4CM".4%k 00000010 8C FF 6A 6B 04 E3 9D 25 22 6A 43 22 54 5C 30 55 ..jk...%"jC"T\0U 00000020 50 5C 30 01 5A BE D5 6E FE FD 6E BF BF 6B FE A9 P\0.Z..n..n..k.. 00000030 57 FF F5 5A 2A 55 6A 28 A9 AA 5C 30 AA F8 C3 2F W..Z*Uj(..\0.../ 00000040 FC 5C 30 3F F0 5C 30 0F 50 14 05 6A 55 A9 AA 55 .\0?.\0.P..jU..U 00000050 AA 22 34 ."4 ``` You can also download the program [here](https://dl.dropboxusercontent.com/u/65361302/mario.pyth) and run it with ``` python3 pyth.py mario.pyth ``` This creates a file `o.png`: [![Mario](https://i.stack.imgur.com/AmG02.png)](https://i.stack.imgur.com/AmG02.png) ### Explanation: There are only 4 different colors, therefore I only need 2 bits to save the color of each pixel. ``` .wc16@Lc4CM"..."jC"..."4 "..." the colors of the image, 2 bit per pixel C convert these bytes to a number j 4 and convert it to base 4 (extracting the colors) "..." the hexcodes of the 4 colors (3 byte per color) CM convert each byte into its number c4 split into 4 lists @L for each pixel, pick the correct list of color-list c16 split into 16 rows .w save it as "o.png" ``` [Answer] # Processing 2 - 359 characters I saw this challenge and immediately thought of Processing's pixel[] function. I was hoping it would be shorter but i'm still fairly happy with the result considering this is my first attempt at code golf. ``` int i,l;i=l=0;size(12,16);loadPixels();for(char c:"3b5r6b9r3b3g2o1g1o4b1g1o1g3o1g3o2b1g1o2g3o1g3o1b2g4o4g4b7o4b2g1r3g5b3g1r2g1r3g1b4g4r4g2o1g1r1o2r1o1r1g5o6r5o8r2o2b3r2b3r3b3g4b3g1b4g4b4g".toCharArray()){while(l>0){pixels[i]=#6B8CFF;if(c=='r')pixels[i]=#B13425;if(c=='g')pixels[i]=#6A6B04;if(c=='o')pixels[i]=#E39D25;i++;l--;}if(c<58){l=c-48;}}updatePixels(); ``` ungolfed: ``` int i,l;i=l=0; size(12,16); loadPixels(); for(char c:"3b5r6b9r3b3g2o1g1o4b1g1o1g3o1g3o2b1g1o2g3o1g3o1b2g4o4g4b7o4b2g1r3g5b3g1r2g1r3g1b4g4r4g2o1g1r1o2r1o1r1g5o6r5o8r2o2b3r2b3r3b3g4b3g1b4g4b4g".toCharArray()) { while(l>0) { pixels[i]=#6B8CFF; if(c=='r')pixels[i]=#B13425; if(c=='g')pixels[i]=#6A6B04; if(c=='o')pixels[i]=#E39D25; i++; l--; } if(c<58){l=c-48;} } updatePixels(); ``` you can download processing [here](https://www.processing.org/download/?processing) [Answer] # Javascript 515 ``` str=''; "000111110000|001111111110|002223323000|023233323330|023223332333|022333322220|000333333300|002212220000|022212212220|222211112222|332131131233|333111111333|331111111133|001110011100|022200002220|222200002222" .split("|").forEach(function(ov, ok) { str += '<div>' ov.split("").forEach(function(iv, ik) { str += '<div style="width:1px;height:1px;background-color:' + ['#6B8CFF','#B13425','#6A6B04','#E39D25'][iv] + ';display:inline-block"></div>'; }); str+= '</div>'; }); document.write(str); ``` just got it working, still have to go in and golf it up [Answer] # Perl - Ungolfed 927 I'll have to golf this later. First time trying out `Image::Magick`. ``` #!/usr/local/bin/perl use Image::Magick; use strict; use warnings; my @p = ( [0,0,0,1,1,1,1,1,0,0,0,0], [0,0,1,1,1,1,1,1,1,1,1,0], [0,0,2,2,2,3,3,2,3,0,0,0], [0,2,3,2,3,3,3,2,3,3,3,0], [0,2,3,2,2,3,3,3,2,3,3,3], [0,2,2,3,3,3,3,2,2,2,2,0], [0,0,0,3,3,3,3,3,3,3,0,0], [0,0,2,2,1,2,2,2,0,0,0,0], [0,2,2,2,1,2,2,1,2,2,2,0], [2,2,2,2,1,1,1,1,2,2,2,2], [3,3,2,1,3,1,1,3,1,2,3,3], [3,3,3,1,1,1,1,1,1,3,3,3], [3,3,1,1,1,1,1,1,1,1,3,3], [0,0,1,1,1,0,0,1,1,1,0,0], [0,2,2,2,0,0,0,0,2,2,2,0], [2,2,2,2,0,0,0,0,2,2,2,2], ); my $image = Image::Magick->new; $image->Set(size=>'12x16'); $image->ReadImage('canvas:white'); for my $i (0..$#p) { for (0..(@{$p[$i]} - 1)) { my $color; $color = ($p[$i][$_] < 1 ? "#6B8CFF" : $p[$i][$_] < 2 ? "#B13425" : $p[$i][$_] < 3 ? "#6A6B04" : "#E39D25"); print "$i : $_ : $color \n"; $image->Set("pixel[$_,$i]"=> $color); } } #$image->Write("mario.png"); $image->Display(); ``` I'm sure we have plenty of these but here's mine: ![Mario!](https://i.stack.imgur.com/FXUBy.png) [Answer] # Bash Printable: ~~179~~ 158 Bytes Inspired by [user2485710's answer](https://codegolf.stackexchange.com/a/39969/18017). You need to tune your terminal to match colors exactly. ``` eval "$(base64 -d<<</AD/8AAD9Wm/2amr2Wpq1qlX/qqv9RX/1RRXVQBVpIIaqAAqoAAK8DwP1f9XVf9V|xxd -b -c3 -g0|cut -c10-33|sed $'s/../\e[4$[2#&+1]m \e[0m/g;s/^/echo /')" ``` [Answer] # Tcl 298 ``` package require base64 set d [base64::decode AVUABVVUCr7ALv78Lr+/K/6oA//wCmoAKmmoqlWq+ddv/VV/9VVfBUFQKgCoqgCq] binary scan $d B* z set i 0 foreach {a b} [split $z ""] { if {$i % 12 == 0} {puts "\033\[0m"} puts -nonewline "\033\[4[string map {00 4 01 1 10 2 11 3} $a$b];m " incr i } puts "\033\[0m" ``` It's a 2 bits per pixel image in base 64. Pixels are mapped to ansi escape codes. ![enter image description here](https://i.stack.imgur.com/ikxF1.png) [Answer] ## JavaScript - 256 characters (161 obfusc-a-tweeted) ``` d=v=>{for(i=v&15;i--;)O.innerHTML+=`<i style="color:#${'6B8CFF6A6B04B13425E39D25'.substr(x%4*6,6)}">█</i>`+(++f%12?'':'<br>');x++},f=x=0,[..."fhilsswsssuss££cgÓdcddc¤g£stcucds³c¹cefefcc¤c§"].map(v=>(d(v=v.charCodeAt(0)-99),d(v>>4))) ``` ``` <p id=O> ``` [![enter image description here](https://i.stack.imgur.com/HcpST.png)](https://i.stack.imgur.com/HcpST.png) ### Method: 1. Using bitmasking, a 63x8-bit string provides a 126x4-bit value array consisting of numbers in the range 0-9. (Frustratingly... saved 63 characters by going 4-bit, but spent 50 characters unpacking the bits again lol. Still, 13 chars is 13 chars! :-) 2. The 4 paint colours are cycled in the order: B, G, R, O. At each iteration, 0-9 divs are rendered for the current color (with a line break every 12th) To determine the optimal order for the color cycle, I ran the compression algorithm against the raw data for each of 24 permutations of [R, G, B, O] and selected the one yielding the shortest output (126 was best, least optimal was around 150-something) ETA discovered this only after reading the other answers using obfusca-tweet... ``` eval(unescape(escape`𩀽𭠽🡻𩡯𬠨𪐽𭠦𜐵𞱩𛐭𞰩𣰮𪑮𫡥𬡈𥁍𣀫👠🁩𘁳𭁹𫁥🐢𨱯𫁯𬠺𘰤𮰧𝡂𞁃𡡆𝡁𝡂𜀴𠠱𜰴𜠵𡐳𞑄𜠵𙰮𬱵𨡳𭁲𚁸𙐴𚠶𛀶𚑽𘠾ﶈ�𛱩🡠𚰨𚰫𩠥𜐲🰧𙰺𙰼𨡲🠧𚐻𮀫𚱽𛁦👸🐰𛁛𛠮𛠢𩡨𪑬𬱳𭱳𬱳𭑳𬲣𸱣𩳓𩁣𩁤𨲤𩲣𬱴𨱵𨱤𬲳𨲹𨱥𩡥𩡣𨲤𨲧𘡝𛡭𨑰𚁶🐾𚁤𚁶👶𛡣𪁡𬡃𫱤𩑁𭀨𜀩𛐹𞐩𛁤𚁶🠾𝀩𚐩𒠼𬀠`.replace(/u../g,''))) ``` Further ideas. - Try 3-bit data range 0-6, with the rare 7,8,9 gaining 4 extra each: 60000N. - check color cycle permutations in all directions and speeds other than horizontally one pixel at a time. - try multiple render passes so colors can be layered. [Answer] # Javascript, ~~253~~ ~~240~~ ~~238~~ 236 ## [Obfuscatweet](http://xem.github.io/obfuscatweet/)ed source - ~~253~~ ~~240~~ ~~238~~ 236 ``` document.write(unescape(escape('🁳𨱲𪑰𭀾𘠵𫐲𫰹𫑨𜰰𞐷𫁯𩰹𜐰𜑰𪰹𮡰𝱵𞑶𭁸𭰹𜱱𭐸𞐸𝡷𭰹𭑯𩱫𞐳𨱳𬁨𞐶𪡭𪡥𞐶𬁬𫡵𞐶𭠷𮐲𞑭𝐸𜀹𭁨𮡯𞐳𨡥𨰵𘠮𬱰𫁩𭀨𞐩𛡦𫱲𡑡𨱨𚁦𭑮𨱴𪑯𫠨𨰩𮱤👤𫱣𭑭𩑮𭀻𨰽𬁡𬡳𩑉𫡴𚁣𛀳𝠩𛡴𫱓𭁲𪑮𩰨𝀩𞱷𪁩𫁥𚁣𛡬𩑮𩱴𪀼𜐲𚑣🐢𜀢𚱣𞱣𛡳𬁬𪑴𚀢𘠩𛡦𫱲𡑡𨱨𚁦𭑮𨱴𪑯𫠨𭠩𮱤𛡷𬡩𭁥𚀢🁰𘁳𭁹𫁥🐧𩁩𬱰𫁡𮐺𪑮𫁩𫡥𞱰𨑤𩁩𫡧𞠹𞱢𨑣𪱧𬡯𭑮𩀺𘰢𚱛𘠶𠠸𠱆𡠢𛀢𝡁𝡂𜀴𘠬𘡅𜰹𡀲𝐢𛀢𠠱𜰴𜠵𘡝𦰫𭡝𚰢𙰾🀯𬀾𘠩𯐩𞱤𛡷𬡩𭁥𚀢🁢𬠾𘠩𯐩🀯𬱣𬡩𬁴🠠').replace(/uD./g,''))) ``` ## Unobfuscated - ~~395~~ ~~370~~ ~~365~~ 361 ``` <script>"5m2o9mh3097log9101pk9zp7u9vtxw93qu8986ww9uogk93csph96jmje96plnu96v7y29m5809thzo93bec5".split(9).forEach(function(c){d=document;c=parseInt(c,36).toString(4);while(c.length<12)c="0"+c;c.split("").forEach(function(v){d.write("<p style='display:inline;padding:9;background:#"+["6B8CFF","6A6B04","E39D25","B13425"][+v]+"'></p>")});d.write("<br>")})</script> ``` Thanks to @compass for the `<p>` tag tricks, and @xem for 2(5) chars. [Demo](http://c99.nl/f/913861.html) It converts data from base 36, and converts to base 4. [Answer] # JavaScript ES6 (HTML + CSS), 199 307 3195 3630 Using [Obfusc-a-tweet](http://xem.github.io/obfuscatweet/): ``` eval(unescape(escape('𬰽𦱝𒠧𜰹𮡲𬀳𝁤𩡬𜱪𩱴𜐴𨡷𭐵𝁢𪱣𩠴𝱰𜡨𜱦𫁹𭀳𪑮𪀱𝀵𝀸𞐶𫑳𫱡𞑰𩡥𝰹𭁺𝑲𞑤𝁢𜰳𝁨𩁸𝀵𩀴𞐶𫠹𩱱𙰮𫑡𭁣𪀨𛰮𮰵𯐯𩰩𛡦𫱲𡑡𨱨𚀨𫠬𪐩🐾𦰮𛠮𬁡𬡳𩑉𫡴𚁮𛀳𝠩𛡴𫱓𭁲𪑮𩰨𝀩𧐮𩡯𬡅𨑣𪀨𚁭𛁪𚐽🡳𛡰𭑳𪀨𪠫𜐫𙱰𮀠𙰫𚀫𪐫𜐩𚰧𬁸𘀣𙰫𦰧𠠱𜰴𜠵𙰬𙰶𠠸𠱆𡠧𛀧𝡁𝡂𜀴𙰬𙱅𜰹𡀲𝐧𧑛𚱭𧐩𚐩𒡤𫱣𭑭𩑮𭀮𭱲𪑴𩐨𙰼𬀠𬱴𮑬𩐽𘡷𪑤𭁨𞠱𬁸𞱨𩑩𩱨𭀺𜑰𮀻𨡯𮀭𬱨𨑤𫱷𞠧𚱳𚰧𘠧𚐠').replace(/uD./g,''))) ``` This displays the sprite without using any images or multiple elements; it just misuses the CSS `box-shadow` property to create each pixel. Try it at <http://jsbin.com/pozohiyezo/>. This unobfuscated version is **307 characters**: ``` s=[] '39zrp34dfl3jgt14bwu54bkcf47p2h3flyt3inh1454896msoa9pfe79tz5r9d4b334hdx45d496n9gq'.match(/.{5}/g).some((n,i)=>[...parseInt(n,36).toString(4)].forEach((m,j)=>s.push(j+1+'px '+(+i+1)+'px #'+['B13425','6B8CFF','6A6B04','E39D25'][+m]))) document.write('<p style="width:1px;height:1px;box-shadow:'+s+'"') ``` This is the original, plain-vanilla HTML version. See it in action at <http://jsfiddle.net/gfeLn1ey/1/>. ``` <p style="width:1px;height:1px;box-shadow:4px 1px 0 #B13425,5px 1px 0 #B13425,6px 1px 0 #B13425,7px 1px 0 #B13425,8px 1px 0 #B13425,12px 1px 0 #6B8CFF,3px 2px 0 #B13425,4px 2px 0 #B13425,5px 2px 0 #B13425,6px 2px 0 #B13425,7px 2px 0 #B13425,8px 2px 0 #B13425,9px 2px 0 #B13425,10px 2px 0 #B13425,11px 2px 0 #B13425,12px 2px 0 #6B8CFF,3px 3px 0 #6A6B04,4px 3px 0 #6A6B04,5px 3px 0 #6A6B04,6px 3px 0 #E39D25,7px 3px 0 #E39D25,8px 3px 0 #6A6B04,9px 3px 0 #E39D25,12px 3px 0 #6B8CFF,2px 4px 0 #6A6B04,3px 4px 0 #E39D25,4px 4px 0 #6A6B04,5px 4px 0 #E39D25,6px 4px 0 #E39D25,7px 4px 0 #E39D25,8px 4px 0 #6A6B04,9px 4px 0 #E39D25,10px 4px 0 #E39D25,11px 4px 0 #E39D25,12px 4px 0 #6B8CFF,2px 5px 0 #6A6B04,3px 5px 0 #E39D25,4px 5px 0 #6A6B04,5px 5px 0 #6A6B04,6px 5px 0 #E39D25,7px 5px 0 #E39D25,8px 5px 0 #E39D25,9px 5px 0 #6A6B04,10px 5px 0 #E39D25,11px 5px 0 #E39D25,12px 5px 0 #E39D25,2px 6px 0 #6A6B04,3px 6px 0 #6A6B04,4px 6px 0 #E39D25,5px 6px 0 #E39D25,6px 6px 0 #E39D25,7px 6px 0 #E39D25,8px 6px 0 #6A6B04,9px 6px 0 #6A6B04,10px 6px 0 #6A6B04,11px 6px 0 #6A6B04,12px 6px 0 #6B8CFF,4px 7px 0 #E39D25,5px 7px 0 #E39D25,6px 7px 0 #E39D25,7px 7px 0 #E39D25,8px 7px 0 #E39D25,9px 7px 0 #E39D25,10px 7px 0 #E39D25,12px 7px 0 #6B8CFF,3px 8px 0 #6A6B04,4px 8px 0 #6A6B04,5px 8px 0 #B13425,6px 8px 0 #6A6B04,7px 8px 0 #6A6B04,8px 8px 0 #6A6B04,12px 8px 0 #6B8CFF,2px 9px 0 #6A6B04,3px 9px 0 #6A6B04,4px 9px 0 #6A6B04,5px 9px 0 #B13425,6px 9px 0 #6A6B04,7px 9px 0 #6A6B04,8px 9px 0 #B13425,9px 9px 0 #6A6B04,10px 9px 0 #6A6B04,11px 9px 0 #6A6B04,12px 9px 0 #6B8CFF,1px 10px 0 #6A6B04,2px 10px 0 #6A6B04,3px 10px 0 #6A6B04,4px 10px 0 #6A6B04,5px 10px 0 #B13425,6px 10px 0 #B13425,7px 10px 0 #B13425,8px 10px 0 #B13425,9px 10px 0 #6A6B04,10px 10px 0 #6A6B04,11px 10px 0 #6A6B04,12px 10px 0 #6A6B04,1px 11px 0 #E39D25,2px 11px 0 #E39D25,3px 11px 0 #6A6B04,4px 11px 0 #B13425,5px 11px 0 #E39D25,6px 11px 0 #B13425,7px 11px 0 #B13425,8px 11px 0 #E39D25,9px 11px 0 #B13425,10px 11px 0 #6A6B04,11px 11px 0 #E39D25,12px 11px 0 #E39D25,1px 12px 0 #E39D25,2px 12px 0 #E39D25,3px 12px 0 #E39D25,4px 12px 0 #B13425,5px 12px 0 #B13425,6px 12px 0 #B13425,7px 12px 0 #B13425,8px 12px 0 #B13425,9px 12px 0 #B13425,10px 12px 0 #E39D25,11px 12px 0 #E39D25,12px 12px 0 #E39D25,1px 13px 0 #E39D25,2px 13px 0 #E39D25,3px 13px 0 #B13425,4px 13px 0 #B13425,5px 13px 0 #B13425,6px 13px 0 #B13425,7px 13px 0 #B13425,8px 13px 0 #B13425,9px 13px 0 #B13425,10px 13px 0 #B13425,11px 13px 0 #E39D25,12px 13px 0 #E39D25,1px 14px 0 #6B8CFF,2px 14px 0 #6B8CFF,3px 14px 0 #B13425,4px 14px 0 #B13425,5px 14px 0 #B13425,6px 14px 0 #6B8CFF,7px 14px 0 #6B8CFF,8px 14px 0 #B13425,9px 14px 0 #B13425,10px 14px 0 #B13425,11px 14px 0 #6B8CFF,12px 14px 0 #6B8CFF,1px 15px 0 #6B8CFF,2px 15px 0 #6A6B04,3px 15px 0 #6A6B04,4px 15px 0 #6A6B04,5px 15px 0 #6B8CFF,6px 15px 0 #6B8CFF,7px 15px 0 #6B8CFF,8px 15px 0 #6B8CFF,9px 15px 0 #6A6B04,10px 15px 0 #6A6B04,11px 15px 0 #6A6B04,12px 15px 0 #6B8CFF,1px 16px 0 #6A6B04,2px 16px 0 #6A6B04,3px 16px 0 #6A6B04,4px 16px 0 #6A6B04,5px 16px 0 #6B8CFF,6px 16px 0 #6B8CFF,7px 16px 0 #6B8CFF,8px 16px 0 #6B8CFF,9px 16px 0 #6A6B04,10px 16px 0 #6A6B04,11px 16px 0 #6A6B04,12px 16px 0 #6A6B04,6px 6px 0 5px #6B8CFF" ``` [Answer] ## Javascript, ~~256 or 245~~ 252 or 241 **256** ``` document.write("k6n56kcraqlaqasasjaqbsasibtdlstlb2cmc2b2cid5dra2q3q2au7u55rj4j4kclcidld".replace(/./g,function(x){return new Array((x=parseInt(x,36))&7).join("<li style=padding:4%;float:left;background:#"+['B13425','6A6B04','6B8CFF','E39D25'][x>>3]+">")})) ``` It's sad to override 256, but **245** is possible if use nonprintable characters: ``` document.write(btoa(">§ç©­ª¥j¦¬jÈÚ©»²&ív[-½ÍÙÈåÚÚÚ­êÙ«»»køÉ\\Ù]").replace(/./g,function(x){return new Array((x=parseInt(x,36))&7).join("<li style=padding:4%;float:left;background:#"+["B13425","6A6B04","6B8CFF","E39D25"][x>>3]+">")})) ``` There is some problem with submitting solution with nonprintable characters. The argument of `btoa` have to be the result of `atob("ij6n56kcraqlaqasasjaqbsasibtdlstlb2cmc2b2cid5dra2q3q2au7u55rj4j4kclcidld")` with 1 symbol of length added for escaping backslash. Shorten both solutions by 4 symbols: we don't need new for array creation. **252** ``` document.write("k6n56kcraqlaqasasjaqbsasibtdlstlb2cmc2b2cid5dra2q3q2au7u55rj4j4kclcidld".replace(/./g,function(x){return Array((x=parseInt(x,36))&7).join("<li style=padding:4%;float:left;background:#"+['B13425','6A6B04','6B8CFF','E39D25'][x>>3]+">")})) ``` **241** ``` document.write(btoa("©ùêG+j©Z©«²6ªnƬ»]Ëeog&sför'yv¶¶«z¶jîîçãâ>$rVÚÙ]").replace(/./g,function(x){return Array((x=parseInt(x,36))&7).join("<li style=padding:4%;float:left;background:#"+['B13425','6A6B04','6B8CFF','E39D25'][x>>3]+">")})) ``` No escaping is needed in this version. The `btoa`'s argument is result of `atob("k6n56kcraqlaqasasjaqbsasibtdlstlb2cmc2b2cid5dra2q3q2au7u55rj4j4kclbaidld")` [Answer] # SmileBASIC, ~~147~~ 136 characters ``` P$="xxxxxxxx FOR I=0TO 191C=ASC("xxxxxxxxxxxxxxxxxxxxxxxx"[I/8])>>I MOD 8*2AND 3GPSET I/16,15AND I,ASC(P$[C*2])<<16OR ASC(P$[C*2+1])NEXT ``` Output (cropped): [![screenshot](https://i.stack.imgur.com/ZXp4R.png)](https://i.stack.imgur.com/ZXp4R.png) I replaced all the characters in the data strings with `x`'s, here are the character codes (in UCS-2): `P$` (Palette): `FF6B,8CFF,FFB1,3425,FF6A,6B04,FFE3,D925` Image data: `0000,83F8,0A80,A3FA,8BE4,A5EA,BEA5,A55A,7EE5,0575,BFF5,0156,BFF5,0156,BBA5,0575,3AF4,A55A,3BC4,A5EA,0BC4,A3FA,0300,83F8` The palette is stored in a string, each color (32 bits) is stored in two characters (16 bits each). The image data (2 bits per pixel) is stored in another string (8 pixels per character) Luckily, the challenge is scored in characters, since this file is significantly larger if saved in UTF-8. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 87 bytes (Non-competing) ``` •8,vkJíÝ1¢tt6,9XÂck$XSãõO©Ú"›qf®¸Ì#}„K0ÝCìxý}É~ð_áú•4BSvy•3«WKyÛòèz*Ðeb•16B6ôè'#ì})12ô» ``` [Try it online!](https://tio.run/nexus/05ab1e#AYIAff//4oCiOCx2a0rDrcOdMcKidHQ2LDlYw4JjayRYU8Ojw7VPwqnDmiLigLpxZsKuwrjDjCN94oCeSzDDnUPDrHjDvX3DiX7DsF/DocO64oCiNEJTdnnigKIzwqtXS3nDm8Oyw6h6KsOQZWLigKIxNkI2w7TDqCcjw6x9KTEyw7TCu/// "05AB1E – TIO Nexus") Outputs: ``` #B13425 #B13425 #B13425 #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #B13425 #B13425 #B13425 #B13425 #B13425 #B13425 #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6A6B04 #E39D25 #E39D25 #6A6B04 #E39D25 #B13425 #B13425 #B13425 #B13425 #6A6B04 #E39D25 #6A6B04 #E39D25 #E39D25 #E39D25 #6A6B04 #E39D25 #E39D25 #E39D25 #B13425 #B13425 #6A6B04 #E39D25 #6A6B04 #6A6B04 #E39D25 #E39D25 #E39D25 #6A6B04 #E39D25 #E39D25 #E39D25 #B13425 #6A6B04 #6A6B04 #E39D25 #E39D25 #E39D25 #E39D25 #6A6B04 #6A6B04 #6A6B04 #6A6B04 #B13425 #B13425 #B13425 #B13425 #E39D25 #E39D25 #E39D25 #E39D25 #E39D25 #E39D25 #E39D25 #B13425 #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6B8CFF #6A6B04 #6A6B04 #6A6B04 #B13425 #B13425 #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6A6B04 #6B8CFF #6A6B04 #6A6B04 #6B8CFF #6A6B04 #6A6B04 #6A6B04 #B13425 #6A6B04 #6A6B04 #6A6B04 #6A6B04 #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6A6B04 #6A6B04 #6A6B04 #6A6B04 #E39D25 #E39D25 #6A6B04 #6B8CFF #E39D25 #6B8CFF #6B8CFF #E39D25 #6B8CFF #6A6B04 #E39D25 #E39D25 #6A6B04 #6A6B04 #6A6B04 #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6A6B04 #6A6B04 #6A6B04 #6A6B04 #6A6B04 #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6B8CFF #6A6B04 #6A6B04 #B13425 #B13425 #6B8CFF #6B8CFF #6B8CFF #B13425 #B13425 #6B8CFF #6B8CFF #6B8CFF #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6A6B04 #B13425 #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6A6B04 #B13425 #6A6B04 #6A6B04 #6A6B04 #6A6B04 #B13425 #B13425 #B13425 #B13425 #6A6B04 #6A6B04 #6A6B04 #6A6B04 ``` Because 05AB1E can't do colors, or graphics of any kind... If this isn't acceptable I'll delete it. [Answer] # [Pxem](https://esolangs.org/wiki/Pxem), 113 bytes (filename). Here is filename (some characters as backslash with its code point in three-digit octal): ``` xHJG\071\070b\015\001\021\001\242\005\001l\215\400\344\236&kl\005\262\065&-\001\001\001\001\015\001\021\001\001\003\067\205\210i\014\352k\205\015B\005g.\326\030e\317z]&\012\015\206S\231\061\225\215\311K\256\005\264J\252\262\002\263\220\374\224\373>\007\253\007%\262q&j\271\226\245\001\001<.w\001.-.o.c.c.z.d.aX.a ``` Outputs as GIF. ## How it works Just as [@nietthedarkabsol's](https://codegolf.stackexchange.com/a/39926/100411), but had to add one to every byte, as the original GIF contains null chacters, which is illegal for filename. Then I just decrement each of them to output them. If I had an implementation whose `.w` breaks from the loop when stack is empty (nk. actually specified on the original page but no one has ever complied with it, including himself), then the final part could be golfed to: `.w.o.c.a`. [Answer] ## Perl, 266 260 257 249 245 bytes ``` $_="444111114444441111111114442223323444423233323334423223332333422333322224444333333344442212224444422212212224222211112222332131131233333111111333331111111133441114411144422244442224222244442222";s/\d/\033[4$&m /g;s/.{84}/$&\033[00m\n/g;print ``` Uses approach similar to user2485710's bash solution to write a VT100 style output. Strips the explicit N for newline by inserting a newline every 12 "vt100 pixels", 12 \* 7 = 84. [![enter image description here](https://i.stack.imgur.com/6CNOs.png)](https://i.stack.imgur.com/6CNOs.png) [Answer] # Sinclair BASIC - 573 bytes OK, so the Spectrum can't show RGB colours as specified, so have used the closest possible. ``` 10 let x=0:let y=0:let i=0 20 let a$="1c2e1f2i1c4c6b461d4646c46c1b464b6c46c14b6d4d1d6g1d4b24c1e4c24b24c14d2d4d6b4262b6246e2f6e2c1b2c6b1b2c1b2c1c4c1d4c14d1d4d" 30 let l=len a$ 40 let i=i+1:let c=1:let p=0:let k=val a$(i) 50 if a$(i+1)>="a" then let c=code a$(i+1)-96:let i=i+1 60 print at y,x;ink k;"\::":let p=p+1:let x=x+1:if x=12 then let x=0:let y=y+1 70 if p<c then goto 60 80 if i<l then goto 40 ``` The string is the colour (1=blue, 2=red etc) followed by a letter to represent how many times that block repeats (by taking the ASCII value minus 96 to become 1,2,3 etc). A number without a letter after it just draws one block. `"\::"` in line 60 is how to enter graphics in a text editor before turning into a TAP file to load into Fuse emulator. (Shows as a solid block graphic on screen). Each keyword is one byte in Sinclair BASIC, have included a count from a PEEK command after it was generated. ![It's-a Mario](https://i.stack.imgur.com/ljG8E.png) ]
[Question] [ You have two values each of which is either `0` representing "unknown", or one of `1,2,3`. Merge them into a single value as follows: * If both values are nonzero and equal, output that value: `(3,3) -> 3` * If both values are nonzero but unequal, output 0 for unknown: `(1,2) -> 0` * If one value is zero and the other is not, output the nonzero value: `(2,0) -> 2, (0,1) -> 1` * If both values are zero, output zero: `(0,0) -> 0` **Test cases:** There are 16 possible input pairs. ``` | 0 1 2 3 --+-------- 0 | 0 1 2 3 1 | 1 1 0 0 2 | 2 0 2 0 3 | 3 0 0 3 (0, 0) -> 0 (0, 1) -> 1 (0, 2) -> 2 (0, 3) -> 3 (1, 0) -> 1 (1, 1) -> 1 (1, 2) -> 0 (1, 3) -> 0 (2, 0) -> 2 (2, 1) -> 0 (2, 2) -> 2 (2, 3) -> 0 (3, 0) -> 3 (3, 1) -> 0 (3, 2) -> 0 (3, 3) -> 3 ``` ## Leaderboards ``` var QUESTION_ID=165314,OVERRIDE_USER=8478;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] # [Python 3](https://docs.python.org/3/), ~~27~~ 25 bytes ``` lambda x,y:(x|y)>>(x*y&2) ``` [Try it online!](https://tio.run/##K6gsycjPM/6fpmCrEPM/JzE3KSVRoUKn0kqjoqZS085Oo0KrUs1I839afpFChUJmnkJRYl56qoaJphUXJ0isEk2Ms6AoM69EI02jQkehUlNHITUvxVZdQV2TCyqh@R8A "Python 3 – Try It Online") [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes ``` gf|S ``` [Try it online!](https://tio.run/##y0rNyan8/z89rSb4v8nDHdsOLz@8L8H9PwA "Jelly – Try It Online") ### How it works ``` gf|S Main link. Left argument: x. Right argument: y. g Compute a, the gcd of x and y. | Compute b, the bitwise OR of x and y. f Filter; yield all common elements of [a] and [b]. S Take the sum. ``` [Answer] # [APL (Dyalog)](https://www.dyalog.com/), 5 bytes ``` ⌈×∧=⌊ ``` [Try it online!](https://tio.run/##AS0A0v9hcGwtZHlhbG9n//9m4oaQ4oyIw5fiiKc94oyK///iiJguZuKNqDAgMSAyIDM "APL (Dyalog) – Try It Online") Useful [reference](https://codegolf.stackexchange.com/a/151368/71256) `∧=⌊`: Returns `1` if the lowest common multiple is equal to the minimum. This is only true if one of the values is zero, or both are equal. Alternatively I could have `=*⌊` `⌈×`: The maximum multiplied by the above. [Answer] # [Shakespeare Programming Language](http://shakespearelang.sourceforge.net/report/shakespeare/), 296 bytes ``` Z.Ford,.Ajax,.Act I:.Scene I:.[Enter Ford and Ajax]Ajax:Listen to thy heart.Ford:Listen to thy heart.Am I as fat as you?Ajax:If so,let us Scene C.Am I as fat as zero?If so,let us Scene C.Ford:Am I as fat as zero?If not,you zero.open heart.let us Scene V.Scene C:.Ajax:open heart.Scene V:.[Exeunt] ``` [Try it online!](https://tio.run/##dZDPCoMwDMbve4o8gJTBbr2IyAbCbgMPGx6KRtxwjbQp6F6@s9XDNtwlf8iP70tih977qziRaRKRPdQ4x5qhkOJSo8ZQ3I6a0UBAQOkGAlWFIM93y6iBCbiboENlOCptDrInFKAstIpDmsilUaRowVLSI4OzsJjmv/ALDaWbYLT7Q2viZLaJvaBhXmjZ5EuiXA/NZTxffnArED4wotNceX/Y7d8) First participation to a code-golf challenge, so let's start with one of my favorite joke languages ! Explanation : Declaration of the two variables Ford and Ajax (shortest variable names available) ``` Z.Ford,.Ajax,. ``` First Scene : Put the two values into the variable, then test them for equality, then test Ajax against 0. If the value that we have to return is stored in the variable Ford, go to Scene C. ``` Act I:. Scene I:. [Enter Ford and Ajax] Ajax: Listen to thy heart. Ford:Listen to thy heart. Am I as fat as you? Ajax: If so,let us Scene C. Am I as fat as zero? If so,let us Scene C. ``` If Ford is 0, print Ajax, else set Ajax as 0 then print Ajax. Then go to the end of the program. ``` Ford:Am I as fat as zero? If not,you zero. open heart. let us Scene V. ``` Scene C : Print Ford ``` Scene C:. Ajax:open heart. ``` Scene V: End of the program. ``` Scene V:. [Exeunt] ``` [Answer] # [Ruby](https://www.ruby-lang.org/), 21 bytes ``` ->a,b{(a|b)*531[a*b]} ``` [Try it online!](https://tio.run/##KypNqvyfZvtf1y5RJ6laI7EmSVPL1NgwOlErKbb2f0FpSbGChoGenrGmXm5iQXVNYg0yL6kmLRqoLbZWS11BvfY/AA "Ruby – Try It Online") Because Ruby # Short explanation: * `a|b` is bitwse OR, so it gives us the right number if a==b or one of them is zero. * Magic number `531` is 2^9+2^4+2^1+2^0, and the [] operator extracts a single bit. This means: multiply by 1 if a\*b is 0, 1, 2, 4 or 9, multiply by 0 otherwise. * This won't work for values > 3 [Answer] # [Haskell](https://www.haskell.org/), 25 bytes ``` x!y=0^((x-y)^2*x)*y+0^y*x ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/v0Kx0tYgTkOjQrdSM85Iq0JTq1LbIK5Sq@J/bmJmnoKtQko@l4JCbmKBb7xCQVFmXolCdDRQj0KNQoWCja5CtIGennFsLJBbicT9DwA "Haskell – Try It Online") [Answer] # [Pyth](https://github.com/isaacg1/pyth), ~~8~~ 7 bytes ``` @{+0SQ3 ``` [Try it online!](https://pyth.herokuapp.com/?code=%40%7B%2B0SQ3&test_suite=1&test_suite_input=%5B3%2C3%5D%0A%5B1%2C2%5D%0A%5B1%2C0%5D%0A%5B0%2C1%5D%0A%5B0%2C0%5D&debug=0) ``` @{+0SQ3 Implicit: Q=input() SQ Sort input +0 Prepend 0 { Deduplicate @ 3 Get 4th element (index 3), modular indexing ``` **Case 1 - Both values nonzero and equal** ``` Sorted Input [3,3] Prepend 0 [0,3,3] Deduplicate [0,3] - index 3 yields 3 ``` **Case 2 - Both values nonzero and unequal** ``` Sorted Input [1,2] Prepend 0 [0,1,2] Deduplicate [0,1,2] - index 3 yields 0 ``` **Case 3 - Exactly one value zero** ``` Sorted Input [0,1] Prepend 0 [0,0,1] Deduplicate [0,1] - index 3 yields 1 ``` **Case 4 - Both values zero** ``` Sorted Input [0,0] Prepend 0 [0,0,0] Deduplicate [0] - index 3 yields 0 ``` --- *Alternate solution, also 7 bytes* ``` *eSQ}s{ ``` [Try it online](https://pyth.herokuapp.com/?code=%2AeSQ%7Ds%7B&test_suite=1&test_suite_input=%5B3%2C3%5D%0A%5B1%2C2%5D%0A%5B1%2C0%5D%0A%5B0%2C1%5D%0A%5B0%2C0%5D&debug=0) ``` *eSQ}s{QQ Trailing Q's inferred {Q Deduplicate input s Take the sum } Q Is this in the input? True treated as 1, false as 0 * Multiplied by eSQ Max from input (end of sorted input) ``` --- *Previous version, 8 bytes* ``` @+0{-QZ3 ``` [Answer] # Java 8, 20 bytes Curried lambda. [Stolen from here](https://codegolf.stackexchange.com/a/165326). ``` a->b->(a|b)>>(a*b&2) ``` [Answer] # [JavaScript (Node.js)](https://nodejs.org), 17 bytes, port somehow from Python answer ``` a=>b=>a*b&2?0:a|b ``` [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/e9m@z/R1i7J1i5RK0nNyN7AKrEm6X9yfl5xfk6qXk5@uka0np6eY1FRYqWGiWasXm5igYZGvE6mpq0dVoksoISbRqamRpYmEPwHAA "JavaScript (Node.js) – Try It Online") # [JavaScript (Node.js)](https://nodejs.org), 21 bytes ``` a=>b=>a-b?a*b?0:a+b:a ``` [Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/e9m@z/R1i7J1i5RN8k@USvJ3sAqUTvJKvF/cn5ecX5Oql5OfrqGm4aBpoaxpuZ/AA "JavaScript (Node.js) – Try It Online") [Answer] # [Stax](https://github.com/tomtheisen/stax), 8 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` Ç∞∟∙◄╥*♣ ``` [Run and debug it](https://staxlang.xyz/#p=80ec1cf911d22a05&i=[0,+0]%0A[0,+1]%0A[0,+2]%0A[0,+3]%0A[1,+0]%0A[1,+1]%0A[1,+2]%0A[1,+3]%0A[2,+0]%0A[2,+1]%0A[2,+2]%0A[2,+3]%0A[3,+0]%0A[3,+1]%0A[3,+2]%0A[3,+3]&a=1&m=2) Unpacked, ungolfed, and commented, it looks like this. ``` e.g. [2, 0] c:s [2, 0] 2 calculate the "span" of the input array (max(a) - min(a)) + [2, 0, 2] append the span to the input array o [0, 2, 2] sort the 3-element array E 0 2 2 explode the 3 elements into 3 separate stack entries a 2 2 0 rotate the third stack element to the top of stack ! 2 2 1 logical not, produces 1 iff the top value was 0 * 2 2 multiply implicitly print top of stack ``` [Run this one](https://staxlang.xyz/#c=+++%09e.g.+++++%09[2,+0]%0Ac%3As%09[2,+0]+2+%09calculate+the+%22span%22+of+the+input+array+%28max%28a%29+-+min%28a%29%29%0A%2B++%09[2,+0,+2]%09append+the+span+to+the+input+array%0Ao++%09[0,+2,+2]%09sort+the+3-element+array%0AE++%090+2+2++++%09explode+the+3+elements+into+3+separate+stack+entries%0Aa++%092+2+0++++%09rotate+the+third+stack+element+to+the+stop%0A%21++%092+2+1++++%09logical+not,+produces+1+iff+the+top+value+was+0%0A*++%092+2++++++%09multiply%0A+++%09+++++++++%09implicitly+print+top+of+stack&i=[0,+0]%0A[0,+1]%0A[0,+2]%0A[0,+3]%0A[1,+0]%0A[1,+1]%0A[1,+2]%0A[1,+3]%0A[2,+0]%0A[2,+1]%0A[2,+2]%0A[2,+3]%0A[3,+0]%0A[3,+1]%0A[3,+2]%0A[3,+3]&a=1&m=2) [Answer] # [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), 32 bytes ``` {(({}[({})]<>)){{}<>}(<>)}{}({}) ``` [Try it online!](https://tio.run/##SypKzMzTTctJzP7/v1pDo7o2Gog1Y23sNDWrq2tt7Go1gMza6lqQ6P//RgrGAA "Brain-Flak – Try It Online") [Answer] (first submission so please don't kick too hard) # [Python 2](https://docs.python.org/2/), 57 44 43 bytes ``` lambda a,b:(0 if a*b else a+b)if a-b else a ``` [Try it online!](https://tio.run/##XctBCsIwEEbhfU7xg5tGI0xmdkJu4maCCRZqLTYbTx9TwVBcfg/e8i7358w1B1zrpI94U6iLl4EwZugxIk1rgp6i3Xz@uRpzQElrMctrnAvyIE5sCNLtHTdTNztq5m5yvtnvfmwBtC9s8Z/km6R@AA "Python 2 – Try It Online") (compressed a bit after looking at [first python](https://codegolf.stackexchange.com/a/165326/80759) answer) [Answer] # C (gcc), 25 bytes `f(a,b){a=a^b&&a*b?0:a|b;}` pseudo-code: ``` foo(A,B) if A XOR B and A*B are > 0 return 0 else return A OR B` ``` [Answer] # C (gcc), 26 bytes ``` f(a,b){a=a*b?a-b?0:a:a+b;} ``` [Try it online!](https://tio.run/##fZBBDoIwEEX3nGKiMQFpDSorEDkIsGhBtESLUXQDPTsOiIqKTpqZRX/emzam2ziu61RnhBsl89iU@4xy33KYw0zuqnosZLy/JBtYnYtE5LPdWhOygAMTUr/mIjGg1KCr5oIFdgQelBaBOYEFgaVy3wL8X@B4wkiqjwAqmCTPE0pKTdpVKEcENVbU9HnbF21fRsaLlOYn0BufQJnl4liB7YJpiv7Gn160VYB4Hog@7Aua3aHZA5oNQQfgiMa/DrKoUww41M/l8OG9vNJUfQM "C (gcc) – Try It Online") Expanation / Ungolfed: ``` int f(int a, int b) { // implicit-int (C89) // return replaced with assignment: [link](https://codegolf.stackexchange.com/a/106067/44694) return a*b ? // if a and b are both not zero, then a-b ? // if a != b 0 : // a != b, so return 0 a // a == b, so return a : a+b // one of a,b is zero, so return whichever is nonzero ; } ``` [Answer] # [MATL](https://github.com/lmendo/MATL), 9 bytes ``` dGp*~GX>* ``` [Try it online!](https://tio.run/##y00syfn/P8W9QKvOPcJO6///aAMdo1gA "MATL – Try It Online") ### Explanation: ``` % Implicit input as a vector with two elements implicitly. Stack: [0,2] d % The difference between the two elements. Stack: [2] G % Push input again. Stack: [2], [0,2] p % The product of the last element (the input). Stack: [2], [0] * % Multiply the two elements on the stack. Stack: [0] ~ % Negate. Stack: [1] G % Push input again. Stack: [1], [0,2] X> % Maximum value. Stack: [1], [2] * % Multiply the two elements on the stack. Stack: [2] % Implicit output ``` [Answer] # GNU sed, 23 bytes ``` s/^0?(.)\1?0?$/\1/ t c0 ``` (must be run with `-r` flag) [Try it online!](https://tio.run/##BcGxDcJAEETR/NdBgANzM7sFXCMWCSBEYls@0z7Le@P1nN/rt/Ya7a5@vU2Lu/qlLW6cPFQlIaNAiYWNAychwkQQSYo0GWT@tv38bOuo@fgD "sed – Try It Online") [Answer] # QBasic, 34 bytes Different approach! ``` INPUT a,b ?(a OR b)*-(a*b=0OR a=b) ``` Observe that the nonzero values in the output grid are all the bitwise `OR` of the two input numbers. This is just `a OR b` in QBasic. We want to output this value when `a*b=0 OR a=b`, and `0` otherwise, which we can do by multiplying by the negative of the aforementioned conditional (negative, since truthy is `-1` in QBasic). [Answer] # brainfuck, 25 bytes ``` ,>,[>]<<[[->->+<<]>[>]]>. ``` Input is two byte values (not ascii) [Answer] # [Swift](https://swift.org/), 118 bytes ``` func c(n1:Int,n2:Int){n1==n2 ? print("\(n1)") : (n1*n2 != 0 ? print("0") : (n1==0 ? print("\(n2)") : print("\(n1)")))} ``` [Answer] ## Batch, ~~38~~ ~~36~~ ~~35~~ 30 bytes ``` @cmd/cset/a"(%1|%2)>>(%1*%2&2) ``` Port of @Dennis's Python answer, as conditionals are too expensive in Batch. [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 10 bytes ``` =h|∋0&⌉|∧0 ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/3zaj5lFHt4Hao55OIGO5wf//0cY6RrH/owA "Brachylog – Try It Online") [Answer] # [J](http://jsoftware.com/), 8 7 bytes 1 byte saved by H.PWiz. ``` >.*=^<. ``` [Try it online!](https://tio.run/##y/qfVmyrp2CgYKVg8N9OT8s2zkbvvyaXkp6CepqtnrqCjkKtlUJaMRdXanJGPlBZGhBD2EZIbEMg2xjCNEYw0/TV9Oyqresy9Uy4/gMA "J – Try It Online") A J port of H.PWiz's APL solution `=` are the numbers equal? (results in 1 or 0) `^` to the power of `<.` the smaller number `*` multiplied by `>.` the larger number [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~9~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` àIËIP_+* ``` -1 byte thanks to *@MagicOctopusUrn*. [Try it online](https://tio.run/##MzBNTDJM/f//8ALPw92eAfHaWv//RxvpGMcCAA) or [verify all test cases](https://tio.run/##HcghDoAwDEDR@wBibcM98MtCIOE0XAKLmUPhOs@VyvLNEy/N2y5HfI/f0S6v7fS6rOMQxd/IOU2pTF1BResKL7zwwiuvvPLKG2@88da//A). **Explanation:** ``` à # Take the maximum of the input-list # [0,2] → 2 IË # Are all elements in the input-list equal? # [0,2] → 0 IP_ # Take the product of the input-list, and verify if it equals 0 # (`_` transforms 0 into 1; everything else into 0) # [0,2] → 0 (product) → 1 (==0) + # Add them together (since only 1 is truthy in 05AB1E, this is basically an OR) # 0+1 → 1 * # Multiply both values on the stack # 2*1 → 2 ``` **Generalized explanation:** ``` IËIP_+ # If both values are equal, or one of them is a zero: à # Output the maximum of the two values # Else: # Output 0 ``` [Answer] # Javascript, 35 bytes ``` f=(m,n)=>(m||n)&&(m!=n)?(m>n?m:n):0 ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 6 bytes ``` ê0ýÙ7è ``` [Try it online!](https://tio.run/##ASoA1f8wNWFiMWX/M8Odw6N2eXl5/8OqMMO9w5k3w6j/eSLDvyAtPiDDvyIsXP8 "05AB1E – Try It Online") Port(ish) of [my Pyth answer](https://codegolf.stackexchange.com/a/165434/41020). *TIO header/footer taken from [Emigna's answer](https://codegolf.stackexchange.com/a/165358/41020)* [Answer] # Javascript ES6, 25 22 21 20 bytes ``` a=>b=>a?b-a?!b*a:a:b ``` **14 13 bytes**, If the arguments are provided in sorted order ``` a=>b=>a%b?0:b ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~34~~ 28 bytes ``` lambda i,j:(i|j,0)[0<i!=j>0] ``` [Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUSFTJ8tKI7MmS8dAM9rAJlPRNsvOIPZ/Wn6RQoVCZp5CUWJeeqqGiaaCFZcCEIDEK7GIg0BBUWZeiUJCRYKCtoKSjhKQTKgEsxVs7RTA3DSNCp1KzYT/AA "Python 2 – Try It Online") -6 with thanks to @Dennis [Answer] # QBasic, ~~38~~ ~~36~~ 35 bytes ``` INPUT a,b ?(a*b>0)*(b-a*(a<>b))+a+b ``` Partly inspired by [Erik's `IF ... THEN ... ELSE` answer](https://codegolf.stackexchange.com/a/167073/16766), here's a math-only solution. ### How I got here *Important note for understanding math-with-conditionals: in QBasic, the results of comparison operators are `0` and `-1`, not `0` and `1`.* We start with Erik's code: ``` IF a*b THEN?a*-(a=b)ELSE?a+b ``` In other words, if `a` and `b` are both nonzero, then print `a*-(a=b)` (`a` if `a=b`, otherwise `0`); else (at least one of `a` and `b` is zero), output `a+b` (the nonzero number, or `0` if they're both zero). There's already some math with conditionals going on here. Let's take it a step farther and see if we can eliminate the `IF` statement entirely. We'll have to use `a*b>0` for the outer condition: `a*b` can have multiple different truthy values, which is fine for `IF` but causes problems for math. ``` c=a*b>0 ?c*a*(a=b)+(c+1)*(a+b) ``` This is the [standard trick](https://codegolf.stackexchange.com/a/166130/16766) of `IF`-elimination. When `c` is true, `c*a*(a=b)` is `-a*(a=b)` and `(c+1)*(a+b)` is `0`; when `c` is false, `c*a*(a=b)` is `0` and `(c+1)*(a+b)` is `a+b`. So this expression gives the same results as the `IF ... THEN ... ELSE`. The only problem is, it makes our program 40 bytes instead of 38. Maybe we can shorten it by rearranging the math. ``` c=a*b>0 ?c*a*(a=b)+c*(a+b)+a+b ``` Still 40 bytes... ``` c=a*b>0 ?c*(a+b+a*(a=b))+a+b ``` Now our program is back to 38 bytes. But since we're only using `c` once, we don't have to assign it to a variable anymore: ``` ?(a*b>0)*(a+b+a*(a=b))+a+b ``` Now we're down to 36 bytes. *But wait there's more...* That `a+b+a*(a=b)` expression looks a bit redundant. `a*(a=b)` is `-a` if `a=b` and `0` otherwise. When we add it to `a`, we get `0` if `a=b` and `a` otherwise. Maybe we can achieve the same thing in fewer bytes by reversing the condition. ``` b+a*-(a<>b) ``` At first, this doesn't look shorter. But we can save a byte by subtracting instead of adding a negative: ``` b-a*(a<>b) ``` And there we have our 35-byte solution. [Answer] # [Shakespeare Programming Language](https://github.com/TryItOnline/spl), 187 bytes ``` ,.Ajax,.Puck,.Act I:.Scene I:.[Enter Ajax and Puck]Ajax:Listen tothy!Puck:Listen tothy!Be you nicer zero?If notyou be I.Am I worse a cat?If notam I as big as you?If notyou zero.Open heart ``` [Try it online!](https://tio.run/##VY0/CwIxDMX3@xRxP4rgdouc4FAQFBzFIVejV/@kR5tDzy9fG3DQKS@/vPeShnvOtWmv@KrNbnS3op2AbczeEZOKw5qFIqgFkE@grqNuzcYnIQYJ0k8zxf9kRdUURmDvSvxNMSztGTiIwq5Um/YBFp4hJgIEh/K9o2JM0PmLjmL/CWqP2Q7lSU8YJed5tfgA "Shakespeare Programming Language – Try It Online") [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 15 bytes ``` ?0⁼?0⁼∨??⁼∨??∴* ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCI/MOKBvD8w4oG84oioPz/igbziiKg/P+KItCoiLCIiLCIxXG4yIl0=) Surprisingly no Vyxal answer yet. Return the max, multiplied by the boolean value indicating whether the values are equal or one of them is zero. --- # [Vyxal](https://github.com/Vyxal/Vyxal), 6 bytes ``` s0pU3i ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCJgKDAsIDApIC0+IDBcbigwLCAxKSAtPiAxXG4oMCwgMikgLT4gMlxuKDAsIDMpIC0+IDNcbigxLCAwKSAtPiAxXG4oMSwgMSkgLT4gMVxuKDEsIDIpIC0+IDBcbigxLCAzKSAtPiAwXG4oMiwgMCkgLT4gMlxuKDIsIDEpIC0+IDBcbigyLCAyKSAtPiAyXG4oMiwgMykgLT4gMFxuKDMsIDApIC0+IDNcbigzLCAxKSAtPiAwXG4oMywgMikgLT4gMFxuKDMsIDMpIC0+IDNgXG5cbmBcXG5gLyBgIC1gLyB2aEUgXG7GmyIsInMwcFUzaSIsIm5TJFwiYCUgLT4gJWAkJTtgXFxuYGoiLCIiXQ==) Thanks @lyxal for this version which ports the Pyth answer. ]
[Question] [ [Sound synthesizers](https://en.wikipedia.org/wiki/Synthesizer) use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, as represented in the following figure from [Wikipedia](https://en.wikipedia.org/wiki/Synthesizer#Attack_Decay_Sustain_Release_.28ADSR.29_envelope): * **Attack time (A)**: time taken for the envelope to reach its maximum level, starting from zero, when the key is first pressed. * **Decay time (D)**: time taken for the envelope to reach the specified sustain level. * **Sustain level (S)**: level which is maintained, after the initial attack and decay, for as long as the key is being pressed. * **Release time (R)**: time taken for the envelope to reach zero when the key is released. [![enter image description here](https://i.stack.imgur.com/lazZO.png)](https://i.stack.imgur.com/lazZO.png) # The challenge Input the four parameters A, D, S, R and **plot the envelope**. Parameters will be **integer values from 0 to 127**. The **maximum level** (reached at the end of the attack phase) will be assumed to be **127**. The **horizontal segment at the sustain level** will be assumed to have **duration 64** (in the actual sound this duration is not fixed, but is determined by the amount of time that the key is held). # Format and further details The output should be an image in raster or vector format. If it's raster, the polygonal line should occupy at least 50 pixels vertically an horizontally. The image can be either displayed or produced as a file in a standard image format. The file can be written to disk, or its exact contents can be output, either to STDERR or as function return argument. The graph need only contain the polygonal line that defines the envelope. The scale of each axis can be freely chosen. Other elements such as axis lines, numeric labels or line colors are optional. Input means and format are [flexible](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) as usual. For example, you can take the four numbers in any order, or an array containing them. [A program or a function](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet) can be provided. [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden. Shortest code in bytes wins. # Test cases Input is in the format `[A D S R]`. Note that the scale is different in each figure (in accordance with the rule that scale can be freely chosen) ``` [15 30 70 40] ``` [![enter image description here](https://i.stack.imgur.com/9dSO4.png)](https://i.stack.imgur.com/9dSO4.png) ``` [64 64 64 64] ``` [![enter image description here](https://i.stack.imgur.com/s5012.png)](https://i.stack.imgur.com/s5012.png) ``` [0 10 50 80] ``` [![enter image description here](https://i.stack.imgur.com/9e6jE.png)](https://i.stack.imgur.com/9e6jE.png) ``` [0 0 90 80] ``` [![enter image description here](https://i.stack.imgur.com/kOo4E.png)](https://i.stack.imgur.com/kOo4E.png) ``` [5 50 0 0] ``` [![enter image description here](https://i.stack.imgur.com/u8fnH.png)](https://i.stack.imgur.com/u8fnH.png) ``` [5 50 0 80] ``` [![enter image description here](https://i.stack.imgur.com/C5SW5.png)](https://i.stack.imgur.com/C5SW5.png) ``` [24 32 127 48] ``` [![enter image description here](https://i.stack.imgur.com/vY3Sp.png)](https://i.stack.imgur.com/vY3Sp.png) [Answer] # TikZ, ~~195~~ ~~193~~ ~~181~~ ~~177~~ ~~172~~ ~~167~~ ~~163~~ ~~160~~ 159 bytes *Thanks to David Carlisle for his helpful answer [here](https://tex.stackexchange.com/a/372621/124071)* ``` \documentclass[tikz]{standalone}\begin{document}\tikz\def~#1{\typein[#1];}~\a~\s~\d~\r\def\u{)--(\a+\d}\draw(,)--(\a,127\u,\s\u+64,\s\u+\r+64,);\end{document} ``` Yes, you heard right ***TikZ***. ## Explanation This uses a couple of techniques to achieve its goal. The first thing is input. Most people might not know that LATEX can take input. Well it can. This is achieved with the command `\typein`. This will halt the compiler and request input from the user as assign it to a variable. The other main technique is the use of `\def`. `\def` in Tikz is absurdly powerful. It essentially defines a piece of code and pastes it everywhere you call the variable. In this code we define two things `\typein[#1]{}` so that we can assign our variables golfily and `)--(\a+\d` because this code shows up a bunch of times in the ungolfed version. Here are two versions of the code (without the wrapper): ### Golfed: ``` \documentclass[tikz]{standalone}\begin{document}\tikz\def~#1{\typein[#1];}~\a~\s~\d~\r\def\u{)--(\a+\d}\draw(,)--(\a,127\u,\s\u+64,\s\u+\r+64,);\end{document} ``` ### Ungolfed: ``` \typein[\a]{}\typein[\s]{}\typein[\d]{}\typein[\r]{}\draw(0,0)--(\a,127)--(\a+\d,)--(\a+\d+64,)--(\a+\d+\r+64,0); ``` ## Image: Since I cannot upload a pdf image directly, and converting it to any other format seems to cause the line to disappear altogether, here is what an image might look like when opened in Preview (input for this image is `[64 64 64 64]`): [![Preview image](https://i.stack.imgur.com/yfCMN.png)](https://i.stack.imgur.com/yfCMN.png) As you can see it is very thin. However because it is a PDF image and not a raster image does not have to comply with thickness requirements. [Answer] # Python 2, ~~83~~ ~~80~~ 79 bytes ``` from turtle import* def f(A,D,S,R):X=A+D+64;map(goto,[A,A+D,X,X+R],[127,S,S,0]) ``` [**Try it online**](https://trinket.io/python/874e164de0) (83-byte version, because it runs online) Note that certain outputs may not be completely visible using Trinket, because of the way the canvas works. You'll need to download and install Python if you want it to work better. ### Ungolfed: ``` from turtle import* A,D,S,R=input() goto(A,127) goto(A+D,S) goto(A+D+64,S) goto(A+D+64+R,0) ``` This version doesn't work in Trinket, because Trinket doesn't support value unpacking of input. [Answer] ## Mathematica, ~~61~~ 58 bytes ``` ListLinePlot[{Accumulate@{0,##3,64,#2},{0,127,#,#,0}}Ôèá]& ``` `Ôèá` is the operator for `Transpose` and is rendered as a superscript `T` by Mathematica. Takes the arguments in the order `S, R, A, D` and returns a vector graphics object. Results for all seven test cases: [![enter image description here](https://i.stack.imgur.com/2uVkO.png)](https://i.stack.imgur.com/2uVkO.png) Click for larger version. [Answer] ## R, ~~66~~ 63 bytes ``` function(A,D,S,R)plot(cumsum(c(0,A,D,64,R)),c(0,127,S,S,0),"l") ``` Displays the image, with axis labs being `cumsum(c(0,A,D,64,R))` and `c(0,127,S,S,0)`, as well axis lines and numeric labels. Thanks to @Zahiro Mor for shaving off *3 bytes* ! **Previous answer :** ``` function(A,D,S,R)plot(c(0,A,A+D,b<-A+D+64,b+R),c(0,127,S,S,0),"l") ``` [Answer] # Matlab, 50 bytes ``` @(A,D,S,R)plot(cumsum([0,A,D,64,R]),[0,127,S,S,0]) ``` This yields an anonymous function "ans" that has to be called as ans(A,D,S,R). [Answer] ## JavaScript (ES6) + HTML, 126 + 23 = 149 ``` c=O.getContext`2d`;c.moveTo(a=0,z=O.height=128);g=(y,x=prompt())=>c.lineTo(a+=+x,y)||g;g(0)(s=z+~prompt())(s,64)(z);c.stroke() ``` ``` <canvas id=O width=512> ``` Takes input one at a time in the order `A, S, D, R`. [Answer] ## JavaScript (ES6), ~~114~~ 111 bytes ``` f=(a,d,s,r)=>`<svg width=446 height=128><path stroke=red fill=none d=M0,127L${a},0l${d},${127-s}h64l${r},${s}>` ``` ``` <div oninput=o.innerHTML=f(a.value,d.value,s.value,r.value)><input type=number value=0 min=0 max=127 id=a><input type=number value=63 min=0 max=127 id=d><input type=number value=127 min=0 max=127 id=s><input type=number value=0 min=0 max=127 id=r><div id=o><svg width=446 height=128><path stroke=red fill=none d=M0,127L0,0l63,0h64l0,127 /></svg> ``` Returns an SVG image suitable for `innerHTML`. Add 18 bytes for valid XML. [Answer] ## Haskell, ~~112~~ 110 bytes ``` import Graphics.Gloss (a#d)s r=display(InWindow""(600,300)(0,0))red$line$zip(scanl(+)0[a,d,64,r])[0,127,s,s,0] ``` Usage example: `(0#10) 50 80`. ![adsr envelope](https://i.stack.imgur.com/SRogC.png) This uses the `Gloss` library. The `display` function expects a window to plot in (here: a window without title (`""`), size 600x300, position `(0,0)` on desktop), a background color (`red`) and picture witch is a line along the path made by zipping the cumulative sum of `[0,a,d,64,r]` = `[0,a,a+d,a+d+64,a+d+64+r]` as the x coordinates and `[0,127,s,s,0]` as the y coordinates. Edit: Thanks @xnor for 2 bytes! [Answer] # MATL, ~~31~~ 22 bytes ``` Oii64ivYsO127itO5$h&XG ``` Accepts four separate inputs ordered as `A`, `D`, `R`, `S` Try it out at [**MATL Online**](https://matl.io/?code=Oii64ivYsO127itO5%24h%26XG&inputs=15%0A30%0A40%0A70&version=19.7.4) **Explanation** ``` 0 % Push a literal 0 to the stack ii % Grab the first two inputs 64 % Push the number literal 64 to the stack i % Grab the third input v % Vertically concatenate all values Ys % Compute the cumulative sum 0 % Push the number literal 0 to the stack 127 % Push the number literal 127 to the stack i % Grab the fourth input t % Duplicate the fourth input O % Push the number literal 0 to the stack 5$h % Concatenate the last 5 elements on the stack &XG % Plot the result using the first array as x and second array as y ``` [![enter image description here](https://i.stack.imgur.com/IhOl1.png)](https://i.stack.imgur.com/IhOl1.png) [Answer] # Processing, ~~134~~ 108 + 14(call to `size`) = ~~148~~ 122 bytes First we need a call to `size` somewhere in the program so that the output will fit in the window (default at 100x100). ``` size(400,400); ``` And here's the actual function: ``` void g(int a,int b,int c,int d){line(0,127,a,0);line(a,0,b+=a,c=127-c);line(b,c,b+=64,c);line(b,c,b+d,127);} ``` Call it like `f(15,20,70,40);` ### Screenshot ``` 15, 20, 70, 40 ``` [![image](https://i.stack.imgur.com/pBwtR.png)](https://i.stack.imgur.com/pBwtR.png) --- My newer answer is more straightforward than the older answer, but I like the older one more (even if it is bigger). ### Old answer (148 bytes) ``` size(400,400); ``` and the two functions ``` void f(int[]v){translate(0,127);l(v[0],-127);l(v[1],127-v[2]);l(64,0);l(v[3],v[2]);}void l(int x,int y){line(0,0,x,y);translate(x,y);} ``` Call it like `f(int_array_containing_values);` and the result will look something like: `f(new int[]{15,20,70,40});` [Answer] # SmileBASIC, 90 bytes ``` INPUT A,D,S,R B=A+D+64W=#Y-S GLINE.,#Y,A,0GLINE A,0,A+D,W GLINE A+D,W,B,W GLINE B,W,B+R,#Y ``` [Answer] # PHP, ~~149~~ 130 bytes ``` [,$a,$d,$s,$r]=$argv;imagepolygon($i=imagecreatetruecolor(446,127),[0,127,$a,0,$d+=$a,$s,$d+=64,$s,$d+$r,127],5,999);imagepng($i); ``` takes input from command line arguments, writes image (PNG with graph blue on black) to stdout. Requires PHP 7.1 or later. usage e.g. ``` # any OS with ImageMagick: php -r '<code>' <parameters> | display # linux with feh: php -r '<code>' <parameters> | feh ``` +4 bytes for older PHP: Replace `[,$a,$d,$s,$r]` with `list(,$a,$d,$s,$r)`. --- There is a small hack in there: instead of using `imageopenpolygon` to hide the base line, the finishing polygon line is drawn outside the canvas. (y=127 would only display on an image with height >= 128.) I could have saved more with color 99 or 9 instead of 999; but those are pretty hard to see on black. :) [Answer] ## Bash + [grace](https://en.wikipedia.org/wiki/Grace_(plotting_tool)), 70 bytes ``` t=$[$1+$2] echo "0 0 $1 127 $t $3 $[t+64] $3 $[t+64+$4] 0">f xmgrace f ``` The script writes to file `f` the coordinates of each point, and xmgrace (the GUI version) reads the file and displays the plot using lines by default. **Run**: ``` ./plot_ADSR.sh 15 30 70 40 ``` **Output:** (print screen) [![15 30 70 40](https://i.stack.imgur.com/O6X3f.png)](https://i.stack.imgur.com/O6X3f.png) I think this can be done directly by a grace script, if it can accept input, but I'm not familiar with its syntax. I'll look into it. **Explanation:** ``` t=$[$1+$2] # store the value of (A+D) for later usage echo "0 0 # start writing the coordinates to file "f", first the origin $1 127 # then (A, 127) $t $3 # then (A + D, S) $[t+64] $3 # then (A + D + 64, S) $[t+64+$4] 0">f # then (A + D + 64 + R, 0) xmgrace f # call xmgrace to plot the generated XY file ``` [Answer] ## Go, ~~947~~ ~~915~~ 506 bytes *This is far from optimized, trying to learn the language while participating in these questions. Feel free to point out what I can do.* [![fixed image](https://i.stack.imgur.com/rX1ki.png)](https://i.stack.imgur.com/rX1ki.png) **Condensed:** ``` package main;import (."os";."image";k"image/png";c"image/color";."strconv";."math");func main(){g:=NewRGBA(Rect(0,0,127*4,127));a,_:=ParseFloat(Args[1],4);d,_:=ParseFloat(Args[2],4);s,_:=ParseFloat(Args[3],4);r,_:=ParseFloat(Args[4],4);z:=[5][]float64{{0,0},{a,127},{a+d,s},{a+d+64,s},{a+d+64+r,0}};for i:=1;i<len(z);i++{v,w,x,y:=z[i-1][0],z[i-1][1],z[i][0],z[i][1];m:=(y-w)/(x-v);t:=y-m*x;for v<=x{g.Set(int(Ceil(v)),127-int(Ceil(w)),c.RGBA{0,0,0,255});v+=.01;w=m*v+t}};f,_:=Create("o.png");k.Encode(f,g)} ``` **Uncondenced:** ``` package main import ( ."os" ."image" k"image/png" c"image/color" ."strconv" ."math" "fmt" ) func main(){ g := NewRGBA(Rect(0, 0, 127*4, 127)) a, _ := ParseFloat(Args[1], 4) d, _ := ParseFloat(Args[2], 4) s, _ := ParseFloat(Args[3], 4) r, _ := ParseFloat(Args[4], 4) z := [5][]float64{{0,0},{a,127},{a+d,s},{a+d+64,s},{a+d+64+r,0}} for i:=1;i<len(z);i++{ v,w,x,y:=z[i-1][0],z[i-1][1],z[i][0],z[i][1] m:=(y-w)/(x-v) t:=y-m*x for v<=x{ g.Set(int(Ceil(v)),127-int(Ceil(w)), c.RGBA{0,0,0,255}) v+=.01 w=m*v+t } } f,_:=Create("o.png") k.Encode(f,g) } ``` [Answer] ## dc, 120 bytes Initially I thought I can't answer in dc, but I see that printing the syntax of a vector image is allowed. ``` ?sR127r-sS[<svg><path d="M0 127 L]nrdn[ 0 L]n+dn32PlSn[ L]n64+dn32PlSn[ L]nlR+n[ 127" fill="none" stroke="red"/></svg>]p ``` The code calculates the translated coordinates of each point and generates the SVG syntax for the plot. Since an image editor has the origin at the top-left corner, I had to subtract the `y` values from `height`, 127 in this case, so that the image is shown as if the origin is at the bottom-left corner. **Run example:** or [**Try it Online!**](https://tio.run/nexus/dc#@29fHGRoZF6kWxwcbVNclm5nU5BYkqGQYqvka6AAlFDwic0rSsmLVjAAsbRT8oyNAnKCgXwgz8wElZ8TpA1kADUpKaRl5uTYKuXl56UqKRSXFOVnp9oqFaWmKOnb2eiDbIkt@P/f0FTB2EDB3EDBxAAA) ``` dc -f plot_ADSR.dc <<< "15 30 70 40" ``` **Output:** ``` <svg><path d="M0 127 L15 0 L45 57 L109 57 L149 127" fill="none" stroke="red"/></svg> ``` To display the image plot, save that exact output to a file and open it with Gimp, for example, or enter the text in an html page as I did above. **Explanation:** `dc` is a reverse-polish **d**esk **c**alculator stack language The script is a long concatenation of the SVG syntax string. The keyword `M` stands for *move to coordinate* and `L` stands for *draw line from current position to given coordinate*. ``` ? # read input (in reverse order by default). Stack: RSDA sR # pop top value, store it in register 'R'. Stack: SDA 127r-sS # push 127, swap top 2 values, pop them and push #subtracting result, save it to 'S', pop it. Stack: DA [<svg><path d="M0 127 L]n # [..]n print string (push then pop). Stack: unchanged rdn # swap, duplicate top, print (A) and pop it. Stack: AD [ 0 L]n # printing +dn # pop top 2 values, push addition result, duplicate it, #print and pop it. Stack: (A+D) 32P # print a space lSn # push value from register 'S', print and pop it. #Stack: unchanged [ L]n # printing 64+dn # push 64, pop top 2 values, push addition result, #duplicate it, print and pop it. Stack: (A+D+64) 32PlSn[ L]n # print space, print register 'S', more printing lR+n #push value from register 'R', pop top 2 values, push #addition result, print it and pop it. Stack: empty [ 127" fill="none" stroke="red"/></svg>]p # printing ``` [Answer] # Processing, 111 bytes ``` size(400,128);line(0,127,a,0),line(a,0,a+d,127-s),line(a+d,127-s,a+d+64,127-s),line(a+d+64,127-s,a+d+64+r,127); ``` Used a simpler method of input compared to user41805. ## Output (formatted) `0,0,90,80` [![enter image description here](https://i.stack.imgur.com/VjKEi.png)](https://i.stack.imgur.com/VjKEi.png) `0,10,50,80` [![enter image description here](https://i.stack.imgur.com/DpJsj.png)](https://i.stack.imgur.com/DpJsj.png) `5,50,0,0` [![enter image description here](https://i.stack.imgur.com/rNPTl.png)](https://i.stack.imgur.com/rNPTl.png) `5,50,0,80` [![enter image description here](https://i.stack.imgur.com/1woH3.png)](https://i.stack.imgur.com/1woH3.png) `15,30,70,40` [![enter image description here](https://i.stack.imgur.com/BTFrn.png)](https://i.stack.imgur.com/BTFrn.png) `24,32,127,48` [![enter image description here](https://i.stack.imgur.com/xVFYC.png)](https://i.stack.imgur.com/xVFYC.png) `64,64,64,64` [![enter image description here](https://i.stack.imgur.com/3F5kW.png)](https://i.stack.imgur.com/3F5kW.png) ## Ungolfed code with formatting ``` void settings() { //size adjusts according to params size(a+d+64+r, 129); } void setup() { translate(1,0); background(255); strokeWeight(3); //axes line(0,127,600,127); line(0,0,0,127); //graph stroke(53,113,9); line(0,127,a,0); stroke(228,77,40); line(a,0,a+d,127-s); stroke(26,39,232); line(a+d,127-s,a+d+64,127-s); stroke(110,27,109); line(a+d+64,127-s,a+d+64+r,127); //save to file save("a"+a+"d"+d+"s"+s+"r"+r+".png"); } int a=24,d=32,s=127,r=48; ``` This program will save your images to disk in the same folder. ]
[Question] [ Your task is to write a full program that will continue to count down from 10 every time it is run. * The first time you run the program, it should print `10`. * The next time, it should output `9`. * The next time, it should output `8`, and so on. * Instead of printing `0`, the program should crash. You do not have to handle the program running any more times after that. * Any facilities used for storage may be assumed to be empty before the first execution of the program. Here's an example implementation in Python 3: ``` try:f=open("a","r+");v=int(f.read()) except:f=open("a","w");v=10 1/v print(v) f.seek(0) f.write(str(v-1)) ``` This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer (measured in bytes) wins. [Answer] # Perl on Linux, 17 bytes I thought it might be interesting to create a program that doesn't maintain any state itself, and doesn't modify its own source code; in other words, it actually checks how often it's been run by asking the OS. The question says "Any facilities used for storage may be assumed to be empty before the first execution of the program.", and thus we'd want to start from a completely blank OS. As such, I'd better explain just how you go about doing that, as otherwise testing the program is difficult. There are actually two ways to set up for running the program. Either way, the minimal OS for the purpose would be running nothing but a shell (to enable us to run Perl in turn), and the simplest possible shell at that (so that it doesn't do anything fancy that makes the OS non-blank). `/bin/dash` is a good choice here, as it was intended as a minimal shell for system recovery. Then, we need to start Linux in such a way that it's running nothing but `dash`. We can either do this by rebooting the computer with `init=/bin/dash` on the Linux command line so that it starts nothing besides `dash`, or (much more conveniently) creating a Linux container using `unshare -Urfp /bin/dash` in a terminal (`unshare` doesn't actually *create* a blank OS, but it does *simulate* one; notably, the inside of the container thinks it's root, `dash` thinks it's init, etc., just as would happen on an actual blank OS). Disclaimer: I haven't actually tested this on bare metal yet, only inside `unshare`, but it should work both ways in theory. Finally, once we've got that set up, we simply have to look at the PID; as we're on a blank system, the init system (here, the shell) will have PID 1, so the executions of Perl will have PIDs from 2 up to 12 inclusive. So our program looks like this: ``` say 12-$$||die ``` Here's a sample run: ``` $ unshare -Urfp /bin/dash # perl -E 'say 12-$$||die' 10 # perl -E 'say 12-$$||die' 9 # perl -E 'say 12-$$||die' 8 # perl -E 'say 12-$$||die' 7 # perl -E 'say 12-$$||die' 6 # perl -E 'say 12-$$||die' 5 # perl -E 'say 12-$$||die' 4 # perl -E 'say 12-$$||die' 3 # perl -E 'say 12-$$||die' 2 # perl -E 'say 12-$$||die' 1 # perl -E 'say 12-$$||die' Died at -e line 1. # ``` [Answer] # 6502 machine language + Apple ][+ ROM, 12 (11? 10? 9?) bytes ``` CE 06 80 F0 01 A2 0B A9 00 4C 24 ED ``` Should start at `$8000`. Crashes to the system monitor when the count reaches 0. --- ``` C6 B6 F0 01 A2 0B A9 00 4C 24 ED ``` Should start at `$B1`. This saves a byte since I can use the (two-byte) zero-page version of `DEC`, but overwrites the critical Applesoft routine `CHRGET`; you'll need to load it and call it from the monitor, and use `CTRL`+`B``Return` to re-initialize BASIC once you're done. Not sure if this invalidates it or not. --- ``` CE 06 80 F0 01 A2 0B 4C 26 ED ``` Should start at `$8000`. This doesn't initialize `$9E`, saving two bytes. However, this means you **must not call it with a negative address** (or, if you call it from the monitor, you have to call the monitor with a positive address). If you do, Applesoft's `CALL` routine will store `FF` in `$9E`, causing it to add 65280 to the number when printing it. Again, not sure if this invalidates the solution or not. --- ``` C6 B6 F0 01 A2 0B 4C 26 ED ``` Should start at `$B1`. This is a combination of the above two programs, saving a total of three bytes; you'll have to call the monitor with a positive address, load it and run it from there, and use `Ctrl`+`B``Return` to re-initialize BASIC once you're done. --- Note that these programs only modify the program in memory; re-loading the program from disk will reset the countdown. This works because the Apple ][ (and ][+, //e, and //c) have no memory protection system whatsoever; the program (and its self-modifications) will stay in memory even after it exits, so you can keep running it from memory until you overwrite that memory with something else. --- ## Sample run ``` ]BLOAD COUNT THEN BRK ]CALL 32768 10 ]CALL 32768 9 ]CALL 32768 8 ]CALL 32768 7 ]CALL 32768 6 ]CALL 32768 5 ]CALL 32768 4 ]CALL 32768 3 ]CALL 32768 2 ]CALL 32768 1 ]CALL 32768 8008- A=80 X=9D Y=00 P=36 S=EE * ``` --- ## Explanation ``` DEC NUM+1 ; Decrement the LDX instruction's operand BEQ NUM+1 ; If it is now zero, branch to it; 00 is the opcode for the BRK instruction, which causes the program to crash to the monitor NUM LDX #$0B ; Load the X register with 0x0A; the operand has already been decremented once LDA #$00 ; Load the accumulator with 0 JMP $ED24 ; Jump to $ED24, an Applesoft ROM routine which prints A (high byte),X (low byte) in decimal ``` --- ## Explanation of 10 byte version ``` DEC NUM+1 ; Decrement the LDX instruction's operand BEQ NUM+1 ; If it is now zero, branch to it; 00 is the opcode for the BRK instruction, which causes the program to crash to the monitor NUM LDX #$0B ; Load the X register with 0x0A; the operand has already been decremented once JMP $ED26 ; Jump to $ED26, which is two bytes into the Applesoft routine at $ED24. The two skipped bytes would store the accumulator in $9E ``` --- # Variants ## Prints `ERR` and beeps when count reaches 0 ### Normal - 15 bytes ``` CE 06 80 F0 07 A2 0B A9 00 4C 24 ED 4C 2D FF ``` ### Overwrites `CHRGET` - 14 bytes ``` C6 B6 F0 07 A2 0B A9 00 4C 24 ED 4C 2D FF ``` ### Doesn't initialize `$9E` - 13 bytes ``` CE 06 80 F0 05 A2 0B 4C 26 ED 4C 2D FF ``` ### Overwrites `CHRGET` and doesn't initialize `$9E` - 12 bytes ``` C6 B6 F0 05 A2 0B 4C 26 ED 4C 2D FF ``` --- ## Freezes when count reaches 0 ### Normal - 12 bytes ``` CE 06 80 F0 FE A2 0B A9 00 4C 24 ED ``` ### Overwrites `CHRGET` - 11 bytes ``` C6 B6 F0 FE A2 0B A9 00 4C 24 ED ``` ### Doesn't initialize `$9E` - 10 bytes ``` CE 06 80 F0 FE A2 0B 4C 26 ED ``` ### Overwrites `CHRGET` and doesn't initialize `$9E` - 9 bytes ``` C6 B6 F0 FE A2 0B 4C 26 ED ``` [Answer] # [Bash](https://www.gnu.org/software/bash/) + sed, ~~41~~ ~~40~~ 38 bytes ``` echo $[n=10/1] sed -i s/$n/$[n-1]/g $0 ``` [Try it online!](https://tio.run/nexus/bash#TYxBC4IwHEfP7lP8IMkKdK5r5s0gCAzqFhHTLd3B/8BpBtVnN7t1evB4vFJ2SFHanjplB0KSIMjyXTDqsrbwL7QVMRdX5rRCaOC4T3yyobjyCn48Ti1jd9viBkN4iTiK4s8GyjKvkK7@O6/TucCbed5vFTg@IVodddsY54wlKE1GK84DzNDqxj60gyScsoOh/olBtmSowuK8z1H01ZJ5ypIevw "Bash – TIO Nexus") [Answer] ## Javascript, 42 bytes ``` y=localStorage;y.a=y.a||10;alert(y.a--||a) ``` Test it out with [this fiddle](https://jsfiddle.net/3runz3mx/) - be sure to clear your local storage to reset the countdown. Thanks to steenbergh, Lmis, and obarakon for lots of bytes! [Answer] # [Dyalog APL](http://goo.gl/9KrKoM), ~~33~~ ~~28~~ 22/20? [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319) I am not sure if this is valid, as it consists of a function (which must be called with a dummy argument). However, all APL programs (purely functional or not) have the same status, and indeed some APL versions do not have traditional programs, only functions. In compensation, I have added two bytes to name it, although that is not necessary for the desired effect. ``` f←{6::⊢c∘←10⋄÷÷c∘←c-1} ``` Note that this relies on an unofficial quirk, that `∘←` assigns globally. `6::` upon any value error `⊢c` return *c* `∘←10` which is globally set to 10 `⋄` now `÷÷c` return the twice inverted (errors on zero) c `∘←` which is globally set to `c-1` one less than *c* [TryAPL online!](http://tryapl.org/?a=f%u2190%7B6%3A%3A%u22A2c%u2218%u219010%u22C4%F7%F7c%u2218%u2190c-1%7D%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C%20%u22C4%20f%u236C&run) --- Certainly valid 28 byte version: ``` f ⍎'c←11'/⍨0=⎕NC'c' ⊢c←÷÷c-1 ``` Works by setting *c* to 11 if missing, then subtracting 1 from *c*, inverting twice (which gives div-by-zero error if *c*-1 is 0), assigning to *c*, and outputting the new value. --- Old 33 byte version: ``` f ÷÷≢2↓r⊣⎕FX¯1↓r←⎕NR'f' ``` Works by redefining itself on each run, but with one less trailing newline. Outputs the twice inverted number of remaining lines (less two), thus giving a div-by-zero error when only two lines are left (the header and the actual code). [Answer] ## C#, ~~197~~ ~~160~~ ~~159~~ 125 bytes ``` namespace System.IO{class P{static void Main(){int n=11;for(;File.Exists(""+--n););File.Create(""+n);Console.Wr‌​ite(n*n/n);}}} ``` *Saved 34 bytes thanks to milk* And a formatted version (With `ReadKey` added so you can view the output): ``` namespace System.IO { class P { static void Main() { int n=11; for(;File.Exists(""+--n);); File.Create(""+n); Console.Wr‌​ite(n*n/n); } } } ``` It is longer than I thought it would be so there's probably room for golfing. [Answer] # Perl, ~~37~~ 36 bytes ``` 9=~//;print$'-sysopen$~,$0,print$'+1 ``` Crashes when the initial value reaches -1 (which would have printed 0), as it writes over the `=~` operator. Saved a byte using `sysopen` rather than `open`. This allows me to print to `STDOUT` first, using the return value as the file mode (`1`, a.k.a. `O_WRONLY`), before `$~` is reassigned. **Sample Usage** ``` $ perl crash-off.pl 10 $ perl crash-off.pl 9 $ perl crash-off.pl 8 ... $ perl crash-off.pl 2 $ perl crash-off.pl 1 $ perl crash-off.pl syntax error at crash-off.pl line 1, near "1~" Execution of crash-off.pl aborted due to compilation errors. ``` [Answer] # [Perl 6](https://perl6.org), ~~60~~ 58 bytes ``` put 10-$=finish.lines||die; $*PROGRAM.open(:a).put; =finish   ``` ``` open($*PROGRAM,a=>put 10-$=finish.lines||die).put =finish   ``` Needs newline character after `=finish`. `die` can be replaced with `1/0`. ## Explanation: It gets a list of lines after `=finish` (`$=finish.lines`) subtracts that from `10`, and if the result isn't `0` it prints it, otherwise it `die`s. The last thing it does is open itself in append mode, and add another line to the end. [Answer] # Python 2, 65 bytes ``` f=open(__file__,"r+") x=75-len(f.read()) x/x print x f.write('#') ``` Inspired by [L3viathan's answer](https://codegolf.stackexchange.com/a/103344/62501). Can be reduced to 60 bytes if you can choose to name the file a single character like `x` and then replace `__file__` with `'x'`. In that case, replace `75` with `70`. [Answer] # Jolf, 20 bytes ``` γ-@▲lqΈ?␡γ?γaγ0₯I₯C1 ``` [Try it here!](http://conorobrien-foxx.github.io/Jolf/#code=zrMtQB5scc6IP3_Osz_Os2HOszDigq9J4oKvQzE) Errors when `0` is printed. Modifies the code. Explanation to come. [Answer] # Applesoft BASIC, 21 bytes (tokenized) ``` 0 PRINT 9 + 1: CALL 2066: END : OR <CTRL-F><CTRL-H>` ``` Replace `<CTRL-F>` and `<CTRL-H>` with their literal versions. Note that this only modifies the program in memory; re-loading it from the disk will reset the countdown. --- ## Sample run ``` ]RUN 10 ]RUN 9 ]RUN 8 ]RUN 7 ]RUN 6 ]RUN 5 ]RUN 4 ]RUN 3 ]RUN 2 ]RUN 1 ]RUN ?SYNTAX ERROR IN 0 ``` --- ## Explanation `PRINT 9 + 1` does what you'd expect. `CALL 2066` calls the 6502 machine-language routine at memory location 2066, which is after `END :`. `END` halts the program so that the machine-language routine (which, to the Applesoft interpreter, is garbage) isn't executed. The machine-language routine simply decrements the `9` in `PRINT 9 + 1`. Disassembly: ``` 0812- CE 06 08 DEC $0806 0815- 60 RTS ``` After the counter reaches 0, it is "decremented" to `/`; attempting to run the program will then cause a syntax error. [Answer] ## [\*><>](http://esolangs.org/wiki/Starfish), ~~20~~ 18 bytes ``` a1Fi:0(?b1-:?:1Fn; ``` This actually works on Linux (and whatever supports files named `\n` I guess). It creates a file named `\n` on first run and outputs `10`. It proceeds to output one less number on each subsquent run, except `0` where it crashes instead. ### Explanation ``` a1F open file named "\n" i: recieve input and duplicate it (-1 if empty) 0(?b if the file is empty, push 11 to the stack 1- subtract one : duplicate the number ?: if the number isn't 0, duplicate it again 1F save the number to the file n output the number (crash if non-existant) ; exit ``` [Answer] # PHP 57 bytes ``` echo$n=($f=file(f))?$f[0]:10?:die;fputs(fopen(f,w),--$n); ``` doesn´t really crash but exit (without counting down) when it hits `0`. Is that sufficient? Run with `-r`. [Answer] # C#, 156 bytes I golfed @TheLethalCoder's answer for a bit, and was able to save 3 bytes by reordering the statements and eliminating the int.parse(). Still room for improvement, I'm sure. ``` using System.IO;class P{static void Main(){int n;try{n=File.ReadAllText("f")[0]-48;}catch{n=10;}System.Console.Write(n/n*n);File.WriteAllText("f",""+--n);}} ``` Ungolfed: ``` using System.IO; class P { static void Main() { int n; try { n = File.ReadAllText("f")[0] - 48; } catch { n = 10; } System.Console.Write(n / n * n); File.WriteAllText("f", "" + --n); } } ``` Meta-question: It may be hack-y to take TheLethalCoder's work as a starting point for my answer. Would it be better (once I have the rep) to add this as a comment on their answer? I'm not trying to compete with them, I just want to show off my golf, for mutual edification. [Answer] ## Powershell V2.0, 49 bytes (First ever code golf, couldn't find the rules on how to calculate bytes. I used a String to bytes calculator online) ``` if(!$n){$n=10;$n}else{$n-=1;if($n-eq0){throw};$n} ``` Running: ``` PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 10 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 9 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 8 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 7 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 6 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 5 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 4 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 3 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 2 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} 1 ____________________________________________________________________________________________________________________________________________________________________ PS C:\Users\***> if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw};$n;} ScriptHalted At line:1 char:49 + if(!$n){$n = 10;$n}else{$n=$n-1;if($n-eq0){throw <<<< };$n;} + CategoryInfo : OperationStopped: (:) [], RuntimeException + FullyQualifiedErrorId : ScriptHalted ``` [Answer] ## Java, 343 bytes My first golfing attempt ``` import java.io.PrintWriter;class M{public static void main(String[] a) throws Exception{if(!new java.io.File("x").exists()) try(PrintWriter p=new java.io.PrintWriter("x")){p.write("10");}int b=new java.util.Scanner(new java.io.File("x")).nextInt();try(PrintWriter p=new java.io.PrintWriter("x")){p.print(b/b*b-1+"");System.out.print(b+"");}}} ``` ungolfed ``` import java.io.PrintWriter; class M { public static void main(String[] a) throws Exception { if (!new java.io.File("x").exists()) { try (PrintWriter p = new java.io.PrintWriter("x")) { p.write("10"); } } int b = new java.util.Scanner(new java.io.File("x")).nextInt(); try (PrintWriter p = new java.io.PrintWriter("x")) { p.print(b / b * b - 1 + ""); System.out.print(b + ""); } } } ``` [Answer] # SQLite, ~~142~~ 137 This could probably be done much more cleverly. ~~141~~ 136 chars for code: ``` create table if not exists t(n not null);insert into t select 11;update t set n=case n when 1 then null else n-1 end;select min(n)from t ``` Plus 1 for the filename `x` in `sqlite3 x '…'`. [Answer] ## JavaScript, 74 bytes ~~`x=typeof x!=typeof 1?10:x!=1?x-=1:_`~~ `l=localStorage;l.a=typeof l.a!=typeof""?10:l.a!=1?l.a=--l.a:_;aler‌​t(l.a)` [Answer] ## Ruby, ~~94~~ ~~87~~ ~~84~~ ~~61~~ 59 bytes ``` j=File.open(?a,"a+");1/(i=j.readlines.size-14);p -i;j.puts ``` Please leave suggestions below. Thanks @ConorO'Brien for the ideas (some shamelessly ripped off from his answer). [Answer] # Ruby, 52 + 1 = 53 bytes Assumes the file is named `a` (+1 byte). ``` q=File.read ?a 0/h=62-q.size p h File.write ?a,q+?1# ``` ## Running ``` C:\Users\Conor O'Brien\Documents\Programming λ type a q=File.read ?a 0/h=62-q.size p h File.write ?a,q+?1# C:\Users\Conor O'Brien\Documents\Programming λ ruby a 10 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 9 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 8 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 7 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 6 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 5 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 4 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 3 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 2 C:\Users\Conor O'Brien\Documents\Programming λ ruby a 1 C:\Users\Conor O'Brien\Documents\Programming λ ruby a a:2:in `/': divided by 0 (ZeroDivisionError) from a:2:in `<main>' ``` [Answer] # Python 2, 89 bytes ``` x=10 x/x print x f=open(__file__,"r+") s=f.read() f.seek(0) f.write(s.replace(`x`,`x-1`)) ``` [Answer] # TI-BASIC (TI-84 Plus) (15 bytes) ``` If not(Ans 11 Ans-1 AnsAns/Ans ``` Ans should equal 0 (the default value) before the first run. Since `AnsAns/Ans` is the last line of the program, it will be outputted and stored to Ans unless Ans is 0, in which case a divide by 0 error occurs. [Answer] # JavaScript, 41 `l=localStorage;l.l=-~l.l;alert(11-l.l||I)` [Answer] # GNU Smalltalk, ~~70~~, 68 bytes 66 bytes code +2 bytes for the "-S" flag EDITS * Removed unnecessary parentheses, -2 bytes **Golfed** ``` X=Y ifTrue:[Smalltalk at:#X put:10]ifFalse:[X:=X-1].(X*X/X)printNl ``` **Test** ``` >seq 11|xargs -L1 sudo gst -S fail.st 2>/dev/null 10 9 8 7 6 5 4 3 2 1 Object: 0 error: The program attempted to divide a number by zero ZeroDivide(Exception)>>signal (ExcHandling.st:254) SmallInteger(Number)>>zeroDivide (SysExcept.st:1426) SmallInteger>>/ (SmallInt.st:277) UndefinedObject>>executeStatements (fail.st:1) ``` *Important* You must run *gst* as root, for it to be able to modify the default image, or specify your own image with *-I*. [Answer] # PHP, 45 bytes Honestly not sure if this one counts. ``` <?session_start();echo10-$_SESSION[0]++?:die; ``` I'd post a link to an example, but all the online testers that I know don't allow `session_start()` to be used. This will keep counting down each time you refresh the page until 0, when the `die` command is ran. [Answer] ## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 70 bytes ``` open"r",1,"a.b" $get#1,1,e|~e=0|e=z\e=e-1]?e~e=0|$error 1|]$put#1,1,e| ``` Opens file `a.b` (or creates it when not found on first run), reads record 1 into `e`. If that record is not found, assume 10, else sub 1. At `e==0`, raise an error. Write back `e` to `a.b`. File access is not built into QBIC, this relies heavily on the underlying QBasic. [Answer] ## Batch, 72 bytes ``` @call:l @if %n%==0 goto g @echo %n% @cmd/cset/a-1>>%0 :l @set/an=10 ``` Needs to be invoked using the full file name including extension. Last line must not have a trailing newline. Works by writing `-1` to the end of the last line so that it evaluates to 1 less each time. `goto g` errors out because there's no label `:g`. [Answer] ## R, 52 bytes ``` `if`(!"x"%in%ls(),cat(x<-10),`if`(x>0,cat(x<-x-1),)) ``` Essentially uses `ls()` to list the names of all globally stored objects. If we assume that the global environment is empty and `"x"` doesn't exist already, generate `x=10`, else if `x!=0` subtract `1` else call a missing argument which returns an error. [Answer] ## Windows Batch, 61 bytes ``` @if %n%.==. set n=10 @if %n%==0 goto. @set /a n-=1&@echo %n% ``` [Answer] **JavaScript, 44 bytes** ``` function* f(n=11){for(;--n;yield n);throw''} p=f() console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) console.log(p.next().value) ``` ]
[Question] [ You goal is to implement the operation of XOR ([carryless](http://en.wikipedia.org/wiki/CLMUL_instruction_set)) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (`^`) as binary addition without carrying ``` 101 5 ^ 1001 9 ---- 1100 12 5^9=12 ``` we can perform XOR multiplication `@` by doing binary [long-multiplication](http://mathworld.wolfram.com/LongMultiplication.html) but doing the adding step without carrying as bitwise XOR `^`. ``` 1110 14 @ 1101 13 ----- 1110 0 1110 ^ 1110 ------ 1000110 70 14@13=70 ``` (For mathematicians, this is multiplication in the polynomial ring \$F\_2[x]\$, identifying polynomials with natural numbers by evaluating at \$x=2\$ as a polynomial over \$\mathbb Z\$.) XOR multiplication commutes `a@b=b@a`, associates `(a@b)@c=a@(b@c)`, and distributes over bitwise XOR `a@(b^c)=(a@b)^(a@c)`. In fact, it is the unique such operation that matches multiplication `a@b=a*b` whenever `a` and `b` are powers of `2` like `1,2,4,8...`. **Requirements** Take two non-negative integers as input and output or print their XOR-product. This should be as numbers or their decimal string representations, not their binary expansions. Fewest bytes wins. Don't worry about integer overflows. Here are some test cases formatted as `a b a@b`. ``` 0 1 0 1 2 2 9 0 0 6 1 6 3 3 5 2 5 10 7 9 63 13 11 127 5 17 85 14 13 70 19 1 19 63 63 1365 ``` [Answer] # x86 machine code: 7 bytes ``` 66 0F 3A 44 C1 00 C3 pclmulqdq xmm0, xmm1, 0 \ ret ``` Only two instructions. `pclmulqdq` does the heavy lifting, it literally implements that type of xor-multiplication. `ret` to make it a callable function, hopefully satisfying the requirement of "outputting" the result (in the return value, `xmm0`). Putting integer arguments in `xmm` args is a bit unusual, but I hope you'll forgive me. [Answer] # Z80, 11 bytes ``` B7 CB 32 30 01 B3 C8 CB 23 18 F6 ``` The code is called as a function. `a` and `b` are in `D` and `E` (the order doesn't matter) and the answer is stored in `A` when the code returns (there are no I/O functions). ``` B7 XOR A // A^=A (A=0) CB 32 SRL D // CARRY = lsb(D), D>>=1, ZERO = D==0 30 01 JR NC, 1 // jump 1 byte if not CARRY B3 XOR E // A^=E, ZERO = A==0 C8 RET Z // return if ZERO CB 23 SLA E // E<<=1 18 F6 JR -10 // jump -10 bytes ``` It produces the correct results for all test input except `63@63` which returns `85` because all the registers are 8-bit and 1365 mod 256 = 85 (integer overflow). [Answer] # Pyth, ~~13~~ 12 bytes ``` uxyG*HQjvz2Z ``` [Demonstration.](https://pyth.herokuapp.com/?code=xFm*vz.%26Q%5E2dQ&input=63%0A63&debug=0) ``` uxyG*HQjvz2Z Implicit: z = input() Q = eval(input()) Z = 0 jvz2 The first input, written in base 2, like so: [1, 0, 1, ... u jvz2Z Reduce over the binary representation, starting with 0. x XOR of yG Twice the previous number *HQ and the second input times the current bit. ``` --- Old version, 13 bytes: ``` xFm*vz.&Q^2dQ ``` [Demonstration.](https://pyth.herokuapp.com/?code=xFm*vz.%26Q%5E2dQ&input=13%0A11&debug=0) [Answer] # C, ~~44~~ 38 bytes *Thanks to nimi, we now use recursion for 6 fewer bytes!* ``` f(a,b){return b?(b&1)*a^f(a*2,b/2):0;} ``` We define a function `f` which takes `a`, `b`. This can be called like: ``` printf("%d @ %d = %d\n", 13, 14, f(13, 14)); ``` Which outputs: `13 @ 14 = 70` Try the test cases [online](http://ideone.com/MaJPpL)! [Answer] # J, 14 bytes ``` */(~://.@)&.#: ``` Usage: ``` 5 (*/(~://.@)&.#:) 17 NB. enclosing brackets are optional 85 ``` Explanation (reading mostly from right to left; `u` and `v` stand for arbitrary functions): * `u&.#:` applies `u` to the vectors of the binary representations of the input numbers then turn the result back to an integer (`u&.v == v_inverse(u(v(input_1), v(input_2)))`) * `*/` products (`*`) of inputs in the Descartes product (`/`) of the two binary vector * `v(u@)` apply `u` to `v` (to the Descartes product) * `u/.` apply `u` to every anti-diagonal of the Descartes product (anti-diagonals represent the 1st, 2nd, ... digits in the binary representation) * `~:/` reduce (`/`) an anti-diagonal with XOR operation (`~:`) * The last step is generating an integer from the binary vector which the first point takes care of. [Try it online here.](http://tryj.tk/) [Answer] # CJam, ~~14~~ 13 bytes ``` q~2bf*{\2*^}* ``` **How it works**: We first get the long multiplication results and then work our way up starting from the bottom two pairs. ``` q~ e# Eval the input. This puts the two numbers on stack 2b e# Convert the second number to binary f* e# Multiply each bit of second number with the first number e# This leaves an array with the candidates to be added in the long e# multiplication step { }* e# Reduce on these candidates. Starting from the bottom \2* e# Bit shift the lower candidate ^ e# XOR each other and continue ``` [Try it online here](http://cjam.aditsu.net/#code=q%7E2bf*%7B%5C1m%3C%5E%7D*&input=14%2013) [Answer] # Python 2, 35 bytes ``` f=lambda m,n:n and n%2*m^f(2*m,n/2) ``` Call like `f(13, 14)`. I think most languages with a similar construct will converge on something like this. [Answer] # Java, 62 ``` (x,y)->{int r=0,i=0;for(;i<32;)r^=x*((y>>i)%2)<<i++;return r;} ``` ## Expanded ``` class XORMultiplication { public static void main(String[] args) { IntBinaryOperator f = (x, y) -> { int r = 0, i = 0; for (; i < 32;) { r ^= x * ((y >> i) % 2) << i++; } return r; }; System.out.println(f.applyAsInt(14, 13)); } } ``` [Answer] ## Perl - 35 Bytes ``` #!perl -p $\^=$`>>$_&1&&$'<<$_ for-/ /..31}{ ``` Counting the command line option as one. Input is taken from `STDIN`, space separated. **Sample usage:** ``` $ echo 13 11 | perl xormul.pl 127 $ echo 5 17 | perl xormul.pl 85 $ echo 14 13 | perl xormul.pl 70 $ echo 19 1 | perl xormul.pl 19 $ echo 63 63 | perl xormul.pl 1365 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes ``` BJ’2*U×B{×^/ ``` [Try it online!](https://tio.run/##DcwxDsIwEATA/l6xLTTx@fAZFzQp00NJR4PyAUSD@ETEC5AiKgQSER1@ifMRc91qtLvHQ9@fam27@XLzy20e2nMe9k0t31f5POfrY/d7l2nc5HuzqNWB4Yjh4SnBWVYTJYEgkEcAO4pIUCEWMIN9JNOIdSBewTDaQbIVJ1KxopmGPw "Jelly – Try It Online") ## How it works ``` BJ’2*U×B{×^/ - Main link. Takes a on the left, b on the right B - Binary representation of a J - Replace each element with its index ’ - Decrement 2* - Raise each to the power 2 U - Reverse B{ - Yield the binary representation of a × - Multiply the bits by the powers × - Multiply b by the results ^/ - Reduce by XOR ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~7~~ 6 bytes ``` Bæc/ḂḄ ``` [Try it online!](https://tio.run/##DcwxCgIxEAXQfk7xWysziZmY1kMI1mIjewFLF0HwIBZiJStEtHLBe8xeZJzu8/j/73dddzBbjdftXFuv7WT6Hr5PbY/11N/1dZuOn/H8u8w2ZgGMQIyISBXBs7gIJSRkisjgQAUVkogTmMGxkGvBMhMv4Fj8oPqKK0nyopvkPw "Jelly – Try It Online") *-1 thanks to Jonathan Allan* Takes a list of `[a, b]`. (The dyadic equivalent is the very fun-looking `BæcḂḄɓB`.) ``` B Convert a and b to their binary digits, æc/ and convolve them. Ḃ Take each mod 2 Ḅ and convert from binary. ``` [Answer] # Haskell, 50 bytes ``` import Data.Bits _#0=0 a#b=b.&.1*a`xor`2*a#div b 2 ``` A translation of @BrainSteel's C answer. Usage example: ``` map (uncurry (#)) [(0,1),(1,2),(9,0),(6,1),(3,3),(2,5),(7,9),(13,11),(5,17),(14,13),(19,1),(63,63)] [0,2,0,6,5,10,63,127,85,70,19,1365] ``` [Answer] # Julia, ~~35~~ ~~33~~ 30 bytes ``` f(a,b)=b%2*a$(b>0&&f(2a,b÷2)) ``` This creates a recursive function `f` which takes two integers and returns the XOR product of the inputs. Ungolfed: ``` function f(a, b) # Bitwise XOR : $ # Short-circuit AND : && b % 2 * a $ (b > 0 && f(2a, b ÷ 2)) end ``` Saved a couple bytes with encouragement from Sp3000! [Answer] # MMIX, 28 bytes (7 instrs) (jelly xxd) ``` 00000000: e3020000 7aff0001 c60202ff 3f000001 ẉ£¡¡z”¡¢İ££”?¡¡¢ 00000010: 37010101 5b00fffc f8030000 7¢¢¢[¡”‘ẏ¤¡¡ ``` Disassembly: ``` clmul SETL $2,0 // r = 0 0H ZSOD $255,$0,$1 // loop: t = a odd? b : 0 XOR $2,$2,$255 // r ^= t SRU $0,$0,1 // a >>= 1 SLU $1,$1,1 // b <<= 1 PBNZ $0,0B // iflikely(a) goto loop POP 3,0 // return r ``` You could get a 128-bit answer out of this with about three more instructions, I think. [Answer] # Python 2, ~~104~~ ~~91~~ ~~78~~ 66 bytes ``` def y(a,b,c=0): for _ in bin(b)[:1:-1]:c^=int(_)*a;a<<=1 print c ``` Take the bits of `b` in reverse order, ending before you hit the `'0b'` at the start of the string. Multiply each one by `a` and `xor` with the total, then left-shift `a`. Then print the total. [Answer] # Mathematica, 40 bytes ``` BitXor@@(#2BitAnd[#,2^Range[0,Log2@#]])& ``` [Answer] # Go, 63 bytes ``` func f(a,b uint)uint{if a<1{return 0};return a%2*b^f(a/2,b*2)} ``` Complete example: <http://play.golang.org/p/-ngNOnJGyM> [Answer] # [GAP](http://gap-system.org), 368 Bytes > > For mathematicians, this is multiplication in the polynomial ring F\_2[x], identifying polynomials with natural numbers by evaluating at x=2 as a polynomial over Z. > > > Sure, let's do that! (this is only loosly golfed, the point was more to move into F2[x] and do the calculations more than any attempt at being a winning entry) Here's the code ``` f:=function(i,j)R:=PolynomialRing(GF(2));x:=IndeterminatesOfPolynomialRing(R);x:=x[1];a:=function(i)local n,r;r:=0*x;while not i=0 do n:=0;while 2^n<=i do n:=n+1;od;n:=n-1;r:=r+x^n;i:=i-2^n;od;return r;end;b:=function(r)local c,i,n;i:=0;n:=0;for c in CoefficientsOfUnivariatePolynomial(r) do if c=Z(2)^0 then n:=n+2^i;fi;i:=i+1;od;return n;end;return b(a(i)*a(j));end; ``` Here's the ungolfed code with explanation: ``` xor_multiplication:=function(i,j) R:=PolynomialRing(GF(2)); x:=IndeterminatesOfPolynomialRing(R); x:=x[1]; to_ring:=function(i) local n,r; r:=0*x; while not i=0 do n:=0; while 2^n<=i do n:=n+1; od; n:=n-1; r:=r+x^n; i:=i-2^n; od; return r; end; to_ints:=function(r) local c,i,n; i:=0;n:=0; for c in CoefficientsOfUnivariatePolynomial(r) do if c=Z(2)^0 then n:=n+2^i; fi; i:=i+1; od; return n; end; return to_ints( to_ring(i)*to_ring(j)); end; ``` Okay, so first off, we create the univariate polynomial ring over the field F2 and call it `R`. Note that `GF(2)` is F2 in GAP. ``` R:=PolynomialRing(GF(2)); ``` Next, we are going to assign the GAP variable `x` to the indeterminate of the ring `R`. Now, whenever I say `x` in GAP, the system will know I am talking about the indeterminate of the ring `R`. ``` x:=IndeterminatesOfPolynomialRing(R); x:=x[1]; ``` Next, we have two functions, which are inverse maps of each other. These maps are both onto, but they are not structure preserving, so I couldn't figure out a better way to implement them in GAP. There almost certainly is a better way, if you know it, please comment! The first map, `to_ring` takes an integer and maps it to its corresponding ring element. It does this by using a conversion to binary algorithm, where every `1` that would appear in binary is replaced by an `x^n` where `n` is the appropriate power that 2 would take if the number was indeed binary. ``` to_ring:=function(i) local n,r; r:=0*x; # initiate r to the zero element of R while not i=0 do # this is a modified binary algorithm n:=0; while 2^n<=i do n:=n+1; od; n:=n-1; r:=r+x^n; i:=i-2^n; od; return r; end; ``` The next function reverses this. `to_ints` takes a ring element and maps it to its corresponding integer. I do this by getting a list of the coefficients of the polynomial and for each nonzero coefficient, the result is increased by 2^n, in the same way that we would convert binary to decimal. ``` to_ints:=function(r) local c,i,n; i:=0;n:=0; for c in CoefficientsOfUnivariatePolynomial(r) do if c=Z(2)^0 then # ^-- Right here you'll notice that the Z(2) is basically '1' in GF(2). So Z(2)^0 ~ 1 and Z(2)*0 ~ 0 # effectively, this line checks for nonzero coefficients n:=n+2^i; fi; i:=i+1; od; return n; end; ``` For the final step, we call these functions. We take the two integer inputs, convert them into elements in the ring `R`, then multiply these elements together, and send the product back to the integers. ``` return to_ints( to_ring(i)*to_ring(j)); ``` [Answer] # ARM Thumb-2 (NEON), 6 bytes Eat my Thumb, `pclmullqlqdqdqdqdq`. ARM has boring builtins, too! ``` ef80 0e01 4770 ``` Assembly code: ``` .syntax unified .arch armv7-a .fpu neon .thumb .globl xormul_boring_neon .thumb_func xormul_boring_neon: // q0[0-8] = d0[0-8] @ d1[0-8] vmull.p8 q0, d0, d1 bx lr ``` Input: two 8-bit values in `d0` and `d1` Output: the 16-bit product in `q0` This actually multiplies 8 packed bytes together. # ARM Thumb-2, manual, 14 bytes Ok, to make up for it, here is a fully scalar version which does a 32x32 multiply with a 32-bit result. ``` 2300 0849 bf28 4043 0040 d1fa 4770 ``` Assembly code: ``` .syntax unified .arch armv6t2 .thumb .globl xormul_scalar .thumb_func // r3 <- r0 @ r1 xormul_scalar: // acc <- 0 movs r3, #0 .Lloop: // test each bit in y by using lsrs carry-out lsrs r1, r1, #1 // was the bit set? it cs // if so, acc ^= x eorcs r3, r0 // shift x left lsls r0, r0, #1 // loop while x is non zero bne .Lloop .Lend: // return in r3 bx lr ``` Equivalent C code: ``` uint32_t xormul_scalar(uint32_t x, uint32_t y) { uint32_t acc = 0; do { if (y & 1) acc ^= x; y >>= 1; } while ((x <<= 1)); return acc; } ``` The numbers to be multiplied are in `r0` and `r1`, and the result is in `r3`. It is a fairly basic shift and xor loop. Yet another case of `lsls` and `lsrs` being far too useful than they deserve to be. [Try it online! (sorta)](https://travis-ci.com/github/easyaspi314/easyaspi-ppcg/jobs/478593577#L439): demo in Travis [Answer] # Jelly, 16 bytes ``` Ḥ⁴BL’¤Ð¡U×"⁴B¤^/ ``` [Try it online!](http://jelly.tryitonline.net/#code=4bik4oG0QkzigJnCpMOQwqFVw5ci4oG0QsKkXi8&input=&args=MTM+MTE) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` Îbv·yI*^ ``` [Try it online](https://tio.run/##yy9OTMpM/f//cF9S2aHtlZ5acf//G5pwGRoDAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWVC6H@D4qSyQ9srI7Ti/tfq/I@ONtAxjNWJNtQxApKWOgZA0gwsYqxjDCSNdEyBpLmOJUiNsY4hSMZUx9AcxDXRMQQpMbQEqzcz1jEzjo0FAA). **Explanation:** ``` Î # Push 0 and the first input b # Convert it to a binary string v # Loop over each bit `y` of this string: · # Double the current integer y # Push bit `y` I* # Multiply it by the second input ^ # Bitwise-XOR the two together # (after the loop, the result is output implicitly) ``` [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/) v13.3+, 38 bytes ``` (F=2~FiniteField~+##;F@#2F@#)@"Index"& ``` Input `[a, b]`. [Version 13.3](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn133#107245402) introduced [`FiniteField`](https://reference.wolfram.com/language/ref/FiniteField.html), which is nicer to golf with than [`FiniteFields`GF`](https://reference.wolfram.com/language/FiniteFields/ref/GF.html). Getting an integer out of a `FiniteFieldElement` is still a little verbose, though. [![test cases](https://i.stack.imgur.com/m82r2.png)](https://i.stack.imgur.com/m82r2.png) [Answer] ## Ruby, ~~76~~ ~~75~~ 73 bytes ``` a,b=$*.map{|x|x.to_i} o=0 while(b>0) o^=a&-(b&1) a<<=1 b>>=1 end puts(o) ``` # Ruby, 60 bytes (function only, no I/O) ``` def t(a,b) o=0 while(b>0) o^=a&-(b&1) a<<=1 b>>=1 end t end ``` [Answer] ## Dart, ~~34~~ 32 bytes ``` m(a,b)=>a<1?0:a%2*b^m(a~/2,b*2); ``` Straight-forward recursive implementation. [Answer] # gnuplot, 29 bytes ``` m(a,b)=a<1?0:a%2*b^m(a/2,b*2) ``` just like in Dart (see above) [Answer] # GNU Assembler(x86\_64 Mac OS X), 97 bytes This is a proper function that can be called from C: ``` .text .globl _f _f: movq %rdi,%xmm0;movq %rsi,%xmm1;pclmulqdq $0,%xmm1,%xmm0;movq %xmm0,%rax;ret ``` & can be tested with this C program: ``` #include <stdio.h> int f(int a, int b); #define p(a,b) printf("%d %d %d\n", a, b, f(a, b)) int main(void) { p(0,1); p(1,2); p(9,0); p(6,1); p(3,3); p(2,5); p(7,9); p(13,11); p(5,17); p(14,13); p(19,1); p(63,63); } ``` Note that on Mac OS X, you have to use `clang -x c` to compile it as C & not C++. For linux(if I remember right), the code would be 95 bytes: ``` .text .globl f f: movq %rdi,%xmm0;movq %rsi,%xmm1;pclmulqdq $0,%xmm1,%xmm0;movq %xmm0,%rax;ret ``` Strangely enough, this version is actually longer than defining the function in inline assembly, but that one was longer than the pure C solution we already have, so I decided to try assembly. ### edit If it's counted by the assembled size(excluding any labels &c.), then it's # x86\_64 Assembler, 22 bytes: ``` 0: 66 48 0f 6e c7 movq %rdi, %xmm0 5: 66 48 0f 6e ce movq %rsi, %xmm1 a: 66 0f 3a 44 c1 00 pclmullqlqdq $0, %xmm1,%xmm0 10: 66 48 0f 7e c0 movq %xmm0, %rax 15: c3 ret ``` [Answer] # [R](https://www.r-project.org/), 53 bytes ``` f=function(x,y)`if`(y,bitwXor(x*y%%2,2*f(x,y%/%2)),0) ``` [Try it online!](https://tio.run/##bY/LCsIwEEX38xVFKGTkgibRlgr9D0FEY2ghEB80EZuvr7YV3Lg6cOfMZaYbrOm65JsQTtenj@7hUz20dfu82ejuN9Ej8dm1Z5FwcfG1v3eiX6Y8V1DLdpzmq1wxY81/mkSFkomsiWJBxvssNiFm1oQm7IgWTME8Rs27EAVZsYZkfCihJlaf2pHFN9fQExW2E0tUs68hZ2MLWc7RBnKWZfXdLjQKzcT4Pcd/bu4P8oj@oI7MNLwB "R – Try It Online") [Answer] # [JavaScript (Node.js)](https://nodejs.org), 29 bytes ``` f=(x,y)=>x&&f(x>>1,y)*2^x%2*y ``` [Try it online!](https://tio.run/##RczNCoJAEADg@zzFXBJXTHZ2c01ifZEyVkzDMJWU2J7eRgg6zN/HzDyqdzXXr25a9sN4a9a1taGPP8IWPgja0BcF8RSpq9@p6LOenERCCYQKFeQouTcsBjRqTEFhiiQhwxyNBtJIhKQyYM3wmAIdkDHjBzlfUQ5G8yKbSV0yT323uMvgkmc1hd4WHP6n6OJ6HOaxb5J@vIf@LMvYn6mMF9v@J8FZbWa3KoRYvw "JavaScript (Node.js) – Try It Online") Similar to <https://codegolf.stackexchange.com/a/50246/> [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes ``` ₌0b(dn⁰*꘍ ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwi4oKMMGIoZG7igbAq6piNIiwiIiwiMTMsIDE0XG4wLCAxXG4xLCAyXG4xMywgMTFcbjE5LCAxXG42MywgNjNcbjIsIDUiXQ==) Ports the 05AB1E answer, so go upvote that too ## Explained ``` ₌0b(dn⁰*꘍ ₌0b # Push 0 and the binary of the first input ( # to each bit: d # double the top of the stack n⁰* # multiply the bit by the second input ꘍ # and bit xor ``` [Answer] # [Pyt](https://github.com/mudkip201/pyt), 37 bytes ``` ɓąƖĐŁř⁻↔2⇹^**ĐŁ2%¬?ŕ:ŕÁ0á;ĐŁ`ŕʁ⊻ĐŁ⁻łŕ ``` [Try it online!](https://tio.run/##K6gs@f//5OQjrcemHZlwtPHozEeNux@1TTF61L4zTksLJGSkemiN/dGpVkenHm40OLzQGiSWcHTqqcZHXbtBbKCGo01Hp/7/b2jCZWgMAA "Pyt – Try It Online") Takes two integers a,b on separate lines The following is worked on a=13, b=14 | Code | Stack | Description | | --- | --- | --- | | ɓąƖ | [1,1,0,1] | Pushes the **ą**rray corresponding to the **ɓ**its of 13 | | ĐŁř⁻↔2⇹^\* | [8,4,0,1] | Converts array to corresponding powers of 2 | | \* | [112,56,0,14] | Multiplies the array by 14 | | ĐŁ2%¬? | [112,56,0,14], True | does the array have an even length? | | ŕ | [112,56,0,14] | If so, pop the boolean check | | :ŕÁ0á | (skipped in this run) | Otherwise, append a 0 to the array | | ;ĐŁ`ŕʁ⊻ĐŁ⁻ł | [70], 0 | **ʁ**educe the array using XOR (**⊻**) while the **Ł**ength of the resulting array is greater than 1 | | ŕ | [70] | **ŕ**emove the 0; implicit print | ]
[Question] [ ## Task Given \$n\$, output position of the last odd digit in the decimal representation of \$2^n\$ (counting from the end). ## Rules * There are no odd digits for \$n=1,2,3,6,11\$ \$(2, 4, 8, 64, 2048)\$ - you may output anything that is not a positive integer for them (no need to be consistent). * You choose whether to handle \$n=0\$. * Standard [sequence](/questions/tagged/sequence "show questions tagged 'sequence'") [I/O rules](https://codegolf.stackexchange.com/tags/sequence/info). * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"). ## Test-cases ``` n answer (2^n) 1 NA 2 2 NA 4 3 NA 8 4 2 16 5 2 32 6 NA 64 7 3 128 8 2 256 9 2 512 10 4 1024 11 NA 2048 12 2 4096 13 2 8192 14 3 16384 15 3 32768 16 2 65536 17 2 131072 18 3 262144 19 6 524288 20 2 1048576 ``` *Inspired by [this Mathematics SE post](https://math.stackexchange.com/a/4714518/347293) and comments on [OEIS A068994](https://oeis.org/A068994).* [Answer] # JavaScript (ES7), 35 bytes Returns `NaN` if there's no odd digit. Supports \$n=0\$. ``` n=>(g=k=>k?k&1||1+g(k/10):+g)(2**n) ``` [Try it online!](https://tio.run/##FcZBDoIwEAXQPaf4KzNDFShLcfAsBGiDJTMGjBvx7DW@1XsM72Eft@X5uqhNcw6SVXqKkqRP93Tyx@FdpFT7hq8uMrVlqZyDbaQQNB0UN0H7j3OMTwGMprutc7VaJD0jkDJ3xTf/AA "JavaScript (Node.js) – Try It Online") ### Commented ``` n => ( // n = input g = k => // g = recursive function looking for an odd digit in k k ? // if k is not zero: k & 1 || // stop and return 1 if the least significant bit is set 1 + // otherwise, increment the final result g(k / 10) // and do a recursive call with k / 10 // note that we rely on arithmetic underflow to stop the // recursion if the LSB is never set : // else: +g // no odd digit found: return NaN, which will propagate // all the way to the initial call )(2 ** n) // initial call to g with k = 2 ** n ``` --- # JavaScript (ES7), 30 bytes A simpler version that throws an error if there's no odd digit. ``` n=>(g=k=>k&1||1+g(k/10))(2**n) ``` [Try it online!](https://tio.run/##PYxBDoIwFET3nGLCQvtpVGCL5S5NLaiQX/IhJgY4ey0bM5tJ3pt524@dnbym5cLh4WNnIptW9WYw7XCqtq3SvRpuVUmk6qJgil0QxTAoGzDuBvVRtCasGbDIFyvEz0noFFODHc4u7qk8/UHuRYLkiaWFCzyH0V/H0KdbjXOKPkRqsj3@AA "JavaScript (Node.js) – Try It Online") [Answer] # Excel, 50 bytes ``` =XMATCH(1,MOD(MID(2^A1,1+LEN(2^A1)-ROW(A:A),1),2)) ``` Input in cell `A1`. Outputs an `#N/A` error if no odd digit exists. *Edit: JvdV's wonderfully creative use of passing an array to `TEXTBEFORE` means that we can employ alternatives such as:* ``` =1+LEN(TEXTAFTER(2^A1,{1,3,5,7,9},-1)) ``` *for just 38 bytes.* [Answer] # Ruby, 31 bytes ``` ->n{(2**n).digits.index &:odd?} ``` 0-indexed; no result returns `nil`. I've been programming Ruby for about a year, and really enjoying it. As this example shows, it's possible to be concise and human readable. `->n{ ... }` is the syntax for creating a lambda. It's not super elegant, but most of the time you're writing methods and not lambdas in Ruby anyways. `.digits` already returns an array of digits starting with the least significant. `.index` will search for an item if given an item, but it can also take a tester function, as it does here. `.odd?` returns whether a number is odd. Prefacing a symbol with `&` creates a function that calls the method associated with that symbol. So `&:odd?` is equivalent to `->(number) { number.odd? }`. [Answer] # [Python 2](https://docs.python.org/2/), 41 bytes ``` f=lambda n,c=1:2**n/c%2or-~f(n,c%2**n*10) ``` [Try it online!](https://tio.run/##Rcq7DoIwGIbh/buKLoRDMPKXMwmbrl6AG2IJTbBtaj2weOsVJ5d3ePKa1c1ace@nfhlul@vAVDr21PEkUfsx4NruPlO0WfCThLLYv2a5CEYdmLPrVmasVI5NkVTm4aI4BhPvURjHzsLqg3zKu9TqaK22/zs8aSVCT@DIUaBEhRoNWlAGIhAH5aACVIIqUA1qQC149gU "Python 2 – Try It Online") Function that terminates with `ZeroDivisionError` for no output. This happens when the power-of-10 `c` that we're using as a divisor is a multiple of `2**n`, which causes `c%2**n` to reset to 0. This first happens for `c=10**n`, which is bigger than `2**n` so we're already out of digits. A probably-cheating version instead terminates with `RuntimeError` for exceeding the maximum recursion depth, though usually we pretend this doesn't exist since it would also trigger for very large inputs that should produce an output. **36 bytes** ``` f=lambda n,c=1:2**n/c%2or-~f(n,c*10) ``` [Try it online!](https://tio.run/##Rcq7DoIwGIbh/buKfzEcopG/nEkYXR28A8QSmkDbNCXK4q1XNpd3ePLa3c9GixCmfhnW52sgfR577kSa6ut4EsZdvlN8WMpZEt6zWiRxB/JuP0rWKe1pipW2m4@TBCQ/o7SeHpv2apU354z7j9HdaBkFhkCOAiUq1GjQgjMwgwU4BxfgElyBa3ADbiGyHw "Python 2 – Try It Online") [Answer] # [Julia 1.0](http://julialang.org/), 32 bytes ``` !x=prod(findmax(digits(2^x).%2)) ``` [Try it online!](https://tio.run/##yyrNyUw0rPj/X7HCtqAoP0UjLTMvJTexQiMlMz2zpFjDKK5CU0/VSFPzf0FRZl5JTp6ehoaBlZGBpoKerZ2CniKEo/kfAA "Julia 1.0 – Try It Online") 1-indexed, works for `0`, and returns `0` for no odd digit [Answer] # Haskell, 46 bytes ``` (succ<$>).findIndex(odd.ord).reverse.show.(2^) ``` [Try it online!](https://tio.run/##VY69bsMwDIT3ewoOGeyhgun8B2mWZinQTt0LqBYTC7GlQFLS9uld2ejQcjp@4N2x1fEiXTcMtr/6kOiok1ZPrQ74C15sTP/Aq/7@EKDX1tEjGQ/K00miINo8u5ThqGi3o7cUrDvTw4Eyn@6sSxJ0k2hGN9dZJ5EU9fpKRWz9Z9an4Pupgaq8FfHWNPvZoVQn63K4ka/CG6N8MKUKcpcQRY1OVdTvZTb8/jDKKX0YKjBqzLHAEiusscEWnCGDa/AcvAAvwSvwGrwBb1FX@AE) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~8~~ 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` oRÅΔÉ ``` 0-indexed. Outputs `-1` if there are no odd digits. Also works for \$n=0\$. [Try it online](https://tio.run/##yy9OTMpM/f8/P@hw67kphzv//ze0BAA) or [verify the first 26 test cases](https://tio.run/##yy9OTMpM/W9kemySn72SwqO2SQpK9n7/84MOt56bcrjzf63OfwA). **Original 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) approach:** ``` oSÉRƶ0Kß ``` 1-indexed. Outputs an empty string if there are no odd digits. Also works for \$n=0\$. [Try it online](https://tio.run/##yy9OTMpM/f8/P/hwZ9CxbQbeh@f//29oCQA) or [verify the first 26 test cases](https://tio.run/##yy9OTMpM/W9kemySn72SwqO2SQpK9n7/84MPdwYd22bgfXj@f53/AA). **Explanation:** ``` o # Push 2 to the power of the (implicit) input-integer R # Reverse it ÅΔ # Find the first 0-based index that's truthy for, or -1 if none are: É # Is the digit odd? # (after which the result is output implicitly) ``` ``` o # Push 2 to the power of the (implicit) input-integer S # Convert it to a list of digits É # Check for each digit whether it's odd (1 if odd; 0 if even) R # Reverse this list ƶ # Multiply each value by its 1-based index 0K # Remove all 0s ß # Pop and keep the minimum, or an empty string if the list was empty # (which is output implicitly as result) ``` [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal) `gA`, ~~7~~ 5 bytes ``` Ef∷ṘT ``` [Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJnQSIsIiIsIkVm4oi34bmYVCIsIiIsIjFcbjJcbjNcbjRcbjVcbjZcbjdcbjhcbjlcbjEwXG4xMVxuMTJcbjEzXG4xNFxuMTVcbjE2XG4xN1xuMThcbjE5XG4yMCJd) `-2` thanks to @lyxal! [Answer] # [Arturo](https://arturo-lang.io), 40 bytes ``` $=>[index reverse map digits^2&=>[&%2]1] ``` [Try it!](http://arturo-lang.io/playground?LnPBpN) 0-indexed; no result returns `null`. ``` $=>[ ; a function where input is assigned to & ^2& ; two raised to the input power digits ; get its digits as a list map ; map over the digits... =>[&%2] ; ...modulo two reverse ; reverse index ... 1 ; get the index of the leftmost 1 ] ; end function ``` [Answer] # [Python 2](https://docs.python.org/2/), 53 bytes ``` lambda n:`[int(c)%2for c in`2**n`[::-1]]`.find('1')/3 ``` An unnamed function that accepts a non-negative integer, \$n\$, and returns the 0-indexed position of the last odd digit of \$2^n\$, or \$-1\$ if all the digits are even. **[Try it online!](https://tio.run/##FczNCoQgGEbhfVfxbUKNfsiJFkLdSAVajZNQbyFtunrHzvrhXM@9nZDBdmPYzTGvhqD04HDzRaTSnp4WctAyy6AHpYp6mnRpHVbOaiaqT3gJIiFv8PvythEqodjl44SQE@t6lpPlEOEP "Python 2 – Try It Online")** Note: this actually gets scuppered at \$n=63\$ when long ints come into play and the representation of `2**n` acquires a trailing `L`. However, this is about where floating point errors would creep in with division-based methods anyway (this errors while they may start giving incorrect results). This can be dealt with by inserting `if'L'>c` between the `]]` for \$60\$. [Answer] # [Python 2](https://docs.python.org/2/), ~~46~~ ~~45~~ 53 bytes *-1 byte thanks to @The Thonnu* *+8 bytes so it always terminates (added `%(i-2*x)`)* ``` i=2**input() x=0 while~i/10**x%2%(i-2*x):x+=1 print x ``` [Try it online!](https://tio.run/##K6gsycjPM/r/P9PWSEsrM6@gtERDk6vC1oCrPCMzJ7UuU9/QQEurQtVIVSNT10irQtOqQtvWkKugKDOvRKHi/39DAwA "Python 2 – Try It Online") Zero indexed, gives a `ZeroDivisionError` for \$n=1,2,3,6,11\$. [Answer] # [PARI/GP](https://pari.math.u-bordeaux.fr), 36 bytes ``` n->valuation(x*Pol(digits(2^n)%2),x) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m728ILEoMz69YMHiNAXbpaUlaboWN1XydO3KEnNKE0sy8_M0KrQC8nM0UjLTM0uKNYzi8jRVjTR1KjRhatPyizTyFGwVDHQUjIC4oCgzrwQooKSgawck0jTyNDWhahcsgNAA) [Answer] # [Thunno 2](https://github.com/Thunno/Thunno2) `M`, 5 [bytes](Https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md) ``` OdɗrV ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m728JKM0Ly_faGm0kq9S7IKlpSVpuhbL_FNOTi8KW1KclFwMFVqwyNAAwgIA) or [verify the first 20 test cases](https://ato.pxeger.com/run?1=m728JKM0Ly_faMEqI4MjG13UObUPLVpaWpKma7HMP-Xk9KKwJcVJycWLfQ8thoguWAChAQ) 0-indexed. Outputs `[]` if there is no odd digit. Works for \$n=0\$. #### Explanation ``` OdɗrV # Implicit input O # Push 2 ** input d # Convert to digits ɗ # Each mod 2 r # Reverse the list V # Truthy indices # Take the minimum # Implicit output ``` [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~49~~ 47 bytes ``` #&@@Reverse@IntegerDigits[2^#]~Position~_?OddQ& ``` [Try it online!](https://tio.run/##FcixCsIwEADQ3a8oBDIplI6FagYRnFrbMUQJ6SU9sBdITsf8esQ3vt3yBrtldLb6ZmiqkErN8IWUQd2JIUC6YkDOunsKU6aYkTFSeV3GdX3IOnqvbx9y/@z7/I5M5jAlJNbidPZKGFkWZ6nMlgLo9ti1pv4A "Wolfram Language (Mathematica) – Try It Online") `-2` thanks to @att [Answer] # [Bash](https://www.gnu.org/software/bash/), 42 bytes ``` i=$[2**n] i=${i#${i%[13579]*}}; echo ${#i} ``` [Try it online!](https://tio.run/##S0oszvifll@kkKeQmadQbainZ2RQa62Qks@loFBQlJlXkqagrmqUElOirqCS9z/TViXaSEsrL1YByKrOVAZi1WhDY1Nzy1itWqC21OSMfAWVauXM2v8p@Xmp/wE "Bash – Try It Online") [Answer] # [R](https://www.r-project.org), 30 bytes ``` \(n)match(1,2^n%/%10^(0:n)%%2) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m72waMHynPyU_AIj26WlJWm6FvtiNPI0cxNLkjM0DHWM4vJU9VUNDeI0DKzyNFVVjTQhijYXJxYU5FRqGFoZGehAtENlFiyA0AA) [Answer] # [MATL](https://github.com/lmendo/MATL), 8 bytes ``` WVooPfX< ``` Output is empty if no solution. [Try it online!](https://tio.run/##y00syfn/PzwsPz8gLcLm/38jAwA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmv5PA/PCw/PyAtwua/uq6ueoTLf0MrIwMA). ### How it works ``` W % Implicit input. 2 raised to that V % Convert to char vector o % Convert each char to code point o % Modulo 2 P % Reverse f % Find: gives 1-based indices of non-zeros X< % Minimum. Implicit display ``` [Answer] # [Nibbles](http://golfscript.com/nibbles/index.html), 7 bytes (14 nibbles) ``` /`?\`@~^2$%$~ ``` Returns `0` if there are no odd digits. ``` /`?\`@~^2$%$~ # full program $ # with implicit arg added; `? # find the indices of elements that are truthy by %$~ # modulo 2 (default) # of \ # reverse of `@~ # digits in base 10 (default) of ^2$ # 2^input / # finally fold over this list from right, returning # left element each time # (so returns first element) ``` [![enter image description here](https://i.stack.imgur.com/dNlH9.png)](https://i.stack.imgur.com/dNlH9.png) [Answer] # [Python 2](https://docs.python.org/2/), 58 bytes ``` lambda n:"".join(`int(i)%2`for i in`2**n`[::-1]).find("1") ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m728oLIkIz_PaMHiNNuYpaUlaboWN61yEnOTUhIV8qyUlPSy8jPzNBIy80o0MjVVjRLS8osUMhUy8xKMtLTyEqKtrHQNYzX10jLzUjSUDJU0oSaogZRVAJUpFCXmpadqGOooGBlqWnEpKBQUAY1SqNBRSNOogKpesABCAwA) # [Python 3](https://www.python.org), 65 bytes ``` lambda n:"".join(str(int(i)%2)for i in str(2**n)[::-1]).find("1") ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3HXMSc5NSEhXyrJSU9LLyM_M0ikuKNDLzSjQyNVWNNNPyixQyFTLzFECiRlpaeZrRVla6hrGaemmZeSkaSoZKmlCD1EFKK0BKixLz0lM1DHUUjAw1rbgUFAqKQMZV6CikaVRoQpUvWAChAQ) [Answer] # [Scala](http://www.scala-lang.org/), 53 bytes Thanks for the comment to save so many bytes. [Try it online!](https://tio.run/##LY1BS8NAEIXv@ysepcIu1iXmGGyh3jx4EvEgUsZ0E1fS2TA7VKXkt8dt9TDDvHkf7@WWBprjYUyiyGfhiTkpaUzsleIgoTUmvX@GVvFIkXEywD50OBRhSfrcYCtCP69PKpH7N9fgmaNifSGBLoll3N2ggibUlfv/A2PhdWCbF0teYXnqLLtp4S7uZM5jjjSgax5Y15uySuZ8H/ty2dr5MX3ZnfOa/oq9hGOQHHzkffh@@QgS7O6q3lTu@naezPwL) 1-indexed. "return 0" means missing odd numbers. ``` BigInt(2).pow(_).toString.reverse.indexWhere(_%2>0)+1 ``` [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 13 bytes ``` ;2^₍↔i%₂ʰℕ₁ʰt ``` [Try it online!](https://tio.run/##ASsA1P9icmFjaHlsb2cy//87Ml7igo3ihpRpJeKCgsqw4oSV4oKByrB0//8xMP9a "Brachylog – Try It Online") ### Explanation ``` ;2^₍ 2^Input ↔ Reverse the number i Take a [Digit, Index] of that number %₂ʰ [Digit mod 2, Index] ℕ₁ʰ Digit mod 2 must be in [1,+inf) t Output = Index ``` `↔` would mess up indexing in case we reverse a number that ends with 0, but powers of 2 cannot have trailing 0. [Answer] # [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 46 (40) bytes 40 bytes if input is allowed to be \$n = 2^t\$ instead of \$t\$ (switched notation). After solving, I saw xnors answer which I think is similar but deals with the power of 2. ``` f=lambda n,j=1:j if n%2else f(n//10,j+1) ``` [Try it online!](https://tio.run/##DcTRCsIgFADQZ/2K@xLqEpYbgxD8GGtayroTvQ@N6Nut83DKQc8d52upvUe3@ddt9YA6O2MzpAh4msLWAkSJ42guOp@N6nGvQJAQqsdHkEbDvCjLGdXjPys1IckoPlFOw0Dqq4WGgCs4IRRn4X0PhWzxrfH@Aw "Python 3.8 (pre-release) – Try It Online") **26** from xnor by accumulating using 1+f instead of j. ``` f=lambda n:n%2or-~f(n//10) ``` Using this in a \$2^\cdot\$ wrapper gives: **43** 58: ``` lambda t:f(2**t) f=lambda n:n%2or-~f(n//10) ``` # [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 46 bytes ``` f=lambda n,j=0:j if 2**n//10**j%2else f(n,j+1) ``` [Try it online!](https://tio.run/##XcpBDoMgEEDRNZ5iNo1ATRSJSUPiYWiFFmJHQmdRYzw7Zd3N37yfdnptqG8pl@Ln1b7viwXs4jyYCMHDKCX2vRqkjJfRrR8Hnle@KlH8loEgIGSLT8dVB3oSpmGU91qWckDivj3I6OU0cHhO4mxFw9z34RKZ/wFtxfID "Python 3.8 (pre-release) – Try It Online") 37 from xnor by accumulating using 1+f instead of j. (Identical except for `n//j` since python 3) ``` f=lambda n,j=1:2**n//j%2or-~f(n,j*10) ``` [Answer] # [Piet](https://www.dangermouse.net/esoteric/piet.html) + [ascii-piet](https://github.com/dloscutoff/ascii-piet), 154 bytes (11×14=154 codels) ``` tldfm?liafqaqQ ? i I rrrjje e A ? e R biqaasccmu _ Saeeumcccccc?sVi qq Vt qq sss Nd qq a Clliqqqq??qfaks ``` Infinite loop for `n = 0, 1, 2, 3, 6, 11, ...` (No odd digits in `n^2`). Outputs correctly for anything with an odd digit. If you want to see how it works, make sure to add input `n` before executing. [Try Piet online!](https://piet.bubbler.one/#eJx1kcEOgjAQRP9lz3PotqVUfoV4MFgTElQS9GT8d7ttQ6pgdpIuy2N2gBcN93Ogru8VHFiDDZjBXq4U2MnAymlhj-j5gF_5qldrk1mdysfitsLW3hVLv3HdsLqgVrakRFExbJPEaNY8-zH3ZAR1aUeL5FLsannZIqD6etZKiK1pBHc5kyqPWnHT_9xcdaOJpMu_wpaSb-XlNILKOxxBS5ipIwJN4zU3YRmou5ymJYDG2_x8yPj9AYFFaAM) ![](https://piet.bubbler.one/api.svg?11,14,0,6,12,13,11,18,6,10,16,13,4,16,4,4,19,19,19,19,19,19,18,19,19,19,10,19,19,10,19,2,2,2,8,8,17,19,19,19,17,19,19,16,19,18,19,19,19,19,19,19,19,19,17,19,19,2,19,14,10,4,16,16,3,15,15,11,5,19,19,18,19,19,19,19,19,19,19,19,19,19,19,19,19,3,16,17,17,5,11,15,15,15,15,15,15,18,3,1,10,19,19,19,19,4,4,19,19,19,19,19,19,1,0,19,19,19,19,4,4,19,3,3,3,19,19,7,12,19,19,19,19,4,4,19,19,16,19,19,19,15,6,6,10,4,4,4,4,18,18,4,13,16,9,3) [Answer] # [Husk](https://github.com/barbuz/Husk), 8 bytes ``` V%2↔d`^2 ``` [Try it online!](https://tio.run/##yygtzv6f@6ip8eGOxUYG/8NUjR61TUlJiDP6/x8A "Husk – Try It Online") ``` V # Index of first element that is truthy when %2 # modulo 2 ↔ # of the reverse of d # the decimal digits of `^2 # 2^input ``` [Answer] # [C++ (gcc)](https://gcc.gnu.org/), 56 bytes ``` [](int&n){int p=1;for(n=1<<n;n%2-!!n;n/=10)++p;n=n?p:0;} ``` [Try it online!](https://tio.run/##VVBhT4MwEP3Or7hhNCAjAlMTaYsfjL9i4wMpZRK3QmgxRMJfF48yMtaU9t1794678rr2j5yPWasrKNi4T51S6gfp9nhBzUJSVI0jWUipJPI@8jcbvJ9YGLieVxPJ5HsdB2QYiXVXSn5qcwG0rJRuRHZOVtyP4LpqEmsqe85K6bi9BbiUzuN4FilqCYiuxkjkwKAPtxAsOzIbwW7Bzyt@t@IRvCIYiPkBr6TSwL@y5hFPwb9Fs0@n4vah@4wO3dsHfi/2Ftbxzr64cXqYXgRKmYsObQG5QDq3rspf4Sw9uwQ8z8guzONNa7JrtBqB3NAC6cW8N3p6TSgc7d6mK0zXV8o0wKtWA6VLVxRs8BM8EKk5NHgZXTCmUsMfpD2XGqxh/OPFKTuq0fexKDvK1vOi7B8 "C++ (gcc) – Try It Online") [Answer] # [Retina](https://github.com/m-ender/retina/wiki/The-Language), 39 bytes ``` ~`.+ .+¶$$.($&*$(2$*)_ -1L$`[13579] $.' ``` [Try it online!](https://tio.run/##BcGxDcIwFEXR/s7xAZMoVp4dx/EENGyAEKagoKGIqBkrA2Qxc876@r4/T7WDu9T2q77H9/tm5p0dO3PBuvODQVerN8WUyx3zp9ZEIDKRmMksFDQioYAimlBCM8poQYUw/gE "Retina – Try It Online") Link includes test cases. 0-indexed. Outputs nothing if no odd digit exists. Explanation: ``` .+ .+¶$$.($&*$(2$*)_ ``` Replace the input with code to calculate that power of `2`. (I could save two bytes by removing the `)_` at the end but this actually prevents a crash in Retina which I feel is not an ideal way to handle zero input.) ``` ~` ``` Execute the code to generate the power of `2`. ``` -1L$`[13579] ``` Match the last odd digit. ``` $.' ``` Output the number of digits after it. [Answer] # [Japt](https://github.com/ETHproductions/japt) [`-g`](https://codegolf.meta.stackexchange.com/a/14339/), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) 0-indexed, returns `undefined` if there's no odd digits ``` õ!²Ìì Ôðu ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWc&code=9SGyzOwg1PB1&input=MTc) ``` õ!²Ìì Ôðu :Implicit input of integer U õ :Range [1,U] !² :Raise 2 to the power of each Ì :Last element ì :Digit array Ô :Reverse ð :0-based indices of elements that truthy (1) u : Mod 2 :Implicit output of first element ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 12 bytes ``` I⌕⮌﹪↨X²Nχ²¦¹ ``` [Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwy0zL0UjKLUstag4VcM3P6U0J1/DKRHIDsgvTy3SMNJR8MwrKC3xK81NAnI1NXUUDA2AhBGYpampaf3/v6Hhf92yHAA "Charcoal – Try It Online") Link is to verbose version of code. 0-indexed. Outputs `-1` if no odd digit exists. Explanation: ``` ² Literal integer `2` X Raised to power N Input integer ↨ Converted to base χ Predefined variable `10` ﹪ Vectorised modulo ² Literal integer `2` ⮌ Reversed ⌕ Find index of ¹ Literal integer `1` Implicitly print ``` Actually outputting the last odd digit also takes 12 bytes: ``` FIX²N¿﹪Iι²Pι ``` [Try it online!](https://tio.run/##S85ILErOT8z5/z8tv0hBwzmxuEQjIL88tUjDSEfBM6@gtMSvNDcptUhTU1MhM01Bwzc/pTQnH6IuU1NHwQgo7luaU5JZUJSZBxKy/v/f4L9uWQ4A "Charcoal – Try It Online") Link is to verbose version of code. Outputs nothing if no odd digit exists. Explanation: ``` FIX²N ``` Loop over the digits. ``` ¿﹪Iι² ``` If the digit is odd, then... ``` Pι ``` ... overprint any previous result. [Answer] # [Desmos](https://desmos.com/calculator), 50 bytes ``` I=[0...nlog2] f(n)=I[mod(floor(2^n/10^I),2)=1].min ``` Counting starts from 0 instead of 1, which is allowed as per the OP. Outputs `undefined` for all-even digits. [Try It On Desmos!](https://www.desmos.com/calculator/u01kewkyao) [Try It On Desmos! - Prettified](https://www.desmos.com/calculator/a8tqzjvnbs) [Answer] # JavaScript, 61 bytes Nearly double the length of the [other JS answer](https://codegolf.stackexchange.com/a/261910/108556) (and a slightly more naive implementation), but spent a bit of time on it, so might as well post it. Returns `-0` when there is no odd digit. ``` n=>-(~(l=(z=[...2**n+'']).findLastIndex(i=>i%2))&&l-z.length) ``` [Attempt This Online!](https://ato.pxeger.com/run?1=LcxNCsIwEEDhvacYCraTxgbNyr_pXvAG4kJsWgNhBmwE6cKLuCmih_I2Fuzqe6v3fLNUrn8JfW6xLpZfYioLfGAg7OhgjLF5zjrLjsrUnqv9qY07rtwdPZV-apVK01B0Jjhu4kWNk1UtVwwuggeCxWZgS2DnQ2itJgBn4VaCM0Ea9KAhWSczEPRqHPT93x8) ]
[Question] [ Suppose you are stringing a strand of [Froot Loops](https://en.wikipedia.org/wiki/Froot_Loops) for a necklace, bracelet, shoelace, or whatever. There are 6 loop colors: **r**ed, **o**range, **y**ellow, **g**reen, **b**lue, and **p**urple. You want your strand to start with red at the very left and cycle in rainbow order going right, ending with purple. That is, you want to make it so your strand could be represented by the string `roygbp` repeated some number of times (possibly 0). The problem is, you've already strung your loops, and not in any particular order. Which loops should you eat and not eat so that you can maximize the number of correct rainbow cycles going from left to right, with the very first loop red and the very last loop purple? Write a program or function that takes in an arbitrary string of the characters `roygbp` and prints or returns a string of the same length with `e` in the place of loops to eat and `n` in the place of loops to not eat. For example, if your Froot Loop strand looked like [![random Froot Loop strand](https://i.stack.imgur.com/XyAos.jpg)](https://i.stack.imgur.com/XyAos.jpg) the input would be ``` gorboypbgbopyroybbbogppbporyoygbpr ``` and going from left to right we can find 3 complete `roygbp` rainbow sequences, but some of the loops need to be eaten away. Thus the output would be ``` eenenneennenennneeeeneennenennnnne ``` resulting in a perfect 3 cycle strand: [![3 rainbow cycle Froot Loop strand](https://i.stack.imgur.com/A8Z14.jpg)](https://i.stack.imgur.com/A8Z14.jpg) If there are no complete rainbow cycles in the input then the output would be all `e`'s and the strand ends up loopless. e.g. the input `proygb` has output `eeeeee`. Conversely, `proygbp` has output `ennnnnn`. You can assume all input strands have at least one loop. **The shortest code in bytes wins.** [Answer] # [Hexagony](https://github.com/mbuettner/hexagony), ~~920~~ ~~722~~ 271 bytes ***Six*** different types of fruit loops, you say? That is what Hexagony was *made* for. ``` ){r''o{{y\p''b{{g''<.{</"&~"&~"&<_.>/{.\.....~..&.>}<.._...=.>\<=..}.|>'%<}|\.._\..>....\.}.><.|\{{*<.>,<.>/.\}/.>...\'/../==.|....|./".<_>){{<\....._>\'=.|.....>{>)<._\....<..\..=.._/}\~><.|.....>e''\.<.}\{{\|./<../e;*\.@=_.~><.>{}<><;.(~.__..>\._..>'"n{{<>{<...="<.>../ ``` Okay, it wasn't. Oh god, what did I do to myself... This code is now a hexagon of side length 10 (it started out at 19). It could probably be golfed some more, maybe even to size 9, but I think my job is done here... For reference, there are 175 actual commands in the source, many of which are potentially unnecessary mirrors (or were added to cancel out a command from a crossing path). Despite the apparent linearity, the code is actually two-dimensional: Hexagony will rearrange it into a regular hexagon (which is also valid code, but all whitespace is optional in Hexagony). Here is the unfolded code in all its... well I don't want to say "beauty": ``` ) { r ' ' o { { y \ p ' ' b { { g ' ' < . { < / " & ~ " & ~ " & < _ . > / { . \ . . . . . ~ . . & . > } < . . _ . . . = . > \ < = . . } . | > ' % < } | \ . . _ \ . . > . . . . \ . } . > < . | \ { { * < . > , < . > / . \ } / . > . . . \ ' / . . / = = . | . . . . | . / " . < _ > ) { { < \ . . . . . _ > \ ' = . | . . . . . > { > ) < . _ \ . . . . < . . \ . . = . . _ / } \ ~ > < . | . . . . . > e ' ' \ . < . } \ { { \ | . / < . . / e ; * \ . @ = _ . ~ > < . > { } < > < ; . ( ~ . _ _ . . > \ . _ . . > ' " n { { < > { < . . . = " < . > . . / ``` ## Explanation I won't even try and begin explaining all the convoluted execution paths in this golfed version, but the algorithm and overall control flow are identical to this ungolfed version which might be easier to study for the really curious after I've explained the algorithm: ``` ) { r ' ' o { { \ / ' ' p { . . . . . . . . . . . y . b . . . . . . . . . . . . . . . ' . . { . . . . . . . . . . . . . . . \ ' g { / . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . > . . . . < . . . . . . . . . . . . . . . . . . . . . . . > . . ) < . . . . . . . . . . . . . . . / = { { < . . . . ( . . . . . . . . . . . . . . . . ; . . . > . . . . . . . . . < . . . . . . . . . . . . > < . / e ; * \ . . . . . . . . . . . . . . . . . . . @ . } . > { } < . . | . . . . . . . . . . / } \ . . . . . . . > < . . . > { < . . . . . . . . . . . . > < . . . . . . . . . . . . . . . | . . . . . . . . . . . . . . _ . . > . . \ \ " ' / . . . . . . . . . . . . . . . . . . \ { { \ . . . > < . . > . . . . \ . . . . . . . . . . < . . . . . . . * . . . { . > { } n = { { < . . . / { . \ . . | . > { { ) < . . ' . . . { . \ ' < . . . . . _ . . . > } < . . . | . . . . > , < . . . e . . . . . . . . . . . . . = . . } . . . . . . . . . > ' % < . . . . . . . . . . . . . & . . . | . . . . . _ . . } . . > } } = ~ & " ~ & " ~ & " < . . . . . . . . \ . . < . . . . . . . . . . . . . . . . } . . . . . \ . . . . . . . . . . . . . . . . . . . . . . . < . . . . . | . . . . . . . . . . . . . . . . . . = . . . . . . . . \ . . . . . . . . . . . . . . . . / . . . . . . . > . . . . . . . . . . . . . . . . < . . . . . . . . . . . . . . . . . . . . . . . _ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ``` Honestly, in the first paragraph I was only half joking. The fact that we're dealing with a cycle of six elements was actually a great help. The memory model of Hexagony is an infinite hexagonal grid where each edge of the grid contains a signed arbitrary-precision integer, initialised to zero. Here is a diagram of the layout of the memory I've used in this program: [![enter image description here](https://i.stack.imgur.com/PLCAg.png)](https://i.stack.imgur.com/PLCAg.png) The long straight bit on the left is used as a 0-terminated string `a` of arbitrary size which is associated with the letter **r**. The dashed lines on the other letters represent the same kind of structure, each one rotated by 60 degrees. Initially, the memory pointer points at the edge labelled **1**, facing north. The first, linear bit of the code sets the inner "star" of edges to the letters `roygbp` as well as setting the initial edge to `1`, such that we know where the cycle ends/begins (between `p` and `r`): ``` ){r''o{{y''g{{b''p{ ``` After this, we're back on the edge labelled **1**. Now the general idea of the algorithm is this: 1. For each letter in the cycle, keep reading letters from STDIN and, if they are different from the current letter, append them to the string associated with that letter. 2. When we read the letter we're currently looking for, we store an `e` in the edge labelled **?**, because as long as the cycle is not complete, we have to assume that we'll have to eat this character as well. Afterwards, we'll move around the ring to the next character in the cycle. 3. There are two ways this process can be interrupted: * *Either* we've completed cycle. In this case, we make another quick round through the cycle, replacing all those `e`s in the **?** edges with `n`s, because now we want that cycle to remain on the necklace. Then we move on to printing code. * *Or* we hit EOF (which we recognise as a negative character code). In this case, we write a negative value into the **?** edge of the current character (so that we can easily distinguish it from both `e` and `n`). Then we search for the **1** edge (to skip the remainder of a potentially incomplete cycle) before moving to printing code as well. 4. The printing code goes through the cycle again: for each character in the cycle it clears the stored string while printing an `e` for each character. Then it moves to the **?** edge associated with the character. If it's negative, we simply terminate the program. If it's positive, we simply print it and move on to the next character. Once we complete the cycle we go back to step 2. Another thing that might be interesting is how I've implemented the arbitrary-size strings (because it's the first time I've used unbounded memory in Hexagony). Imagine we're at some point where we're still reading characters for **r** (so we can use the diagram as is) and **a[0]** and **a[1](https://i.stack.imgur.com/PLCAg.png)** have already been filled with characters (everything north-west of them is still zero). E.g. maybe we've just read the first two characters `og` of the input into those edges and are now reading a `y`. The new character is read into the **in** edge. We use the **?** edge to check whether this character is equal to `r`. (There's a nifty trick here: Hexagony can only distinguish between positive and non-positive easily, so checking for equality via subtraction is annoying and requires at least two branches. But all the letters are less than a factor of 2 from each other, so we can compare the values by taking the modulo, which will only give zero if they are equal.) Because `y` is different from `r`, we move the (unlabelled) edge left of **in** and copy the `y` there. We now move further around the hexagon, copying the character one edge further each time, until we have the `y` on the edge opposite of **in**. But now there is already a character in **a[0]** which we don't want to overwrite. Instead, we "drag" the `y` around the next hexagon and check **a[1](https://i.stack.imgur.com/PLCAg.png)**. But there's a character there as well, so we go another hexagon further out. Now **a[2]** is still zero, so we copy the `y` into it. The memory pointer now moves back along the string towards the inner ring. We know when we've reached the beginning of the string, because the (unlabelled) edges between the **a[i]** are all zero whereas **?** is positive. This will probably be a useful technique for writing non-trivial code in Hexagony in general. [Answer] # [Hexagony](http://esolangs.org/wiki/Hexagony), 169 bytes I was inspired by [Martin Büttner’s answer](https://codegolf.stackexchange.com/a/57877/668) (it’s his esolang, too) and decided I can do it in size 8. (I’m convinced it’s possible in size 7, too, but it’s very difficult. I’ve already spent four days non-stop on this.) ``` r'.'o\|{##|_#{#>\_{b{"]_\..<>"<>\/><#y/''"_<.}]''/'\>)}}.\}}'{<"\\#_#/<|##|#@#"p><n'>"{,<##g#_/#'.\<\##'#{(.<#e;#"\##%\\(};/*#>.)\>##_/"{__\}#>}=\#>=<|>##)|###_'#\"{__\\ ``` Laid out hexagonally: ``` r ' . ' o \ | { # # | _ # { # > \ _ { b { " ] _ \ . . < > " < > \ / > < # y / ' ' " _ < . } ] ' ' / ' \ > ) } } . \ } } ' { < " \ \ # _ # / < | # # | # @ # " p > < n ' > " { , < # # g # _ / # ' . \ < \ # # ' # { ( . < # e ; # " \ # # % \ \ ( } ; / * # > . ) \ > # # _ / " { _ _ \ } # > } = \ # > = < | > # # ) | # # # _ ' # \ " { _ _ \ \ ``` The program does not actually use the `#` instruction, so I’ve used that character to show which cells are actually unused. Furthermore, every no-op cell that is traversed in only one direction is a mirror (e.g. `_` if traversed horizontally), so you know all the `.` characters are traversed in more than one direction. # Explanation At the start, we execute the sequence of instructions `r''o{{y''g{{b''p"")"`. These are strewn a bit haphazardly across the code because I squeezed them in after I wrote everything else. I use `]` to switch to the next instruction pointer a few times; this way I can essentially teleport to another corner of the hexagon. The entire rest of the program is executed by instruction pointer #3. The memory now looks as follows, with the important edges labeled with names I will use in this explanation: [![memory layout near start of program](https://i.stack.imgur.com/hx4Ec.png)](https://i.stack.imgur.com/hx4Ec.png) The labeled edges mean the following: * `in`: We use this edge to store a character we read from STDIN. * `%`: We use this edge to perform a modulo operation on the character read from STDIN (`in`) and the current “valid” character (`r`, `o`, etc.), which will be `0` if they are equal. I stole this trick from Martin Büttner’s answer, but the rest of the program is different. * `#`: For as long as we read “invalid” characters (i.e. colors we need to eat), we increment this edge. Thus, this edge remembers how many `e`s we need to output later. * `r?`: Always `0` except where the `r` (red) part is. This tells us when we’ve completed a cycle. The program proceeds thusly: * Keep reading characters. If it’s not the character we’re currently looking for, increment `#`. Otherwise move to the next segment of the memory in clockwise order. * When moving to the next segment, if `r?` is positive, we’ve made a whole revolution. Make a complete round and output `#` `e`s and 1 `n` per segment. This sets each `#` back to `0`. (The `e` is placed on an unlabeled edge, but for the `n` we misappropriate the `#` edge, which we set to `0` using a `*` (multiplication) afterwards, which works because we know that all the `%` edges are zero at this time.) * When reading a character, if it is not positive (i.e., EOF), go backwards through the circle and output `#`+1 `e`s until you get back to where `r?` is positive, then exit. After a complete run, the memory looks approximately as follows at the end. You will notice the edges containing `101` (the ASCII code of `e`); one of the `in` edges is `-1` (EOF); all the `#` edges are at 0; and the memory pointer ends at the positive `r?` edge. [![memory layout at end of program](https://i.stack.imgur.com/NhM5c.png)](https://i.stack.imgur.com/NhM5c.png) [Answer] # [Retina](https://github.com/mbuettner/retina), ~~148~~ ~~85~~ 79 bytes ``` $ #roygbp .(?<=(?=((?=.*#(\2?(.))).*?\3(?<=^\5())?)+.*\3$)(.*))\4 n #.* [^n] e ``` You can run this from a single source file with the `-s` interpreter flag. ## Explanation Let's get the simple stuff out of the way first: ``` $ #roygbp ``` Appends `#roygbp` to the end of the string, which we'll use to compute the cycle of letters dynamically. The next (long) step figures out which loops to keep and replaces them with `n`. We'll look into how this works in a bit. ``` #.* <empty> ``` This gets rid of our lookup helper at the end of the string. ``` [^n] e ``` This replaces all characters that weren't replaced in the second step with `e`, completing the transformation. Now let's go back to the second step. The basic structure uses a trick, which I [discovered a few months ago](https://codegolf.stackexchange.com/a/53763/8478) to replace selected characters in a global match: ``` .(?<=(?=...(?<=^\k<prefix>(?<flag>))?...)^(?<prefix>.*))\k<flag> ``` where `...` corresponds to an arbitrarily complex pattern. This matches the character to be replaced with `.` and then starts a lookbehind (which you should read from right to left). The lookbehind captures everything up to the matched character into a group `prefix`. Then it switches to a look*ahead*, which now starts from the beginning of the string and can contain a complex pattern. *After* the character which we want to replace in that pattern, we put an optional look*behind*, which checks if the `prefix` group matches here. If it does, it captures an empty string into the `flag` group. If it doesn't, because it's optional, it doesn't affect the state of the regex engine at all and is ignored. Finally, once the lookahead is matched successfully, only the `\k<flag>` at the end is left which only matches if the flag was set at some point during the computation. Now let's ungolf the long regex a bit by using named groups and freespacing mode: ``` . (?<= (?= (?: (?= .*# (?<cycle> \k<cycle>? (?<char>) ) ) .*? \k<char> (?<=^\k<prefix>(?<flag>))? )+ .* \k<char>$ ) (?<prefix>.*) ) \k<flag> ``` I hope you recognise the general outline from above, so we only need to look at what I filled in for `...`. We want to capture the next character in the cycle into the group `char`. We do this by also remembering the string from `#` to the current character in `cycle`. To get the next character, we use a lookahead to search for the `#`. Now we try to match `cycle` and then match the next character in `char`. This will usually be possible, unless `char` is the last character `p`. In this case, `\k<cycle>` will match the entire remainder of the string and there won't be a character left to capture into `char`. So the engine backtracks, omits the backreference to `cycle` and just matches the first character `r` instead. Now we've got the next character in the cycle in `char`, we search for next possible occurrence of that character with `.*?\k<char>`. These are the characters we want to replace, so we put the `prefix` check after it. These steps (find the next `char` in the cycle, search for the next occurrence of it, set flag if appropriate) are now simply repeated with a `+`. That's actually all there is to finding the cyclic subsequence, but we also need to make sure that we end on a `p`. This is fairly easy: just check that the value currently stored in `char` matches the `p` at the end of the string with `.*\k<char>$`. This also ensures that our lookup string isn't used to finish an incomplete cycle, because we need the trailing `p` for this check. [Answer] # Pyth, 31 bytes ``` :*lz\nhf!:jk.DzT"roygbp"kyUlz\e ``` Incredibly inefficient, explanation coming soon. `yUlz` generates all possible subsets of all possible indices of `z` (the input) in order. E.g. if the input is `abc`: ``` [[], [0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]] ``` Then `hf!` finds the first `T` in the above list such that `:jk.DzT"roygbp"k` is false. `.D` takes a string and list of indices, and deletes the elements at those indices. So `.D"abcd",1 3` is `"ac"`. Since `.D` returns a list (which should not be the case, will fix in future versions of Pyth), I use `jk` (`k` is `""`) to join it together back into a string. The `:_"roygbp"k` part replaces every instance of a cycle with the empty string. Since the empty string is false, the above paragraphs explain how I find the smallest set of indices needed to eat to get a string consisting only of cycles. `:*lz\n_\e` then turns that list of indices into an `nnnneeennene` string. [Answer] ## Python 2, ~~133 130 126~~ 121 bytes ``` r=n='' for c in input():r+='en'[c=='roygbp'[r.count('n')%6]] for c in r:n+=['e',c][n.count('n')<r.count('n')/6*6] print n ``` The first loop gets cycles, and the second removes an incomplete cycle Saved 3 bytes thanks to J F and 5 from DLosc [Answer] # Perl 5, ~~76~~ 65 bytes A pinch of pure undiluted regular expressions. First finds what shouldn't be eaten. What remains is eatable. ``` s/r(.*?)o(.*?)y(.*?)g(.*?)b(.*?)p/n$1n$2n$3n$4n$5n/g;s/[^n\s]/e/g ``` ### Test ``` $ perl -p fruitloops.pl <<<gorboypbgbopyroybbbogppbporyoygbpr eenenneennenennneeeeneennenennnnne ``` [Answer] # Lua, 101 bytes ``` s=arg[1]:gsub("r(.-)o(.-)y(.-)g(.-)b(.-)p.-","*%1*%2*%3*%4*%5*"):gsub("%w","e"):gsub("*","n")print(s) ``` Uses Lua patterns creatively; I think it's an interesting approach. It replaces all non-eaten characters with "\*"s, replaces all alphanumeric characters with "e"s, then replaces all "\*"s with "n"s. [Answer] # Javascript (ES6), 118 ``` a=>eval("b=[...a],d=0,e=b.map(f=>f=='roygbp'[d%6]?'n'[++d&0]:'e');for(i=e.length-1;i&&b[i]!='p';e[i--]='e');e.join``") ``` [Fiddle](http://jsfiddle.net/L5dv8nk3/) tested in Firefox. I hear Chrome supports arrow functions now but I haven't tested this in Chrome yet. Ungolfed: ``` input=>eval(" array = [...input], rainbow_index = 0, mapped = array.map( item=> item == 'roygbp'[rainbow_index%6] ? 'n'[++rainbow_index&0] : 'e' // when we encounter an item of the rainbow, do not eat and start using // the next rainbow item, otherwise eat ); // go through backwards and eat until we find a 'p' indicating the last // complete loop for(i = mapped.length - 1; i && array[i]!='p'; mapped[i--] = 'e'); mapped.join`` ") ``` [Answer] # gawk, 96 ``` {for(;c=substr("roygbp",++i,1);r=r"\\"i"n")p=p"([^"c"]*)"c;$0=gensub(p,r,"g");gsub(/[^n]/,"e")}1 ``` Constructs the search pattern `"([^r]*)r([^o]*)o([^y]*)y([^g]*)g([^b]*)b([^p]*)p"` and the replacement `"\\1n\\2n\\3n\\4n\\5n\\6n"`. After that replacement it declares everything food ("e"), that's not part of a complete rainbow. This combination automatically ensures, that no rainbows will be harmed during this operation, and no severed rainbows show up at the end. [Answer] # Pyth, 42 bytes ``` Jf-Z=+Zq@zT@"roygbp"ZUzs.e@"en"}k<J*6/lJ6z ``` Try it online: [Demonstration](http://pyth.herokuapp.com/?code=Jf-Z%3D%2BZq%40zT%40%22roygbp%22ZUzs.e%40%22en%22%7Dk%3CJ*6%2FlJ6z&input=gorboypbgbopyroybbbogppbporyoygbpr&debug=0) [Answer] # CJam, 41 bytes ``` 2r:R,m*{R.*s__,6/"roygbp"*=\,~*}$0="en"f= ``` Brute-force approach that tries all eat/not-eat variations and selects the one that results in the longest, valid necklace. Try it online in the [CJam interpreter](http://cjam.aditsu.net/#code=2r%3AR%2Cm*%7BR.*s__%2C6%2F%22roygbp%22*%3D%5C%2C~*%7D%240%3D%22en%22f%3D&input=gorboypbgbopyr). [Answer] # CJam, 50 bytes ``` l{"roygbp"T=={'nT):T;}{'e}?}%W%_'ne=6%{_'n#'et}*W% ``` [Try it online](http://cjam.aditsu.net/#code=l%7B%22roygbp%22T%3D%3D%7B'nT)%3AT%3B%7D%7B'e%7D%3F%7D%25W%25_'ne%3D6%25%7B_'n%23'et%7D*W%25&input=gorboypbgbopyroybbbogppbporyoygbpr) This is a little longer than some of the other submissions, but it is very efficient with linear complexity. It scans through the input string, and matches characters one by one. The core part of the algorithm is actually fairly compact. About half of the code is for removing the incomplete cycle at the end. [Answer] # C90, 142-146 bytes (down to 119, depending) Operates in linear time to efficiently eat those fruit loops that can't be part of a pretty rainbow. Then, a postprocess kills any partial loop at the end. Here are four versions: * Version 1 (146 bytes), call with `[name] [string]`: `main(int a,char**b){char*v=b[1],*s="roygbp",i=0,k=0;for(;v[i];++i)if(s[k]==v[i]){++k;k%=6;v[i]='n';}else v[i]='e';while(k-->0)v[--i]='e';puts(v);}` * Version 2 (142 bytes), call with `[name] [string] [rainbow order]`: `main(int a,char**b){char*v=b[1],*s=b[2],i=0,k=0;for(;v[i];++i)if(s[k]==v[i]){++k;k%=6;v[i]='n';}else v[i]='e';while(k-->0)v[--i]='e';puts(v);}` This allows you to define your own rainbow ordering with any colors you want so long as they aren't `n` or `e`. This actually makes the code shorter! * Version 3 (123 bytes), call like version 1: `main(int a,char**b){char*v=b[1],*s="roygbp",i=0,k=0;for(;v[i];++i)if(s[k]==v[i]){++k;k%=6;v[i]='n';}else v[i]='e';puts(v);}` This one gives you as much of your rainbow as possible! The incomplete trailing rainbows show promise! We shouldn't eat them! * Version 4 (119 bytes), call like version 2: `main(int a,char**b){char*v=b[1],*s=b[2],i=0,k=0;for(;v[i];++i)if(s[k]==v[i]){++k;k%=6;v[i]='n';}else v[i]='e';puts(v);}` Same as version 3, but MOAR RAINBOW TYPES! Minor limitation: machine must have signed chars (the general case), and string must be fairly short. Outputs a trailing `\n` for clarity. Version 1 is the only one that clearly passes the requirements, although version 2 is arguable. Versions 3 and 4 are less-correct (but still fun) interpretation of the question. [Answer] ## Pyth, 38 bytes I know this is significantly longer than orlp's answer, but this one runs in linear time :o) ``` u+G?qH@"roygbp"/G\n\n\e+_>_zJx_z\p*Jdk ``` Try it out [here](https://pyth.herokuapp.com/?code=u%2BG%3FqH%40%22roygbp%22%2FG%5Cn%5Cn%5Ce%2B_%3E_zJx_z%5Cp%2AJdk&test_suite=1&test_suite_input=gorboypbgbopyroybbbogppbporyoygbpr%0Aproygb%0Aproygbp&debug=1). In brief, this program replaces all characters after the final 'p' with spaces, then iterates over each character in the resulting string. If the character is the next in the 'roygbp' sequence, print 'n', otherwise print 'e'. ``` Implicit: z=input(), d=' ', k='' Jx_z\p Find number of chars after last p, store in J _>_zJ Take all but J chars of the input + *Jd Append J spaces u k Reduce on the above, starting with '' /G\n Count 'n' in output so far @"roygbp" Take relevant char from sequence string (modulus indexing) ?qH Does the current char equal the above? +G \n\e Select 'n' or 'e' as appropriate and append ``` I've struggled to find a shorter way to process the input string. `_>_zJ` in particular feels awkward, but `<Jz` doesn't give the required string when `J == 0`, i.e. when the input ends with a 'p'. [Answer] # Haskell, 138 bytes `g` does it. ``` f(c:r)(h:t)|c==h='n':(f(r++[c])t)|0<1='e':(f(c:r)t) f _""="" z 'n' 'n'='n' z a b='e' r=reverse g s=zipWith z(f"roygbp"s)(r$f"pbgyor"(r s)) ``` [Answer] # Javascript (ES6), ~~85~~ 82 bytes The "necklace must end in a purple" rule was originally a great hurdle, increasing my score from 66 to 125, but I found a shorter way over it (thankfully!). ``` s=>(i=j=0,s.replace(/./g,x=>s.lastIndexOf`p`>=j++&x=='roygbp'[i%6]?(i++,'n'):'e')) ``` ### Explanation: This code loops through each character in the input and replaces each with `r` or `e` with this logic: * If the character's position is <= the last position of `p`, AND the character is the next one in the rainbow, keep it (replace it with `n`). * Otherwise, eat it (replace it with `e`). ### Ungolfed: ``` function a(s) { var i=0, j=0, r=''; t = t.replace(/./g, function (x) { if (s.lastIndexOf('p') >= j++ && x == 'roygbp'.charAt(i)) { i++; i %= 6; return 'n'; } else { return 'e'; } }); return r; } ``` Suggestions welcome! [Answer] # Python 2, 254 bytes Loops! ``` i=raw_input();r='roygbp';l='r';d='' for n in i: if n==l:d+='n';l=r[(r.index(l)+1)%6] else:d+='e' d=list(d)[::-1];p=(r.index(l)+1)%6; for s in range(len(d)): if d[s]=='n'and p-1:d[s]='e';p-=1 if d.count('n')<6:print'e'*len(d) else:print''.join(d[::-1]) ``` Excuse the pun. :P ]
[Question] [ [Reproductive strategy of oozes](https://rpg.stackexchange.com/questions/4272/is-an-ooze-a-living-creature/4273#comment4503_4273) can be summarized as follows: > > o O 8 oo > > > A population of oozes at generation N is described by a string, for example: ``` ooooo88ooOoOo8Ooooo8OOoo8Oo8Oo8oo8oooooo8OOooO88o ``` To compute the population at generation N+1, take one character randomly, and replace it by the result of ooze evolution: * If `o`, replace by `O` * If `O`, replace by `8` * If `8`, replace by `oo` Generation 0 is the one-character string `o`. Your program or function should get a positive number N, and output the population of oozes at generation N. At each generation, each ooze should have the same chance (to within 1% accuracy) to evolve. Test cases (actual results may vary due to randomness): ``` 1 -> O 2 -> 8 3 -> oo 4 -> Oo 5 -> OO 10 -> OO8 20 -> oo8oooo 30 -> oOoooOO8O 100 -> 8o8oO8OOooOo8OOoo88oOO8OOO 200 -> 88OOo8oooo8OOoooOoOOO8O8OO88o8Oo8oooOooooooOo8OooO888 1000 -> 8Ooooo88OO8o8O8oooOOoOOO88oOoO88OOoO8OOOooOOo8OO88O8OO8OO8ooo8oOO8OoooO88OooooooooOo8oooOO8OO8Oo8Oooo8O88oooOooO8Oo8ooOOOOo8OooOo8OoooooooO8oOooooOooOO8oOO8ooo8Ooooo8ooo8ooOOooO8OOoO8oO8oo88ooo8oO8OO8o888oO8OOoO8o8ooO8O88OOOoO8oooO8OoOoOo88O88oo88ooo8oO8o8oOooOo ``` --- If your solution has running time of O(n), please specify it explicitly! [Answer] # [Python 3](https://docs.python.org/3/), 114 bytes ``` from random import* def f(n,s=b'o'):k=randrange(len(s));return n and f(n-1,s[:k]+b'oO8o'[-~s[k]%3::3]+s[k+1:])or s ``` [Try it online!](https://tio.run/##FYwxDsIwDEV3TuEFNaGulBAqQVDPwAGqDKCmUJU6VRIGFq4e3MH@3/rve/3mVyBTyhjDAvFOA8u0rCHmw27wI4yCMHWPKlTSzt0G8Dy9eHsSScpr9PkTCQg42eBGY@rt7Gqu3M6h6ptf6me3N9YaV7OttXUyREhl5E0wESjUeESDJ2xRK2z5VpsovChld7DGibLg51KWPw "Python 3 – Try It Online") Interesting observation: the ascii values of `oO8` are `111`, `79`, and `56`, respectively. If you take these modulo 3, you get `0`, `1` and `2`. --- Additional observation: you can validate the generation of your final string by substituting `'o'` with 3, `'O'` with 4 and `'8'` with 5; then taking the sum of your list and subtracting 3 from the total. This works for all strings regardless of random variations, because each replacement in your string increases this sum by 1: ``` 'o' (3) -> 'O' (4) 'O' (4) -> '8' (5) '8' (5) -> 'oo' (3+3 = 6) ``` We then just need to correct for the offset of 3. [Validate it online!](https://tio.run/##K6gsycjPM/7/v6AoM69Eo7g0V6NaPV/dylhH3V/dykRH3ULdyrQ2OjNWIS2/SCFTITMPiApKSzQ0NXWNNf//zwcBC4v8fH8gtPAH8/z9QQQY5YMQXNAfqBAA) [Answer] # [Ruby](https://www.ruby-lang.org/), ~~79 77 73 72~~ 61 bytes ``` ->n,s=?o{n.times{s[w=rand(s.size)]=%w[O 8 oo][s[w].ord%3]};s} ``` [Try it online!](https://tio.run/##KypNqvyfZvtf1y5Pp9jWPr86T68kMze1uLo4uty2KDEvRaNYrzizKlUz1la1PNpfwUIhPz82GigZq5dflKJqHFtrXVz7v6C0pFghLdrQzCD2PwA "Ruby – Try It Online") -11 bytes thanks to Value Ink and [Jitse](https://codegolf.stackexchange.com/a/196141/18535) [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~40~~ ~~32~~ 31 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set") Full program. Prompts for N from stdin. ``` 'o8O'[{∊⌷∘3(1 1)2@(?≢⍵)⊢⍵}⍣⎕,1] ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94L96voW/enT1o46uRz3bH3XMMNYwVDDUNHLQsH/UuehR71bNR10gqvZR7@JHfVN1DGNB2v4rgEEBlyEXjGUEZxnDWSZwlimcZWiA0IJgGhsgKUBWgSJuAAA "APL (Dyalog Unicode) – Try It Online") `'o8O'[`…`]` select the following characters from the string `"oO8"`:  `,1` the list `[1]`  `⎕` prompt for N from stdin  `{`…`}⍣` apply the following anonymous lambda to `[1]`, that N times:   `⊢⍵` on the argument…   `@(`…`)` **at** position…    `≢⍵` the length of the argument    `?` random index in that range   … apply the following tacit function:   `⌷∘3(1 1)2` use the number to select from the list `[3,[1 1],2]`:   `∊` **ϵ**nlist (flatten) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 26 bytes ``` 'osFÐg<ÝΩ©è…oO8S„O8„ooª‡®ǝ ``` [Try it online!](https://tio.run/##ATcAyP9vc2FiaWX//ydvc0bDkGc8w53OqcKpw6jigKZvTzhT4oCeTzjigJ5vb8Kq4oChwq7Hnf//MjAw "05AB1E – Try It Online") [Answer] # [Pyth](https://github.com/isaacg1/pyth), 25 bytes ``` uXGJOlG@c"O 8 oo")C@GJQ\o ``` [Try it online!](https://tio.run/##K6gsyfj/vzTC3cs/x90hWclfwUIhP19J09nB3SswJv//f0MDAA "Pyth – Try It Online") Written by @FryAmTheEggman, similar idea to my earlier post but much cleaner as it reduces instead of looping. ## How it works ``` uXGJOlG@c"O 8 oo")C@GJQ\o u Q\o - Reduce 'o' Q=input times JOlG - With random number J in the range [0,length G), where G is the previous list XG - Replace the element in G at index J... @c"O 8 oo") - With an element of "O 8 oo" split by whitespace, at index... C@GJ - ...of the codepoint of the element in G at index J ``` # [Pyth](https://github.com/isaacg1/pyth), 38 bytes ``` K\oJ["oo"\o\O\8)VQ=kOlK=KXKk@JhxJ@Kk;K ``` [Try it online!](https://tio.run/##K6gsyfj/3zsm3ytaKT9fKSY/xj/GQjMs0DbbP8fb1jvCO9vBK6PCy8E729r7/39DAwA "Pyth – Try It Online") My original solution, less sophisticated. ## How it works ``` K\oJ["oo"\o\O\8)VQ=kOlK=KXKk@JhxJ@Kk;K K\o - K = 'o', start J["oo"\o\O\8) - J = ['oo', 'o', 'O', '8'] VQ - Loop Q=input times =kOlK - k = random number from 0..length of K =K - K equals... XKk - K with the element at index k replaced by... @Jh - The item in J at index+1 of... xJ - The index (in J) of... @Kk - The element of K at index k ;K - End loop, print K ``` [Answer] # [R](https://www.r-project.org/), ~~109~~ ~~97~~ 93 bytes ``` for(i in 1:scan())T=append(T,switch(T[j],"O",O=8,"8"=c("o","o")),j<-sample(sum(T>0),1))[-j];T ``` [Try it online!](https://tio.run/##DcPBCkBAEADQX9GcZmoUByWsX3CZmxy2RXZjbZZ8/vLqXSmt54U2sz4rm2i0RyJROoTFzygcX3ubDWV0E8MAPKiaoQZlEE7gPxG7Lo/6CPuC8TlQ@oK4JBpzN7WSqvQB "R – Try It Online") Output as an array. Thanks to [Robin Ryder](https://codegolf.stackexchange.com/users/86301/robin-ryder) for golfing out 6 bytes, for pointing out a bug in a previous version, and for golfing out an additional 4 bytes. [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 55 bytes ``` {('o',{S:p(rand*.comb)[.]=<O 8 oo>[$/.ord%3]}...*)[$_]} ``` [Try it online!](https://tio.run/##JcfBCsIgAIfxV/kzrOkwc1kR1fYKHTqKyGp5ajnsNMRnt1WHD37f@AjPfR4mLB2aHGnpSx6vx5GG7tVX4u6HG9PCNOcLDvC@1WQtfOgXyiQhRMU0sSbldzehIBarFtFRYlkq4HxAzbHhUBxbjh1HLeefU/Lr3/wlT/kD "Perl 6 – Try It Online") ### Explanation ``` { } # Anonymous block , ...* # Infinite sequence 'o' # Start with string "o" { } # Compute next item by S # replacing :p(rand*.comb) # starting at random position [.] # any character =<O 8 oo> # with "O", "8" or "oo" [$/.ord%3] # depending on ASCII code mod 3 ( )[$_] # nth item of sequence ``` [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~172~~ ~~158~~ ~~150~~ ~~149~~ ~~144~~ ~~137~~ ~~130~~ 128 bytes ``` a=>{dynamic r=new Random(),g="o",i;while(a-->0)g=g.Remove(i=r.Next(g.Length),1).Insert(i,"O,8,oo".Split(',')[g[i]%3]);return g;} ``` [Try it online!](https://tio.run/##bcxBS8MwGMbx@z5FKMgSSENrFYSYHoXBcDAPHsYOoXuXvbC@keTdpsg@e9Wj7a4//s/T5bLLOGT2jJ14OVH3jMQ6c0IKrdgLN3jXfu@@yPe/QXIEF7H2tIu9VDq4IhYa7eWAR5C@LNtKBRfMGvp4BokumVf4ZBnMEijwQelamQVlSCxRFyv9pGMszNvHEVnO9Vxtwga3d81W2QR8SiSCvQ52NntPyLBEArmXtVL2H9yPoRnDwxgex1BXk9eJNNV0dWN2q/qz4Qc "C# (Visual C# Interactive Compiler) – Try It Online") -14 bytes thanks to @Jitse's observation about character modulus -8 bytes by renaming a variable I forgot about -1 byte by switching to a while loop -5 bytes by not saving the current character to a variable -7 bytes by switching to the interactive compiler -7 bytes by chaining declarations and inlining assignment thanks to @my pronoun is monicareinstate -2 bytes by changing to string split over character comparison thanks to @Olivier Grégoire for inspiration [Answer] # [J](http://jsoftware.com/), 54 bytes ``` 'oO8'{~(((1+2={)`[`(1"0@])}#(3|1+{)`[`]})~1?#)^:(]`0:) ``` [Try it online!](https://tio.run/##y/pvqWhlGGumaGWprs6lpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/1fP9LdSr6zQ0NAy1jWyrNROiEzQMlQwcYjVrlTWMawy1wUKxtZp1hvbKmnFWGrEJBlaa/zW5UpMz8hXSFEwN/gMA "J – Try It Online") Wholly different approach to shave off 2 bytes # original solution # [J](http://jsoftware.com/), 56 bytes ``` 'oO8'{~(({.,(i.@3(>:@i.{ ::0 0[){),>:@[}.])~1?#)^:(]`0:) ``` [Try it online!](https://tio.run/##y/pvqWhlGGumaGWprs6lpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/1fP9LdSr6zQ0qvV0NDL1HIw17KwcMvWqFaysDBQMojWrNXWAAtG1erGadYb2yppxVhqxCQZWmv81uVKTM/IV0hRMDf4DAA "J – Try It Online") Had an equal byte solution, but adjusted it slightly using Adam's idea of doing all the calculation in pure integers, and saving the translation-to-string step till last, which I felt looked a bit cleaner. [Answer] # [Perl 5](https://www.perl.org/), 79 bytes ``` sub f{$_[0]?do{$_=f(-1+pop);substr($_,rand length,1)=~y/oO8/O82/;s,2,oo,r}:"o"} ``` [Try it online!](https://tio.run/##FYxBCsIwEEWvMoQsEpw2bVEsluoRegCVoLRRoWRCEhci9eox3X147303@XmXUnjfwXy5PlfX00h59EYU9caRk11mIXrBNfqbHWGe7CM@sZb976NoaNXQNqoL2CAR@uXAiC0prKrYS1gL5182AuMaiiMwNPlKIrtYBoY81GW5rdIf "Perl 5 – Try It Online") ``` sub f { $_[0] ? do{ $_ = f(-1+pop); substr($_,rand length,1) =~ y/oO8/O82/; s,2,oo,r } : "o" } srand(7) and print "$_ -> ",f($_),"\n" for 1..40 ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 38 bytes ``` ⊞υoFN«≡⊟υo⊞υO¦O⊞υ8F²⊞υo≔‽LυιUMυ§υ⁺λι»υ ``` [Try it online!](https://tio.run/##VY1LCsIwFEXHzSpCRwlUqI6kHRVHBbXBHcQ2bQP5lHxUkK49NlVEZ493zr23HalpNRUhEG9H5DOY6hSXoNcGolpN3p29vDKDMIZPkNg7d@0IEdET8u9XSy2LoQJ@G5rY8AHNL9ivoGM99cIVcB3ZYfg/ncwgqazlg0IXqjot0ZGpwY1xMIM8Gic6HbSUC42xytWqY494EuEtEtHCizcDYrhyS7AMYZvnYXMTLw "Charcoal – Try It Online") Link is to verbose version of code. Outputs an array, which is like a string but vertical (+1 byte to output the array horizontally). Explanation: ``` ⊞υo ``` Start with a single `o`. ``` FN« ``` Loop the given number of generations. ``` ≡⊟υ ``` Remove the last character and switch on it. ``` o⊞υO ``` If it's an `o` then push an `O`. ``` O⊞υ8 ``` If it's an `O` then push an `8`. ``` F²⊞υo ``` Otherwise push `o` twice. ``` ≔‽LυιUMυ§υ⁺λι ``` Rotate the array by a random amount. This causes the oozes to be evolved in a random order. ``` »υ ``` Finally output the resulting array. [Answer] # [Japt](https://github.com/ETHproductions/japt), ~~32~~ ~~31~~ 29 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ``` _gZÊö _Ä %3ª1ö2Ãc}g[]á)Ëg"oO8 ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=X2dayvYgX8QgJTOqMfYyw2N9Z1td4SnLZyJvTzg&input=MTAwCg) ``` _ // function taking array gZÊö // replace a random element with : _Ä %3 // element incremented mod 3 ª1ö2à // or [0,0] c} // flattens g[]á) // run the function input times with initial value of array, return last element Ëg"oO8 // convert values to o O 8 ``` Thanks to @Embodiment of Ignorance for reminding me I don't need = at beginning [Answer] # [Python 2](https://docs.python.org/2/), 104 bytes ``` from random import* l=['o'] exec"i=randrange(len(l));l[i:i+1]='oO8o'[-~ord(l[i])%3::3];"*input() print l ``` [Try it online!](https://tio.run/##K6gsycjPM/r/P60oP1ehKDEvBUhl5hbkF5VoceXYRqvnq8dypVakJitl2oJkgTg9VSMnNU8jR1PTOic60ypT2zDWVj3f3yJfPVq3Lr8oRQMoGqupamxlZRxrraSVmVdQWqKhyVVQlJlXopDz/7@hAQA "Python 2 – Try It Online") Golfing [Jitse's](https://codegolf.stackexchange.com/a/196141/20260) solution using the mutability of lists. [Answer] # [Java (JDK)](http://jdk.java.net/), 138 bytes ``` n->{var s=new StringBuffer("o");for(int i;n-->0;s.replace(i*=Math.random(),i+1,"O,8,oo".split(",")[s.charAt(i)%3]))i=s.length();return s;} ``` [Try it online!](https://tio.run/##PY8xa8MwEIX3/IpDYJBSWThNCiWuA@1Q6BAyZCwZFFtO5NqSkc4pIfi3p7IdOhy6h959966SFxlXxc9dN611CFXQokNdi7IzOWprxDyd5bX0HrZSG7jNANruWOscPEoMz8XqAprwR/fotDl9H0C6k2ejFeDL4OcD9bY7VirHDZSQ3U28uV2kA58Z9QvT6EdXlspRYglLS@uoNgg6NXG8SVIvnGprmSuq59lW4lk4aQrbUMb104KTHX/l1hLh21ojJZywby/ys3TvSDWLlgfGdOZFrcwJz5SlTmHnDPi0v6dj0LAsREfl0UP2CA@w4PDMYclhxeGFwyIJOtQyGfpRTF0y@vsJFbLDGH6grScm@0furx5VI2yHog1XY0lJtCrWEPnIED66OZRCtm19pYNibML2s6H6@x8 "Java (JDK) – Try It Online") ## Credits * -2 bytes thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen) [Answer] # [Zsh](https://www.zsh.org/), ~~75~~ 73 bytes ``` s=o m=(oo 8 O) repeat $1 ((n=1+RANDOM%$#s))&&s[n]=$m[m[(i)$s[n]]-1] <<<$s ``` ~~[Try it online!](https://tio.run/##TYwxC8IwEEb3@xUHvZY7i7RBBIdmEFy14Bo6iKTUoYmYDsXS3x4jLm7vPT6@dxhiz8IxaA@jZo8tHtB7gZd92tuEpJDZaVVej5dTe84pCyJFEYzrNI1GlaPhh9DXuw6apqEQBaBHVdcAGU42TOA0Mf8OMMd9XYuAnVPskVzC@@AToMY0w92GKbPzVgmWSEtGi52ryq/rvxrfdqmIxA8 "Zsh – Try It Online")~~ [Try it online!](https://tio.run/##TYwxC8IwEEb3@xUHvZY7S7FBBIdmEFy14Bo6iKTUoYmYDsXS3x4jLm7vPT6@dxhiz8IxaA@jZu/xgK3Ayz7tbUJSyOy0Kq/Hy6k955QFkaIIxnWaRjMafgh9ratUB03TUIgC0KOqa4AMJxsmcJqYfweY476uRcDOKfZILuF98AlQY5rhbsOU2blSgiXSktFi5@3Wr@u/Gt92qYjEDw "Zsh – Try It Online") I want to focus here specifically: ``` $m[m[(i)$s[n]]-1] m[ ] # from array $m: (i) # get the index of $s[n] # the nth character in the string (as a pattern) # if not found substitute 4 (length of array + 1) -1 # subtract one $m[ ] # substitute the element at that index ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~21~~ 16 bytes ``` 1F‘JX$¦ḃ3Ʋ¡ị“oO8 ``` [Try it online!](https://tio.run/##y0rNyan8/9/Q7VHDDK8IlUPLHu5oNj626dDCh7u7HzXMyfe3eNQw9z9QgYEBAA "Jelly – Try It Online") A full program that takes `n` as its argument and implicitly outputs the state of the oozes after that many generations. Thanks to @cairdcoinheringaahing for saving a byte! ## Explanation ``` 1 | Literal 1 Ʋ¡ | Repeat the following the number of times given by the argument F | - Flatten ‘ $¦ | - Increment the item at the index given by: J | - Sequence along the list X | - Random number fron the sequence ḃ3 | Convert to bijective base 3 ị“oO8” | Index into "oO8" ``` [Answer] # [Python 3.8](https://docs.python.org/3.8/), 91 bytes ``` f=lambda n,s='o':n and f(n-1,s[:(k:=id(s)//7%len(s))]+'oO8o'[-~ord(s[k])%3::3]+s[k+1:])or s ``` [Try it online!](https://tio.run/##FY1BDoIwEEX3nmI2pG0YQmsl4iScwQOQLjBIJOC0adm48eq1bv5/L3/xw@d4ebZ9iDkvwz69H/MEjGkQXhDDxDMskhuDaSS50bDOMqm2vVb7kwspVwt/770Ym6@PZRs3pypLZF1duDbklI@Q8lKSYWXQaPCMFi/YodHYFdf/0njTmk4Q4sqHLJ9K5R8 "Python 3.8 (pre-release) – Try It Online") I'll be perfectly honest, I don't know for sure that this is valid randomness. It seems like it to me, but I'm not sure how I'd determine one way or the other - if someone could confirm or deny, that'd be much appreciated. Assuming validity, this is a modification of [Jitse's](https://codegolf.stackexchange.com/questions/196139/simulate-reproduction-in-a-population-of-oozes/196141#196141) answer that gets rid of the import. `id(s)` gives a different integer every time, but just taking it modulo `len(s)` gave results that were too consistent. Integer dividing the id by 7 seemed to do the trick, but again, I'm not sure how to verify. If this turns out not to be valid, I'll delete immediately. [Answer] # JavaScript (ES10), 91 bytes Similar to the ES6 version, but returns an array of characters. ``` n=>(g=P=>n--?g(P.flatMap(c=>i--?c:'8O'[c|c>g]||['o','o'],i=Math.random()*P.length|0)):P)`o` ``` [Try it online!](https://tio.run/##HYixCoMwFAD3foVbkvIMUVsolqRTR6m7CIaoUbHviUon/93aDscdN9iPXdzcT2uIVDd7q3fUhnuda4Nh@PA8l@1o18xO3GnTH8ul7PZihduc8eW2FYwYHJTQ68yunZwt1vTm4pzLsUG/dpsSIs1FRdV@LyKIIYELXCFSECtI1BG/@luVJ9nS/LSu4xhoEzjChcZGjuQ5QtByFHKgHjljQoj9Cw "JavaScript (Node.js) – Try It Online") --- # JavaScript (ES6), ~~98 ... 94~~ 93 bytes ``` n=>(g=P=>n--?g(P.replace(/./g,c=>i--?c:'8O'[c|c>g]||'oo',i=Math.random()*P.length|0)):P)('o') ``` [Try it online!](https://tio.run/##HcixDoIwFEDR3a9ga2sepYAmBtM6ORrZCUNTSsHgewSIE/@O6HRP7st@7OymflxipMZvrd5QGx50qQ3G8S3wUk5@HKzzPJFJAKdNv39XsMuTVW51JtTryogY9Pphl05OFht6c3Es5eAxLN2qhChKwRkxsV2rFDLI4QRnSBVkCnK146d/VX2QLU136zqOkTaRI5xp8HKgwBGilqMQYvsC "JavaScript (Node.js) – Try It Online") ### Commented ``` n => ( // n = number of generations g = P => // g is a recursive function taking the population string P n-- ? // decrement n; if it was not equal to 0: g( // do a recursive call: P.replace(/./g, c => // for each character c in P: i-- ? // if we haven't reached the requested position: c // leave c unchanged : // else: '8O'[ // replace with: c | c > g // 'O' is c != 8 and c is lowercase ] // '8' is c != 8 and c is uppercase || 'oo', // 'oo' if c = 8 i = Math.random() // compute a random position i within the current * P.length | 0 // population string ) // end of replace() ) // end of recursive call : // else: P // return the final population )('o') // initial call to g with P = 'o' ``` [Answer] # [Red](http://www.red-lang.org), 93 bytes ``` func[n][s: copy"o"loop n[replace at s i: random length? s s/:i select[#"o"#"O"#"8":oo]s/:i]s] ``` [Try it online!](https://tio.run/##JY7BCsIwEETv/Yoh/YDG1oLk4icIXkMOIdnaQt0NSUX8@prqYXkzuzOwmeJ@p2hdkz1HeXaFKILl3UwG@/TiYNnZYhAkfZSoVSSBbaa0@kDwGwoWg38ZK/Fjm691VzqzoNBKYbNt7bXqVueijIg7bq64fZJMPsxg2BN6DDhjxEmj1xg0Rl31YX7UDjblhbcKXx@sWWUUJrBz@xc "Red – Try It Online") [Answer] # [K (oK)](https://github.com/JohnEarnest/ok), 51 bytes ``` {"oO8"x{{,/(x#t),((1;2;0 0)t@x),(x+1)_t}1?#t:x}/,0} ``` [Try it online!](https://tio.run/##y9bNz/7/P82qWinf30KporpaR1@jQrlEU0dDw9DayNpAwUCzxKECyK3QNtSML6k1tFcusaqo1dcxqP2fpm6oYKRgrGCiYKpgaKBgZKBgagBkgFgG/wE "K (oK) – Try It Online") No doubt this can be done much shorter / more elegant (using ammend?). I'm somewhat happy that it works at least. [Answer] # [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~29~~ 27 bytes ``` K`o "$+"{@T`\oo`\O80`. 0 oo ``` [Try it online!](https://tio.run/##K0otycxLNPz/3zshn0tJRVup2iEkISY/PyHG38IgQY/LgCs///9/QwMDAA "Retina – Try It Online") Edit: Saved 2 bytes when I realised how I could combine `@` with `T`. Explanation: ``` K`o ``` Replace the input with the initial generation. ``` "$+"{ ``` Repeat the remaining stages for the given number of generations. ``` @T`\oo`\O80`. ``` The `O` is a metacharacter and needs to be escaped. The `o` is also a metacharacter, so the first `o` is literal, while the second `o` represents `O80` from the destination pattern. This therefore transliterates the characters `oO8` to `O80`. The final `.` means that each character is treated as a separate match for the purposes of the `@` operator, which chooses one match (i.e. character) at random to be transliterated. ``` 0 oo ``` Fix up any `0` to `oo`. (This stage does not need to be conditional.) [Answer] # Python 3, 142 bytes ``` from random import* def f(i,x='o'):i-=1;s=randint(0,len(x)-1);o={'o':'O','O':'8','8':'oo'};x=x[:s]+o[x[s]]+x[s+1:];return x if i<1else f(i,x) ``` [Answer] # [Icon](https://github.com/gtownsend/icon), 85 bytes ``` procedure f(n) s:="o" 1to n&s[p:=?*s]:=["O",8,"oo"][find(s[p],"oO8")]&\z return s end ``` [Try it online!](https://tio.run/##bc/NCoMwDAfwe5@i5CDt8KD7ACnIHsEHcD2IrVA2E2mVgS/vlO2w1eX2S/4kxLWEy8PhnfsGDfXL4Km1ZvKWdwIlC6oEApaPxDEJ9aDK6yFoVdZQQVqkQAS67hwasQ716qoAqZPbzLwdJ488MIvma2vfOBSS8bXeF91sP356N1rRiVz@@hj5FPkc@RI5z@KF2S6xj/zJbK3tmxc "Icon – Try It Online") [Answer] # [C (gcc)](https://gcc.gnu.org/), 101 bytes ~~104 117 bytes~~ ``` char*h,g[9999];l;f(a){*g='o';for(l=1;a--;(*h="O8o"[*h%3])-'o'?:bcopy(h,h+1,l++))h=g+rand()%l;g[l]=0;} ``` [Try it online!](https://tio.run/##hY5NCsIwEEb3PUUpFCf9gdQqqEPwCB6gdhGjTcSYSFoXIj17LEVcmm81zHvDfKKUQngvFHeZKmSzndKixg44eWeSLewCO@tAswp5WSJkiiWHjU2aTKV1S8pJ2O9Owj5eoAqVV4XOc0IUk7nj5gwk1Sgb3TKKo7@aIb7zqwESvaN4Sj87QltxA0Jw3nVQfaeHmw46SNL@aJJC/vgywOsAXwX4OsArGioYEmoafEH/K@4yPJ2JKUZj5D8 "C (gcc) – Try It Online") **(Many thanks to ceilingcat for the awesome code golfing help and ideas!)** Ok, except for large generation count buffer overflow and the fact that I seeded random outside the code, this now works. Making g bigger could put the overflow size above what an int can hold if needed. ### Commented ``` char *h,g[9999] // Work pointer and a fixed size buffer. l; // int length of string (number of slimes) f(a){ // a is generation *g='o' // Set first value. for(l=1; // Length is 1. a--; // consume a generation (*h="O8o"[*h%3]) // Use the mod 3 trick to index into the next symbol and assign the new slime character. -'o'?: // if we went back to 'o', grow the string bcopy(h,h+1,l++)) // move all the values up in in array to length (including new 'o' symbol) Note: bcopy() can overlap src and dest. h=g+rand()%l; // for each loop, find which slime to evolve and point h to it. g[l]=0;} // NUL Terminate the g buffer to make it a string. ``` [Answer] # [C (gcc)](https://gcc.gnu.org/) (with `-m32` compiler flag), 174 172 bytes Thanks to ceilingcat for the suggestions. Not competing (there are already shorter versions in C), but this uses a different method. Instead of using a hard-coded output buffer, I use a linked list on the stack to hold each cell's state and traverse the list to locate cells to mutate. If the cell splits in two, the function calls itself to hold the new cell state and adds itself into the list chain. As the list is not necessarily linear on the stack, the last function prints the list of cells (intermediate callers set their list start to `NULL` after control returns to them to prevent unwanted output.) ``` g(i,j,s,p)int*s,*p;{int a[2]={},r;for(j++?*a=*p,*p=a:(s=a);i--;++p[1]>2?p[1]=0,g(i,j,s,a),s=i=0:0)for(r=rand(p=s)%j;r--;p=*p);for(;s;s=*s)printf(L"oO8"+s[1]);}f(i){g(i,0);} ``` [Try it online!](https://tio.run/##VU9BTsMwELznFaugSrbjIDcFCdW4/UAFJ04VB@M0qas2sewUDlG@zmIHOPS0s7Oe8YwpW2MQW2L5iQfuqO0GFjhzcowI9L56V@PEvWx6T05FsWVaMRfvSq9JUJpKW5ayKNx@@b6ptmkowf/tNOVBWSXWgia9V153NXEq0MVJ@ih00YzO3jLIoFigzsd/G7LL@9envAjRj8qpIZaOyVTEBe9sZ87X@gDPYahtf3/cZDfU2X7ccoO9HBKTpUoXbTsyd/Ot4WCO2gNjcfmkMGYA6WRlBClVmAMnPXl52@0olcCKIj2W4K5DIHlOowz@UueLGtQGcg5W6aG35Nc3qlIDCVM2IQpcYoUrfMBHXAqsBK4iJRKap/g2zVm3AcvLqsLy6wc "C (gcc) – Try It Online") [Answer] # [Lua](https://www.lua.org/), ~~106~~ ~~101~~ 110 bytes **Changed Code to function format + 9 bytes** ``` e={"O",8,"oo"}for i=1,t do s=math.random(1,#o)o=o:sub(1,s-1)..e[o:sub(s,s):byte()%3+1]..o:sub(s+1)end return o ``` [Try it online!](https://tio.run/##TY6xasNAEER7fcVyJnBrnw4fIRAMqlOmMKQJKc7SCiuRb83tXmGbfLsixSkyxcAbBmbGEqdT1KPPMXV8EqLOsvh25PbL4jpsf4VQ1/fCcCXQIwEXPReFzyIKPWfoS6qq2VodOEFv2YHiRM3NvBr37Ayz@V56QxOcQscgzb9ZG9yKkRveSTnMIHVA7@n9zuIEd4eLksWHx0348P4v3wSk1EEmLTkBTzNU1TkPSW1vDRsHT1tcvsNeY1Z4i2MhBy@UKMflqEw/ "Lua – Try It Online") [Answer] # APL(NARS), chars 62, bytes 124 ``` {⍵{⍺=0:⍵⋄(⍺-1)∇(⍵↑⍨k-1),(('oO'⍸k⊃⍵)⊃"O"'8'"oo"),⍵↓⍨k←?≢⍵},'o'} ``` test: ``` h←{⍵{⍺=0:⍵⋄(⍺-1)∇(⍵↑⍨k-1),(('oO'⍸k⊃⍵)⊃"O"'8'"oo"),⍵↓⍨k←?≢⍵},'o'} h 0 o h 4 oO h 10 8OO h 100 8oOOO8ooOO8oOOoO8oOooooO8OO h 200 8OO888Ooo8OO8oO88O8oo8oooooOo8ooO8OooOO88OoO8O8o8Oo ``` but it has problems if the argument is >500, the 73 chars code below has not these problems: ``` r←f w;k r←,'o' →0×⍳0>w-←1⋄r←(r↑⍨k-1),(('oO'⍸k⊃r)⊃"O"'8'"oo"),r↓⍨k←?≢r⋄→2 f 1000 O8oooo8OoooO8ooOO88oo88OOOoo8oOoO8888oo88ooOOOoooooo8oooOO8OooO8O8oOO8oOOOo88Oo Ooooo88O8o8ooooo8OOooOO8O8OOOoo8OoO8Oo88ooOOoooO888O8o8OoOOoooOo8oooo8OoO 88Oooo8O8OoooooooOo88oo8oooooo8OOoO8oOO8Oo8oo8oO88oo8OOoOoOOoOoOoo8O88o8O 88OoO8OOoOo8Oo8ooo8OoooooooooOOooO8oo88 ``` [Answer] # [Lexurgy](https://www.lexurgy.com/sc), 306 bytes Uses `oO%` for ooze states. Since Lexurgy doesn't have a random feature, the program deterministically moves a pointer from right to left in the ooze string, incrementing the ooze at that pointer. Iteration stops when the generation counter hits 0. Note: This seems to work all the way up to 83 generations; 84 or more generations has the interpreter complain about how the propagation doesn't converge to an endpoint. ``` Class u {o,O,%} Class d {\1,\2,\3,\4,\5,\6,\7,\8,\9,\0} p: *=>`ol/_ $ e propagate: @d=>{\0,\1,\2,\3,\4,\5,\6,\7,\8,s\9}/_ ` @d s=>{\0,\1,\2,\3,\4,\5,\6,\7,\8,\9} * then: \0 `=>*/$ _ \0=>*/$ _ then: @u=>{O, %, oo}/_ l//$ ` _ then: @u$1 l=>l $1 then: *=>l/` l @u* _ $ l=>*/` _ s: {s,l,`}=>* ``` Ungolfed explanation: ``` Class ooze {o, O, %} Class next {O, %, oo} Class digit {\1,\2,\3,\4,\5,\6,\7,\8,\9,\0} Class dec {\0,\1,\2,\3,\4,\5,\6,\7,\8,s\9} Class dec2 {\0,\1,\2,\3,\4,\5,\6,\7,\8,\9} # setup: generate initial digit-ooze sep, `o`, and pointer pre: * => `ol / _ $ # [gens left]`[oozes][growth pointer] # while the input was changed last iteration... evolve-once propagate: # decrement the generation counter @digit => @dec / _ ` @digit s => @dec2 * # handle carries then: # remove leading 0s \0 ` => * / $ _ \0 => * / $ _ then: # grow an ooze if it's right before the growth pointer # but not when there's no generations left @ooze => @next / _ l // $ ` _ then: # move the growth pointer to the left @ooze$1 l => l $1 then: # move the growth pointer to the end if it's at the left side of the ooze string * => l / ` l @ooze* _ $ l => * / ` _ # remove extraneous characters strip: {s,l,`} => * ``` ]
[Question] [ ## The task In this challenge, your input is a non-empty list of positive integers, given in the native format of your language. Your output is that same list, in the same format, with some elements removed. You shall remove every occurrence of `1`, every second occurrence of `2`, every third occurrence `3`, and so on. In general, for every positive integer `N`, you shall remove every `N`th occurrence of `N` from the list, starting with the `N`th occurrence. ## Example Consider the input list ``` [3,2,6,1,1,6,2,3,2,6,6,6,6,1,6,6,3,3,7,2] ``` First, we remove every occurrence of `1`: ``` [3,2,6, 6,2,3,2,6,6,6,6, 6,6,3,3,7,2] ``` Then every second occurrence of `2`: ``` [3,2,6, 6, 3,2,6,6,6,6, 6,6,3,3,7 ] ``` Then every third occurrence of `3`: ``` [3,2,6, 6, 3,2,6,6,6,6, 6,6, 3,7 ] ``` The numbers `4` and `5` don't occur in the input, so they can be skipped. Next, we remove every sixth occurrence of `6`: ``` [3,2,6, 6, 3,2,6,6,6, 6,6, 3,7 ] ``` There's only one occurrence of `7`, so that can be skipped as well. Thus the correct output is ``` [3,2,6,6,3,2,6,6,6,6,6,3,7] ``` ## Rules and scoring You can write either a full program or a function. The lowest byte count wins, and standard loopholes are disallowed. ## Test cases ``` [1] -> [] [2] -> [2] [1,1,1] -> [] [2,2,2] -> [2,2] [1,1,2,2,2,3,3,3,3] -> [2,2,3,3,3] [1,2,3,1,2,3,1,2,3,1,2,3] -> [2,3,3,2,3] [3,2,6,1,1,6,2,3,2,6,6,6,6,1,6,6,3,3,7,2] -> [3,2,6,6,3,2,6,6,6,6,6,3,7] [5,4,5,4,3,5,4,5,4,5,4,3,5,4,5,3,3,3,4,5,4,5,4,5,4,3,3,3,5,4] -> [5,4,5,4,3,5,4,5,4,3,5,4,5,3,3,4,5,5,4,4,3,3,5,4] [6,4,5,8,2,9,3,1,8,5,3,5,5,6,3,5,1,2,3,9,3,5,8,7,5,9,1,3,4,8,2,3,4,7,8,5,8,5,3,1] -> [6,4,5,8,2,9,3,8,5,3,5,5,6,3,9,3,5,8,7,5,9,4,8,2,3,4,7,8,5,8,5,3] [4,4,9,12,9,4,4,4,12,9,12,9,12,4,12,4,4,9,4,9,12,4,12,4,4,12,4,4,9,12,9,12,9,4,9,12,4,9,12,9,12,9,4,9,12,12,4,4,12,4] -> [4,4,9,12,9,4,4,12,9,12,9,12,4,12,4,9,4,9,12,4,12,4,12,4,4,9,12,9,12,4,9,12,9,9,12,9,4,9,12,12,4,4,12] [2,2,11,11,11,11,6,2,2,6,6,2,2,2,2,6,11,6,11,11,2,11,2,6,6,11,2,11,6,2,6,6,6,6,6,11,2,11,11,6,6,6,11,6,2,6,2,6,6,2,11,2,2,11,11,11,11,2,6,2] -> [2,11,11,11,11,6,2,6,6,2,2,6,11,6,11,11,2,11,6,11,2,11,6,6,6,6,6,2,11,11,6,6,6,11,6,2,6,6,11,2,11,11,11,11,2,6] [20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102] -> [20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,21,22,100,101,102,20,22,100,101,102,20,21,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,21,22,100,101,102,20,21,22,100,101,102,20,22,100,101,102,20,21,22,100,101,102,20,21,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,21,22,101,102,20,21,22,100,102,20,21,22,100,101,20,21,22,100,101,102,20,21,22,100,101,102,20,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,22,100,101,102,20,21,100,101,102] ``` ## Leaderboard Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` ## Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` ## Ruby, <s>104</s> <s>101</s> 96 bytes ``` If you want to include multiple numbers in your header, make sure that the actual score is the *last* number in the header: ``` ## Perl, 43 + 2 (-p flag) = 45 bytes ``` You can also make the language name a link which will then show up in the leaderboard snippet: ``` ## [><>](http://esolangs.org/wiki/Fish), 121 bytes ``` ``` var QUESTION_ID=70091,OVERRIDE_USER=32014;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] ## awk, 10 bytes Input is expected on STDIN, one number per line. ``` ++a[$1]%$1 ``` ### Explanation Keeps a counter for each number in an associative array, prints only if the counter value modulo `n` is not zero. Printing is implicit. Long version: ``` ++a[$1]%$1{print $0} ``` [Answer] # Pyth, ~~18~~ ~~15~~ ~~14~~ ~~10~~ 9 bytes ``` f%/aYTTTQ ``` I think this is the first code I've written that has five consecutive variable references in nine bytes. I wish the array manipulation solution (`u.DG%HgxHGH{QQ`, 14 bytes) weren't so long. ``` f%/aYTTTQ Implicit: Q=input lambda T: Y Variable: starts as empty list. a T Append T to Y. Mutates Y. / T Number of elts of Y that equal T. % T Modulo by T f Q Filter that lambda over Q. ``` Try it [here](https://pyth.herokuapp.com/?code=f%25%2FaYTTTQ&input=%5B3%2C2%2C6%2C1%2C1%2C6%2C2%2C3%2C2%2C6%2C6%2C6%2C6%2C1%2C6%2C6%2C3%2C3%2C7%2C2%5D&debug=1). [Answer] # [Jelly](http://github.com/DennisMitchell/jelly), ~~10~~ 8 [bytes](https://github.com/DennisMitchell/jelly/blob/master/docs/code-page.md) ``` =;\S€%af ``` *Thanks to @Sp3000 for golfing off 2 bytes!* [Try it online!](http://jelly.tryitonline.net/#code=PTtcU-KCrCVhZg&input=&args=WzMsMiw2LDEsMSw2LDIsMywyLDYsNiw2LDYsMSw2LDYsMywzLDcsMl0) ### How it works ``` =;\S€%af Main link. Input: A (list) ;\ Compute the cumulative concatenations of the elements of A, i.e., the list of A's prefixes. = Compare the elements of the nth prefix with the nth element of A. S€ Compute the sum of the resulting arrays. % Take the nth sum modulo the nth element of A. a Logical AND; replace the nth remainder with the nth element of A if the remainder is non-zero. f Filter; remove the zeroes (which do not occur in A) from the result. ``` [Answer] ## Python, 57 bytes ``` lambda l:[n for i,n in enumerate(l)if l[:i+1].count(n)%n] ``` [Answer] # [Perl 6](http://perl6.org), 28 bytes ``` {$_=$;grep {++.{$^n}%$n},@_} ``` Explanation ``` { $_=$; # put $_ in a clean state grep { ++.{$^n} # increment $_{ $n } and declare $n as an argument % $n # check if the count is not divisible by $n }, @_ # the input } ``` Usage: ``` # give it a lexical name for ease of use my &code = {...} sub check ( @a, @b ){ say try { so all code(@a) »==« @b } // False } check [1], []; # True check [2], [2]; # True check [1,1,1], []; # True check [2,2,2], [2,2]; # True check [1,1,2,2,2,3,3,3,3], [2,2,3,3,3]; # True check [1,2,3,1,2,3,1,2,3,1,2,3], [2,3,3,2,3]; # True check [3,2,6,1,1,6,2,3,2,6,6,6,6,1,6,6,3,3,7,2], [3,2,6,6,3,2,6,6,6,6,6,3,7]; # True ``` Double check that the correct elements are being thrown out ``` # have to change it to a pure number # when checking $_ V my &code = {$_=$;grep {++.{+$^n}%$n},@_} # only matters here because we are using # a subclass of Int but want it to use # the same key as a normal Int sub F ( Int $v ) { IntStr.new: $v, "Fail($v)" } # prove that it passes through unchanged say [F(2)]; # (Fail(2)) say code [3,2,6,F(1),F(1),6,F(2),3,2,6,6,6,F(6),F(1),6,6,F(3),3,7,F(2)]; # (3 2 6 6 3 2 6 6 6 6 6 3 7) ``` [Answer] ## JavaScript ES6, 34 bytes ``` a=>a.filter(v=>f[v]=-~f[v]%v,f=[]) ``` Turned out to be the same as Brad's Perl algorithm. Edit: Saved 2 bytes thanks to @edc65. [Answer] ## Seriously, ~~22~~ 17 bytes ``` k╗,;`;;╜o;╗c%`M@░ ``` Hex Dump: ``` 6bbb2c3b603b3bbd6f3bbb6325604d40b0 ``` [Try It Online](http://seriously.tryitonline.net/#code=a-KVlyw7YDs74pWcbzvilZdjJWBNQOKWkQ&input=WzIsMyw0LDIsMyw0LDIsMyw0LDIsMyw0XQ) Explanation: ``` k╗ Put empty list in reg0 ,; Two copies of input ` `M Map over the list ;; Make 2 extra copies of n ╜o Load reg0 and push the n onto it ;╗ Put a copy back in reg0 c Count the number of copies of n in the list % Take the result modulo n @░ Filter the original list with the resulting list ``` [Answer] ## Mathematica, ~~40~~ ~~38~~ 36 bytes ``` Select[(f@#=#)&/@#,++f[#]~Mod~#>0&]& ``` This is an unnamed function taking and returning a `List`. It defines a named function `f` when executed (to keep track of the numbers), but takes care of resetting the relevant definitions of `f` beforehand. ### Explanation The way functions (or function definitions) work in Mathematica is really powerful. As in Haskell (for instance), functions cannot only be overloaded and defined for certain types, but also for individual values (or arbitrary patterns of arguments, actually). But it is even more powerful than Haskell in that a) these values can be defined as side effects during control flow and b) the values can also be redefined at any time. That means functions are actually pretty powerful lookup tables (that can optionally *compute* the looked-up value instead of just storing it). If we remove the golfitude from the code it would look a bit like this: ``` g[list_] := ( Map[ (f[#] = #) &, list ]; Select[ list, Mod[++f[#], #] > 0 & ] ) ``` So first, we loop over the input and define `f[x] = x`, for all `x` in the list. `f` will ultimately be used to keep track of how often each number has already appeared in the list. Why do we not count from `0`? The loop over the list is a `Map`. The expression `f[x] = y` returns `y` (in addition to storing the function definition). So by setting `f[x]` to `x`, the map will evaluate to the input list itself. That saves two bytes because then we don't need to provide `list` again explicitly to `Select`. Starting from `x` instead of `0` doesn't affect the computation at all since we're only ever interested in `Mod[f[x], x]`. (Normally we could simply use something like `f[_] = 0` as a fallback definition to avoid the `Map`, but we don't know if our function has been used before, which would leave some previous values defined that would mess with our counting.) Then `Select` filters the list by keeping only those elements where the unnamed function passed as the second argument yields `True`. That function *first* increments the value of `f[x]` (where `x` is the current list element), in order to count the occurrences, and then it takes the resulting count modulo `x`. We want to discard all elements where this yields `0`. [Answer] ## CJam, 17 bytes ``` Lq~{:X+_Xe=X%},p; ``` Just beat... J? Not sure what my expectations are for this challenge, really. Note that `""` is CJam's representation of an empty array. [Try it online](http://cjam.aditsu.net/#code=Lq~%7B%3AX%2B_Xe%3DX%25%7D%2Cp%3B&input=%5B3%202%206%201%201%206%202%203%202%206%206%206%206%201%206%206%203%203%207%202%5D) | [Test suite](http://cjam.aditsu.net/#code=qN%2F%7B%0A%0AL%5C~%7B%3AX%2B_Xe%3DX%25%7D%2Cp%3B%0A%0A%7D%2F&input=%5B1%5D%0A%5B2%5D%0A%5B1%201%201%5D%0A%5B2%202%202%5D%0A%5B1%201%202%202%202%203%203%203%203%5D%0A%5B1%202%203%201%202%203%201%202%203%201%202%203%5D%0A%5B3%202%206%201%201%206%202%203%202%206%206%206%206%201%206%206%203%203%207%202%5D%0A%5B5%204%205%204%203%205%204%205%204%205%204%203%205%204%205%203%203%203%204%205%204%205%204%205%204%203%203%203%205%204%5D%0A%5B6%204%205%208%202%209%203%201%208%205%203%205%205%206%203%205%201%202%203%209%203%205%208%207%205%209%201%203%204%208%202%203%204%207%208%205%208%205%203%201%5D%0A%5B4%204%209%2012%209%204%204%204%2012%209%2012%209%2012%204%2012%204%204%209%204%209%2012%204%2012%204%204%2012%204%204%209%2012%209%2012%209%204%209%2012%204%209%2012%209%2012%209%204%209%2012%2012%204%204%2012%204%5D%0A%5B2%202%2011%2011%2011%2011%206%202%202%206%206%202%202%202%202%206%2011%206%2011%2011%202%2011%202%206%206%2011%202%2011%206%202%206%206%206%206%206%2011%202%2011%2011%206%206%206%2011%206%202%206%202%206%206%202%2011%202%202%2011%2011%2011%2011%202%206%202%5D) (the last case is too long for the permalink) ### Explanation ``` L Push empty array (let's call it L) q~ Push input and evaluate { }, Filter the array elements by... :X Save number to variable X + Append to L _ Duplicate Xe= Count occurences of X X% Take modulo X The top element is popped to determine whether or not to keep that element, with the updated L kept on the stack for the next iteration p Print the resulting filtered array ; Pop L, which is now equal to the input array ``` [Answer] # J, 18 bytes ``` #~((0<]|+/@:=){:)\ ``` Usage: ``` (#~((0<]|+/@:=){:)\) 1 2 3 1 2 3 1 2 3 1 2 3 2 3 3 2 3 ``` Pretty straightforward method. We count the occurrences of a number up to it and select the number only if the number divides the count. More explanation comes later. [Try it online here.](http://tryj.tk/) [Answer] # JavaScript ES6, 55 bytes ``` a=>a.filter((v,i)=>a.filter((w,j)=>j<=i&v==w).length%v) ``` ### Explanation ``` a=> //a -> input array a.filter( //filter array. only keep elements if inside function returns truthy (v,i)=> //inside function to decide whether to keep items. v -> item; i -> index a.filter((w,j)=> //get all ocurrences of v that occur before index i j<=i&v==w //(this is done by keeping all items w at index j, if j <= i and v == w ).length%v //get length (count ocurrences), and mod v. //this will only be falsy if the number of ocurrences of v up to this index is divisible by v. (0 -> falsy, positive -> truthy) ) //so, we don't keep every second 2, every third 3, etc. ``` [Answer] ## PowerShell, 56 bytes ``` param($a)$b=,0*($a|sort)[-1];$a|%{if(++$b[$_-1]%$_){$_}} ``` Uses a similar helper-array-trick as [Rainer P's answer](https://codegolf.stackexchange.com/a/70126/42963), which I developed independently but I apparently got FGITW'd. Takes input as an array with `param($a)`. We then create our helper array `$b` as a populated-with-zeros array by using the comma operator coupled with the overloaded multiplication operator. This creates `$b` to be equal to `@(0,0,0...0)` with `$b.length` equal to the maximal number in `$a`. (Quick plug for my "Showcase your language" [answer](https://codegolf.stackexchange.com/a/66119/42963) where I describe this in detail) Next is our output. We loop over every element of our input array `$a|%{...}` and each loop check an `if` statement. The conditional pre-increments the value in our helper array that corresponds with the current element, then checks whether it's a multiple of the current element with the modulo operator. If it is a multiple, the `%` will equal `0` which is falsey, so the `if` doesn't execute. Otherwise, we output the current element. Takes advantage of implicit typecasting to save on output formatting. If a function or program returns multiple elements, and you save the results to a variable, PowerShell will dynamically create that variable as an array. Example: ``` PS C:\Tools\Scripts\golfing> $testc = .\remove-every-nth-n.ps1 @(2,2,2) PS C:\Tools\Scripts\golfing> $testc 2 2 PS C:\Tools\Scripts\golfing> $testc.GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array ``` [Answer] # [Haskell](https://www.haskell.org/), ~~58~~ 56 bytes *2 bytes saved by xnor* ``` q w=[x|(n,x)<-zip[1..]w,0<mod(sum[1|u<-take n w,u==x])x] ``` [Try it online!](https://tio.run/##LYdBCoAgEAC/socOBatkXfUl4kEoSEqzUpTo71YUw8DMpI95XJZSNkhC5qt2mBtOTuMlo1QlbLldh/qIVrIrchL0PIKDhFGIrJqsitXGgQC/Gxeggg0kww77x5ev2f@9Kjc "Haskell – Try It Online") [Answer] # R, ~~110~~ ~~98~~ ~~99~~ 92 Bytes ``` function(a){for(i in 1:max(a))for(j in seq_along(b<-which(a==i)))if(j%%i<1)a[b[j]]=0;a[a>0]} ``` Edit complete rewrite fixes bug with test case 2/3 Edit 2 Save 7 bytes thanks to @Alex-A [Answer] # [MATL](https://esolangs.org/wiki/MATL), 20 bytes ``` tu"t@=f@@h0h)0w(]tg) ``` This uses [current release (10.2.1)](https://github.com/lmendo/MATL/releases/tag/10.2.1) of the language/compiler. [**Try it online!**](http://matl.tryitonline.net/#code=dHUidEA9ZkBAaDBoKTB3KF10Zyk&input=WzMsMiw2LDEsMSw2LDIsMywyLDYsNiw2LDYsMSw2LDYsMywzLDcsMl0) ### Explanation ``` tu % implicitly input array. Duplicate and get unique elements " % for each unique element, say "i" t % duplicate @=f % indices of occurrences of i @@h0h % build index representing i-th occurrences (Matlab's i:i:end) ) % keep only indices of i-th occurrences 0w( % set those entries to 0 ] % end for loop tg) % keep nonzeros only. Implicit display ``` [Answer] # R, 63 bytes ``` f=function(z){n=seq(z);for(i in n)z[which(z==i)[n*i]]=0;z[z>0]} ``` [Answer] ## C#, 224 bytes ``` List<int>R(List<int>l,int n=1){l=l.Where(w=>w!=0&&w!=1).ToList();for(int i=0,t=0;i<l.Count;i++){if(l[i]==n&&++t==n){l[i]=0;t=0;}}return !l.Any()||n>l.Max()?l:R(l,++n);} ``` This code uses recursion. With `using` statements that's 224 bytes (160 for the method code itself). [Try it online.](https://dotnetfiddle.net/Qh5g1O) ``` List <int> R(List <int> l, int n = 1) { l = l.Where(w => w > 1).ToList(); for (int i = 0, t = 0; i < l.Count; i++) { if (l[i] == n && ++t == n) { l[i] = 0; t = 0; } } return !l.Any() || n > l.Max() ? l : R(l, ++n); } ``` [Answer] # Haskell, 78 bytes ``` f l=[l!!n|n<-[0..length l-1],0/=mod(1+(length.filter(==l!!n)$take n l))(l!!n)] ``` [Try it Online!](https://tio.run/##JctBDoMgEEbhq/wmLiBFKu22cxLCgkSoxHHaKMvenUbN233Jm@O@JObWMpg8d5385DX40VpO8q4zeHDBjHdaP5NyN3WpzYVr2hTRcei@xiVBwFqrE0JbYxEQvluRih4Z3hlnHmfPq9D@) [Answer] # [Perl 5](https://www.perl.org/), 24 + 1 `-p`= 25 bytes ``` $\.=$_ if++$k{0|$_}%$_}{ ``` [Try it online!](https://tio.run/##K0gtyjH9/18lRs9WJV4hM01bWyW72qBGJb5WFYir//835jLiMuMyBEIzIAvCg0BDMGkMhOZcRv/yC0oy8/OK/@v6muoZGBr81y0AAA "Perl 5 – Try It Online") Input has each entry on a separate line [Answer] # C# - 177 Bytes ``` void r(List<int> i){for(int c=1,k=1,m=i.Max();k<=m;k++){var n=new List<int>();foreach(var o in i)if(o==k&&c++==k)c = 1;else n.Add(o);i=n;}Console.WriteLine(string.Join(" ",i));} ``` Ungolfed ``` void r(List<int> i) { for (int c = 1, k = 1, m = i.Max(); k <= m; k++) { var n = new List<int>(); foreach (var o in i) if (o == k && c++ == k) c = 1; else n.Add(o); i = n; } Console.WriteLine(string.Join(" ", i)); } ``` [Answer] ## Mathematica, 63 bytes ``` Fold[Delete[#,Position[#,#2][[#2;;;;#2]]~Check~{}]&,#,Union@#]& ``` Quite interesting to golf! Ignore the occasional message that pops up. [Answer] # Ruby, 120 bytes ``` ->a{1.upto(a.max).each{|i|k=0;a.length.times.each{|j|k+=1if a[j]==i;a[j]=''if k%i==0&&a[j]==i;a[j]}};a.select{|i|i!=''}} ``` [Answer] ## TI-BASIC, 47 bytes ``` Input X For(I,1,dim(∟X ∟X(I If fPart(sum(∟X=Ans),1,I)/Ans Ans→L₁(1+dim(L₁ End L₁ ``` This uses the fact that, on a fresh calculator, `L₁` is initialized and cleared. Note that trying to display an empty list in TI-BASIC throws an error. [Answer] ## APL, 16 chars ``` {⍵/⍨×⍵|+/¨⍵=,\⍵} ``` In English: * `,\⍵`: vector of the vector prefixes up to the nth-element of the argument * `+/¨⍵=`: per prefix vector, count how many are equal to the n-th element itself * `×⍵|`: signs of the mod's (that is: 0 if the remainder of the division is 0, 1 otherwise) * `⍵/⍨`: of the argument keep only the element where the mod is 0 [Answer] ## Racket 179 bytes ``` (λ(l)(define m(apply max l))(let g((n 1)(c 0))(set! l(for/list((i l))(if(= i n)(begin (set! c(+ 1 c))(if(= 0(modulo c n))0 i))i)))(if(< n m)(g(+ 1 n)0)(filter(λ(x)(> x 0))l)))) ``` Ungolfed: ``` (define f (λ(l) (define m (apply max l)) (let loop ((n 1) (c 0)) (set! l (for/list ((i l)) (if (= i n) (begin (set! c (+ 1 c)) (if (= 0 (modulo c n)) 0 i )) ; replace by 0 i ))) (if (< n m) (loop (+ 1 n) 0) (filter (λ(x)(> x 0)) l) ; remove all 0s )))) ``` Testing: ``` (f '[1]) (f '[2]) (f '[1 1 1]) (f '[2 2 2]) (f '[1 1 2 2 2 3 3 3 3]) (f '[1 2 3 1 2 3 1 2 3 1 2 3]) (f '[3 2 6 1 1 6 2 3 2 6 6 6 6 1 6 6 3 3 7 2]) ``` Output: ``` '() '(2) '() '(2 2) '(2 2 3 3 3) '(2 3 3 2 3) '(3 2 6 6 3 2 6 6 6 6 6 3 7) ``` [Answer] # [Factor](https://factorcode.org/), 61 bytes ``` [ H{ } clone '[ _ 2dup inc-at over of swap mod 0 > ] filter ] ``` [Try it online!](https://tio.run/##7ZbPboMwDMbvPIVvOw0R/mR0k3bddtll2qmqpoiGFq0EBummquLZmXFooO2eYAoG8@X32U4kLuQi01XTv7@9vD7dQ94c4FM2Su5AtG2VtVAKvQUlStnWIpMttPJrL9Wg6kZqfaibQum59rNK5cUGHjzv6AFeR2DQwSjDSTKKmRNeugZFY8ysAV5nWxDhktMETsawMsEoD9Pu5pslENMTWTVfme3jCy8afTuEk5Xi3AUdKaXWBIPT2xxyQTrF/RPUjAan5MTIUvIS6reDYwwsHebGFCRPKTYpJvecWGNqsCV/wHnX2WdhbLo5ET6@jSZs7NAkbkB46uDTF2B2oAWm4jSVsatNjd2djhRAiAxLggAfrAhCBx100EEHHXTQwf8PO6/rl/B8xF@1bFcpCTdL@IBwva@hUNmt0FB9ywaqHNofUUNZrSGAR1hBXuw0Gqs@CXBcKZpNofC3XqOsYQm@72ORFNm2/wU "Factor – Try It Online") The idea is to have a hash table that keeps a running count of each element. Then we reject each element from the input that is divisible by its current count. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` ʒˆ¯y¢yÖ_ ``` Inspired by [*@RainerP.*'s awk answer](https://codegolf.stackexchange.com/a/70126/52210). [Try it online](https://tio.run/##yy9OTMpM/f//1KTTbYfWVx5aVHl42qPOBf//RxvrGOmY6RgCoRmQBeFBoCGYNAZCcx2jWAA) or [verify all test cases](https://tio.run/##7ZE9bsMwDIX3niLwzMGyZVUpUGTOlAMYHlogQ5e2QJMCHroWyJohc5ALZAlyAGdrb5GLuORjZLs/JygE2hT5PZKS5aeXu/uHefuaTB@fl4ubUUL17VUyWy4uWfux/nxv9nWzq0@b82rbvlFznDSHtixNRaMyE2eIDRmxBYKEcjWFkv7yIuUcOJnCXgTJ1Ay8zLjW0QVZkjenEA0z3c7@0HLVpd0Bet5hjAN4NBVsDqsebIzY854FxwYjPRTLzEOTPny1ZchFMtHCEAZn1Vmo30kn9A1dyR9w0BUu25j@cbhvd1k1BlY5U@cUZKHD9TdtuoEd0Iow1ehPHW4KGadJKeOU1TTll8WUayOMMMIII4wwwgj/OayqLw). **Explanation:** ``` ʒ # Filter the (implicit) input-list by: ˆ # Pop and add the current integer to the global array ¢ # Count how many times y # the current integer ¯ # occurs in the global array ≠ # Check that this count is NOT Ö # evenly divisible y # by the current integer # (after which the filtered list is output implicitly as result) ``` [Answer] # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 27 bytes ``` gj<<fn(by**(ce~<gj)$gj)<pxn ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m708I7E4OzUnZ8FNxczcgvyiEoXC0sSczLTM1BSFgKLUnNKUVC6oRMDS0pI0XYu9abbpWTY2aXkaSZVaWhrJqXU26VmaKkBsU1CRB1FzUyE3MTPPtqBIJS3aWMdSx1DHWMcIiA2BEEQbxULULVgAoQE) ## Explanation This code is a rats nest. That's in part because to do the glue for this program I tried structuring it a bunch of different ways, plugging things into the pointfree converted until I ran out of ideas and using the shortest one. It's rather difficult to truly explain it, but the rough idea is as follows: First we use `pxn` to get all the prefixes of the list. Then we perform a filter to filter out prefixes where their last element occurs in the prefix a number of times divisible by that last element. Then we get the last element of each prefix. The rats nest is in the part where we "filter out prefixes where their last element occurs in the prefix a number of times divisible by that last element". By the description it seems like that is a rather complex operation. ## Reflection There are a couple of things I think would have been really helpful. * It would be nice to have a combined zip and filter. What I'd really like is something like ``` (Alternative f, Zip f) => (a -> b -> Bool) -> f a -> f b -> f a ``` But I'd happily settle for: ``` (Alternative f, Zip f) => f a -> f Bool -> f a ``` which seems like it would have more general use. * Speaking of odd filters. Why not have prefix/suffix filters? This solution is doing a filter on the prefix list, and I can imagine it happening again in the future. There are a couple of ways to do this. The best motivated types seem to be ``` (a -> List a -> Bool) -> List a -> List a ``` and ``` (List a -> Bool) -> List a -> List (List a) ``` ]
[Question] [ ### Objective Given a list of three-word passphrases, crack them all. Each time you guess, you will be given a clue in the style of [Mastermind](http://en.wikipedia.org/wiki/Mastermind_(board_game)), depicting how many characters match the password, and how many are in their correct position. The objective is to minimize the total number of guesses over all test cases. ### Passphrases From my system's default word list, I randomly chose 10,000 distinct words to make the dictionary for this challenge. All words consist of `a-z` only. This dictionary can be found [here](http://pastebin.com/KeJLY958) ([raw](http://pastebin.com/raw.php?i=KeJLY958)). From this dictionary, I generated 1000 passphrases consisting of three random space-separated words each (`apple jacks fever`, for example). Individual words can be reused within each passphrase (`hungry hungry hippos`). You can find the list of passphrases [here](http://pastebin.com/7NgyNeAe) ([raw](http://pastebin.com/raw.php?i=7NgyNeAe)), with one per line. Your program can use/analyze the dictionary file however you want. You **cannot** analyze the passphrases to optimize for this specific list. Your algorithm should still work given a different list of phrases ### Guessing To make a guess, you submit a string to a checker. It should return **only**: * The number of characters in your string also in the passphrase (*not* in the correct position) * The number of characters in the correct position If your string is a perfect match, it may output something indicating that (mine uses `-1` for the first value). For example, if the passphrase is `the big cat` and you guess `tiger baby mauling`, the checker should return `7,1`. 7 characters (`ige<space>ba<space>`) are in both strings but different positions, and 1 (`t`) is in the same position in both. Notice that spaces count. I've written an example (read: not optimized) function in Java, but feel free to write your own as long as it gives only the information required. ``` int[] guess(String in){ int chars=0, positions=0; String pw = currentPassword; // set elsewhere, contains current pass for(int i=0;i<in.length()&&i<pw.length();i++){ if(in.charAt(i)==pw.charAt(i)) positions++; } if(positions == pw.length() && pw.length()==in.length()) return new int[]{-1,positions}; for(int i=0;i<in.length();i++){ String c = String.valueOf(in.charAt(i)); if(pw.contains(c)){ pw = pw.replaceFirst(c, ""); chars++; } } chars -= positions; return new int[]{chars,positions}; } ``` ### Scoring Your score is simply the number of guesses you submit to the checker (counting the final, correct one) for all test phrases. The lowest score wins. You must crack **all** the phrases in the list. If your program fails on any of them, it is invalid. Your program must be deterministic. If run twice on the same set of passphrases, it should return the same result. In the case of a tie for first, I will run the tied entries on my computer four times each, and the lowest average time to solve all 1000 cases wins. My computer is running Ubuntu 14.04, with an [i7-3770K](http://ark.intel.com/products/65523/Intel-Core-i7-3770K-Processor-8M-Cache-up-to-3_90-GHz) and 16GB of some sort of RAM, in case that makes a difference to your program. For that reason, and to facilitate testing, your answer should be in a language which has a compiler/interpreter that can be downloaded from the web free of charge (not including free trials) and does not require sign up/registration. Title adapted from [XKCD](http://xkcd.com/936/) [Answer] ## C - total: 37171, min: 24, max: 55, time: around 10 seconds I borrowed [Ray's idea](https://codegolf.stackexchange.com/a/36940) to find the length of each word by guessing with spaces, except I am doing a binary search rather than a linear one, which saves me a lot of guesses. Once I determine the length of a word, I guess with the first word which matches its length and I record the number of correct positions. Then I select the first word from the set of all words which share the same number of positions with my first guess as the mystery word. For my third guess I select the first word from the set of all words which share the same number of positions with my first guess as the mystery word and the same number of positions as my second guess with the mystery word, etc. Using this method I'm able to guess each word, one at a time, in about 5-10 guesses. Obviously the third word I have to do a little differently because I don't know its length, but the method is similar. I use a file which contains a matrix of the number of positions each word share in common that I've precomputed. The majority of the run-time is incurred while loading the precomputed data. You can download everything [here](http://orbitaldecay.com/code/mastermind.zip). ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #define DICTIONARY_SIZE 10000 #define PHRASE_COUNT 1000 #define MAX_STRING 512 #define MAX_SAVED_GUESSES 100 #define DEBUG typedef struct { int wordlen; char word[MAX_STRING]; } dictionary_entry; static int g_guesses; static int g_max_word_len; static int g_min_word_len; static char *g_password; static dictionary_entry g_dictionary[DICTIONARY_SIZE]; static char g_phrases[PHRASE_COUNT][MAX_STRING]; static int g_pos_matrix[DICTIONARY_SIZE][DICTIONARY_SIZE]; /* Returns true if the guess was correct and false otherwise */ int guess(char *in, int *chars, int *positions) { int i, j, contains; char c, pw[1024]; /* Increment the total guess count */ g_guesses++; strcpy(pw, g_password); *chars = 0; *positions = 0; for (i = 0; (i < strlen(in)) && (i < strlen(pw)); i++) if (in[i] == pw[i]) (*positions)++; if (strcmp(in, pw) == 0) { *chars = -1; return 1; } for (i = 0; i < strlen(in); i++) { for (j = 0; j < strlen(pw); j++) { if (pw[j] == in[i]) { (*chars)++; pw[j] = '*'; break; } } } (*chars) -= (*positions); return 0; } int checker() { char guess_str[MAX_STRING], *guess_ptr; int i, j, saved_guesses, word; int guesses; int chars, positions; int wordlen[3], wordidx[3]; int guesswordidx[MAX_SAVED_GUESSES]; int guesswordpos[MAX_SAVED_GUESSES]; int tryit, finished; /* Initialize everything */ finished = 0; guess_ptr = guess_str; for (i = 0; i < 3; i++) { wordlen[i] = -1; wordidx[i] = -1; } guesses = 0; for (word = 0; word < 3; word++) { saved_guesses = 0; // If we're not on the last word, figure out how long the word is by // doing a binary search using spaces if (word < 2) { int a = g_min_word_len, b = g_max_word_len; int c; while (wordlen[word] == -1) { c = (b + a) / 2; for (i = 0; i <= c; i++) { guess_ptr[i] = ' '; } guess_ptr[i] = '\0'; guess(guess_str, &chars, &positions); guesses++; if (positions == 0) { if (b - a < 2) wordlen[word] = b; a = c; } else { if (b - a < 2) wordlen[word] = c; b = c; } } #ifdef DEBUG printf("\tLength of next word is %d.\n", wordlen[word]); #endif } // Look for words using matching positions from previous guesses to improve our search for (i = 0; i < DICTIONARY_SIZE; i++) { tryit = 1; for (j = 0; j < saved_guesses; j++) { if (g_pos_matrix[guesswordidx[j]][i] != guesswordpos[j]) { tryit = 0; break; } } // If the word length is incorrect then don't bother if ((word < 2) && (g_dictionary[i].wordlen != wordlen[word])) tryit = 0; if (tryit) { strcpy(guess_ptr, g_dictionary[i].word); guess(guess_str, &chars, &positions); guesses++; #ifdef DEBUG printf("\tWe guessed \"%s\", it had %d correct positions.\n", g_dictionary[i].word, positions); #endif guesswordidx[saved_guesses] = i; guesswordpos[saved_guesses] = positions; saved_guesses++; // If we're on the last word and all the positions matched then check if we've found the phrase if ((word == 2) && (g_dictionary[i].wordlen == positions)) { sprintf(guess_ptr, "%s %s %s", g_dictionary[wordidx[0]].word, g_dictionary[wordidx[1]].word, g_dictionary[i].word); guesses++; if (guess(guess_ptr, &chars, &positions)) { finished = 1; break; } } } } wordidx[word] = guesswordidx[saved_guesses - 1]; wordlen[word] = g_dictionary[guesswordidx[saved_guesses - 1]].wordlen; #ifdef DEBUG printf("\tThe next word is \"%s\".\n", g_dictionary[wordidx[word]].word); #endif guess_ptr += wordlen[word] + 1; for (i = 0; i < guess_ptr - guess_str; i++) { guess_str[i] = '#'; } } #ifdef DEBUG if (finished) { sprintf(guess_str, "%s %s %s", g_dictionary[wordidx[0]].word, g_dictionary[wordidx[1]].word, g_dictionary[wordidx[2]].word); printf("\tPhrase is \"%s\". Found in %d guesses.\n", guess_str, guesses); } else { printf("Oh noes! Something went wrong!\n"); exit(1); } #endif return guesses; } int main(int argc, char **argv) { FILE *dictfp, *phrasefp, *precompfp; int i, j, total_count, chars, positions; g_max_word_len = 0; g_min_word_len = 9999; dictfp = fopen("dictionary.txt", "r"); for (i = 0; i < DICTIONARY_SIZE; i++) { fgets(g_dictionary[i].word, MAX_STRING, dictfp); while (!isalpha(g_dictionary[i].word[strlen(g_dictionary[i].word) - 1])) g_dictionary[i].word[strlen(g_dictionary[i].word) - 1] = '\0'; g_dictionary[i].wordlen = strlen(g_dictionary[i].word); if (g_dictionary[i].wordlen < g_min_word_len) g_min_word_len = g_dictionary[i].wordlen; if (g_dictionary[i].wordlen > g_max_word_len) g_max_word_len = g_dictionary[i].wordlen; } fclose(dictfp); phrasefp = fopen("phrases.txt", "r"); for (i = 0; i < PHRASE_COUNT; i++) { fgets(g_phrases[i], MAX_STRING, phrasefp); while (!isalpha(g_phrases[i][strlen(g_phrases[i]) - 1])) g_phrases[i][strlen(g_phrases[i]) - 1] = '\0'; } fclose(phrasefp); precompfp = fopen("precomp.txt", "r"); for (i = 0; i < DICTIONARY_SIZE; i++) { for (j = 0; j < DICTIONARY_SIZE; j++) { fscanf(precompfp, "%d ", &(g_pos_matrix[i][j])); } } g_guesses = 0; int min = 9999, max = 0, g; for (i = 0; i < PHRASE_COUNT; i++) { g_password = g_phrases[i]; #ifdef DEBUG printf("Testing passphrase \"%s\"...\n", g_password); #endif g = checker(); if (g < min) min = g; if (g > max) max = g; } printf("Total %d. Min %d. Max %d.\n", g_guesses, min, max); return 0; } ``` It's also fun to watch it narrow in on words: ``` Testing passphrase "somebody sighed intimater"... Length of next word is 8. We guessed "abashing", it had 0 correct positions. We guessed "backlogs", it had 1 correct positions. We guessed "befitted", it had 0 correct positions. We guessed "caldwell", it had 0 correct positions. We guessed "disgusts", it had 0 correct positions. We guessed "encroach", it had 0 correct positions. We guessed "forenoon", it had 3 correct positions. We guessed "hotelman", it had 2 correct positions. We guessed "somebody", it had 8 correct positions. The next word is "somebody". Length of next word is 6. We guessed "abacus", it had 0 correct positions. We guessed "baboon", it had 0 correct positions. We guessed "celery", it had 0 correct positions. We guessed "diesel", it had 2 correct positions. We guessed "dimple", it had 1 correct positions. We guessed "duster", it had 1 correct positions. We guessed "hinged", it had 3 correct positions. We guessed "licked", it had 3 correct positions. We guessed "sighed", it had 6 correct positions. The next word is "sighed". We guessed "aaas", it had 0 correct positions. We guessed "b", it had 0 correct positions. We guessed "c", it had 0 correct positions. We guessed "debauchery", it had 2 correct positions. We guessed "deceasing", it had 0 correct positions. We guessed "echinoderm", it had 3 correct positions. We guessed "enhanced", it had 1 correct positions. We guessed "intimater", it had 9 correct positions. The next word is "intimater". Phrase is "somebody sighed intimater". Found in 38 guesses. ``` [Answer] ## Python 3.4 - min: 21, max: 29, total: 25146, time: 20min ## ~~min: 30, max: 235, total: 41636, time: 4min~~ ### Update: 1. Use binary search to find space. The idea is borrowed from [Orby's answer](https://codegolf.stackexchange.com/a/36958/6935). One spot I optimized is that if you found 2 spaces in a range when searching for the first space, you can narrow the search range of the second space. 2. Save wrong guesses along with their result. Compare with them in following guesses. This can save a lot. 3. Reduce letter enumerate count to 12, thanks to update #2. ![enter image description here](https://i.stack.imgur.com/JQ7yw.png) --- This mehod don't use randomness so the score will not change. First it use guesses like the following to find the first and second spaces in the answer. ``` . ...................... .. ..................... ... .................... .... ................... # more follows, until two spaces found. ``` Then, it count occurrence of each letter by guessing `aaaaa...`, `bbbbb....`... After these it will cost about 40 steps. In fact, we don't need to try all the letters and we can try them in arbitary order. In most cases, trying about 20 letters is enough. Here I choose 21. Now it know the length of the first word and the second word so it can filter out a list of candidates for these two words. Normally it will have about 100 candidates left for each. Then it just enumerate the first and the second word. Once the first two words is enumerated, we can infer all valid third word since we know it's character counts. To optimize for speed, I use the `concurrent.futures` to add multiprocessing to the program. So you need Python 3 to run it and I tested it with Python 3.4 on my Linux box. Also, you need to install `numpy`. ``` import sys import functools from collections import defaultdict from concurrent.futures import ProcessPoolExecutor import numpy as np def debug(*args, **kwargs): return print(*args, **kwargs) def compare(answer, guess): b = sum(1 for x, y in zip(guess, answer) if x == y) a = 0 c = defaultdict(int) for x in answer: c[x] += 1 for x in guess: if c.get(x, 0) > 0: a += 1 c[x] -= 1 return a, b def checker_task(guesser): @functools.wraps(guesser) def task(case): i, answer = case return (i, answer, run_checker(answer, guesser)) return task def run_checker(answer, guesser): guess_count = 0 guesser = guesser() guess = next(guesser) while True: guess_count += 1 if answer == guess: break try: guess = guesser.send(compare(answer, guess)) except StopIteration: raise Exception('Invalid guesser') try: guesser.send((-1, -1)) except StopIteration: pass return guess_count # Preprocessing words = list(map(str.rstrip, open('dict.txt'))) words_with_len = defaultdict(list) for word in words: words_with_len[len(word)].append(word) M = 12 chars = 'eiasrntolcdupmghbyfvkwzxjq'[:M] char_ord = {c: i for i, c in enumerate(chars)} def get_fingerprint(word): counts = [0] * (M + 1) for c in word: counts[char_ord.get(c, M)] += 1 return tuple(counts[:-1]) word_counts = {word: np.array(get_fingerprint(word)) for word in words} # End of preprocessing # @profile @checker_task def guesser1(): # Find spaces using binary search max_word_len = max(map(len, words)) max_len = max_word_len * 3 + 2 # debug('max_len', max_len) s_l = [1, 3] s_r = [max_len - 3, max_len - 1] for i in range(2): while s_l[i] + 1 < s_r[i]: # debug(list(zip(s_l, s_r))) mid = (s_l[i] + s_r[i]) // 2 guess = '.' * s_l[i] + ' ' * (mid - s_l[i]) a, b = yield guess if b > 1 and i == 0: s_l[1] = max(s_l[1], s_l[0] + 2) s_r[1] = min(s_r[1], mid) s_r[0] = mid - 2 elif b > 0: s_r[i] = mid else: s_l[i] = mid if i == 0: s_l[1] = max(s_l[1], s_l[0] + 2) spaces = s_l del s_l, s_r word_lens = [spaces[0], spaces[1] - spaces[0] - 1, None] debug('word_lens', word_lens) debug('spaces', spaces) char_counts = [0] * M for i, c in enumerate(chars): guess = c * max_len _, char_counts[i] = yield guess char_counts = np.array(char_counts) candidates = [words_with_len[word_lens[0]], words_with_len[word_lens[1]], words] for i, ws in enumerate(candidates): candidates[i] = [word for word in ws if np.alltrue(char_counts >= word_counts[word])] P = defaultdict(list) for word in candidates[2]: P[get_fingerprint(word)].append(word) debug('candidates', list(map(len, candidates))) wrong_guesses = [] # @profile def search(i, counts, current): if i == 2: rests = tuple(char_counts - counts) for word in P[rests]: current[i] = word guess_new = ' '.join(current) for guess, t in wrong_guesses: if t != compare(guess_new, guess): break else: yield current return for word in candidates[i]: counts += word_counts[word] if np.alltrue(char_counts >= counts): current[i] = word yield from search(i + 1, counts, current) counts -= word_counts[word] try_count = 0 for result in search(0, np.array([0] * M), [None] * 3): guess = ' '.join(result) a, b = yield guess try_count += 1 if a == -1: break wrong_guesses.append((guess, (a, b))) debug('try_count', try_count) def test(test_file, checker_task): cases = list(enumerate(map(str.rstrip, open(test_file)))) scores = [None] * len(cases) with ProcessPoolExecutor() as executor: for i, answer, score in executor.map(checker_task, cases): print('-' * 80) print('case', i) scores[i] = score print('{}: {}'.format(answer, score)) sys.stdout.flush() print(scores) print('sum:{} max:{} min:{}'.format(sum(scores), max(scores), min(scores))) if __name__ == '__main__': test(sys.argv[1], guesser1) ``` [Answer] # Scala 9146 (min 7, max 15, avg 9.15) time: 2000 seconds Like many entries I start by getting the total length, then finding the spaces, getting a bit more information, reducing down to the remaining candidates and then guessing phrases. Inspired by the original xkcd comic, I tried to apply my rudimentary understanding of information theory. There are a trillion possible phrases or just under 40 bits of entropy. I set a goal of under 10 guesses per test phrase, which means we need to learn on average nearly 5 bits per query (since the last one is useless). With each guess we get back two numbers and roughly speaking the bigger potential range of those numbers, the more we expect to learn. To simplify the logic, I use each query as effectively two separate questions so each guess string is two parts, a left side interested in the number of correct positions (black pegs in mastermind) and a right side interested in the number of correct chars (total pegs). Here is a typical game: ``` Phrase: chasteness legume such 1: p0 ( 1/21) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -aaaaaaaaaaaabbbbbbbbbcccccccccdddddddddeeeeeeeeeeeeeeefffffffffgggggggggggghhhhhhhhhiiiiiiiiiiiiiiiiiijjjjjjkkkkkkkkkllllllllllllmmmmmmmmmnnnnnnnnnnnnoooooooooooopppppppppqqqrrrrrrrrrrrrssssssssssssssstttttttttuuuuuuuuuuuuvvvvvvwwwwwwxxxyyyyyyyyyzzzzzz 2: p1 ( 0/ 8) - - - --- - ---aaaaaaaaaaaadddddddddeeeeeeeeeeeeeeefffffffffjjjjjjkkkkkkkkkllllllllllllooooooooooooqqqwwwwwwxxxyyyyyyyyyzzzzzz 3: p1 ( 0/11) ----- ------ ---------bbbbbbbbbdddddddddeeeeeeeeeeeeeeefffffffffgggggggggggghhhhhhhhhiiiiiiiiiiiiiiiiiikkkkkkkkkllllllllllllppppppppptttttttttvvvvvv 4: p1 ( 2/14) ---------- ------ ----ccccccccceeeeeeeeeeeeeeehhhhhhhhhkkkkkkkkkllllllllllllmmmmmmmmmooooooooooooqqqrrrrrrrrrrrrsssssssssssssssvvvvvvwwwwwwzzzzzz 5: p3 ( 3/ 3) iaaiiaaiai iaaiia iaaiaaaaaaaaaaaabbbbbbbbbdddddddddiiiiiiiiiiiiiiiiiikkkkkkkkkllllllllllllqqquuuuuuuuuuuuvvvvvvyyyyyyyyy 6: p3 ( 3/11) aaaasassaa aaaasa aaaaaaaaaaaaaaaabbbbbbbbbcccccccccdddddddddfffffffffhhhhhhhhhppppppppprrrrrrrrrrrrssssssssssssssstttttttttuuuuuuuuuuuuwwwwwwxxxyyyyyyyyy 7: p4 ( 4/10) accretions shrive pews 8: p4 ( 4/ 6) barometric terror heir 9: p4 SUCCESS chasteness legume such ``` ## Guessing spaces Each space guess can return at most 2 black pegs; I tried to construct guesses to return 0,1, and 2 pegs with probabilities 1/4,1/2, and 1/4 respectively. I believe this is the best you can do for an expected 1.5bits of information. I settled on an alternating string for the first guess followed by randomly generated ones, though it turns out it's usually worthwhile to just start guessing on the second or third try, since we know the word length frequencies. ## Learning character set counts For the right side guesses I pick random (always 2 of e/i/a/s) sets of characters so that the expected number returned is half the phrase length. A higher variance means more information and from the wikipedia page on the [binomial distribution](http://en.wikipedia.org/wiki/Binomial_distribution) I'm estimating about 3.5 bits per query (at least for the first few before the information becomes redundant). Once spacing is known, I use random strings of the most common letters on the left side, chosen so as not to conflict with the right side. ## Coalescing the remaining candidates This game is a compute speed / query efficiency tradeoff and the enumeration of remaining candidates can take a really long time without structured information like specific characters. I optimized this part by mainly collecting information that's invariant with word order, which lets me precompute the character-set counts for each individual word and compare them with the counts learned from the queries. I pack these counts into a Long integer, using the machine equality comparator and adder to test all my character counts in parralel. This was a huge win. I can pack up to 9 counts in the Long, but I found collecting the additional information wasn't worth it and settled on 6 to 7. After the remaining candidates are known, if the set is reasonably small I pick the one with the lowest expected log of remaining candidates. If the set is large enough to make this time consuming, I choose from a small sample set. Thanks everyone. This was a fun game and enticed me to sign up to the site. **Update:** Cleaned code for simplicity and readability, with minor tweaks to the algorithm, resulting in an improved score. Original score: 9447 (min 7, max 13, avg 9.45) time: 1876 seconds New code is 278 lines of Scala, below ``` object HorseBatteryStapleMastermind { def main(args: Array[String]): Unit = run() print () val n = 1000 // # phrases to run val verbose = true // whether to print each game //tweakable parameters val prob = 0.132 // probability threshold to guess spacing val rngSeed = 11 // seed for random number generator val minCounts = 6 // minimum char-set counts before guessing val startTime = System.currentTimeMillis() def time = System.currentTimeMillis() - startTime val phraseList = io.Source.fromFile("pass.txt").getLines.toArray val wordList = io.Source.fromFile("words.txt").getLines.toArray case class Result(num: Int = 0, total: Int = 0, min: Int = Int.MaxValue, max: Int = 0) { def update(count: Int) = Result(num + 1, total + count, Math.min(count, min), Math.max(count, max)) def resultString = f"#$num%4d Total: $total%5d Avg: ${total * 1.0 / num}%2.2f Range: ($min%2d-$max%2d)" def timingString = f"Time: Total: ${time / 1000}%5ds Avg: ${time / (1000.0 * num)}%2.2fs" def print() = println(s"$resultString\n$timingString") } def run(indices: Set[Int] = (0 until n).to[Set], prev: Result = Result()): Result = { if (verbose && indices.size < n) prev.print() val result = prev.update(Querent play Oracle(indices.head, phraseList(indices.head))) if (indices.size == 1) result else run(indices.tail, result) } case class Oracle(idx: Int, phrase: String) { def query(guess: String) = Grade.compute(guess, phrase) } object Querent { def play(oracle: Oracle, n: Int = 0, notes: Notes = Notes0): Int = { if (verbose && n == 0) println("=" * 100 + f"\nPhrase ${oracle.idx}%3d: ${oracle.phrase}") val guess = notes.bestGuess val grade = oracle.query(guess) if (verbose) println(f"${n + 1}%2d: p${notes.phase} $grade $guess") if (grade.success) n + 1 else play(oracle, n + 1, notes.update(guess, grade)) } abstract class Notes(val phase: Int) { def bestGuess: String def update(guess: String, grade: Grade): Notes } case object Notes0 extends Notes(0) { def bestGuess = GuessPack.firstGuess def genSpaceCandidates(grade: Grade): List[Spacing] = (for { wlen1 <- WordList.lengthRange wlen2 <- WordList.lengthRange spacing = Spacing(wlen1, wlen2, grade.total) if spacing.freq > 0 if grade.black == spacing.black(bestGuess) } yield spacing).sortBy(-_.freq).toList def update(guess: String, grade: Grade) = Notes1(grade.total, genSpaceCandidates(grade), Limiter(Counts.withMax(grade.total - 2), Nil), GuessPack.stream) } case class Notes1(phraseLength: Int, spacingCandidates: List[Spacing], limiter: Limiter, guesses: Stream[GuessPack]) extends Notes(1) { def bestGuess = (chance match { case x if x < prob => guesses.head.spacing.take(phraseLength) case _ => spacingCandidates.head.mkString }) + guesses.head.charSet def totalFreq = spacingCandidates.foldLeft(0l)({ _ + _.freq }) def chance = spacingCandidates.head.freq * 1.0 / totalFreq def update(guess: String, grade: Grade) = { val newLim = limiter.update(guess, grade) val newCands = spacingCandidates.filter(_.black(guess) == grade.black) newCands match { case best :: Nil if newLim.full => Notes3(newLim.allCandidates(best)) case best :: Nil => Notes2(best, newLim, guesses.tail) case _ => Notes1(phraseLength, newCands, newLim, guesses.tail) } } } case class Notes2(spacing: Spacing, limiter: Limiter, guesses: Stream[GuessPack]) extends Notes(2) { def bestGuess = tile(guesses.head.pattern) + guesses.head.charSet def whiteSide(guess: String): String = guess.drop(spacing.phraseLength) def blackSide(guess: String): String = guess.take(spacing.phraseLength) def tile(guess: String) = spacing.lengths.map(guess.take).mkString(" ") def untile(guess: String) = blackSide(guess).split(" ").maxBy(_.length) + "-" def update(guess: String, grade: Grade) = { val newLim = limiter.updateBoth(whiteSide(guess), untile(guess), grade) if (newLim.full) Notes3(newLim.allCandidates(spacing)) else Notes2(spacing, newLim, guesses.tail) } } case class Notes3(candidates: Array[String]) extends Notes(3) { def bestGuess = sample.minBy(expLogNRC) def update(guess: String, grade: Grade) = Notes3(candidates.filter(phrase => grade == Grade.compute(guess, phrase))) def numRemCands(phrase: String, guess: String): Int = { val grade = Grade.compute(guess, phrase) sample.count(phrase => grade == Grade.compute(guess, phrase)) } val sample = if (candidates.size <= 32) candidates else candidates.sortBy(_.hashCode).take(32) def expLogNRC(guess: String): Double = sample.map(phrase => Math.log(1.0 * numRemCands(phrase, guess))).sum } case class Spacing(wl1: Int, wl2: Int, phraseLength: Int) { def wl3 = phraseLength - 2 - wl1 - wl2 def lengths = Array(wl1, wl2, wl3) def pos = Array(wl1, wl1 + 1 + wl2) def freq = lengths.map(WordList.freq).product def black(guess: String) = pos.count(guess(_) == ' ') def mkString = lengths.map("-" * _).mkString(" ") } case class Limiter(counts: Counts, guesses: List[String], extraGuesses: List[(String, Grade)] = Nil) { def full = guesses.size >= minCounts def update(guess: String, grade: Grade) = if (guesses.size < Counts.Max) Limiter(counts.update(grade.total - 2), guess :: guesses) else Limiter(counts, guesses, (guess, grade) :: extraGuesses) def updateBoth(whiteSide: String, blackSide: String, grade: Grade) = Limiter(counts.update(grade.total - 2).update(grade.black - 2), blackSide :: whiteSide :: guesses) def isCandidate(phrase: String): Boolean = extraGuesses forall { case (guess, grade) => grade == Grade.compute(guess, phrase) } def allCandidates(spacing: Spacing): Array[String] = { val order = Array(0, 1, 2).sortBy(-spacing.lengths(_)) //longest word first val unsort = Array.tabulate(3)(i => order.indexWhere(i == _)) val wordListI = WordList.byLength(spacing.lengths(order(0))) val wordListJ = WordList.byLength(spacing.lengths(order(1))) val wordListK = WordList.byLength(spacing.lengths(order(2))) val gsr = guesses.reverse val countsI = wordListI.map(Counts.compute(_, gsr).z) val countsJ = wordListJ.map(Counts.compute(_, gsr).z) val countsK = wordListK.map(Counts.compute(_, gsr).z) val rangeI = 0 until wordListI.size val rangeJ = 0 until wordListJ.size val rangeK = 0 until wordListK.size (for { i <- rangeI.par if Counts(countsI(i)) <= counts j <- rangeJ countsIJ = countsI(i) + countsJ(j) if Counts(countsIJ) <= counts k <- rangeK if countsIJ + countsK(k) == counts.z words = Array(wordListI(i), wordListJ(j), wordListK(k)) phrase = unsort.map(words).mkString(" ") if isCandidate(phrase) } yield phrase).seq.toArray } } object Counts { val Max = 9 val range = 0 until Max def withMax(size: Int): Counts = Counts(range.foldLeft(size.toLong) { (z, i) => (z << 6) | size }) def compute(word: String, x: List[String]): Counts = x.foldLeft(Counts.withMax(word.length)) { (c: Counts, s: String) => c.update(if (s.last == '-') Grade.computeBlack(word, s) else Grade.computeTotal(word, s)) } } case class Counts(z: Long) extends AnyVal { @inline def +(that: Counts): Counts = Counts(z + that.z) @inline def apply(i: Int): Int = ((z >> (6 * i)) & 0x3f).toInt @inline def size: Int = this(Counts.Max) def <=(that: Counts): Boolean = Counts.range.forall { i => (this(i) <= that(i)) && (this.size - this(i) <= that.size - that(i)) } def update(c: Int): Counts = Counts((z << 6) | c) override def toString = Counts.range.map(apply).map(x => f"$x%2d").mkString(f"Counts[$size%2d](", " ", ")") } case class GuessPack(spacing: String, charSet: String, pattern: String) object GuessPack { util.Random.setSeed(rngSeed) val RBF: Any => Boolean = _ => util.Random.nextBoolean() //Random Boolean Function def genCharsGuess(q: Char => Boolean): String = (for (c <- 'a' to 'z' if q(c); j <- 1 to WordList.maxCount(c)) yield c).mkString def charChooser(i: Int)(c: Char): Boolean = c match { case 'e' => Array(true, true, true, false, false, false)(i % 6) case 'i' => Array(false, true, false, true, false, true)(i % 6) case 'a' => Array(true, false, false, true, true, false)(i % 6) case 's' => Array(false, false, true, false, true, true)(i % 6) case any => RBF(any) } def genSpaceGuess(q: Int => Boolean = RBF): String = genPatternGuess(" -", q) def genPatternGuess(ab: String, q: Int => Boolean = RBF) = (for (i <- 0 to 64) yield (if (q(i)) ab(0) else ab(1))).mkString val firstGuess = genSpaceGuess(i => (i % 2) == 1) + genCharsGuess(_ => true) val stream: Stream[GuessPack] = Stream.from(0).map { i => GuessPack(genSpaceGuess(), genCharsGuess(charChooser(i)), genPatternGuess("eias".filter(charChooser(i)))) } } } object WordList { val lengthRange = wordList.map(_.length).min until wordList.map(_.length).max val byLength = Array.tabulate(lengthRange.end)(i => wordList.filter(_.length == i)) def freq(wordLength: Int): Long = if (lengthRange contains wordLength) byLength(wordLength).size else 0 val maxCount: Map[Char, Int] = ('a' to 'z').map(c => (c -> wordList.map(_.count(_ == c)).max * 3)).toMap } object Grade { def apply(black: Int, white: Int): Grade = Grade(black | (white << 8)) val Success = Grade(-1) def computeBlack(guess: String, phrase: String): Int = { @inline def posRange: Range = 0 until Math.min(guess.length, phrase.length) @inline def sameChar(p: Int): Boolean = (guess(p) == phrase(p)) && guess(p) != '-' posRange count sameChar } def computeTotal(guess: String, phrase: String): Int = { @inline def minCount(c: Char): Int = Math.min(phrase.count(_ == c), guess.count(_ == c)) minCount(' ') + ('a' to 'z').map(minCount).sum } def compute(guess: String, phrase: String): Grade = { val black = computeBlack(guess, phrase) if (black == guess.length && black == phrase.length) Grade.Success else Grade(black, computeTotal(guess, phrase) - black) } } case class Grade(z: Int) extends AnyVal { def black: Int = z & 0xff def white: Int = z >> 8 def total: Int = black + white def success: Boolean = this == Grade.Success override def toString = if (success) "SUCCESS" else f"($black%2d/$white%2d)" } } ``` [Answer] # Java 13,923 (min: 11, max: 17) ### Update: improved score (broke the <14/crack avg!), new code * Checking of known characters now denser (now ABABAB\*, instead of -A-A-A-A\*) * When no known characters are available, two unknowns will be counted in a single guess * Wrong guesses are stored and used to check possible matches * Some constant tweaking with new logic in place ### Original post I've decided to focus completely on the amount of guesses instead of performance (given the rules). This has resulted in a **very** slow smart program. Instead of stealing from the known programs I decided to write everything from scratch, but it turns out some/most ideas are the same. ### Algorithm This is how mine works: 1. Do a single query which results in the amount of e's and characters in total 2. Next we look for the spaces, appending some unknown characters at the end to get a character count 3. Once the spaces are found we still want to find out more character counts, in the mean time I also get more data on the known characters (if they are on even positions) that will help me eliminate a lot of phrases. 4. When we reach a certain limit (trail/error) it generates all possible phrases and starts a binary search, most of the time still appending unknown characters at the end. 5. Finally we do some guesses! ### Example guesses Here is an actual example: ``` Phase 1 (find the e's and total character count): eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccccccccccccddddddddddddddddddffffffffffffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnooooooooooooooooooppppppppppppppppppqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrssssssssssssssssssttttttttttttttttttuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzz Phase 2 (find the spaces): ----------------iiiiiiiiiiiiiiiiii ----------aaaaaaaaaaaa -------------sssssssssssssss --------------rrrrrrrrrrrr ---------------nnnnnnnnnnn -------ttttttttt ---------oooooooo --------lllllll Phase 3 (discovery of characters, collecting odd/even information): eieieieieieieieieieieieicccccc ararararararararararararddddd ntntntntntntntntntntntntuuuuu Phase 4 (binary search with single known character): ------------r------------ppppp Phase 5 (actual guessing): enveloper raging charter racketeer rowing halpern ``` Because my code never really focusses on single words and only collects information about the complete phrase it has to generate a lot of those phrases making it very slow. ### Code And finally here is the (ugly) code, don't even try to understand it, sorry: ``` import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; public class MastermindV3 { // Order of characters to analyze: // eiasrntolcdupmghbyfvkwzxjq - 97 private int[] lookup = new int[] {4, 8, 0, 18, 17, 13, 19, 14, 11, 2, 3, 20, 15, 12, 6, 7, 1, 24, 5, 21, 10, 22, 25, 23, 9, 16}; public static void main(String[] args) throws Exception { new MastermindV3().run(); } private void run() throws Exception { long beforeTime = System.currentTimeMillis(); Map<Integer, List<String>> wordMap = createDictionary(); List<String> passPhrases = createPassPhrases(); int min = Integer.MAX_VALUE; int max = 0; for(String phrase:passPhrases) { int before = totalGuesses; solve(wordMap, phrase); int amount = totalGuesses - before; min = Math.min(min, amount); max = Math.max(max, amount); System.out.println("Amount of guesses: "+amount+" : min("+min+") max("+max+")"); } System.out.println("Total guesses: " + totalGuesses); System.out.println("Took: "+ (System.currentTimeMillis()-beforeTime)+" ms"); } /** * From the original question post: * I've added a boolean for the real passphrase. * I'm using this method to check previous guesses against my own matches (not part of Mastermind guesses) */ int totalGuesses = 0; int[] guess(String in, String pw, boolean againstRealPassphrase) { if(againstRealPassphrase) { //Only count the guesses against the password, not against our own previous choices totalGuesses++; } int chars=0, positions=0; for(int i=0;i<in.length()&&i<pw.length();i++){ if(in.charAt(i)==pw.charAt(i)) positions++; } if(positions == pw.length() && pw.length()==in.length()) return new int[]{-1,positions}; for(int i=0;i<in.length();i++){ String c = String.valueOf(in.charAt(i)); if(pw.contains(c)){ pw = pw.replaceFirst(c, ""); chars++; } } chars -= positions; return new int[]{chars,positions}; } private void solve(Map<Integer, List<String>> wordMap, String pw) { // Do one initial guess which gives us two things: // The amount of characters in total // The amount of e's int[] initialResult = guess(Facts.INITIAL_GUESS, pw, true); // Create the object that tracks all the known facts/bounds: Facts facts = new Facts(initialResult); // Determine a pivot and find the spaces (binary search) int center = ((initialResult[0] + initialResult[1]) / 3) + 1; findSpaces(center, facts, pw); // When finished finding the spaces (and some character information) // We can calculate the lengths: int length1 = (facts.spaceBounds[0]-1); int length2 = (facts.spaceBounds[2]-facts.spaceBounds[0]-1); int length3 = (facts.totalLength-facts.spaceBounds[2]+2); // Next we enter a discovery loop where we find out two things: // 1) The amount of a new character // 2) How many of a known character are on an even spot int oddPtr = 0; int pairCnt = 0; // Look for more characters, unless we have one HUGE word, which should be brute forcible easily int maxLength = Math.max(length1, Math.max(length2, length3)); while(maxLength<17 && !facts.doneDiscovery()) { // We don't need all characters, the more unknowns the slower the code, but less guesses // Try to generate a sequence with ABABABABAB... with two characters with known length String testPhrase = ""; int expected = 0; while(oddPtr < facts.charPtr && (facts.oddEvenUsed[oddPtr]!=-1 || facts.charBounds[lookup[oddPtr]] == 0)) { oddPtr++; } // If no character unknown, try pattern -A-A-A-A-A-A-A... with just one known pattern int evenPtr = oddPtr+1; while(evenPtr < facts.charPtr && (facts.oddEvenUsed[evenPtr]!=-1 || facts.charBounds[lookup[evenPtr]] == 0)) { evenPtr++; } if(facts.oddEvenUsed[oddPtr]==-1 && facts.charBounds[lookup[oddPtr]] > 0 && oddPtr < facts.charPtr) { if(facts.oddEvenUsed[evenPtr]==-1 && facts.charBounds[lookup[evenPtr]] > 0 && evenPtr < facts.charPtr) { for(int i = 0; i < (facts.totalLength + 3) / 2; i++) { testPhrase += ((char)(lookup[oddPtr] + 97) +""+ ((char)(lookup[evenPtr] + 97))); } expected += facts.charBounds[lookup[oddPtr]] + facts.charBounds[lookup[evenPtr]]; } else { for(int i = 0; i < (facts.totalLength + 3) / 2; i++) { testPhrase += ((char)(lookup[oddPtr] + 97) + "-"); } expected += facts.charBounds[lookup[oddPtr]]; } } // If we don't have known characters to explore, use the phrase-length part to discover the count of an unknown character boolean usingTwoNew = false; if(testPhrase.length() == 0 && facts.charPtr < 25) { usingTwoNew = true; //Fill with a new character while(testPhrase.length() < (facts.totalLength+2)) { testPhrase += (char)(lookup[facts.charPtr+1] + 97); } } else { while(testPhrase.length() < (facts.totalLength+2)) { testPhrase += "-"; } } // Use the part after the phrase-length to discover the count of an unknown character for(int i = 0; i<facts.charBounds[lookup[facts.charPtr]];i++) { testPhrase += (char)(lookup[facts.charPtr] + 97); } // Do the actual guess: int[] result = guess(testPhrase, pw, true); // Process the results, store the derived facts: if(oddPtr < facts.charPtr) { if(evenPtr < facts.charPtr) { facts.oddEvenUsed[evenPtr] = pairCnt; } facts.oddEvenUsed[oddPtr] = pairCnt; facts.oddEvenPairScore[pairCnt] = result[1]; pairCnt++; } if(usingTwoNew) { facts.updateCharBounds(result[0]); if(result[1] > 0) { facts.updateCharBounds(result[1]); } } else { facts.updateCharBounds((result[0]+result[1]) - expected); } } // Next we generate a list of possible phrases for further analysis: List<String> matchingPhrases = new ArrayList<String>(); // Hacked in for extra speed, loop over longest word first: int[] index = sortByLength(length1, length2, length3); @SuppressWarnings("unchecked") List<String>[] lists = new List[3]; lists[index[0]] = wordMap.get(length1); lists[index[1]] = wordMap.get(length2); lists[index[2]] = wordMap.get(length3); for(String w1:lists[0]) { //Continue if (according to our facts) this word is a possible partial match: if(facts.partialMatches(w1)) { for(String w2:lists[1]) { //Continue if (according to our facts) this word is a partial match: if(facts.partialMatches(w1+w2)) { for(String w3:lists[2]) { // Reconstruct phrase in correct order: String[] possiblePhraseParts = new String[] {w1, w2, w3}; String possiblePhrase = possiblePhraseParts[index[0]]+" "+possiblePhraseParts[index[1]]+" "+possiblePhraseParts[index[2]]; //If the facts form a complete match, continue: if(facts.matches(possiblePhrase)) { matchingPhrases.add(possiblePhrase); } } } } } } //Sometimes we are left with too many matching phrases, do a smart match on them, binary search style: while(matchingPhrases.size() > 8) { int lowestError = Integer.MAX_VALUE; boolean filterCharacterIsKnown = false; int filterPosition = 0; int filterValue = 0; String filterPhrase = ""; //We need to filter some more before trying: int targetBinaryFilter = matchingPhrases.size()/2; int[][] usedCharacters = new int[facts.totalLength+2][26]; for(String phrase:matchingPhrases) { for(int i = 0; i<usedCharacters.length;i++) { if(phrase.charAt(i) != ' ') { usedCharacters[i][phrase.charAt(i)-97]++; } } } //Locate a certain character/position combination which is closest to 50/50: for(int i = 0; i<usedCharacters.length;i++) { for(int x = 0; x<usedCharacters[i].length;x++) { int error = Math.abs(usedCharacters[i][x]-targetBinaryFilter); if(error < lowestError || (error == lowestError && !filterCharacterIsKnown)) { //If we do the binary search with a known character we can append more information as well //Reverse lookup if the character is known filterCharacterIsKnown = false; for(int f = 0; f<facts.charPtr; f++) { if(lookup[f]==x) { filterCharacterIsKnown = true; } } filterPosition = i; filterValue = x; filterPhrase = ""; for(int e = 0; e<i; e++) { filterPhrase += "-"; } filterPhrase += ""+((char)(x+97)); lowestError = error; } } } //Append new character information as well: while(filterPhrase.length() <= (facts.totalLength+2)) { filterPhrase += "-"; } if(filterCharacterIsKnown && facts.charPtr < 26) { //Append new character to discover for(int i = 0; i<facts.charBounds[lookup[facts.charPtr]];i++) { filterPhrase += (char)(lookup[facts.charPtr] + 97); } } //Guess with just that character: int[] result = guess(filterPhrase, pw, true); //Filter the 50% List<String> inFilter = new ArrayList<String>(); for(String phrase:matchingPhrases) { if(phrase.charAt(filterPosition) == (filterValue+97)) { inFilter.add(phrase); } } if(result[1]>0) { //If we have a match, retain all: matchingPhrases.retainAll(inFilter); } else { //No match, filter all matchingPhrases.removeAll(inFilter); } if(filterCharacterIsKnown && facts.charPtr < 26) { //Finally filter according to the discovered character: facts.updateCharBounds((result[0]+result[1]) - 1); List<String> toKeep = new ArrayList<String>(); for(String phrase:matchingPhrases) { if(facts.matches(phrase)) { toKeep.add(phrase); } } matchingPhrases = toKeep; } } // Finally we have some phrases left, try them! for(String phrase:matchingPhrases) { if(facts.matches(phrase)) { int[] result = guess(phrase, pw, true); System.out.println(phrase+" "+Arrays.toString(result)); if(result[0]==-1) { return; } // No match, update facts: facts.storeInvalid(phrase, result); } } throw new IllegalArgumentException("Unable to solve!?"); } private int[] sortByLength(int length1, int length2, int length3) { //God this code is ugly, can't be bothered to fix int[] index; if(length3 > length2 && length2 > length1) { index = new int[] {2, 1, 0}; } else if(length3 > length1 && length1 > length2) { index = new int[] {2, 0, 1}; } else if(length2 > length3 && length3 > length1) { index = new int[] {1, 2, 0}; } else if(length2 > length1 && length1 > length3) { index = new int[] {1, 0, 2}; } else if(length2 > length3) { index = new int[]{0, 1, 2}; } else { index = new int[]{0, 2, 1}; } return index; } private void findSpaces(int center, Facts facts, String pw) { String testPhrase = ""; //Place spaces for analysis: for(int i = 0; i<center; i++) {testPhrase+=" ";}while(testPhrase.length()<(facts.totalLength+2)) {testPhrase+="-";} //Append extra characters for added information early on: for(int i = 0; i<facts.charBounds[lookup[facts.charPtr]];i++) { testPhrase += (char)(lookup[facts.charPtr]+97); } //Update space lower and upper bounds: int[] answer = guess(testPhrase, pw, true); if(answer[1] == 0) { facts.spaceBounds[0] = Math.max(facts.spaceBounds[0], center+1); facts.spaceBounds[2] = Math.max(facts.spaceBounds[2], center+3); } else if(answer[1] == 1) { facts.spaceBounds[1] = Math.min(facts.spaceBounds[1], center); facts.spaceBounds[2] = Math.max(facts.spaceBounds[2], center+1); } else { facts.spaceBounds[3] = Math.min(facts.spaceBounds[3], center); facts.spaceBounds[1] = Math.min(facts.spaceBounds[1], center-2); } int correctAmountChars = (answer[0] + answer[1]) - 2; facts.updateCharBounds(correctAmountChars); //System.out.println(Arrays.toString(facts.spaceBounds)); if(facts.spaceBounds[0]==facts.spaceBounds[1]) { if(facts.spaceBounds[2]==facts.spaceBounds[3]) return; findSpaces(facts.spaceBounds[2] + ((facts.spaceBounds[3]-facts.spaceBounds[2])/3), facts, pw); } else { findSpaces((facts.spaceBounds[0]+facts.spaceBounds[1])/2, facts, pw); } } private class Facts { private static final String INITIAL_GUESS = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccccccccccccddddddddddddddddddffffffffffffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnooooooooooooooooooppppppppppppppppppqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrssssssssssssssssssttttttttttttttttttuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzz"; private final int totalLength; private final int[] spaceBounds; // Pre-filled with maximum bounds obtained from dictionary: private final int[] charBounds = new int[] {12, 9, 9, 9, 15, 9, 12, 9, 18, 6, 9, 12, 9, 12, 12, 9, 3, 12, 15, 9, 12, 6, 6, 3, 9, 6}; private final int[] oddEvenUsed = new int[] {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; private final int[] oddEvenPairScore = new int[26]; private int charPtr; public Facts(int[] initialResult) { totalLength = initialResult[0] + initialResult[1]; spaceBounds = new int[] {2, Math.min(totalLength - 2, 22), 4, Math.min(totalLength + 1, 43)}; //Eliminate firsts charBounds[lookup[0]] = initialResult[1]; //Adjust: for(int i = 1; i<charBounds.length; i++) { charBounds[lookup[i]] = Math.min(charBounds[lookup[i]], totalLength-initialResult[1]); } charPtr = 1; } private List<String> previousGuesses = new ArrayList<String>(); private List<int[]> previousResults = new ArrayList<int[]>(); public void storeInvalid(String phrase, int[] result) { previousGuesses.add(phrase); previousResults.add(result); } public boolean doneDiscovery() { if(charPtr<12) { //Always do at least N guesses (speeds up and slightly improves score) return false; } return true; } public void updateCharBounds(int correctAmountChars) { // Update the bounds we know for a certain character: int knownCharBounds = 0; charBounds[lookup[charPtr]] = correctAmountChars; for(int i = 0; i <= charPtr;i++) { knownCharBounds += charBounds[lookup[i]]; } // Also update the ones we haven't checked yet, we might know something about them now: for(int i = charPtr+1; i<charBounds.length; i++) { charBounds[lookup[i]] = Math.min(charBounds[lookup[i]], totalLength-knownCharBounds); } charPtr++; while(charPtr < 26 && charBounds[lookup[charPtr]]==0) { charPtr++; } } public boolean partialMatches(String phrase) { //Try to match a partial phrase, we can't be too picky because we don't know what else is next int[] cUsed = new int[26]; for(int i = 0; i<phrase.length(); i++) { cUsed[phrase.charAt(i)-97]++; } for(int i = 0; i<cUsed.length; i++) { //Only eliminate the phrases that definitely have wrong characters: if(cUsed[lookup[i]] > charBounds[lookup[i]]) { return false; } } return true; } public boolean matches(String phrase) { // Try to match a complete phrase, we can now use all information: int[] cUsed = new int[26]; for(int i = 0; i<phrase.length(); i++) { if(phrase.charAt(i)!=' ') { cUsed[phrase.charAt(i)-97]++; } } for(int i = 0; i<cUsed.length; i++) { if(i < charPtr) { if(cUsed[lookup[i]] != charBounds[lookup[i]]) { return false; } } else { if(cUsed[lookup[i]] > charBounds[lookup[i]]) { return false; } } } //Check against what we know for odd/even for(int pair = 0; pair < 26;pair++) { String input = ""; for(int i = 0; i<26;i++) { if(oddEvenUsed[i] == pair) { input += (char)(lookup[i]+97); } } if(input.length() == 1) { input += "-"; } String testPhrase = ""; for(int i = 0; i<=(totalLength+1)/2 ; i++) { testPhrase += input; } int[] result = guess(testPhrase, phrase, false); if(result[1] != oddEvenPairScore[pair]) { return false; } } //Check again previous guesses: for(int i = 0; i<previousGuesses.size();i++) { // If the input phrase is the correct phrase it should score the same against previous tries: int[] result = guess(previousGuesses.get(i), phrase, false); int[] expectedResult = previousResults.get(i); if(!Arrays.equals(expectedResult, result)) { return false; } } return true; } } private List<String> createPassPhrases() throws Exception { BufferedReader reader = new BufferedReader(new FileReader(new File("pass.txt"))); List<String> phrases = new ArrayList<String>(); String input; while((input = reader.readLine()) != null) { phrases.add(input); } return phrases; } private Map<Integer, List<String>> createDictionary() throws Exception { BufferedReader reader = new BufferedReader(new FileReader(new File("words.txt"))); Map<Integer, List<String>> wordMap = new HashMap<Integer, List<String>>(); String input; while((input = reader.readLine()) != null) { List<String> words = wordMap.get(input.length()); if(words == null) { words = new ArrayList<String>(); } words.add(input); wordMap.put(input.length(), words); } return wordMap; } } ``` [Answer] # Java - ~~18,708 Queries; 2.4 seconds~~ 11,077 Queries; 125 min. ## Min: 8, Max: 13, Effective Queries: 10,095 I spent way too long on this. :P ~~Code is available at <http://pastebin.com/7n9a50NM>~~ ~~Rev 1. available at <http://pastebin.com/PSXU2bga>~~ Rev 2. available at <http://pastebin.com/gRJjpbbu> My second revision. I'd hoped to crack the 11K barrier to win the prize, but I've run out of time to optimize this beast. It operates on an entirely separate principle from the previous two versions (and takes approximately 3,500 times as long to run). The general principle is to use space and even/odd character sieving to reduce the candidate list to manageable size (usually between 2-8 million), and then perform repeated queries with maximum discrimination power (i.e. whose output distribution has maximized entropy). Not speed but *memory* is the principal limitation. My Java VM won't let me reserve a heap larger than 1,200 MB for some obscure reason (probably Windows 7), and I tuned the parameters to give me the best possible solution that doesn't exhaust this limit. It irks me that a proper run with the proper parameters would break 11K with no meaningful increase in execution time. I need a new computer. :P What irks me just as much is that 982 of the queries in this implementation are useless "validation" queries. They have no purpose other than to satisfy the rule that the oracle must return a special "you got it" value at some point, even though in my implementation the correct answer has been deduced with certainty prior to this query in 98.2% of cases. Most of the other sub-11K submissions rely on filtering techniques that use candidate strings as query strings and hence don't suffer the same penalty. For this reason, although my official query count is 11,077 (short of the leaders, provided their code proves compliant, true-to-spec, etc.), I boldly state that my code makes 10,095 *effective* queries, meaning that only 10,095 queries are actually necessary to determine all pass phrases with 100% certainty. I'm not sure any of the other implementations will match that, hence I'll consider it my wee victory. ;) [Answer] ## Java - min: 22, max: 41, total: 28353, time: 4 seconds The program guesses the password in 3 steps : 1. find the space positions with a binary search 2. count the occurrences of most frequent characters in the 3 words 3. find the words starting from left, using the info gathered above It also handles a set of "bad characters" that return a zero result in the search, and a set of "good characters" that are placed somewhere else in the passphrase. Below an example of the values successively sent for guessing, you can see the 3 steps: ``` * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** * **** **** **** **** **** **** **** **** * ******** ******** ******** ******** * **************** **************** * ********** ******** ********************************************* eeeeeeeeeee eeeeeeeeeee eeeeee iiiiiiiiiii iiiiiiiiiii iiiiii aaaaaaaaaaa aaaaaaaaaaa aaaaaa sssssssssss sssssssssss ssssss rrrrrrrrrrr rrrrrrrrrrr rrrrrr nnnnnnnnnnn ttttttttttt ooooooooooo ooooooooooo oooooo lllllllllll a facilitates facilitates w facilitates wis facilitates widows facilitates widows e facilitates widows briefcase ``` The code: ``` import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; public class Main5 { private static String CHARS = "eiasrntolcdupmghbyfvkwzxjq "; private static String currentPassword; private static List<String> words; private static List<String> passphrases; private static char [] filters = {'e', 'i', 'a', 's', 'r', 'n', 't', 'o', 'l'}; private static int maxLength; public static void main(String[] args) throws IOException { long start = System.currentTimeMillis(); passphrases = getFile("passphrases.txt"); words = getFile("words.txt"); maxLength = 0; for (String word : words) { if (word.length() > maxLength) { maxLength = word.length(); } } int total = 0; int min = Integer.MAX_VALUE; int max = 0; for (String passphrase : passphrases) { currentPassword = passphrase; int tries = findPassword(); if (tries > max) max = tries; if (tries < min) min = tries; total += tries; } long end = System.currentTimeMillis(); System.out.println("Min : " + min); System.out.println("Max : " + max); System.out.println("Total : " + total); System.out.println("Time : " + (end - start) / 1000); } public static int findPassword() { /************************************** * STEP 1 : find the spaces positions * **************************************/ int tries = 0; Map<String, int []> res = new HashMap<String, int[]>(); long maxBits = (long) Math.log((maxLength * 3+2) * Math.exp(2)); for (int bit = 0; bit < maxBits-2; bit++) { String sp = buildSpace(maxLength*3+2, bit); tries++; int [] ret = guess(sp); res.put(sp, ret); } List<String> candidates = new ArrayList<String>(); List<String> unlikely = new ArrayList<String>(); for (int x1 = 1; x1 < maxLength + 1; x1++) { for (int x2 = x1+2; x2 < Math.min(x1+maxLength+1, maxLength*3+2); x2++) { boolean ok = true; for (String key : res.keySet()) { int [] ret = res.get(key); if (key.charAt(x1) == ' ' && key.charAt(x2) == ' ') { // ret[1] should be 2 if (ret[1] != 2) ok = false; } else if (key.charAt(x1) == '*' && key.charAt(x2) == '*') { // ret[1] should be 0 if (ret[1] != 0) ok = false; } else if (key.charAt(x1) == ' ' || key.charAt(x2) == ' ') { // ret[1] should be 1 if (ret[1] != 1) ok = false; } } if (ok) { String s = ""; for (int i = 0; i < maxLength*3+2; i++) { s += i == x1 || i == x2 ? " " : "*"; } // too short or too long words are unlikely to occur if (x1 < 4 || x2 - x1 - 1 < 4 || x1 > 12 || x2 - x1 - 1 > 12) { unlikely.add(s); } else { candidates.add(s); } } } } candidates.addAll(unlikely); String correct = null; if (candidates.size() > 1) { for (int i = 0; i < candidates.size(); i++) { String cand = candidates.get(i); int [] ret = null; if (i < candidates.size() - 1) { tries++; ret = guess(cand); } if (i == candidates.size() - 1 || ret[1] == 2) { correct = cand; break; } } } else { correct = candidates.get(0); } int spaceIdx1 = correct.indexOf(' '); int spaceIdx2 = correct.lastIndexOf(' '); /******************************************** * STEP 2 : count the most frequent letters * ********************************************/ // test the filter characters in the first, second, last words List<int []> f = new ArrayList<int []>(); for (int k = 0; k < filters.length; k++) { char filter = filters[k]; String testE = ""; for (int i = 0; i < spaceIdx1; i++) { testE += filter; } int tmpCount = 0; for (int [] tmp : f) { tmpCount += tmp[0]; } int [] result; if (tmpCount == spaceIdx1) { // we can infer the result result = new int[] {1, 0}; } else { tries++; result = guess(testE); } int [] count = {result[1], 0, 0}; if (result[0] > 0) { // test the character in the second word testE += " "; for (int i = 0; i < spaceIdx2-spaceIdx1-1; i++) { testE += filter; } tries++; result = guess(testE); count[1] = result[1] - count[0] - 1; if (testE.length() - count[0] - count[1] > 8) { // no word has more than 8 similar letters count[2] = result[0]; } else { if (result[0] > 0) { // test the character in the third word testE += " "; for (int i = 0; i < maxLength; i++) { testE += filter; } tries++; result = guess(testE); count[2] = result[1] - count[0] - count[1] - 2; } } } f.add(new int[] {count[0], count[1], count[2]}); } /*********************************************** * STEP 3 : find the words, starting from left * ***********************************************/ String phrase = "", word = ""; int numWord = 0; Set<Character> badChars = new HashSet<Character>(); Set<Character> goodChars = new HashSet<Character>(); while (true) { boolean found = false; int wordLength = -1; // unknown if (numWord == 0) wordLength = spaceIdx1; if (numWord == 1) wordLength = spaceIdx2-spaceIdx1-1; // compute counts List<Integer> counts = new ArrayList<Integer>(); for (int [] tmp : f) { counts.add(tmp[numWord]); } // what characters should we test after? String toTest = whatNext(word, badChars, numWord == 2 ? goodChars : null, wordLength, counts); // if the word is already found.. complete it, no need to call guess if (toTest.length() == 1 && !toTest.equals(" ")) { phrase += toTest; word += toTest; goodChars.remove(toTest.charAt(0)); continue; } // try all possible letters for (int i = 0; i < toTest.length(); i++) { int [] result = null; char c = toTest.charAt(i); if (badChars.contains(c)) continue; boolean sureGuess = c != ' ' && i == toTest.length() - 1; if (!sureGuess) { // we call guess ; increment the number of tries tries++; result = guess(phrase + c); // if the letter is not present, add it to the set of "bad" characters if (result[0] == 0 && result[1] == phrase.length()) { badChars.add(c); } // if the letter is present somewhere else, add it to the set of "good" characters if (result[0] == 1 && result[1] == phrase.length()) { goodChars.add(c); } } if (sureGuess || result[1] == phrase.length()+1) { goodChars.remove(c); phrase += c; word += c; if (toTest.charAt(i) == ' ') { word = ""; numWord++; } found = true; break; } } if (!found) break; } if (!phrase.equals(currentPassword)) System.err.println(phrase); return tries; } public static int[] guess(String in) { int chars=0, positions=0; String pw = currentPassword; // set elsewhere, contains current pass for(int i=0;i<in.length()&&i<pw.length();i++){ if(in.charAt(i)==pw.charAt(i)) positions++; } if(positions == pw.length() && pw.length()==in.length()) return new int[]{-1,positions}; for(int i=0;i<in.length();i++){ String c = String.valueOf(in.charAt(i)); if(pw.contains(c)){ pw = pw.replaceFirst(c, ""); chars++; } } chars -= positions; return new int[]{chars,positions}; } private static String buildSpace(int length, int bit) { String sp = ""; for (int i = 0; i < length; i++) { if (((i >> bit) & 1) != 0) { sp += " "; } else { sp += "*"; } } return sp; } public static String whatNext(String s, Set<Character> badChars, Set<Character> goodChars, int length, List<Integer> counts) { String ret = ""; Map<Character, Integer> freq = new HashMap<Character, Integer>(); for (char c : CHARS.toCharArray()) { if (badChars.contains(c)) continue; freq.put(c, 0); } for (String word : words) { if (word.startsWith(s) && (word.length() == length || length == -1)) { char c1 = word.equals(s) ? ' ' : word.charAt(s.length()); if (badChars.contains(c1)) continue; boolean badWord = false; for (int j = 0; j < counts.size(); j++) { int cpt = 0; for (int i = 0; i < word.length(); i++) { if (word.charAt(i) == filters[j]) cpt++; } if (cpt != counts.get(j)) { badWord = true; break; } } if (badWord) continue; String endWord = word.substring(s.length()); for (char bad : badChars) { if (endWord.indexOf(bad) != -1) { badWord = true; break; } } if (badWord) continue; if (goodChars != null) { for (char good : goodChars) { if (endWord.indexOf(good) == -1) { badWord = true; break; } } } if (badWord) continue; freq.put(c1, freq.get(c1)+1); } } while (true) { char choice = 0; int best = 0; for (char c : CHARS.toCharArray()) { if (freq.containsKey(c) && freq.get(c) > best) { best = freq.get(c); choice = c; } } if (choice == 0) break; ret += choice; freq.remove(choice); } return ret; } public static List<String> getFile(String filename) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(filename)); List<String> lines = new ArrayList<String>(); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } } ``` [Answer] ## PYTHON 2.7 - 156821 guesses, 0.6 seconds I went for speed rather than lowest number of guesses, although I figure my number of guesses is still lower than for example a straight up dictionary attack would be. I do not calculate the number of letters in the password but in the wrong place, as my method doesn't use it, but if you feel this gives me an unfair advantage, I will implement it. I simply start with an empty guess string, and add a single character suffix on it which increments over my list of chars, checking the result of 'check' to see if the number of correct characters is equal to the length of the guess. For example, if the password was 'bad', I would guess: a,b a a,b,c,d I also tried sorting the letters by english letter frequency, which shaved off about 35% of the number of guesses, as well as the time. I cracked all passwords in 0.82 seconds. Stats are printed at the end. ``` import string import time class Checker(): def __init__(self): #self.chars = string.ascii_lowercase + ' ' #ascii letters + space self.baseChars = "eiasrnt olcdupmghbyfvkwzxjq" #ascii letters in order of frequency, space thrown in a reasonable location self.subfreqs = {} self.chars = "eiasrnt olcdupmghbyfvkwzxjq" self.subfreqs['a'] = "tnlrcsb dmipguvykwfzxehajoq" self.subfreqs['b'] = "leaiour sbytjdhmvcnwgfpkqxz" self.subfreqs['c'] = "oaehtik rulcysqgnpzdmvbfjwx" self.subfreqs['d'] = "eioarus ldygnmvhbjwfptckqxz" self.subfreqs['e'] = "rsndlat cmepxfvgwiyobuqhzjk" self.subfreqs['f'] = "ioefalu rtysbcdgnhkjmqpwvxz" self.subfreqs['g'] = "erailho usngymtdwbfpckjqvxz" self.subfreqs['h'] = "eaoiurt ylmnsfdhwcbpgkjqvxz" self.subfreqs['i'] = "notscle amvdgrfzpbkuxqihjwy" self.subfreqs['j'] = "ueaoicb dgfhkjmlnqpsrtwvyxz" self.subfreqs['k'] = "eisalny owmurfptbhkcdjgqvxz" self.subfreqs['l'] = "eialyou stdmkvpfcngbhrwjqxz" self.subfreqs['m'] = "eaiopub msnylchfrwqvdgkjtxz" self.subfreqs['n'] = "gtesdia conufkvylhbmjrqpwzx" self.subfreqs['o'] = "nrumlts opcwdvgibafkeyxzhjq" self.subfreqs['p'] = "eroalih ptusybfgkdmwjcnqvxz" self.subfreqs['q'] = "uacbedg fihkjmlonqpsrtwvyxz" self.subfreqs['r'] = "eaiostm rdyuncgbplkvfhwjqzx" self.subfreqs['s'] = "tesihoc upalmnykwqfbdgrvjxz" self.subfreqs['t'] = "iearohs tyulcnwmfzbpdgvkjqx" self.subfreqs['u'] = "srnltmc adiebpgfozkxvyqhwuj" self.subfreqs['v'] = "eiaouyr bhpzcdgfkjmlnqstwvx" self.subfreqs['w'] = "aieonhs rlbcmpdkyfgutwvjqxz" self.subfreqs['x'] = "pitcaeh oyulgfbdkjmnqsrwvxz" self.subfreqs['y'] = "sepminl acortdwgubfkzhjqvyx" self.subfreqs['z'] = "eaizoly usrkmwxcbdgfhjnqptv" self.numGuessesTot = 0 self.numGuessesCur = 0 self.currentIndex = 0 self.passwords = [line.strip() for line in open('passwords.txt', 'r').readlines()] self.currentPass = self.passwords[self.currentIndex] self.numPasswords = len(self.passwords) self.mostGuesses = (0, '') self.leastGuesses = (1e9, '') def check(self, guess): self.numGuessesTot += 1 self.numGuessesCur += 1 numInPass = 0 numCorrect = 0 lenPass = len(self.currentPass) lenGuess = len(guess) minLength = min(lenPass, lenGuess) for i in range(minLength): if guess[i] == self.currentPass[i]: numCorrect += 1 if numCorrect == len(self.currentPass): return -1, -1 # numInPass is not calculated, as I don't use it return numInPass, numCorrect def nextPass(self): if self.numGuessesCur < self.leastGuesses[0]: self.leastGuesses = (self.numGuessesCur, self.currentPass) if self.numGuessesCur > self.mostGuesses[0]: self.mostGuesses = (self.numGuessesCur, self.currentPass) self.numGuessesCur = 0 self.currentIndex += 1 if self.currentIndex < self.numPasswords: self.currentPass = self.passwords[self.currentIndex] def main(self): t0 = time.time() while self.currentIndex < self.numPasswords: guess = '' result = (0, 0) while result[0] is not -1: i = 0 while i < len(self.chars) and result[1] < len(guess)+1 and result[1] is not -1: result = self.check(guess + self.chars[i]) i += 1 guess += self.chars[i-1] if self.chars[i-1] == " ": self.chars = self.baseChars i = 0 else: self.chars = self.subfreqs[self.chars[i-1]] i = 0 if result[0] == -1: #print self.currentIndex, self.currentPass self.nextPass() elapsedTime = time.time() - t0 print " Total number of guesses: {}".format(self.numGuessesTot) print " Avg number of guesses: {}".format(self.numGuessesTot/self.numPasswords) print " Least number of guesses: {} -> {}".format(self.leastGuesses[0], self.leastGuesses[1]) print " Most number of guesses: {} -> {}".format(self.mostGuesses[0], self.mostGuesses[1]) print " Total time: {} seconds".format(elapsedTime) if __name__ == "__main__": checker = Checker() checker.main() ``` EDIT: Removed a stray +1 and -1 from two of the while loops from previous iterations of testing, also added additional stats for least guesses and most guesses for an individual password. EDIT2: added lookup table for most common 'next' letter, per letter. Greatly increased speed and decreased guess count [Answer] # C++ - 1138310989 Matches! ## Update Fixed memory leaks, and removed 1 more attempt to reduce the individual word dictionary sizes. Takes about 50 minutes on my mac pro. Updated code is on github. --- I switched over to the phrase matching strategy, and reworked the code, and updated it on github <https://github.com/snjyjn/mastermind> With Phrase based matching, we are down to 11383 attempts! It is expensive in terms of compute! I also dont like the code structure! And it is still way behind the others :-( This is how I am doing it: 1. Measure the length of the phrase - using a string with all 26 characters max times (max = 3 \* maxwordlen + 2) and 2 spaces. First maxlen characters are the most frequent in the dictionary i.e. e 2. Use a binary sieve kind of strategy to identify the spaces - do a set number of attempts, and identify potential pairs of spaces. Create specific test strings to reduce to a single pair. 3. In parallel, append 'crafted' test strings to get more information about the phrase. The current strategy is as follows: a. Use characters in order of their frequency in the dictionary. b. We already know the count for the most frequent c. 1st Test string = next 5 characters. This gives us the count of these characters in the phrase. d. next 3 test strings = next 5 characters each, covering a total of 20 characters in 4 attempts in addition to the first 1 char. This gives us the count for these last 5 characters as well. sets with 0 count are great for reducing the dictionary size! e. Now for the previous test that had the least, non-zero counts, split the string into 2, and use 1 for testing. The resulting count tells us about the other split as well. f. Now repeat tests with characters (0-based), ``` 1,6,11,16,21 2,7,12,17,22 3,8,13,18,23 4,9,14,19,24 This should give us 5,10,15,20,25 ``` ``` g. After this, the next set of test strings are all 1 character long. though we dont expect to get so many tries! ``` 1. Once the spaces are identified, use the constraints so far (as many tests as could be done in these attempts) to reduce the size of the dictionary. Also create 3 sub dictionaries, 1 for each word. 2. Now do some guesses for each word, and test it. Use these results to reduce the individual dictionary sizes. Decorate this with test characters as well (after the length) to get more constraints on the phrase! I used 3 guesses in the final version - 2 for word 1, and 1 for word 2 3. This brings the dictionary to a manageable size. Perform a cross product, applying all constraints as before to create a phrase dictionary. 4. Solve for the phrase dictionary through a series of guesses - this time using both position and character match information. 5. This approach brings us to under 11383 attempts: ``` Matcher Statistics ------------------ Length : 1000 Spaces : 6375 Word 1 : 1996 Word 2 : 999 Phrase : 1013 TOTAL : 11383 Dictionary Statistics word 0 6517 word 1 780 221 92 word 2 791 233 word 3 772 phrase 186 20 4 2 Solution time: 20 minutes on my macbook pro. ``` ## Previous Post I have cleaned up the code, and uploaded it to <https://github.com/snjyjn/mastermind> In the process, I improved it, and still have 1 more idea to try out. There 1 one major difference from what I had done yesterday: > > Removed the individual guessing for characters based on high frequency characters in the dictionary for words 1 & 2, and instead I use a string based on the highest frequency character for that position. > > > The statistics now look like: ``` Spaces : 6862 Word 1 : 5960 Word 2 : 5907 Word 3 : 2953 TOTAL : 21682 ``` ## Original Post Apologies for the 'answer', but I just created an account, and dont have enough reputation to add a comment. I have a c++ program, which takes about 6.5seconds, and 24107 match attempts. It is about 1400 lines of c++. I am not happy about the code quality, and will clean it before I put it up in another day or so. But in the interest of the community and contributing to the discussion, this is what I do: * Read the dictionary, get some basic info about it - min/max word length, character frequency, etc. * First identify spaces - This has 2 halves, the first is a set of queries which continue to partition the space (similar to one C. Chafouin): ``` ******** **** **** ** ** ** ** - * * * * * * * ``` This is not exactly accurate, since I use the min / max word length, and I use the match counts at each stage, but you get the idea. At this point, there is still not sufficient information to get the 2 spaces, but I do have enough to reduce it to a small number of combinations. From those combinations, I can make a couple of specific queries, which will narrow it down to 1 combination. * First Word - Get a Subdictionary, which has words of the right length. The subdictionary has its own stats. Do a few guesses with the most frequent characters, so you get a count of these characters in the word. Reduce the dictionary again based on this inforamtion. Create a guess word, which has the most different characters, and use that. Each response causes a reduction in the dictionary till we have an exact match, or the dictionary is size 1. * Second Word - similar to First word * Third word - this is most different from the other 2. We dont have size information for this, but we do have all the previous queries (which we have kept). These queries allow you to reduce the dictionary. The logic is on the lines of: ``` - query abc returned a match count of 1 - words 1 and 2 dont have b or c - It is clear that b or c cannot be a part of word 3 ``` Use the reduced dictionary to make a guess, with the most diverse characters, and continue to reduce the dictionary till size 1 (as in words 1 and 2). The statistics look like: ``` Space finding: 7053 Word 1 chars : 2502 Word 1 words : 3864 Word 2 chars : 2530 Word 2 words : 3874 Word 3 chars : 2781 Word 3 words : 1503 TOTAL : 24107 ``` [Answer] # Go - Total: 29546 Similar to some others, with some optimizations. 1. Get total length by testing `AAAAAAAABBBBBBBBCCCCCCCC...ZZZZZZZZ` 2. Determine actual lengths of all three words by moving spaces in from both ends. 3. Filter each word by letter counts of some common letters. 4. Reduce candidate set by testing a string, and removing other candidates that don't provide the same results. Repeat until winner found. It is not particularly fast. ``` package main import ( "bytes" "fmt" "strings" ) var totalGuesses = 0 var currentGuesses = 0 func main() { for i, password := range passphrases { currentGuesses = 0 fmt.Println("#", i) currentPassword = password GuessPassword() } fmt.Println(totalGuesses) } func GuessPassword() { length := GetLength() first, second, third := GetWordSizes(length) firstWords := GetWordsOfLength(first, "") secondWords := GetWordsOfLength(second, strings.Repeat(".", first+1)) thirdWords := GetWordsOfLength(third, strings.Repeat(".", first+second+2)) //tells us number of unique letters in solution. As good as any for an initial pruning mechanism. RecordGuess("abcdefghijklmnopqrstuvwxyz") candidates := []string{} for _, a := range firstWords { for _, b := range secondWords { for _, c := range thirdWords { candidate := a + " " + b + " " + c if MatchesLastGuess(candidate) { candidates = append(candidates, candidate) } } } } for { //fmt.Println(len(candidates)) RecordGuess(candidates[0]) if lastExist == -1 { fmt.Println(lastGuess, currentGuesses) return } candidates = Prune(candidates[1:]) } } var lastGuess string var lastExist, lastExact int func RecordGuess(g string) { a, b := MakeGuess(g) lastGuess = g lastExist = a lastExact = b } func Prune(candidates []string) []string { surviving := []string{} for _, x := range candidates { if MatchesLastGuess(x) { surviving = append(surviving, x) } } return surviving } func MatchesLastGuess(candidate string) bool { a, b := Compare(candidate, lastGuess) return a == lastExist && b == lastExact } func GetWordsOfLength(i int, prefix string) []string { candidates := []string{} guess := prefix + strings.Repeat("e", i) _, es := MakeGuess(guess) guess = prefix + strings.Repeat("a", i) _, as := MakeGuess(guess) guess = prefix + strings.Repeat("i", i) _, is := MakeGuess(guess) guess = prefix + strings.Repeat("s", i) _, ss := MakeGuess(guess) guess = prefix + strings.Repeat("r", i) _, ts := MakeGuess(guess) for _, x := range allWords { if len(x) == i && strings.Count(x, "e") == es && strings.Count(x, "a") == as && strings.Count(x, "i") == is && strings.Count(x, "r") == ts && strings.Count(x, "s") == ss { candidates = append(candidates, x) } } return candidates } func GetLength() int { all := " " for i := 'a'; i <= 'z'; i++ { all = all + strings.Repeat(string(i), 8) } a, b := MakeGuess(all) return a + b } func GetWordSizes(length int) (first, second, third int) { first = 0 second = 0 third = 0 guess := bytes.Repeat([]byte{'.'}, length) left := 1 right := length - 2 for { guess[left] = ' ' guess[right] = ' ' _, exact := MakeGuess(string(guess)) guess[left] = '.' guess[right] = '.' if exact == 0 { left++ right-- } else if exact == 1 { break } else if exact == 2 { first = left second = right - first - 1 third = length - first - second - 2 return } } //one end is decided, the other is not //move right in to see right-- guess[left] = ' ' guess[right] = ' ' _, exact := MakeGuess(string(guess)) guess[left] = '.' guess[right] = '.' if exact == 2 { //match was on left. We got lucky and found other match too! first = left second = right - first - 1 third = length - first - second - 2 return } else if exact == 0 { //match was on right, but we lost it. //keep going on left right++ left++ guess[right] = ' ' for { guess[left] = ' ' _, exact = MakeGuess(string(guess)) guess[left] = '.' if exact == 2 { first = left second = right - first - 1 third = length - first - second - 2 return } left++ } } else if exact == 1 { //exact == 1. Match was on left and still is. Keep going on right right-- guess[left] = ' ' for { guess[right] = ' ' _, exact = MakeGuess(string(guess)) guess[right] = '.' if exact == 2 { first = left second = right - first - 1 third = length - first - second - 2 return } right-- } } return first, second, third } var currentPassword string func MakeGuess(guess string) (exist, exact int) { totalGuesses++ currentGuesses++ return Compare(currentPassword, guess) } func Compare(target, guess string) (exist, exact int) { if guess == target { return -1, len(target) } exist = 0 exact = 0 for i := 0; i < len(target) && i < len(guess); i++ { if target[i] == guess[i] { exact++ } } for i := 0; i < len(guess); i++ { if strings.IndexByte(target, guess[i]) != -1 { exist++ target = strings.Replace(target, string(guess[i]), "", 1) } } exist -= exact return } ``` [Answer] # Java : 58,233 ### (reference program) A simple bot for everyone to beat. It uses an initial 26 guesses for each phrase to establish a character count. Then it eliminates all words that contain letters not found in the phrase. Then comes a massive O(n3) loop over the remaining words. First it checks each candidate phrase to see if it's an anagram. If so, it guesses it, ignoring the results unless it's a perfect match. I've seen it use between 28-510 guesses for any given phrase so far. This is **slow**, and it entirely depends on how many words can be eliminated straight from the initial 26 guesses. Most of the time it leaves between 1000-4000 words to loop over. Right now it's been running for somewhere around 14 hours, at a rate of ~180s/phrase. I estimate it will take 50 hours to complete, and will update the score at that time. You should *probably* do something smarter or more thready than this. (update) It finally finished, with a bit under 60k guesses. ``` import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; public class Mastermind { String currentPassword; String[] tests; HashSet<String> dict; ArrayList<HashSet<String>> hasLetter; int maxLength = 0; int totalGuesses; public static void main(String[] args) { Mastermind master = new Mastermind(); master.loadDict("dict-small"); master.loadTests("passwords"); System.out.println(); master.run(); } public Mastermind(){ totalGuesses = 0; dict = new HashSet<String>(); hasLetter = new ArrayList<HashSet<String>>(26); for(int i=0;i<26;i++) hasLetter.add(new HashSet<String>()); } int run(){ long start = System.currentTimeMillis(); for(int i=0;i<tests.length;i++){ long wordStart = System.currentTimeMillis(); currentPassword = tests[i]; int guesses = test(); if(guesses < 0){ System.out.println("Failed!"); System.exit(0); } totalGuesses += guesses; long time = System.currentTimeMillis() - wordStart; System.out.println((i+1) + " found! " + guesses + " guesses, " + (time/1000) + "s ("+ ((System.currentTimeMillis()-start)/1000) +" total) : " + tests[i]); } System.out.println("\nTotal for " + tests.length + " tests: " + totalGuesses + " guesses, " + ((System.currentTimeMillis()-start)/1000) + " seconds total"); return totalGuesses; } int[] guess(String in){ int chars=0, positions=0; String pw = currentPassword; for(int i=0;i<in.length()&&i<pw.length();i++){ if(in.charAt(i)==pw.charAt(i)) positions++; } if(positions == pw.length() && pw.length()==in.length()) return new int[]{-1,positions}; for(int i=0;i<in.length();i++){ String c = String.valueOf(in.charAt(i)); if(pw.contains(c)){ pw = pw.replaceFirst(c, ""); chars++; } } chars -= positions; return new int[]{chars,positions}; } int test(){ int guesses = 0; HashSet<String> words = new HashSet<String>(); words.addAll(dict); int[] counts = new int[26]; for(int i=0;i<counts.length;i++){ char[] chars = new char[maxLength]; Arrays.fill(chars, (char)(i+97)); int[] result = guess(new String(chars)); counts[i] = result[0] + result[1]; guesses++; } int length = 2; for(int i=0;i<counts.length;i++){ length += counts[i]; if(counts[i]==0) words.removeAll(hasLetter.get(i)); } System.out.println(words.size() + ", " + Math.pow(words.size(),3)); for(String a : words){ for(String b : words){ for(String c : words){ String check = a + " " + b + " " + c; if(check.length() != length) continue; int[] letters = new int[26]; for(int i=0;i<check.length();i++){ if(check.charAt(i)!=' ') letters[check.charAt(i)-97]++; } int matches = 0; for(int i=0;i<letters.length;i++) if(letters[i] == counts[i]) matches+=letters[i]; if(matches == check.length()-2){ guesses++; int[] result = guess(check); System.out.println(check + " : " + result[0] +", " + result[1]); if(result[0] < 0) return guesses; } } } } return -guesses; } int loadDict(String filename){ try { BufferedReader br = new BufferedReader(new FileReader(filename)); String line; while ((line = br.readLine()) != null){ if(line.length()*3+2 > maxLength) maxLength = line.length()*3+2; dict.add(line); for(int i=0;i<line.length();i++){ hasLetter.get(line.charAt(i)-97).add(line); } } br.close(); } catch (Exception e){}; System.out.println("Loaded " + dict.size() + " words."); return dict.size(); } int loadTests(String filename){ ArrayList<String> tests = new ArrayList<String>(); try { BufferedReader br = new BufferedReader(new FileReader(filename)); String line; while ((line = br.readLine()) != null) if(line.length()>0) tests.add(line); br.close(); } catch (Exception e){}; this.tests = tests.toArray(new String[tests.size()]); System.out.println("Loaded " + this.tests.length + " tests."); return this.tests.length; } } ``` [Answer] # Java : ~~28,340~~ 26,185 ### Min 15, Max 35, Time 2.5s Since my [stupid bot](https://codegolf.stackexchange.com/a/36922/14215) finally finished running, I wanted to submit something a *little* faster. It runs in just a few seconds, but gets a good score (not quite winning ><). First it uses a big pad string to get the total length of the phrase. Then binary search to find spaces, similar to others. While doing this, it also starts checking letters one at a time (in pivot-order) so it can eliminate words that contain more of any letter than the entire phrase. Once it has the word lengths, it uses a binary reduction step to narrow down the choices for the word lists. It chooses the largest list and a letter that's in approx half the words. It guesses a word-length pad of that letter to determine which half to throw away. It also uses the results to get rid of words in the *other* lists that have too many of the letter. Once a list consists of anagrams only, this doesn't work. At that point I just loop through them until only two remain (or one if the other words are not known). If I have a total word count of four (two known and one with two options), I skip the reduction and anagram checks and just guess one of the options as a full phrase. If it doesn't work, then it's gotta be the other, but I save a guess 50% of the time. Here's an example, showing the first phrase being cracked: ``` aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffgggggggggggggggggggghhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnooooooooooooooooooooppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrssssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzz ..................................................................oooooooooooooooooooo ..................................................................tttttttttttttttttttt ..................................................................nnnnnnnnnnnnnnnnnnnn ..................................................................llllllllllllllllllll ..................................................................iiiiiiiiiiiiiiiiiiii ..................................................................dddddddddddddddddddd ..................................................................uuuuuuuuuuuuuuuuuuuu ..................................................................ssssssssssssssssssss ..................................................................yyyyyyyyyyyyyyyyyyyy ............rrrrrr ............ssssss ...................ttttttttt ............aaaaaa ...................aaaaaaaaa ............iiiiii sssssssssss ...................lllllllll ............dddddd ............eeeeee lllllllllll ccccccccccc ...................ccccccccc rrrrrrrrrrr ...................bbbbbbbbb facilitates wisdom briefcase facilitates widows briefcase ``` And of course, the code: ``` import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class Splitter { int crack(){ int curGuesses = guesses; none = ""; int[] lens = getLengths(); List<Set<String>> words = new ArrayList<Set<String>>(); for(int i=0;i<3;i++){ words.add(getWordsOfLength(lens[i])); exclude[i] = ""; for(int j=0;j<26;j++){ if(pCounts[j]>=0) removeWordsWithMoreThan(words.get(i), pivots.charAt(j), pCounts[j]); } } while(!checkSimple(words)){ if(numWords(words)>4) reduce(words, lens); if(numWords(words)>4) findAnagrams(words, lens); } return guesses - curGuesses; } boolean checkSimple(List<Set<String>> words){ int total = numWords(words); if(total - words.size() == 1){ int big=0; for(int i=0;i<words.size();i++) if(words.get(i).size()>1) big=i; String pass = getPhrase(words); if(guess(pass)[0]<0) return true; words.get(big).remove(pass.split(" ")[big]); } total = numWords(words); if(total==words.size()){ String pass = getPhrase(words); if(guess(pass)[0]<0) return true; } return false; } boolean findAnagrams(List<Set<String>> words, int[] lens){ String test; Set<String> out; for(int k=0;k<words.size();k++){ if(words.get(k).size() < 8){ String sorted = ""; boolean anagram = true; for(String word : words.get(k)){ char[] chars = word.toCharArray(); Arrays.sort(chars); String next = new String(chars); if(sorted.length()>1 && !next.equals(sorted)){ anagram = false; break; } sorted = next; } if(anagram){ test = ""; for(int i=0;i<k;i++){ for(int j=0;j<=lens[i];j++) test += '.'; } while(words.get(k).size()>(numWords(words)>4?1:2)){ out = new HashSet<String>(); for(String word : words.get(k)){ int correct = guess(test+word)[1]; if(correct == lens[k]){ words.set(k, new HashSet<String>()); words.get(k).add(word); break; }else{ out.add(word); break; } } words.get(k).removeAll(out); } } } } return false; } int numWords(List<Set<String>> words){ int total = 0; for(Set<String> set : words) total += set.size(); return total; } String getPhrase(List<Set<String>> words){ String out = ""; for(Set<String> set : words) for(String word : set){ out += word + " "; break; } return out.trim(); } void reduce(List<Set<String>> words, int[] lens){ int k = 0; for(int i=1;i<words.size();i++) if(words.get(i).size()>words.get(k).size()) k=i; if(words.get(k).size()<2) return; char pivot = getPivot(words.get(k), exclude[k]); exclude[k] += pivot; String test = ""; for(int i=0;i<k;i++){ for(int j=0;j<=lens[i];j++) test += '.'; } for(int i=0;i<lens[k];i++) test += pivot; int[] res = guess(test); Set<String> out = new HashSet<String>(); for(String word : words.get(k)){ int charCount=0; for(int i=0;i<word.length();i++) if(word.charAt(i)==pivot) charCount++; if(charCount != res[1]) out.add(word); if(res[1]==0 && charCount>0) out.add(word); } words.get(k).removeAll(out); if(lens[k]>2 && res[0]<lens[k]-res[1]){ for(int l=0;l<words.size();l++) if(l!=k) removeWordsWithMoreThan(words.get(l), pivot, res[0]); } } void removeWordsWithMoreThan(Set<String> words, char c, int num){ Set<String> out = new HashSet<String>(); for(String word : words){ int count = 0; for(int i=0;i<word.length();i++) if(word.charAt(i)==c) count++; if(count > num) out.add(word); } words.removeAll(out); } char getPivot(Set<String> words, String exclude){ int[] count = new int[26]; for(String word : words){ for(int i=0;i<26;i++) if(word.indexOf((char)(i+'a'))>=0) count[i]++; } double diff = 999; double pivotPoint = words.size()/1.64d; int pivot = 0; for(int i=0;i<26;i++){ if(exclude.indexOf((char)(i+'a'))>=0) continue; if(Math.abs(count[i]-pivotPoint)<diff){ diff = Math.abs(count[i]-pivotPoint); pivot = i; } } return (char)(pivot+'a'); } Set<String> getWordsOfLength(int len){ Set<String> words = new HashSet<String>(); for(String word : dict) if(word.length()==len) words.add(word); return words; } int[] pCounts; int[] getLengths(){ String test = ""; int pivot = 0; pCounts = new int[27]; for(int i=0;i<27;i++) pCounts[i]=-1; for(int i=0;i<45;i++) test += ' '; for(int i=0;i<26;i++){ for(int j=0;j<20;j++){ test += (char)(i+'a'); } } int[] res = guess(test); int len = res[0]+res[1]; int[] lens = new int[3]; int[] min = {1,3}; int[] max = {len-4,len-2}; int p = (int)((max[0]-min[0])/3+min[0]); while(lens[0] == 0){ if(max[0]==min[0]){ lens[0] = min[0]; break; } String g = "", h = ""; for(int i=0;i<=p;i++) g+=' '; if(pivot < pivots.length()){ h += pad; for(int i=0;i<20;i++) h += pivots.charAt(pivot); } res = guess(g+h); if(res[1]==0){ min[0] = p+1; min[1] = max[0]; pCounts[pivot] = g.length()>1?res[0]-2:res[0]-1; }else if(res[1]==2){ max[0] = p-2; max[1] = p; pCounts[pivot] = res[0]; }else if(res[1]==1){ max[0] = p; min[1] = p+1; pCounts[pivot] = g.length()>1?res[0]-1:res[0]; } p = (int)((max[0]-min[0])/2+min[0]); pivot++; } min[1] = Math.max(min[1], lens[0]+2); while(lens[1] == 0){ p = (max[1]-min[1])/2+min[1]; if(max[1]==min[1]){ lens[1] = min[1] - lens[0] - 1; break; } String g = "", h = ""; for(int i=0;i<=p;i++) g+=' '; if(pivot < pivots.length()){ h += pad; for(int i=0;i<20;i++) h += pivots.charAt(pivot); } res = guess(g+h); if(res[1]<2){ min[1] = p+1; pCounts[pivot] = res[0]-1; }else if(res[1]==2){ max[1] = p; pCounts[pivot] = res[0]; } pivot++; } lens[2] = len - lens[0] - lens[1] - 2; return lens; } int[] guess(String in){ guesses++; int chars=0, positions=0; String pw = curPhrase; for(int i=0;i<in.length()&&i<pw.length();i++){ if(in.charAt(i)==pw.charAt(i)) positions++; } if(positions == pw.length() && pw.length()==in.length()){ System.out.println(in); return new int[]{-1,positions}; } for(int i=0;i<in.length();i++){ String c = String.valueOf(in.charAt(i)); if(pw.contains(c)){ pw = pw.replaceFirst(c, ""); chars++; } } System.out.println(in); chars -= positions; return new int[]{chars,positions}; } void start(){ long timer = System.currentTimeMillis(); loadDict("dict-small"); loadPhrases("passwords"); exclude = new String[3]; int min=999,max=0; for(String phrase : phrases){ curPhrase = phrase; int tries = crack(); min=tries<min?tries:min; max=tries>max?tries:max; } System.out.println("\nTotal: " + guesses); System.out.println("Min: " + min); System.out.println("Max: " + max); System.out.println("Time: " + ((System.currentTimeMillis()-timer)/1000d)); } int loadPhrases(String filename){ phrases = new ArrayList<String>(1000); try { BufferedReader br = new BufferedReader(new FileReader(filename)); String line; while ((line = br.readLine()) != null) if(line.length()>0) phrases.add(line); br.close(); } catch (Exception e){}; System.out.println("Loaded " + phrases.size() + " phrases."); return phrases.size(); } int loadDict(String filename){ dict = new HashSet<String>(10000); try { BufferedReader br = new BufferedReader(new FileReader(filename)); String line; while ((line = br.readLine()) != null) dict.add(line); br.close(); } catch (Exception e){}; System.out.println("Loaded " + dict.size() + " words"); return dict.size(); } int guesses; double sum = 0; List<String> phrases; Set<String> dict; String curPhrase; String[] exclude; String none; String pivots = "otnlidusypcbwmvfgeahkqrxzj"; // 26185 String pad = ".................................................................."; public static void main(String[] args){ new Splitter().start(); } } ``` [Answer] # C# - 10649 (min 8, max 14, avg: 10.6) time: ~12 hours This is what it looks like: ``` 13, whiteface rends opposed, 00:00:00.1282731, 00:01:53.0087971, 00:00:09.4368140 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooopppppppppp pppppppppppppppppppppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssstttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz .. . . . . . . . .............................................rrrrrrrrrrrrrrrrrrssssssssssssssssssttttttttttttttttttiiiiiiiiiiiiiiiiiinnnnnnnnnnnnnnnnnnaaaaaaaaaaaaaaaaaa . . . . . . . . . .............................................sssssssssssssssssslllllllllllllllllldddddddddddddddddduuuuuuuuuuuuuuuuuummmmmmmmmmmmmmmmmmrrrrrrrrrrrrrrrrrr .. . .. ....... .................................................nnnnnnnnnnnnnnnnnnddddddddddddddddddiiiiiiiiiiiiiiiiiiggggggggggggggggggllllllllllllllllllffffffffffffffffff .. . ............ ...............................................rrrrrrrrrrrrrrrrrrtttttttttttttttttthhhhhhhhhhhhhhhhhhddddddddddddddddddooooooooooooooooooffffffffffffffffff ....... . .......................................................ssssssssssssssssssttttttttttttttttttuuuuuuuuuuuuuuuuuuhhhhhhhhhhhhhhhhhhmmmmmmmmmmmmmmmmmmpppppppppppppppppp ....... ... .....................................................aaaaaaaaaaaaaaaaaa ......... ..... .................................................iiiiiiiiiiiiiiiiii sheffield eject postwar projected leigh gathers portfolio felts escapee fortescue ethyl affixes whiteface rends opposed ``` **Solver** It uses a forward-looking solver. Before it makes a guess, it estimates the number of distinct values returned from the mastermind given the currently possible passphrases. The guess that maximizes the number of distinct results is the one used. For the space guessing phase it considers only possible combinations of " " and ".". For the phrase guessing phase, it creates the whole list of currently possible passphrases (which is why its so slow). **Letter Counts** Letter counts are thrown in with the space finding. The letter sets were chosen by a greedy search, adding one letter at a time and sampling random test phrases to see how effective the set is. Code is here: <https://github.com/Tyler-Gelvin/MastermindContest> No interface was specified, so all input is hardcoded and unit tests are the only interface. The "main" test is SolverFixture.SolveParallelAll. [Answer] # C# - Total: 1000, Run Time: 305 Seconds, Avg: 24, Min: 14, Max: 32 Wow Avg's < 15 that's pretty good, well I can't beat that but I did take a stab at it so here's my approach. I broke it up word by word then solved them in succession. By determining the length of the first two words and then making a few strategic guesses(each time filtering by the previously guessed word) I was able to obtain the answer with a relatively small number of guesses. Over the period I developed this I was able to optimize most parts of it to preform efficiently(in number guesses) but the fault with it lies with the initial design decision to logically solve one word at a time, this causes me to discard parts of guesses and/or not run guesses as efficiently as possible, which in turn means I'm not winning this one ;(. Still a interesting design(at least I think so), one thing to note with the included code, in certain cases I can determine the answer without ever running a guess that returns -1, if that is required simple uncomment the line of code labelled "ADD GUESS HERE(if required)"(and add up to +1 to all my scores :( ) ## Algorithm(My Sudo Code Thinking) So really there's two parts to this, the first two words, and the last word. This may make no sense to anybody but me, but I've tried to add enough comments to the code so maybe that will make more sense: **NextWord(one of the two first two words)** { var lengthOfPossibleWord = Determine length of the word(In code see: efficient way to find length) List possibilities = All Words of that length(lengthOfPossibleWord) Make a guess possibilities = possibilities where(for the all guesses) { Number of characters in the same position is equal to the possible word (if outOfPlace characters is equal to 0) then where all characters are different than the possible word } } **LastWord(After the first two are solved)** { List possibilities = All Words filtered by the number of offPosition characters in the second word(In code see: helperWords) Make a guess possibilities = possibilities where(for the all guesses ) { Number of characters in the same position is equal to possible word Sum of in and out of position characters == possible word ( for all guesses ) Length is equal of greater than (Sum of in and out of position characters) length of possible word (if outOfPlace characters is equal to 0) then where all characters are different than the possible word } } ## Code Note for this to work you need to include the ppcg\_mastermind\_dict.txt and ppcg\_mastermind\_passes.txt in the running directory(or in the VS in the same directory and set "Copy to Output Directory" to true). I really apologize for the quality of code there's still allot of work to be done on this, it should work though. ``` using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; namespace MastermindHorseBatteryStaple { class Program { static void Main(string[] args) { List<int> results = new List<int>(); var Start = DateTime.UtcNow; foreach (var element in File.ReadAllLines(Directory.GetCurrentDirectory() + "\\ppcg_mastermind_passes.txt").ToArray()) { var pas1 = new PassPhrase(element); var pasSolve = new PassPhraseCracker(); var answer = pasSolve.Solve(pas1); Console.WriteLine("Answer(C): " + answer); Console.WriteLine("Answer(R): " + pas1.currentPassword); Console.WriteLine("Equal: " + answer.Equals(pas1.currentPassword)); Console.WriteLine("Total Cost: " + pas1.count); Console.WriteLine(); results.Add(pas1.count); } Console.WriteLine("Final Run Time(Seconds): " + (DateTime.UtcNow - Start).TotalSeconds); Console.WriteLine("Final Total Cost: " + results.Average()); Console.WriteLine("Min: " + results.Min()); Console.WriteLine("Max: " + results.Max()); Console.ReadLine(); } } class PassPhrase { public List<string> Words { get; set; } public int count = 0; public string currentPassword { get; set; } /// <summary> /// Declare if you want the class to generate a random password /// </summary> public PassPhrase() { Words = File.ReadAllLines(Directory.GetCurrentDirectory() + "\\ppcg_mastermind_dict.txt").ToList(); Random random = new Random(); currentPassword = Words[random.Next(Words.Count())] + " " + Words[random.Next(Words.Count())] + " " + Words[random.Next(Words.Count())]; } /// <summary> /// Use if you want to supply a password /// </summary> /// <param name="Password">The password to be guessed agianst</param> public PassPhrase(string Password) { Words = File.ReadAllLines(Directory.GetCurrentDirectory() + "\\ppcg_mastermind_dict.txt").ToList(); currentPassword = Password; } public int[] Guess(String guess) { count++; return Test(guess, currentPassword); } /// <summary> /// This method compares two string and return -1 if equal, /// otherwise it returns the number of character with the same index matching, /// and number of characters matching but in the wrong position /// </summary> /// <param name="value1">First value to compare</param> /// <param name="value2">Second value to compare</param> /// <returns>Returns {-1, -1} if equal, /// Two ints the first(0) being the number of chars matching but not in the right postion /// The second(1) being the number of chars that match and are in the right position /// </returns> public int[] Test(String value1, String value2) { if (String.Equals(value1, value2)) return new int[] { -1, -1 }; var results = new int[2]; results[0] = TestNumberOfOutOfPositionCharacters(value1, value2); results[1] = TestNumberOfInPositionCharacters(value1, value2); return results; } public int TestNumberOfInPositionCharacters(String value1, String value2) { var result = 0; var value1Collection = value1.ToCharArray(); var value2Collection = value2.ToCharArray(); for (int i = 0; i < value1Collection.Count(); i++) { if (value2Collection.Count() - 1 < i) continue; if (value2Collection[i] == value1Collection[i]) result++; } return result; } public int TestNumberOfOutOfPositionCharacters(String value1, String value2) { return CommonCharacters(value1, value2) - TestNumberOfInPositionCharacters(value1, value2); } private int CommonCharacters(string s1, string s2) { bool[] matchedFlag = new bool[s2.Length]; for (int i1 = 0; i1 < s1.Length; i1++) { for (int i2 = 0; i2 < s2.Length; i2++) { if (!matchedFlag[i2] && s1.ToCharArray()[i1] == s2.ToCharArray()[i2]) { matchedFlag[i2] = true; break; } } } return matchedFlag.Count(u => u); } private string GetRandomPassword() { Random rand = new Random(); return Words[rand.Next(Words.Count())] + " " + Words[rand.Next(Words.Count())] + " " + Words[rand.Next(Words.Count())]; } } class PassPhraseCracker { public class LengthAttempt { public int Length { get; set; } public int Result { get; set; } } public class WordInformation { public string Word { get; set; } public int[] Result { get; set; } } public string Solve(PassPhrase pas) { //The helperWords is used in the final word to lower the number of starting possibilites var helperWords = new List<WordInformation>(); var first = GetNextWord(pas, "", ref helperWords); //TODO: I'm ignoring the helperWords from the first word, //I should do some comparisions with the results of the seconds, this may make finding the last word slightly faster helperWords = new List<WordInformation>(); var second = GetNextWord(pas, first + " ", ref helperWords); //The final Word can be found much faster as we can say that letters in the wrong position are in this word var third = GetLastWord(pas, first + " " + second + " ", helperWords); return first + " " + second + " " + third; } private string GetNextWord(PassPhrase pas, string final, ref List<WordInformation> HelperWords) { var result = new int[] { 0, 0 }; var currentGuess = final; Random random = new Random(); var triedValues = new List<WordInformation>(); //The most efficient way to find length of the word that I could come up with var triedLengths = new List<LengthAttempt>(); var lengthAttempts = new List<LengthAttempt>(); var lengthOptions = pas.Words.AsParallel().GroupBy(a => a.ToCharArray().Count()).OrderByDescending(a => a.Count()).ToArray(); var length = 0; while (length == 0) { //Find most frequency number of character word between already guessed ones var options = lengthOptions.AsParallel().Where(a => (!lengthAttempts.Any(b => b.Result == 1) || a.Key < lengthAttempts.Where(b => b.Result == 1).Select(b => b.Length).Min()) && (!lengthAttempts.Any(b => b.Result == 0) || a.Key > lengthAttempts.Where(b => b.Result == 0).Select(b => b.Length).Max())); //Rare condition that occurs when the number of characters is equal to 20 and the counter //Guesses 18 and 20 if (!options.Any()) { length = lengthAttempts.Where(a => a.Result == 1).OrderBy(a => a.Length).First().Length; break; } var tryValue = options.First(); //Guess with the current length, plus one space //TODO: I can append characters to this and make it a more efficient use of the Guess function, //this would speed up the calculation of the final Word somewhat //but this really highlights the failing of this design as characters in the wrong positions can't be deterministically used until the final word result = pas.Guess(currentGuess + new String(' ', tryValue.Key) + " "); //This part looks at all the attempts and tries to determine the length of the word lengthAttempts.Add(new LengthAttempt { Length = tryValue.Key, Result = result[1] - final.Length }); //For words with length 1 if (lengthAttempts.Any(a => a.Length == 1 && a.Result == 1)) length = 1; //For words with the max length if (lengthAttempts.Any(a => a.Length == lengthOptions.Select(b => b.Key).Max() && a.Result == 1)) length = lengthAttempts.Single(a => a.Length == lengthOptions.Select(b => b.Key).Max() && a.Result == 1).Length; else if (lengthAttempts .Any(a => a.Result == 1 && lengthAttempts.Any(b => b.Length == a.Length - 1) && lengthAttempts.Single(b => b.Length == a.Length - 1).Result == 0)) length = lengthAttempts .Single(a => a.Result == 1 && lengthAttempts.Any(b => b.Length == a.Length - 1) && lengthAttempts.Single(b => b.Length == a.Length - 1).Result == 0).Length; } //Filter by length var currentOptions = pas.Words.Where(a => a.Length == length).ToArray(); //Now try a word, if not found then filter based on all words tried while (result[1] != final.Length + length + 1) { //Get farthest value, or middle randomly //TODO: I've struggled with this allot, and tried many way to some up with the best value to try //This is the best I have for now, but there may be a better way of doing it var options = currentOptions.AsParallel().OrderByDescending(a => ComputeLevenshteinDistance(a, triedValues.Count() == 0 ? currentOptions[0] : triedValues.Last().Word)).ToList(); if (random.Next(2) == 1) currentGuess = options.First(); else currentGuess = options.Skip((int)Math.Round((double)(options.Count() / 2))).First(); //try it result = pas.Guess(final + currentGuess + " "); //add it to attempts triedValues.Add(new WordInformation { Result = result, Word = currentGuess }); //filter any future options to things with the same length and equal or more letters in the same position and equal or less letters in the wrong position currentOptions = currentOptions.Except(triedValues.Select(a => a.Word)).AsParallel() .Where(a => triedValues.All(b => pas.TestNumberOfInPositionCharacters(a, b.Word) == b.Result[1] - 1 - final.Length)) //Special Zero Case .Where(a => triedValues .Where(b => b.Result[1] - 1 - final.Length == 0) .All(b => pas.TestNumberOfInPositionCharacters(a, b.Word) == 0)) .ToArray(); } //Add attempts to helper list HelperWords = HelperWords.Concat(triedValues.Where(a => a.Result[0] - pas.TestNumberOfOutOfPositionCharacters(a.Word, currentGuess) > 0) .Select(a => new WordInformation { Word = a.Word, Result = new int[] { a.Result[0] - pas.TestNumberOfOutOfPositionCharacters(a.Word, currentGuess), a.Result[1] } }).ToList()).ToList(); return currentGuess; } private string GetLastWord(PassPhrase pas, string final, List<WordInformation> HelperWords) { Random rand = new Random(); var triedList = new List<WordInformation>(); var result = new int[] { 0, 0 }; //This uses the helperList from the previous word to attempt help filter the initial possiblities of the last word before preforming the first check var currentOptions = pas.Words.AsParallel().Where(a => HelperWords .All(b => pas.TestNumberOfOutOfPositionCharacters(a, b.Word) + pas.TestNumberOfInPositionCharacters(a, b.Word) >= b.Result[0])).ToArray(); var current = final; while (result[0] != -1) { //Here we know the final word but their is no reason to submit it to the guesser(that would cost one more), just return it if (currentOptions.Count() == 1) { //ADD GUESS HERE(if required) //pas.Guess(final + current); return currentOptions[0]; } //Get farthest value, or middle randomly var options = currentOptions.AsParallel() .OrderByDescending(a => ComputeLevenshteinDistance(a, triedList.Count() == 0 ? currentOptions[0] : triedList.Last().Word)).ToList(); //Get the next value to try if (rand.Next(2) == 1) current = options.First(); else current = options.Skip((int)Math.Round((double)(options.Count() / 2))).First(); //try it result = pas.Guess(final + current); //If its the right word return it if (result[0] == -1) return current; //add it to attempts triedList.Add(new WordInformation { Result = result, Word = current }); //filter any future options to things with the same length and equal or more letters in the same position and equal or less letters in the wrong position currentOptions = currentOptions.Except(triedList.Select(a => a.Word)).AsParallel() .Where(a => triedList .All(b => pas.TestNumberOfInPositionCharacters(a, b.Word) == b.Result[1] - final.Length && pas.TestNumberOfInPositionCharacters(a, b.Word) + pas.TestNumberOfOutOfPositionCharacters(a, b.Word) == b.Result[0] + b.Result[1] - final.Length && a.Length >= pas.TestNumberOfInPositionCharacters(a, b.Word) + pas.TestNumberOfOutOfPositionCharacters(a, b.Word) - final.Length)) //Special zero match condition .Where(a => triedList .Where(b => b.Result[1] - final.Length == 0) .All(b => pas.TestNumberOfInPositionCharacters(a, b.Word) == 0)).ToArray(); } return current; } /// <summary> /// http://www.dotnetperls.com/levenshtein /// Returns the number of character edits (removals, inserts, replacements) that must occur to get from string A to string B. /// </summary> /// <param name="s">First string to compare</param> /// <param name="t">Second string to compare</param> /// <returns>Number of edits needed to turn one string into another</returns> private static int ComputeLevenshteinDistance(string s, string t) { int n = s.Length; int m = t.Length; int[,] d = new int[n + 1, m + 1]; // Step 1 if (n == 0) { return m; } if (m == 0) { return n; } // Step 2 for (int i = 0; i <= n; d[i, 0] = i++) { } for (int j = 0; j <= m; d[0, j] = j++) { } // Step 3 for (int i = 1; i <= n; i++) { //Step 4 for (int j = 1; j <= m; j++) { // Step 5 int cost = (t[j - 1] == s[i - 1]) ? 0 : 1; // Step 6 d[i, j] = Math.Min( Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost); } } // Step 7 return d[n, m]; } } } ``` [Answer] # Python - min: 87, max: 108, total: 96063, time: 4s This is my second post. This method use less time but score worse. And it can be run using either: * CPython 2 * CPython 3 * Pypy 2 (fastest) * Pypy 3 Steps: * Find the first 2 spaces using guesses like `. ....`, `.. ...`, ... * Count character freqencies for each word in the password. * Guess for each valid combinations after filtering by word length and character freqency. It cost about 90 guesses for each password. ``` from __future__ import print_function import sys import itertools from collections import defaultdict def run_checker(answer, guesser): guess_count = 0 guesser = guesser() guess = next(guesser) while True: char_count = len(set(guess) & set(answer)) pos_count = sum(x == y for x, y in zip(answer, guess)) guess_count += 1 if answer == guess: break guess = guesser.send((char_count, pos_count)) try: guesser.send((-1, -1)) except StopIteration: pass return guess_count # Preprocessing words = list(map(str.rstrip, open('dict.txt'))) M = 26 ord_a = ord('a') def get_fingerprint(word): counts = [0] * M for i in map(ord, word): counts[i - ord_a] += 1 return tuple(counts) P = defaultdict(list) for word in words: P[get_fingerprint(word)].append(word) # End of preprocessing def guesser2(): max_word_len = max(map(len, words)) max_len = max_word_len * 3 + 2 spaces = [] for i in range(1, max_len - 1): guess = '.' * i + ' ' char_count, pos_count = yield guess if pos_count > 0: spaces.append(i) if len(spaces) == 2: break word_lens = [spaces[0], spaces[1] - spaces[0] - 1, max_word_len] C = [] for i in range(3): char_counts = [0] * M for j in range(M): guess = chr(ord_a + j) * (i + sum(word_lens[:i + 1])) _, char_counts[j] = yield guess C.append(char_counts) for i in (2, 1): for j in range(M): C[i][j] -= C[i - 1][j] candidates = [] for i in range(3): candidates.append(P[tuple(C[i])]) for i in range(2): candidates[i] = [w for w in candidates[i] if word_lens[i] == len(w)] try_count = 0 for result in itertools.product(*candidates): guess = ' '.join(result) char_count, pos_count = yield guess try_count += 1 if char_count == -1: break def test(test_file, guesser): scores = [] for i, answer in enumerate(map(str.rstrip, open(test_file))): print('\r{}'.format(i), end='', file=sys.stderr) scores.append(run_checker(answer, guesser)) print(scores) print('sum:{} max:{} min:{}'.format(sum(scores), max(scores), min(scores))) if __name__ == '__main__': test(sys.argv[1], guesser2) ``` [Answer] # Perl (still running ... as of now min/avg/max of 8/9,2/11, estimate it at 1500300hours total runtime) Update: Changed the initial guesses to speed it up somewhat. Fixed a bug. Its probably not gonna finish before this contest does, but I might aswell post it. It does not determine individual word lengths, so it has to check the entire dictionary, which ... takes some time. With the first two guesses it determines the total length, the count of 'e', and how many different characters there are. Then it tries all combinations that suffice those statistics as well as all previous guesses. This recent (and last) version has added mp and currently runs on a 24 core system. ``` use strict; use POSIX ":sys_wait_h"; $| = 1; my( $buckets ); open my $dict, "<", "dict.txt"; while( <$dict> ) { chomp; push( @{$buckets->{length($_)}}, [ split // ] ); }; close $dict; open my $pass, "<", "pass.txt"; my( @pids ); my( $ind ) = 0; for( my $i = 0; $i < 1000; $i++ ) { my $phrase = <$pass>; chomp( $phrase ); my( $pid ) = fork(); if( $pid != 0 ) { $pids[$ind] = $pid; print join( "; ", @pids ), "\n"; for( my $j = 0; $j < 18; ++$j, $j %= 18 ) { waitpid( $pids[$j], WNOHANG ) and $ind=$j,last; sleep( 1 ); }; } else { my( $r ) = &guessPassPhrase( $phrase, $buckets ); open my $out, ">>", "result.txt"; print $out "'$phrase' => $r\n"; close $out; exit; }; }; close $pass; sub guessPassPhrase { our( $pp, $buckets ) = @_; our( @log ) = undef; our( @ppa ) = split //, $pp; our( $trys ) = 0; our( $invers ) = 1; our( $best ) = 0; print "Next : ", $pp, "\n"; my( @pw1 ) = map { @{$buckets->{$_}} } ( sort { $b <=> $a } keys( %$buckets )); my( @pw2, $llt1 ); my( @pw3, $llt2 ); my( $t ) = [ (" ")x9,("-")x58,("a".."z") x 64 ]; my( $y, $c ) = &oracleMeThis( $t ); my( $l ) = $y + $c; push( @log, [ [(" ")x9], 2-$c, $c ] ); $t = [("a".."z")]; my( $y, $c ) = &oracleMeThis( $t ); push( @log, [ $t, $y, $c ] ); if( $best < ($y + $c) ) { $best = ($y + $c); }; print "Guessed ($pp:$trys/$best/$l):", @$t, "=> $y/$c \n"; $t = [("e")x4]; my( $y, $c ) = &oracleMeThis( $t ); push( @log, [ $t, $y, $c ] ); if( $best < ($y + $c) ) { $best = ($y + $c); }; print "Guessed ($pp:$trys/$best/$l):", @$t, "=> $y/$c \n"; $t = [("i")x6]; my( $y, $c ) = &oracleMeThis( $t ); push( @log, [ $t, $y, $c ] ); if( $best < ($y + $c) ) { $best = ($y + $c); }; print "Guessed ($pp:$trys/$best/$l):", @$t, "=> $y/$c \n"; LOOP1: for my $w1 ( @pw1 ) { my( $t ) = [ @$w1, " " ]; print "Pondering: ", @$t, "($trys;$best/$l;",$::e1,",",$::e2,") \r"; &EliminatePartial( $t ) && ++$::e1 && next; if( $llt1 != @$t ) { @pw2 = map { $_ < $l - @$t ? @{$buckets->{$_}} : () } ( sort { $b <=> $a } keys( %$buckets )); $llt1 = @$t; }; $llt2 = 0; LOOP2: for my $w2 ( @pw2 ) { my( $t ) = [ @$w1, " ", @$w2, " " ]; # print "Pondering: ", @$t, "(",$::e1,",",$::e2,") \r"; &EliminatePartial( $t ) && ++$::e2 && next; if( $llt2 != @$t ) { @pw3 = map { $_ == $l - @$t ? @{$buckets->{$_}} : () } ( sort { $b <=> $a } keys( %$buckets )); $llt2 = @$t; }; LOOP3: for my $w3 ( @pw3 ) { my( $t ) = [ @$w1, " ", @$w2, " ", @$w3 ]; &EliminatePartial( $t ) && next LOOP3; my( $y, $c ) = &oracleMeThis( $t ); push( @log, [ $t, $y, $c ] ); if( $best < ($y + $c) ) { $best = ($y + $c); }; print "Guessed ($pp:$trys/$best/$l):", @$t, "=> $y/$c \n"; if( $c == $l ) { return( $trys ); }; if( $c == 0 ) { @pw2 = (); next LOOP1; }; if( $c == 1 ) { @pw3 = (); next LOOP2; }; if( $c < @$w1 ) { next LOOP1; }; if( $c < @$w1 + @$w2 ) { next LOOP2; }; }; }; }; die( "Failed To Guess" ); sub EliminatePartial { my( $guessn ) = @_; for my $log ( @log ) { next if !$log; my( $guesso, $yo, $co ) = @$log; my( $guessos ) = join( "", @$guesso ); my( $cn ) = scalar( map { $$guesso[$_] eq $$guessn[$_] ? ( 1 ) : () } ( 0 .. ( @$guesso < @$guessn ? @$guesso : @$guessn ) - 1 )); my( $yn ) = scalar( map { $guessos =~ s/$_// ? ( 1 ) : () } ( @$guessn )) - $cn; return( 1 ) if( $cn > $co || $yn > $yo ); return( 1 ) if(( $yo - $yn ) + ( $co - $cn ) > $l - @$guessn ); return( 1 ) if( @$guesso <= @$guessn && $co != $cn ); }; return( 0 ); }; sub oracleMeThis { my( $guessn ) = @_; $trys++; my( $pph ) = $pp; my( $cn ) = scalar( map { $ppa[$_] eq $$guessn[$_] ? ( 1 ) : () } ( 0 .. @$guessn - 1 )); my( $yn ) = scalar( map { $pph =~ s/$_// ? ( 1 ) : () } ( @$guessn )) - $cn; return( $yn, $cn ); }; }; ``` [Answer] # Java 10.026 (in 2.5 hours) Here is my optimised code, now multi-threaded to improve speed: ``` import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class MastermindV4MT { /* * Total guesses: 10026 * Took: 8461801 ms */ // Order of characters to analyze: // eiasrntolcdupmghbyfvkwzxjq - 97 private int[] lookup = new int[] { 4, 8, 0, 18, 17, 13, 19, 14, 11, 2, 3, 20, 15, 12, 6, 7, 1, 24, 5, 21, 10, 22, 25, 23, 9, 16 }; public static void main(String[] args) throws Exception { new MastermindV4MT().run(); } int done = 0; int totalGuesses = 0; private void run() throws Exception { long beforeTime = System.currentTimeMillis(); Map<Integer, List<char[]>> wordMap = createDictionary(); List<String> passPhrases = createPassPhrases(); ExecutorService executor = Executors.newFixedThreadPool(8); for(String phrase:passPhrases) { executor.execute(new Runnable() { public void run() { int guesses = solve(wordMap, phrase); totalGuesses+=guesses; done++; System.out.println("At "+done+" of "+passPhrases.size()+" just added "+guesses+" predicted score: "+((1.0*totalGuesses)/done)*passPhrases.size()); }; }); } executor.shutdown(); try { executor.awaitTermination(Long.MAX_VALUE, TimeUnit.HOURS); } catch (InterruptedException e) { } System.out.println("Total guesses: " + totalGuesses); System.out.println("Took: " + (System.currentTimeMillis() - beforeTime) + " ms"); } int[] guess(char[] in, char[] pw, char[] pwsorted) { int chars = 0, positions = 0; char[] inc = Arrays.copyOf(in, in.length); for (int i = 0; i < inc.length && i < pw.length; i++) { if (inc[i] == pw[i]) positions++; } if (positions == pw.length && pw.length == inc.length) return new int[] { -1, positions }; Arrays.sort(inc); int i1 = 0; int i2 = 0; while(i1 < pwsorted.length && i2 < inc.length) { if(inc[i2]==pwsorted[i1]) { i1++; i2++; chars++; } else if(inc[i2]<pwsorted[i1]) { i2++; } else { i1++; } } chars -= positions; return new int[] { chars, positions }; } private int solve(Map<Integer, List<char[]>> wordMap, String password) { // Do one initial guess which gives us two things: // The amount of characters in total // The amount of e's char[] pw = password.toCharArray(); char[] pwsorted = password.toCharArray(); Arrays.sort(pwsorted); int[] initialResult = guess(Facts.INITIAL_GUESS.toCharArray(), pw, pwsorted); int guesses = 1; // Create the object that tracks all the known facts/bounds: Facts facts = new Facts(initialResult); // Determine a pivot and find the spaces (binary search) int center = ((initialResult[0] + initialResult[1]) / 2) + 1; guesses += findSpaces(center, facts, pw, pwsorted); // We know the first word length, the second might have some bounds, but // is unknown: // We can calculate the lengths: int minLength1 = facts.spaceBounds[0] - 1; int maxLength1 = facts.spaceBounds[1] - 1; char[] phraseBuilder = new char[facts.totalLength+2]; for (int length1 = minLength1; length1 <= maxLength1;length1++) { if (wordMap.get(length1) == null) { continue; } for (char[] w1 : wordMap.get(length1)) { for(int i = 0; i<w1.length;i++) { phraseBuilder[i] = w1[i]; } phraseBuilder[w1.length] = ' '; if (facts.partialMatches(phraseBuilder, facts.totalLength+1-w1.length)) { int minLength2 = (facts.spaceBounds[2] - length1 - 2); int maxLength2 = (facts.spaceBounds[3] - length1 - 2); for (int length2 = minLength2; length2 <= maxLength2;length2++) { if (wordMap.get(length2) == null) { continue; } for (char[] w2 : wordMap.get(length2)) { // Continue if (according to our facts) this word is a // partial match: for(int i = 0; i<length2;i++) { phraseBuilder[w1.length+1+i] = w2[i]; } phraseBuilder[w1.length+w2.length+1] = ' '; if (facts.partialMatches(phraseBuilder, facts.totalLength-(w1.length+w2.length))) { if (wordMap.get(facts.totalLength - length2 - length1) == null) { continue; } int length3 = facts.totalLength - length2 - length1; for (char[] w3 : wordMap.get(length3)) { for(int i = 0; i<length3;i++) { phraseBuilder[w1.length+w2.length+2+i] = w3[i]; } if (facts.matches(phraseBuilder)) { int[] result = guess(phraseBuilder, pw, pwsorted); guesses++; //String possiblePhrase = new String(phraseBuilder); //System.out.println(possiblePhrase + " " + Arrays.toString(result)); if (result[0] == -1) { return guesses; } // No match, update facts: facts.storeInvalid(phraseBuilder.clone(), result); } } for(int i = 0; i<phraseBuilder.length-(w1.length+2+w2.length);i++) { phraseBuilder[w1.length+w2.length+2+i] = '-'; } } } for(int i = 0; i<phraseBuilder.length-(w1.length+1);i++) { phraseBuilder[w1.length+1+i] = '-'; } } } } } throw new IllegalArgumentException("Unable to solve!?"); } private int findSpaces(int center, Facts facts, char[] pw, char[] pwsorted) { char[] testPhrase = new char[facts.totalLength + 2+facts.charBounds[lookup[facts.charPtr]]]; // Place spaces for analysis: int ptr = 0; for (int i = 0; i < center; i++) { testPhrase[ptr++] = ' '; } while (ptr < (facts.totalLength + 2)) { testPhrase[ptr++] = '-'; } // Append extra characters for added information early on: for (int i = 0; i < facts.charBounds[lookup[facts.charPtr]]; i++) { testPhrase[ptr++] = (char) (lookup[facts.charPtr] + 97); } // Update space lower and upper bounds: int[] answer = guess(testPhrase, pw, pwsorted); if (answer[1] == 0) { facts.spaceBounds[0] = Math.max(facts.spaceBounds[0], center + 1); facts.spaceBounds[2] = Math.max(facts.spaceBounds[2], center + 3); } else if (answer[1] == 1) { facts.spaceBounds[1] = Math.min(facts.spaceBounds[1], center); facts.spaceBounds[2] = Math.max(facts.spaceBounds[2], center + 1); } else { facts.spaceBounds[3] = Math.min(facts.spaceBounds[3], center); facts.spaceBounds[1] = Math.min(facts.spaceBounds[1], center - 2); } int correctAmountChars = (answer[0] + answer[1]) - 2; facts.updateCharBounds(correctAmountChars); // System.out.println(Arrays.toString(facts.spaceBounds)); if (facts.spaceBounds[1]-facts.spaceBounds[0]<5) { // Only find the first space return 1; //if(facts.spaceBounds[3]-facts.spaceBounds[2]<4) return; //findSpaces(facts.spaceBounds[2] + ((facts.spaceBounds[3]-facts.spaceBounds[2])/3), facts, pw, pwsorted); } else { return 1+findSpaces((facts.spaceBounds[0] + facts.spaceBounds[1]) / 2, facts, pw, pwsorted); } } private class Facts { private static final String INITIAL_GUESS = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccccccccccccddddddddddddddddddffffffffffffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnooooooooooooooooooppppppppppppppppppqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrssssssssssssssssssttttttttttttttttttuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzz"; private final int totalLength; private final int[] spaceBounds; // Pre-filled with maximum bounds obtained from dictionary: private final int[] charBounds = new int[] { 12, 9, 9, 9, 15, 9, 12, 9, 18, 6, 9, 12, 9, 12, 12, 9, 3, 12, 15, 9, 12, 6, 6, 3, 9, 6 }; private int charPtr; public Facts(int[] initialResult) { totalLength = initialResult[0] + initialResult[1]; spaceBounds = new int[] { 2, Math.min(totalLength - 2, 22), 4, Math.min(totalLength + 1, 43) }; // Eliminate firsts charBounds[lookup[0]] = initialResult[1]; // Adjust: for (int i = 1; i < charBounds.length; i++) { charBounds[lookup[i]] = Math.min(charBounds[lookup[i]], totalLength - initialResult[1]); } charPtr = 1; } private List<char[]> previousGuesses = new ArrayList<char[]>(); private List<int[]> previousResults = new ArrayList<int[]>(); public void storeInvalid(char[] phrase, int[] result) { previousGuesses.add(phrase); previousResults.add(result); } public void updateCharBounds(int correctAmountChars) { // Update the bounds we know for a certain character: int knownCharBounds = 0; charBounds[lookup[charPtr]] = correctAmountChars; for (int i = 0; i <= charPtr; i++) { knownCharBounds += charBounds[lookup[i]]; } // Also update the ones we haven't checked yet, we might know // something about them now: for (int i = charPtr + 1; i < charBounds.length; i++) { charBounds[lookup[i]] = Math.min(charBounds[lookup[i]], totalLength - knownCharBounds); } charPtr++; while (charPtr < 26 && charBounds[lookup[charPtr]] == 0) { charPtr++; } } public boolean partialMatches(char[] phrase, int amountUnknown) { //Try to match a partial phrase, we can't be too picky because we don't know what else is next Arrays.fill(cUsed, 0); for(int i = 0; i<phrase.length; i++) { if(phrase[i]!=' ' && phrase[i]!='-'&&phrase[i]!=0) { cUsed[phrase[i]-97]++; } } for(int i = 0; i<cUsed.length; i++) { //Only eliminate the phrases that definitely have wrong characters: if(cUsed[i] > charBounds[i]) { return false; } } //Check again previous guesses: int cnt = 0; char[] phraseSorted = phrase.clone(); Arrays.sort(phraseSorted); for(char[] previousGuess:previousGuesses) { // If the input phrase is the correct phrase it should score the same against previous tries: int[] result = guess(previousGuess, phrase, phraseSorted); int[] expectedResult = previousResults.get(cnt); //Some cases we can stop early: if(result[0]+result[1] > expectedResult[0]+expectedResult[1]) { return false; } if(result[1]>expectedResult[1]) { return false; } if(result[0]+amountUnknown<expectedResult[0]) { return false; } if(result[1]+amountUnknown<expectedResult[1]) { return false; } if(result[0]+result[1]+amountUnknown < expectedResult[1]+expectedResult[0]) { return false; } cnt++; } return true; } int[] cUsed = new int[26]; public boolean matches(char[] phrase) { // Try to match a complete phrase, we can now use all information: Arrays.fill(cUsed, 0); for (int i = 0; i < phrase.length; i++) { if(phrase[i]!=' ' && phrase[i]!='-'&&phrase[i]!=0) { cUsed[phrase[i] - 97]++; } } for (int i = 0; i < cUsed.length; i++) { if (i < charPtr) { if (cUsed[lookup[i]] != charBounds[lookup[i]]) { return false; } } else { if (cUsed[lookup[i]] > charBounds[lookup[i]]) { return false; } } } // Check again previous guesses: char[] phraseSorted = phrase.clone(); Arrays.sort(phraseSorted); int cnt = 0; for(char[] previousGuess:previousGuesses) { // If the input phrase is the correct phrase it should score the // same against previous tries: int[] result = guess(previousGuess, phrase, phraseSorted); int[] expectedResult = previousResults.get(cnt); if (!Arrays.equals(expectedResult, result)) { return false; } cnt++; } return true; } } private List<String> createPassPhrases() throws Exception { BufferedReader reader = new BufferedReader(new FileReader(new File("pass.txt"))); List<String> phrases = new ArrayList<String>(); String input; while ((input = reader.readLine()) != null) { phrases.add(input); } return phrases; } private Map<Integer, List<char[]>> createDictionary() throws Exception { BufferedReader reader = new BufferedReader(new FileReader(new File("words.txt"))); Map<Integer, List<char[]>> wordMap = new HashMap<Integer, List<char[]>>(); String input; while ((input = reader.readLine()) != null) { List<char[]> words = wordMap.get(input.length()); if (words == null) { words = new ArrayList<char[]>(); } words.add(input.toCharArray()); wordMap.put(input.length(), words); } return wordMap; } } ``` ]
[Question] [ Output this 1364-digit base-10 number: ``` 10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874897489950008250798014478066014893203193926076357920163707042852616942733354325378261468425502224936203089956427521668102778596882443702230532724374828028933960643144327285227754985461570358500265135333500954075465441985256254776102064625494398779453723330206306859677410408807692326906168737018862161148707729611012076342295413323680430446529763872458887191437347994063250920466184003173586602441075384748222102267773145003624260992372156354624662289026123081819214885321984526331716887191378907363723962768881646531494039722207338471537744184950666337656928147552391544567298663655079621129011773598162469141317639170063853667739680653118979048627652462235681893246541359880812508588104345141359691398313598202577424145658860334913269759048622492214169304247816441675958725602279911468750380291607080058491441201347157459047314438815796116358356171983789000270540329047696182295315977628397256525031861796294929740163865774776146472541890007191451515587790900275580657982495983198842069735835409348390389014043245596652434869311982404102985853034513631928339140603461069829946906350 ``` This number is the entire text of the singularly elegant puzzle [Ginormous](http://web.mit.edu/puzzle/www/2005/setec/ginormous/) by Derek Kisman from the 2005 MIT Mystery Hunt. It encodes a single-word message in a clever multilayered way for solvers to figure out without any instructions. You might want to try solving the puzzle before reading further. How was this number produced? We reverse the steps from the [puzzle solution](http://web.mit.edu/puzzle/www/2005/setec/ginormous/solution.html). Since the solution performs repeated prime factorization, we produce the number by repeatedly multiplying specific primes derived from the previous step. 1. Start with the solution word `UNSHARPENED` and convert it to a list of numbers with `A=1, ... Z=26` to get `[21, 14, 19, 8, 1, 18, 16, 5, 14, 5, 4]`. 2. Convert each number to a 5-digit prime where: * the first two digits count up from 13 * the third and fourth digits are the numbers from the previous step, with a leading zero for one-digit numbers * the last digit is the smallest one to make the whole 5-digit number primeThis gives: ``` 13217 14143 15193 16087 17011 18181 19163 20051 21143 22051 23041 ``` Find their product `58322536285290033985886806240808836417438318459`. 3. Take the digits, `5, 8, 3, ...` and count up from 0 skipping that many values in between. * Skip 5 numbers after 0 to get 6 * Skip 8 numbers after 6 to get 15 * Skip 3 numbers after 15 to get 19 * ... and so onThis gives you: ``` [6, 15, 19, 22, 25, 31, 35, 42, 45, 54, 60, 63, 73, 74, 75, 79, 83, 93, 102, 108, 117, 126, 133, 142, 143, 150, 153, 158, 159, 168, 169, 178, 187, 191, 198, 203, 205, 213, 218, 222, 231, 235, 237, 246, 251, 257, 267] ``` Take the respective \$n\$'th highest-primes (the 6th prime is 13, the 15th prime is 47, ...) and multiply them ``` 13 * 47 * 67 * 79 * 97 * 127 * 149 * 181 * 197 * 251 * 281 * 307 * 367 * 373 * 379 * 401 * 431 * 487 * 557 * 593 * 643 * 701 * 751 * 821 * 823 * 863 * 883 * 929 * 937 * 997 * 1009 * 1061 * 1117 * 1153 * 1213 * 1237 * 1259 * 1303 * 1361 * 1399 * 1453 * 1483 * 1489 * 1559 * 1597 * 1621 * 1709 ``` to get: ``` 142994592871080776665367377010330975609342911590947493672510923980226345650368095529497306323265234451588273628492018413579702589 ``` 4. Finally, take the digits `1, 4, 2, ..., 8, 9` and put them as powers of successive primes in the factorization \$2^1 3^4 5^2 \cdots 719^8 727^9\$ to get the final number: ``` 10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874897489950008250798014478066014893203193926076357920163707042852616942733354325378261468425502224936203089956427521668102778596882443702230532724374828028933960643144327285227754985461570358500265135333500954075465441985256254776102064625494398779453723330206306859677410408807692326906168737018862161148707729611012076342295413323680430446529763872458887191437347994063250920466184003173586602441075384748222102267773145003624260992372156354624662289026123081819214885321984526331716887191378907363723962768881646531494039722207338471537744184950666337656928147552391544567298663655079621129011773598162469141317639170063853667739680653118979048627652462235681893246541359880812508588104345141359691398313598202577424145658860334913269759048622492214169304247816441675958725602279911468750380291607080058491441201347157459047314438815796116358356171983789000270540329047696182295315977628397256525031861796294929740163865774776146472541890007191451515587790900275580657982495983198842069735835409348390389014043245596652434869311982404102985853034513631928339140603461069829946906350 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 32 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` “Œɱl»O_96J+12żƲȷ,⁵¤ḋÆnPD‘ÄÆNPDÆẸ ``` **[Try it online!](https://tio.run/##AT4Awf9qZWxsef//4oCcxZLJsWzCu09fOTZKKzEyxbzGssi3LOKBtcKk4biLw4ZuUETigJjDhMOGTlBEw4bhurj//w "Jelly – Try It Online")** ### How? ``` “Œɱl»O_96J+12żƲȷ,⁵¤ḋÆnPD‘ÄÆNPDÆẸ - Link: no arguments “Œɱl» - dictionary word "unsharpened" O - ordinals [117,110,115,104,97,114,112,101,110,101,100] _96 - minus 96 [21,14,19,8,1,18,16,5,14,5,4] Ʋ - last four links as a monad - f(X=that): J - range of length [1,2,3,4,5,6,7,8,9,10,11] 12 - twelve 12 + - add [13,14,15,16,17,18,19,20,21,22,23] ż - zip with (X) [[13,21],[14,14],[15,19],[16,8],[17,1],[18,18],[19,16],[20,5],[21,14],[22,5],[23,4]] ¤ - nilad followed by link(s) as a nilad: ȷ - a thousand 1000 ⁵ - ten 10 , - pair [1000,10] ḋ - dot product [13210,14140,15190,16080,17010,18180,19160,20050,21140,22050,23040] Æn - next prime above [13217,14143,15193,16087,17011,18181,19163,20051,21143,22051,23041] P - product 58322536285290033985886806240808836417438318459 D - digits [5,8,3,2,2,5,3,6,2,8,5,2,9,0,0,3,3,9,8,5,8,8,6,8,0,6,2,4,0,8,0,8,8,3,6,4,1,7,4,3,8,3,1,8,4,5,9] ‘ - increment [6,9,4,3,3,6,4,7,3,9,6,3,10,1,1,4,4,10,9,6,9,9,7,9,1,7,3,5,1,9,1,9,9,4,7,5,2,8,5,4,9,4,2,9,5,6,10] Ä - cumulative sums [6,15,19,22,25,31,35,42,45,54,60,63,73,74,75,79,83,93,102,108,117,126,133,142,143,150,153,158,159,168,169,178,187,191,198,203,205,213,218,222,231,235,237,246,251,257,267] ÆN - nth prime [13,47,67,79,97,127,149,181,197,251,281,307,367,373,379,401,431,487,557,593,643,701,751,821,823,863,883,929,937,997,1009,1061,1117,1153,1213,1237,1259,1303,1361,1399,1453,1483,1489,1559,1597,1621,1709] P - product 142994592871080776665367377010330975609342911590947493672510923980226345650368095529497306323265234451588273628492018413579702589 D - digits [1,4,2,9,9,4,5,9,2,8,7,1,0,8,0,7,7,6,6,6,5,3,6,7,3,7,7,0,1,0,3,3,0,9,7,5,6,0,9,3,4,2,9,1,1,5,9,0,9,4,7,4,9,3,6,7,2,5,1,0,9,2,3,9,8,0,2,2,6,3,4,5,6,5,0,3,6,8,0,9,5,5,2,9,4,9,7,3,0,6,3,2,3,2,6,5,2,3,4,4,5,1,5,8,8,2,7,3,6,2,8,4,9,2,0,1,8,4,1,3,5,7,9,7,0,2,5,8,9] ÆẸ - prime exponentiate (answer) ``` [Answer] # [JavaScript (Node.js)](https://nodejs.org), 149 bytes ``` d=>(F=n=>[...n+''].map(h=v=>(g=k=>x%--k?g(k):k>1)(++x)||!d&&v--?h(v):p*=x**BigInt(d?v:1),p=x=1n)&&p)(d=F(0xA3745E1D28D1E3702D3F5F1E336A3F1A64F7F7Bn)) ``` [Try it online!](https://tio.run/##DcnRCoIwFIDhZ@kiO0fbaE0zhKMoOugZogtxZmXNUTF20bubdz/f/2hd@@ned/tlZtL9fKVZUw6KDOVnzrmJNpsLf7UWbuSWMdBIuV8zNhYDjJiNuUCIIo@/30oHgWOsuIHDzIbkw7C6DyfzBV24TODWkidhMAgsgiYFO1/KNE4aUe@PtWhkutvXUiVqSXkopRLlIVapSiuDOHeT@UzPnj@nAa6wwB8 "JavaScript (Node.js) – Try It Online") ### How? The result of the 2nd step is hard-coded as a BigInt in hexadecimal: ``` 0xA3745E1D28D1E3702D3F5F1E336A3F1A64F7F7Bn ``` The 3rd and 4th steps are similar enough to be processed with the same helper function **F**, whose exact behavior depends on the flag **d**. ``` d => // 4th step: invoke F with d truthy F( d = // 3rd step: invoke F with d falsy (undefined) F(0xA3745E1D28D1E3702D3F5F1E336A3F1A64F7F7Bn) ) ``` Where **F** is defined as follows: ``` F = n => // F is a helper function taking a BigInt n [...n + ''] // turn n into a list of digits .map(h = v => // h is a recursive callback; for each digit v: ( g = k => // g is a recursive function taking a divisor k: x % --k ? // decrement k; if k is not a divisor of x: g(k) // do recursive calls until it is : // else: k > 1 // return true if k > 1, i.e. x is composite )(++x) // initial call to g with k = x incremented || // if x is composite !d && v-- ? // or d is not set and v is not equal to 0: h(v) // do a recursive call to h : // else: p *= // multiply p by x ** BigInt( // the prime x raised to the power of d ? v : 1 // either v if d is set, or 1 otherwise ), // p = x = 1n // start with p = x = 1 ) && p // end of map(); return p ``` [Answer] # [Python 2](https://docs.python.org/2/), 1370 bytes ``` print 10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874897489950008250798014478066014893203193926076357920163707042852616942733354325378261468425502224936203089956427521668102778596882443702230532724374828028933960643144327285227754985461570358500265135333500954075465441985256254776102064625494398779453723330206306859677410408807692326906168737018862161148707729611012076342295413323680430446529763872458887191437347994063250920466184003173586602441075384748222102267773145003624260992372156354624662289026123081819214885321984526331716887191378907363723962768881646531494039722207338471537744184950666337656928147552391544567298663655079621129011773598162469141317639170063853667739680653118979048627652462235681893246541359880812508588104345141359691398313598202577424145658860334913269759048622492214169304247816441675958725602279911468750380291607080058491441201347157459047314438815796116358356171983789000270540329047696182295315977628397256525031861796294929740163865774776146472541890007191451515587790900275580657982495983198842069735835409348390389014043245596652434869311982404102985853034513631928339140603461069829946906350 ``` [Try it online!](https://tio.run/##HZRJTgRBDAS/whO8Lz@CCyDEhdcP4RZi1N1V5SUyXd9/v@9fn/Z6ff98fP6@qXiUlGunj3XnZuy4aWylzWyYp056qfHDnjtQvpLLgmiwYCYlGaOb3SETG5oSSrxe4ZegE60qMR1ls1Yrm6nO6vLZOTMr1Um0rAvVXZUrUhHZFEMi1@AEpVGVpmWkNGGNX/bl7esyl87O4oXcugT3dHXLSa3InPJOo@N28Z6RvA4jbi/10NxQ5ez9b4rIGHl2SBw9UsXDrANC1@lEupxkJkpgaQmbtNKiyHZyB6nJw6eoCcsUgMV6EUEuRbExTatGD9bk1oxFEM3oJt3aeImxEdi5L4oFMOJWSHa6we8QZYvTqNAHdPPyC6QDJgGhULYBGHbwJR2B7mXDd9ApqNQ4dAsudaWgKAIJnLrW/JSjuWmq05miboUHjbctj3JylIcZWdXdvAYJJEhvyONDMzkg1lW68kCnIBuQYYi30EJg2/QBazionDnjAJhRs1FT0z6dATFQYCmssQRC0A4xDE4gUPCNYib8PJgYiScQxwlPD08NSLPSWJvGt6z5PPik8AxYxLfP3yh5DgZPUxBuTYxAnK6Eymh04qlVEGdBgtK98nwDIbUVPb/lEpr69oyswFhtnOs3XzRFfvxFYsV9GHeunGQ/Nkjcca47FfUCDZ3BbGB5AxSpz3diI6U/W0zsBtICVsW@EvdgHQ0Z9Cc@RoRp4FYkMvxN67zdPYBQCX8GdPWs2ymOAVdxvIxIQgEPorf6oem4mP34kppuaJWRyKF2cFPUkcaZzV0hbre52DNnFde8ibc53hRLZ67DOfgtNTKNN19T19BZNyrYiBQX8vFSKn95Lpa9LDzL3QKM0uYhgVng6@2nppD1IB1NoU6AEF/C74CzABDVO8s9RtNgTq4LkuAU/DRMIYfqbkMl5hguvtFg3l6vfw "Python 2 – Try It Online") [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 33 bytes ``` 13r23×ȷ “Œɱl»ØaiⱮ⁵×¢+ÆnPD‘ÄÆNPDÆẸ ``` [Try it online!](https://tio.run/##AUAAv/9qZWxsef//MTNyMjPDl8i3CuKAnMWSybFswrvDmGFp4rGu4oG1w5fCoivDhm5QROKAmMOEw4ZOUETDhuG6uP// "Jelly – Try It Online") Full program, outputting to standard output. ## Explanation So, it turns out that at least in Jelly, it makes sense to go all the way through the process right from the start, rather than encoding the steps one at a time. ``` 13r23×ȷ r inclusive range from 13 23 13 to 23 ×ȷ multiply each element by 1000 (giving 13000, 14000, … 23000) ```   ``` “Œɱl»ØaiⱮ⁵×¢+ÆnPD‘ÄÆNPDÆẸ “Œɱl» "unsharpened" (specified via dictionary index) i take 1-based index of Ɱ each letter Øa in the lowercase alphabet × multiply each of those indexes by ⁵ 10 + add {corresponding elements of} ¢ the constant computed on the preceding line Æn take the next prime {above each element} P take the product D express as decimal digits ‘ increment each digit Ä take cumulative sum ÆN take the nth prime {for each element n} P take the product D express as decimal digits ÆẸ interpret as exponents of consecutive primes ``` Yes, turns out step 4 is actually a Jelly builtin! It's obvious that calculating steps 3 and 4, rather than hardcoding the result, gives savings; likewise for most of step 2 (the rule for encoding the offsets of 13000, 14000, etc. is fairly verbose but much smaller than the offsets themselves). My second-best attempt hardcodes the output just after the `⁵×` (the numbers are all under 250 so can be written as a byte each), but it's still slightly more verbose than starting from the start: ``` “Ż⁼ȦP½Ṇɦ2⁼2(‘ [210, 140, 190, 80, 10, 180, 160, 50, 140, 50, 40] “Œɱl»ØaiⱮ⁵× alphabet indexes of "unsharpened", times 10 ``` (Another possibility would be to use base conversion, but this ends up even longer because there's no terse way to specify the base, and you still need to spend two bytes for the multiplication by 10.) [Answer] # [Python 3.8](https://docs.python.org/3.8/), ~~207~~ \$\cdots\$ ~~192~~ 188 bytes Saved ~~3~~ 5 bytes thanks to [user202729](https://codegolf.stackexchange.com/users/69850/user202729)!!! Saved a byte thanks to the man himself [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)!!! ``` from math import* p=[n for n in range(2,1710)if perm(n-1)**2%n];i=s=1 for n in str(int("S87MGJSI5MYQMC8O1HDMTTI1EE4FWB",36)):i-=~int(n);s*=p[i] print(prod(p.pop(0)**int(b)for b in str(s))) ``` [Try it online!](https://tio.run/##Pc3LCoJAFIDhvU8xBMEcsWjsohSzqewGEqEQIS2KsmbhmcNxNm16dctFbX9@@OjlnhaHMXHTlGwrUV3cU5iKLDvfI12gKC0LFAYFX/Bxl2GgIjUAUwq6cyWxp8D3wy6eZ0bXWnn/vXYsDTrZyeIoXe@y7Tg9HdJFvFebZZrnW5Uko9Vx3gmGE4Cp6el3eyPMal9TYc4ecRuI7U1SnyzJwVdq0xVa5PpDagBomg8 "Python 3.8 (pre-release) – Try It Online") Prints the ginormous number by computing it starting with a slightly altered version of the huge number from the \$2^{\text{nd}}\$ step. [Answer] # [Python 2](https://docs.python.org/2/), 151 bytes This is two bytes shorter than my previous answer, thanks to an insight from [@xnor](https://codegolf.stackexchange.com/users/20260/xnor). ``` x=r=n=2 for c in" !NwXv\erA$x V }G_sTJBDRPR;V\!=[u,4 bzroe_:\0Ik X4;d.d":n=n<<7|ord(c) while n: x+=1 if~-2**x%x<2:r*=x**(n%10);n/=10 print r ``` [Try it online!](https://tio.run/##K6gsycjPM/r/v8K2yDbP1ogrLb9IIVkhM09JRtGvPKIsJrXIUaVCLkxYrtY9vjhEzMvJRSxIMEAyyDosRtE2ulTHhEmWNamqiDU/Nd4qxsAzm00hwsQ6RS9FySrPNs/GxrwmvyhFI1mTqzwjMydVIc@KS6FC29aQSyEzrU7XSEurQrXCxsiqSMu2QktLI0/V0EDTOk/f1tCAq6AoM69Eoej/fwA "Python 2 – Try It Online") Due to Python's verbosity, it seems best to directly use the number from the end of step 3, instead of computing it. Fermat's primality test can be used to calculate the primes. For some pseudoprime numbers (namely `561, 645, 341`) the test fails, in which `0` is used as the exponent instead. ### [Python 2](https://docs.python.org/2/), ~~158~~ 153 bytes *-2 bytes thanks to @ovs* *-3 bytes thanks to @Sisyphus* ``` a=b=r=n=1 for c in"c!U!u5uk^Cv m Ink~)3Ii0@45x: ja'eh?tMS mwPD QK%a":n=n*129+ord(c) while n: if a%b:r*=b**(n%10);n/=10 a*=b*b;b+=1 print r ``` [Try it online!](https://tio.run/##K6gsycjPM/r/P9E2ybbINs/WkCstv0ghWSEzTymZT5E1VLHUVKJUKDvOuUwul9szL7uunlXT2DPTwMHEtEJC3oo7i0kqkVU9NYPJvsRXNJg7tzzAhSfQWzVRySrPNk/L0MhSO78oRSNZk6s8IzMnVSHPikshM00hUTXJqkjLNklLSyNP1dBA0zpP39bQgEshESSWZJ2kDXRHQVFmXolC0f//AA "Python 2 – Try It Online") Primes are found using Wilson's theroem. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 36 bytes Only the first step is hardcoded. Thanks to [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen) for helping with this! ``` ∞<Ø•BIº£¡P°•₂вā12+т*+T*ÅNPS>ηO<ØPSmP ``` [Try it online!](https://tio.run/##yy9OTMpM/f//Ucc8m8MzHjUscvI8tOvQ4kMLAw5tAPIeNTVd2HSk0dBI@2KTlnaI1uFWv4Bgu3Pb/YGKA4JzA/7/BwA "05AB1E – Try It Online") **Commented:** ``` # step 1: •BIº£¡P°• # compressed integer 3044554559124550 ₂в # convert to base 26 digits # [21, 14, 19, 8, 1, 18, 16, 5, 14, 5, 4] # step 2: ā # get a range from 1 in the same length as the result from step 1 12+ # add 12 to each value т* # multiply by 100 + # add element-wise to the result of the first step T* # multiply each value by 10 ÅN # find the next prime P # take the product # step 3: S # split into digits > # increment each digits ηO # take the sum of each prefix of this list < # decrement every sum Ø # take the 0-based nth prime P # take the product of the primes # step 4: ∞ # push infinite list [1, 2, 3, ...] < # decrement each value Ø # take the 0-based nth prime ... # this list of primes is at the bottom of the stack during all other steps S # split the result of the third step into digits m # raise each prime to a digit power P # take the product ``` --- # [05AB1E](https://github.com/Adriandmen/05AB1E), 36 bytes The first 2.5 steps are hardcoded. ``` ∞<Ø•1‘;67₃в©¾ΛM„ØΩüñïΩ'ÿ•.¥āÌÌ+ØPSmP ``` [Try it online!](https://tio.run/##AUsAtP9vc2FiaWX//@KInjzDmOKAojHigJg7NjfigoPQssKpwr7Om03igJ7DmM6pw7zDscOvzqknw7/igKIuwqXEgcOMw4wrw5hQU21Q//8 "05AB1E – Try It Online") **Commented**: ``` ∞ # push infinite list: [1, 2, 3, ...] < # decrement each value Ø # for each number, get the 0-based nth prime: [2, 3, 5, ...] # this prime list will be needed in the last step •1...ÿ• # large compressed integer .¥ # take the cumulative sum of the digits ā # push a range of the same length: [1, 2, ..., length] ÌÌ # add 4 to each value: [4, 5, ..., length+4] + # add this element-wise to the cumulative sums # this results in the list from step 3 Ø # take the nth primes (0-based) P # take their product S # split into digits m # for each digit, raise a corresponding prime to this power P # take the product ``` [Answer] This first attempt is mildly golfed, but represents an authentic implementation of the spec. The final number is split into multiple lines, each terminated by `\` (as per normal `bc` output). If this is not acceptable, I can add a few more bytes to make it all one line. # [Bash](https://www.gnu.org/software/bash/) + common linux utils, 241 ``` m()(paste -sd* -|bc) r=primes printf 1$($r 1 1800|sed -nf <(for p in $(printf UNSHARPENED|od -An -w1 -td1|awk '{print 1000*NR+11360+$1*10}');do $r $p|sed 1q done|m|sed s/./\&+1+p/g|dc|sed s/$/p/)|m|sed 'N;s/\\\n//;s/./*%s^&/g') $($r 1 728)|m ``` [Try it online!](https://tio.run/##Lc5Bi8IwEAXge3/FHKJNWuJkdmEVqgdBwVNZFG9loTWtK0vT2BQ8GH97t5aehvf44E2Ru9@@r7ngNnddCdLpCKQvLiJoN7a91aULhmO6Cohx1gIBrZTyrtQgTQVrXjUtWLgZYHyC5/R02B6/9@l@55uBbQ3IB4HsNPn88Qfhc4RASqkoPcZEn18qZhSReoUi0U0w7DA7btA90I0pfT0mhwvM5jHFFq9eX6aOoUUxiTBNHGZZZhCTt45m7meO11DA9P3yYzXYvv8H "Bash – Try It Online") --- The above gives some good starting points to get golfing. Here we skip straight to step 3: # [Bash](https://www.gnu.org/software/bash/) + common linux utils, 186 ``` m()(paste -sd* -|bc) printf 1$(primes 1 1800|sed -nf <(sed s/./\&+1+p/g<<<58322536285290033985886806240808836417438318459|dc|sed s/$/p/)|m|sed 'N;s/\\\n//;s/./*%s^&/g') $(primes 1 728)|m ``` [Try it online!](https://tio.run/##TY47DoMwEAX7nMIFAQwi6w@GRXCGnMCKxD8pQChL6bs7kDTpZqSn0etaenq/xDzeWtpHltGQsMx1Pb9s79e6T0wG8UHLSEwyiUI4GgeWrRNr4pMIbmDDVKYbzE3TGNRKGV0oNKoSQusKDWKBolC5QIGoi1yWuUYtMTeVG3r3qwSwAXfL16J7TWCtXQHqs59c6RHCHHH296VUeOy9/wA "Bash – Try It Online") --- Skipping to step 4 is a little longer: # [Bash](https://www.gnu.org/software/bash/) + common linux utils, 191 ``` printf 1$(sed s/./*%s^\&/g<<<142994592871080776665367377010330975609342911590947493672510923980226345650368095529497306323265234451588273628492018413579702589) $(primes 1 728)|paste -sd* -|bc ``` [Try it online!](https://tio.run/##Dc45CsJQFEDRrfxCxQRi3jxAliKCQxwKJfhTuveY@p7iXs71uSzT9/WZ7wU3@zreSu0Pfbutp@OufwzDgEKZoknhCAHuZqZszu6AwAzpapC8MkRNSHHJtZMiJHEGEBmLmgJbQKpSSjqDMTGZEosoagQ5G4UkAYYgq6cDaWRTNvv18D3WgsUpmt90rvNYunprS/e7XJflDw "Bash – Try It Online") --- But the best seems to be representing the step 4 input as hex, and splitting (to work around dc/bc output length limits): # [Bash](https://www.gnu.org/software/bash/) + common linux utils, 177 ``` printf 1$(dc<<<16i15B99C0EC8211C220ED814252AE350B502C02270461072F62C9A4CCn8CDAF145DAB65AE8478B533CCF0F1E3364D943BA2D9FFA4E913Dn|sed s/./*%s^\&/g) $(primes 1 728)|paste -sd* -|bc ``` [Try it online!](https://tio.run/##Dc5LDoIwEADQq3SBRk2QmemHNmHTTttTGBMFVBYSYl1yd/Sd4N1v5bVty2eavw@B1WHou65DM6EOzjEktoTIRJCiRUWafJIaggZiIGpBGYSWsiF2XjHPlqPPqHT0wWifrGpt0FIyZ8iYpDQqOiWDp@hy9io5lHFeyziI0pyb065cL/vmeRTV4X96j0WgaMke1@VWvqOoy3AS9Xrvt@0H "Bash – Try It Online") [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 345 325 bytes -20 bytes thanks to mazzy!! This is a bit of a silly answer just for the fun of it. It could probably definitely be golfed further, but I got tired of fiddling with the numbers. This is derived from the prime factorization of the 1264-digit number. Effectively, I factorized the number, then broke the factors into groups based on how many times they occur in the factorization, then multiplied those groups into the largest numbers PowerShell will parse to cut down on '\*' characters. Not terribly exciting, but I was curious how far this method would cut the number down. ``` "$(echo 19805596543926073442 78873566720902235*18013318998359734663 593140350139852859*8104731785668783073 6644372255178073982360301 1353238597766773*12805823735079030233 6662348615646027385791148837 13372864637471*7423896006336743 14127919992957378413027 74874566303993533*2096862721178836784989|%{"[bigint]$_*"*++$i})1"|iex ``` [Try it online!](https://tio.run/##FY/dSgRRDINf5TCsoGdv2qa/zyIiKIM7sLiigoLrs4/1NsmXpm@Xr/X947Sez/u@HG7X59NlcCWZlZuixCmgKiMyA@YeQkUisMlJDHBWJaw65Y5hBVaCtVVpklYzmTTAkU1nJLpwuKsiRMxab6FS4ATiwTAImovoY4HJ0mva7usU1RnBP@8CTWdzdZJoIIpZMxFd0dXZBkKDZ2j3lRM54KEYrCydriopC0Qqd2uM0AztkSBU9QzM/tXTJYR7ZjadWlnXm5/l/ml72V4/Hw6Pc5nH42H7vePluq3f@/4H "PowerShell – Try It Online") [Answer] # [J](http://jsoftware.com/), 83 bytes ``` */(p:@i.@#^x:)"."0":*/p:<:+/\1x+"."0":4*/@p:((1e3*12+#\)+10*_64x+3&u:)'UNSHARPENED' ``` [Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/tfQ1CqwcMvUclOMqrDSV9JQMlKy09AusbKy09WMMK7QhIiZa@g4FVhoahqnGWoZG2soxmtqGBlrxZiYV2sZqpVaa6qF@wR6OQQGufq4u6v81uSwVrYzNFWKB9sSDMBdXanJGvkLafwA "J – Try It Online") This is just a straightforward translation of the steps in reverse. [Answer] # [Husk](https://github.com/barbuz/Husk), ~~54~~ 53 bytes ``` Πz`^İpdΠm!İptGo→+0dΠz(`ḟİp≥*10+*100)→½ḣ23mo-96c¨unẇṗ± ``` [Try it online!](https://tio.run/##yygtzv7//9yCqoS4IxsKUs4tyFUE0iXu@Y/aJmkbAPlVGgkPd8wHij3qXKplaKANxAaaQMlDex/uWGxknJuva2mWfGhFad7DXe0Pd04/tPH/fwA "Husk – Try It Online") Uses the complete method as described. *Step 1:* `mo-96c¨unẇṗ±` Subtract 96 from the character values of each letter in the compressed string `¨unẇṗ±` = 'unsharpened'. *Step 2:* `Πz(`ḟİp≥*10+*100)…13 23` Zip previous list with `13...23` by multiplying arg2 by 100, adding arg1, multiplying by 10, and getting the first prime greater-or-equal to this; then take the product. *Step 3:* `Πm!İptGo→+0d` Get decimal digits, and scan (sequentially apply function to each element and previous result, keeping intermediate results) by adding and incrementing; then get the primes at these indices and take the product. *Step 4:* `Πz`^İpd` Get decimal digits, zip with list of primes by taking exponent; then take the product. [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), ~~99~~ ~~83~~ 64 bytes ``` ≔…²⊗φθF⁴²≔⁻θ×θ⁺²ιθIΠEIΠE⁴⁷§θ⁺κΣ…”)¶↘…⊘¤|⟧≦?Lν~⊘θ¿nê₂ηYx”⊕κX§θκIι ``` [Try it online!](https://tio.run/##ZY/NasMwEITvfQqR0wpUUPTjrMkpOJccAqbtC6iykgjLUiLbSfv0rknTUuielo@Z2Vl7MtkmE6Zp0/f@GOHFxKMDwcg2je/BNXCglJELXT8dUiagBCUP5d7HsYcLI2@@c/elDjOYrZ7@eOrs4wCV6Qeoc2pGO8DenP8DtWJkM@xi4z5@g1pGXscOqk8bXHVKZ1holEJoWQjUouRcyhI1YoG8EIojR5SFWq6URLlEpcsFI7tos@tcHOZHWvqYOT/dXIY/B9sZ3kv5b8l6mqbna/gC "Charcoal – Try It Online") Link is to verbose version of code. Would take 570 bytes as a compressed string literal. Explanation: ``` ≔…²⊗φθF⁴²≔⁻θ×θ⁺²ιθ ``` Find all the primes below `2000` by multiplying the range from `2` to `2000` by all integers from `2` to `43` and taking the set difference. ``` IΠEIΠE⁴⁷§θ⁺κΣ…”)¶↘…⊘¤|⟧≦?Lν~⊘θ¿nê₂ηYx”⊕κX§θκIι ``` Add the digital sum of each nontrivial prefix of the compressed string literal to the current index and use that to index into the primes. Cast the product of those primes to string. For all of this string's digits, take the prime at that index and raise it to the power of that digit. Print the final product. Previous ~~99~~ 80-byte solution also performed steps 1 and 2. (I also tried step 4 only, but that took ~~103~~ 84 bytes.) ``` ≔…²⊗φθF⁴²≔⁻θ×θ⁺²ιθ≔IΠEUNSHARPENED⌊ΦEχ⁺λ⁺×⁺¹³κφ×⊕⌕αιχ⬤θ﹪λνηIΠEIΠEη§θ⁺κΣ…η⊕κX§θκIι ``` [Try it online!](https://tio.run/##ZY/NbsMgEITvfQqU0yJRKU57y8lyEjUHRyhpH4BiHCOvocG4P09PMXaiSOHCajU7841shJNWYAh53@uzgaMwZwUrRjZ2@ERVQU0pIxe6fqqtI/C6omRWltoMPVwYededSgPHuIinml5vZmkheg/c2WqQHkrxBYuPw@ktP/LtYbtZMBKtdDd0sNPolUuKbDn74fxPKWnMXhhpY0JNr@F7I53qlPEReKdNBSJRMJItaYLJEUfCMiKgHT0NnR4jTeTkThv/iPmwaKKT35tK/d76toycInrxJ1EVjU2ae5yW3pK4/Ynt7gzGEilDT5J1COH5G/8B "Charcoal – Try It Online") Link is to verbose version of code. Explanation: ``` ≔…²⊗φθF⁴²≔⁻θ×θ⁺²ιθ ``` Find all the primes below `2000` by multiplying the range from `2` to `2000` by all integers from `2` to `43` and taking the set difference. ``` ≔IΠEUNSHARPENED⌊ΦEχ⁺λ⁺×⁺¹³κφ×⊕⌕αιχ⬤θ﹪λνη ``` Take the word `UNSHARPENED` and look up the 1-indexed letter values, multiply by `10`, add `1000` times the 0-indexed position, and add the range `13000..13009`. Filter out any elements of that range that are divisible by any prime below `2000`, and take the minimum of the remainder. Multiply these together and cast the result to string. ``` IΠEIΠEη§θ⁺κΣ…η⊕κX§θκIι ``` For all the digits in the string, add the digital sum so far to the current index and use that to index into the primes. Cast the product of those primes to string. For all of this new string's digits, take the prime at that index and raise it to the power of that digit. Print the final product. [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~110~~ ~~108~~ 107 bytes ``` d=1##&@@(j=0;k=##2;Prime[j+=+k#+1]^k^#&)/@IntegerDigits@#& Print@d@d[36^^16yk3y2kcq6hc87t5gstghaesn1uqnv,1] ``` [Try it online!](https://tio.run/##DcpBC8IgFADge3/jwSgMyo0sGMI7dOnWfUwQFXWisPkK9uut7/xlTcFlTdHo1qzkAB3icZHXMUmAfnxvMbtpYZIlYHxWSUF3uuCrkPNue0YfqSJ0h/8rhBbtNAiluNjTsPfJrCKYx51uvpIP2tXCP2v5nvnc2g8 "Wolfram Language (Mathematica) – Try It Online") Starts from the result of step 2, `16yk3y2kcq6hc87t5gstghaesn1uqnv` in base 36. `d` performs both steps 3 and 4, depending on the presence or absence of a `1` as the second argument: ``` d=1##&@@( (* product of: *) j=0; (* (reset the counter) *) --- (with 1: k=1) Prime[j+=#+1]^1^#& (* primes, skipping over n at a time, *) --- (without 1: k=Sequence[]) Prime[j+=0#+1]^#& (* successive primes to the power of n *) --- )/@IntegerDigits@#& (* for each digit n of the first argument *) ``` [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 301 bytes ``` using C=System.Numerics.BigInteger;int i=-1,j,d=0;C u=new C(1);var z=Enumerable.Range(2,2000).Where(x=>{for(j=2;x%j>0&j++<x;);return x<j;}).ToList();var g="58322536285290033985886806240808836417438318459".Aggregate(u,(a,o)=>a*z[i+=o-47])+"";Write(z.Take(129).Aggregate(u,(a,b)=>a*C.Pow(b,g[d++]-48))); ``` [Try it online!](https://tio.run/##XdBNS8MwAMbxr1IKSmLbmCZtl5ploMWDICI62GHs0G0xprpEktTViV/d@nbz/PB7Dv@NzzZej2PvtVFRI@7ffJA7dNPvpNMbjy60ujJBKum4NiHSIsvTLt0KzJuoF0buowbkkL@2LjqIS/PD2vWzRHetURKQlGCMIVo8SifBIGbvD9aBThA@HHUzfNwlyXTgkDsZemeiYdrxD4jm9lr7AP5elYhLRgkpaUVYSWqMKa1ZyVjFcEUKzDBjtCrySUEZzVlR1jE6V8pJ1QYJ@hS0qYVi1p4cljoRNismK5jEMV84/b0f0Lx9kiAnNfyv1r@qQbd2D9apWm6TZJUVDELIx/HTvgRtjR9P3dm/ZF8 "C# (Visual C# Interactive Compiler) – Try It Online") Saved a byte thanks to ceilingcat [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 40 bytes ``` •3^—Ð7η¨Á∊δ¿x₅т«n¹L°;₄•11вÅ»+}ØPSDgÅpsmP ``` [Try it online!](https://tio.run/##AU0Asv9vc2FiaWX//@KAojNe4oCUw5A3zrfCqMOB4oiKzrTCv3jigoXRgsKrbsK5TMKwO@KChOKAojEx0LLDhcK7K33DmFBTRGfDhXBzbVD//w "05AB1E – Try It Online") ``` •...•11вÅ»+}ØPSDgÅpsmP # trimmed program P # push the product of... # (implicit) each element of... Åp # the first... g # length of... P D # the product of... Ø # the primes with indices in... Å» # cumulative... + # sums... Å» # to the right of... в # list of base... 11 # literal... в # digits of... •...• # 4693500063420580072723276169489497775909790306646... Åp # primes... m # to the power of... # (implicit) each element of... S # digits of... P s # the product of... Ø # the primes with indices in... Å» # cumulative... + # sums... Å» # to the right of... в # list of base... 11 # literal... в # digits of... •...• # 4693500063420580072723276169489497775909790306646 } # end cumulative operations # implicit output ``` [Answer] # [Haskell](https://www.haskell.org/), 139 bytes ``` t.zipWith(^)p.f.f$fromEnum<$>"آ\\maXyZ]k^d" f=map(read.pure).show.t.map(p!!).scanl1((+).(+1)) p=[x|x<-[2..],mod(-t[1..x-1])x==1] t=product ``` [Try it online!](https://tio.run/##JZTBbltHDEX3/ookyEJCqgdySM5w0si77gp02aJOAgh23BixZcVWULfo1/Sr@jV1D1UYFt57M0NeHl7O593jl0@3t8@Pq/3br@vt/u3jxdNfT@82X7@7u7968fRify4fvj87bB8v2rLwtN@@fz4uf94cfr45fl59XB@W6@X69fXD/d0P@293716fv/rn7/fv73a//PHrhy8fr16dXW/vdofVw6fd1XL49vBpvTx@vv99OS719fDyJe@Xu/2trlZv1svqja7XZ5vNYfu/iFPOErLaHC90WZ42@mH9tN2eHbeHh/urb5fH57vdzX5b0X/cn5/z9WZ/XFb77Xb9rGLepZuOsGxjxAyfaU199miZ05uFZljXxg976kC3KTFZEHUWWpMu4akzxnBJn64hrsQbU/glaPpQFc/hveVsfcqMUGN18tk4k1P6CKJFr1Bj9B5TpLvHQAyJTJ0TSEOVRgsPGYRt/LIvat/ozWTEiM4LuXUS3MLUWmRo94jsNqJR8TCxkSlRFbrXXvRQXKIyZ/3PEJFs5JlJYh8pvfOQ0wCh06hERjeSNVECyxBvGa1rR@QwcjupycMn7@ktQgDm0zoRpFJ0NkbT3lMLVsbsmc2daI1qwtpovHi2FNiZTTrmwPBaIVn1DX6FKIYYhQp1QDcqv0DaYeIQcmUbgGEHX9IRqF6m20z65ChtHKoFk15S6CgNEjiNPptV5yguB@o0s6Nb4UHho00epdrRzVsjq5o160kLxEnfaI8lxUSCWKdSlTl9crIBGYZ4i14IbAd1wBoOKmVOLwCtobmhaVA@lQHR6cBE2MASNIJyiNHgBAIFXypmws@JiWlxOs0xwlPDSQOtmTKwNoXP3gafE590PAMWsTnK33SyHAyegSDcGhiBOKMHVFJ9BJ6aCuLokEC69SjfQEjbFC2/xSQ0@mYZWYExdeBcq/miKPLjLxIr7sO4WXKC/dggcEe5rrqoFSipDGYJyxogDz19JzattNOWJq0GsjmsOvu6mDnr9JBBP8XHiDB13EqLGv6mdN7qHqBRAX8GdGpZd4QYBpyK4yVFAgp4kH6rFZrhFXOcfImmGlplJCLRDm5EFWmcObgrxFpt7uzJsopp1MS3LN6IpTLT5Bz8JhqZxpqv7FVQWde7s5FWVMiTl0L5i3KxzMrCs9QtwCjNKCQwc3w9x0mTyzQnHUXRHQchvoRfAWcBIKp1lnuMosEcXBckwSn4KZlCDvW6DZWY2XBxjQbz9u/l9e3ut8fnzeXh8Lz5qf0H "Haskell – Try It Online") (the code above times out on TIO, so the link points to a slightly more efficient version). ## How? ### ♣ Preliminaries `t=product` defines an alias for `product` (the builtin name is so long that even using it twice saves bytes). `p=[x|x<-[2..],mod(-t[1..x-1])x==1]` is the list of all prime numbers, courtesy of xnor's well known trick based on Wilson's theorem. ### ♣ Steps 1-2 ``` f$fromEnum<$>"آ\\maXyZ]k^d" f=map(read.pure).show.t.map(p!!).scanl1((+).(+1)) ``` We start from the unicode string `"آ\\maXyZ]k^d"` (actually all the characters but the first are printable ASCII characters), and we extract their code points in a list of integers thanks to `(fromEnum<$>)`. The result is the following list. ``` [1570,92,109,97,88,121,90,93,107,94,100] ``` What's special about this list? Let's see what happens when we pass it to the function `f`. * `scanl1((+).(+1))`\$\implies\$`[1570,1663,1773,1871,1960,2082,2173,2267,2375,2470,2571]`. Nope, still very mysterious. * `map(p!!)`\$\implies\$`[13217,14143,15193,16087,17011,18181,19163,20051,21143,22051,23041]`. Ah-ah! Indexing into the list of primes yields exactly the prime numbers described in step 2. * `t`\$\implies\$`58322536285290033985886806240808836417438318459`. We take the product. * `map(read.pure).show`\$\implies\$`[5,8,3,2,...,8,4,5,9]`. Finally, we get a list of the individual digits. This is definitely **not** the shortest way of obtaining this list. For instance, simply encoding the product in hexadecimal and then extracting the digits would require fewer bytes. However, having already defined the function `f`, performing step 3 is trivial. ### ♣ Step 3 ``` f ``` Don't believe it? Let's try applying `f` once more, this time starting from `[5,8,3,2,...,8,4,5,9]`. * `scanl1((+).(+1))`\$\implies\$`[5,14,18,21,...,245,250,256,266]`. As described in the problem statement, we count up from `0`, skipping `5` numbers, then `8` numbers, and so on. This list is different from the one described in the statement (each number is decremented by one) since our list of primes is 0-indexed. * `map(p!!)`\$\implies\$`[13,47,67,79,...,1559,1597,1621,1709]`. We index into the list of primes. * `map(read.pure).show.t`\$\implies\$`[1,4,2,9,...,2,5,8,9]`. Just as before, we compute the product and we split it into individual digits. ### ♣ Step 4 ``` t.zipWith(^)p ``` Step 4 is relatively boring. We raise each prime to the corresponding digit (`zipWith(^)p`) and we take the product (`t`). ### ♣ Output As expected, the output is ``` 10346063175382775954983214965288942351853612536382034663905935101461222060548195774084941504127779027795484711048746289269095513027910438498906751225648197766590064457965461314130149942152545074712074006545797623075756579902190433531325851645586375231773037880535184421903026638874897489950008250798014478066014893203193926076357920163707042852616942733354325378261468425502224936203089956427521668102778596882443702230532724374828028933960643144327285227754985461570358500265135333500954075465441985256254776102064625494398779453723330206306859677410408807692326906168737018862161148707729611012076342295413323680430446529763872458887191437347994063250920466184003173586602441075384748222102267773145003624260992372156354624662289026123081819214885321984526331716887191378907363723962768881646531494039722207338471537744184950666337656928147552391544567298663655079621129011773598162469141317639170063853667739680653118979048627652462235681893246541359880812508588104345141359691398313598202577424145658860334913269759048622492214169304247816441675958725602279911468750380291607080058491441201347157459047314438815796116358356171983789000270540329047696182295315977628397256525031861796294929740163865774776146472541890007191451515587790900275580657982495983198842069735835409348390389014043245596652434869311982404102985853034513631928339140603461069829946906350 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 39 bytes ``` ØaiⱮ“Œɱl»DŻ-.ịƊ€J+12Ɗ;"$V×⁵ÆnPD‘ÄÆNPDÆẸ ``` [Try it online!](https://tio.run/##AUoAtf9qZWxsef//w5hhaeKxruKAnMWSybFswrtExbstLuG7i8aK4oKsSisxMsaKOyIkVsOX4oG1w4ZuUETigJjDhMOGTlBEw4bhurj//w "Jelly – Try It Online") A direct translation of the specification. Compressing the output as a base-250 integer is 571 bytes: [Try it online!](https://tio.run/##HVMNT1NXGP4rIqsOFgYbG9lkKswxjRkfY1WJy5iTVZ2yIVE@ZraGy6e2ktE2oWVOEGlvM6XYltGecy/W5Ly3J/f2X7z3j7Dnktw0bc993@fz3I2Mj/9@dOTP/aP2vPIl36ixKI9S7ZNZ11T/qrcs51TWzbFcYPvpDFt/eYet3aryYY8qsqg6aZVnsTPKcofyl9iO4cskpTEbpsyP/Szn2V69y1aqkxKN@BXaHGFRYSuOmUEWWRZbAKSi825kShfec7M/KCAVgJwP6V1V1snzymzrY/uALalXJjHipcZU0a3qpE7cY7ntG2C4PqLesch9xNaLc30sliihc2S6e6ed9W9YrF6hLbZWdNJ988VXv6p9J91Byyx321i@htYP2HqiYyHX1IUelq8GvFSHk8YxW8nozzi7SWss073ONtDcKluChJdmsThzdRSyF6K/tDbXk4@8EjilulmuUO1jLO6HW2wtU7GLTGXCAdGpn7N81q1yXmnarV5uojRI26vqZT2lc/oxW9Dyn9qt2xfUwQ0oDrHcYPlSF2jle5yEMfyZm53t9Q2rCaF45ciQbwhaUfstQA3g5KIy32@BCXU7iEss3LymY1TCEhC6DqdoC@hmO1BpE2qoSAkWm9hy5jdMAeA2ArvBckkXnGIDf7z@jmq@cRh1q56JqbBvVC6CC7zWzymDHFVlGn7Xk59jeBgmDzixDp2406HKLJ6ejILZciMeUm8H1b5v2JS5PHP/Ebx4OOEbByiVHaNEEF0MHIZCYCMLnzrAXR4Duig7L/pgvthy3wSqQNWJeykPgta9Q7bjzSxr42zFLjZh0np83CwJUk6sNXx@WB2MTCAmL6Xy2mhjO4tHldXeWbRy28GSxVu0NoshtYN8sebesRvBR/VWP/h9eQIo8pWzDm@nqXj6FHhNnv26HSWQS83TJ0B7qEuVCW1szOOHm4dqlDcfcLVXI8fW1Q/h2Tlavh7wKg6Oqh3K6Aw0y2de@ULnsE6ioHjcLF6gxfsoHK2p/YhrNuIwBW5bpx60ILuunvCdMFUJF@bAiQfroACq9caZqWvHmezjctIaBVFZSTcH3HasizlpnfUNSZuqglFoUXvQG0UraJFFANL9LcqHN0dVFr2Z0ImfrmrD2Z5iMX9ci7@99ITa9UoP28Z6gxvwBJF46chA2yySwPGU3kB/5RwSPtmY1wmnBOw/H/ilvT/G/LmNo6P/AQ "Jelly – Try It Online") -6 bytes (indirectly) thanks to [ais523's answer](https://codegolf.stackexchange.com/a/218732/66833) [Answer] # [Julia 0.4](http://julialang.org/), ~~123~~ 129 bytes ``` show(prod(big(primes(727)).^digits(parse(BigInt,"sADsqNdwRYpd0LiTS4dgSvAP9BD2FkP9a9PLVt4ZGbbmxFCrkG4TEZI1ajJfYfdCycXNu6BN",62)))) ``` [Try it online!](https://tio.run/##xZTLbhVHEIb3fgxWtoSiunZXLVhwCYgIIRRQFFhEMjE4h3uwCcnTO18dKc8QH3k0M91d9ddXf827bx8O5zc3V398/n765evni9PXh0tuDh/fXJ1u22dnP/x2cbg8XF@dfjn/evXm9N7h8vGn69u3ru4@uPrz6cX3n19@uZAnhxfP4@Ly@V93n/W9B/bw/bM@72dPfrmOV49ev/7498P7X98/ihc/vnqs5@9@evvy7cX9f37/9em3de/prdvLzvi7Ieen6w@fTs9O/rs7@R/1nNy5c6LisWS57vSyvbMzutw0eqVVdZinVvpS48KeObC8JZsF0WDBTJZklHbuHVLRoSmhxNstXAlasVUlaseyalstnanOavPaOVMtayfRck2ovdfKFlkRuRFDItfgBNJQpWkZKZuwxpV9Ofv2MpedOxcP5NYmuKerW1bqisxavtOoeLv4rpKcCiNmL3oorlBZPf@dIlJGni4Sxy5Zi5tqB4S2U4ns5SQzUQLLlrBKW7oQuZ3cQWry8CpWhWUKwKJ9EUEmxWJjmq5VOrAqe1VZBNGMatJtGw9RVgI796ZjAYyYFZJN3@A3iHKLU6hQB3Rz8gukAyYBoVC2ARh28CUdgeahw7voU6DUODQLLmuk0FEaJHDaq82ncxRXG3VatdCt8KDwbc2tTDuWhxlZ1d18FS2QIL3RHi@KyQKxtlKVB30KsgEZhniLXghsN3XAGg4qY84YAGZoNjRtyqcyIAYdaIRtLEEjKIcYBicQKPhKMRN@LkxMiytojhOeGo4aaE3LxtoU3ss2rwufLDwDFvHe4286OQ4Gz0YQbk2MQJy9EiqlsRNPtYI4FySQ7ivHNxBSa9HxWzah0ddjZAVG68a5PvNFUeTHXyRW3Idxa@Qk@7FB4o5x3XRRJ1BRGcwKljNAkXp8T2xa6cctJjYDaQGrxb4l7sE6PWTQj/ExIkwDt9Iiw9@UztN8B2hUwp8BbR3r7hTHgK04XkokoYAH6bf6oNkxMffRl2iaoVVGIgvt4EbUkMaZm2@FuM3mxZ4aq7jmTLzV8EYslbkW5@DXaGQaZ75qTUFj3VjBRloxIY9eSuWX42LpycK9zFeAUeocJDALfN37qCmkPUhHUXQnQIgv4TfAWQCI6pzlO0bRYE4@FyTBKfipmEIOrfkaKjHLcPGMBvN2dvMv "Julia 0.4 – Try It Online") I'm using Julia 0.4 because `primes` was a built-in function in this version. It would be nearly identical with a modern version of Julia and the package `Primes.jl` Starting at step 4 but with the reversed number in base 62: ``` 985207975314810294826372885154432562323603794925590863056543622089329015276394749095119243906579033010773763566677080178295499241 ``` [Answer] # [Python 3.7](https://docs.python.org/3.7/), 240 174 bytes ``` p=str(int('3ged5xs20knlms4j3eaoxfzn5wdy54rml7sjp9f2pdhuoqdmky310zhxpta29r51libwivktdzfdpr2lcn1',36)) d=0 n=W=o=1 exec('W*=n;n+=1\nif~-n==W%n:o*=n**int(p[d]);d+=1\n'*726) print(o) ``` --- Original 240 byte answer: ``` p='142994592871080776665367377010330975609342911590947493672510923980226345650368095529497306323265234451588273628492018413579702589' d=0 n=2 W=1 o=1 while n<728: W=W*(n-1) if W%n==n-1: o=o*n**int(p[d]) d=d+1 n=n+1 print(o) ``` [Answer] # [bc](https://www.gnu.org/software/bc/manual/html_mono/bc.html) 1.07, 147 bytes I haven't found any documentation on this version, but it seems to allow input bases of up to `36`. ``` ibase=36 i=r=p=1 for(c=NT35WE2NF68SLMVUQIHDYNG22V9938091UQB6B4RLISCQDMPA9EPP1AVLANPVVX0J0DWW68XTA7C93PC8A1;c;p*=i*i){if(p%++i){r*=i^(c%A);c/=A}} r ``` [Try it online!](https://tio.run/##DcjNDoIgAADgO@/h5s8hkSKY44A/lc0YpqJd2pLlxilHx@azk7dv36SdM9Pr@2YIA8MsWxgE88f6mokOHYYyESdM2vqm@qa6FA9xThJFKSIxhX2T4Wx/r6s2b4qb5LSUEnJVcyGVGuNrXAwDJmPHjzlFMiccpjpdQmZCE/zM7C9eFG2y2zx97fEg1TvG1xVY4Nwf "bc – Try It Online") The primes are generated using Wilson's theorem. **Ungolfed**: ``` # all literals are in base 36 ibase = 36 # the result is calculated in r r = 1 # i is the current prime candidate, p=factorial(i-1)^2 i = p = 1 # c is the result of step 3 with reversed digits c = NT35WE2NF68SLMVUQIHDYNG22V9938091UQB6B4RLISCQDMPA9EPP1AVLANPVVX0J0DWW68XTA7C93PC8A1 while(c) { # until c is 0: if(p % ++i){ # (increment i) if i is a prime r *= i^(c%A) # take i to the power of the last digit of c and multiply to r c /= A # remove the last digit from c } p *= i*i # update the squared factorial } r # print the result ``` [Answer] # [Pyth](https://github.com/isaacg1/pyth), ~~95~~ 94 bytes ``` *Fm^hdsedC,.fP_Z129)`i."0z–Œ9í¶&¸¨÷)j3 &龃~ƒà‘œ\BŒ,5ß@XHZ~õÎòF23U÷_e”’@ä׋߭²j½¾"36 ``` [Try it online!](https://tio.run/##AYYAef9weXRo//8qRm1eaGRzZWRDLC5mUF9aMTI5KWBpLiIwegHClsKMOcOtCMK2JsK4wqjDtylqMyAmw6kPwr4UwoN@woPDoMKRwpwUFVxCwowCLDXDn0BYSFp@w7XCj8OOw7JGMsKQM1XDt19lwpTCkkDDpMOXH8KLw5/CrcKyasK9wr4iMzb//w "Pyth – Try It Online") Starts with the number at the end of step 3. Explanation: ``` *F # multiply all elements of m # map ^hdsed # first element to the str(last element) power # over C, # zip .f 129) # first 129 P_Z # primes # with ."0...¾" # packed string i 36 # convert from base 36 to int ` # convert to string # (i.e. each prime with each char) ``` [Answer] # Deadfish~, 5368 bytes ``` {{i}ddddd}dcdciiiciciicddddddciiiiiicdddcddciiiiiicddcddciiiiicddddddciiiiiccddciiiicddddcdciiiiicdcdddddcdcdciiiciiiiicdddcdcdddciiiiiiccicdddddcddciciicddddc{i}dddcdddcddciiicdddddciciiicddciiicdddciiiiicddddddcddciiiciciiccdddciiiiiic{d}iciiiiiciiiicddddddciicddddcdciciiiciicdddddcicccddciiiiiicddddddciiiiicdciiiic{d}iiic{i}ddcddddciiccdddcddddc{i}ddcddddciiiiicdddddcdddciiiicdddddciiiicdddciciiiiiccciic{d}iciiciiiiicciicddddcdciiiicddddciiicddddddccdciiiiciiiicdcdddciicddddciiiiiicic{d}iiiciiiiciiic{d}ic{i}dcddddccddddciicdddciiciiiiiciic{d}iicdciiiicdciiiiicddddciiiiicdcic{d}iciiiiiicicddcddddcicciiicicddciiiic{d}iiic{i}ddcddccdccdciiiic{d}icciiiiiicddcciciiciicdddcdcdciicdddddciicddciiicdddciicdddciciiiciiiiiccdddddcddcdciiiicdddciiicdcicdddddc{i}dddcdddciiicddddddcicddc{i}dddcdddcddddcciiiiiicdcdciciiciicddcdcddddcicdddc{i}dddcddciicddcicdciiciicc{d}iciicdc{i}ddc{d}iciiiicdcciicddcddciicdciiiciiicdddcddddciiiiicddcicciiicddcdddciiiicddcdddcicddciiiiiiccddddcdddciiiciiiicicc{d}iiciiiiicddciicddddc{i}dddcddddccddcdc{i}ddc{d}iciiicdddciiciiiiccdddciiiiiccdcdddciiiicicddcdddciiiiciccddddcdddddccc{i}ddcddddddciiicdddddc{i}dddciicdc{d}iiciciiicciiicic{d}iiciiiiiiccddddddciciiiciiiicicddddddcdcddciiicddc{i}ddcddddddciiiiiic{d}iiiciiiicddddddc{i}dddcdcdddciiciiciic{d}iiicddciciiiiicdddciiiic{d}iiic{i}dddc{d}iiiciiiicddciiiiiicdddcdddciiiicdddddciiiiiciiicdddddcddciiiiicddddccciicdcdcdciiicddciiiicicddddddciiiicdddddciiiciiciicddddcddciiiccdddddciiccciiciiiiicddddddciiicddddcddciiicdddc{i}ddciccddddcicddcddciiiiicddcdddcdciiiiicciic{d}iiicdciiciiiiiccicdddciiiicdddciiccddddddciiccdciiiic{d}iiiciiccicdddciiiiicddcdciiiiicdddddciicdciiiicdddciiiicddddddciiiiiic{d}iiciiciiiiiicicddddddcciiiiiicdddcddddddciiiiiicddcdcddciiiccdcdciiiiicdddddciiiiiicdddcdddcciiiiiccddcdciiiiicdcdddcdciicdddddciiiiciic{d}iiiciiiciiciiicdddcdddddcciiciiiicdcddddciiciicddccciicdddddcc{i}dcddddcdcddddc{i}dddcddcdciicdcdccdddc{i}ddcdcdddcdddciiicicddddciiicdciiiccdcdddddcdciicddciiiiiicddciicddddciiicdciiiiicdddddcdciiiiiicdcdcciicdddddcicddciiiicdddddcicccdddciicddciiiiiicdddcdddciiiiiiciicdddciiiicdddciccdddcdddcdciiiicddddc{i}ddcc{d}iic{i}dddcdciiic{d}iiicicdciiiiciiic{d}iciiiiiicdddddciiiiiciicdcddddciiiic{d}iiicic{i}dddccddcddddcdciiiiicdddddcciiiciiiicdc{d}iiic{i}dddccdddddc{i}dddcdddcdddddccdcicicddc{i}dddcdcdddcicddcc{i}dddcddddcdcdddciiccdciciiiciic{d}iiciiiicdcdddciiiicciicdcdddc{i}dddcddcdcdddciiiiicdcdddddciiciciiicccdcddddddc{i}ddc{d}iiciiicdciiiicddddciciiiciiccdddddcddddciiiiiicdddcdciiicdddddc{i}dc{d}iiicddciiiiciiccdddddc{i}dddcddddcddddcciiicddciiiiiicddddciiciiicddccddddddciiciiccdddcdc{i}dddcddcddciiiiicddddciiicdddciiiicddddddcccdcdciicciiiicicccddddcddciiicicdddddcciiiciiicddddciicddciiiicddddddc{i}dcc{d}iiiciciiiicdddddcdciiiicicdddciicdciicddddciiciiccddddcciiiiiicic{d}iciiciiiicdddddcicicdddc{i}ddc{d}iiic{i}dddc{d}iiic{i}ddc{d}iiicdciiiciiiiccdddcddcdcdc{i}ddcdcddddcicdddciiiicdddccddciiiiiicddddddciiiiiciiccdcddddddc{i}ddc{d}iiciiciiiicicic{d}ic{i}dddcddddciiicdddciiiicdddddciciiiiiicdddcddddciiiiicdciiccc{d}iiiciiiiicddciicdcddcddciiiciiiiicdddddcddddciiiciiiiiicddcdddddcccddc{i}dddcddddcciiiiicddddciiicddddddciiiicddciiiiccdddccdddc{i}dddcddddciiiiicddddcdddddciiiiiicccdddcciiiicdcdciciiic{d}iiiciiiiiic{d}iiiciiiciiicddccdddciciiiiiic{d}iiciiiicdccicicicdddddc{i}dddcdcddccdddciiicdccdddddc{i}dddciicdddcddddcdccic{i}dddc{d}icicciiiiiiccddddciiciiiicdc{d}iiiciiiiicddddciiciiciiic{d}iiciiicdddciicddciiiiiicdcdddciiiiiic{d}iiciiiiiic{d}iiicciiiiiicdddciiiiicdddcddciiicciccddddciiiiiicdddciic{d}iiciiiiiicdcddcddcc{i}dddcicddciic{d}iciiiiciiiicddcddddciiiiicdcdcdddciiciicddddcciciiciciic{d}iiic{i}dddcicddddddcdciiciicdcdcdddciiciiciiiicdcc{d}iic{i}ddc{d}iiiciciiicdddddc{i}ddcdddciiicc{d}iiicdciiiicdcicicddddciiicdddciiciiciiiicdddciiic{d}iiciiciiiiiicdcdddddcddciiciiciiiicdcddddddcddciiciiiciiccdddcddciicdddciiicicicdciiiccddcddddddciiicciciiiiic{d}iiciicdciiiiciiicddcddciiiic{d}iciiiiciiiicddcddddcciiciiiiic{d}iiiccdciiicdddciiiiiciiicddddddcdddciiiicddciiciiicic{d}iiiciiiiicddccdddciiiiicicddciiiicddddciiicdcdddddciiicicddddddciicciiiiiciicc{d}iicciiiciiciicdcddcdddddciiiciiiiic{d}iiciic{i}dddc{d}iiciiiiicddddddc{i}dddc{d}iiic{i}ddc{d}iicciiiiiciiicddddciiiiic{d}iiciiiccdddcicddciciiciciiicddddddciiiiciicdddciciiiic{d}iciiiiciiicddddcddciiiccdciiiiicc{d}iiiciiiiciiciicdddcdddddcciiiiicdddciiciiicdddddciicicdddddciiiiiicddddddc{i}ddcdcdddddciiiicicic{d}iccciiciiiiic{d}iiiciiiiicdcddddciiicdc{i}dddc{d}iciiiiciiicdciiicdddcdddddc{i}dddcddddddcc{i}dddcddddcddcddciiiiciiiicddccdcddddciiiiiicdddddciiiiiicddcdddddciiicicdcdddciiicdddddciiicddc{i}dddcddcdddddciiiiiiciicdddcddddc{i}dddcdddddciiiiic{d}iiic{i}dddcddcdddcddddciciiiiicdddciiiiicddcdciiccdddciiiccdcdddddciiiciicddciiicdddddciiicdcdddc{i}dddcic{d}iccc{i}dddcddddddc{i}ddc{d}iiciiicicddddciiiicddddciiiicciiicdcciic{d}ic{i}dc{d}icciiciiiiicddcciiic{d}iiciiiiiicdciiciicdcddddddciiciiiiicddddciiiicdcdddddcddc{i}ddcdccddddcddcddciiiiiiciiicddcddddciiciiicdddddciicdcddddc{i}dcddddddciciiiicdddddciiiiiic{d}iciiiciiiiicic{d}iciciiicddddciiiicdcdciicicciiiicdddccdcdddciicdciciiiicddciiicddddddcddcc{i}ddcdcddddddciicddddciiiicdddcdciic{i}dddcdcdddciiicdddcddcdddciiicicicddddciiciiicdddcddc{i}ddc{d}iiiciiiiiicdddddcciiiiiic{d}iiciiicddddciiiiiicddddddciiiciciicdddddcdciiiiiiciiicdcddddddc{i}dddccdddddciiciiic{d}iciiiiiicdddciicdddddc ``` [Answer] # [Bubblegum](https://esolangs.org/wiki/Bubblegum), 606 Generated with `zopfli --i1000 --deflate -c ginormous.txt | xxd`. I honestly thought bubblegum might do a bit better than this, but here it is: ``` 0000000: 1d4e 0711 c030 08b4 04bf 00ff c67a 6976 .N...0.......ziv 00000010: e057 1795 0a7b ccc5 8ccf ba25 5a17 63f7 .W...{.....%Z.c. 00000020: 04ba d74c c30c 1745 25bc f2d1 5dad 3480 ...L...E%...].4. 00000030: 4a59 dbe7 19d5 ead4 2e35 66e6 0a33 67ad JY.......5f..3g. 00000040: a6bb b4a3 600f b93a bb59 98eb 1257 b757 ....`..:.Y...W.W 00000050: 1937 e03c a999 c457 15c9 73b1 d26c 35ab .7.<...W..s..l5. 00000060: 7527 b461 b946 d3a8 5155 fc70 13b0 c6e3 u'.a.F..QU.p.... 00000070: 78ee 0a7d 25d2 6cc2 eb8e ec0d c760 cfb0 x..}%.l......`.. 00000080: 38bb 65ba 577a 5816 12ee 8ef6 de3e 57d5 8.e.WzX......>W. 00000090: c235 b7d5 d26c 25d5 da23 8a7d 3ca4 26f4 .5...l%..#.}<.&. 000000a0: 1caa c3a9 2961 8d74 4e18 9216 61ce 22ad ....)a.tN...a.". 000000b0: ac60 1700 1d83 623d 8b08 6374 b25d 9859 .`....b=..ct.].Y 000000c0: 5f76 2171 0a60 9918 88a3 c516 f6c8 4b45 _v!q.`........KE 000000d0: 6ce9 75d6 c08c 756b a53d 45af ab10 37fd l.u...uk.=E...7. 000000e0: fcab ceaa b162 a96f 0d07 d64c ba50 5160 .....b.o...L.PQ` 000000f0: 9d78 3b73 3207 245f 8395 f565 465d aadd .x;s2.$_...eF].. 00000100: 9a1c 885c a5b3 c3a9 de0d 3add daa9 195c ...\......:....\ 00000110: baab 5113 0a38 ab49 305b 6249 316e c21d ..Q..8.I0[bI1n.. 00000120: c8bb 3b7d 2d0e 3577 aa10 ae43 29e9 5515 ..;}-.5w...C).U. 00000130: 7be8 4d0a 52d7 98ab d102 e802 3233 6cb9 {.M.R.......23l. 00000140: 8a81 90ba 0307 edd0 0a94 007b 8534 58db ...........{.4X. 00000150: db87 d6ae 89be 9511 b2a7 f367 68ce 5e0d ...........gh.^. 00000160: c301 2f98 ec6e 4731 5ba7 e20d 801a 7235 ../..nG1[.....r5 00000170: 6dce 48bd 3a57 1272 e21c b635 3678 6dc9 m.H.:W.r...56xm. 00000180: 19dc 268c 5d73 4137 aeba 67e8 db0e 946b ..&.]sA7..g....k 00000190: 357b c2eb a90a d74c 6678 d97a c6bd 3757 5{.....Lfx.z..7W 000001a0: da60 6228 009d ed3d 42b1 fa09 6d6d c3b5 .`b(...=B...mm.. 000001b0: deed 12e5 feeb b9e6 2d7f 080a 9e11 d472 ........-......r 000001c0: bc9b 2275 4de4 c6bf 3ea0 035a 9d63 099a .."uM...>..Z.c.. 000001d0: ed48 9df1 7907 4e01 73d7 adec b8b8 85eb .H..y.N.s....... 000001e0: d4d4 5679 752d 35aa a969 8f9e e6b0 25ee ..Vyu-5..i....%. 000001f0: b6e7 d21d 7ae9 f4f4 2d67 afaa 3065 15f1 ....z...-g..0e.. 00000200: c0b9 f402 67b6 6f26 58de b335 5cec 4dcf ....g.o&X..5\.M. 00000210: 05a7 c38d aac3 8d67 3493 5634 b0fa 979c .......g4.V4.... 00000220: be96 db6d efcc d53d 177b 2b9e 5be8 7ccb ...m...=.{+.[.|. 00000230: be5d a172 f367 521d b5bc e25e b54a 84ec .].r.gR....^.J.. 00000240: 4b0c 519b 63f7 e396 ba70 eb35 8b72 33ec K.Q.c....p.5.r3. 00000250: c392 d7aa 1495 aedc e24e b90a 5d1f .........N..]. ``` [Try it online!](https://tio.run/##TVb7bxZVFPzdv@KIghLD8b4fBUzUgLwjJlgQCr2vrYQWsKVYWvnb65z9dqubdPs1/e7s3Dkzc7ce17o/9o4Pzs/V5toi3d0gFbWmpqwilaoj5epESk0TtRALhRwDET9iZsWb6/T1xy82CBoYQ/lIOmZPqsRKrTVPqbWJajGefNGRgp0iMLax9mxGuPwHN14wDDDwzEI9ukbNqgY058n42mgyXZPvpZN1SQGD@QF@bl3GbYfdimGB4YrP1OsAmdw9jdIdmWE9hTACuFlL2E8nuvds2YefmO3eiuGAUUKtVF3BV6EA1WwL1QrcnEYlbbDTGn2cefAu8xYL1jZvLxheNM02QhTbqOScqTmRx7dM0VZN3YRG1pcKjMg35tV8xLzvVx4BGNEbPMkFDQouULclkdfe09SiIm2rwnCGJTr@hgvfZn78hN8LpwUjCkYa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y5SH9MbpD7/VJU8zwmBsYdbRwbOkDw0kVleSHaHqH@RMO7qOFz4Ih/dEdDkcfohSR6XIeFSmRTGnKOCACjgXjUfPg8fun42so5tfzsb1iSH/UgKO2SzJjQb4mhw43HRYtE9CsQoloD5azHqeiB0arxsrDSH80VWUl8hViRZFPJkhABlULj/mGDbmOV4kZY4/fXcEJ418gfwuG9Ify8HWzSeqq4VQRCtZli/0hblVNEDbmdjGXPce/u//0MNIfdWQcZxU2GFNr1KWOdYTvDMaM5MCssbVNbg/EH3z2HT/nf1YMO2NIY2o4YA6qF2WqvMMMSIlPrlByQ3jsICt7c4O85HsXPKQ/XMXbj9cwyfzKNCxoIbYKBzf0SBXg1grGfXRhE4T3ODUP7Yrh5@xng5RgBtqhzcvoQgHveVXi47uGnPN10R6P5F3q/Pxf "Bubblegum – Try It Online") [Answer] # Python 3, 349 bytes ``` eval(eval('"19805596543926073442*"+"78873566720902235*18013318998359734663*"*2+"593140350139852859*8104731785668783073*"*3+"6644372255178073982360301*"*4+"1353238597766773*12805823735079030233*"*5+"6662348615646027385791148837*"*6+"13372864637471*7423896006336743*"*7+"14127919992957378413027*"*8+"74874566303993533*2096862721178836784989*"*9+"1"')) ``` Fork of @ZaelinGoodman's powershell solution ]
[Question] [ Write a program or function that takes in a positive integer (via stdin, command line, or function arg) and prints or returns a string of that many of these small triangles tiled together, alternating which way they point: ``` /\ /__\ ``` This sole triangle is the output if the input is `1`. If the input is `2`, the output is ``` ____ /\ / /__\/ ``` If the input is `3`, the output is ``` ____ /\ /\ /__\/__\ ``` If the input is `4`, the output is ``` ________ /\ /\ / /__\/__\/ ``` And so on. Your program must support inputs up to 216 - 1 = 65535. **Details** * The leftmost triangle always points upwards. * There may be trailing spaces but there may not be unnecessary leading spaces. * There may be an optional trailing newline. * Note that for `1` the output is two lines long but otherwise it's three. This is required. * The shortest submission [in bytes](https://mothereff.in/byte-counter) wins. [Answer] # Pyth, ~~44~~ 42 ``` ItQpdd*\_*4/Q2)jbms<*dQhQ,c" /\ "2,\/"__\\ ``` The first line: ``` ItQpdd*\_*4/Q2) ItQ ) If the input is not 1 pdd Print two spaces *\_*4/Q2 Then groups of 4 underscores, repeated input/2 times. ``` The other two lines are generated by noticing that the second line consists of `" /"` and `"\ "` alternating input + 1 times, and the third line consists of `"/"` and `"__\"` alternated in the same fashion. [Answer] # SQL, ~~182~~ ~~175~~ ~~173~~ 187 bytes Not that this'll ever be the shortest, but it's still amusing to try to minimize sql ;) lol I did this in Oracle 11, however, these should be basic SQL. [edit] as pointed out, I didn't apply the when input = 1 rule - only show 2 lines. can't think of a better way to do it, however, I did save a couple bytes by modifying the v logic ;) adding 2 ahead of time saves a couple bytes by not having to repeat it later [/edit] ``` select decode(&i,1,'',rpad(' ',v,'____')||z)||rpad(' /',v,'\ /')||decode(y,1,'\')||z||rpad('/',v-1,'__\/')||decode(y,1,'__\')from(select 2+floor(&i/2)*4v,mod(&i,2)y,chr(10)z from dual); ``` [edit1] removed some unnecessary spaces[/edit1] [edit2] changed &&i to just &i. It cuts down 2 chars, but forces user to input the # of triangles twice ... :P I realized my "good coding habits" using &&i were costing be 2 bytes!! The horror!! [/edit2] **Explanation** (note: I use &&1 in this explanation so it only prompts once, the &1 above saves code space, but prompts multiple times ;) ) ``` select -- line 1 decode(&&1,1,'', -- don't need line 1 if input is 1 rpad(' ',v,'____') || z ) || -- every pair of triangles -- line 2 rpad(' /',v,'\ /') || -- every pair of triangles decode(y,1,'\') || z || -- add the final triangle, input: 1,3,5 etc. -- line 3 rpad('/',v-1,'__\/') || -- every pair of triangles decode(y,1,'__\') -- add the final triangle, input: 1,3,5 etc. from (select 2+floor(&&i/2)*4 v, -- common multiplier. 4 extra chars for every triangle pair mod(&&i,2) y, -- Flag for the final triangle (odd inputs, 1,3,5, etc) chr(10) z -- CR, here to save space. from dual); ``` **Output** ``` SQL> accept i 1 SQL> / /\ /__\ SQL> accept i 2 SQL> / ____ /\ / /__\/ SQL> accept i 3 SQL> / ____ /\ /\ /__\/__\ SQL> accept i 12 SQL> / ________________________ /\ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/__\/ SQL> ``` [Answer] # Python 2, ~~89~~ ~~88~~ ~~87~~ ~~85~~ 83 named / 81 unnamed ``` f=lambda n:1%n*(" "+n/2*4*"_"+"\n")+(" /\ "*n)[:2+2*n]+"\n"+("/__\\"*n)[:n-~n+n%2] ``` *(Thanks to @orlp for a byte, and @xnor for another three)* This is a function which takes in an int `n` and returns the triangles as a string using the row-by-row approach. e.g. `print f(10)` gives ``` ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ ``` For the first row, instead of `(n>1)*` we use `1%n*`, since `1%n` is 0 if `n == 1` and 1 if `n > 1`. [Answer] # JavaScript (ES6), 101 ~~109~~ Way too long ``` f=(n,z=a=>a.repeat(n/2))=>(n>1?' '+z('____')+'\n ':' ')+z('/\\ ',w=' /'[++n&1]+'\n')+w+z('/__\\')+w ``` **Explanation** Using fat arrow for function definition. Moreover no `{}` block: the function body is a single expression that is the return value. `f=(a,b,c)=>expr` is equivalent to ``` function f(a,b,c) { return expr; } ``` Inside a single expression you can not use statements like `if` or `var`, but * parameters with default values can be used as local variables * conditional expressions `?:` work well instead of `if else` * you can add more subexpressions using the comma operator or even better as unused parameter to functions. In this case the assignment of `w` is the second (unused) parameter to the function `z` We can rewrite the `f` function as ``` f = function(n) { var z = function(a) { // use current value of n (that changes) return a.repeat(n/2); }; var result; if (n > 1) { result = ' ' + z('____') + '\n '; // top row if more than 1 triangle else result = ' '; // else just the blank ++n; // increase n, so invert even/odd w = ' /'[n&1]+'\n'; // blank if n is now even, else '/' if n is now odd // the next rows will end in "/\" or "\ /" based on n even/odd result += z('/\\ ') + w; // offset by the blank char added before result += z('/__\\') + w; return result; } ``` **Test** in Firefox/FireBug console ``` console.log(f(1),f(2),f(3),f(4),f(9)) ``` *Output* ``` /\ /__\ ____ /\ / /__\/ ____ /\ /\ /__\/__\ ________ /\ /\ / /__\/__\/ ________________ /\ /\ /\ /\ /\ /__\/__\/__\/__\/__\ ``` [Answer] # CJam, ~~55~~ ~~53~~ 51 bytes ``` SSri:I2/4*'_*N]I1>*" /\ "I*I)2*<N"/__\\"I*I2*)I2%+< ``` I tried porting my [Python answer](https://codegolf.stackexchange.com/a/48113/21487) and it turned out to be shorter than the other CJams. [Permalink](http://cjam.aditsu.net/#code=SSri%3AI2%2F4*'_*N%5DI1%3E*%22%20%2F%5C%20%22I*I%292*%3CN%22%2F__%5C%5C%22I*I2*%29I2%25%2B%3C&input=10). [Answer] # Haskell ~~155~~ ~~153~~ ~~139~~ 131 Bytes I found a slightly different approach that turned out to be shorter than my original method. My original attempt is preserved below. As with before, golfing tips are appreciated. ``` m n=unlines.dropWhile(==" ").z[" "," /","/"].foldr1 z$map t[1..n] t n|odd n=["","\\","__\\"] t _=["____"," /","/"] z=zipWith(++) ``` Thanks to Nimi for the golfing tips. --- # Previous Attempt ~~197~~ 179 Bytes ``` t n=putStr.unlines.dropWhile(all(==' ')).z(flip(++))(if odd n then["","\\","__\\"]else repeat"").z(++)[" "," /","/"].map(take(4*div n 2).cycle)$["____","\\ /","__\\/"] z=zipWith ``` [Answer] # CJam, ~~73~~ ~~68~~ ~~63~~ ~~62~~ 60 bytes This definitely needs some golfing... ``` S2*l~:I2/'_4**N]I(g*S"\\ /"'\{I2md@*@@*'/\@}:F~N"__\\/"_W<F ``` [Test it here.](http://cjam.aditsu.net/#code=S2*l~%3AI2%2F'_4**N%5DI(g*S%22%5C%5C%20%20%2F%22'%5C%7BI2md%40*%40%40*'%2F%5C%40%7D%3AF~N%22__%5C%5C%2F%22_W%3CF&input=5) ## Explanation ``` "Print the first line:"; S2*l~:I2/'_4**N]I(g* S2* "Push a string with 2 spaces."; l~:I "Read and eval the input, store it in I."; 2/ "Divide by two to get the number of top segments."; '_4** "Push '____' and repeat it by the number of segments."; N] "Push a newline and wrap everything in an array."; I(g* "Get sign(I-1) and repeat the array that often. This is a no-op for I > 1 but otherwise empties the array."; "Print the other two lines. The basic idea is to define block which takes as arguments a repeatable 4-character string as well as another string which only gets printed for even I."; S"\\ /"'\{I2md@*@@*'/\@}:F~N"__\\/"_W<F S "Push a space."; "\\__/"'\ "Push the string '\__/' and the character \."; { }:F~ "Store this block in F and evaluate it."; I2md "Get I/2 and I%2 using divmod."; @* "Pull up the second argument and repeat it I%2 times. This turns it into an empty string for even I."; @@ "Pull up I/2 and the 4-character string."; * "Repeat the string I/2 times."; '/\@ "Push a / and reorder the three line parts."; N "Push a newline."; "__\\/"_W<F "Call F again, with '__\/' and '__\'."; ``` [Answer] # Julia, 115 bytes ``` n->(m=n÷2;p=println;k=n%2>0?m+1:m;e=m<k?"":"/";t=" /\\ ";b="/__\\";if n>1 p(" "*"_"^4m)end;p(t^k*" "*e);p(b^k*e)) ``` This creates an unnamed function which accepts an integer and prints the triangles. To call it, give it a name, e.g. `f=n->(...)`. Ungolfed + explanation: ``` function f(n) m = n ÷ 2 # Number of upside down triangles p = println # Store println function to save space k = n % 2 > 0 ? m + 1 : m # Number of right side up triangles e = m < k ? "" : "/" # n even? End lines with a / # Top of the triangle t = " /\\ " # Bottom of the triangle b = "/__\\" # Print the bottoms of any upside down triangles # * performs string concatenation # ^ performs string repetition if n > 1 println(" " * "_"^4m) end # Print the triangle tops (these have two trailing spaces # if the last triangle isn't upside down) println(t^k * " " * e) # Print the triangle bottoms println(b^k * e) end ``` Example output: ``` julia> for i = 1:10 f(i) end /\ /__\ ____ /\ / /__\/ ____ /\ /\ /__\/__\ ________ /\ /\ / /__\/__\/ ________ /\ /\ /\ /__\/__\/__\ ____________ /\ /\ /\ / /__\/__\/__\/ ____________ /\ /\ /\ /\ /__\/__\/__\/__\ ________________ /\ /\ /\ /\ / /__\/__\/__\/__\/ ________________ /\ /\ /\ /\ /\ /__\/__\/__\/__\/__\ ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ ``` I'm pretty bummed that this is so long. I'm sure there are golfing opportunities aplenty but they aren't clear to me at the moment. Let me know if you have any suggestions or if you'd like any further explanation! [Answer] # CJam, ~~68 62~~ 60 bytes As far as I can see, this is a completely different approach than the other CJam solution. This can be golfed a lot. ``` "/__\\ /\\"4/]ri:R(['/" /"'_4*"__\\"'\L]3/R*<+zR1>SS+*\W%N* ``` [Try it online here](http://cjam.aditsu.net/#code=%22%2F__%5C%5C%20%2F%5C%5C%224%2F%5Dri%3AR(%5B'%2F%22%20%20%2F%22'_4*%22__%5C%5C%22'%5CL%5D3%2FR*%3C%2BzR1%3ESS%2B*%5CW%25N*&input=6) [Answer] ## C# 190 ``` void f(int n){string s=(n>1)?"\n ":"",t=" /",u = "/";bool b=true;int m=n;while(m-->0){s+=(n>1&&b&&m>0)?"____":"";t+=b?"\\":" /";u+=b?"__\\":"/";b=!b;}Console.Write("{0}\n{1}\n{2}",s,t,u);} ``` Ungolfed ``` void f(int n) { string s = (n > 1) ? "\n " : "", t = " /", u = "/"; bool b = true; int m = n; while(m-->0) { s += (n > 1 && b && m>0) ? "____" : ""; t += b ? "\\" : " /"; u += b ? "__\\" : "/"; b = !b; } Console.Write("{0}\n{1}\n{2}",s,t,u); } ``` [Answer] # C#, ~~257~~183 bytes ``` void C(int t){int i;var n="\r\n";var s=" "+string.Join("____",new string[1+t/2])+n;for(i=0;i++<=t;)s+=i%2<1?"\\ ":" /";s+=n;for(i=0;i++<=t;)s+=i%2<1?"__\\":"/";Console.WriteLine(s);} ``` **Edit:** Thanks to the tips from @VisualMelon, saved 74 bytes. I know it's far from the best language to golf in, but I'm mostly interested in learning about the various nuances of C#, rather than winning the competition. This is basically a port of [this](https://codegolf.stackexchange.com/a/48101/15417) Pyth answer. I'm thinking the for loops could be golfed further, but I'm not quite sure how, given the tertiary statements embedded within them. Example (1, 2, 3, 10): ``` /\ /__\ ____ /\ / /__\/ ____ /\ /\ /__\/__\ ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ ``` **Ungolfed:** ``` void C2(int t) { int i; var n="\r\n"; var s=" "+string.Join("____",new string[1+t/2])+n; for(i=0;i++<=t;) s+=i%2<1?"\\ ":" /"; s+=n; for(i=0;i++<=t;) s+=i%2<1?"__\\":"/"; Console.WriteLine(s); } ``` [Answer] # Java, 185 ``` String f(int n){int i;String s="";if(n>1){s=" ";for(i=0;i<n/2;i++)s+="____";s+='\n';}for(i=0;i<=n;)s+=i++%2<1?" /":"\\ ";s+='\n';for(i=0;i<=n;i++)s+=i%2<1?i<n?"/_":"/":"_\\";return s;} ``` # Explanation ``` String f(int n) { int i; String s = ""; if (n > 1) { s = " "; for (i = 0; i < n / 2; i++) { s += "____"; } s += '\n'; } for (i = 0; i <= n; i++) { s += i % 2 < 1 ? " /" : "\\ "; } s += '\n'; for (i = 0; i <= n; i++) { s += i % 2 < 1 ? i < n ? "/_" : "/" : "_\\"; } return s; } ``` [Answer] ## C# - ~~151~~ ~~146~~ ~~141~~ 138 Inspired by @bacchusbeale's answer ``` string f(int n){string t="\n",s=n>1?" "+new string('_',n/2*4)+t:"";for(var b=n<0;n-->=0;t+=b?"__\\":"/",b=!b)s+=b?"\\ ":" /";return s+t;} ``` Ungolfed ``` string f(int n) { string t = "\n", s = n > 1 ? " " + new string('_', n / 2 * 4) + t : ""; for (var b = n < 0; n-- >= 0; t += b ? "__\\" : "/", b = !b) s += b ? "\\ " : " /"; return s + t; } ``` [Answer] # Go, ~~156~~ 144 ``` func f(n int){a,b,c:=" ","","";for i:=0;i<=n;i++{if i<n/2{a+="____"};if i%2<1{b+=" /";c+="/"}else{b+=`\ `;c+=`__\`}};print(a+"\n"+b+"\n"+c)} ``` Ungolfed: ``` func f(n int) { a, b, c := " ", "", "" // Initialize 3 accumulators for i := 0; i <= n; i++ { // For each required triangle if i < n/2 { // Yay integer math a += "____" } if i%2 < 1 { // Even, uneven, (are we drawing up or downslope?) b += " /" c += "/" } else { b += `\ ` c += `__\` } } print(a + "\n" + b + "\n" + c) } ``` The only real trick here (and it isn't even a good one) is using 3 accumulators so I can condense the solution down to 1 loop. The code can be run here: <http://play.golang.org/p/urEO1kIjKv> [Answer] # [><> (Fish)](http://esolangs.org/wiki/Fish), 215 183 156 bytes Edit: Notepad++ was giving me 5 extra bytes due to CR, so modified count accordingly Slightly more golfed, but it is my first fish program so far >\_< The requirement to not have a blank first line for 1 triangle doubled the size of the program. ``` 99+0{:}1=?.~~" "oo:2,:1%-v -1 oooo "____" v!? )0:/! " /"oa~~.?=1}:{24~/:oo v!?)0:-1o"\"v!?)0:/!-1ooo" /" /v ~o"/"oa/! !\:0)?!;"\__"ooo1-:0)?!;"/"o1- ``` Can test at <http://fishlanguage.com/> (Int on initial stack for length) Explanation: ``` Start with initial stack as input number 99+0 Push 18 and 0 to the top of the stack {:} Shift the stack to the left (wraps), copy the top value, and shift it back to the left (i.e. copy bottom of stack to the top) 1= Check to see if the top of the stack is equal to 1, pushes 1 for true, 0 for false ?. If top of stack is zero, skip the ., otherwise jumps to x,y coordinates on top of stack (18,0). This skips the next 8 instructions ~~ Pop the top 2 values from the stack (if they're not popped by the jump) " " Push the string literal " " onto the stack oo Pop the top two values of stack and output them as characters :2, Copy top value of stack, ad divide by 2 :1%- Since ><> uses float division, and doesn't have >= notation, remove the decimal part (if exists) v Redirect pointer down / Redirect pointer left :0) Copy top of stack, and see if its greater than 0 (1 for true, 0 for false) ?!v If top of stack is non-zero, then ! is executed, which skips the next instruction (redirect), otherwise, code is redirected "____" Push the literal "____" to the stack oooo Pop the top four values of stack and output them as characters 1- Decrement the top of the stack by 1 !/ Ignore the redirect action. When the loop gets to 0, it goes to next line, and gets redirected to the left. ~ Pops the top of the stack (0 counter) 42 Pushes 4 and 2 to the stack {:} As before, copies the bottom of the stack to the top 1=?. Also as before, if the initial value is 1, jump to (2,4) (skipping next 4 instructions ~~ Pop 2 values from stack if these instructions haven't been skipped ao Push 10 onto the stack and output it as a character (LF) "/ "oo Push the literal "/ " onto the stack and output it :// Copies the top of the stack then redirects to the line below, which then redirects to the left :0) Copies top of the stack and compares if its greater than 0 ?!v If it is, redirect to next line "\"o Push "\" to stack, then output it as a character 1- Decrement top value of stack :0)?!v If loop is not greater than 0, redirect to next line Either mode of redirect will loop to the left, and (potentially) skip the far right redirect because of the ! ao Push 10 to stack and output it as a character (LF) "/"o~ Push "/" to stack, then output it as a character. Pop top value of stack (the 0 from previous loop) v Redirects to next line, which then redirects to the right :0)?!; If the top of the stack is not greater than 0, terminate (;) "\__" Pushes "\__" to the stack ooo Outputs top 3 stack values as characters ("__\") 1- Decrement top of stack by 1 :0)?!; If the top of the stack is not greater than 0, terminate (;) "/"o Push "/" to top of stack then output it as a character 1- Decrement top of stack by 1 !\ Ignore the redirect ``` [Answer] # perl 109 108 106 ``` $i=<>;$t=join$/,$i-1?" "."_"x($i/2)x4:(),$m.=(" /")[$_&1]||"\\ ",$b.=("/")[$_&1]||"__\\"for 0..$i;print$t ``` I think this is alright for my first golf, I used Vynce's section for the first line, with the rest of my code to get past the new line problem with 1 triangle. Now to see if I can shorten it :) **Edit**: Whitespace **Edit 2**: replaced `"\n"` with `$/` ``` 1: /\ /__\ 4: ________ /\ /\ / /__\/__\/ ``` [Answer] # C89, 150 ``` r(p,q,n)int*p,*q;{n?printf(p),r(q,p,n-1):puts(p);}main(c,v)int**v;{c=atoi(v[1]);if(c>1)printf(" "),r("","____",c-1);r(" /","\\ ",c);r("/","__\\",c);} ``` An ungolfed version: ``` r(p, q, n) char *p, *q; { if(n > 0) { printf(p); r(q, p, n-1); /* swap p and q */ } else { puts(p); } } main(c, v) char**v; { c = atoi(v[1]); if(c>1) { printf(" "); r("", "____", c - 1); } r(" /", "\\ ", c); r("/", "__\\", c); } ``` The output: ``` $ seq 1 3 10 | xargs -n1 ./triangles /\ /__\ ________ /\ /\ / /__\/__\/ ____________ /\ /\ /\ /\ /__\/__\/__\/__\ ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ ``` The stack overflows if I enter `65535` (but not if you compile with `-O3`!), but theoretically it should work ;-) *edit:* program now fulfills the requirement that only two lines should be outputted if `1` is passed to the program *edit 2:* use `int*` instead of `char*` [Answer] # C++ stdlib, 194 bytes ``` string f(int n){char* p[]={"____"," /\\ ","/__\\"};int x[]={(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},i,j;string s=n>1?" ":"";for (i=n>1?0:1;i<3;s+=++i<3?"\n":"")for (j=0;j<x[i];)s+=p[i][j++%4];return s;} ``` Test program: ``` #include <string> #include <iostream> using namespace std; string f(int n) { char* p[]={"____"," /\\ ","/__\\"}; int x[]={(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},i,j; string s=n>1?" ":""; for (i=n>1?0:1;i<3;s+=++i<3?"\n":"") for (j=0;j<x[i];) s+=p[i][j++%4]; return s; } int main(int argc, char* argv[]) { cout << f(10); return 0; } ``` [Answer] # Bash, ~~166~~ ~~127~~ ~~125~~ ~~119~~ 105 bytes ``` printf -v l %$[$1/2]s;(($1%2))&&r= j=$l\ ||r=/ j=$l;echo " ${l// /____} ${j// / /\ } $r ${j// //__\\}"$r ``` In a function: ``` triangle() { printf -v l %$[$1/2]s;(($1%2))&&r= j=$l\ ||r=/ j=$l;echo " ${l// /____} ${j// / /\ } $r ${j// //__\\}"$r } ``` With some presentations: ``` for i in {1..5} 10 31;do paste -d\ <( figlet -fsmall $i | sed 's/^/ /;s/^ *\(.\{10\}\)$/\1 /;$d' ) <(triangle $i) done ``` May render (if you have *figlet* installed): ``` _ / | /\ | | /__\ |_| ___ ____ |_ ) /\ / / / /__\/ /___| ____ ____ |__ / /\ /\ |_ \ /__\/__\ |___/ _ _ ________ | | | /\ /\ / |_ _| /__\/__\/ |_| ___ ________ | __| /\ /\ /\ |__ \ /__\/__\/__\ |___/ _ __ ____________________ / |/ \ /\ /\ /\ /\ /\ / | | () | /__\/__\/__\/__\/__\/ |_|\__/ _____ ____________________________________________________________ |__ / | /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ |_ \ | /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\ |___/_| ``` ### Save 2 chars if *input* from variable instead of `$1`: 103 ``` printf -v l %$[i/2]s;((i%2))&&r= j=$l\ ||r=/ j=$l;echo " ${l// /____} ${j// / /\ } $r ${j// //__\\}"$r ``` Into the loop: ``` for i in {1..3} {31..34};do [ $i == 31 ] && figlet -fsmall ... paste -d\ <( figlet -fsmall $i | sed 's/^/ /;s/^ *\(.\{10\}\)$/\1 /;$d' ) <( printf -v l %$[i/2]s;((i%2))&&r= j=$l\ ||r=/ j=$l;echo " ${l// /____} ${j// / /\ } $r ${j// //__\\}"$r ) done ``` Will render (approx) same: ``` _ / | /\ | | /__\ |_| ___ ____ |_ ) /\ / / / /__\/ /___| ____ ____ |__ / /\ /\ |_ \ /__\/__\ |___/ _ _ _ (_|_|_) _____ ____________________________________________________________ |__ / | /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ |_ \ | /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\ |___/_| _______ ________________________________________________________________ |__ /_ ) /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ / |_ \/ / /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/ |___/___| ________ ________________________________________________________________ |__ /__ / /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ |_ \|_ \ /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\ |___/___/ _____ _ ____________________________________________________________________ |__ / | | /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ / |_ \_ _| /__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/__\/ |___/ |_| ``` [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~116~~ 95 bytes Big thanks to Mazzy and ASCII-Only for saving 21 bytes ``` param($n)@(" "+"_"*4*($x=$n-shr1))[$n-eq1] " /"+"\ /"*$x+"\"*($a=$n%2) "/"+"__\/"*$x+"__\"*$a ``` [Try it online!](https://tio.run/##LY1BCsIwEEX3OcUwTCWJWInosuA9rIQsIl3U2qYLC7VnH7/g6j94D/74eucyd7nvVR7U0KpjKulpZXBXy0S858j@7K0sjQyHuSvBuRsoT@FumI4IWsJ4WUCMMCGsTs7wz8XY/h0IkHQzoa4vn2rd4VDiphq@ "PowerShell – Try It Online") Not allowing an empty line for n = 1 ate up like ~~14~~ 10 bytes. This solution is ~~pretty brain dead~~ now much more clever with a minimal amount of repeated code. Banker's Rounding is still the actual devil. [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 27 bytes ``` FEN﹪鲫P×⁴_↗⊗¬ι↓P↘²↘⊗ι↑P↗⊗ι ``` [Try it online!](https://tio.run/##ZY09C8IwFEXn9leETi@QLsXFunZxSBGxs/Qj2gdpX4hJHcTfHiEoFh3v4d5z@7G1PbU6hAtZBrI1sJ@Nd7WfOmWBCyZp8JoABSs45@yRJtJrh8bi7OCEk7rBRrDsnHG@S5NDxGVjjngdnWAV@U6rAWpygDxWJC0Kyoruc0xfWWTvXbGSrfBHhytTY349f@@x/gxhG/JFvwA "Charcoal – Try It Online") Link is to verbose version of code. Explanation: ``` FEN﹪鲫 ``` Generate a list of alternating bits of length `n` and loop over them. ``` P×⁴_ ``` Draw `____` without moving the cursor. ``` ↗⊗¬ι↓ ``` On the first and every other triangle, draw the left `/` side. ``` P↘² ``` Draw the `\` side without moving the cursor. ``` ↘⊗ι↑ ``` On the second and every other triangle, draw the left `\` side again to move the cursor. ``` P↗⊗ι ``` On the second and every other triangle, draw the right `/` side, without moving the cursor. [Answer] # C, 368 Bytes ``` void p(char* c){printf(c);} int x(int s,int f){int t=0,p=s;for(int i=0;i<f;i++){if(p==1){t++;p=0;}else{p=1;}}return t;} int main(int argc,char* argv[]){int t=atoi(argv[1]);if(t>1){p(" ");for(int i=0;i<x(0,t);i++) {p("____");}p("\n");}for(int i=0;i<x(1,t);i++){p(" /\\ ");}if(t%2==0){p(" /");}p("\n"); for(int i=0;i<x(1,t);i++){p("/__\\");}if(t%2==0){p("/");}p("\n");} ``` It's more if you count the `#include` statements, but it compiled on gcc, albeit with warnings, without them. I know it's not the shortest by far, but I still like that I did it in C. [Answer] # Perl (simple) 131 125 120 fairly straightforward first pass: ``` $i=<>;print join"\n",$i-1?" "."_"x(4*int($i/2)):(),join("",map{(" /","\\ ")[$_%2]}0..$i),join"",map{("/","__\\")[$_%2]}0..$i ``` oh who needs explicit int? ``` $i=<>;print join"\n",$i-1?" "."_"x($i/2)x4:(),join("",map{(" /","\\ ")[$_%2]}0..$i),join"",map{("/","__\\")[$_%2]}0..$i ``` [Answer] # Prolog, 126 bytes ``` A+B:-writef(A,B). $N:-(N>1," %r\n"+['____',N//2];!),(0is N/\1,T='/';T='')," %r%w\n"+['/\\ ',N/2,T],"%r%w\n"+['/__\\',N/2,T]. ``` Invoke like `$3`. More readable: ``` triangle(N):- ( N > 1 -> writef(" %r\n", ['____', N//2]) ; true ), ( 0 is N mod 2 -> T = '/' ; T = '' ), writef(" %r%w\n", ['/\\ ', N/2, T]), writef("%r%w\n", ['/__\\', N/2, T]). ``` Example: ``` ?- findall(N,between(1,10,N),NN), maplist($, NN), !. /\ /__\ ____ /\ / /__\/ ____ /\ /\ /__\/__\ ________ /\ /\ / /__\/__\/ ________ /\ /\ /\ /__\/__\/__\ ____________ /\ /\ /\ / /__\/__\/__\/ ____________ /\ /\ /\ /\ /__\/__\/__\/__\ ________________ /\ /\ /\ /\ / /__\/__\/__\/__\/ ________________ /\ /\ /\ /\ /\ /__\/__\/__\/__\/__\ ____________________ /\ /\ /\ /\ /\ / /__\/__\/__\/__\/__\/ NN = [1, 2, 3, 4, 5, 6, 7, 8, 9|...]. ``` [Answer] # C#: 1 line LINQ, 198 bytes ``` string f(int n){return(n>1?" ":"")+string.Join("\n",new[]{"____"," /\\ ","/__\\"}.Zip(new[]{(n-n%2)*2,n*2+2-n%2,n*2+1+n%2},(s,l)=>string.Join(s,new string[n+1]).Substring(0,l)).Where(x=>x.Any()));} ``` [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 83 bytes ``` {~[" {'____'x$_/2-.5} "x($_>2),'/\ 'x$_/2~($!='/'x$_%2)," "~'/__\\'x$_/2~$!]}o*+1 ``` [Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/ui5aSUGhWj0eCNQrVOL1jXT1TGu5lCo0VOLtjDR11PVjFBQgEnUaKoq26vogjipQRolLqU5dPz4@JgYqraIYW5uvpW3435pLTy1NrzixUiEtv0jBUE/P9D8A "Perl 6 – Try It Online") Anonymous code block that takes a number and returns a string. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~117~~ 115 bytes -2 thanks to ceilingcat. All those parentheses suggest something less clunky is surely possible. ``` f(n,i,j){for(j=3-1/n;j--;puts("/"+(n%2|j>1)))for(i=0;i<n+(j<2)>>1;)printf(" %.4s"+2-j*!i++,"/__\\/\\ ____"+j*4);} ``` [Try it online!](https://tio.run/##JY5BCoMwEEXX5hTTgDBjTNNYd1FPEpAipCTQVNSurGdPI/2b9xkew5/kc5pSchhrXwfa3XvB0N@lVtEEKc382VbkiguMZfMNgyai0/H9zfguCgxdQ8OgDc2Lj5tDDlBe25WLRobq4oWouRpHa5W1AGMOF6FqyRwp6/B6@IjEdlbkp4DnyUMP2mR0mbdchCBWZKNw6Mlk/jfxsx/sSD8 "C (gcc) – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 37 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` ≠iðð'_I2÷4*×J}„ /„\ ‚I>∍J'/…__\‚I>∍J» ``` [Try it online](https://tio.run/##yy9OTMpM/f//UeeCzMMbDm9Qj/c0OrzdROvwdK/aRw3zFPSBRIzCo4ZZnnaPOnq91IH8ZfHxMXCBQ7v//zcGAA) or [verify the first 10 outputs](https://tio.run/##yy9OTMpM/R/i6ufyqGHe4f1WOv8fdS7IPLzh8Ab1eD@jw9tNtA5P96oFyinoA4kYhUcNs/zsHnX0eqkD@cvi42PgAod2/9c5tM3@PwA). **Explanation:** ``` ≠i } # If the (implicit) input is NOT 1: # i.e. 1 → 0 (falsey) # i.e. 5 → 1 (truthy) ðð # Push two spaces " " '_ '# Push string "_" I # Push the input 2÷ # Integer-divide it by 2 # i.e. 5 → 2 4* # And then multiply it by 4 # i.e. 2 → 8 × # Repeat the "_" that many times # i.e. "_" and 8 → "________" J # Join everything on the stack together to a single string # i.e. " ________" „ / # Push string " /" „\ # Push string "\ " ‚ # Pair them together: [" /","\ "] I> # Push the input+1 ∍ # Extend the list to that size # i.e. [" /","\ "] and 2 → [" /","\ "] # i.e. [" /","\ "] and 6 → [" /","\ "," /","\ "," /","\ "] J # Join the list together to a single string # i.e. [" /","\ "] → " /\ " # i.e. [" /","\ "," /","\ "," /","\ "] → " /\ /\ /\ " '/ '# Push string "/" …__\ # Push string "__\" ‚ # Pair them together: ["/","__\"] I> # Push the input+1 ∍ # Extend the list to that size # i.e. ["/","__\"] and 2 → ["/","__\"] # i.e. ["/","__\"] and 6 → ["/","__\","/","__\","/","__\"] J # Join the list together to a single string # i.e. ["/","__\"] → "/__\" # i.e. ["/","__\","/","__\","/","__\"] → "/__\/__\/__\" » # Join the entire stack with a newline delimiter # i.e. " /\ " and "/__\" → " /\ \n/__\" # i.e. " ________", " /\ /\ /\ " and "/__\/__\/__\" # → " ________\n /\ /\ /\ \n/__\/__\/__\" # (and output the result implicitly) ``` [Answer] # Java 11, 122 bytes ``` n->(n>1?" "+"_".repeat(n/2*4)+"\n":"")+" /\\ ".repeat(n).substring(0,++n*2)+"\n"+"/__\\".repeat(n).substring(0,n/2*4+n%2) ``` [Try it online.](https://tio.run/##fZBBbsMgEEX3OcUIqRKEBsdWVnWcnqDZdFkqizikInHGlsGRqspndyfYUlfpBhj@h3l/zuZmVufjZaxq4z28GYc/CwCHwXYnU1nY30uA99A5/IKKkwIocrocFrT4YIKrYA8IBYy42nHcpa8MgElWMtXZ1prAMcmWGyGZRvbCGB0g0Rr@ZKF8f/CxBV8/S4nLbHJLlpSl1o@c8V@JT5kY8ztN2x9qopmhbo07wpUS8Yn@4xOMmOKcmi4mcUWag9sW6Zo2KWeV4n77YK@q6YNq6WmokTtJ7DH4AwMqmo74zzFrQxzeMP4C) **Explanation:** ``` n-> // Method with integer parameter and String return-type (n>1? // If the input is larger than 1: " " // Return two spaces +"_".repeat( // Appended with "_" repeated the following amount of times: n/2 // The input integer-divided by 2 *4) // And then multiplied by 4 +"\n" // Appended with a newline : // Else: "") // Return nothing +" /\\ ".repeat(n) // Appended with " /\ " repeated the input amount of times .substring(0, // After which we only leave the first `x` characters, where `x` is: ++n // Increase the input by 1 first with `++n` *2) // And then multiply it by 2 // i.e. For input 1, `x` becomes 4 here // i.e. For input 6, `x` becomes 14 here +"\n" // Appended with a newline +"/__\\".repeat(n) // Appended with "/__\" repeated the input amount of times .substring(0, // After which we only leave the first `y` characters, where `y` is: n/2 // The input+1 integer-divided by 2 *4 // Then multiplied by 4 +n%2) // And then the input+1 modulo-2 added // i.e. For input 1, `y` becomes 4 here // i.e. For input 6, `y` becomes 13 here ``` [Answer] # [MathGolf](https://github.com/maxbergmark/mathgolf), 35 bytes ``` ½û__∞* ∞qpÿ /\ *k∞⌠<p)½ÿ/__\*k¥┬'/* ``` [Try it online!](https://tio.run/##y00syUjPz0n7///Q3sO74@MfdczTUgAShQWH9yvoxyhoZQM5j3oW2BRoAhXs14@Pj9HKPrT00ZQ16vpa//8bchlxGXOZcJlymRr8100BAA "MathGolf – Try It Online") ## Explanation The program is split into 3 parts, `½û__∞* ∞qp`, `ÿ /\ *k∞⌠<p`, and `)½ÿ/__\*k¥┬'/*`. One part for each line of the output. ### First part ``` ½ Halve input to integer û__∞ Push "__" and double * Repeat string (input//2 times) ∞ Push space character and double qp Print the spaces first, then the underscores ``` ### Second part ``` ÿ /\ * Push " /\ " and repeat it <input> times k∞ Push input and double it ⌠ Increment by two <p Slice the string to get the first (<input>*2 + 2) characters and print ``` ### Third part ``` )½ Increment input by 1 and halve it to integer ÿ/__\* Repeat "/__\" that many times k¥┬ Check if input is divisible by 2 '/* Repeat "/" either zero or one times based on input ``` ]
[Question] [ [Inspired by this challenge](https://codegolf.stackexchange.com/q/104785/32686) Given an integer in the range `0 <= n < 2**64`, output the minimum sized container it can fit in out of * bit: 1 * nibble: 4 * byte: 8 * short: 16 * int: 32 * long: 64 ## Testcases: ``` 0 -> 1 1 -> 1 2 -> 4 15 -> 4 16 -> 8 123 -> 8 260 -> 16 131313 -> 32 34359750709 -> 64 ``` This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins. [Answer] ## Python, 39 bytes ``` f=lambda n:4**(n>1)*(n<16)or 2*f(n**.5) ``` Counts how many times one must take the square root for `n` to be below `16`, with some special-casing to avoid outputs of 2. If 2 were included, we could do ``` f=lambda n:n<2or 2*f(n**.5) ``` with True for 1. --- **41 bytes:** ``` f=lambda n,i=1:i*(2**i>n)or f(n,i<<1+i%2) ``` Repeatedly doubles the exponent `i` until `2**i>n`. Skips from `i=1` to `i=4` by shifting an additional bit when `i` is odd. Alt 45 bytes: ``` f=lambda n,i=4:4**(n>1)*(2**i>n)or 2*f(n,i*2) ``` [Answer] # J, 19 bytes Monadic verb taking the number on the right and spitting out the container size. There are a couple of equivalent ways of writing it so I've included both. ``` 2^2(>.+1=>.)@^.#@#: 2^s+1=s=.2>.@^.#@#: ``` Explained by explosion: ``` 2^2(>.+1=>.)@^.#@#: NB. takes one argument on the right... #: NB. write it in binary #@ NB. length (i.e. how many bits did that take?) 2 ^. NB. log base 2 of that (>. )@ NB. ceiling +1=>. NB. +1 if needed (since no container is two bits wide) 2^ NB. base 2 exponential ``` What's cool is we see two different ways of taking log base 2 in J. The first is the obvious `2^.`, which is a numerical logarithm. The second is `#@#:`, which can be read as "length of base-2 representation". This is almost equivalent to one-plus-floor-of-log-base-2, except that `#:0` is the one-element list `0`, which is exactly what we want. This beats `1+2<.@^.1&>.` by 8 bytes. In use at the REPL: ``` f =: 2^2(>.+1=>.)@^.#@#: f 131313 32 f 34359750709 64 (,.f"0) 0 1 2 15 16 123 260 0 1 1 1 2 4 15 4 16 8 123 8 260 16 ``` --- Old, overly clever 20 byte solution. ``` 2&^.(>.+1=>.&.)@#@#: NB. takes one argument on the right... #@#: NB. how many bits 2&^. NB. log base 2 of that >. NB. ceiling +1=>. NB. +1 if needed (since no container is two bits wide) ( &.) NB. undo log base 2 ``` [Answer] # Python, 53 50 49 bytes ``` lambda n:[w for w in[1,4,8,16,32,64]if n<2**w][0] ``` [Answer] # Mathematica, ~~44~~ ~~39~~ 38 bytes Thanks @orlp for 5 bytes and @MartinEnder for 1 byte. ``` FirstCase[{1,4,8,16,32,64},x_/;2^x>#]& ``` Finds the first the elements in the list `{1, 4, 8, 16, 32, 64}` such that 2^number is greater than the input. [Answer] # [Pip](https://github.com/dloscutoff/pip), 19 bytes ``` (a<2**_FI2**,7RM2i) ``` [Try it online!](https://tio.run/nexus/pip#@6@RaGOkpRXv5gkkdcyDfI0yNf///28EAA "Pip – TIO Nexus") ### How it works ``` a is 1st cmdline arg, i is 0 (implicit) 2**,7 Construct powers of 2 from 0 to 6 [1 2 4 8 16 32 64] RM2 Remove 2 FI Filter for elements for which: a<2**_ a is less than 2 to that element ( i) Get 0th item of resulting list and autoprint ``` [Answer] ## JavaScript (ES7), 35 bytes ``` n=>[1,4,8,16,32,64].find(b=>2**b>n) ``` [Answer] # Mathematica, ~~46~~ ~~43~~ 38 bytes *Thanks to JungHwan Min and Martin Ender for saving 3 bytes!* *Thanks to ngenisis for a big 5-byte savings!* ``` 2^⌈Log2@BitLength@#⌉/.{2->4,0->1}& ``` Unnamed function taking a nonnegative integer as input and returning a positive integer. `BitLength@#` computes the number of bits in the input, and then `2^⌈Log2@...⌉` computes the smallest power of 2 that's at least as large as the number of bits. Finally, `/.{2->4,0->1}` takes care of the special case that there's no "niblit" between bit and nybble, and also fixes the answer for the weird input `0`. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes ``` bg.²îD1Q+o ``` ## Explanation ``` bg Push the length of the binary representation of input without leading zeros .²î Push x = ceil(log2(length)) D1Q+ Add 1 if x == 1 or add 0 otherwise o Push pow(2,x) and implicitly display it ``` [Try it online!](https://tio.run/nexus/05ab1e#@5@Urndo0@F1LoaB2vn//xsBAA "05AB1E – TIO Nexus") [Answer] # Julia, 40 bytes ``` n->filter(x->n<big(2)^x,[1;2.^(2:6)])[1] ``` This is an anonymous function that generates an array of the powers of 2 from 0 to 6, excluding 2, and filters it to only those elements *x* such that 2*x* is greater than the input. The first such element is the answer. Unfortunately this requires promoting 2 to a `BigInt` to avoid overflow on *x* = 64. This is actually quite similar to orlp's Python answer, though I didn't see it before concocting this approach. [Try it online!](https://tio.run/nexus/julia5#FYjbCoMwEETf/YpFELKwKbnUiL2E/ofVhxJTAmVbgg/@fRpnOAdmSryz9DF9tjWLXXq@vdJbGFx2mvTVnBZhLg5nnPRc4jcDQ2IQikATmOq@4irG1u2O3x4lsGfbj0OvBjViAzWPX068RdF2WgeQHrrw5JaACaJgxGblUP4 "Julia 0.5 – TIO Nexus") [Answer] # [Perl 6](http://perl6.org/), 30 bytes ``` {first 1+<*>$_,1,4,8,16,32,64} ``` `+<` is Perl 6's left bit shift operator, which many other languages call `<<`. [Answer] ## Haskell, 31 bytes ``` f n=[2^i|i<-0:[2..],2^2^i>n]!!0 ``` 32-byte alt: ``` f n|n<2=1|n<16=4|1>0=2*f(sqrt n) ``` [Answer] # Java, 143 bytes. ``` int f(long a){a=Long.toBinaryString(a).length();if(a<2)return 1;if(a<5)return 4;if(a<9)return 8;if(a<17)return 16;if(a<33)return 32;return 64;} ``` [Answer] # Haskell, 43 bytes ``` f x=head$filter((>x).(2^))$[1,4,8,16,32,64] ``` [Answer] # Ruby, ~~39~~ 36 bytes ``` ->n{2**[0,*2..6].find{|p|2**2**p>n}} ``` Thanks G B for helping golf [Answer] # Java 8, ~~65~~ 55 bytes This is a lambda expression which takes a `long` and returns an `int`. Never golfed in Java before, so this should be easily beatable: ``` x->{int i=1;while(Math.pow(2,i)<=x)i<<=1+i%2;return i;} ``` [**Try it online!**](https://repl.it/EyLU/3) --- For **47 bytes**, we could have: ``` x->{int i=1;while(1L<<i<=x)i<<=1+i%2;return i;} ``` However, `1L<<i` overflows for return values larger than 32, so this fails for the final testcase. [Answer] ## Mathematica, 30 bytes ``` 2^(f=BitLength)[f@#-1]/. 2->4& ``` Explanation: Let `N` be the set of nonnegative integers. Define two functions on `N`, `BitLength` and `NextPower` as follows: ``` BitLength(n) := min {x in N : 2^x - 1 >= n} NextPower(n) := 2^(min {x in N : 2^x >= n}) ``` This solution essentially calculates `NextPower(BitLength(n))` given an integer `n >= 0`. For `n > 0`, we can see that `NextPower(n) = 2^BitLength(n-1)`, so `NextPower(BitLength(n)) = 2^BitLength(BitLength(n)-1)`. Now the Mathematica `BitLength` built-in agrees with the definition I gave for `n >= 0`. For `n < 0`, `BitLength[n] == BitLength[BitNot[n]] == BitLength[-1-n]`, so `BitLength[-1] == BitLength[0] == 0`. Thus we get the desired answer of `1` for `n==0`. Since we skip straight from bit to nibble, we have to replace answers of `2` with `4`. [Answer] # bash, ~~49 bytes~~ 48 bytes ``` for((y=1;$[y==2|$1>=1<<y];$[y*=2])){ :;};echo $y ``` or ``` for((y=1;$[y==2|$1>=1<<y];)){ y=$[y*2];};echo $y ``` Save in a script and pass the number to be tested as an argument. *Edit: Replaced || with |, which works because the arguments are always 0 or 1.* **Note:** This works for integers up to the largest positive integer that your version of bash can handle. If I have time, I'll modify it to work up to 2^64-1 in versions of bash that use 32-bit signed arithmetic. In the meantime, here's a 64-byte solution that works for arbitrarily large numbers (in any bash version): ``` for((x=`dc<<<2o$1n|wc -c`;$[x==2||x&(x-1)];$[x++])){ :;};echo $x ``` [Answer] # Stacked, ~~34~~ 30 bytes ``` @n 1 2 6|>2\^,:n 2 log>keep 0# ``` or ``` {!1 2 6|>2\^,:n 2 log>keep 0#} ``` The first takes input on the TOS and leaves output on TOS; the second is a function. [Try it here!](https://conorobrien-foxx.github.io/stacked/stacked.html) ## Explanation ``` @n 1 2 6|>2\^,:n 2 log>keep 0# @n set TOS to `n` 1 2 6|>2\^, equiv. [1, ...2 ** range(2, 6)] : duplicate it n push `n` 2 log log base-2 > element-wise `>` keep keep only truthy values 0# yield the first element ``` Here's an example of it working [on the repl](https://conorobrien-foxx.github.io/stacked/repl.html): ``` > 8 (* input *) (8) > @n 1 2 6|>2\^,:n 2 log>keep 0# (* function *) (4) > (* output *) (4) ``` ## Test cases ``` > {!1 2 6|>2\^,:n 2 log>keep 0#} @:f () > (0 1 2 15 16 123 260 131313 34359750709) $f map ((1 1 4 4 8 8 16 32 64)) > ``` Or, as a full program: ``` {!1 2 6|>2\^,:n 2 log>keep 0#} @:f (0 1 2 15 16 123 260 131313 34359750709) $f map out ``` [Answer] ## Racket 45 bytes ``` (findf(λ(x)(>(expt 2 x)m))'(1 4 8 16 32 64)) ``` Ungolfed: ``` (define (f m) (findf (λ (x) (> (expt 2 x) m)) ; find first function '(1 4 8 16 32 64))) ``` Other versions: ``` (define (f1 m) (for/last ((i '(1 4 8 16 32 64)) ; using for loop, taking last item #:final (> (expt 2 i) m)) ; no further loops if this is true i)) ``` and using string length: ``` (define (f2 m) (for/last ((i '(1 4 8 16 32 64)) #:final (<= (string-length (number->string m 2)) ; convert number to binary string i)) i)) ``` Testing: ``` (f 0) (f 1) (f 2) (f 15) (f 16) (f 123) (f 260) (f 131313) (f 34359750709) ``` Output: ``` 1 1 4 4 8 8 16 32 64 ``` [Answer] # [Thunno](https://github.com/Thunno/Thunno), \$ 13 \log\_{256}(96) \approx \$ 10.70 bytes ``` bL2AYZmD1=+2@ ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m72sJKM0Ly9_wYKlpSVpuhZrk3yMHCOjcl0MbbWNHCBiUKkFywyNQRDCAwA) Port of Osable's 05AB1E answer. #### Explanation ``` bL2AYZmD1=+2@ # Implicit input bL # Length of binary representation 2AY # Log base 2 of above Zm # Ceil of above 1= # Equals one? D + # If true, add one; else, pass 2@ # Two to the power of above # Implicit output ``` [Answer] # Octave, ~~40 36 31~~ 29 bytes Simple anonymous function. It is assumed that the input value is an integer - see the caveat at the end. ``` @(a)(b=2.^[0 2:6])(a<2.^b)(1) ``` The code works as follows: * First an array of the allowed bit lengths (1,4,8,16,32,64) is created and saved to `b`. * Next we find the number of bits required to store the input number `a` by comparing with the maximum size of each container in `b` to see which are big enough. * We then use the resulting index vector to extract the container size from `b` again. * Finally we take the first element in the resulting array which will be the smallest container possible. You can try it online [here](http://octave-online.net/). Simply run the following code, and then do `ans(x)`. --- The only caveat with this is that double precision is used for constants by default which means that it only works with numbers up to the highest value representable by a double precision float that is less than 2^64. This can be fixed by ensuring that the number that is supplied to the function is an integer rather than a double. This can be achieved by calling the function for example with: `ans(uint64(x))`. [Answer] # PHP, ~~49~~ ~~46~~ 44 bytes ``` echo(2**ceil(log(log(1+$argn,2),2))-2?:2)+2; ``` Run like this: ``` echo 16 | php -R 'echo(2**ceil(log(log(1+$argv[1],2),2))-2?:2)+2;';echo ``` # Explanation ``` echo # Output the result of the expression ( 2** # 2 to the power ceil(log( # The ceiling of the power of 2 of bitsize log(1+$argn,2), # Number of bits needed 2 )) - 2 ?: # Subtract 2 (will be added back again) 2; # If that results in 0, result in 2 (+2=4). ) + 2 # Add 2. ``` # Tweaks * Saved 3 bytes by getting rid of the `$r=` assignment * Saved 2 bytes by using `-R` to make `$argn` available [Answer] # [CJam](https://sourceforge.net/p/cjam), 18 bytes ``` 2ri2b,2mLm]_({)}|# ``` [Try it online!](https://tio.run/nexus/cjam#@29UlGmUpGOU65MbG69RrVlbo/z/v6ExCAIA "CJam – TIO Nexus") **Explanation** ``` 2 Push 2 ri Read an integer from input 2b, Get the length of its binary representation 2mLm] Take the ceiling of the base-2 log of the length _( Duplicate it and decrement it {)}| Pop the top element, if it's 0, increment the next element Effectively, if ceil(log2(input)) was 1, it's incremented to 2, otherwise it stays the same. # Raise 2 to that power ``` [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes ``` ʀ~‹E≬E?>c ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJ+IiwiIiwiyoB+4oC5ReKJrEU/PmMiLCIiLCIwIC0+IDFcbjEgLT4gMVxuMiAtPiA0XG4xNSAtPiA0XG4xNiAtPiA4XG4xMjMgLT4gOFxuMjYwIC0+IDE2XG4xMzEzMTMgLT4gMzJcbjM0MzU5NzUwNzA5IC0+IDY0Il0=) This took a lot of experimenting to get to 9 bytes. Like at least 20 minutes of trying and trying. ## Explained ``` ʀ~‹E≬E?>c ʀ # The range [0, input] ~‹ # With 1 removed (filter by decrement, could also be 1o, but that's not as stylish) E # with 2 raised to the power of each item. This creates a list of [1, 4, ...] ≬ c # get the first item of that where E # 2 to the power of the item ?> # is greater than the input ``` [Answer] # C, ~~71~~ 52 bytes ``` i;f(long long n){for(i=1;n>>i;i*=2);return i-2?i:4;} ``` [Answer] ## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 27 bytes ``` :~a<2|_Xq]{~a<2^t|_Xt\t=t*2 ``` Explanation ``` : Get cmd line parameter N, call it 'a' ~a<2 IF 'a' is 0 or 1 (edge case) |_Xq] THEN quit, printing 1 ('q' is auto-initialised to 1). ']' is END-IF { DO - infinite loop 2^t 't' is our current number of bits, QBIC sets t=4 at the start of the program. 2^t gives the maximum number storable in t bytes. ~a< IF the input fits within that number, |_Xt THEN quit printing this 't' \t=t*2 ELSE jump to the next bracket (which are spaced a factor 2 apart, from 4 up) DO-loop is auto-closed by QBIC. ``` [Answer] ## Pyke, 13 bytes ``` 7Zm@2-#2R^<)h ``` [Try it here!](http://pyke.catbus.co.uk/?code=7Zm%402-%232R%5E%3C%29h&input=16&warnings=0) ``` 7Zm@ - [set_bit(0, i) for i in range(7)] <- create powers of 2 2- - ^.remove(2) # )h - filter(^, V)[0] 2R^ - 2 ** i < - input < ^ ``` [Answer] # PHP, 43 bytes ``` for(;1<<2**$i++<=$argn;);echo 2**$i-=$i!=2; ``` Run with `echo <number> | php -R '<code>'`. loops `$i` up until `2**(2**$i)` is larger than input. (Tweak: `<<` instead of `**` to eliminate parens) After the loop, $i is one too high; so it gets a decrement before calculating the output - but not for `$i==2`. ]
[Question] [ iOS 11 has a bug [that makes the result of 1+2+3 to be 24](https://www.reddit.com/r/apple/comments/782250/try_quickly_typing_1_2_3_into_the_ios_11/?sort=old&sh=63028759&st=J93B9RWJ). This is related to the animation speed, but anyway: The task is to make `1 + 2 + 3 == 24`. But only that. So you should provide a function that correctly sums most sequences but returns `24` when the arguments are `1`, `2` and `3` in any order. Example inputs: ``` 1 2 => 3 3 4 => 7 1 2 3 4 5 6 7 8 9 => 45 3 2 1 => 24 2 1 3 => 24 1 1 => 2 1 2 3 => 24 40 2 => 42 1 2 2 4 => 9 1 2 3 4 1 2 3 => 16 1 => 1 1 23 => 24 0 1 2 => 3 3 2 3 => 8 ``` Input can be in any format as long as your code accepts any number of arguments. * Support for negative numbers isn't required (all non negative numbers are required to work, that includes 0) * We assume correct input --- Differences from [another similar question: "What do you get when you multiply 6 by 9? (42)"](https://codegolf.stackexchange.com/questions/124242): * In this case your function is required to accept **any** number of arguments. The old question specifies exactly 2. * In this case order doesn't matter, while the old question specified that order `6 9` is required and `9 6` should be evaluated correctly. [Answer] # Java 8, ~~109~~ ~~106~~ ~~101~~ ~~90~~ ~~75~~ ~~74~~ ~~71~~ 66 bytes ``` a->{int s=0,p=0;for(int i:a){s+=i;p|=1<<i;}return s<7&p==14?24:s;} ``` -12 bytes thanks to *@OlivierGrégoire*. -31 bytes thanks to *@Nevay*. **Explanation:** [Try it here.](https://tio.run/##jZCxTsMwEIb3PsVNKBFXK0kDpXUMT0CXjojBdV3kkjpW7FRCIc8eLi0DC3Il25LPn7/7dUd5lvPGaXvcf65GVUvv4VUa288AjA26PUilYTNdLwVQCZ2MMZApp@JAm5YPMhgFG7AgYJTz535ivcjQiYwfmnb6BWYt097fC8Pdt8iryvCh1aFrLfhqeeeEyMuXolx7Poz86nXdribvr/7cmD2cKF2yDa2xH2/vlOIabfvlgz6xpgvM0VOobWKZSnIs0kvOf4kFlhGCHEgUPuAjLvEJV1FjgXmEIQIX0b75LckiTJlFRzBpipvH8KfpMBvGHw) ``` a->{ // Method with integer-array parameter and boolean return-type int s=0, // Sum-integer, starting at 0 p=1; // Product-integer, starting at 1 for(int i:a){ // Loop over the input-array s+=i; // Add current item to sum p|=1<<i; // Take 1 bitwise left-shifted with `i`, and bitwise-OR it with `p` } // End of loop return p==14 // If `p` is now exactly 14 (`0b1110`) &s<7? // and the sum is 6 or lower: 24 // Return 24 : // Else: s; // Return the sum } // End of method ``` (Inefficient) proof that only `[1,2,3]` (in any order) will be the possible results when `p` is `0b1110` (`p==14`) and the sum is below 6 or lower (`s<7`): [**Try it here.**](https://tio.run/##jZG9TsMwFEZn/BRXnhyZVhTB5HpgQEww0BExOLZbpbRJVDuVEOTZQ5Imjpuflgz3OvaJ7/mUrTiKWZLqeKu@ikLuhDHwKqL4BwGkWbiLJBgrbNmOSaRgXx6RlT1E8ebjE8RhY4KKBIhiC@9Pby/PwOH@kdV76@RAqn3BZ/URA7Hk7YrS5suOCx0XOi70uI6UjpSOlDV500HKQcpB6uw6/0rtaO1oPaBPQQ0XNKSSKqrZyHHKSfnc/ZLFcimCoO5h02XTVdN1MLhhTVLOFw@DyQCrb2P1fp5kdp6Wv8DuYiIovsWlTFVlXVVdNcVATLbnmBqKAzwYk6Ppt7OMDI3muxav99lUqP9GuhTGl/fXXgyGhhGmEpyx497Xrad9O8Nu5UwZ6ln2JT1gTO2S2JRSq9H2RoYhX6T1cLvD6eOzx6eeZlU1R3lR/AE) > > `p==14` (`0b1110`) evaluates to true iff the input values modulo 32 cover the values `1`, `2` and `3` and contain no other values (`p|=1<<i`) (each value has to occur 1+ times). The sum of input that matches `p==14` will be larger than `6` for any input except `1,2,3` (`s=a*1+b*2+c*3+u*32` with `a>0,b>0,c>0,u>=0`). > > *@Nevay* > > > --- Old **71 bytes** answer: ``` a->{int s=0,p=1;for(int i:a){s+=i;p*=i;}return a.length==3&p==s?s*4:s;} ``` Proof that for any three given non-zero natural numbers, only `[1,2,3]` (in any order) will have a sum equal to its product (`1+2+3 == 1*2*3`) (with a positive sum): [*When the sum equals the product* by Leo Kurlandchik & Andrzej Nowicki](http://www-users.mat.umk.pl/%7Eanow/ps-dvi/si-krl-a.pdf) (Inefficient) proof that only `[1,2,3]` (in any order) and `[0,0,0]` will be the possible results with non-negative numbers and a length of 3: [**Try it here.**](https://tio.run/##XY8xD4IwEIV3fsXFCawanLGDg3HSQUbjcK1AitA2tJIYw2/HVo0Cy93lve9e7kpscal0Jsvrre95hcbAAYV8BgD6zirBwVi0rrVKXKF2VpjaRsjifAFsChN5EkBIC6ftcb8DCus4jpO3mqsm9A7SOAHc0DfhJkK@a3@EeYT9EDZA/hD3EP9BfAR9jjAUCSM8mcia4pzNx3IeGkr1KAEgfRib1St1tyvt3rSVDJHMFjMX6iuPhhFdMJ0@3dcu6Pr@BQ) So `s*4` will becomes `6*4 = 24` for `[1,2,3]`, and `0*4 = 0` for `[0,0,0]`. [Answer] # [MATL](https://github.com/lmendo/MATL), ~~11~~ 10 bytes ``` St3:X=6*+s ``` [Try it online!](https://tio.run/##y00syfn/P7jE2CrC1kxLu/j//2hjHUMdo1gA "MATL – Try It Online") or [verify all test cases](https://tio.run/##y00syfmf8D@4xNgqwtZMS7v4v0vI/2hDHQWjWK5oYx0FEyAF4ukogDg6CqY6CmY6CuY6ChY6CpYQJUA5QyALRAFVQdQbIrQBWSYGEPMgIkaYpiKUwjQaxwIA "MATL – Try It Online") **Explanation** ``` % implicit input [3,1,2] S % sort % STACK: [1,2,3] t % duplicate elements 3: % push range 1..3 % STACK: [1,2,3], [1,2,3], [1,2,3] X= % true if arrays are numerically equal % STACK: [1,2,3], 1 6*+ % multiply result of comparison by 6 and add to the original array % STACK: [7,8,9] s % sum % (implicit) convert to string and display ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes ``` Os{3LQi4* ``` Explanation: ``` Os{ Get the sum of the input, and then get the sorted input list Qi If it is equal to... 3L [1, 2, 3] 4* Then multiply the sum by four. ``` [Try it online!](https://tio.run/##MzBNTDJM/f/fv7ja2Ccw00Tr//9oQx0Fw1gA "05AB1E – Try It Online") [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes ``` 3R⁼Ṣ4*×S ``` [Try it online!](https://tio.run/##y0rNyan8/9846FHjnoc7F5loHZ4e/P///2hDHQUjHQXjWAA "Jelly – Try It Online") [Answer] # [Haskell](https://www.haskell.org/), 37 bytes ``` f[a,b,c]|2^a+2^b+2^c==14=24 f l=sum l ``` [Try it online!](https://tio.run/##dY/BDoIwEETvfMUcvLkHWwrIYb@EQFLQRmJBI3rz32tpgpFQD3vZNzO7c9HT9Wytc6bS1FJXv2Wj97Jp/XTMQrFUiYHl6TXAukH3IxinWwLcH/34xA4GlSDIGsxI1/uUoMK@2OoJMyVkhJxQEI6EMohVtknxahGY/2bFZuCTokx8TdHrUY86LFVU1CWXRuX/Rr/5Incf "Haskell – Try It Online") We use pattern matching to catch the exceptional case. Haskell doesn't have sorting built-in. The equality `2^a+2^b+2^c==14` is satisfied only by `[a,b,c]` a permutation of `[1,2,3]` among non-negative integers. A shorter `a+b+c=a*b*c` almost works, but is satisfied by `[0,0,0]`, and appending the check `,a>0` makes it 1 byte longer. [Answer] # [MATL](https://github.com/lmendo/MATL), 13 bytes ``` stGp=18*Gda*+ ``` [Try it online!](https://tio.run/##y00syfn/v7jEvcDW0ELLPSVRS/v//2izWAA "MATL – Try It Online") It's two bytes longer than the other MATL answer, but it uses a completely different (and IMO more interesting) approach, so I figured it's worth posting. ### Explanation: This solution uses the fact that: > > The sum and product of an array with three elements are only equal if the array is a permutation of `1,2,3`. > > > This takes the input, calculates the sum `s`, and duplicates it `t`. It then checks if the sum equals the product `Gp=`. We multiply the boolean `1/0` by 18, `18*`, and checks if there are non-identical values in the vector `da*` (again, multiply by a boolean `any(diff(x))`. We then multiply the two add the last number to the original sum. A step by step explanation: Assume the input is `[1, 2, 3]`: ``` s % Implicit input, calculate the sum % 6 t % Duplicate the sum: % 6, 6 G % Grab input % 6, 6, [1,2,3] p % Calculate the product % 6, 6, 6 = % Check if the last two elements are equal % 6, 1 (true) 18* % Push 18, multiply by the last number % 6, 18 G % Grab input % 6, 18, [1,2,3] d % Calculate the difference between each element % 6, 18, [1,1] a % any non zero elements? % 6, 18, 1 (true) * % Multiply last two numbers % 6, 18 + % Add numbers. Result: 24 ``` [Answer] # [Python 2](https://docs.python.org/2/), 39 bytes ``` lambda*a:sum(a)+18*(sorted(a)==[1,2,3]) ``` [Try it online!](https://tio.run/##FcqxDsIgFEDRuXzFG6G@QVo1pgljXV3c1AEtTUlaIA@I9uuxjufmhjVN3jVlVI8y6@U16Fp3MS9ci5081zx6SmbYpNRdYoPtU5REa8eqz2RnAzfKZkMVyLoEI6@tCzlxIZj5vk1I0F8vPZGnbQo6xiIRGoSWHRCOCCe2R/inHw "Python 2 – Try It Online") Uses an alternate method of adding 18 if the sorted input is `[1, 2, 3]` to beat the [other Python answer](https://codegolf.stackexchange.com/a/146185/60919) by a byte. [Answer] # [Octave](https://www.gnu.org/software/octave/), 34 bytes ``` @(x)sum(x)+isequal(sort(x),1:3)*18 ``` [Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0KzuDQXSGpnFqcWlibmaBTnF5UA@TqGVsaaWoYW/9M0og11jHSMYzW5gEwjHUMY0xjINIIw4Qy4OrAWHRNkDpIpUFkdUx0zHXMdCx1LoPB/AA "Octave – Try It Online") or ``` @(x)(s=sum(x))+18*~(s-6|prod(x)-6) ``` [Try it online!](https://tio.run/##y08uSSxL/Z9mq6en999Bo0JTo9i2uDQXyNDUNrTQqtMo1jWrKSjKTwGK6Jpp/k/JLC7QSNOINtQx0jGO1dTkggmYAAUMkQWAKoDc/wA) or ``` @(x)(s=sum(x))+18*~(s-prod(x)|s-6) ``` This is shorter than the approach others use: `@(x){24,sum(x)}{2-isequal(sort(x),1:3)}`. **Explanation:** It takes the sum of the vector, and adds 18 if the sorted vector is equal to `1,2,3`. This will give `6+18=24` if the vector is a permutation of `1,2,3`, and just the sum of the vector if not. [Answer] # PHP, 116 bytes This is my first attempt at a golfing challenge ever, AND it's PHP, a language which apparently sucks at golfing since I rarely see it here, so ... uhm, I tried? ``` <?php //call as var/www/html/cg_ios.php --'1 2 3 4 5' $i=$argv[1];$a=(explode(' ',$i));echo((($b=array_sum($a))==6&&count($a)==3&&in_array(3,$a)&&!in_array(0,$a)?24:$b)); ``` Note: I did not include the comment into the bytecount. ### Ungolfed It's nothing special tbh: ``` $i=$argv[1]; //Read the input from the command line $a=array_filter($c=explode(' ',$i)) //Split the input string into an array, use Whitespace as delimiter //also, remove all 0 from the array, since they are not important at all echo( //print the result ($b=array_sum($a) == 6 //If The SUM of the Array is 6 ... && //... AND ... (count($c) == 3) //... the array has exactly 3 values ... && //... AND ... in_array(3,$a) // ... the array contains the value 3 ... && // ... AND ... !in_array(0,$a) //... the array contains no zeros ? 24 //print 24 : $b)); //print the sum of the array values we saved earlier ``` If you want to test this in PHPFiddle and not on console, you can obviously replace `$i` with anything you'd like. Thanks to Olivier Grégoire who made me aware of the string combination `[0,3,3]` which returned 24 before and also helped me saving a few chars by storing the `array_sum` and returning that instead of running the function again. [Answer] # R, ~~47 bytes~~ ~~34 bytes~~ 36 bytes ``` x=scan();all(sort(x)==1:3)*18+sum(x) ``` [Try it online!](https://tio.run/##fYvBCgIhFEX37yuENs96i566iMKPERlhwBwaNQaibzcJGVq1O/eee9fWNpu9SyhvLkbMy1pwk9byVcsjX0653ntuDAwKNEAQVoSafJmX1MXrz@ktDtOjzk8Xp1QgoEcmJeWXNJlB5ryXXZMerIh31r3n3w0ZGtv2AQ) Sum the input and add 18 if the input set is 1:3. Thanks to @mlt for golfing off 11 bytes. Thanks to @Ayb4btu for identifying an error with the overgolfed code [Answer] # Javascript ES6, 39 bytes Thanks to @Herman Lauenstein ``` a=>a.sort()=="1,2,3"?24:eval(a.join`+`) ``` ``` f=a=>a.sort()=="1,2,3"?24:eval(a.join`+`) console.log(f([1,2,3])); console.log(f([1,2,3,4])); ``` # Previous answer Javascript ES6, 66 bytes ``` a=>(n=[1,2,3],a.every(_=>n.includes(_))?24:a.reduce((x,y)=>x+y,0)) ``` ## Try it ``` f=a=>(n=[1,2,3],a.every(_=>n.includes(_))?24:a.reduce((x,y)=>x+y,0)) console.log(f([1,2,3])); console.log(f([1,3,2])); console.log(f([1,2,3,4])); ``` [Answer] ## Swift, 67 Bytes ``` func z(i: [Int])->Int{return i.sorted()==[1,2,3] ?24:i.reduce(0,+)} ``` Could make it to 27 bytes with extensions on [Int], but that would be cheating :( [Answer] # Mathematica, 28 bytes ``` If[Sort@#=={1,2,3},24,Tr@#]& ``` [Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/DfMy06OL@oxEHZ1rbaUMdIx7hWx8hEJ6TIQTlW7X9AUWZeiYJDWjRUKvY/AA "Wolfram Language (Mathematica) – Try It Online") [Answer] # J, 17 bytes *-6 bytes thanks to Frowny Frog* ``` +/*1+3*1 2 3-:/:~ ``` Sum all the numbers `+/` and multiply the result by (pseudocode) `1 + 3*(is123 ? 1 : 0)`. That is, return the results unchanged unless the sorted list is `1 2 3` in which case we multiply the result by 4. [Try it online!](https://tio.run/##VYo7DsIwEAV7n2KUJiIBgr02n5V8GhQL0VCkTq5uTEyKFK@YN/POaSIqF8pyP3S2l87ikJMOuuSDac60KWrLkVlJkzHj8/VBiCRKWfG2ouAr@rDp30fgWoo7j2qd/9cOu3sKI/kL "J – Try It Online") ### original answer ``` +/`(24"_)@.(1 2 3-:/:~) ``` Check if the sorted input is `1 2 3` -- if yes, invoke the constant function 24 (`24"_`); if not, return the sum `+/` [Try it online!](https://tio.run/##VYq9DoIwGEX3PsUJCzTyI20R/ZImvokkxMa4MDDDq9dqdXC4w7nnPGNY8cKRtHjopsq44qavbdVjsI10suuoVdFSBi8lNZsQVqXu82PB4gmkNOP4QYvL6Iaffn8MnFJx5pKtcd/a0P89ibHxBQ "J – Try It Online") [Answer] # [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 57+18=75 bytes ``` a=>a.OrderBy(x=>x).SequenceEqual(new[]{1,2,3})?24:a.Sum() ``` [Try it online!](https://tio.run/##lY5Ba4MwGIbPy6/4jglkAXWnOS1taWGwsYGHHYqHED9KQBM0SWsRf7uTFWG3udPLCw/P@yr3qGyHU3DanKG4OY9NSn438aZNmxJVS@fgcyDOS68VHINRL9r4U8lhjhxerdtWFWQwySyX4qOrsNvdaJ/lPRMFtgGNwkMbZE0NXk/lEPGYJyPbxE/PUhShoWxKyaK/WF3Bu9SGMjKQh701ztYovjrtcT6E9D53V8HiYunfaMyjtehsXQ3yhP/jRPSDjWScvgE "C# (.NET Core) – Try It Online") +18 for `using System.Linq;` [Answer] # [Lua](https://www.lua.org), ~~116~~ 81 bytes -7 bytes thanks to [Jonathan](https://codegolf.stackexchange.com/users/74172/jonathan-s) Takes input as command line arguments ``` Z=0S={}for i=1,#arg do j=arg[i]+0S[j]=0Z=Z+j end print(#S>2 and#arg<4 and 24or Z) ``` [Try it online!](https://tio.run/##yylN/P8/ytYg2La6Ni2/SCHT1lBHObEoXSElnyvLFsiIzozVNgiOzoq1NYiyjdLO4krNS@EqKMrMK9FQDrYzUkjMSwGptzEBsRSMTIBmRGn@///f8L/xfyMA "Lua – Try It Online") # Explanation: Works by creating an sparse array `S` and adding zeroes in the indices corresponding to the input values. If parameters are `3, 4, 7` the sparse array will only have numbers at those indices. With that array, we get it's length with the operator `#` that counts from index `1` up to the higher index that has a value in it, if this length is exactly `3`, it means that there were elements in the position `1`, `2` and `3` wich is what we're looking for. The length of the sparse array will be always between `0` and `N` where `N` is the number of parameters. So we just have to check if the length of both the parameters array and the sparse array is `3`. [Answer] # C++17, ~~56~~ 54 bytes ``` [](auto...i){return(-i&...)+4|(~i*...)+24?(i+...):24;} ``` [Try it online!](https://godbolt.org/g/cCqkC6) Note that the function object created is usable at compile time, so the tests are performed by the compiler without having to run a program. ### Explanation: ``` [] // Callable object with empty closure, (auto...i) // deduced argument types, { // and deduced return type return // (-i&...) // If the fold over the bitwise AND of the negation of each argument +4| // is unequal to -4, or (~i*...) // if the product of the bitwise complements of the arguments +24? // is unequal to -24, then (i+...): // return the sum of the arguments, otherwise 24;} // return 24. ``` Proof that the only nonnegative `i...` for which `(-i&...)` equals -4 and `(~i*...)` equals -24 are the permutations of `1, 2, 3`: We first observe that since `-0` = `0`, if any `i` = `0` then `(-i&...) = 0`, so we conclude that all the `i` are positive. Now, note that in 2's complement, `-i` is equivalent to `~(i - 1)`, and `~i` is equivalent to `-(i + 1)`. Applying De Morgan's rule, we find that `(-i & ...)` = `~((i - 1) | ...)` = `-(((i - 1) | ...) + 1)`, so `((i - 1) | ...) = 3`; similarly, `-1 ** n * ((i + 1) * ...) = -24`, so `n` is odd and `((i + 1) * ...) = 24`. The prime factors of 24 are 2\*\*3 \* 3, so `n` <= 4. If `n` = 1, we have `i - 1 = 3` and `i + 1 = 24`, so `n` = 3. Write the `i` wlog as `a <= b <= c`, then clearly `a` = 1 as otherwise `(a + 1)(b + 1)(c + 1)` >= 27. Also `c` <= 4 as otherwise `(a - 1)|(b - 1)|(c - 1)` >= 4. `c` cannot be 4 as 5 is not a factor of 24, so `c` <= 3. Then to satisfy `(a - 1)|(b - 1)|(c - 1) = 3` c = 3, b = 2 as required. [Answer] # [R](https://www.r-project.org/), ~~55~~ ~~45~~ ~~54~~ ~~49~~ ~~57~~ ~~54~~ 48 bytes Saved many ~~bytes and~~ incorrect solutions thanks to Ayb4btu. Saved ~~3~~ 9 bytes thanks to Giuseppe. I keep learning new ways to abuse the fact that `F==0`. ``` "if"((s=sum(x<-scan()))-prod(x)|sum(x|1)-3,s,24) ``` [Try it online!](https://tio.run/##dY3dCoJAFITvfYrFbvbAEfaPtSgfRkxBKC1XQ8iefdt2VSzo7sw3M2c6a@O6iik1mRmudDwlpsgbCgDJrWvPdITJ84lDItGgUGA5EURGUZVVQ1P0ddu41HPuw9G/M3/bL7Ij5X2oH/mlbHr3hRaUowAgWea@fqREFWTqpWKLrcQSRxmIUJ4I5D9Eugz/Ir6FCjdtrslqiWX04BDzF/MmQwarVMFRbOltV7U/9WxtdtIV6QD29g0 "R – Try It Online") The other R answer won in the end. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~136~~ ~~131~~ ~~125~~ ~~97~~ ~~91~~ ~~83~~ 81 bytes Thanks to @landfill babby, and @ceilingcat (of course we're not using c anymore) ``` r,t;main(i,v)int**v;{for(;*++v;t|=1<<i)r+=i=atoi(*v);printf("%d",r>6|t-14?r:24);} ``` [Try it online!](https://tio.run/##Dco7CoAwDADQuwhCfw614mCsnkUqlQx@CKGLevbom19qtpREyDHsCx4KXdF4sDEF7nySAmNtAX6iH0fUZCPGhU9Upmi46J9ZVfVaOZr6hxvfzTS0nYZXRIJ4CR8 "C (gcc) – Try It Online") [Answer] ## [Retina](https://github.com/m-ender/retina), 21 bytes ``` O` ^1¶2¶3$ 24 .+ $* 1 ``` [Try it online!](https://tio.run/##K0otycxL/K@qEZyg898/gSvO8NA2o0PbjFW4jEy49LS5VLS4DP//N9Qx4jLWMeEC0jpAWsdUx0zHXMdCxxIoaqRjyAXEOsZAWUOICi4TA6AGENMISROYBgA "Retina – Try It Online") Input is linefeed-separated, but the test suite uses comma-separation for convenience. ### Explanation ``` O` ``` Sort the numbers (lexicographically, actually, but we only care about the case that the inputs are `1`, `2`, `3` in some order, where that doesn't make a difference). ``` ^1¶2¶3$ 24 ``` If the input is `1,2,3` (in some order), replace it with 24. ``` .+ $* ``` Convert each number to unary. ``` 1 ``` Count the number of `1`s, which adds the unary numbers and converts them back to decimal. [Answer] # [Haskell](https://www.haskell.org/), 44 bytes ``` f a|sum a==6,product a==6,a<[6]=24|1<2=sum a ``` [Try it online!](https://tio.run/##dY87DoMwEET7nGKKlFvExpggsSdBFFYICgo/8em4uwFHREE45c6bmdW8zPB@VpW1Bcw8TDUMs6aub/PpMX4Ok6Q6Y6lmkUh2FlubsgEjby9A15fNiCsKpIIgMzAjOOoBQTk9OvsJGyWEBE2ICHdC7MwqPLWsbuGYVEe2gbXJy8Q35P3uzajbPkV5U3JfFP9f9NsvtF0A "Haskell – Try It Online") The permutations of `[1,2,3]` are the only partitions of `6` whose product is `6`, barring `6` itself. (This assumes the inputs are non-negative, which seems to be the case for all the test cases… I’ve asked the OP about this.) [Answer] ## **PL/SQL - ~~135~~ 123 Bytes** Assuming i as an integer array input of any size: ``` if (select sum(s) = exp(sum(ln(s))) from unnest(i) s) then return 24; else return (select sum(s) from unnest(i) s); end if; ``` [Answer] # [Jq 1.5](https://stedolan.github.io/jq/), 35 bytes ``` if[1,2,3]==sort then 24else add end ``` Assumes input is an array e.g. `[2,1,3]` [Try it online!](https://tio.run/##VY7LDoIwEEXX5SuauJ0m9gHIAn@EsCChRgxpEUrc@O3WodRUlvfcM4/H0zccRAuEkBOtr1RmjQSVcpltPSCDHAoo4QIVtqFT@SYL4JseiFBZgxnkgfDdiCAuPBjq/P@Dio7YHwmsSn/8xgPnBRZplAdNtiQtf/vhFk/W9WJnR91dG2z0uGja9T3Vpvf@Yyc3WLN4xsw6jmww0@owzN2L2dVh@AI "jq – Try It Online") [Answer] # [Husk](https://github.com/barbuz/Husk), 9 bytes ``` ?K24Σ=ḣ3O ``` [Try it online!](https://tio.run/##yygtzv7/397byOTcYtuHOxYb@////z/aWMdIxzAWAA "Husk – Try It Online") ### Explanation ``` ?K24Σ=ḣ3O O Sort the input ? =ḣ3 If it is equal to [1,2,3]: K24 Return 24 Else: Σ Return the sum of the input ``` ### Previous solution Gives the wrong result to [2,2], and probably other inputs too, but it was more interesting. ``` ?ṁD→E§eΠΣ §eΠΣ Build a two-element list with the product and sum of the input ? E If the two elements are equal: (true for any permutation of [1,2,3] and the list [0,0,0] ṁD Double both elements and sum them (This is 4 times the sum: 24 for permutations of [1,2,3], 0 for [0,0,0]) Else: → Return the last element (the sum) ``` [Try it online!](https://tio.run/##ASAA3/9odXNr//8/4bmBROKGkkXCp2XOoM6j////WzMsMiwxXQ "Husk – Try It Online") [Answer] # [Pushy](https://github.com/FTcode/Pushy), 12 bytes ``` gF3RFx?18;S# ``` [Try it online!](https://tio.run/##Kygtzqj8/z/dzTjIrcLe0MI6WPn///@GOgpGOgomAA "Pushy – Try It Online") This works by sorting the input and, if it is equal to `[1, 2, 3]`, appending 18. Then, the sum is calculated and printed, yielding 24 is 18 was appended, and the normal answer otherwise. ``` \ Implicit: Input on stack. g \ Sort input ascendingly F3RF \ On auxiliary stack, push range(3) -> [1, 2, 3] x? \ If the stacks are equal: 18 \ Append 18 to the input ; S# \ Print sum of input. ``` [Answer] # [Pyth](https://github.com/isaacg1/pyth), 9 bytes ``` ?qS3SK24s ``` **[Verify all the test cases.](https://pyth.herokuapp.com/?code=%3FqS3SQ24s&test_suite=1&test_suite_input=%5B1%2C2%2C3%5D%0A%5B2%2C1%2C3%5D%0A%5B3%2C1%2C2%5D%0A%5B1%2C2%5D%0A%5B2%2C3%5D%0A%5B1%2C2%2C3%2C4%5D%0A%5B1%2C2%2C3%2C1%2C2%2C3%5D%0A%5B1%2C2%2C3%2C4%2C5%2C6%2C7%2C8%2C9%5D&debug=0)** [Answer] # [Python 2](https://docs.python.org/2/), ~~41~~ 39 bytes -1 byte thanks to [caird](https://codegolf.stackexchange.com/users/66833/caird-coinheringaahing) -1 by inspiration from [FlipTack's answer](https://codegolf.stackexchange.com/a/146197/66418) ``` lambda*a:sum(a)*4**(sorted(a)==[1,2,3]) ``` [Try it online!](https://tio.run/##Fcq9DsIgFEDhuTzFHYHcoaXVoQljXV3c1AEtTUn6Qy4Q7dMjjt/J8Uec903lST/yYtbXaKTpQ1q5EbKTkoedoh2LtL43qLB9ihzp6Fn1md1i4UbJFlSe3BZh4tJtPkUuBLPft/URhutlINqpTN6EkBsEhdCyDuGEcGY1wj/9AA "Python 2 – Try It Online") ### Alternative 39 bytes solution ``` lambda*a:sum(a)<<2*(sorted(a)==[1,2,3]) ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 9 bytes ``` Ṣ24S⁼?3R¤ ``` [Try it online!](https://tio.run/##y0rNyan8///hzkVGJsGPGvfYGwcdWvL///9oQx0FIx0F41gA "Jelly – Try It Online") -1 byte thanks to [Erik](https://codegolf.stackexchange.com/users/41024/erik-the-outgolfer) Alternative (by [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder)), also for 9 bytes: ``` 3R⁼Ṣ×18+S ``` [Try it online!](https://tio.run/##y0rNyan8/9846FHjnoc7Fx2ebmihHfz///9oQx0FIx0F41gA "Jelly – Try It Online") ## How it works ``` Ṣ24S⁼?3R¤ - Main link. Argument: l (list) Ṣ - Sort ? - Ternary if statement ⁼ - Condition: Is l equal to... 3R¤ - [1, 2, 3] 24 - If condition: Return 24 S - Else: Return the sum of the list ``` [Answer] # [Pyth](https://github.com/isaacg1/pyth), 9 bytes Different aproach from the other Pyth answer. ``` *sQ^4qS3S ``` ### Explanation: A port from my Python answer ``` *sQ^4qS3SQ # Full program (Q at the end is implicit and represents the input) * # A * B where A and B are the next two lines sQ # Sum elements of input ^4 # 4 to the power of: qS3SQ # Compares sorted input to [1, 2, 3] and returns 0 or 1 ``` [Try it online!](https://tio.run/##K6gsyfj/X6s4MM6kMNg4@P//aEMdIx3jWAA "Pyth – Try It Online") [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 44 bytes ``` param($a)($a-join'+'|iex)+18*!(diff(1..3)$a) ``` [Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVRE4h1s/Iz89S11WsyUys0tQ0ttBQ1UjLT0jQM9fSMNYFK/v//76BhqGOsY6QJAA "PowerShell – Try It Online") Similar algorithm to the Python and JavaScript answers. Takes input as a literal array `$a`. Then immediately sums `$a` together, which forms the left-hand operator of the `+`. The right-hand is the `diff` (alias for `Compare-Object`) of `1,2,3` and `$a` -- this is either an empty array if they are equal, or a non-empty array of the different items if they are not equal -- enclosed in a Boolean-not. So, if they are equal, that makes the empty array (a falsey value) into `$true`. That's then multiplied by `18` which implicitly casts `$true` to `1` and `$false` to `0`. So the right-hand side will be `18` if the arrays are the same, and `0` otherwise. That gives the correct result of `24` if the input array is `1,2,3` in any permutation, and the summation of the input array otherwise. ]
[Question] [ # Introduction The current coronavirus disease is officially named **COVID-19**, from the 3 words **co**rona **vi**rus **d**isease, and the year 20**19**. (Technically it's coronavirus, making 2 words, but whatever...) Given this example, we can apply this naming convention to name other potential diseases. # Challenge You will be given 3 words and a year. * Take the first letters of the first 2 words, up to and including the first vowel, and append them together. * Then, append the first letter of the 3rd word. * Finally, append the character `-`, followed by the last 2 digits of the year. Thus, `corona,virus,disease,2019 -> co + vi + d + - + 19 -> covid-19`. ### Challenge rules * It is guaranteed that each of the three words have at least one vowel. For the purposes of this challenge, vowels are defined as the letters `a, e, i, o, u`. * You may assume that words consist only of lowercase letters `a-z`, or only uppercase letters `A-Z` if you prefer. Your output may be in either case. * It's guaranteed that the date is exactly four digits. * Input may be specified in any format, as long as there is a delimiter between the words. For example, `['corona', 'virus', 'disease', '2019']`, `corona,virus,disease,2019`, `[['corona', 'virus'], 'disease', 2019]` and `corona virus disease 2019` are all valid inputs. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer wins. # Example test cases ``` corona,virus,disease,2019 -> covid-19 computer,addiction,syndrome,1970 -> coas-70 code,golf,fun,2020 -> cogof-20 a,ba,ca,1234 -> abac-34 tree,string,create,9000 -> trestric-00 love,time,cholera,1985 -> lotic-85 ``` [Answer] # [Python 3](https://docs.python.org/3/), ~~83~~ 81 bytes ``` lambda a,b,c,d:g(*a)+g(*b)+c[0]+"-"+d[2:] g=lambda c,*s:c[:c in"aeiou"]or c+g(*s) ``` [Try it online!](https://tio.run/##ZY/BioMwEIbvPkXISeukRLtQFOyLuB7GJLoBTSSJhbLss7uxtexhL3P4/u8fZpZH@LLmsg3N5zbh3EskCD0IkPWYnjDL4@yzXLS8yymjuWzLukvG5nAFnHwt2loQbSgqbVfaWUfEXvPZpufFukD8wyfJEPmkjYrmDs4@SG3qhBAPjjRkxiX1wUXs9AJP8@yXSYeUshvNsigeh/2X/duEl@iUj9KQHoUdLU6b8Aawr4S/HAbafsdS07ifjmabsM4ahLt2qwepvUKvoORFRdiNCHvXkhVVIuy8rEE5QCm1CNoa8A8jnZ0VFNWVv2T07MqjKxWMdhpgWE1cVR7paAdW8iQegiAQivLysQfYo2CXjyQ4pWB/0owgnMKgoOL82Y3RHgjG@S8 "Python 3 – Try It Online") *-2 bytes thanks to @JonathanAllan!* ### Explanation: `g` is a recursive function that takes in a splatted string and return the string, truncated after the first vowel. * `lambda c,*s` gather the splatted string into the first character `c` and the rest `s`. * `c[:c in"aeiou"] or c+g(*s)` evaluates to: + if `c` is a vowel, then `c[:c in"aeiou"]` evaluates to `c[:1]` which is `c`. Since `c` is Truthy, it is returned. + if `c` is not a vowel, then `c[:c in"aeiou"]` evaluates to `c[:0]` aka the empty string. The empty string is Falsy, so `c+g(*s)` (the recursive case) is returned. **Old solution, kept here for sentimental reason** ### [Python 3](https://docs.python.org/3/), 89 bytes ``` lambda a,b,c,d:g(a)+g(b)+c[0]+"-"+d[2:] g=lambda s:s[:[x in"aeiou"for x in s].index(1)+1] ``` [Try it online!](https://tio.run/##Zc/PboQgEAbwu09BOGkcNuhu0mjivoj1gICWRMEwuFnT9Nkt7p/00CPf95vJsGzhy9nzPjSf@yTmXgkioAcJqh5TkeVj2me5bHmXU0Zz1ZZ1l4zNS2KNbd3eibFUaONWOjhPjifB7mSs0ve0yPKi2828OB8Ibpgkh5mM1Q@24QmDMrZOCEHwpCGzWFIMPsbeLPCQJ1wmE1LKrjTLInwd@B/jW8ITeo0RDelr4IgWb2x4B3CshL8eBtp@x6Gm8T8dzXbpvLMCbsavCMqgFqih5EVF2JVIdzOKFVUi3bysQXsQShkZjLOAm1XezRqK6oM/sUD2waNVGkY3DTCsNq4qX@3oBlbyJB4iQAooyvPlKEQvJDtfkuC1huOTdgTptQgaKs4fs7E6Csk4/wU "Python 3 – Try It Online") [Answer] # Java 8, ~~82~~ ~~74~~ ~~71~~ ~~67~~ 61 bytes ``` s->s.replaceAll((s="(.*?[aeiou]).*,")+s+"(.).*,..","$1$2$3-") ``` -8 bytes thanks to *@ValueInk*. -6 bytes thanks to *@Nevay*. Input as a single comma-separated string like in the challenge description. [Try it online.](https://tio.run/##fVE9a8MwEN3zKw6Rwa4vwk4KJSlpKZ06NB06hgwXWQ5KbclIckoI/u2u7DjdWhDiPt5793Q60olmx/yrEyU5B@@k9GUCoLSXtiAhYdOnAJ/eKn0AEY2Bix9DvZ2Ey3nySsAGNKyhc7Mnx62sy0B@KcsocmsW8bvnLUllml3M75DFiUtCsY85Z8im2XQ@XcxY3PWi4dTNvgySo/LJqByq4Gwcvt0BxVdbhbE3R146/0pOwgq0/IYb9MKEsUYTnpRtHObKyQDCeZotGUJoVnUT3oqU50p4ZTS6s86tqSRmy4f0isklHkxZYNHowJwPVcI9oSDM5ov7PvdWSnTDVBRWkpe4TNOUtaPVsMOz87LipvG8DjBf6oi96TB@BcCSm/9hsX/BPxo/4FmiuYh@Kf9xxl47fFfb/QA) **Explanation:** ``` s-> // Method with String as both parameter and return-type s.replaceAll( // Regex-replace the match with the replacement (see below) // As match: (s="(.*?[aeiou]).*,")+s // Repeat this String twice (re-using the input-variable) +"(.).*,..", // and append this String "$1$2$3-") // And as replacement: use this String ``` *Regex explanation:* ``` (.*?[aeiou]).*,(.*?[aeiou]).*,(.).*,.. # MATCH: .* # 0 or more characters ? # which are optional to lower their priority [aeiou] # followed by a vowel ( ) # Stored in capture group 1 .* # Followed by some optional characters , # and a comma (.*?[aeiou]).*, # Same again, with capture group 2 . # Then a single character ( ) # Stored in capture group 3 .* # Followed by some optional characters , # and a comma again .. # Followed by 2 characters $1$2$3- # REPLACEMENT: $1$2$3 # The contents of groups 1, 2, and 3 - # Appended with a literal "-" ``` Note how the two trailing digits of the input-String aren't touched, and will still be there after the replacement. [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 26 bytes ``` \B.*¶\d. - ([aeiou]).*¶ $1 ``` [Try it online!](https://tio.run/##FctBCsIwEEbhfc6hUOW3JFWQbr2CSys4JtMSsIlMEsGLeQAvFuv28T3h7APVdXO@oQ6ndvv9DK5VO9VciH0s180/qZWp1UaJgfDyUhKcT0yJ0WnTKxvnZ8ksIOe8zT4GpHdwEmeG6Y96AY4xxceIsYTl6bQi3AmWYLr9QWVhRsriwwQrTJnRa61/ "Retina 0.8.2 – Try It Online") Link includes test suite. Takes lowercase words and year on separate lines, but test suite splits each test case on commas automatically for the convenience of the user. Explanation: ``` \B.*¶\d. - ``` Truncate the last word after the first character, remove the first two digits of the year, and join the two together with a `-`. ``` ([aeiou]).*¶ $1 ``` Truncate each of the first two words after the first vowel, and join everything together. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~18~~ 17 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` ḣe€ØcM$ḢƊ€⁴Ḣ”-3⁵ṫ ``` A full program accepting arguments `['word1', 'word2'] 'word3' 'year'` which prints the result. **[Try it online!](https://tio.run/##y0rNyan8///hjsWpj5rWHJ6R7KvycMeiY11AzqPGLUDmo4a5usaPGrc@3Ln6////0eolRamp6joK6sUlRZl56eqx/9WTixJLUtX/q1saGBioAwA "Jelly – Try It Online")** ### How? ``` ḣe€ØcM$ḢƊ€⁴Ḣ”-3⁵ṫ - Main Link: [word1, word2] € - for each (w in [word1, word2]): Ɗ - last three links as a monad: $ - last two links as a monad: € - for each (character, c of w): e - (c) exists in?: Øc - vowels = "AEIOUaeiou" M - maximal indices (i.e (sorted) indices of vowels in w) ḣ - head to index (vectorises across the list of indices): Ḣ - head (the first such head-to-index result) ⁴ - program's 2nd argument, word3 - ...N.B. a nilad here forces Jelly to smash the previous list - together and print to STDOUT. Ḣ - head - i.e. the first character of the third word ”- - literal '-' character - ...N.B. again a nilad here forces a print of the previous - result, the first character of the third word. 3 - literal three ⁵ - program's 3rd argument, year ṫ - tail from index (i.e. "2019" -> "19") - implicit print (of these two characters) ``` [Answer] # [Japt](https://github.com/ETHproductions/japt) v2.0a0 [`-P`](https://codegolf.meta.stackexchange.com/a/14339/), 15 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) ``` ®¯ÒZb\vÃpVÎ'-W¤ ``` Saved a byte thanks to @Shaggy (`s2` -> `¤`) [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LVA&code=rq/SWmJcdsNwVs4nLVek&input=WyJjb3JvbmEiCiJ2aXJ1cyJdCiJkaXNlYXNlIgoiOTAwMCI) ``` ®¯ÒZb\vÃpVÎ'-W¤ Input: ["corona" "virus"] "disease" "2019" ® à Map ["corona" "virus"] to Zb\v Index of first vowel in word Ò Add one ¯ Slice 0..index+1 ["co" "vi"] p Append the following: VÎ A) First letter of third word '- B) "-" W¤ C) Last two digits of year ["co" "vi" "d" "-" "19"] -P Implicit join -> "covid-19" ``` [Answer] # [Bash](https://www.gnu.org/software/bash/) + Core utilities, ~~58~~ 55 bytes ``` sed -E 's/([aeiou]).*/\1/;3s/\B.*/-/;4s/..//'|tr -d \\n ``` [Try it online!](https://tio.run/##Jcg5DoAgEADAnlfQeSSwGG2MnYmvEAvUjdJgwmLn39erm8zsaGcmXKUaZEaQjw79cU6FLsFW0NUEtn@soGsItAbIrhSlWqW1gTlFREEp@rCJJaJLKFpjzPf8P//P798 "Bash – Try It Online") *3 bytes shorter through the use of \B, thanks to user41805.* Accepts newline-delimited input on stdin. Output on stdout. [Answer] # [Python 3](https://docs.python.org/3/), 86 bytes ``` lambda t,c,y:''.join(re.sub('([aeiou]).*',r'\1',s)for s in t)+c[0]+'-'+y[2:] import re ``` [Try it online!](https://tio.run/##NVHLboMwELzzFRYX242JgESKgkSP/YLeCAdjTOoq2MiPSAjx7dRLmsvs7O7MrrWeZv9j9Gkb6tv24GPXc@SZYHOF8fHXKE2sPLrQEUwaLpUJLT1@YGbxrcDM0cFY5JDSyNODaPL2gDN8mJuyahM1TsZ6ZOXmpfMO1YgkhKTCWKN5ytKnssHF2CsnuZORlXlxTSmLkqfqs52/HOMUvLRRwfteCa@MjtzNurdmBGNxveQvI3fZTl@@Hpp38xhiGILeV5T/yrsZsvIthfd0AAKgKE9nEPGOi2ynoPFWwjjnrdJ3kFrJPVSueb7PjAJoimxPE5rYevm2QVYB30J5KU6YoS/@cO/CWeA1gQN6JvcTwpmqBHHWwQfUPkGuHgiJOYUCTdAUd3sypAtfGVo6AAEwryj7RItb0WIbV9eyXVO6/QE "Python 3 – Try It Online") Inputs the first two words in a tuple followed by the third word and then year as a string. [Answer] # [Perl 5](https://www.perl.org/) `-p`, 48 bytes ``` $p='(.*?[aeiou]).*? 'x2;s/$p(.).*(..)/$1$2$3-$4/ ``` [Try it online!](https://tio.run/##FYtBCsIwEADvvmIPgbZC0zQqUkR8iHgIzVYCaTZkG9HPG@NtBmYiJn8qRcRr08r97W7QUX50FaF56wsPIrayaitlN4hRaHHoxXEoZaZEwcDLpcxgHaNhBK3GaTfTGvOGCYy1bt4cBeBPsIlWhHE6qxpYhCf5BZYc6qPVl@K/49JH/wM "Perl 5 – Try It Online") Basically, a straight forward regex to pick out the relevant parts and put them back together. [Answer] # [QuadS](https://github.com/abrudz/QuadRS), 33 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set") Takes lowercase multi-line input. ``` ∊('-',⍨⊃)¨@3⊢⍵ ^.*?[aeiou]|\d.$ & ``` [Try it online!](https://tio.run/##KyxNTCn@//9RR5eGuq66zqPeFY@6mjUPrXAwftS16FHvVq44PS376MTUzPzSWK6YFD0VLrX//5Pzi/LzErnKMotKi7lSMotTE4tTuYwMDC0B "QuadS – Try It Online") `&` Search for and return `^.*?[aeiou]|\d.$` initial letters ending with a vowel, or a trailing digit with another character `⊢⍵` on that `(`…`)¨@3` **at** the third match:  `⊃` pick the first character  `'-',⍨` prepend a dash `∊` **ϵ**nlist (flatten) [Answer] # [Python 3](https://docs.python.org/3/), [86 bytes](https://mothereff.in/byte-counter#lambda%20a%2Cc%2Cd%3A%27%27.join%28re.sub%28%22%28%5Baeiou%5D%29.%2a%22%2Cr%22%5C1%22%2Cx%29for%20x%20in%20a%29%2Bc%5B0%5D%2B%22-%22%2Bd%5B2%3A%5D%0Aimport%20re) ``` lambda a,c,d:''.join(re.sub("([aeiou]).*",r"\1",x)for x in a)+c[0]+"-"+d[2:] import re ``` Accepts input like `["corona", "virus"], "disease", "2019"` [Try it online!](https://tio.run/##RZDBboMwEETP5SssXwLNggxEiohEf4RwMLahrsBG9hIlX09NSJTbSG92d2bnB/5aU659fV1HPnWSEw4C5OVwyP6sNrFTmV@6mMYNV9oubZJ9U3D0mlO4J7115E60ITw5ioa1R5rSo2yKSxvpabYOiVMrKo@e1IRSKqyzhsNNu8WD1F5xr6BgeUXSHyLsTcs0ryJhp3lB5YBLqQVqa8A/jHR2UpBXZ7abuU/PLHilgsGOPfSLCauKFx1snxYs4tCFOhzyojxtgHdcpOUpQqcUeHTaDCCc4qigYuw5G9AGRMpYSJz5edQ4aqN8nETRVhi3ws9Sl@hLmxDVA@Fmq4i7PabbIpq8cSC7eGPYmFMYQB83Owvvg5etyduPLj6ybMPYHEJjHO5BeC4@L9d1UMn6Dw) [Answer] # JavaScript (ES6), ~~65~~ 63 bytes Takes input as 4 distinct strings. ``` (a,b,[c],[,,d,e])=>a.match(r=/.*?[aeiou]/)+b.match(r)+c+'-'+d+e ``` [Try it online!](https://tio.run/##ZY/BaoQwEIbvfQrxsloTje7C4sH2QcTDmEQ3RTNLEoU@vU26CIvmMDMM/3x8@YEVLDfq6ahGIbeh2RIgPWl5R1pCBJFd2nxBPoPjj8Q0Rf753YJUuHRFmvX7Ps14dqGXTGRy46gtTjKfcEyGJOZoUENM4lWZxfoulJVgpZ8qVtZx9HppGhVFxHFVgpb1xwkyPxcnjT8CIRR3CrWf7a8WBufAKus7i3cIWHpnZ4YIwRGnwbdh0f8GFdsNDiIjDrQ6QcJH@lB4KGV1vR3O3yHQA6fX25HhjAwi1hmlx4AyElzY1Iy92bwYPhyCnDK2/QE "JavaScript (Node.js) – Try It Online") --- # JavaScript (ES6), 71 bytes Takes input as `["word1", "word2", "word3", "year"]`. ``` a=>'012-3'.replace(/\d/g,i=>a[i].match([,,/./,/..$/][i]||/.*?[aeiou]/)) ``` [Try it online!](https://tio.run/##bY/daoQwEEbv@xQihdViTNSFxQu3D2K9mE2im6IZSaJQ2He3Sf9o1wYyMwxfDievsILlRs2OaBRy65sNmvOBFSWpDrmR8whcJvRF0CFTzRla1eUTOH5N2iyjOfU3f6SdX99uNH96bkEqXDqaphtHbXGU@YhD0idtzNGghjiLV2UW67tQVoKVfipZUcfR5@nSNKI04rgqQYr6YY@Z5sVJ45@BEIo7hdrP9k0Lg1OgFfWJxT8YsOTE/qGIEB1w7H3rF/1hUbJvi3uZAXtS7jHhO5dQeChFWR3vAH8wcAFOquOO4owMMtYZpYcAMxJc2NSM/TL6ovh0SHLC2PYO "JavaScript (Node.js) – Try It Online") [Answer] # [Icon](https://github.com/gtownsend/icon), 95 bytes ``` procedure f(a,b,c,d) return a[1:1+upto(t:='aoeiu',a)]||b[1:1+upto(t,b)]||c[1]||"-"||d[3:0] end ``` [Try it online!](https://tio.run/##bU/NasMwDL7nKYIvdZgHdjoYCfRJQg@OrRTDYgdZ3hjk3Vurp0Kqwyeh7wcpuBTv9w2TA18Q2kVaNSunfNcgUMHY2smM5qNslCSNl5NNEMpJ2e667/MLpWbeuMlUFJ9i3/10HvW1bSD6l/zVhii7pq31h4FALlK4hClaocRvwJJr95DBZqhTr80guoN@3QoBVt56HxyFFOuc/6PHtLLNDN/6jc0zd0s/S21Lic/8/ijkU2YGx2D689dBQgiclQlDvLESwRJvBq2fgfz1Aw "Icon – Try It Online") [Answer] # perl -anE, 65 bytes ``` s/[aeiou]\K\w+// for@F[0,1];$F[2]=~s/.\K.*//;$F[3]=~s/../-/;say@F ``` [Answer] # [Zsh](https://www.zsh.org/), 41 bytes ``` <<<${(Mj::)@[1,2]#*[aeiou]}${3[1]}-${4:2} ``` [Try it online!](https://tio.run/##FcoxCsMgFADQPaf4UActDUTboRGHXqAnEAeJBi1EQZNAIp7dtvN7Z3ZtxgQ3IQQq@P3hnLwkvTF1uUptfdxUReUuqao9Kg/OaiNdN8MUUwwadp@2DMZnq7MFNtDxZ8kdq1uc1bsNoI3x0@pjgHwEk@Lyb8OzfQE "Zsh – Try It Online") Normally `${param#pattern}` is prefix removal, adding the `(M)` flag keeps the prefix instead. ``` <<<${(Mj::)@[1,2]#*[aeiou]}${3[1]}-${4:2} ${ @[1,2] } # first two args ${(M ) #*[aeiou]} # match shortest prefix ending with a vowel ${( j::) } # join the resulting words on empty string ${3[1]} # third param, first char ${4:2} # fourth param, starting at third char ``` If the first two words can be given as a single space seperated argument (as in `corona virus` `disease` `2019`), then one byte can be saved for **40 bytes**: ``` <<<${(Mj::)${=1}#*[aeiou]}${2[1]}-${3:2} ``` [Try it online!](https://tio.run/##FcrRCoMgFADQ977iwgQ1GKR72cR9wr4gepA0vIMUtIImfruj53N@2beFcda01qSwz1cpTspb1Fs/GodxnyopchRTvZPyULI23nUL0DmmGAwcmPZMwWJ2JjuQg3hdmvy5@dU7c7gAxlqcN4yBQj6DTXG94vBsfw "Zsh – Try It Online") [Answer] # [Ruby](https://www.ruby-lang.org/), 48 bytes ``` ->a,b,c,d{a[r=/.*?[aeiou]/]+b[r]+c[0]+?-+d[2,2]} ``` [Try it online!](https://tio.run/##DcxBbsMgEEbhPaf4F13FToJppcqLJAehKBrDOEVyIBqgVVTl7K7373vSpuc6n77W/Zn6qfd9@CMrp@Nhd7HEMTd3dN1kxXXeatdd9l2wpjfutf5@x4Vx41oU8Gi1YLa7t@uhPJZYneIUVp8lJ8JPlFYQYmEqDKOHUfl83wgLKIToa8wJ5ZmC5DtjGD/1FoRtnpcZc0ubMVoRJoInDOb9Q1VhRqkS0w1emCpj1Fr/Aw "Ruby – Try It Online") [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~44~~ 40 bytes Original (and more fun): `{t←{⍵↑⍨⊃⍸⍵∊'aeiou'} ⋄ ,/⍎¨'tt12',¨' ↑↓',¨⍵}` Improved: `{d←2∘↓⋄t←{⍵↑⍨⊃⍸⍵∊'aeiou'}⋄,/⍎¨'tt⊃d',¨⍵}` [Try it online!](https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtE6pLQMSj3q2P2iY@6l3xqKv5Ue8OELejSz0xNTO/VL32UXeLjv6j3r5DK9RLSgyN1HWADAUFkPq2ySAOUHUt0LD//9XV1cvzi1KAlAJOpqGlroUJkAYA)1 Takes input of form: `'''word''' '''word''' '''word''' '''dd-dd'''` This one is just a lot of fun and rather unconventional. Not necessarily the shortest, but that's the price of fun! Have a feeling `t` function can be further golfed but haven't managed to. The rest I'll leave as is because it's primarily neat; concision is secondary for once. Plus, who could possibly stomach messing with *42* bytes! I'll add the full explanation tomorrow, however in short it's all just an abuse of the fact that we were trusted to determine the input format. Thus, one can pass it to the function as data and prepend (with a couple zips) the necessary manipulations, before evaluating the pieces of the list. This requires taking strings of strings as input; In *Dyalog APL*, quotes are escaped by doubling them, so printing `'''Hello world'''` yields `'Hello world'`. Before each element is evaluated and concatenated: `{'tt12',¨' ↑↓',¨⍵}` yields `t 'corona' , t 'virus' , 1↑'disease' , 2↓'20-19'`. The two strings in the function are zipped together with the input to yield a piece of code containing the manipulations we desire for each piece. To clarify, `t` is the function which takes a string and returns the first elements until a vowel is spotted. The function `t` is defined in the right half of the code. 1Due to the dangerous 'execute' (`⍎`) operator, I've only gotten it to run online in TIO under [dzaima's](https://www.github.com/dzaima) dialect, which is the TIO page linked above. However, as long it's downloaded, it'll work in any old flavor of Dyalog, so I'm insisting on marking it as such in the title! [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 44 bytes ``` {S:g/<[aeiou]><(.*?\s//}o{S/\S<(\S*\s\d./-/} ``` [Try it online!](https://tio.run/##DcxBDoIwEEDRPaeYlSEkUkCjwaAeokvrYmxH0gQ6pKUmhHD2yv6/P5EfLmlc4PCFe1rlrRfdC8lyfD@6vCyeKgix8SqFkl2uZKGCMqU4ii0FXKDc2Zc9DNZRSJo9O4Sf9TGAsYEwEDRV3WaaxynO5AGNsXq27CAszngeCer2Wu2BIeh52HfR7aapMoQPgkaom9P5Dw "Perl 6 – Try It Online") Combination of two substitution regexes, the first to replace the third word and year with the letter dash date, and the second to remove anything between a vowel and a space (removing the space as well). [Answer] # [Erlang (escript)](http://erlang.org/doc/man/escript.html), 124 bytes ``` f(A,B,C,D)->g(A)++g(B)++[hd(C)]++"-"++string:slice(D,2). g([H|T])->case"aeiou"==("aeiou"--[H])of true->[H]++[g(T)];_->H end. ``` [Try it online!](https://tio.run/##ZU67bsMwDNz9FYYmEpIMN1tSxEAegz8gm2EUgkwrBFypkOR26b@7MtqtHMg74u5IiovxTlOykT/yVm0zXNRV3dQddefgglI6uJY@PCe44Sil0ELKlCN7d0oLW4K7OmBTORj678dYbNYkEoY4rOJ8hj@k9dCPGOY6x5V0V0jJdPDA8fVNd31Nfmq2d8Mehj2jqktxOM1fkTPBDMKGGLwRSnxyXFOZEyfaLylxaF@OAlEVvV8A1X9zjrQLf98uwEYyed8c27Yt1mb7AQ "Erlang (escript) – Try It Online") ## Explanation ``` f(A,B,C,D)->g(A)++g(B) % Slice things up to vowels for A and B ++[hd(C)] % Add the head of C ++"-"++string:slice(D,2). % Add a - and tail of D g([H|T])-> % Recursive function for the vowel slicing case"aeiou"==("aeiou"--[H])of true-> % If head isn't vowel: [H]++[g(T)]; % Return head + slicing (tail) _->H end. % Else: return head ``` ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes ``` ⭆E²S…ι⌊ΦEaeiou⊕⌕ιλλ§S⁰-✂S² ``` [Try it online!](https://tio.run/##XY3BCsIwDIbvPkXoqYUO5m7iSQbCDgNhT1Da4AJdO7p26NPX1YGihyQ/yffn16MK2iub8y2Qi3yI27j3aualGgmdm1Pct1wICe1TW2xHP3OS0JOjKU38SjZieFuYQvKJFaMOOKGLaLa7M4W3orwoXYjzYU@8xM4ZfPCfIAn1l2AV@@jBksZ/ttnYnLUP3ilYKaQFDC2oFoSmPp5ytdoX "Charcoal – Try It Online") Link is to verbose version of code. Takes lowercase words either space or newline-separated. Explanation: ``` ⭆E²S ``` For the first two words... ``` …ι⌊ΦEaeiou⊕⌕ιλλ ``` ... find the positions of the vowels, and take the minimum of those that exist, and truncate the word after that point. ``` §S⁰ ``` Print the first letter of the third word. ``` - ``` Print a `-`. ``` ✂S² ``` Input the year as a string and print the last two digits. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 55 bytes ``` 1(UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R? ``` [Try it online!](https://tio.run/##AWgAl/8wNWFiMWX//zEoVUkjdsK0eVhp0L0/fVTQuGDFvk12eWvLhn3Cr8qSMiviiaB9V0Quw69pxaDFoHM@wqM/fVg@VX0iLSI/VVIywqNSP///Y29yb25hIHZpcnVzIGRpc2Vhc2UgMjAxOQ "05AB1E (legacy) – Try It Online") I'm sure this can be optimized in so many different ways, but I'll throw it in here anyway. [Answer] # [R](https://www.r-project.org/), 106 bytes ``` function(a,b,c,y,s=substr,f=function(x)s(x,1,regexpr("[aeiou]",x)))paste0(f(a),f(b),s(c,1,1),"-",s(y,3,4)) ``` [Try it online!](https://tio.run/##PY1BisMwDEX3PYZXFqjgtDOLLnKS0oXiUYIh2MFSinP6jJJCNxJf76Ff96nfxzVHTSV7wgEjbii9rINoxbH/sgbiG3ZYeeK2VO@exKmsL4cNABYS5eBHT4CjHwDFR5M7QHd1Fja84w/APnmnSoNDF0ltasns8Ba6X7gcrLJFZ9UpT4dUmdQujxDCKbAsHBPN82Z0Kcr5@DJTI03v89OtO8VYaslk7J3qKrb/kjDJp@wB@z8 "R – Try It Online") Say hello to R's atrocious handling of strings. I wouldn't be surprised if this could be golfed significantly. [Answer] # [Red](http://www.red-lang.org), ~~94~~ 92 bytes ``` func[a b c d][g: func[t][head clear find/tail t charset"aoeiu"]rejoin[g a g b c/1"-"at d 3]] ``` [Try it online!](https://tio.run/##PU47bsMwDN19CkJ7EdspUDjH6CpoYERKVuFIAUUH6OldyUW78PM@5BOm45PJuiHcjrBnbxHu4IGcjTc4AXV2ZSTwG6NASJkuimkDHfyKUlkNFk67ccJfJWUbASH2I5fJvBlUILg6d4QijH6F/wcAdgDji5SMBswryV5bp1QZK7dpHqfFnJLHc1eWBiFR8ppKbnP9ziTl0ZXT8jH@KqmvsWyhtZb@vDKfXP9x78X3Ms3X946qcHdUlZRjJ1tI7cgyjs3mwD4bo2AD/OV2xw8 "Red – Try It Online") [Answer] # [JavaScript (Node.js)](https://nodejs.org), 64 bytes ``` (a,[b],c)=>a.map(x=>/.*?[aeiou]/.exec(x)).join``+b+'-'+c[2]+c[3] ``` [Try it online!](https://tio.run/##bc/BioMwEAbg@z6F5FJdjUYtFA92H0SEjkmUFM1IouI@vWtaCqVuDiEM/3z8ucMClhs1TlSjkFtbbj5EVVNHPCivEA8w@mt5TeLvnwqkwrlOYrlK7q9BEN9R6dstbMITPYW8yur9yuuNo7bYy7jHzm/9inA0qIFEZFFmtqSOiFBWgpX7KGNpQbznCQIvSTyOixI0Lb6OzDDOkzT7Fgih@KRQO8z@amFwcFpaXBh5MWDphf2jCJfssG/dcjvrR4uMvVp8lOmwpdmRcd9pwAncPdMsP38A7ww0wGl@PiiTka6MnYzS3QMzEiY3Khh7a/RU9rRLcsrY9gc "JavaScript (Node.js) – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 22 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` εžMySkd0šÅ¡н}Iн'-I¦¦)S ``` Inputs as `["corona","virus"]`, `disease`, and `2019`. Output as a list of characters. [Try it online](https://tio.run/##AUkAtv9vc2FiaWX//861xb5NeVNrZDDFocOFwqHQvX1J0L0nLUnCpsKmKVP/Sv9bImNvcm9uYSIsInZpcnVzIl0KZGlzZWFzZQoyMDE5) or [verify all test cases](https://tio.run/##LU29CsIwEN59CskiQoS0ClKXzgriIIoiBdMmLUFNJEmFDo4@iItvoJsOFVfxjeqlunzffT93pwyNBa8OaCj3uTWDJgoL3ECT3IKs1Xo@a1fv6@sxLqYbRl7n56k8f@7Hxefe6izLS3lpT6sRLm9htVqhRGklKcLoIHRugJkwnBqOsE@8IMJNV9nBba4hpIyJxAolYTaFZFrtoOkFffJvMpAoU9sUKM2lu@L/MvcjdpAAeH63V7tWc7dhrBYyc6Hm1IITEEKi6As). (Feel free to remove the `J`oin in the footer to see the actual output-list.) **Explanation:** ``` ε # Map over the first (implicit) input-list of strings: žM # Push the vowel constant "aeiou" y # Push the current word we're mapping over S # Convert it to a list of characters # i.e. "virus" → ["v","i","r","u","s"] k # Get the index of each character in the string (-1 if not found) # → [-1,2,-1,4,-1] d # Check for each index if it's non-negative (>= 0) # → [0,1,0,1,0] 0š # Prepend a 0 to this list # → [0,0,1,0,1,0] Å¡ # Split the string we're mapping over on the truthy indices # → ["vi","ru","s"] н # And only leave the first part # → "vi" }I # After the map: push the second input-string н # Pop and push just its first letter # i.e. "disease" → "d" '- '# Push a literal "-" I # Push the third input-integer ¦¦ # Remove its first two digits # i.e. 2019 → 19 ) # Wrap all values on the stack into a list # → [[["c","o"],["v","i"]],"d","-","19"] S # And convert it to a flattened list of characters # → ["c","o","v","i","d","-","1","9"] # (after which it is output implicitly as result) ``` [Answer] # [ssed -R](https://launchpad.net/ssed/), 70 bytes Expects input through stdin in lowercase separated by spaces, e.g., `corona virus disease 2019`. ``` s_(.+?(?![aeiou])).*? (.+?(?![aeiou])).*? (.).*? \d\d(\d\d)_\1\2\3-\4_ ``` `ssed`, known as "super sed", has PCRE which gives us non-greedy matchers. ``` (.+?(?![aeiou])).*?<space> ^^^^^^^^^^: Eats the rest of the word before the space ^^^^^^^^^^^: Before a character that is a vowel ^^^: Match fewest number of characters ``` The rest is simple enough once you understand the above. If anyone is interested I can go into more depth but I think this is enough. The try-it-online thing doesn't have `ssed` installed in Bash. To try it locally you can install `ssed` through Homebrew by `brew install ssed` if you're on a mac. If anyone knows a way to get a working try-it-online I'll add it. [Answer] # [C (gcc)](https://gcc.gnu.org/), 96 bytes ``` #define z write(1,*a++,strcspn(*a,"aeiou")+1) f(a,y)char**a;{z;z;printf("%c-%.2d\n",**a,y%100);} ``` *-13 bytes and all concerns resolved thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!* [Try it online!](https://tio.run/##XZPbbqMwEEDf@QqLKhIGt@WSpI3c/ZI0D17bpJYSOzKQikR8e3YAt5sJ0gCe4xmOMcjnvZS325PStbGaXMi3N61OCpaKLGNN62VzskkqWCy0cV1Ms4JGdSJYT@WX8Gkq@PXCL/zkjW3rJF7I58VLqT5tzICxflHkOeXDDTp1siXGnro2ukYEjrGepGJb7fg0hgak59HAo@gojE3o/TxZbHfkD4ml886KmN@R8occobf2iFU/TGmUX8553Gg1J1uv8eT1nD@4M8qfg9LZ@K5BIBgJpYxsjbMIBqW9O9QoH5T@IqdzcILXZ@wekWDVmiOyUsFKmUaLBqPg1fRWefdQFrTqDtmqYCWRlQpW0mvR4jbBSn65g/Zj0cTud38@N@O8ic2bPN1dZcHgtTJYxMBImRebgd3TEiiEKoEWm7cc0woohKqm2vKBLoFCqOVYW1ZLTFdAIdQK6CbPH2rXQCHUenru@yrQIayudj4ZP14DK885XD5IYy7a1cm8VPqKhtt8R2FWltHfZ/wis3sRjPwf9BR@iNs/ "C (gcc) – Try It Online") [Answer] # [dirt](https://github.com/0xB0C5/dirt), 38 ``` ([^,]*[aeiou]{[^,]*,})*.{[^,]*,..}'-.. ``` Accepts a comma-separated list of strings and outputs the disease name. e.g. `dirt disease.dirt -i "corona,virus,disease,2019"` prints `covid-19`. ## Explanation ``` ( [^,]* # match and output any number of non-comma characters [aeiou] # match and output a vowel { # with no output: [^,]* # - match any number of non-comma characters , # - match a comma } )* # run the above any number of times. . # match and output 1 character. { # with no output: [^,]* # - match any number of non-comma characters , # - match a comma .. # - match 2 characters } '- # output a hyphen .. # match and output 2 characters ``` [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal) `Ṫ`, 15 bytes ``` ƛA1ḟ›Ẏ;∑?h\-?2ȯ ``` [Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJ+4bmqIiwiIiwixptBMeG4n+KAuuG6jjviiJE/aFxcLT8yyK8iLCIiLCJbXCJjb3JvbmFcIixcInZpcnVzXCJdLFwiZGlzZWFzZVwiLFwiMjAxOVwiIC0+Y292aWQtMTlcbltcImNvbXB1dGVyXCIsXCJhZGRpY3Rpb25cIl0sXCJzeW5kcm9tZVwiLFwiMTk3MFwiIC0+Y29hcy03MFxuW1wiY29kZVwiLFwiZ29sZlwiXSxcImZ1blwiLFwiMjAyMFwiIC0+Y29nb2YtMjBcbltcImFcIixcImJhXCJdLFwiY2FcIixcIjEyMzRcIiAtPmFiYWMtMzRcbltcInRyZWVcIixcInN0cmluZ1wiXSxcImNyZWF0ZVwiLFwiOTAwMFwiIC0+dHJlc3RyaWMtMDBcbltcImxvdmVcIixcInRpbWVcIl0sXCJjaG9sZXJhXCIsXCIxOTg1XCIgLT5sb3RpYy04NSJd) #### Explanation ``` ƛA1ḟ›Ẏ;∑?h\-?2ȯ # Implicit input ƛ ; # Apply to both of the first two words: A1ḟ # Index of the first vowel › # Incremented to make 1-indexed Ẏ # That many characters from the start ∑ # Join into a string ?h # First character of the last word \- # Push a "-" ?2ȯ # Last two characters of the year # Implicit output of joined stack ``` [Answer] # [Python 3](https://docs.python.org/3/), ~~128~~ ~~124~~ ~~122~~ 119 bytes ``` a,b,c,d=input().split() def g(a): for i in a: if i in'aeiou':return a[:a.find(i)+1] print(g(a)+g(b)+c[0]+'-'+d[2:]) ``` [Try it online!](https://tio.run/##HYxLCsMgFAD3OcXbqZiGJF1VyEmCixc/6YOi4qfQ09u0q2EYmPSpzxjuveN4jGa0G4XUKhdTSS@6OFjn4eQo1AA@ZiCgAHgJkP8LQ0exMZVdbflKu8LJU7CchFz0kDKFyn8DefJDSLPPWrIbk3ZflRa9m5hjQHhTbgUsFYfFwTovjy8 "Python 3 – Try It Online") Pretty new, probably overcomplicated. edit 1: saved four bytes by moving a part from print() to function edit 2: saved two more bytes thanks to @surculose-sputum edit 3: another three bytes thanks to @surculose-sputum [Answer] # [FEU](https://github.com/TryItOnline/feu), 57 bytes ``` s/([^aeiou]+.).+,([^aeiou]+.).+,(.).+,\d+(\d\d)/\1\2\3-\4 ``` [Try it online!](https://tio.run/##S0st/f@/WF8jOi4xNTO/NFZbT1NPWwedCyZjUrQ1YlJiUjT1YwxjjGKMdWNM/v9Pzi/Kz0vUKcssKi3WScksTk0sTtUxMjC0BAA "FEU – Try It Online") ]
[Question] [ (Inspired by [this question](https://codegolf.stackexchange.com/q/80961/41505)) # Objective Your task is to write a program or function to print an ASCII version of the Stack Overflow logo to STDOUT ``` \|/ (-) (-) (-) (-) ``` Your program should take two inputs, referred to here as H and N. The height of the stack "container" (the parentheses) is determined by H. The number of items in the stack is determined by N. If N>H, the stack will "overflow". # Input/Output H will determine the height of the containers For example: H=1: ``` ( ) ``` H=2: ``` ( ) ( ) ``` H=3: ``` ( ) ( ) ( ) ``` H will always be at least 1 N will determine how many items are in the stack. The following examples are all H = 2: N=0 ``` ( ) ( ) ``` N=1 ``` ( ) (-) ``` N=2 ``` (-) (-) ``` N=3 ``` \ (-) (-) ``` N=4 ``` \| (-) (-) ``` N=5 ``` \|/ (-) (-) ``` N=6 ``` \|/ (-)- (-) ``` N=7 ``` \|/ (-)- (-)- ``` N will never be more than `2H+3` (In other words, the stack will never go through the ground). # Rules * No Standard Loopholes. * Your program must not produce any errors. * All test cases must pass. * You can input H and N any way you want. * I seriously doubt that your language has a built-in for this. * Each line may optionally have an extra space at the end. A blank line above a stack where N <= H is optional, as is a trailing newline. * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins! # Test Cases In addition to all of the H=2 test cases from the Input/Output section, all of the following test cases must pass: H=1, N=1 ``` (-) ``` H=1, N=5 ``` \|/ (-)- ``` H=4, N=7 ``` \|/ (-) (-) (-) (-) ``` H=5, N=0 ``` ( ) ( ) ( ) ( ) ( ) ``` ## Leaderboards Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` # Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` # Ruby, <s>104</s> <s>101</s> 96 bytes ``` If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header: ``` # Perl, 43 + 2 (-p flag) = 45 bytes ``` You can also make the language name a link which will then show up in the leaderboard snippet: ``` # [><>](http://esolangs.org/wiki/Fish), 121 bytes ``` ``` var QUESTION_ID=81167,OVERRIDE_USER=41505;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] # Pyth, ~~43~~ ~~41~~ 40 bytes ``` <" \|/"g#0hK-QJEVJs[\(?<N_Kd\-\)*<N-K3\- ``` [Try it online.](http://pyth.herokuapp.com/?code=%3C%22%20%5C%7C%2F%22g%230hK-QJEVJs%5B%5C(%3F%3CN_Kd%5C-%5C)*%3CN-K3%5C-&input=7%0A4&test_suite_input=0%0A2%0A1%0A2%0A2%0A2%0A3%0A2%0A4%0A2%0A5%0A2%0A6%0A2%0A7%0A2&debug=0&input_size=2) [Test suite.](http://pyth.herokuapp.com/?code=%3C%22%20%5C%7C%2F%22g%230hK-QJEVJs%5B%5C(%3F%3CN_Kd%5C-%5C)*%3CN-K3%5C-&test_suite=1&test_suite_input=0%0A2%0A1%0A2%0A2%0A2%0A3%0A2%0A4%0A2%0A5%0A2%0A6%0A2%0A7%0A2%0A1%0A1%0A5%0A1%0A7%0A4%0A0%0A5&debug=0&input_size=2) First pass, quick and dirty. Input to STDIN as `N\nH`. ### Explanation 1. Save the second input (height) to `J` (`JE`), and subtract it from the first input (the number of items). (`-QJE`) 2. Save the difference (number of overflowing items) to `K`. (`K-QJE`) 3. Add 1 to the number. (`hK-QJE`) 4. Take `max(0, previous)`. This is required as negative numbers would break the next step. (`g#0hK-QJE`) 5. Take at most that many letters from the string `" \|/"` to get the first line and print. (`<" \|/"g#0hK-QJE`) 6. Loop `N` over `range(0, J)`. (`VJ`) For each `N` print the concatenation of the following: (`s[`) * `"("` (`\(`) * `" "` if there are at least `N+1` free spaces in the stack (`<N_K`), `"-"` otherwise. (`?<N_Kd\-`) * `")"` (`\)`) * `"-"` if there are at least `N+4` overflowing pieces in the stack (`<N-K3`), `""` otherwise. (`*<N-K3\-`) [Answer] ## JavaScript (ES6), ~~105~~ 102 bytes @Edit: Saved 3 bytes thanks to @PatrickRoberts. ``` f= (n,h)=>` \\|/`.substr(0,n+1-h)+[...Array(h)].map((_,i)=>` (${i+n<h?` `:`-`})${i+h+3<n?`-`:``}`).join`` ; ``` ``` <div oninput=o.textContent=f(+n.value,+h.value)>n<input id=n type=number min=0 value=0>h<input id=h type=number min=0 value=0><pre id=o> ``` [Answer] # JavaScript (ES6), ~~126~~ ~~122~~ 112 bytes ``` h=>n=>' \\|/'.substr(0,(o=n-h)+1)+` ( )`[r='repeat'](0>-o?0:-o)+` (-)-`[r](o=0>o-3?0:o-3)+` (-)`[r](n<h-o?n:h-o) ``` ## Test ``` f=h=>n=>' \\|/'.substr(0,(o=n-h)+1)+` ( )`[r='repeat'](0>-o?0:-o)+` (-)-`[r](o=0>o-3?0:o-3)+` (-)`[r](n<h-o?n:h-o) document.write(`<pre>${[[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[1,1],[1,5],[4,7],[5,0]].map(a=>f(a.shift())(a.shift())).join` `}</pre>`) ``` ## Alternate Test (if your browser does not support ES6) See the test on [Babeljs.io](https://babeljs.io/repl/#?evaluate=false&presets=es2015-loose&code=f%3Dh%3D%3En%3D%3E'%20%5C%5C%7C%2F'.substr(0%2C(o%3Dn-h)%2B1)%2B%60%0D%0A(%20)%60%5Br%3D'repeat'%5D(0%3E-o%3F0%3A-o)%2B%60%0D%0A(-)-%60%5Br%5D(o%3D0%3Eo-3%3F0%3Ao-3)%2B%60%0D%0A(-)%60%5Br%5D(n%3Ch-o%3Fn%3Ah-o)%0D%0Adocument.write(%60%3Cpre%3E%24%7B%5B%5B2%2C0%5D%2C%5B2%2C1%5D%2C%5B2%2C2%5D%2C%5B2%2C3%5D%2C%5B2%2C4%5D%2C%5B2%2C5%5D%2C%5B2%2C6%5D%2C%5B2%2C7%5D%2C%5B1%2C1%5D%2C%5B1%2C5%5D%2C%5B4%2C7%5D%2C%5B5%2C0%5D%5D.map(a%3D%3Ef(a.shift())(a.shift())).join%60%0D%0A%0D%0A%60%7D%3C%2Fpre%3E%60)) and check "evaluate". ## Interesting alternate approach at 136 bytes ``` h=>n=>' \\|/'.substr(0,(o=n-h)+1)+` ( )${0>-o?0:-o} (-)-${o=0>o-3?0:o-3} (-)${n<h-o?n:h-o}`.replace(/(\n.*)(\d+)/g,(_,s,r)=>s.repeat(r)) ``` This moves the repeat amounts into the template string and uses a regexp and replace to inject the repeating groups. Unfortunately the signature for `.replace()` is just too long. [Answer] ## C++14 (lambda function), 196 Saved 1 byte thanks to Quentin. Saved 2 bytes thanks to Adam Martin. ``` #include<iostream> using namespace std;[](int h,int n){auto s=" \\|/( ) (-) (-)-"s;int t=max(min(n-h,3),0);n-=t;cout<<s.substr(0,t+1)+'\n';for(;h;h--)n-=t=n>h?2:h<=n,cout<<s.substr(4+4*t,4)+'\n';} ``` The function itself takes 157 bytes. See it in action [here](http://coliru.stacked-crooked.com/a/e29ab94fad2ff5ab). Ungolfed version: ``` [](int h, int n) { auto s = " \\|/( ) (-) (-)-"s; int t = max(min(n - h, 3), 0); n -= t; cout << s.substr(0, t + 1) + '\n'; for(; h; h--) { if (n > h) t = 2; else if (h > n) t = 0; else t = 1; n -= t; cout << s.substr(4 + 4 * t, 4) + '\n'; } }; ``` [Answer] ## CJam, 57 bytes ``` Sri:X'(*+X),W%X)X')*+X),X))f+]zN*X5*,X'-*_"\|/"\++ri<S+er ``` [Test it here.](http://cjam.aditsu.net/#code=Sri%3AX'(*%2BX)%2CW%25X)X')*%2BX)%2CX))f%2B%5DzN*X5*%2CX'-*_%22%5C%7C%2F%22%5C%2B%2Bri%3CS%2Ber&input=4%207) Could definitely use some improvement. The idea is to build a grid where the `-\|/-` cells are replaced with consecutive integers, e.g. ``` 345 (2)6 (1)7 (0)8 ``` And then to replace them with the correct characters (potentially spaces) at the end. [Answer] # Python 2, ~~101~~ ~~100~~ 98 bytes ``` def f(h,n): print" \|/"[:max(0,n-h+1)] for i in range(h):print("(-)","( )")[h-i>n]+"-"*(n>i+h+3) ``` [Answer] # JavaScript (ES6), ~~87~~ 80 bytes ``` F=(h,n)=>h?F(h-1,n-1)+` (${n>0?'-':' '})${n>2*h+2?'-':''}`:' \\|/'.substr(0,n+1) ``` Uses recursion to create the output string from the bottom up. **EDIT**: Thanks to [@Neil](https://codegolf.stackexchange.com/users/17602/neil) for shaving 7 bytes off from 87 bytes ## Original ``` (h,n)=>(E=s=>h--?E(` (${n>0?'-':' '})${--n>2*h+3?'-':''}`+s):` \\|/`.substr(0,n+1)+s)`` ``` ## Test snippet: ``` F=(h,n)=>h?F(h-1,n-1)+` (${n>0?'-':' '})${n>2*h+2?'-':''}`:' \\|/'.substr(0,n+1) h.oninput = n.oninput = () => output.innerHTML = F(+h.value, +n.value); ``` ``` <label>h <input type="number" min="0" value="0" id="h" /></label> <label>n <input type="number" min="0" value="0" id="n" /></label> <hr /> <pre id="output"></pre> ``` [Answer] # JavaScript (ES6), ~~149~~ ~~139~~ 137 bytes ``` h=>n=>` ${[(g=(j,m=1)=>` -\\|/`[(j<n)*m])(h,2),g(h+1,3),g(h+2,4)].join``}${[...Array(h)].map((_,i)=>` (${g(h-i-1)})${g(h+i+3)}`).join``}` ``` I liked @MartinEnder's idea about indexing the `-\|/` characters and I wanted to see how it would fare in ES6. Apparently I didn't do so well. Trying to figure out if this could be improved using `for...of`. ### Edits * I managed to remove regexp and the call to `.replace`, moving the indexing directly into `g()` instead. * I accidentally counted `f=` in the second byte count ## Test ``` f=h=>n=>` ${[(g=(j,m=1)=>` -\\|/`[(j<n)*m])(h,2),g(h+1,3),g(h+2,4)].join``}${[...Array(h)].map((_,i)=>` (${g(h-i-1)})${g(h+i+3)}`).join``}` document.write(`<pre>${[[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[1,1],[1,5],[4,7],[5,0]].map(a=>f(a.shift())(a.shift())).join` `}</pre>`) ``` [Answer] # Java, 186 177 bytes ``` void f(int h,int n){for(int i=0;i<h+1;i++)System.out.print((i>0?"(":" ")+(i>0?n>h-i-2?"-":" ":n>h+0?"\\":" ")+(i>0?")":n>h+1?"|":" ")+(i>0?n>h+2+i?"-":" ":n>h+2?"/":" ")+"\n");} ``` **Ungolfed** [try online](http://ideone.com/tItYmf) ``` String f(int h, int n) { String s=" "; s+=n>h+0?"\\":" "; s+=n>h+1? "|":" "; s+=n>h+2? "/":" "; s+="\n"; for(int i=0; i<h; i++) { s+="("; s+=n>h-i-1?"-":" "; s+=")"; s+=n>h+3+i?"-":" "; s+="\n"; } return s; } ``` [Answer] # Excel, 131 bytes Input taken as a tuple, Height `H` in `A1`, `N` in `B1`. Cell containing formula needs to have Text Wrapping turned on. Suggest using a Mono-spaced font. ``` =LEFT(" \|/",MAX(0,B1-A1+1))&" "&REPT("(-)- ",MAX(0,B1-A1-3))&REPT("( ) ",MAX(0,A1-B1))&REPT("(-) ",A1-MAX(0,B1-A1-3)-MAX(0,A1-B1)) ``` [Answer] # C++11, ~~155~~ ~~148~~ 145 bytes ``` void f(int h,int n){cout<<string{" \\|/",max(min(3,n-h),0)+1}<<'\n';for(int i=0;i<h;++i)cout<<(h-i<=n?"(-)":"( )")<<(i<max(n-h-3,0)?"-\n":"\n");} ``` **Ungolfed**: ``` void f(int h,int n) { cout << string{" \\|/", max(min(3, n-h), 0) + 1} << '\n'; for(int i=0; i<h; ++i) cout << (h-i <= n ? "(-)" : "( )") << (i < max(n-h-3,0) ? "-\n" : "\n"); } ``` **Usage**: ``` #include <iostream> #include <string> using namespace std; void f(int h,int n){cout<<string{" \\|/",max(min(3,n-h),0)+1}<<'\n';for(int i=0;i<h;++i)cout<<(h-i<=n?"(-)":"( )")<<(i<max(n-h-3,0)?"-\n":"\n");} int main() { int h,n; cin >> h >> n; f(h, n); } ``` [Answer] # [Vyxal](https://github.com/Lyxal/Vyxal), 34 bytes ``` ð₴-0∴`\|/`Ẏ,(\(₴¹n->\)-2↳3¹+n+⁰<-, ``` [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%C3%B0%E2%82%B4-0%E2%88%B4%60%5C%7C%2F%60%E1%BA%8E%2C%28%5C%28%E2%82%B4%C2%B9n-%3E%5C%29-2%E2%86%B33%C2%B9%2Bn%2B%E2%81%B0%3C-%2C&inputs=3%0A7&header=&footer=) ``` ð₴ # Output a space - # Difference 0∴ # or 0 if diff. is negative `\|/` # String literal Ẏ, # First (max(N - H, 0)) letters ( # Height times do... \(₴ # Output a ( ¹n- # The difference of (iteration number) and (height) > # Is greater than (N) \)- # That many -s before a ) 2↳ # Justified to the right, so space if not empty 3¹+ # 3 + (Height) n+ # Plus iteration number ⁰< # Is less than (N) - # That many -s appended to the previous string , # Output with trailing newline. ``` [Answer] # Python 3, ~~134~~ ~~121~~ ~~118~~ 111 bytes ``` def f(h,n):print('\|/'[:max(0,n-h)]+'\n'+'\n'.join('(-)-'if h<n-x-3else('(-)','( )')[x+n<h] for x in range(h))) ``` Test it here: <https://repl.it/CYL1/0> Un-golfed: ``` def f(h,n): top=['\|/'[:max(0,n-h)]] stack=['( )'if x+n<h else'(-)'for x in range(h)] overflow=top+stack v=n-3 while v>h: overflow[h-v]+='-' #add side overflow v-=1 print('\n'.join(overflow)) ``` ~~I'd like to have added the side overflow to the list comprehension, but I couldn't squeeze it in, so I had to go with the while loop.~~ Saved 13 bytes! [Answer] # [Perl 5](https://www.perl.org/), 91 bytes ``` say((' \|/'=~/./g)[0..-($a=<>)+($b=<>)]);say$b<=$a-$_?'( )':'(-)'.'-'x($b-2>$a+$_)for 1..$a ``` [Try it online!](https://tio.run/##FcpBCsIwEADAu6/IYWF3KbtJhFy0qS/wBSolBRWhmNJ6sFB8urGe5jLDdexDKVOaidCcF4vxY9Xe@eRUhSDFuuGKoPt74f0aoasjJIH2gGQYd0jCqCj4XptsG0gVtHzLo/GqkEoJG@@/eXg98nMqcgzqvPsB "Perl 5 – Try It Online") [Answer] # [Pip](https://github.com/dloscutoff/pip), 50 bytes ``` Ps.(0Xa."\|/")@<bDC0Fi,aP"()"WV"- "@[b<a-ib<a+4+i] ``` [Try it online!](https://tio.run/##K8gs@P8/oFhPwyAiUU8ppkZfSdPBJsnF2cAtUycxQElDUyk8TElXQckhOskmUTcTSGibaGfG/v//3@S/BQA "Pip – Try It Online") Ugh, this is too long... don't know how to shorten it any more, though. Cyclical indexing, which is usually helpful, cost extra bytes this time. [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~109~~ ~~108~~ 104 bytes ``` param($n,$h)-join" \|/"[0..(($d=$n-$h),0)[$d-lt0]] 1..$h|%{("( )","(-)")[$h-$_-lt$n]+"-"*($h+$_+2-lt$n)} ``` [Try it online!](https://tio.run/##HcpBCsIwEEDRvacIwwgzJhNjF@48SQ2l0EKUmJYquGh79jG4/e/P03dc3mnMWXXul/5FWBwmluf0KGDu2xna4D0RDjcsUsUFbnGQ/AkxHi7eY9qOKwEZBgckDJWTYFcPLNGCwIkwWexs80@8q@rVND8 "PowerShell – Try It Online") Lost a lot on expensive indexing but still decent-ish. I'm not sure my index math is optimal however. Stole some logic from the other answers to save a byte. Also remembered precedence to pop some parens for -4 bytes. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 45 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` -U…( )¸¹иε²N›ið'-:]RεX4-N@i'-«]" \|/"XdX*>£š» ``` Can definitely be golfed.. Not too happy about it in its current form tbh. [Try it online](https://tio.run/##AUkAtv9vc2FiaWX//y1V4oCmKCApwrjCudC4zrXCsk7igLppw7AnLTpdUs61WDQtTkBpJy3Cq10iIFx8LyJYZFgqPsKjxaHCu///Mwo4) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WqVMZlBB2aGXkf93QRw3LNBQ0D@2IvLDj3NZD6/weNezKPLxBXdeqtjbo3NYIE10/h0x13UOra2uVFGJq9JUiUiK07A4tPrrw0O7/Ooe22f@PjjbUMYjViTYGk0Y6hmDSGEyagkkzIGkIFjcEi5jomANJU7B6Ux1DiGaL2FgA). **Explanation:** ``` - # Subtract the 2nd (implicit) input `n` from the 1st (implicit) input `h` # i.e. `h`=3, `n`=8 → 5 U # Pop and store it in variable `X` …( ) # Push string "( )" ¸ # Wrap it into a list: ["( )"] ¹и # Repeat it the first input (`h`) amount of times # i.e. 3 → ["( )","( )","( )"] ε # Map each to: ²N›i # If the second input `n` is larger than the map-index N: # i.e. `n`=8 >= N=0 → 1 (truthy) ð'-: '# Replace the space with a "-" # i.e. "( )" → "(-)" ] # Close both the if and map R # Reverse the list ε # Map each to: X4-N@i # If `X` minus 4 is larger than or equal to the map-index N: # i.e. `X`=5 and N=0 → 5-4 >= 0 → 1 (truthy) # i.e. `X`=5 and N=2 → 5-4 >= 2 → 0 (falsey) '-« '# Append a "-" ] # Close both the if and map " \|/" # Push String " \|/" Xd # Check if `X` is 0 or positive (0 if negative, 1 if 0 or positive) # i.e. `X`=5 → 1 (truthy) X* # Multiply it by `X` # i.e. 1 * 5 → 5 > # Increase it by 1 # i.e. 5 → 6 £ # Take that many character of the string " \|/" # i.e. 6 → " \|/" š # Prepend it to the list # i.e. ["(-)-","(-)-","(-)"] and " \|/" → [" \|/","(-)-","(-)-","(-)"] » # Join the list by newlines (and output implicitly) # i.e. [" \|/","(-)-","(-)-","(-)"] → " \|/\n(-)-\n(-)-\n(-)" ``` ]
[Question] [ ## Rules You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$. These points occupy a plane that is infinite in all directions. At any step in the process you may do any of the three following actions: 1. Draw a line that passes through two points. 2. Draw a circle centered at one point such that another point lies on the circle. 3. Add a new point where two objects (lines and circles) intersect. Your goal is to create 5 points such that they form the vertices of a [regular pentagon](https://en.wikipedia.org/wiki/Pentagon#Regular_pentagons) (a convex polygon with 5 sides equal in length) using as few circles as possible. You may, of course, have other points but 5 of them must for a regular pentagon. You do not have to draw the edges of the pentagon for your scoring. ## Scoring When comparing two answers the one that draws fewer circles is better. In the case of a tie in circles the answer that draws the fewest lines is better. In the case of a tie in both circles and lines the answer that adds the fewest points is better. ## Anti-Rules *While the rules list is exhaustive and details everything you can do, this list is not. Just because I don't say you can't do something does not mean you can.* * You cannot create "arbitrary" objects. Some constructions you will find will do things like add a point at an "arbitrary" location and work from there. You cannot add new points at locations other than intersections. * You cannot copy a radius. Some constructions will involve taking a compass setting it to a radius between two points and then picking it up and drawing a circle elsewhere. You cannot do this. * You cannot perform limiting processes. All constructions must take a finite number of steps. It is not good enough to approach the answer asymptotically. * You cannot draw an arc or part of a circle in order to avoid counting it as a circle in your scoring. If you want to visually use arcs when showing or explaining your answer because they take up less space go ahead but they count as a circle for scoring. ## Tools You can think through the problem on [GeoGebra](https://www.geogebra.org/graphing). Just go over to the shapes tab. The three rules are equivalent to the point, line and circle with center tools. ## Burden of Proof This is standard but I would like to reiterate. If there is a question as to whether a particular answer is valid the burden of proof is on the answerer to show that their answer is valid rather than the public to show that the answer is not. ## What is this doing on my Code-Golf site?! This is a form of [atomic-code-golf](/questions/tagged/atomic-code-golf "show questions tagged 'atomic-code-golf'") similar to [proof-golf](/questions/tagged/proof-golf "show questions tagged 'proof-golf'") albeit in a bit of a weird programming language. There is currently [a +22/-0 consensus on the meta](https://codegolf.meta.stackexchange.com/a/16689/56656) that this sort of thing is allowed. [Answer] # 2 circles, 13 lines, 17 points [![picture](https://i.stack.imgur.com/9YnhL.png)](https://i.stack.imgur.com/9YnhL.png) [Try it on GeoGebra](https://www.geogebra.org/geometry/c4ttfqt6) * Let circle(A, B) intersect circle(B, A) at C and D. * Let AB intersect circle(A, B) again at E. * Let AB intersect circle(B, A) again at F. * Let AD intersect circle(A, B) again at G. * Let AD intersect CF at H. * Let BG intersect DF at I. * Let HI intersect circle(A, B) at J and K. * Let BG intersect EJ at L. * Let BJ intersect EG at M. * Let BG intersect EK at N. * Let BK intersect EG at O. * Let LM intersect circle(A, B) at P and S. * Let NO intersect circle(A, B) at Q and R. Then EPQRS is a regular pentagon. ### Why it works Let BE intersect GJ at T, and let BE intersect GK at U. The complete quadrilateral BEGJ shows that T is the [polar](http://mathworld.wolfram.com/Polar.html) of LM, which is the intersection of the tangents at P and S. Similarly, the complete quadrilateral BEGK shows that U is the polar of NO, which is the intersection of the tangents at Q and R. Let FG intersect HI at V. The diagonals DV and GI of the complete quadrilateral DGVI intersect FH at [harmonic conjugates](https://en.wikipedia.org/wiki/Projective_harmonic_conjugate) with respect to F and H; since the first is at ∞, the second is the midpoint C of FH, which is to say that C, D, V are collinear. Let CG intersect HI at W. [![picture](https://i.stack.imgur.com/3LY56.png)](https://i.stack.imgur.com/3LY56.png) Now for the fun part. Line FUBAT is [perspective](https://en.wikipedia.org/wiki/Perspectivity) about G to line VKIHJ, which is perspective about D to circle CKDGJ, which is perspective about C to line HKVWJ, which is perspective about G to line AUF∞T. Composing these four perspecitivities yields a [projectivity](https://en.wikipedia.org/wiki/Projectivity) FUBAT ⌅ AUF∞T. Since a one-dimensional projectivity is determined by three points, T and U are determined as the two fixed points of FBA ⌅ AF∞. Assigning coordinates with A = 0, B = −1, F = −2, this projectivity is defined by *x* ↦ 4/*x* + 2, and its fixed points T = 1 + √5 = sec(2π/5) and U = 1 − √5 = −sec(2π/10), exactly as required to make EPQRS a regular pentagon. [Answer] # ~~7~~ 6 circles, 3 lines This is a classical pentagon construction, a proof of its correctness can be found [here](https://math.stackexchange.com/a/95614/109451). [![enter image description here](https://i.stack.imgur.com/Nxqrp.gif)](https://i.stack.imgur.com/Nxqrp.gif) [Answer] # 4 circles, 7 lines Since it has been beaten I thought I would just post my original solution to the problem. This solution is modified from the method given by Dixon in *Mathographics*, a proof of correctness for that method can be found [here](https://math.stackexchange.com/a/95614/276060). * Draw \$\mathrm{Circle}(A,B)\$ * Draw \$\overline{AB}\$ * Mark the intersection of \$\mathrm{Circle}(A,B)\$ and \$\overline{AB}\$ as \$C\$ * Draw \$\mathrm{Circle}(B,C)\$ * Draw \$\mathrm{Circle}(C,B)\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\mathrm{Circle}(B,C)\$ as \$D\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{AB}\$ as \$E\$ * Draw \$\overline{DC}\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{DC}\$ as \$F\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\mathrm{Circle}(B,C)\$ as \$G\$ * Draw \$\overline{BG}\$ * Mark the intersection of \$\overline{BG}\$ and \$\overline{EF}\$ as \$H\$ * Draw \$\overline{HC}\$ * Mark the intersection of \$\overline{HC}\$ and \$\mathrm{Circle}(C,B)\$ as \$I\$ * Draw \$\overline{IA}\$ * Mark the intersection of \$\overline{IA}\$ and \$\mathrm{Circle}(A,B)\$ as \$J\$ * Draw \$\mathrm{Cirlce}(I,J)\$ * Mark the intersection of \$\mathrm{Circle}(I,J)\$ and \$\overline{HC}\$ as \$L\$ * Mark the intersections of \$\mathrm{Circle}(I,J)\$ and \$\mathrm{Circle}(C,B)\$ as \$M\$ and \$K\$. * Draw \$\overline{ML}\$ * Draw \$\overline{KL}\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{ML}\$ as \$N\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{HC}\$ as \$O\$ * Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{KL}\$ as \$P\$ \$MKPON\$ is a regular pentagon. [![Drawing](https://i.stack.imgur.com/xs63F.png)](https://i.stack.imgur.com/xs63F.png) ]
[Question] [ Given a single letter from A to Z (except J and K) as input, output the smallest non-negative integer containing that letter in its written form. Assume numbers never contain the word "and", so `101` is "one hundred one", not "one hundred and one". Assume American (short-scale) counting, so one million is `10^6` and one billion is `10^9`. ``` a 1000 one thousand b 1000000000 one billion c 1000000000000000000000000000 one octillion d 100 one hundred e 0 zero f 4 four g 8 eight h 3 three i 5 five j k l 11 eleven m 1000000 one million n 1 one o 0 zero p 1000000000000000000000000 one septillion q 1000000000000000 one quadrillion r 0 zero s 6 six t 2 two u 4 four v 5 five w 2 two x 6 six y 20 twenty z 0 zero ``` J and K are not part of the input specification, so your behavior is undefined for them. Given one of the above letters, output the (decimal) number next to it. You can take input in lowercase or uppercase, but you cannot require that some inputs are lowercase and others uppercase. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins. [Answer] # [JavaScript (Node.js)](https://nodejs.org), ~~78 75 74~~ 73 bytes ``` c=>(n=([x]=Buffer(c+'8>P7 $(#% +;! MD &"$%"&4 '))[x-96]-53)<0?n+21:10**n ``` [Try it online!](https://tio.run/##BcFJDoIwFADQq3yRoQVpwFmxmBi3Ju4JCywtYqBFJtHL1/de2Zh1rC2b3pcq51pQzWiMJEXJlNLLIARvEfOcfXzfgYnmFoAXzeB2BdswLcNeg4NxMvmHbepvVvgUnKW3DI9h4LpSRwkhxMkeLOeieJZVLVXzbrt@GD/T9@ekpM4axIDGwJTsVMVJpQrEFiAQwxjrPw "JavaScript (Node.js) – Try It Online") ### How? Each value is encoded with a single printable character. We use the ASCII range \$[32..52]\$ to encode \$n-32\$ and the range \$[53..80]\$ to encode \$10^{n-53}\$. ### Commented ``` c => // c = input character ( n = // ( [x] = // let x be the 1st byte of the Buffer( // buffer made of: c + // c followed by '8>P7 $(#% +;! MD &"$%"&4 ' // the encoded values ) // )[x - 96] // let n be the encoded value corresponding to c - 53 // minus 53 ) < 0 ? // if n is negative: n + 21 // return n + 21 : // else: 10 ** n // return 10 ** n ``` [Answer] # [Stax](https://github.com/tomtheisen/stax), 33 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` º░¡µ?Äz*B╥╪╩ΓoΣ4ù↓|♂5%⌡ÿΩ²┼h{☻4O└ ``` [Run and debug it](https://staxlang.xyz/#p=a7b0ade63f8e7a2a42d2d8cae26fe43497197c0b3525f598eafdc5687b02344fc0&i=a%0Ab%0Ac%0Ad%0Ae%0Af%0Ag%0Ah%0Ai%0Al%0Am%0An%0Ao%0Ap%0Aq%0Ar%0As%0At%0Au%0Av%0Aw%0Ax%0Ay%0Az&a=1&m=2) ### Procedure: 1. Extract codepoint from input. 2. Index into constant array `[3, 5, 7, 9, 11, -6, 1, 0, -24, -15, 0, 6, 2, 4, 5, 2, 6, 20, 0, -3, -9, -27, -2, 0, 4, 8]` using codepoint. (with wrap-around) 3. If the result is negative, negate and raise `10` to that power, otherwise leave as-is. [Answer] # [Ruby](https://www.ruby-lang.org/), 65 bytes ``` ->n{i="CI[B?;7<:??4F>?XO?9=;:=9+?"[n.ord-65].ord-64;i>0?10**i:~i} ``` [Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOtNWydkz2sne2tzGyt7exM3OPsLf3tLW2srWUtteKTpPL78oRdfMNBZCm1hn2hnYGxpoaWVa1WXW/tewd9TTs4/S1MtNLKiuyaopUIjO0kmLzoqNrf0PAA "Ruby – Try It Online") Improvements inspired by GB's comment. # [Ruby](https://www.ruby-lang.org/), 70 bytes ``` ->n{i="ci}b@DHCE@@KfA@xo@FBDEBFT@"[n.ord-65].ord;i>96?10**(i-96):i-64} ``` [Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOtNWKTmzNsnBxcPZ1cHBO83RoSLfwc3JxdXJLcRBKTpPL78oRdfMNBZEW2faWZrZGxpoaWlk6lqaaVpl6pqZ1P7XsHfU07OP0tTLTSyorsmqKVCIztJJi86Kja39DwA "Ruby – Try It Online") [Answer] # [///](https://esolangs.org/wiki////), 125 bytes ``` /:/\/\///T/000:d/100:a/d0:m/aT:b/aTT:q/bTT:p/qTTT:c/pT:e/0:f/4:g/8:h/3:i/5:l/11:n/1:o/0:r/0:s/6:t/2:u/4:v/5:w/2:x/6:y/20:z/0/ ``` [Try it online!](https://tio.run/##DYpHDsNADAPv/AzXTkHAd@wxF3c7cc26f94RBA0JaUKbhLoI10XxbUN6OueUMzImzJ06Jl6pwWtiahw5eYuMo1dBp5J3VXyp5k0NH2oZReoZabDnzzbwqZmxFhNXEzbru90Oxk4nHa8EKTLkKFCiQo0GH3zRokOPASMm/BAwY8GKDTsOnNcf "/// – Try It Online") Input is appended to the end of the code, as per [I/O meta](https://codegolf.meta.stackexchange.com/a/10553/86422). The footer in the above TIO link tests all letters simultaneously, as a single newline-delimited string, but the code also works just fine when inputting [a single character](https://tio.run/##DYpJDsJADASfVJ6wCPU7fOQyWSBIARIGCPD5wbJc3bKrTLmMQ6kVcYwBx8zUk4KZ3nQlu9qAa6ENziwe0TG7Bkwntjpz0MhGF3aaSEk3ku7xfMQW9nrS6BXiO4Q1@iduXxrTD6Or9Q8). [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 50 bytes Letters b, c, m, p and q are skipped for performance reasons when testing on TIO. ``` (i=0;While[1>StringCount[IntegerName@i,#],i++];i)& ``` [Try it online!](https://tio.run/##Pcu9CsIwGIXh3asoEURpBl3tDwWl4CKCgkPIEDRtP2gTqKlGS689HhAcnuXlnE65RnfK0U2FMgtLytbJtaFWi01@dj2ZemcH48TBOF3r/qg6XRCfS05xLBNaLcLeihN2Tlzs71D4NGfbiKX5v5TCS8mj0fORKcbZHTRUUEMDBC0YsNDDAxwM8IQXeHjDh02TnIUv "Wolfram Language (Mathematica) – Try It Online") [Answer] # Excel, 85 bytes ``` =CHOOSE(CODE(A1)-96,1E3,1E9,1E27,100,,4,8,3,5,,,11,1E6,1,,1E24,1E15,,6,2,4,5,2,6,20,) ``` 2 Golfy bits: * Using exponents (e.g. `1E15`) saves `26 bytes`. * Default of `CHOOSE` when nothing is provided is `0`, saves `4 bytes` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 36 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` •—ßusδtθ}™-5„©‘öæH•57в₆-sÇ`èD0‹iÄ° ``` Port of [*@recursive*'s Stax answer](https://codegolf.stackexchange.com/a/191242/52210). Input in lowercase. [Try it online](https://tio.run/##AUwAs/9vc2FiaWX//@KAouKAlMODw4XCuHVzzrR0zrh94oSiLTXigJ7CqeKAmMO2w6ZI4oCiNTfQsuKChi1zw4dgw6hEMOKAuWnDhMKw//9h) or [verify all test cases](https://tio.run/##AVoApf9vc2FiaWX/QXZ5PyIg4oaSICI/ef/igKLigJTDg8OFwrh1c860dM64feKEoi014oCewqnigJjDtsOmSOKAojU30LLigoYtc8OHYMOoRDDigLlpw4TCsP99LP8). **Explanation:** ``` •—ßusδtθ}™-5„©‘öæH• # Push compressed integer 3133432551338094772548436198140408157771728287 57в # Converted to base-57 as list: [39,41,43,45,47,30,37,36,12,21,36,42,38,40,41,38,42,56,36,33,27,9,34,36,40,44] ₆- # Subtract 36 from each: [3,5,7,9,11,-6,1,0,-24,-15,0,6,2,4,5,2,6,20,0,-3,-9,-27,-2,0,4,8] sÇ` # Swap to take the input, and convert it to its unicode value è # Index it into the list (with automatic wraparound) D0‹i # Create a copy, and if this is negative: Ä # Take the absolute value ° # And then take 10 the power this value # (implicitly output the top of the stack as result) ``` [See this 05AB1E tip of mine (section *How to compress large integers?* and *How to compress integer lists?*)](https://codegolf.stackexchange.com/a/166851/52210) to understand why `•—ßusδtθ}™-5„©‘öæH•` is `3133432551338094772548436198140408157771728287` and `•—ßusδtθ}™-5„©‘öæH•57в` is `[39,41,43,45,47,30,37,36,12,21,36,42,38,40,41,38,42,56,36,33,27,9,34,36,40,44]`. [Answer] # [Perl 5](https://www.perl.org/) `-p`, 84 bytes ``` $_=(1e3,1e9,1e27,100,0,4,8,3,5,1,1,11,1e6,1,0,1e24,1e15,0,6,2,4,5,2,6,20,0)[-65+ord] ``` [Try it online!](https://tio.run/##FYtJC8IwFITv8zs8KL5C0jZRDx7c17rvIoIYJFDaUPv7ja/MwneYcaZIlfe1Z7cuTUTSdDhhi6QQJCimNkWkSFZiG80gqkXMJRWzppBnipuJP417oFUzL94P73voY4AhRhhjgilmmGOBJRKssMYGW@ywxwFHnHDGBVfcfrkrbZ59fZC87MdmpQ9c@gc "Perl 5 – Try It Online") [Answer] # [Python 3](https://docs.python.org/3/), 103 bytes ``` lambda x:(1000,10**9,10**27,100,0,4,8,3,5,0,0,11,10**6,1,0,10**24,10**15,0,6,2,4,5,2,6,20,0)[ord(x)-97] ``` [Try it online!](https://tio.run/##JYpNDsIgGAX3noJdoflMgP438STqogWxTVpArNp6eaS4mTfJG7stg9GZV6eLn7q5lx1aW8wopcBomjaRvApDgUIONWRQwO6Mxa8EBv@W53HYfpfAQ1wEBgs1ORsn8UqOTXX1yjgk0KhR0vVC3tR9GKdZG/twz@X1/qzbN2kPyLpRL1gAUlgQ4n8 "Python 3 – Try It Online") [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~77~~ ~~74~~ 68 bytes ``` x=>((x="1‘Ʊ! aƁñ"[x-65])&15)*Math.Pow(10,x>>4) ``` Encodes each letter's output as \$a \times 10^b\$, where \$a\$ is represented by the lowest 4 bits of the character, while \$b\$ is represented by the next five bits after that. Uses capital letters. **Commented** ``` x=> //Lambda taking in a char (x= ) //Re-assign x to "1‘Ʊ! aƁñ"[x-65] //The character's value at index x-65 ( &15) //Bitwise AND by 15 * Math.Pow(10,x>>4) // Multiplied by 10**(floor(x/16)) ``` [Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpdsk5yRWKSTkl@alJNql2b7v8LWTkOjwlbJ8NDEYxsVBVg4mFkVFLgTGQWONR7eKMDGxMLKxCYkoBRdoWtmGqupZmiqqeWbWJKhF5BfrmFooFNhZ2ei@d@aKy2/SANkskKmgq2CuqO6NZBhA2RFgVja2poK1VycmWkKGkBpoKi3ukJNjQKE7aWuqRBelFmS6pOZlwqU11ZQslIozUtJTQPyU5Q0rbk4U3OKUzHVKAGpNI1MTaCK2v8A "C# (Visual C# Interactive Compiler) – Try It Online") [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 67 bytes ``` {/\-/??10**-$_!!$_}o{'`ZHacgkfhccn]dcKTciegheiwc'.ords[.ord-97]-99} ``` [Try it online!](https://tio.run/##jZJfT8IwFMXf@ynuImHKsn@oKDHCq4mvPikER9etla2FdgMH4bNPpiOaIN3uQx@aX@85OadLIpNBmRbQjeARyp07sd3x2Pd6PbszM4zObC925vvrU4DjRUQx5tMQP79gRmJK2AabjpCheqtOe3g3tYfDfamCApzDukhIMAPTccyt@YAuquuEcaJGI6e7u0xdz7MOUnbHdbBI54Zhpe4ktNwr67DEwVSqMgDf8zw4P4ITyKjIVcBDNP@mf@YsPWdJwgRH@A98OjUscFbjYYVDgxOa81CSEBHQogBbIgWK4EZPRSKXKIZ7PUVYTDNE4VqPZVQSghjcNmiyNUEfgBYoAd/XCydkTThKj0HqkknrGDnod1YwEq3iW54v8FdXkeWxwdUJ/4/PVR6Esn4gW9lQMNBTin2iDPoN7WwEylv9h3WrBjdtBD/bWC@g7zVsIjwr0LZNWl8 "Perl 6 – Try It Online") Uses a lookup table where a negative number means that is the negative of the exponent, otherwise it is the number itself. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 32 bytes ``` •н“вüQ;æ¡ζæÀÛß%aÜ×₃t•56вsCè2‰`i° ``` [Try it online!](https://tio.run/##AVsApP9vc2FiaWX/QXZ5PyIgLT4gIj95/@KAotC94oCc0LLDvFE7w6bCoc62w6bDgMObw58lYcOcw5figoN04oCiNTbQsnNDw6gy4oCwYGnCsP99LP//LS1uby1sYXp5 "05AB1E – Try It Online") ``` •н“вüQ;æ¡ζæÀÛß%aÜ×₃t•56в # compressed list: # [31, 0, 12, 4, 8, 10, 4, 12, 40, 0, 7, 19, 55, 5, 0, 8, 16, 6, 10, 1, 1, 22, 13, 2, 0, 49] s # swap so the input is at the top C # parse input as "binary" (a -> 36, b -> 37, ...) è # index (wraps around) 2‰ # divmod 2: [n / 2, n % 2] ` # dump both on the stack i # if the modulo is 1: ° # 10 ** the quotient # implicit output ``` [Answer] # [Bash](https://www.gnu.org/software/bash/), ~~129~~ 100 bytes ``` A=xDVw04835zzbA10SJ0624526k0 c=$[64#${A:$[64#$1-10]:1}] [ $c -gt 30 ]&&printf 1%0$[c-30].0f||echo $c ``` [Try it online!](https://tio.run/##S0oszvj/39G2wiWs3MDEwti0qirJ0dAg2MvAzMjE1Mgs24Ar2VYl2sxEWaXa0QrCMNQ1NIi1MqyN5YpWUElW0E0vUTA2UIhVUysoyswrSVMwVDVQiU7WNTaI1TNIq6lJTc7IB6r7//9/DgA "Bash – Try It Online") ~~[Try it online!](https://tio.run/##S0oszvj/39G2wiWs3MDEwti0qirJ0dAg2MvAzMjE1Mgs24Ar2VYl2sxEWaXa0QrCMNQ1NIi1MqyN5UrLL9LQsFaJTrYxNoi11tSsVkhNzshXUEm2Tq3ILLGu5SooyswrSVMwRKi0A6lM1tUFKYbKGljX/v//Pw0A "Bash – Try It Online")~~ ### How it works: ``` A=xDVw04835zzbA10SJ0624526k0 ``` $A: Base64 encoded "a"-"z": numbers less than 100 are stored directly. Larger numbers are encoded as the number of zeros +30. (ex: 1,000 = 33, 100 = 32, etc.) ``` c=$[64#${A:$[64#$1-10]:1}] ``` Extract one letter from $A at position specified in argument $1 (base64 decoded, -10 to account for offset of 'a'). Base64 decode that character and store in c. ``` [ $c -gt 30 ]&&printf 1%0$[c-30].0f||echo $c ``` If $c is greater than 30, print "1" padded with $c-30 zeros. Else, print $c. [Answer] # [Sledgehammer](https://github.com/tkwa/Sledgehammer), 17 bytes Technically, this is 133 bits long, but that doesn't really make this 16.625 bytes, as the compressor claims. ``` ⣜⢍⢞⢹⡱⡋⣽⡱⡆⢺⢦⡽⡐⡌⢗⠈⣵ ``` This probably decodes to ``` x1 = Input[]; x2 = 0; While[StringFreeQ[IntegerName[x2], x1], x2++]; Print[x2] ``` (approximately the same as my Mathematica answer), although I barely got it encoded (it appears as though my PC has compatibility issues with everything), so good luck decoding it again to check. I might have made some mistakes while using the encoder, so be careful. [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 11 bytes ``` λ∆ċ‛λ¬-?c;ṅ ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwizrviiIbEi+KAm867wqwtP2M74bmFIiwiIiwiZlxuZ1xuaFxubFxueSJd) Very literal implementation of the title. ## Explained ``` λ∆ċ‛λ¬-?c;ṅ λ ;ṅ # The first number ∆ċ‛λ¬- # (converted to words, with any "and"s removed) ?c # to contain the input ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 36 bytes ``` Oị“[@ịẆþĊ`o&÷ḲḞṘḂỊP¥t’b48¤_⁹⁵*ɗ¹>?20 ``` [Try it online!](https://tio.run/##AWQAm/9qZWxsef//T@G7i@KAnFtA4buL4bqGw77EimBvJsO34biy4bie4bmY4biC4buKUMKldOKAmWI0OMKkX@KBueKBtSrJl8K5Pj8yMP874oCcIC0@IOKAnTvDhwrDmGHDh@KCrFn/ "Jelly – Try It Online") A monadic link taking a lower case letter as its argument and returning an integer. Returns `0` for `j` and `k`. ## Explanation ``` O | Convert to code point ị ¤ | Index into following as a nilad (wraps around): “[...t’ | - Integer 5370441668223940717846370165240010583188867 (stored base 250) b48 | - Convert to base 48 ɗ >?20 | If >20, following as a dyad using 20 as right argument: _⁹ | - Subtract right argument (20) ⁵* | - 10 to the power of this ¹ | Else: leave unchanged (identity function) ``` [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 89 bytes ``` ^ $' T`l`111104835__111011062452620`^. T`abcm\pq`139285 \d$ $*0$&$*0$&$*0 d 00 T`\lyl`10_ ``` [Try it online!](https://tio.run/##NYxLDoIwAET37xz1ExemlE/wBF7AZQMtH5UEEBA/ePlaF04mk8nkZaZ6bnrrVtujcRliw8m0JvCSURrGef5r3omKYpUoabK9J2xRdnoYTRAeVBqjK4HYSbH@BxVSek63iz@TuXOWgtLPNWcuXGlo6ei5MTAycWfmwZMXbxY@Xw "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation: ``` ^ $' ``` Duplicate the input. ``` T`l`111104835__111011062452620`^. ``` Change the first copy to the (first) digit of the relevant result. ``` T`abcm\pq`139285 ``` If the number has a multiple of 3 trailing zeros, get that multiple now. ``` \d$ $*0$&$*0$&$*0 ``` And actually convert it into the relevant number of trailing zeros. (Note that this would simplify to `*3*0` in Retina 1.) ``` d 00 ``` Fix up `d`. ``` T`\lyl`10_ ``` Fix up `l` and `y` and remove any remaining letters. [Answer] # [PHP](https://php.net/), 104 bytes ``` <?=A<($a='^FX]0483500GC10UL0624526P0'[ord($argn)-97])?20==($b=ord($a)%30)||11==$b?$b:str_pad(1,$b,0):$a; ``` [Try it online!](https://tio.run/##JcrJCsIwFAXQ/f0KkYgNKLzWuTUUEXTjwo0gONFYtU5NTOuI324U3B6OTrS13VD0ug6LRHk5mC6o3q41iIZ9lyYjanr1htccU3mmTPw7Zpfyaqe14KFHQjhMir/zUo34@@26QjAZMulnuVnpKHbcCpMV4j6LArtZJ6pQnKfFwEaQWCPGBlvskGCPA4444YwUChoXGGTIccUNdzzwxOujdL5XaWargy8 "PHP – Try It Online") I have a string `^FX]0483500GC10UL0624526P0` which holds a single character for every input letter from "a" to "z". I extract this character based on input and store it in `$a`. If the character is not a digit, its ASCII code mod 30 will be stored in `$b`. If `$a` is a digit, same digit is printed, this is used for any input that needs an output between 0 and 9 (like "e", "f", etc). Else if `$b` is 20 or 11, same number is printed, this is used for "l" and "y". Else, digit "1" padded to `$b` with "0"s is printed. For example for input of "a", the character is "^" which has an ASCII code of 94. `94 % 30 = 4` and "1" padded to 4 with "0"s will be "1000". ]
[Question] [ *Inspired by [this comment chain](https://codegolf.stackexchange.com/questions/144318/how-many-chapters-do-i-have?noredirect=1&lq=1#comment353719_144318)...* > > I wanna [`enklact`](https://codegolf.stackexchange.com/a/141677/68615) my way out of this challenge but I can't... > > > @ETHproductions *to enklact* (v): to implement a lookup table using a subsection consisting of unique elements. > > > --- Enklacting is a very useful way to compress a lookup table. For example, let's say you had the following list of colors: ``` red green blue yellow purple orange ``` If you want to be able to take a color as input and return it's index in this list, there's obviously the straightforward way: ``` ["red", "green", "blue", "yellow", "purple", "orange"].index(input()) ``` But there's a way we could do this in way less bytes: ``` "rgbypo".index(input()[0]) ``` This works because the first (or 0'th) index of each string is unique. This example is obvious, but sometimes it's a little bit harder. What if we wanted to make a lookup table for this list? ``` Sweet Onion Chicken Teriyaki Oven Roasted Chicken Turkey Breast Italian BMT Tuna Black Forest Ham Meatball Marinara ``` In this case, we can't do this: ``` "SOTITBM".index(input()[0]) ``` because there are two different inputs that start with a `'T'`, namely "Tuna" and "Turkey". We must look at a different index. If you look at the 4th index of each string, you'll notice that they are all unique. So we can do this... ``` "enklact".index(input()[3]) ``` In this case, the *"enklaction string"* is "enklact". That leads us to today's challenge... Given a list of strings, return any valid enklaction string. Or in other words, given a list of strings, return any new string where each letter is unique, and the string is formed by joining the i'th letter of each string. If there is no valid enklaction string, your submission must return an empty string or a consistent falsy value instead. As usual, either functions or full programs are allowed, and the input/output formats are permissive (within reason). Each string will only contain printable ASCII, and this challenge is case sensitive. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so try to write the shortest program possible in your language of choice! ## Test cases ``` Input: Programming Puzzles Code Golf Output (any one of these): "ozdl" "gzef" Input: the quick brown fox jumped over lazy dogs Output: "tbjl" "hrua" "eomz" " wpy" "qne " "if o" "kxvs" Note that "u dd" and "coog" are not valid. Input: Sunday Monday Tuesday Wednesday Thursday Friday Saturday Output: "" Input: AbC aBc bbC Output: "Aab" Input: @#$%^_ Hello_World How are you? Output: "#eo" "$lw" "%l " "^oa" Input: a ab ac Output: "" ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~68~~ ~~67~~ 61 bytes ``` lambda a:`{0:j for j in zip(*a)if len(set(j))==len(j)}`[6::5] ``` [Try it online!](https://tio.run/##RcxBC8IgAAXge79CPGl0iKAOwk5BnYLBBh3WYIa6KU6H08MW/XZL2Or2PXjvDZPvrDlEkT2ipv2TUUBJ89oTBYR1QAFpwCwHtKVYCqC5QSP3SGGcZSko/G6qEyHHOg5OGo8EqmDubOto30vTwh2AeZhnzcfEs2Uc7uDVagFrjDf/TREMo1Pq3OyqMvBx4Z0z8wtlF9zqi5OLCuqDS/4exw8 "Python 2 – Try It Online") *Improvements* * From 68 bytes to 67 bytes by [Jo King](https://codegolf.stackexchange.com/users/76162/jo-king) * From 66 to 65 bytes by [Lynn](https://codegolf.stackexchange.com/users/3852/lynn) --- **If output would not have to be a string:** # [Python 3](https://docs.python.org/3/), 49 bytes ``` lambda a:[j for j in zip(*a)if len({*j})==len(j)] ``` [Try it online!](https://tio.run/##TcqxDsIgEADQna@43MQ13dxMmBxcu9cOmEKFwEFoHcT47RgSB7c3vPw6HolPzapbCzreVw36PHuwqYAHx1BdloMmZyEYlu/Bf0ipTk9Ly8XxIa2ccSppKzpGxxuOgNOz1mD2zktaDY54TcHiQtT@pvg10Y/o4ws "Python 3 – Try It Online") [Answer] # Python3, 59 bytes ``` lambda l:{len({*d}):''.join(d)for d in zip(*l)}.get(len(l)) ``` Returns a string with the enklact, None otherwise [Answer] # [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~43~~ 32 bytes ``` +/^(.).+^\1|^$/ms&m`^. |""Lm`^. ``` [Try it online!](https://tio.run/##K0otycxLNPz/X1s/TkNPU087LsawJk5FP7dYLTchTo@Lq0ZJyQfE@v8/oCg/vSgxNzczL50roLSqKie1mMs5PyWVyz0/Jw0A "Retina – Try It Online") Edit: Saved 11 bytes thanks to @MartinEnder. Explanation: ``` + ``` Repeat while the input changes... ``` /^(.).+^\1|^$/ms& ``` ...only if one line is empty or two lines begin with the same character... ``` m`^. ``` ...delete the first character of every line. The repeat therefore stops if either a) all the lines begin with different characters, in which case the condition fails and the input does not get changed, or b) at least one line becomes empty, in which case all the characters eventually get deleted, at which point the input stops changing. ``` |""L`^. ``` Collect the first character of every line. (If there was no solution, the above loop will have deleted everything and there will be nothing to collect.) [Answer] # [Haskell](https://www.haskell.org/), 71 bytes ``` f x|elem""x=""|y<-head<$>x,and[filter(==a)y==[a]|a<-y]=y|1<2=f$tail<$>x ``` [Try it online!](https://tio.run/##VYs7DsIwEAV7TrFapQApKaD20lDQpo9cLNgOFv4gJ0hx5LubQEfzZop5D56e2rlaDSxFO@0RF0IsWXQPzUo056XloAZj3azTnogPmWhgWVh0WVIuR3Ei08xs3Teunm0AAhV38Eo2zNCAgQH7FMfE3tswYov9e12dnja7RKU3XKMzKP8vjC0g3357R1k/ "Haskell – Try It Online") BMO saved 3 bytes with `any null x` → `elem""x`. Ørjan Johansen saved a byte with `sum[1|b<-y,a==b]<2` → `filter(==a)[y]==[a]`. ## Explanation ``` f x|elem""x="" -- Once any of the strings is empty, return "". |y<-head<$>x -- Otherwise, let y be all the first letters... ,and[ |a<-y] -- If, for all a in y, filter(==a)y==[a] -- a occurs just once in y: =y -- return y. |1<2=f$tail<$>x -- Else, chop off all the first letters and recurse. ``` If throwing an error (`Prelude.head: empty list`) when there's no solution is OK, `|elem""x=""` can be erased for **61 bytes**. [Answer] # [Ruby](https://www.ruby-lang.org/), 38 bytes ``` ->x,*y{x.zip(*y).find{|z|z==z-[p]|[]}} ``` [Try it online!](https://tio.run/##LcpPT4MwGIDx@/spmjgNEMcSj0acukR3MVmyJTswXF7a8kdLi4U6KPDZcUxPz@/waBO3YxKM88fm1mu7xrd56Xit6ye5ZF1vexsEdh6WUR9GwzDOHnzNkflVKfLaWRxkdzcsXJ8jzbq@5lXdlyQJvUn/z/IgXb/A0rm5pxnqyo2GcaNVqrEocpnCxlgreAUrxTi8KZEA1Bkn3yanXxBrdZIkUQ18mqLkjKgfrkGgbQlTaQWwNZJhC@/qkp3h1dQ9Z/JPu8zoC151PmWLtdET4DleAb5QiM@Fp6vZ9ccR1lwIddwrLRis1Ymg5qRVZgmAgDEgPSOmU5GyXw "Ruby – Try It Online") Thanks to G B for pointing out a bug. [Answer] # [Pyth](https://pyth.readthedocs.io), 6 bytes ``` >1{I#C ``` [Test suite.](https://pyth.herokuapp.com/?code=%3E1%7BI%23C&test_suite=1&test_suite_input=%5B%27Programming%27%2C+%27Puzzles%27%2C+%27Code%27%2C+%27Golf%27%5D%0A%0A%5B%27the+quick%27%2C+%27brown+fox%27%2C+%27jumped+over%27%2C+%27lazy+dogs%27%5D%0A%0A%5B%27Sunday%27%2C+%27Monday%27%2C+%27Tuesday%27%2C+%27Wednesday%27%2C+%27Thursday%27%2C+%27Friday%27%2C+%27Saturday%27%5D%0A%0A%5B%27AbC%27%2C+%27aBc%27%2C+%27bbC%27%5D%0A%0A%5B%27%40%23%24%25%5E_%27%2C+%27Hello_World%27%2C+%27How+are+you%3F%27%5D%0A%0A%5B%27a%27%2C+%27ab%27%2C+%27ac%27%5D%0A&debug=0&input_size=2) The output is a singleton list, as [allowed by default](https://codegolf.meta.stackexchange.com/a/11884/59487); the list **[ ]** (empty list, falsy) is returned in case the string cannot be *enklactified*. ### Explanation ``` >1{I#C – Full program. C – Transpose the input, cropping absences. # – Filter by: {I – Invariant under deduplication. >1 – Slice to 1. list[:1] in Python. ``` --- **[Pyth](https://pyth.readthedocs.io), 5 bytes** This would've been valid if crashing would have counted as a falsy value. ``` h{I#C ``` [Test suite.](https://pyth.herokuapp.com/?code=h%7BI%23C&test_suite=1&test_suite_input=%5B%27Programming%27%2C+%27Puzzles%27%2C+%27Code%27%2C+%27Golf%27%5D%0A%0A%5B%27the+quick%27%2C+%27brown+fox%27%2C+%27jumped+over%27%2C+%27lazy+dogs%27%5D%0A%0A%5B%27Sunday%27%2C+%27Monday%27%2C+%27Tuesday%27%2C+%27Wednesday%27%2C+%27Thursday%27%2C+%27Friday%27%2C+%27Saturday%27%5D%0A%0A%5B%27AbC%27%2C+%27aBc%27%2C+%27bbC%27%5D%0A%0A%5B%27%40%23%24%25%5E_%27%2C+%27Hello_World%27%2C+%27How+are+you%3F%27%5D%0A%0A%5B%27a%27%2C+%27ab%27%2C+%27ac%27%5D%0A&debug=0&input_size=2) [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes ``` z0Q€fZḢ ``` Returns the integer **0** if the strings cannot be enklactified. [Try it online!](https://tio.run/##Jc8xTsNAEIXh/p1iJaDnBgQiQRqkoESKoCAae8eOw9oD4yzB7qDhANwAWkoUgZAogjiIc5HFTpr5fr1u5uxcFUJ9eLF5ek@ums/X8PfSfL1tHn/Wq/Wq@f5o99/n9lyGMFRJlfI8K1IMfV07LtEXyzgTlwCLGZs7n8U3iFSWhUnkAXOf37I1cs8KR3VlrKQlMPKFpQrnsmXsueycsC12NZ553capZh0jWnjtAsdRH3QSI2pFb2//4HqKQfuETCeizmIgS0PKphJ/BBAoAsX/ "Jelly – Try It Online") ### How it works ``` z0Q€fZḢ Main link. Argument: A (string array) z0 Zip/transpose, filling shorter rows with 0. Q€ Unique each deduplicate resulting string. Z Zip/transpose, without using a filler. f Filter; keep only string that appear in the results to both sides. Ḣ Head; extract the first string. Returns 0 if the array is empty. ``` [Answer] # [R](https://www.r-project.org/), ~~116~~ ~~107~~ 95 bytes **R+pryr** ``` pryr::f(for(i in 1:min(nchar(v)))`if`(anyDuplicated(t<-substr(v,i,i)),0,{cat(t,sep="") break})) ``` [Try it online!](https://tio.run/##NY3BasMwEETv@gqRkxYUaK8mvbglNBATaP0BWTtrskhem5WcYkq/3VUPvc3whnm65XE@7LdZV62qwQ2TOrYs9rkaWZz0d1T3AIArD1eHsr4tc@QeM91cPuzT0qVcBp49A/gn/12Qyz7R/LLbgemUMPwA/FlcybczCyUHYD6/iLK9CE9iX@/cBxLbkvKKgc3lUdrHhKlo/qlpFw202rrcpGxOGSOj2LppCxE0dcQ@2OOklLJ9x9E0hLnDGG2DyoKKZvsF "R – Try It Online") **base R** ``` function(v)for(i in 1:min(nchar(v)))`if`(anyDuplicated(t<-substr(v,i,i)),0,{cat(t,sep="") v=0}) ``` [Try it online!](https://tio.run/##NY3BasMwEETv@oolJwkUSK8luTihtFATaP0B2ShrslheG2ntYkq@3VEPPc68YV5atR/327WdJCgPYmfXDskysMDLa89iJdwxldq5C7cXi7KcpjFyQKWb1f02T9esZeDZs3N@538LsuozjYfNxpn5sHu4P4tNhLdPFsrWOfP9Q6RwluKE451DRwINJV6wY3OeS/oaMBfHPzXNlDpaoCo3Wc2HYmQUqOqmEEFTRQwdvA2JssI79qYm1CvGCDUmFkxo1ic "R – Try It Online") *These two variants saving 9 bytes thanks to [Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe).* ### Explanation: This effectively truncates all stings in the vector `v` to the length of the shortest and iterates through subsequent indexes. Then checks whether there are any duplicates within chosen letters and if not, pastes them together and prints with `cat`. If all indexes return duplicated results, this prints empty string. All wraped in an anonymous `pryr` function with `break` to halt the loop, or base R function zeroing the vector to break the loop. [Answer] # [Haskell](https://www.haskell.org/), ~~76~~ 74 bytes ``` f t=last$"":(id=<<foldr(zipWith(#))([[]]<$t)t) x#[s]=[x:s|all(/=x)s] x#e=e ``` [Try it online!](https://tio.run/##Nci7CoMwAEDRvV8RokMC0u5ipkI7CYKCQ8gQSNTQPCQPsNJ/txbtdA934uEltd62AUSieYg5hCVSglTV4LTwaFVzr@KEMowRpYxVecQRX5aMBkboUoYP1xrdyIID268kcjNcWUCA4XMN0OyVjeAKBgwohY13o@fGKDvCAjZpXbUMu@5OyD1PpwfICgrbZAV/76d2J7okw6FeCvt3NyV/8uHVgZbH5H9kbPsC "Haskell – Try It Online") Returns the last valid lookup string or an empty string if no such string exists. --- ### ~~71~~ 69 bytes If throwing a consistent exception as falsy value is allowed: ``` f t=head$id=<<foldr(zipWith(#))([[]]<$t)t x#[s]=[x:s|all(/=x)s] x#e=e ``` [Try it online!](https://tio.run/##NchNC4MgAIDh@36FWAeF2O4jT4PtFAQFHcSDoC6ZafgBLfbfm6N2eh/ekYeXNGbbFIhklFyUWpC6Vs4Ij1Y9DzqOqMAYUcpYXUYcT0tBAyN0uYYPNwZdyIIDy1cSuU1cW0DAxOcGoNlrG8EZKAwoha13T8@nSdsnrGCb1tXIkHVzQuY8nFGQVRR2yQr@zqdxB/okw65BCvt3PyZ/8O71jo7H5H9kbPsC "Haskell – Try It Online") Throws an `empty list` exception if no string is found, returns the first valid string otherwise. *-2 bytes thanks to Ørjan Johansen* [Answer] # [Stax](https://github.com/tomtheisen/stax), ~~9~~ 8 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` åτIⁿs↓µg ``` [Run and debug it](https://staxlang.xyz/#p=86e749fc7319e667&i=[%22Programming%22,+%22Puzzles%22,+%22Code%22,+%22Golf%22]%0A[%22the+quick%22,+%22brown+fox%22,+%22jumped+over%22,+%22lazy+dogs%22]%0A[%22Sunday%22,+%22Monday%22,+%22Tuesday%22,+%22Wednesday%22,+%22Thursday%22,+%22Friday%22,+%22Saturday%22]%0A[%22AbC%22,+%22aBc%22,+%22bbC%22]%0A[%22%40%23%24%25%5E_%22,+%22Hello_World%22,+%22How+are+you%3F%22]%0A[%22a%22,+%22ab%22,+%22ac%22]&a=1&m=2) Explanation (unpacked): ``` M{c0-u=}j Full program, implicit input e.g. ["Programming", "Puzzles", "Code", "Golf"] M Transpose ["PPCG", "ruoo", "ozdl", "gzef", "rl\0\0", "ae\0\0", "ms\0\0", "m\0\0\0", "i\0\0\0", "n\0\0\0", "g\0\0\0"] { }j Find first matching element: e.g. "PPCG" c0- Copy and remove zero bytes (padding) "PPCG" "PPCG" u Unique "PPCG" "PCG" = Check if equal: 1 First matching here: "ozdl". If none is found, the stack is empty Implicit output if anything on stack ``` [Answer] # [R](https://www.r-project.org/), 127 bytes ``` function(S,s=sapply(S,substring,x<-1:max(nchar(S)+1),x))cat(rbind(s[!apply(s,1,anyDuplicated)&!rowSums(s==""),],"")[1,],sep="") ``` [Try it online!](https://tio.run/##JYuxDoIwFEV3v0IYTBvLwGpgM046lcSBOBRapAk8mvfaCF@PFJZ7Tu7NxbU7F9naBWi9nYBJQSUp54YlamjIo4WvmIssv41qZtD2Cpnk15yLmfNWeYaNBc2oTo4biVwoWO7BDXabjeaXBKefDCMxKss05eIjtqzzjWRcbNaOoVH6acEQ4/wkA2i1nF7TjioYinwbDYdVfcBdHmgjpPIBo6x/ "R – Try It Online") `sapply` typically returns a `matrix` when all the `length(FUN(X[[i]]))` are equal, except when `length(FUN(X[[i]]))==1`, in which case it returns a `vector`. In order to use the matrix operations, then, we have to `substring` one further than we need to guarantee a `matrix`, which is why `x` extends to `max(nchar(S)+1)`. We then filter for rows that have no duplicates and no empty strings. Since we can only return a single string, we take the first one, except that when there are no rows that meet the criteria, we would throw an error, so we append an extra row of `""` to the end. Then we print out the `enklact`ified string or the empty string. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes ``` øʒDÙQ}н ``` [Try it online!](https://tio.run/##MzBNTDJM/f//8I5Tk1wOzwysvbD3//9o9ZKMVIXC0szkbHUdBfWkovzyPIW0/AoQJ6s0tyA1RSG/LLUIxM1JrKpUSMlPL1aPBQA "05AB1E – Try It Online") **Explanation** ``` ø # Zip the input array ʒ } # Filter by ... DÙQ # ... an entry is equal to itself deduplicated н # Take the first element ``` [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 27 bytes ``` {([Z] $_).first:{.Set==$_}} ``` [Try it online!](https://tio.run/##RVFdb4IwFH3nV9wgG5psPO5BB3Mz2fayxEQTkxmHBYqghWI/xpDw292tc5o0uee2536c04oK9nAsGril5Y6RWIF/bPvLzxU44cBLcyHVsPVmVPm@E3adYY4VlUqCD0sLYF/Xj1PBN4IURV5uYKoPB0YlTHhC4Y2zNLg7s1yVUdjrPN654EaC1yWk/AfxVhcVTYB/U4EZI4cGEr6R7qVypsuENPDBT2GuqTRxQZPyD80zLU7gVeQmzIjSAsGlwXM0AfISQxRNruuMe87NV4gT3yljPFxwwRKT8RqIoNBw/XRdgQCJgMSYr0aWlXLx78J9AI5B0CKzh7JLlKHAaJVKoCMSFAcCcUYEuksFsBzZfYL3WS4BD6kqHFgq1oBNcJWaJvYAu6HVjikzVp9mBIEX8yIa4ZtEmfthvLbb87f1/6gDb8vzsrPXI6uzjr8 "Perl 6 – Try It Online") After seeing that the ruby version has been upvoted, I have copied the approach and used character lists, instead of strings. I don't like it. My older, and more correct submission is as below: # [Perl 6](https://github.com/nxadm/rakudo-pkg), 38 bytes Split, zip, check uniqueness, join. ``` {[~] ([Z] @_>>.comb).first:{.Set==$_}} ``` [Try it online!](https://tio.run/##RZBLT8JQEIX3/RUTRAuJsnQBtlZJ1I0JCSQkNlhu22mp3HbgPqylKX8dbxFhdb6TeZzJbFDw@0NewQ0Wa84iBc6h9vcL6PkfC/AC1x1ElIf9QZIJqYb1YIrKcbpB07RDnkKpJDjgWwDbsnyYCEoFy/OsSGGidzuOEsYUI7wST9zbU5etVghbnUVrG@xQUFlAQj@Gv3S@wRjoG4VxnO0qiCmV9nlyqouYVfBOR5lplK3OMS7@aLbS4ggvImtlypQWBs4LnsIxsOcIwnB8Oce76l5/BibxDTmnYE6Cx62jEphAqEg/Xk5gwEJgkfGLkWUlJP6/cOdCtyWoTac04dthtOzUp7/2jrV@01mOrMY6/AI "Perl 6 – Try It Online") [Answer] # [Perl 5](https://www.perl.org/) `-plF`, 56 bytes Saved 5 bytes thanks to [@Xcali](https://codegolf.stackexchange.com/users/72767/xcali)! ``` map$;[$_].=$F[$_],0..@F}{($_)=grep$.==y///c*!/(.).*\1/,@ ``` [Try it online!](https://tio.run/##NY29asMwFEZ3PYUKGuzUlpwhS4rBOGASiDG07pSEcONcWmFZFrL6Y0pfPYo6dDqc7wyfQatW3g9g2NOBnU88Z9Ufk4zzovr9idg5zt8sGsbzfBZCdIsHEfGYL45LkRTev3whOtpoOWq6eZddj5q2aOUMvSTNZ7DnESaH1/9K2g/b40xLi2EnOwdKgqZl3YaigZQKup5Wo8XJ0S0MpEZwF1CK1mClBgu30bhwN/nUqMqn9YpnyyxwLye3Xr86qR6jAb7jOw "Perl 5 – Try It Online") [Answer] # [Japt](https://github.com/ETHproductions/japt) v2.0a0, 7 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) Takes input as an array of ~~character arrays~~ strings, returns ~~an array of characters~~ a string or `undefined`. ``` Õæȶ¸¬â ``` [Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&header=tw&code=1ebItris4g&input=IlN3ZWV0IE9uaW9uIENoaWNrZW4gVGVyaXlha2kKT3ZlbiBSb2FzdGVkIENoaWNrZW4KVHVya2V5IEJyZWFzdApJdGFsaWFuIEJNVApUdW5hCkJsYWNrIEZvcmVzdCBIYW0KTWVhdGJhbGwgTWFyaW5hcmEi) [Answer] # [Python 3](https://docs.python.org/3/), 75 bytes ``` def f(t):c=[s.pop(0)for s in t];return all(t)and(f(t),c)[len(t)==len({*c})] ``` Operates on character lists instead of strings. Returns False if no valid enklaction string exists. [Try it online!](https://tio.run/##HY0xD4IwEIX3/orbbI0hJm4YJgdXBzfCUOHAar02xxEB42/H4lveJe979@Ik90CHZWmwhVaLyeui7LMYot6bNjD04AikOjLKwATW@wRZavQK72pTeqR0FcXqn239NdUiOAoUUFbqfXce4coD5gqShKcc1jizMWL64l0v2lEcRBtj/gyONUbJ4cZon0pFdiR6s8kewdG6mtoJXS4cOravl6NOXYZ59tirU2hQnYNvfw) [Answer] # [C (gcc)](https://gcc.gnu.org/), 161 bytes ``` f(s,i)char**s;{char**t,a[255],*u=a;for(i=0;memset(a,0,255),u&&~i;i+=!!~i&&u)for(t=s;(u=u?*t++:0)&&~(i=u[i]?i:-1)&&!a[u[i]]++;);while(~i&&(u=*s++))putchar(u[i]);} ``` [Try it online!](https://tio.run/##TY7JTsMwGITveQpHSJG3ogSpl5q0DxLlYBwn@UuW4iUFqvbVjQ0XbjPzzUijdoNS4QkWNflOo1frOlifx2P2PzKwDDELPbYciBqlodSK259wXDYv@33Lqa@l6FeDoS7FrGerHZa85BES7oviAQJYnecPKApPUtHVVmBf@xN1jB1KEjtx7BtoT3DYVdHnskm2ZUwQcR1h0jjN44haxgi5eJde4FQi4h5gcWiWsOAkpBkUR4kjSqPZCLplCEGPEzlWBP2qjVVEZPcQ3KjRhwf1Ht7Mel1Qv36Gs58vukPrpk2Y5PcX6tbB/gA "C (gcc) – Try It Online") Each character position is tested for duplication and skipped if a duplicate is detected; this is continued until the shortest string ends. It's ASCII only, sadly: DBCS/UTF-8 strings break this function badly! [Answer] # [Japt](https://github.com/ETHproductions/japt), 12 bytes Returns `undefined` for non-enklactic strings. ``` y ·æ_¬n ä¦ e ``` [Try it online!](https://tio.run/##y0osKPn/v1Lh0PbDy@IPrclTOLzk0DKF1P//lQKK8tOLEnNzM/PSuQJKq6pyUou5nPNTUrnc83PSlAA "Japt – Try It Online") ## Explanation: ``` y ·æ_¬n ä¦ e y // Split the input at newlines and transpose · // Join on newlines æ_ // Return the first item that returns truthy when ran through: ¬n // Sort ä¦ // Reduce with != e // All items are truthy (unique) ``` [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 54 bytes ``` #&@@Select[PadRight@#,#~FreeQ~0&&Union@#==Sort@#&]& ``` [Try it online!](https://tio.run/##NY69TsMwEID3PEWUQARVJdhRhaFSYUFKSREDgsqNL4nB8cHFprRVuzLyqDxCuDRl8X33@f5q6SqopdO5bIvRSRsnQmRgIHdPqVT3uqyciH9/vofxbkIA0915kjxYjVbEo1GGxL/Jc9KeXgRTr8GJQUracijEYFxJkrkDas7EJgg2UUpYkqxrbctoGKV@vTbQMI1RAYcbNEW0HXIhnxR@eJ2/sV0QLm1Y4Bfzq6/fQYX4CcSZketVqLBs@qbMWyVX7O/wADMPTU@PoOw/zypPB5yQ7iGTzlOH@0lXizE7eZ1365n3UsRHxy9zNrdgDM4fkYzqMlyGkiBcob/sC2XXu@iePNoGwbb9Aw "Wolfram Language (Mathematica) – Try It Online") Takes a list of list of characters as input, returns a list of characters. Contains U+F3C7, corresponding to "Transpose" operator. Returns `#1` and throws a bunch of ignorable errors when there is no suitable string. ### Explanation: ``` PadRight@# ``` Pad the input so that each "string" (list of characters) is the same length. This appends integer `0`s (not string `"0"`s). Then transpose. ``` Select[ ... ,#~FreeQ~0&&Union@#==Sort@#&] ``` Select the strings that have no integer `0`s in them and have all unique characters. ``` #&@@ ``` Get the first one. [Answer] # JavaScript (ES6), 66 bytes Returns either a string or `undefined` if no solution exists. ``` f=(a,i=0)=>a.every(s=>(o[k+=c=s[i],c]^=1)&&c,o=k=[])?k:c&&f(a,i+1) ``` [Try it online!](https://tio.run/##bY5Bb8IgGIbv@xUk29oSOzOvJug2k22XJSaaeGiqoUArlvI5KLr65zuI7rL0As8XnvflO9ATtczIY/ukgYu@L0lCU0meMZnRsTgJ0yWWzBLI6hFhxGYyT1m@JRMcRSwFUpMsx/N6yqKoDMHRBPcMtAUlxgqqpEyyeGmgMrRppK7iNF66y0UJ62nhP/TXB6gyzjG@@59r9wJ9O8lqLxUGzhqV8OP54Jqj4Aj8cn5S9NIhDpUd7Fg5zWnntS@4wdoJe6WN4PqP13tnbvhu5BVWtHUm4FDxa7HwCn1jYTnPQ87L/cPjdueFT6EU7DZgFA8TnBE1AnXg5oM5GpqLcLDw3v8C "JavaScript (Node.js) – Try It Online") ### Commented ``` f = ( // f = recursive function taking: a, // a[] = input array i = 0 // i = pointer ) => // a.every(s => // for each string s in a[]: (o[k += // append to the key string k c = s[i], // the character c at position i in s c] ^= 1 // and toggle o[c] (undefined -> 1 -> 0) ) && c, // additionally, make sure that c is defined o = k = [] // start with o = k = empty array ) ? // every() is true if all characters were distinct and defined: k // in which case we return k : // else: c && // provided that every() didn't fail because of an undefined character, f(a, i + 1) // try again at the next position ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), ~~23~~ 21 bytes -2 bytes thanks to [@Neil](https://codegolf.stackexchange.com/users/17602/neil)! ``` §ΦE⌊EθLι⭆θ§λι⬤ι⁼¹№ιλ⁰ ``` [Try it online!](https://tio.run/##NYzBCsIwEET/JacNrKCfUIqKoFDwWHpY2jUNbBObJiL9@RgrnmZ4j5l@pNB7kpyreHEDv@FkJXKAGz1hsm7LGa/sTBzBaq3xHoN15sf/I8FNVSJg8TgnkgUOWPvkYgGiv3Kvc25b1QRvAk3l2yhUTVpX4aW02g9c4uzlobou715CHw "Charcoal – Try It Online") [Answer] # [Husk](https://github.com/barbuz/Husk), 9 bytes ``` ḟS=UḞz:∞ø ``` [Try it online!](https://tio.run/##NZBBTsJQEIb3/yleol7CxKiQIC4IRGrYSaZ0aGtf3@C0j1J2uvIUeAvDWk4CF6ktxtX3zfyL@TOJL7Iml@L08b457H@@m@P@a3rzfNzvttenz91h3zSNcoRYmR1C6xk1WysVVl5XliFKLmZgWjGXZuxScaafpIuMnQlY05qyFON1Oz0JFSVH/ykCrxnXpqfc7vFYkk3Jmd4oaBNH6FlaZGYgykVphpRjxFSGZK0ZkaaOlICJSqyU56mLMfHbreUCfYkYD2KXQJmwefPtNYQqlTNL2eDV56u2hKxZYWlbm0jioq3vXUQ1RnJG4LnoOOPI/VmQeD3LQNMOUyq9doL7sA/qLRC2xN3F5dXLHMPuRfOZqI0wlMqQsqnF3wIECkGLXw "Husk – Try It Online") ### Explanation ``` fS=UḞz:∞ø Ḟz:∞ø Transpose the input dropping characters of longer strings Ḟ Fold right z: Zip with prepend ∞ø Infinite list of empty lists ḟS=U Find the first string without duplicates, returns an empty string if none ḟ Return first value satisfying predicate = Equal S U to itself with duplicates removed ``` [Answer] # [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~81~~ 56 bytes ``` m`$ $.=*£¢ N$`. $.%` ¶ ~`(.*?¢)+ L`.{$#1} A`(.).*\1|£|¢ ``` [Try it online!](https://tio.run/##K0otycxLNPz/PzdBhUtFz1br0OJDi7j8VBL0gDzVBK5D27i46hI09LTsDy3S1ObySdCrVlE2rOVyBIpp6mnFGNYcWlxzaNH//wFF@elFibm5mXnpXAGlVVU5qcVczvkpqVzu@TlpAA "Retina – Try It Online") *-25 bytes thanks to @Neil* --- Transposing rectangular text in Retina is surprisingly difficult. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~121~~ ~~113~~ 110 bytes ``` i;d;f(s)char**s;{char**_=s,x[255]={0},y[99]={0};for(d=i=0;*_;)d+=x[y[i++]=*(*_++)++]++;d=d?*x?0:f(s):puts(y);} ``` [Try it online!](https://tio.run/##Jc07C4MwGIXhv5IxFwu24KAfwaFDV/cgEhK1gRpLosUL/vbUtNuzvOeoS69UCAY0dNgT9ZSOUg/7Hw33ySJuWVbzPT2SVeT5T9CNDmtueAq0AaIZX8QqDGM1p5g2jJGTjIHmuqRLmRZxu3jPk8crgSMYO6FBGosjpOtVguIhoqc/oiZ7h6PYlQBy7TQ7i9IzC5UbeyeHwdg@VPO2vVof7qNuw2N8dV8 "C (gcc) – Try It Online") ## Ungolfed ``` void enklactify(char *strings[]) { int quit = 0; while (!quit) { char **arg = strings; // current row int exists[255] = {0}; // which characters exist in the column char output[99] = {0}; // will hold output string int index = 0; // where to insert in output int duplicates = 0; // have we found any duplicates? while (*arg != NULL) { char *word = *arg; // current word char first = *word; // first letter of current word if (exists[first]) duplicates = 1; // we found a duplicate exists[first] = 1; // mark it as in our string output[index] = first; // add it to our output index++; (*arg)++; // advances the current word to the next // character by reference (chops first char) arg++; // advance to next whole argument } if (!duplicates) { // This is a valid solution puts(output); quit = 1; } if (exists[0]) { // We hit the null terminator of one of the // input strings, so we failed quit = 1; } } } ``` -3 thanks to ceilingcat This abuses the ability to just add 1 to a string pointer in C to get the 'tail' of the string. The main byte savers are: * `d+=x[y[i++]=*(*_)++]++` which appends the first character of the first string of `_` to `y`, advances the first string of `_` to remove its first character, adds the `x` entry at that character to `d`, and increments said `x` entry * `q=d?*x:puts(y)` which prints `y` if `d` is non-zero while setting `q` to a non-zero value, or sets `q` to non-zero if the first element of `x` is non-zero (if we were at the end of one of the strings then said element would be non-zero) Edit: Shaved bytes by switching from while loop to recursive tail call and removing brackets from for loop. [Answer] # [Husk](https://github.com/barbuz/Husk), 8 bytes ``` ḟȯ=L¹LUT ``` [Try it online!](https://tio.run/##NZBBTsMwEEWvYgXY9QoISKUCUqtWNKiLqlSTZNqYOB6Y2C3pDi7CEdjClhXXgIuEcdpuPO//P/aMXPi6bKu/t9f29/P95@N8@P01vE/atp3Po@kW0amx1WRVv9BZiVYlyLqBUke9aLwRfUdQO8yPudiJ5xIbFTNKIvrWgdFgVTxKutSClNhAVqoBMdZO3UAl1gjBpWCMGgFrCwzRojePJkxrhqrSdi09E7/bGayF@pSjlGsyq67PFaievewgZsq0tWpFL8KPvnqS9WiDLMrArlE5revuztTbHJowmg6QeKz3NMPcHjkpPB9wwHoPU3CeA4aHrtK@WBBnYbhw8C5PTs8elmLcoDG0nBGbPCjaKmBUDfmLri/8BqThyKLF4h8 "Husk – Try It Online") Different approach to the [previous Husk answer](https://codegolf.stackexchange.com/a/164245/95126). Gets the longest prefix with all-unique characters from each index position, and then selects the first that is the same length as the number of input strings. ``` ḟ # first element that satisfies ȯ=L¹L # length (of string) equals length of input (array), of U # longest prefixes of all unique characters of T # transpose of input ``` [Answer] # Pyth, 13 bytes ``` e+kf{[[email protected]](/cdn-cgi/l/email-protection) ``` [Try it here](https://pyth.herokuapp.com/?code=e%2Bkf%7BIT%40.TQ.t&input=%22Sweet+Onion+Chicken+Teriyaki%22%2C%22Oven+Roasted+Chicken%22%2C%22Turkey+Breast%22%2C%22Italian+BMT%22%2C%22Tuna%22%2C%22Black+Forest+Ham%22%2C%22Meatball+Marinara%22&debug=0) ``` e+kf{[[email protected]](/cdn-cgi/l/email-protection) .tQ Transpose the (implicit) input with padding. .TQ Transpose the input without padding. @ Take the strings in both. f{IT Find the ones that have no duplicates. e+k Get the last, or an empty string. ``` [Answer] # [Red](http://www.red-lang.org), 139 bytes ``` func[b][m: length? first b foreach a b[m: min m length? a]repeat n m[c: copy[]foreach a b[append c a/(n)]if c = unique c[return rejoin c]]] ``` [Try it online!](https://tio.run/##VY9BT8MwDIXv/AqrgAQn7pPQgEnABWlik3aowpQmTpuRxp3bMLo/X1xtwHZJPuc9PzuMdnhHm6sLNxlciiYvVF5PIGAsu2oKznPbQQGOGLWpQEMxyrWPUP@ZtGJsUHcgj7mZgKGmz9Vpi24ajBYM6LubeKu8E7yHFP02IZicsUscgXFDEmyUUkPDPnbgIM/mTCXrWkaWGWTztN8HbIVmZFGuFwouUxf//q5C2CZvPkUsmHZRlv8W3qS6QQv0hSxV0PseLJXtWe8iRat7kd/oCMuE7YFWaOMvL6vER3xmf4CFlk@MqOAk8bGYiaafzLiN8Om0h8ur64@1CK8YAq1XxMGOFe1AM0JPaXrm12NSMR4mU8MP "Red – Try It Online") ## Explanation: Takes the input as a block (list) of strings. Returns the *enklaction* string or `none` otherwise. ``` f: func[b][ m: length? first b ; the minimal length of the first string foreach a b[m: min m length? a] ; find the minimal length of all strings repeat n m[ ; limit the search to the minimal length c: copy[] ; an empty block foreach a b[append c a/(n)] ; for each string append the current char if c = unique c[return rejoin c] ; if all chars are unique, return the block ] ] ``` [Answer] # [Röda](https://github.com/fergusq/roda), ~~80~~ 77 bytes ``` f a{a|seq 0,#_|try{{|i|a|[_[i:i+1]]|orderedUniq|concat|[_]if[#_1=#a]}_|head}} ``` [Try it online!](https://tio.run/##NclBa4NAEIbhc/ZXDHhJaA/NNZCLhdIeJNDak4h8dUcyaGbJuG0R199uvfT4vo8Fj3XtCDPSyHd6esyaFG2a5yQJqWoqOcnDsa5TMM/G/lPlntqgLeKmtXRV1hzPGeqlSVeGX5b1BlGa3Q50OlMlnjVKnPaH2u26PQ5uWT9@mSNdVILS81XanpVKNpnQi7v8bPUeMEb2/@rKb@t5otx4@@4tYhAo5UW5icLlA9qeXoLxGOkVN1cw4heGgQqYKAx/ "Röda – Try It Online") *-1 byte thanks to [Cows quack](https://codegolf.stackexchange.com/users/41805/cows-quack)* Explanation: ``` f a{ a| /* Push the strings in a to the stream */ /* For each string (_): */ seq 0,#_| /* Push a range from 0 to the length of _ to the stream */ try{ /* Ignore errors during the following block */ {|i| /* For each i in the stream: */ a| /* Push strings in a to the stream */ [_[i:i+1]]| /* For each string, push the ith character to the stream */ orderedUniq| /* Remove duplicate characters */ concat| /* Join the characters into a string */ [_]if /* Push the string to the stream if */ [#_1=#a] /* Its length is the length of a */ }_| head /* Take the first string in the stream and return it */ } } ``` The `try` keyword is used to dismiss errors that occur if `i` is larger than the length of the smallest string in `a`, or there is no answer and `head` causes an error. [Answer] # Java 10, 106 bytes ``` a->{for(int i=0;;i++){var r="";for(var s:a)r+=s[i];if(r.length()==r.chars().distinct().count())return r;}} ``` Will give an error instead of returning an empty String if no solution can be found. Input is a character-matrix. [Try it online.](https://tio.run/##fVNRb9owEH7frzixTUrUNdpzT2wraF37QDsNpD4gVl2SA1yMnZ1tIEX8duYEqDRNVEp0dz7fd9/Zn59pRZfP5WJfaHIOBqTM9h2AMp5lSgXDfRMCDL0oM4MiKeYk48l4ApRizOziHz/nyasC7sFAF/Z0@WU7tZJEFFDdz4jq4iLdrkhAup0ONqkmcFeUykXXjdUE1TSRTLOZ@XmSdruSNX1ckmalcl6Zwke3sMFEmwr7IAYEd7s9HvpXIdex/5HGyqoSlnGU5EC7ZXuYw7PzSUe4xJkwG8x1YKxZa7vGKkilGa2QmXEnc5VWcS920nbSU@1wzezhwShroD9XxYINjFhUTQuFD6sY/bLkPJenLI6CLLiGnnBcxztPWpGB3mAUM4awp6lYwI2VCA@3tMQBk89J63gbkT0JneXyU@xMaLmMM@LP8PKi2WHflow/rJ6erfJzhj8hcsNc7NrA1G7wOSyrSNmuWFDTSw2lnbnzZxBMSTUObGtGgV1jH7k0B280D9I6N6IaM6R4Y9E5C3id95F6BeZ5/@yeb@8/fPz9hLfNZT09WtEl3to1kDDUNnw9W0dIOVLxX/5f6baaaQteNeOOmnmVvDJV8FHghteHRXeUbEweOp4U3waNzo/vZnPl0nYNDiDj@CImEWmTeduPSNciVCcn2lJvj5uHdVTSMrPBZ1UE8tokJiuSFuM05a4gX8yTFuLOlLx5CP5h2ouPpXTfNwVXvpEqb9I3QDtvV38CZ8FYWEXplhCFGrR3nVP/9ix3@78) **Explanation:** ``` a->{ // Method with character-matrix parameter and String return-type for(int i=0;;i++){ // Loop `i` upwards var r=""; // Result-String, starting empty for(var s:a) // Loop over the character-arrays of the input r+=s[i]; // And append every `i`'th character to `r` if(r.length()==r.chars().distinct().count()) // If `r` only contains unique characters return r;}} // Return `r` as result ``` [Answer] ## Clojure, 59 bytes ``` #(for[s(apply map list %):when(=(count(set s))(count %))]s) ``` Returns a list of lists of characters. ]
[Question] [ I've recently been indulging myself in some nostalgia in the form of Bookworm Deluxe: ![](https://i.stack.imgur.com/c1x3x.png) In case you haven't seen it before, it's a word game where the goal is to connect adjacent tiles to form words. In order to determine whether a string is a valid word, it checks it against its internal dictionary, which is stored in a compressed format that looks like this: ``` aa 2h 3ed ing s 2l 3iis s 2rdvark 8s 4wolf 7ves ``` The rules for unpacking the dictionary are simple: 1. Read the number at the start of the line, and copy that many characters from the beginning of the previous word. (If there is no number, copy as many characters as you did last time.) 2. Append the following letters to the word. So, our first word is `aa`, followed by `2h`, which means "copy the first two letters of `aa` and append `h`," forming `aah`. Then `3ed` becomes `aahed`, and since the next line doesn't have a number, we copy 3 characters again to form `aahing`. This process continues throughout the rest of the dictionary. The resulting words from the small sample input are: ``` aa aah aahed aahing aahs aal aaliis aals aardvark aardvarks aardwolf aardwolves ``` Your challenge is to perform this unpacking in as few bytes as possible. Each line of input will contain zero or more digits `0-9` followed by one or more lowercase letters `a-z`. You may take input and give output as either a list of strings, or as a single string with words separated by any character other than `0-9`/`a-z`. Here is another small test case with a few edge cases not covered in the example: ``` abc cba 1de fg hi 0jkl mno abcdefghijk 10l => abc cba cde cfg chi jkl mno abcdefghijk abcdefghijl ``` You may also test your code on the full dictionary: [input](https://gist.githubusercontent.com/KeyboardFire/755e04d8d51c195c8688184bf3890588/raw/e7c236cb179acb1de859b5ed6b0569d7766bc911/input.txt), [output](https://gist.githubusercontent.com/KeyboardFire/755e04d8d51c195c8688184bf3890588/raw/e7c236cb179acb1de859b5ed6b0569d7766bc911/output.txt). [Answer] # Vim, 57 bytes ``` :%s/\a/ & :%norm +hkyiwjP :g/\d/norm diw-@"yl+P :%s/ //g ``` [Try it online!](https://tio.run/##HcpNCoAgFEbR@bcKCWoS8WrqqCW0ACea5m8JBUWrN2l67r1L4e1FQhLrwNsjnzvrXXz9ExZwS0LTb9o/w9y8qa9af0ZkUYpUK1YlMWmDzcJ5jCEm7EdGTdps1vkQMY3pAw "V – Try It Online") [Answer] # JavaScript (ES6), ~~66 62~~ 61 bytes ``` a=>a.map(p=s=>a=a.slice([,x,y]=/(\d*)(.*)/.exec(s),p=x||p)+y) ``` [Try it online!](https://tio.run/##ZY1NEoIwDEb3XoRWsfg3o5t6EWQR2xQKhXaogzjD3TFduHLzknzJvLQwQVSjDa/94DWuRq4g7yB6CCzISK0EEZ1VyMp8zj@VLNhDbzkTW14InFGxyPMg52UJfPfhq/JD9A6F8zUzrMwAsjw7NYQzaqIdamJMoUuhtfE3j3qCsaPulsbL2ztD9TphzCrON3/mp6K1eqYHR41Ek9SNJRzaLtn7wRPpUKOpG9sm@fHgkm79Ag "JavaScript (Node.js) – Try It Online") ### Commented ``` a => // a[] = input, re-used to store the previous word a.map(p = // initialize p to a non-numeric value s => // for each string s in a[]: a = // update a: a.slice( // extract the correct prefix from the previous word: [, x, y] = // load into x and y: /(\d*)(.*)/ // the result of a regular expression which splits the new .exec(s), // entry into x = leading digits and y = trailing letters // this array is interpreted as 0 by slice() p = x || p // update p to x if x is not an empty string; otherwise leave // it unchanged; use this as the 2nd parameter of slice() ) // end of slice() + y // append the new suffix ) // end of map() ``` [Answer] # [brainfuck](https://github.com/TryItOnline/brainfuck), 201 bytes ``` ,[[[-<+>>>+<<]>-[---<+>]<[[-<]>>]<[-]>>[<<,>>>[-[-<++++++++++>]]++++<[->+<]-[----->-<]<]<]>>>[[>>]+[-<<]>>[[>>]+[<<]>>-]]+[>>]<[-]<[<<]>[->[>>]<+<[<<]>]>[>.>]+[>[-]<,.[->+>+<<]>>----------]<[<<]>-<<<,] ``` [Try it online!](https://tio.run/##PU7LDoMwDLv7VyCIx6TtUOVHqh7Ku8CYBBr7fJYAIj3Edm235eLD3H6rcd9jay2ZiJkjYxyTJVLqjMqOFZAsa0wsHktqvoed0yUWSbsjS8SS06N2KwWRRJRd5MAkQXuVm0OSikOITioCJ2pndcSJvnD@kOmeKyr1Jnb77j3yHkVTI8wdVuQTihBWRUu9@WXEa8Xj95laPLdmRerLClXpkdUN2g59QDqME97zB3JVN23Xh2FElk74Aw "brainfuck – Try It Online") Requires a trailing newline at the end of the input. A version without this requirement is 6 bytes longer: # [brainfuck](https://github.com/TryItOnline/brainfuck), 207 bytes ``` ,[[[-<+>>>+<<]>-[---<+>]<[[-<]>>]<[-]>>[<<,>>>[-[-<++++++++++>]]++++<[->+<]-[----->-<]<]<]>>>[[>>]+[-<<]>>[[>>]+[<<]>>-]]+[>>]<[-]<[<<]>[->[>>]<+<[<<]>]>[>.>]+[>[-]<,[->+>+<<]>>[----------<.<]>>]<[<<]>-<<<,] ``` [Try it online!](https://tio.run/##PU5BDoNACLzzlRUP2qQ9ED5COGyrthuNTdzUPn8LqykcYCYzMPctpnX6POZSGhFBCswciJRREB0qOa3sC9oQosY0gi7@F6v6MIm5tXoR2XzeLhc7EMzi6AR1RzPKeZwqZScqEQ5oBLcuZ1c0/uAIyMeTWtSeCWtysohaSozQvaAfB0jrEzJ0C/QpZd@2YY/bDLcMl@97meC6j/kH "brainfuck – Try It Online") Both versions assume all numbers are strictly less than 255. ## Explanation The tape is laid out as follows: ``` tempinputcopy 85 0 inputcopy number 1 a 1 a 1 r 1 d 0 w 0 o 0 l 0 f 0 ... ``` The "number" cell is equal to 0 if no digits are input, and n+1 if the number n is input. Input is taken at the cell marked "85". ``` ,[ take input and start main loop [ start number input loop [-<+>>>+<<] copy input to tempinputcopy and inputcopy >-[---<+>] put the number 85 in the cell where input was taken <[[-<]>>] test whether input is less than 85; ending position depends on result of comparison (note that digits are 48 through 57 while letters are 97 through 122) <[-]> clean up by zeroing out the cell that didn't already become zero >[ if input was a digit: <<,>> get next input character >[-[-<++++++++++>]] multiply current value by 10 and add to current input ++++ set number cell to 4 (as part of subtracting 47) <[->+<] add input plus 10*number back to number cell -[----->-<] subtract 51 <] move to cell we would be at if input were a letter <] move to input cell; this is occupied iff input was a digit part 2: update/output word >>> move to number cell [ if occupied (number was input): [>>]+[-<<]>> remove existing marker 1s and decrement number cell to true value [[>>]+[<<]>>-] create the correct amount of marker 1s ] +[>>]<[-] zero out cell containing next letter from previous word <[<<]> return to inputcopy [->[>>]<+<[<<]>] move input copy to next letter cell >[>.>] output word so far +[ do until newline is read: >[-]< zero out letter cell ,. input and output next letter or newline [->+>+<<] copy to letter cell and following cell >>---------- subtract 10 to compare to newline ] <[<<]>- zero out number cell (which was 1 to make copy loop shorter) <<<, return to input cell and take input ] repeat until end of input ``` [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~50~~ 48 bytes *-2 bytes thanks to nwellnhof* ``` {my$l;.map:{$!=S[\d*]=substr $!,0,$l [R||]=~$/}} ``` [Try it online!](https://tio.run/##RcvLCoJAAEbhfU/xC0NUSHmJisweopbmYnRmdHS84JQhaq9utmp34PDVvFGHqeiwFPAx9UVHlLctaH3uieHfgwfbhL5@RfrZgBimZRKF4DYMof8hu3GcvIWmHcTqQimcFC5nkGUCDUfBlVL/qmEtbXKcNPbvSgkcW66v67@MYsQRhc04RIJUwspyhaKsMC/GRZLKLIdtqRlNXw "Perl 6 – Try It Online") A port of [Arnauld's solution](https://codegolf.stackexchange.com/a/177809/76162). Man, that `R||` trick was a rollercoaster from 'I think this could be possible', to 'nah, it's impossible', to 'kinda maybe possible' and finally 'aha!' ### Explanation: ``` {my$l;.map:{$!=S[\d*]=substr $!,0,$l [R||]=~$/}} { } # Anonymous code block my$l; # Declare the variable $l, which is used for the previous number .map:{ } # Map the input list to $!= # $! is used to save the previous word S[\d*]= # Substitute the number for substr $!,0 # A substring of the previous word , # With the length of ~$0 # The num if it exists $l [R||]= # Otherwise the previous num ``` The `$l [R||]=~$/` part roughly translates to `$l= ~$/||+$l` but... it has the same amount of bytes `:(`. Originally, it saved bytes using an anonymous variable so the `my$l` was gone but that doesn't work since the scope is now the substitution, not the `map` codeblock. Oh well. Anyways, `R` is the reverse metaoperator, so it reverses the arguments of `||`, so the `$l` variable ends up being assigned the new number (`~$/`) if it exists, otherwise itself again. It could be 47 bytes if Perl 6 didn't throw a kinda redundant compiler error for `=~`. [Answer] # [Ruby](https://www.ruby-lang.org/), ~~49~~ ~~45~~ 43 bytes ``` $0=$_=$0[/.{0#{p=$_[/\d+/]||p}}/]+$_[/\D+/] ``` [Try it online!](https://tio.run/##HclLDkAwFEDR@duGzhr6LMDMLhBR9Smljc9A6NY9jeE9dzvlRcQwY3XGsBDJjdHtQhWiVFxUz@O8FxX/IQ9A1MgWWtlAqjroBxg14DQbWFYLYamuH0Y9zZCiea07tF13ip35AA "Ruby – Try It Online") ### Explanation ``` $0= #Previous word, assign the value of $_= #Current word, assign the value of $0[/.{0#{ }}/] #Starting substring of $0 of length p which is p=$_[/\d+/]||p #defined as a number in the start of $_ if any +$_[/\D+/] #Plus any remaining non-digits in $_ ``` [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~65~~ ~~57~~ ~~55~~ 53 bytes ``` n;b[9];c=b;f(){scanf("%d",&n);gets(c+n)&&f(puts(c));} ``` [Try it online!](https://tio.run/##FYndCoIwGIaPe68ihGSjBNOgYnQl0cH89uN0znBWB@Gtt@rs@aHCEiUX5vUgXWAcb6wM4wJLCqK5nm@CLo34lXckGQzLNirb5YELq@fIaBt4nht2f/yFc7GkJCWqFrVWcMEiovKonYt/mtRTTj1OEYfX6A2OTx1RyoZAjcReaRiL1qHseo8hjPgtpY1tXddjX/oPGS9tTMVQV18 "C (gcc) – Try It Online") ### Explanation: ``` n; /* `n` stores the shared prefix length, implicitly 0 */ b[9]; /* int[] buffer we read into, we need 12+1 bytes for the largest words, this buffer is 9*4=36 bytes */ c=b; /* if we use `b` in pointer arithmetic it would be an int*, but we want to address individual bytes, so we need to store the address as an integer. */ f() { /* the unpacking function */ scanf("%d",&n); /* read the common prefix length, if scanf fails because no new prefix length is given then `n`s value will remain the same, which is exactly what we want! :-) */ gets(c+n) /* read the suffix part, the first `n` characters are the common prefix */ && /* short-circuit, so if the gets fails the next part is not executed */ f(puts(c)); /* print the word that was extracted and call `f` recursively to handle the next word */ } ``` [Answer] ## Python 3.6+, ~~172~~ ~~195~~ ~~156~~ ~~123~~ ~~122~~ ~~121~~ 104 bytes ``` import re def f(l,n=0,w=""): for s in l:t=re.match("\d*",s)[0];n=int(t or n);w=w[:n]+s[len(t):];yield w ``` * -12 bytes thanks to [Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler) * -5 bytes thanks to [Dennis](https://codegolf.stackexchange.com/users/12012/dennis) [Try it online!](https://tio.run/##RY5BboMwEEX3c4oRK7tFKAqVWoF8i@woCxoPxYozWPYkDqen0Ejt38yX/tPohUWmmet1ddcwR8FIYGnEUfmSzaHMpih0AzjOERM6Rt@IiVRdBzlPqvi0L0WZdHfoWzaORQluIOs2m9w13L@mzhMr0U3fLo68xbx6NNj1kCfnCU/xRtv7LRKXZ9njK3oIsVWOw02UrlLwbrv6l6DHmYL801@RhgvAn@Mmr59riLtU0uswwHGCmiw4/oYERw@1c2lv0d6HeIGPBG959iO83yn9AA "Python 3 – Try It Online") ### Explanation I caved, and used Regular Expressions. This saved at least 17 bytes. : ``` t=re.match("\d*",s)[0] ``` When the string doesn't begin with a digit at all, the length of this string will be `0`. This means that: ``` n=int(t or n) ``` will be `n` if `t` is empty, and `int(t)` otherwise. ``` w=w[:n]+s[len(t):] ``` removes the number that the regular expression found from `s` (if there's no number found, it'll remove `0` characters, leaving `s` untruncated) and replaces all but the first `n` characters of the previous word with the current word fragment; and: ``` yield w ``` outputs the current word. [Answer] ## Haskell, ~~82~~ 81 bytes ``` tail.map concat.scanl p["",""] p[n,l]a|[(i,r)]<-reads a=[take i$n++l,r]|1<2=[n,a] ``` Takes and returns a list of strings. [Try it online!](https://tio.run/##dYxBbsIwFET3nGJksWhFQCRUahfkJGkWH9uJP/6xLTuCDWevmx6gi5FGevPGUfFWpLr@u67EclooQcegaT0VTUGQBqUapcZdGkIjI72GN27y@3g9ZkumgPphJW/B@3A4SJPHV3vt@m1LY12IA3qYuAOQMocVe7gtz5g3VRGhc7hYAw4zCjrBhbn8tWwelD2@Cj6eUSZ8PmxR/93cNPSN0BqLaYZjnO9esISIDRk7zY7vHu1ZVP3Rk9Bc6lGn9As "Haskell – Try It Online") ``` scanl p["",""] -- fold function 'p' into the input list starting with -- a list of two empty strings and collect the -- intermediate results in a list p [n,l] a -- 1st string of the list 'n' is the part taken form the last word -- 2nd string of the list 'l' is the part from the current line -- 'a' is the code from the next line |[(i,r)]<-reads a -- if 'a' can be parsed as an integer 'i' and a string 'r' =[take i$n++l,r] -- go on with the first 'i' chars from the last line (-> 'n' and 'l' concatenated) and the new ending 'r' |1<2 -- if parsing is not possible =[n,a] -- go on with the previous beginning of the word 'n' and the new end 'a' -- e.g. [ "aa", "2h", "3ed", "ing" ] -- -> [["",""],["","aa"],["aa","h"],["aah","ed"],["aah","ing"]] map concat -- concatenate each sublist tail -- drop first element. 'scanl' saves the initial value in the list of intermediate results. ``` Edit: -1 byte thanks to @Nitrodon. [Answer] # Japt, ~~19~~ ~~18~~ 17 bytes Initially inspired by [Arnauld's JS solution](https://codegolf.stackexchange.com/a/177809/58974). ``` ;£=¯V=XkB ªV +XoB ``` [Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=O6M9r1Y9WGtCIKpWICtYb0I=&input=WyJhYmMiLCJjYmEiLCIxZGUiLCJmZyIsImhpIiwiMGprbCIsIm1ubyIsImFiY2RlZmdoaWprIiwiMTBsIl0KLVM=) ``` :Implicit input of string array U £ :Map each X ¯ : Slice U to index Xk : Remove from X ; B : The lowercase alphabet (leaving only the digits or an empty string, which is falsey) ªV : Logical OR with V (initially 0) V= : Assign the result to V for the next iteration + : Append Xo : Remove everything from X, except ; B : The lowercase alphabet = : Reassign the resulting string to U for the next iteration ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes ``` ⁹fØDVo©®⁸ḣ;ḟØDµ\ ``` [Try it online!](https://tio.run/##y0rNyan8//9R4860wzNcwvIPrTy07lHjjoc7Fls/3DEfKHRoa8z/h7u3KBxuV4hUeLhj@6OGOQrBBTmZJToKyYk5OQpppXnJJZn5eToKWfmZeXr//ycmchllcBmnpnBl5qVzFXMZ5XAZZ2YWg1hFKWWJRdlcFsVcJuX5OWlc5mWpxQA "Jelly – Try It Online") ### How it works ``` ⁹fØDVo©®⁸ḣ;ḟØDµ\ Main link. Argument: A (array of strings) µ\ Cumulatively reduce A by the link to the left. ⁹ Yield the right argument. ØD Yield "0123456789". f Filter; keep only digits. V Eval the result. An empty string yields 0. o© Perform logical OR and copy the result to the register. ® Yield the value in the register (initially 0). ⁸ḣ Head; keep that many character of the left argument. ; Concatenate the result and the right argument. ØD Yield "0123456789". ḟ Filterfalse; keep only non-digits. ``` [Answer] # [Groovy](http://groovy-lang.org/), 74 bytes ``` {w="";d=0;it.replaceAll(/(\d*)(.+)/){d=(it[1]?:d)as int;w=w[0..<d]+it[2]}} ``` [Try it online!](https://tio.run/##RYzLboMwEEX3fAXyyk4kHkmkRCVW1O/IsDAeA07cARkEqqJ8Ox21iy7PuVeni8OwfG8m1akwBujQAx0dAnnqgCYWgYX30x9EXEx8Al0YTusQWqDz4iaRNL@BxgLZhjMlOqCWC70HKh5PjnzRAMQPdG3X@wdHyiKIxOrttWohKtRF5ecsujEY6z5DkLkE3CmZ7VWuXqiln@9lfftAZabU01yter0XWXbFes/ToX6/tzHyECi10qjkHxq1/QA "Groovy – Try It Online") ### Explanation: ``` { } Closure, sole argument = it w="";d=0; Initialize variables it.replaceAll(/(\d*)(.+)/){ } Replace every line (since this matches every line) and implicitly return. Loop variable is again it d=(it[1]?:d)as int; If a number is matched, set d to the number as an integer, else keep the value w=w[0..<d]+it[2] Set w to the first d characters of w, plus the matched string ``` [Answer] # [Python 2](https://docs.python.org/2/), 118 bytes ``` import re n=0 l=input() o=l.pop(0) print o for i in l:(N,x),=re.findall('(\d*)(.+)',i);n=int(N or n);o=o[:n]+x;print o ``` [Try it online!](https://tio.run/##LYxLDoMgFEXnrIIZ0BJjO9SwBTdgHfhDn@J7hNDErp5K08k9k3uO/8SV8JkSHJ5C5GFmaErmDKB/R6kYGVd48rJUzAfAyIlZChw4IHeVbPSptAlzYQGn3jkp5Gu6KVncldCgarxCUTb8UlDVZKitsLuf9b@VUiv6YRSai3HoMx7TnGGXvCvkLbfdZR5IGdd/mu2ywrb/hNKJ7gs "Python 2 – Try It Online") [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 69 bytes ``` +`((\d+).*¶)(\D) $1$2$3 \d+ $* +m`^((.)*(.).*¶(?<-2>.)*)(?(2)$)1 $1$3 ``` [Try it online!](https://tio.run/##FYs7DoMwEET7OccWu7aCsGlRaDgGijDYgPlFinK2HCAXM6aYYt68@YRvPF1KumfuvJZC/X/CXSsgQ5YqZAhS0Ef/Yi5E5dwON/XDPnMXbtgKibkPVUpuGDEODsYHTDOWiHLddhznG3nyYZqXuG4w5X4B "Retina 0.8.2 – Try It Online") Link includes harder test cases. Explanation: ``` +`((\d+).*¶)(\D) $1$2$3 ``` For all lines that begin with letters, copy the number from the previous line, looping until all lines begin with a number. ``` \d+ $* ``` Convert the number to unary. ``` +m`^((.)*(.).*¶(?<-2>.)*)(?(2)$)1 $1$3 ``` Use balancing groups to replace all `1`s with the corresponding letter from the previous line. (This turns out to be slightly golfier than replacing all runs of `1`s.) [Answer] # [Red](http://www.red-lang.org), 143 bytes ``` func[b][a: charset[#"a"-#"z"]u: b/1 n: 0 foreach c b[parse c[copy m to a p: copy s to end(if p<> c[n: do m]print u: rejoin[copy/part u n s])]]] ``` [Try it online!](https://tio.run/##LY5BTsMwEEX3PsVX2MAC0TSkKRXiEGyjLBx7nLhx7MhOi6Dq2cu4sLDk73n/eSLp2yfpthPmcDMnr9q@a@UBapQx0do@FLJ4fih@iu50QP9Swh@wgQmRpBqh0LdLBqFaFZZvzFgDpFhYkGPKkbx@tAbL@wdTXNcBc7dE61ewM9IxWH9vv7CK3@CRuqeu624GaXF2FRfZK6F6KUpNwgxitGJznJyYfRA80mSG0R4nUW7cFZ6@nPUkxN8XRSHEv@ciJbYjKtKwfuDltg6VtSnfoj7LOGGf8PoVnEFzpoRqGBH57EZsOZ3DQC4jZY@tRKUkauYnrBStdDgl7HLLrJhkggue0HCeF4qUe0xXXgePhlfYR7wlNHmTmXjRskx3erGKXewl1Bo79436Pme4jtjdLa8jalbkwP1rgeL2Cw "Red – Try It Online") [Answer] # [Perl 5](https://www.perl.org/) `-p`, ~~45~~ 41 bytes ``` s:\d*:substr($p,0,$l=$&+$l*/^\D/):e;$p=$_ ``` [Try it online!](https://tio.run/##FcdRCsIwDADQ/5wjiM7JxqYolf15jKFUG2cxrKGZ8/ZG/XtPKPPOTF0fCqevq055iVLWJXKHizVyUZ37U7VydETp8GLmPTQPaClAHAdQaBjaGPWvHGafn3BQ2L4T32E/k0J9S4GGXz9JpphGtY18AQ "Perl 5 – Try It Online") Explanation: ``` s:\d*:substr($p,0,$l=$&+$l*/^\D/):e;$p=$_ Full program, implicit input s: : :e; Replace \d* Any number of digits substr($p,0, ) By a prefix of $p (previous result or "") $l= + With a length (assigned to $l) of the sum $& of the matched digits * and the product $l of $l (previous length or 0) /^\D/ and whether there is no number in the beginning (1 or 0) (product is $l if no number) $p=$_ Assign output to $p Implicit output ``` [Answer] # [Java (JDK)](http://jdk.java.net/), 150 bytes ``` a->{String p="",s[];for(int n=0,i=0;i<a.length;a[i]=p=p.substring(0,n=s.length<1?n:new Short(s[0]))+a[i++].replaceAll("\\d",""))s=a[i].split("\\D+");} ``` [Try it online!](https://tio.run/##fVDBitswFLznKwZBwW68wtkttMTxlqW99pRj1gfFlm05smT05IRlybenVuINhdIKhKQ3b@bNqBNH8dBVh4vqB@s8uunNR680/5wt/qrVoym9siaApRZE@CWUwfsCGMa9ViXICz8dR6sq9BMWbb1TptkVEK6h@NoK/LCGxl66zQf6jBr5RTw8v98qGHLGEtoVWW1dpIyHydNE5WmmNoJraRrfZmKninzIB07jnq60KE1MTjO@WX03ayNP2LZTioh2aRHHy4m0XBbcyUGLUr5oHbHX14oljMUx5UGS06CVD@WfSxZn50t29XwP4iV5Qj5HCYsJgccWT7JC8E541HhSisLNVUfhDvhG@HKyusbXoySW/EHdlyj3AqtKom7QKqTdQaM3FhNUybppVXfAKtVsJp1vfsLHzJ8VHK1vvuK7rWksTtZVwWqAPmJhyjS3bN/Iy57b0fNhEvJ1xD7RGizBi3Pijbi3twnRVSi@E2suylIOfq7/S0@b6L9C50XY58tv "Java (JDK) – Try It Online") [Answer] # [Scala](http://www.scala-lang.org/), 226 129 102 bytes Thanks @ASCII-only for their work here (and for the Groovy answer). ``` s=>{var(w,d,r)=("",0,"(\\d*)(.+)".r) s map(_ match{case r(a,b)=>{if(a>"")d=a.toInt w=w.take(d)+b} w})} ``` [Try it online!](https://tio.run/##TY5NS8QwEIbv/RUhp8QNpVXBReiCF0HQk8fdRab52KbtpiWJW6H0t9eJsOrlybzDZJ4JEnpYh7rVMpI3sI7or6idCuRpHMmcXcAT8/j86WS0gyv3rzbE/Xv01p2O4n84VmuodjPOs0ko4XnFKBWFoOxwUDec5RtOc8@zQM4wsg9klM0sIWjiGYia42drGOwo5aqCPA4vLmZTNeUROs0U39RLNi18WUf0xd4xw5KfUQAq6G2DuNMKidcgQ2r2qWltuGav8L4Oq22K99PQG3wfLjpQznl23fxX/TpqiYOyTqpSaaRJksYiirZLnrMbkDiotDk1tk2asuh/Fi/rNw "Scala – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~20~~ ~~19~~ ~~17~~ 16 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` õUvyþDdi£U}Xyá«= ``` [Try it online](https://tio.run/##yy9OTMpM/f//8NbQssrD@1xSMg8tDq2NqDy88NBq2///o5USE5V0lIwygIRxagqQzMxLB5LFIMEckGBmZjGMX5RSlliUDWRZgLgm5fk5aUDavCy1WCkWAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V@m5OkXEBpipaBkX@mio@QfGgLh6fw/vDW0rPLwPpeUzEOLQ2sjKg8vPLTa9n/toW32/6OjlRITlXSUjDKAhHFqCpDMzEsHksUgwRyQYGZmMYxflFKWWJQNZFmAuCbl@TlpQNq8LLVYKVZHAWhUUjKQn5wEMtEwJRVIpoHMysgEEgZZ2SDjcvPygSRQYUpqWnpGZhbINEODHKXYWAA). **Explanation:** ``` õ # Push an empty string "" U # Pop and store it in variable `X` v # Loop `y` over the (implicit) input-list: yþ # Push `y`, and leave only the digits (let's call it `n`) Ddi } # If it's a non-negative integer (thus NOT an empty string ""): £ # Pop and push the first `n` characters of the string U # Pop and store it in variable `X` X # Push variable `X` yá # Push `y`, and leave only the letters « # Merge them together = # Print it with trailing newline (without popping) ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 27 bytes ``` f€ȯ@\V,ɗḟ€ɗØDZẎḊṖḣ2/Ż;"f€Øa ``` [Try it online!](https://tio.run/##y0rNyan8/z/tUdOaE@sdYsJ0Tk5/uGM@kHdy@uEZLlEPd/U93NH1cOe0hzsWG@kf3W2tBFJ5eEbi/8Pt2vpA5tFJD3fO@P8/Wj0xKVldR0E9OSkRRBmmpIKotHQQmZEJIg2ysnNAdG5ePogCqk9JTUvPyMzKBmswyFGPBQA "Jelly – Try It Online") [Answer] # [Groovy](http://groovy-lang.org/), ~~103~~ 99 bytes ``` {w=it[0];d=0;it.collect{m=it=~/(\d+)(.+)/;i=m.find()?{d=m[0][1] as int;m[0][2]}():it;w=w[0..<d]+i}} ``` [Try it online!](https://tio.run/##VU7daoMwGL3vUxy8ShBStYONZmEPYr2IiT9fjVpMUIq4V3euN2N355/TTOM4P3cNhUhrZC0ulQUNDTwyhwuR/0WTnfXU4cPjbRldjfe58pHwD0eBRYj4qXwNlAam1EhthbpBS0junUM/jDgsW9VNS/cOaeL@dY3a10VRyJNCWpVICsKMzlUmrP0hq@8zu9mYMxHzsyTVi5oGy/jXalV/dPK0gPbH5yBfNCs2xq8U5KKWPBHi0xYxbdv@mI6IG2CY5qc/UvL9Bw "Groovy – Try It Online") [Answer] # Common Lisp, 181 bytes ``` (do(w(p 0))((not(setf g(read-line t()))))(multiple-value-bind(a b)(parse-integer g :junk-allowed t)(setf p(or a p)w(concatenate'string(subseq w 0 p)(subseq g b)))(format t"~a~%"w))) ``` [Try it online!](https://tio.run/##NU3RagMxDHv3V5jCmPMQKO1gY3/ju/huWdMki32Xt/76LWXMIJCEJM8paj0OCoU6VTw7R5SLkYotuFITDj7FLGjknkf3LVmsSfzOaRM/xRyIcXJUuan4mE1Wabji5/eWb55TKl0CmvubrFQaMlbXaS55ZpM88KrWYl5Jt0nlBzueR@JfrWN9PF5Ku7OhnR78eDn1YR0HM1y@4CoBRhsULgmuMeqTtbBzu8GHwlsvaYH3XRR@AQ) Ungolfed: ``` (do (w (p 0)) ; w previous word, p previous integer prefix (initialized to 0) ((not (setf g (read-line t ())))) ; read a line into new variable g ; and if null terminate: (multiple-value-bind (a b) ; let a, b the current integer prefix (parse-integer g :junk-allowed t) ; and the position after the prefix (setf p (or a p) ; set p to a (if nil (no numeric prefix) to 0) w (concatenate 'string ; set w to the concatenation of prefix (subseq w 0 p) ; characters from the previous word (subseq g b))) ; and the rest of the current line (format t"~a~%"w))) ; print the current word ``` As usual, the long identifers of Common Lisp make it non particularly suitable for PPCG. [Answer] # [Python 2](https://docs.python.org/2/), ~~101~~ ~~100~~ 99 bytes ``` import re s=n='0' for t in input():(m,w),=re.findall('(\d*)(.+)',t);n=m or n;s=s[:int(n)]+w;print s ``` [Try it online!](https://tio.run/##TY89b8IwEIbn@lecxHB2iRDQSq1AGenapRtlMMQhJo4dnQ0pvz71pZVaybr39X35cX9PTfDr8RQqAyUQIo626wMlICNi6UtcoqgDQQLr8@mvSaqN7IpBFSWZRW19pZ2TKD@rRyUXc4VFUltfdpCH/DaWcb@xPkmvDvNh21P2EMf8jhga6wx80NVsxEOie44P5sucgGGy/@nFGYqcPpk@we79bUcUiDuPZHQrZrVUQszgt1cf8/RRwyr/pj5DY2F5aR10PkAuVaY@N/bSwmrpcBF7Z5NEQDXuUWssANcNxydTsVh/ZolTwU0Fa@Nfiqqbppbt65R4HoKr2bzcTMSD2DMN3zMQS2ZiqaetjeXIcKyZj@Uf4jSQKQ/f "Python 2 – Try It Online") [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 134 bytes ``` a=>{int l=0,m,n;var p="";return a.Select(s=>{for(m=n=0;s[m]<58;n=n*10+s[m++]-48);return p=p.Substring(0,l=m>0?n:l)+s.Substring(m);});} ``` [Try it online!](https://tio.run/##dVFNa8MgGL7nV0hOyZKWdOtYmTVjhw12G3S3koMxprFVU9S0jJLfnhmC0rINPDxf@j68Ej0jmg3vnSTrjzfZCapwyelaG8XkLk//0HJQAzRglF@YNICjLBWphCeswBGFIVTUdEoCPN9QTomJtA3WrYoEkiiDeiuK9eMKSiTvFlliaZIUs@UqdveO6DjfdOU0K8pSjkSevchnHif6yhAx7O0ZYBBMyrbYFsBQbTRAQNIzuJIvAbiRRg5AiHGYTui@ceiBVg7aqIPaB7kPMqZ/26qyezg4uvLG8tzy2pGnE52MPv2nWElclpS@5KKiDta@WcMcyvYHX07I1kH7VkXrXcP2vtYi4258b/dnP4di0kTjD44LBExOi4zHOp@2mYnqaFTi@Vf7qhT@juIYBv3wAw "C# (Visual C# Interactive Compiler) – Try It Online") -9 bytes thanks to @ASCIIOnly! Less golfed... ``` // a is an input list of strings a=>{ // l: last prefix length // m: current number of digits // n: current prefix length int l=0,m,n; // previous word var p=""; // run a LINQ select against the input // s is the current word return a.Select(s=>{ // nibble digits from start of the // current word to build up the // current prefix length for(m=n=0; s[m]<58; n=n*10+s[m++]-48); // append the prefix from the // previous word to the current // word and capture values // for the next iteration return p=p.Substring(0,l=m>0?n:l)+ s.Substring(m); }); } ``` ]
[Question] [ For this challenge you need to implement two functions, **f** and **g**, on the integers, such that **f ∘ g** is a strictly decreasing function while **g ∘ f** is a strictly increasing function. In other words, if you take any two integers **a < b**, then **f(g(a)) > f(g(b))** and **g(f(a)) < g(f(b))**. There are no restrictions on **f** and **g** individually, except that they must each map one integer to another integer. Please include a short description of **f** and **g** and an argument for why they have the required property. **Credit:** This challenge was inspired by a problem in the 2011 Romanian Master of Mathematics competition (which asks the same thing but on the real numbers, instead of integers). If you really want spoilers, you now know what to search for. ## Rules * The word "function" in this challenge should be taken in the mathematical sense of mapping one integer to another: you may either write [two programs or two functions](https://codegolf.meta.stackexchange.com/q/2419) and use any of the [standard methods](https://codegolf.meta.stackexchange.com/q/2447) of receiving input and providing output, as usual. You may use string representations of integers instead of actual integer variables, but the types of input and output should be identical, so that the functions can be composed without manually converting types in between. Remember that conceptually, **f** and **g** still need to be functions on ℤ, so you can't cheat by using two different string representations of the same number or anything like that. * Remember that [functions may be unnamed](http://meta.codegolf.stackexchange.com/questions/1501/should-function-literals-be-allowed-when-a-function-is-asked-for/1503#1503), as long as their name isn't needed by itself or another function you define. If you do name one or both of the functions, you may assume that they exist in the same program, so that they may refer to each other in their implementation (e.g `def f(x): return -g(x)` in Python). * The usual integer overflow rules apply: your solution must be able to work for arbitrarily large integers in a hypothetical (or perhaps real) version of your language in which all integers are unbounded by default, but if your program fails in practice due to the implementation not supporting integers that large, that doesn't invalidate the solution. * You may use any [programming language](https://codegolf.meta.stackexchange.com/q/2028), but note that [these loopholes](https://codegolf.meta.stackexchange.com/q/1061/) are forbidden by default. * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so your score is the sum of the *number of bytes* of both functions and the shortest valid answer wins. [Answer] # Python, 68 characters ``` f=lambda x:(1-x%2*2)*(2*x*x+(x<0)) g=lambda x:(1-x%2*2)*(2*x*x+(x>0)) ``` f maps negative numbers to odd numbers and positive numbers to even numbers, and even numbers to positive numbers and odd numbers to negative numbers, with the output magnitude increasing strictly with the input magnitude. g does the same, except it maps negative numbers to even numbers and positive numbers to odd numbers. f ∘ g maps negative → even → positive and positive → odd → negative. g ∘ f maps negative → odd → negative and positive → even → positive. Therefore f and g have the desired properties. [Answer] ## CJam (17 bytes) Function f (named `F` because CJam only allows upper-case names): ``` {W1$2b,#*}:F ``` Function g (anonymous): ``` {F2*} ``` [Online demo](http://cjam.aditsu.net/#code=%7BW1%242b%2C%23*%7D%3AF%7BF2*%7D%0A%0A%3AG%3B%3B%0A21%2C10f-%7BFG%7D%25p%0A21%2C10f-%7BGF%7D%25p%0A) This saves a byte by relying on a implementation detail of CJam which is arguably a bug: when doing base conversions it uses absolute value. `2b,` therefore gives the number of bits in the absolute value of its argument, so f negates precisely those numbers whose absolute value has an odd number of bits. g applies f and then doubles (changing the parity of the number of bits). So applying f and then g leaves sign unchanged and doubles, mapping `x` to `2x`. Applying g and then f changes the sign exactly once and doubles, mapping `x` to `-2x`. [Answer] # [Python](https://docs.python.org/2/), 40 bytes ``` f=lambda x:x*(-1)**x g=lambda x:3*f(x)+1 ``` [Try it online!](https://tio.run/nexus/haskell#@5@mUGFboaWha6ippVXBlQ7kGWobawFF/@cmZuYp2CrkJhb4KhQUZeaVKKgoRAN5CoUK0bqGBnp6hgaxCjUKhTa60Wl66ToK6XppsbH/AQ "Haskell – TIO Nexus") Some outputs are floats that equal integers because `(-1)**(-3)` gives a float for instance. Based off [ideas from Peter Taylor](https://codegolf.stackexchange.com/a/115558/20260). The function `f` negates odd numbers and leaves even ones unchanged. The function `g` does the same, then applies the monotonic parity-switching map `x -> 3*x + 1`. Since `f(f(x)) = x`, we have `g(f(x)) = 3*f(f(x))+1 = 3*x+1` increasing. For `f(g(x)) = f(3*f(x)+1)`, the idea is that exactly one of the inner and outer `f` flips sign, making it decreasing. * For even `x`, `f(x) = x`, but `f(3*x+1) = -3*x-1` because `3*x+1` is odd. * For odd `x`, `f(x) = -x`, and `f(-3*x+1) = -3*x+1` because `-3*x+1` is even. We now only need the even and odd inputs interleave in a decreasing way, which holds because `-3*x±1` is decreasing regardless of how the signs are chosen. This is why the `3*` is needed. A Haskell port is 25 bytes: ``` f x=x*(-1)**x g x=1+3*f x ``` [Try it online!](https://tio.run/nexus/haskell#@5@mUGFboaWha6ippVXBlQ7kGWobawFF/@cmZuYp2CrkJhb4KhQUZeaVKKgoRAN5CoUK0bqGBnp6hgaxCjUKhTa60Wl66ToK6XppsbH/AQ "Haskell – TIO Nexus") [Answer] # Pyth, 34 Bytes This is just a direct translation of my Python answer. ``` *-1*2%Q2+*2*QQ<Q0 *-1*2%Q2+*2*QQ>Q0 ``` ]
[Question] [ Everyone knows that the content makes the question. But a good title helps too, and that's the first thing we see. It's time to turn that first impression into a program, and figure out what kinds of titles get more upvotes. You are hereby challenged to write a program or function that takes the title of a PPCG question as input, and returns a prediction of its score. For instance, you might receive `Counting Grains of Rice` as an input, and you would be trying to return something close to the score, `59` in this case. Non-integer guesses are fine, but guesses at or below `-20` are not. Here is the data, for testing and scoring: <http://data.stackexchange.com/codegolf/query/244871/names-and-upvotes> **Scoring:** Your program will be run on every question in this site's (PPCG) history, not counting closed questions. The function `ln(score + 20)` will then be applied to each score, and to each guess. The root-mean-squared-error between the two resultant sets of values is your score. Lower is better. For instance, a program that guessed 0 every time would score 0.577, while one that guessed 11 every time would score 0.362. Please calculate your score and include it in the title of your answer. Please also include your program's prediction for how many upvotes this question will get. **Restrictions:** * To prevent excessive hard-coding, no more than 1000 characters. * Must run on the entire data set above in under a minute on a reasonable machine. * Standard Loopholes are closed. --- Here is a tester written in Python, for your use and/or to clear up ambiguities: ``` import sys import math import csv scores_dict = {} with open(sys.argv[1], 'r') as csv_file: score_reader = csv.reader(csv_file) for score, title in score_reader: if score == 'Score': continue scores_dict[title] = int(score) def rate_guesses(guesser): def transform(score): return math.log(score + 20) if score > -20 else 0 off_by_total = 0 lines_count = 0 for title in scores_dict: guessed_score = guesser(title) real_score = scores_dict[title] off_by_total += (transform(real_score) - transform(guessed_score)) ** 2 return (off_by_total/len(scores_dict)) ** .5 def constant11(title): return 11 print(rate_guesses(constant11)) ``` [Answer] # Javascript ES6 ## Score: 0.245663Length: 1000 bytesPredicts: 5 (I guess the question is due for an unexpected avalanche of downvotes. :P) ### Minified ``` E="ABCDEFGHIJKLMNOPQRSTUVWXYZ";E=E+E.toLowerCase()+"0123456789!@#$%;*()";P="RCRHIFMGPGIDQKHMJLLRMLFJGKHEqHPOgJNKGPCHPJNUPOSGJQKKKMELMIJHLKIKNcKDOfSJLFHDILGKIOUKLMLLKMKIHGHJGIIJDGJKIHIIFIGMTIHFJMIKDJGQJKGMKJHPRJPLMGIOPIIIIPBYFMGLEIKIMMRUKFLFGJFKFTHPFODEQTGTHKIJDHNJGDGiHKNYLHHDLJHGILOEViKNEKGQZfHJMIISIJFRHKLJMLPIFJILKKKJKKJESHNLLIKIGKGJJJHKJRGULLSLRONJNEeLKIQGGPQIHPLEIHHIDXjQHNBKOGWWIENRbYoHINHNMKTNKHTGMIPXFJLLMLIHPPLDJJKFUMIQMOKJLJJKIJKNLHRILJIAIbJEZOGIELGHGLOINDPJMJeJWRIIJHSOZDOsOFRRIOIOTIJSGGJKFUIDOINGOcLQEJFEITLMNIIGIGIMG7LPSNLKVOKIFGHJITGOFUJIIRN";K={};"99r1501vz076mip077myv0733it280exx081gt9118i1g279dyx102uho203ejd07433z087uje097kdg1567ft2088rk275dmu1203ez106lih1763ei126f6q101aax084owh088aid161i9y179gvn236ptn3338vf132i55080fke101l4z3789ai281ulm081blm124euz074o5m07513z14117l095qdn092gl30757n5153".replace(/(...)(...)/g,(_,a,b)=>K[a]=1*b);D=40655;N=479;H=(s,T)=>(h=7,[...s].map(c=>h=~~(h*T+c.charCodeAt(0))),h);S=s=>(y=H(s,31),K[((y%D+D)%D).toString(36)]||E.indexOf(P[(H(s,48)%N+N)%N])); ``` ### Expanded ``` E = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; E = E + E.toLowerCase() + "0123456789!@#$%;*()"; K = {}; P = "RCRHIFMGPGIDQKHMJLLRMLFJGKHEqHPOgJNKGPCHPJNUPOSGJQKKKMELMIJHLKIKNcKDOfSJL" + "FHDILGKIOUKLMLLKMKIHGHJGIIJDGJKIHIIFIGMTIHFJMIKDJGQJKGMKJHPRJPLMGIOPIIIIP" + "BYFMGLEIKIMMRUKFLFGJFKFTHPFODEQTGTHKIJDHNJGDGiHKNYLHHDLJHGILOEViKNEKGQZfH" + "JMIISIJFRHKLJMLPIFJILKKKJKKJESHNLLIKIGKGJJJHKJRGULLSLRONJNEeLKIQGGPQIHPLE" + "IHHIDXjQHNBKOGWWIENRbYoHINHNMKTNKHTGMIPXFJLLMLIHPPLDJJKFUMIQMOKJLJJKIJKNL" + "HRILJIAIbJEZOGIELGHGLOINDPJMJeJWRIIJHSOZDOsOFRRIOIOTIJSGGJKFUIDOINGOcLQEJ" + "FEITLMNIIGIGIMG7LPSNLKVOKIFGHJITGOFUJIIRN"; ("99r1501vz076mip077myv0733it280exx081gt9118i1g279dyx102uho203ejd07433z087u" + "je097kdg1567ft2088rk275dmu1203ez106lih1763ei126f6q101aax084owh088aid161i9" + "y179gvn236ptn3338vf132i55080fke101l4z3789ai281ulm081blm124euz074o5m07513z" + "14117l095qdn092gl30757n5153"). replace( /(...)(...)/g, (_,a,b) => K[a] = 1*b ); D = 40655; N = 479; H = (s,T) => ( h = 7, [...s].map( c => h = ~~(h*T + c.charCodeAt(0)) ), h ); S = s => ( y = H( s, 31 ), K[((y%D + D)%D).toString( 36 )] || E.indexOf( P[(H( s, 48 )%N + N)%N] ) ); ``` The function `S` accepts a string (title) and returns its score. Notes on Behaviour: * ≤ 70 vote titles are handled separately from > 70 vote titles * ≤ 70 vote titles are sorted into bins using a highly sophisticated holonomic keyword tracking potential optimization algorithm that in no way resembles a string hash function * after a bit of happy calculus it turns out that the optimal guess for each bin is simply the geometric average of the (votes + 20)'s for all titles in the bin, minus 20 * the optimal guesses for all 479 bins are then encoded as a 479-character base-70 string * for > 70 vote titles, the titles are assigned unique 3-digit base-36 codes generated using a state-of-the-art hashing technique that guarantees no collisions with other > 70 vote titles and no false detections of ≤ 70 vote titles. This state-of-the-art technique in no way resembles trying random bin counts until one produces no collisions. * the > 70 vote title codes and their vote counts are encoded in a string (6 bytes per title), which is converted to a simple lookup table. The routine therefore has zero error for all > 70 vote titles. [Answer] ## Python 2, Score = 0.335027, 999 chars, Predict 11.34828 for this question Just to get the ball rolling. This is nowhere optimal. The fancy SVM thing is just my random idea and I felt like implementing it, so here it is. It does improve the baseline by 0.02 points, so I'm happy enough with that. But to show that hard-coding the input is where the majority of the improvement comes from, I'm hard coding some answer also. Without the hard-coding the score is 0.360 (and actually all the predictions are around 11, haha) I'm using [scikit-learn](https://github.com/scikit-learn/scikit-learn) and [nltk](http://www.nltk.org/) ``` import sys import math import csv from sklearn.feature_extraction.text import TfidfVectorizer as TV from sklearn.svm import SVR from nltk.stem.porter import PorterStemmer as PS sd = {} lr = None tv = None with open(sys.argv[1], 'r') as cf: sr = csv.reader(cf) for sc, t in sr: if sc == 'Score': continue sd[t] = int(sc) ts,scs = zip(*sd.items()) s = PS() def analyzer(st): r = [] for word in st.split(): if word.isdigit(): r.append('<NUM>') elif not word.isalnum(): r.append('<PUNCT>') else: r.append(s.stem(word.lower())) return r tv = TV(min_df=25, stop_words='english', analyzer=analyzer) ti = tv.fit_transform(ts) lr = SVR() lr.fit(ti, scs) d={'4 w':378,'y 42':333,'eeta':280,'an Got':279,'s 2 ':275,"e I'":208,'r CP':203,'? No':179,'B.O':156} def c(t): for s in d.keys(): if s in t: return d[s] t = tv.transform([t]) r = lr.predict(t)[0]+1.5 return r ``` [Answer] # Python 2, 991 chars, score 0.221854834221, predict 11 ``` import base64 e={} d=base64.decodestring('vgAcRAEVDAIsqgQYalYaggcjQKwVXAoZWAsYQg0Ckg4VlWEX9hEDRhMe0hckCBkeuhsW3CAWQiEm\nSiMZMiwgTDAZZjIcSLMZfDQDnjwCe2AVaEQCYWEBIEgnDEoXzk0e3lQb5FYVKlkVZlwB+F0XwmI/\nGmRcuGUXWmYdVGkbzmwafG8eaHMdInkggHonRn5sKoMXgIkpbowVOI4cNJAubpQdYpcydJgVypkA\nZpweMp8ZsqEcRKMghKQYkKVPPXEWMqkWHKwbjrEdzLIBNLMf1LQivrYC99UV9rxNRsABNMEiPzob\npc0ActAhn3gcrNUZYNcWYNov/t8VgOEXAuMYqOUWsqUiCPIefPWNbvtKevwWvP0Cl9UsjQMdWwQb\nfQdpJQgWYwkCZRLBjxMWWdkqHRkWNxwB6x8p2SEZyyICSyYcgysaOS0CUy8hezAaGeEVpTRQ3zUz\nZzkZRzohizwwST4c8UAdF0OqG9AXIuEYYRN6208nU1AktVEVJ1IVWeMkIVQXdY4D2VYYD/cYb1om\nG1xA0zoY3uUaRWAhWpBSHWUXQTxGe+cad20CO3AZX3EBw3IiMXcef3gecXsVGXwhw30VbX4W24BD\n6qyQ45YaYYgZ4YobbYwauY4bMY82HZEdO5YmQ5cV35sVxaMbY6gYNas576ws+bADO7QpN7hdLJ8B\n4Eoks8EYX8VU68cYWfcar82QOdAaxdEfQ9UiW/kXL9k2ddwCW90m694enqUCkeEBE+IYWvsfA1FC\nJ+spMVIjhe4WEP0fAfYax/c3MfgbgfkqP/0DLf4V\n') for i in range(0,600,3): e[ord(d[i])*256+ord(d[i+1])]=ord(d[i+2])*2-8 def p(t): return e.get(hash(t)%256**2,11) ``` # Explanation: This is shameless hardcoding, but trying to do it efficiently. ## Preprocessing: In a separate code, I hashed each title to a value between 0 and 256^2-1. Let's call these values bins. For each bin, I calculated the average score. (Average is needed because for a tiny fraction of the bins, there are collisions - more than 1 title hashes to the same bin. But for the vast majority each title maps to a bin of its own). The idea behind the 2-byte code for each title is that 1 byte is not enough - we get too many collisions, so we don't really know what score to assign to each 1-byte bin. But with 2-byte bins, there are almost no collisions, and we effectively get a 2 byte representation of each title. Then **rank** the bins - compute the gain in score if we assign this bin its computed value, instead of just guessing 11. Take the top N bins, and code them into a string (which is d in the actual code). The encoding: the key of the bin is coded as 2 bytes. the value is encoded using 1 byte. I found values between -8 and 300+something, so had to squeeze a bit to get it into 1 byte: x -> (x+8)/2. ## Actual code: read d as byte triplets, decoding the encoding explained above. When a title is given, compute its hash (modulo 256^2), and if that key is found in the dict, return the value it maps to. Otherwise, return 11. [Answer] # Python 2, 986 chars, score 0.3480188, predict 12 ``` M,S=14.29,23.02 D=lambda x:[ord(y)-32 for y in x] w='fiLoNoNuMiNoTiMoShOnLoGoLeThRantexgensuBaSqUnInPeReGaMuLinprOuThInThEvEnClOpExPyThADdiSoLiSiMaTrEqUsImAsCoManstARrePoWoReawhapoLandradeTyPaLOsoReCreprediVeReSpebeTiPrImPladaTrihelmakwhicolpaReValpaTrafoROsoumovfinfunpuzyoufaSeQuiwhecoDeChagivcouchehanpoStrdiGraconjavwricalfrowitbinbrafrabuipoi' for i in range(26):w=w.replace(chr(65+i),chr(97+i)*2) w=[w[i:i+3]for i in range(0,372,3)] m=D("(+),+)+=*...+..++'(*)5)/2)*43++16+0,+33*4*/(0.'+>-)+13+(2?8+6;,3;43+4(+.('(,.*.*+56+6)0((++(B,))+E0,-7/)/*++),+***)2+(3(.*)'") s=D("))'B)'*j+:51(*3+0')+)^'/<-+MG,-1=),-0:A+T&J&K1%,O*()4Y-%:_A.=A*C]MJ-N%)5(%%-0+).*3Q(M&0'%(+$p*)()a8:-T?%5(-*'/.'+)+@,'J&1'&&") def G(x,m,s):s=s or 1e-9;return(.4/s)*(2.78**(-(x-m)**2./(2*s*s))) d={w[i]:(m[i],s[i])for i in range(124)} def Z(t,c): p=1 for W in t.split(): if len(W)>3: W=W[:3].lower() if W in d:p*=G(c,*d[W]) return p*G(c,M,S) def J(t):return max([(Z(t,r),r)for r in range(-9,99)])[1] ``` The relevant function is `J`. The program is essentially [Naive Bayes](https://en.wikipedia.org/wiki/Naive_Bayes_classifier) using title words as features, but it's extremely restricted thanks to the char limit. How restricted? Well... * For each title we convert to lower case and only look at words at least 4 letters long. Then we take the **first three letters** of each of those words as features. We skip stripping punctuation to save on chars. * We choose only letter triplets which are at the start of **at least 19** words (these are stored in `w` above). Compression is done by rearranging the triplets so that as many doubled letters are present as possible, and these pairs are replaced with their corresponding ASCII uppercase (e.g. fiLoNoN... → fil, lon, non, ...) * For each triplet, we look at the scores of the titles in which it appears and calculate the mean and standard deviation of the scores. Then we **convert those to integers** and store them in `m`, `s` above, by using the fact that the mean/sd are at most 90 (allowing a direct ASCII encoding, since there are 95 printable ASCII) * `G` is the normal distribution function - we round e to 2dp and the inverse square root of 2 pi to 1 dp to save on chars. Altogether the extreme char limit made this one of the worst ideas I've ever come up with, but I'm pretty happy with how much I managed to cram in (even though it doesn't work very well). If anyone has better ideas for compression, please let me know :) (Thanks to KennyTM for pointing out my pointless compression) [Answer] # Python 2, 535 chars, score 0.330910, predicts 11.35 Average the score for titles containing each word, then use the top and bottom 50 words to possibly modify the BASE score in the `guess(title)` function. Python code: ``` BASE = 11.35 word={} for sc,ti in csv.reader(open(sys.argv[1])): if sc == 'Score': continue parts = re.findall(r"[-a-zA-Z']+", ti.lower()) for p in parts: a, c = word.get(p, (0.0,0)) word[p] = (a+int(sc), c+1) rank = sorted([(sc/ct,wd) for wd,(sc,ct) in word.items() if ct > 2]) adjust = rank[:50] + rank[-50:] def guess(title): score = BASE parts = re.findall(r"[-a-zA-Z']+", title.lower()) for sc,wd in adjust: if wd in parts: score *= 0.7 + 0.3*sc/BASE return score ``` [Answer] # C ## Score: UnknownLength: 5 bytesPredicts: 5 ## Golfed: ``` int s(char *p){return 5;} ``` ## Ungolfed: ``` int s(char *p) { return 5; } ``` A query of the scores gives an average score of 5. I've not got the ability to test it at the moment, others are welcome to run/edit. ]
[Question] [ **Monday Mini-Golf:** A series of short [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenges, posted (hopefully!) every Monday. True story1: The other day, I was playing around on my tablet when I had the idea to visit [the page](http://www.webtoolkitonline.com/javascript-tester.html) I normally use on my PC for testing JavaScript. After the page loaded, I entered this simple program: ``` alert("Hello!") ``` I then proceeded to press the Execute button, and was surprised when it told me that the code I had entered was invalid. I took a second look at the textbox and saw this: ``` alllelelerlerlertlert("Heeelelellellelloello!") ``` Wha??? That's not what I entered! So what happened here? To figure it out, I entered two simple lines: ``` abcdefg 0123456 ``` This turned out as: ``` abbbcbcbcdbcdbcdebcdebcdefbcdefbcdefgbcdefg 0112123123412345123456 ``` By now, I still had no clue about what happened to letters, but the numbers seemed simpler, so I took a closer look. As it turned out, the webpage was simply entering the first character, then repeating all the rest in the string every time a new one was pressed: ``` 0112123123412345123456 0 1 12 123 1234 12345 123456 ``` But what about the sections of letters? After pondering for a minute, I realized that it's just the same, but instead of repeating each subsection once, it repeats it *twice*: ``` abbbcbcbcdbcdbcdebcdebcdefbcdefbcdefgbcdefg a bb bcbc bcdbcd bcdebcde bcdefbcdef bcdefgbcdefg ``` A combination of the two works with a combination of these techniques: ``` abc123z abbbcbcbc1bc12bc123bc123zbc123z a bb bcbc bc1 bc12 bc123 bc123zbc123z ``` Whatever glitch causes this seems to reset at punctuation and spaces, so `abc def` becomes `abbbcbc deeefef`. By this point, I was so absorbed in figuring it out and turning it into an interesting challenge that I forgot why I had been on there in the first place. (I did figure out how to type normally, however: pressing space-backspace after every character. Pretty tedious, but you gotta do what you gotta do.) # Challenge The goal of the challenge is to write a program or function that takes in the text to be processed, makes the changes listed above, and outputs/returns the result. ## Details * The input will only contain printable ASCII, and no tabs or newlines. # Test-cases **Inputs:** (one per line) ``` Mess up text This is some longer text. CAPS LOCK && "Punc-tua"+'tion' under_score_style CaPs wItHIn loWERs 1337 numb3r5 abcdefghij 0123456789 Code-golf is the best! ``` **Outputs:** ``` Meeesesessess upp teeexexextext Thhhihihishis iss sooomomomeome looononongongongeongeongeronger teeexexextext. CAAAPAPAPSAPS LOOOCOCOCKOCK && "Puuunununcunc-tuuuaua"+'tiiioioionion' unnndndndendendernder_scccococorcorcorecore_stttytytyltyltyletyle CaaaPaPaPsaPs wIIItItItHItHItHIItHIItHInItHIn loooWoWoWEoWEoWERoWERoWERsoWERs 1333337 nuuumumumbumbumb3umb3rumb3rumb3r5 abbbcbcbcdbcdbcdebcdebcdefbcdefbcdefgbcdefgbcdefghbcdefghbcdefghibcdefghibcdefghijbcdefghij 0112123123412345123456123456712345678123456789 Cooodododeode-gooolololfolf iss thhhehe beeesesestest! ``` # Scoring This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest valid code in bytes wins. Tiebreaker goes to submission that reached its final byte count first. ~~The winner will be chosen next Monday, Nov 2. Good luck!~~ **Edit:** And the winner is... **@MartinBüttner** using **Retina** for an incredible **43-byte** solution! 1 Yes, this story is completely true, and if you need any more clarification, see footnote 1. [Answer] # [Retina](https://github.com/mbuettner/retina), 43 bytes ``` .(?<=[^_\W]([^_\W]+))(?<=(\1)(?<=\D))? $1$2 ``` Run the code from a single file with the `-s` flag. Since this is just a single regex substitution, [you can test it here](http://regexstorm.net/tester?p=.(%3f%3c%3d%5b%5e_%5cW%5d(%5b%5e_%5cW%5d%2b))(%3f%3c%3d(%5c1)(%3f%3c%3d%5cD))%3f&i=Mess+up+text%0d%0aThis+is+some+longer+text.%0d%0aCAPS+LOCK+%26%26+%22Punc-tua%22%2b%27tion%27%0d%0aCaPs+wItHIn+loWERs%0d%0a1337+numb3r5%0d%0aabcdefghij+0123456789%0d%0aCode-golf+is+the+best!&r=%241%242) (click the Context tab to see the results). ## Explanation This matches any digit and letter which is not the first in a run. While `.` can match any non-linefeed character, the lookbehinds ensure the other conditions: ``` (?<=[^_\W]([^_\W]+)) ``` This matches *backwards* from the position after the `.`. First it matches one or more alphanumeric characters and captures them into group `1` with `([^_\W]+)`. This immediately ensures that the `.` corresponds to an alphanumeric character itself. Then the additional `[^_\W]` makes sure that there is one more alphanumeric character in the current run, which we *don't* include the match. Now group `1` is what we want to replace the match with if it is a digit - if it is a letter we want to replace it with twice this string. That's where the second lookbehind comes into play: ``` (?<=(\1)(?<=\D))? ``` This one is optional, so if it fails it won't affect the match at all. It first ensures that the `.` was *not* a digit via `(?<=\D)` - so this lookbehind is only relevant when we're matching letters. In that case, we match group `\1` once more (this always matches, because we've captured the group from the same position), but capture it into group `2`. Hence, we simply replace the regex with the contents of both groups (`$1$2`). If the match was a digit, `$2` will still be empty and we write back the prefix only once. If it was a letter, `$2` is the same as `$1` and we write it back twice. [Answer] # JavaScript(ES6) 82 Using the regexp optimization suggested by Mwr247 ``` s=>s.replace(/([\W_])|./g,(x,y)=>y?(f=0,x):f?(p+=x,p+(-x-1?z:p)):(p=z,f=x),f=z='') ``` Test running the snippet below in any recent browser ``` F=s=>s.replace(/([\W_])|./g,(x,y)=>y?(f=0,x):f?(p+=x,p+(-x-1?z:p)):(p=z,f=x),f=z='') // document.write(F(prompt('Insert string'))) // TEST console.log=x=>O.innerHTML+=x+'\n' function test() { O.innerHTML=F(I.value) } ;[ ['Mess up text','Meeesesessess upp teeexexextext'] ,['This is some longer text.', 'Thhhihihishis iss sooomomomeome looononongongongeongeongeronger teeexexextext.'] ,['CAPS LOCK && "Punc-tua"+\'tion\'', 'CAAAPAPAPSAPS LOOOCOCOCKOCK && "Puuunununcunc-tuuuaua"+\'tiiioioionion\''] ,['CaPs wItHIn loWERs' ,'CaaaPaPaPsaPs wIIItItItHItHItHIItHIItHInItHIn loooWoWoWEoWEoWERoWERoWERsoWERs'] ,['1337 numb3r5','1333337 nuuumumumbumbumb3umb3rumb3rumb3r5'] ,['abcdefghij 0123456789' ,'abbbcbcbcdbcdbcdebcdebcdefbcdefbcdefgbcdefgbcdefghbcdefghbcdefghibcdefghibcdefghijbcdefghij 0112123123412345123456123456712345678123456789'] ,['Code-golf is the best!' ,'Cooodododeode-gooolololfolf iss thhhehe beeesesestest!'] ].forEach(t => ( i=t[0],x=t[1],r=F(i), console.log('Test ' + (r==x?'OK':'Fail')+'\nInput: '+i+'\nResult: '+r+'\nCheck: '+x+'\n') )) ``` ``` #I { width: 50% } ``` ``` Your test<input id=I><button onclick="test()">-></button> <pre id=O></pre> ``` [Answer] # JavaScript (ES6), ~~92~~ ~~88~~ 87 ``` f=>f.replace(/[^_\W]+/g,m=>m[0]+[...m].slice(1).reduce((a,e)=>a+=(y+=e,++e?y:y+y),y='')) ``` I have no idea how to golf this down... *Thanks Mwir247 for the golfed down regex and ETHproductions for one byte golf in reduce function*. [Answer] # Gema, 57 characters ``` \X?=?@set{s;} <D1>=@append{s;$0}$s <L1>=@append{s;$0}$s$s ``` Sample run: ``` bash-4.3$ gema '\X?=?@set{s;};<D1>=@append{s;$0}$s;<L1>=@append{s;$0}$s$s' <<< '1337 numb3r5' 1333337 nuuumumumbumbumb3umb3rumb3rumb3r5 ``` [Answer] # Haskell, ~~215~~ 200 bytes ``` import Data.List import Data.Char c=concatMap p c=[isDigit c,isAlpha c] r(Just n)=c id.replicate(n+1) r _=id f(h:t)=h:(c(\s->r(findIndex id.p$last s)s).tail.inits)t m=c f.groupBy(\a b->or$p a==or$p b) ``` It's a mess. Have fun reading all the weird quirks, I never thought I would use `id` this much. Too bad the stuff that already does half the work here needs to be imported (`isDigit`,`isAlpha`,`inits`). [Answer] # Haskell, ~~183~~ 181 bytes ``` import Data.Char b(x:y)|h x=x:c[]y|2>1=x:b y b[]=[] h y=isDigit y||isAlpha y c x l@(y:z)|h y=c(y:x)z|2>1=c x[]++b l c x[]=reverse$g$x g[]=[] g a@(x:y)|isDigit x=a++g y|2>1=a++a++g y ``` Usage: ``` b"Hello, world!" >"Heeelelellellelloello, wooorororlorlorldorld!" ``` Don't know if it is essentially different with Leif Willerts' answer. But here's the algorithm. 1. Search for valid letter(Letter or Num) 2. If it letter, begin collecting letter. However, it is stored reversely, make the string reversed. And first item is omitted. 3. As it hit invalid letter, do the question's transform with reversed input. The question's transform is reverse.g.reverse, but since it is already reversed, then we just do reverse.g I somehow keep redudant brackets. [Answer] **T-SQL, 357 bytes** ``` create proc x(@s varchar(99),@z int=0,@i int=0,@y varchar(99)='',@x varchar(99)='',@w varchar(99)='') as while LEN(@s)>0 begin select @z=patindex('%[^0-z]%',@s+' '),@i=1,@w+=LEFT(@s,1) while @i<@z-1 begin select @y=SUBSTRING(@s,2,@i) ,@x+=@y ,@i+=1 if @y like'%[a-z]'set @x+=@y end select @w+=@x+SUBSTRING(@s,@z,1) ,@x='' ,@s=REPLACE(@s,left(@s,@z),'') end select @w ``` ex: `exec x(@s='1337 numb3r5')` returns `1333337 nuuumumumbumbumb3umb3rumb3rumb3r5` [Answer] # Python 2, 131 Bytes ``` i=raw_input();s=r='';g=1 for c in i: s+=c if g:r+=c;g=0;s='' elif c.isalpha():r+=s*2 elif '/'<c<':':r+=s else:g=1;r+=c print r ``` Loops through characters, and saves/repeats if required. [Answer] # Pip, 41 bytes ``` aR`[^_\W]+`{[[email protected]](/cdn-cgi/l/email-protection)@{1,++y}X2-(_Q+_)MJa} ``` Takes the text as a command-line argument. We use a regex replacement to replace all alphanumeric runs (`[^_\W]+`) with a callback function. This function maps another function to each character of the word, generating progressively larger runs of characters (with the global variable `y` keeping track of the index) and repeating them X2 if the character is not a number. (The logic for which uses `+` to convert to a number and then `Q` to check whether this is string-equal to the original character.) This process leaves out the first character, though, so we have to add it on afterward (`a@0.`). [Answer] # [Python 3](https://docs.python.org/3/), 86 bytes ``` f=0 m='' for i in input():g=i.isalnum();m=m*g*f+i*f;print(end=m*-~i.isalpha()or i);f=g ``` [Try it online!](https://tio.run/##K6gsycjPM/7/P83WgCvXVl2dKy2/SCFTITMPiApKSzQ0rdJtM/UyixNz8kpzNTStc21ztdK10rQztdKsC4oy80o0UvNSgGK6dRBVBRmJGpogIzSt02zT//83NDY2VwBqTTIuMgUA "Python 3 – Try It Online") ]
[Question] [ # McCarthy's 1959 LISP In early 1959, John McCarthy wrote a groundbreaking paper defining just nine primitive functions that when put together still form the basis for all LISP-like languages today. The paper is available digitized here: **<http://www-formal.stanford.edu/jmc/recursive.pdf>** Your job is to fully implement a parser and interpreter for McCarthy's LISP exactly as described in the 1960 paper: That is, the functions `QUOTE`, `ATOM`, `EQ`, `CAR`, `CDR`, `CONS`, `COND`, `LAMBDA`, and `LABEL` should all be functional. The paper will take precedence over this challenge text when considering the correctness of answers, but I've tried to summarize the nine functions below. Note that the language will be in ALL CAPS and no error checking is necessary, all input should be presumed to be valid. **Types** * There are only two types in McCarthy's LISP: An atom, and a linked list, which is recursively defined as a head, which may be a list or an atom, and a list that the head is attached to (tail). `NIL` has the special property of being both an atom and a list. * As per the paper, atom names will only consist of capital letters, numbers, and the space character, though strings of consecutive spaces should be considered as just one space and all leading and trailing space characters should be removed. Example equivalent atom names (replace underscore with space character): `___ATOM__1__ = ATOM_1`. Example not equivalent atom names: `A_TOM_1 != ATOM_1` * Lists are denoted by parentheses, and an implied `NIL` is at the end of every list. Elements in a list are separated by commas and *not* whitespace like in most modern Lisps. So the list `(ATOM 1, (ATOM 2))` would be `{[ATOM 1] -> {[ATOM 2] -> NIL} -> NIL}`. **`QUOTE`:** * Takes one argument which may be either an atom (single element) or a linked list. Returns the argument exactly. * **Test cases:** * `(QUOTE, ATOM 1) -> ATOM 1` * `(QUOTE, (ATOM 1, ATOM 2)) -> (ATOM 1, ATOM 2)` **`ATOM`:** * Takes one argument which may be either an atom (single element) or a linked list. Returns `T` (true) if the argument is an atom, or `NIL` (false) if the argument is not an atom. * **Test cases:** * `(ATOM, (QUOTE, ATOM 1)) -> T` * `(ATOM, (QUOTE, (ATOM 1, ATOM 2))) -> NIL` **`EQ`:** * Takes two arguments which must be atoms (behavior is undefined if either of the arguments are not atoms). Returns `T` (true) if the two atoms are equivalent, or `NIL` (false) if they are not. * **Test cases:** * `(EQ, (QUOTE, ATOM 1), (QUOTE, ATOM 1)) -> T` * `(EQ, (QUOTE, ATOM 1), (QUOTE, ATOM 2)) -> NIL` **`CAR`:** * Takes one argument which must be a list (behavior is undefined if it is not a list). Returns the first atom (head) of that list. * **Test cases:** * `(CAR, (QUOTE, (ATOM 1, ATOM 2))) -> ATOM 1` **`CDR`:** * Takes one argument which must be a list (behavior is undefined if it is not a list). Returns every atom but the first atom of the list, i.e. the tail. Note that every list ends in an implied `NIL`, so running `CDR` on a list that appears to just have one element will return `NIL`. * **Test cases:** * `(CDR, (QUOTE, (ATOM 1, ATOM 2))) -> (ATOM 2)` * `(CDR, (QUOTE, (ATOM 1))) -> NIL` **`CONS`:** * Takes two arguments. The first may be an atom or a list but the second must be a list or `NIL`. Prepends the first argument to the second argument and returns the newly-created list. * **Test cases:** * `(CONS, (QUOTE, ATOM 1), (QUOTE, NIL)) -> (ATOM 1)` * `(CONS, (QUOTE, ATOM 1), (CONS, (QUOTE, ATOM 2), (QUOTE, NIL))) -> (ATOM 1, ATOM 2)` **`COND`:** * This is LISP's "if-else" statement of sorts. Takes a variable-length amount of arguments, each of which must be a list of length exactly 2. For each argument list in order, evaluate the first term and if it is true (T), return the associated second term and exit the function. If the first term is not true, move on to the next argument and test its condition, and so on until the first true condition is reached. At least one of the argument conditions can be assumed to be true -- if they are all false, this is undefined behavior. See page 4 for a good example of the behavior of this function. * **Test cases:** * `(COND, ((ATOM, (QUOTE, ATOM 1)), (QUOTE, 1)), ((ATOM, (QUOTE, (ATOM 1, ATOM 2))), (QUOTE, 2))) -> 1` * `(COND, ((ATOM, (QUOTE, (ATOM 1, ATOM 2))), (QUOTE, 2)), ((ATOM, (QUOTE, ATOM 1)), (QUOTE, 1))) -> 1` **`LAMBDA`:** * Defines an anonymous function. Takes two arguments, the first being a list of atoms which represent the arguments to the function and the second being any S-expression (the function body), which would typically use the arguments. * **Test cases:** * Defining and using an anonymous "isNull" function: * `((LAMBDA, (ATOM 1), (EQ, ATOM 1, (QUOTE, NIL))), (QUOTE, NIL)) -> T` * `((LAMBDA, (ATOM 1), (EQ, ATOM 1, (QUOTE, NIL))), (QUOTE, ATOM 1)) -> NIL` **`LABEL`:** * Gives a name to an anonymous `LAMBDA` function, which also allows that function to be called recursively in the body of the `LAMBDA`. Takes two arguments, the first being a label and the second being the `LAMBDA` function to which the label should be bound. Returns the name supplied. The scope of all `LABEL` names is global, and redefining a `LABEL` is undefined behavior. * Fun fact, `LABEL` is not actually necessary to create recursive functions as we now know `LAMBDA` can be used with a ['Y-Combinator'](https://en.wikipedia.org/wiki/Fixed-point_combinator#Fixed_point_combinators_in_lambda_calculus) to accomplish this task, but McCarthy wasn't aware of this method when writing the original paper. It makes programs much easier to write anyways. * **Test cases:** * `(LABEL, SUBST, (LAMBDA, (X, Y, Z), (COND, ((ATOM, Z), (COND, ((EQ, Y, Z), X), ((QUOTE, T), Z))), ((QUOTE, T), (CONS, (SUBST, X, Y, (CAR, Z)), (SUBST, X, Y, (CDR, Z))))))) -> SUBST` * *(after running the above)* `(SUBST, (QUOTE, A), (QUOTE, B), (QUOTE, (A, B, C))) -> (A, A, C)` To help visualize the `SUBST` function above, it could be represented as this Python-like pseudocode: ``` def substitute(x, y, z): # substitute all instances of y (an atom) with x (any sexp) in z if isAtom(z): if y == z: return x elif True: return z elif True: return substitute(x,y,z[0]) + substitute(x,y,z[1:]) ``` **FINAL TEST CASE:** If I have transcribed it correctly, your interpreter should be able to interpret `EVAL` with this code: ``` (LABEL, CAAR, (LAMBDA, (X), (CAR, (CAR, X)))) (LABEL, CDDR, (LAMBDA, (X), (CDR, (CDR, X)))) (LABEL, CADR, (LAMBDA, (X), (CAR, (CDR, X)))) (LABEL, CDAR, (LAMBDA, (X), (CDR, (CAR, X)))) (LABEL, CADAR, (LAMBDA, (X), (CAR, (CDR, (CAR, X))))) (LABEL, CADDR, (LAMBDA, (X), (CAR, (CDR, (CDR, X))))) (LABEL, CADDAR, (LAMBDA, (X), (CAR, (CDR, (CDR, (CAR, X)))))) (LABEL, ASSOC, (LAMBDA, (X, Y), (COND, ((EQ, (CAAR, Y), X), (CADAR, Y)), ((QUOTE, T), (ASSOC, X, (CDR, Y)))))) (LABEL, AND, (LAMBDA, (X, Y), (COND, (X, (COND, (Y, (QUOTE, T)), ((QUOTE, T), (QUOTE, NIL)))), ((QUOTE, T), (QUOTE, NIL))))) (LABEL, NOT, (LAMBDA, (X), (COND, (X, (QUOTE, NIL)), ((QUOTE, T), (QUOTE, T))))) (LABEL, NULL, (LAMBDA, (X), (AND, (ATOM, X), (EQ, X, (QUOTE, NIL))))) (LABEL, APPEND, (LAMBDA, (X, Y), (COND, ((NULL, X), Y), ((QUOTE, T), (CONS, (CAR, X), (APPEND, (CDR, X), Y)))))) (LABEL, LIST, (LAMBDA, (X, Y), (CONS, X, (CONS, Y, (QUOTE, NIL))))) (LABEL, PAIR, (LAMBDA, (X, Y), (COND, ((AND, (NULL, X), (NULL, Y)), (QUOTE, NIL)), ((AND, (NOT, (ATOM, X)), (NOT, (ATOM, Y))), (CONS, (LIST, (CAR, X), (CAR, Y)), (PAIR, (CDR, X), (CDR, Y))))))) (LABEL, EVAL, (LAMBDA, (E, A), (COND, ((ATOM, E), (ASSOC, E, A)), ((ATOM, (CAR, E)), (COND, ((EQ, (CAR, E), (QUOTE, QUOTE)), (CADR, E)), ((EQ, (CAR, E), (QUOTE, ATOM)), (ATOM, (EVAL, ((CADR, E), A)))), ((EQ, (CAR, E), (QUOTE, EQ)), (EQ, (EVAL, (CADR, E, A)), (EVAL, (CADDR, E, A)))), ((EQ, (CAR, E), (QUOTE, COND)), (EVCON, (CDR, E), A)), ((EQ, (CAR, E), (QUOTE, CAR)), (CAR, (EVAL, (CADR, E), A))), ((EQ, (CAR, E), (QUOTE, CDR)), (CDR, (EVAL, (CADR, E), A))), ((EQ, (CAR, E), (QUOTE, CONS)), (CONS, (EVAL, (CADR, E), A), (EVAL, (CADDR, E), A))), ((QUOTE, T), (EVAL, (CONS, (ASSOC, (CAR, E), A), (EVLIS, (CDR, E), A)), A)))), ((EQ, (CAAR, E), (QUOTE, LABEL)), (EVAL, (CONS, (CADDAR, E), (CDR, E)), (CONS, (CONS, (CADAR, E), (CONS, (CAR, E), (CONS, A, (QUOTE, NIL))))))), ((EQ, (CAAR, E), (QUOTE, LAMBDA)), (EVAL, (CADDAR, E), (APPEND, (PAIR, (CADAR, E), (EVLIS, (CDR, E), A)), A)))))) (LABEL, EVCON, (LAMBDA, (C, A), (COND, ((EVAL, (CAAR, C), A), (EVAL, (CADAR, C), A)), ((QUOTE, T), (EVCON, (CDR, C), A))))) (LABEL, EVLIS, (LAMBDA, (M, A), (COND, ((NULL, M), (QUOTE, NIL)), ((QUOTE, T), (CONS, (EVAL, (CAR, M), A), (EVLIS, (CDR, M), A)))))) ``` After running that behemoth, this line should return `(A, B, C)`: ``` (EVAL, (QUOTE, (CONS, X, (QUOTE, (B, C)))), (QUOTE, ((X, A), (Y, B)))) ``` However, to quote John McCarthy himself on page 16, it seems like he was running out of characters on his computer: > > If more characters were available on the computer, it could be improved considerably ... > > > Therefore, this challenge is tagged [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") and the shortest answer in characters will be the winner. Standard loopholes apply. Good luck! **Note on String Evals**: I understand that some think it may be possible to win this challenge by using a Lisp and modifying the syntax to fit the host language and then using a string `(eval)`. I'm not particularly convinced that this approach will necessarily win especially with the identifier naming rules, and even if it did I think banning string `eval`s in all languages would be a subjective and slippery slope. But I don't want to punish people for doing this challenge the 'right' way, so I may allow two winners for this challenge, one in a Lisp-like language and one in a non-Lispy language, if this becomes a problem. [Answer] # Python 3, 770 bytes This is a REPL on stdin/stdout. Expects every line to be a full statement or empty. `eval` is used to shorten the implementation, but is otherwise not necessary for logic. ``` import re,sys;S=re.sub P=lambda l:eval(S("([A-Z0-9][A-Z0-9 ]*)",r"' '.join('\1'.strip().split())",S("NIL","()",S("\)",",)",l)))) d={"QUOTE":'(v,L[1])[1]',"EQ":'[(),"T"][E(L[1],v)==E(L[2],v)]', "CDR":'E(L[1],v)[1:]',"CONS":'(E(L[1],v),)+E(L[2],v)',"CAR":'E(L[1],v)[0]', "LAMBDA":'("#",)+L[1:]',"LABEL":'[v.update({L[1]:E(L[2],v)}),L[1]][1]'} def E(L,v): if L*0=="":return v[L] elif L[0]in d:return eval(d[L[0]]) elif L[0]=="COND":return next(E(l[1],v)for l in L[1:]if E(l[0],v)=="T") elif L[0]=="ATOM":o=E(L[1],v);return[(),"T"][o*0in["",o]] else:l=E(L[0],v);n=v.copy();n.update({a:E(p,v)for a,p in zip(l[1],L[1:])});return E(l[2],n) R=lambda o:o==()and"NIL"or 0*o==()and"(%s)"%", ".join(R(e)for e in o)or o g={} for l in sys.stdin: if l.strip():print(R(E(P(l),g))) ``` [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~523...451~~ 447 bytes Saved 12 bytes thanks to [@Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler)! Saved 1 byte thanks to [@Adám](https://chat.stackexchange.com/users/130368/adam) (and 7 more thanks to [this comment](https://codegolf.stackexchange.com/questions/68637/implement-multiplicative-fuzzy-logic#comment505414_216446) on another answer) ``` s←⎕SE.Dyalog.Utils.repObj z←'NIL' p←{')'=⊃⍵:(⊂z)(1↓⍵)⋄v r←{'('=⊃⍵:p⍵⋄⍵(↑,Ö⊂↓)⍨⊃⍸⍵∊',)'}1↓⍵⋄n r←∇r⋄(n,⍨⊂v)r} e←{1=≡⍵:((⊃⍺)⍳⊂⍵)⊃(1⊃⍺),⊂⍵⋄⍺(⍎⍺e⊃⍵)1↓⍵} b←⊃∘z'T' CAR←⊃x←e∘⊃ CDR←1↓x QUOTE←⊃⊢ CONS←{(⊂⍺x⍵),⊆⍺e 1⊃⍵} EQ←{b≡/⍺∘e¨¯1↓⍵} ATOM←b 1=∘≡x COND←{z≢⍺x⊃⍵:⍺e 1⊃⊃⍵⋄⍺∇1↓⍵} LAMBDA←{⍕'{((('(s⊃⍵)'),⊃⍺)((⍺∘e¨⍵),1⊃⍺))e'(s 1⊃⍵)'}'} LABEL←{u←⍎⍕'#.'(⊃⍵)'←',⍺e 1⊃⍵⋄⊃⍵} ``` To execute a line of LISP: ``` {{1=≢⍵:⍵⋄1=≡⍵:'_'⎕R' '⊢⍵⋄⍕1⌽')(',∇¨¯1↓⍵}⍬⍬e⊃p'(?<=\(|,) *(?=\d)| +' ' *([(),]) *'⎕R'_' '\1'⊢⍵} ``` [Try it online!](https://tio.run/##nVVPaxNBFL/vp1jwMDO6VnsVi0x391BImjZJJcGKNLqVSmhDWiWtzaUtNY1WFKl48WBB8CB4kIIUvNRvsl@kvvdmZnez/yqWdLP79v3@vDdvJiu97s0n2yvdjaeX4duTx9tsc6W7xezw9YEdrK90ukFDVprWn4/h4buXPDw@g48dHp8L@IdPHDkTQ7h@thc2utura92uvbrRh8BXC1jnaoC@fbkJV3hq@FMeCU4tba11N6f6Qa/WeWbtwFs2P1dhVg@1mGAz4XgfiO/wcLy3I/h0ePgBdcDaC7tPOTzK6aGR1wdw5eHhewf8jvcgH2x@o4xf@H40Zo5gQ00E6evEE45e9eGBrzuUvfdC9IdWgALTM@HRF7LAiQXL/onMaGO8D5ZU1FExMoA9eQtfgXImtNrQ6qAUxEafdliTWa6sq8AAvgKIwq3lehhEyMBaXKo1fY0Zn1pubb6hFgG1zgfIDbqHKGUrIyDiL2JOB2zfwhUafQouvl38iDzIZq0KCR0bKgPFoy8D5PUQsxMenRKvamhMS8@qNOhURFWR1VlPIjI8PmEvOeeMb@qaGTqjzkDjjA0ybDomAsg2tmFNGBLO@hXke45FYw9P2LUpxk0OzoeTrBY96bKtYBA8Riwt2akqABOiFWSPGMxendkMmmkKOpkO3/xmggPv6FWyUeHxd/jgEvYYv3d3ZpnvOsK@zu/NLD8Ru/YNoIGnB1w4DyGsmB9BcHla0w8vL8mTzTjV5diulHXH5qptcNMScHEpRteWgD@WBnleDohidM0HSa9QqRjkyUIlWaIkS6US2DywdwXYKwXLf0AnDQBJikU2GjV3gsSx28QDmwK@uL9IFMiBca3hqWd84LRLHbuJD5quZcTbRbJEXiTaim/b8B8JZOT0PZyZqFL@NtPA@Voz273YQBJdwNzML25@qVLJMKuK8fTRTcTGtvJcplu1sOCXdosrPSRtZ5zimRnPADowdHq0iteoMtdoFsg29BLTXfsfiliQc/WyElR34kL0rZqw9EroZFo@01CRirTVPOjydSlxF9x4frW1qB0Tg5utxL8vJxYXjMmJSkjeT2wGyhDxOyXui5xdVtdIXTF9Cb3jIkxBMpLTe62ijUZQclFG4C8KM5cGrLGmgDgah8sYsToNhFvTWm2lBCbrIj7KJq3oMkrAngZ7/wOGcUnOTQ4824YEa3LnmSzFZM7ZSFIzwWRm@pLuatolTaLIaphfBF/ElMkzIMqKkxKnQyIgszv6CkO4GdIjEmVFR47ZagkHJR3I3XxqjqLd56Z2XySPAm52weJwznolZtSNTOR4UI4jD9WUB3V0VcUVvyHpEasrTHYuqnkN0TBNmDiTTWQWixDJ85PjqUv0cGLPEt1f "APL (Dyalog Unicode) – Try It Online") ~~Unfortunately, this doesn't work in TIO~~ dzaima (and Adám) got `⎕SE.Dyalog.Utils.repObj` working! Requires `⎕IO←0` now. ## Formatting the input First `⎕R` is used to format the input. It accepts a bunch of regex on the left and the strings to replace them with on the right. In this case, we're replacing areas before atom names starting with digits (`(?<=\(|,) *(?=\d)`) or multiple spaces ( `+`) with a single underscore because in APL, identifiers cannot contain spaces or start with digits. At the same time, `*([(),]) *` captures parentheses or commas along with spaces around them, but only keeps the parentheses and commas, dropping leading or trailing spaces by doing so. Thus, `( QUOTE, (1, ATOM 2))` would become `(QUOTE,(_1,ATOM_2))`. ## Creating an AST `p` creates an AST from this formatted string. Every atom is represented by a string, and every s-expression is simply an array of atoms or other s-expressions, with the string `NIL` at the end. Thus, `(QUOTE,(ATOM_1,ATOM_2))` would become `('QUOTE' ('ATOM_1' 'ATOM_2' 'NIL') 'NIL')`. ## Executing the AST `e` takes such an AST as its right argument and evaluates it. The left argument is a context that gives the variables in scope. It's an array whose first elements is a list of strings denoting the names of atoms, while the second element is a list of the same length with those variables' values. For example, given a lisp expression `((LAMBDA, (X, Y), (CONS, Y, X)), (QUOTE, (ATOM 1)), (QUOTE, ATOM 2))`, the context would look like this (the `NIL`s are an unfortunate side effect of how the ASTs are structured, but they're harmless): ``` 'X' | 'Y' | 'NIL' 'ATOM_1' 'NIL' | 'ATOM_2' | 'NIL' ``` If the right argument to `e` is a single string (an atom), it looks up the atom in the context and gets back the corresponding value. If the atom is not found in the context, it just gives back the same string. So in the example above, if `⍵` (the right argument) were `X`, we would get back `ATOM_1`, but if it were `CAR`, we would get back `CAR` again. Otherwise, it's a function call, so it calls `e` on the first element of that tree with the same context on the left. The first element of the AST is either a label name or one of the nine "builtin" functions, or a lambda expression. If it's the former, we'll just get back the name of the function again. In that case, we can execute the string with `⍎` (APL's equivalent of `eval`) to get another dyadic function. We give it the same context on the left and apply it to the rest of `⍵`, the right argument. Otherwise, if it's a lambda expression, applying the function `LAMBDA` (the one I've defined) returns a string containing a function, so again, we can execute it and apply it to the rest of `⍵`. The initial left argument is `⍬⍬` (`⍬` is an empty array), because we don't have any variables defined yet. ## Printing the result `{1=≢⍵:⍵⋄1=≡⍵:'_'⎕R' '⊢⍵⋄⍕'('(∇¨¯1↓⍵)')'}` is a recursive function that turns arrays into strings. `1=≢⍵` checks if the argument is a string (with depth 1). If so, it turns underscores back into spaces with `'_'⎕R' '`. Otherwise, it drops the last element (always `NIL`) using `¯1↓⍵`, then calls itself on each element using `∇¨`. That is put into an array with parentheses, and `⍕` is used to turn that array into a string (with extra spaces). ### `LAMBDA` This function returns a string representing another function. For example, `(LAMBDA, (X, Y), (CONS, X, Y))` becomes ``` {((('X' 'Y' 'NIL'),⊃⍺)((⍺∘e¨⍵),1⊃⍺))e'CONS' 'X' 'Y' 'NIL'} ``` While the definition of `LAMBDA` itself may look messy, there is nothing complicated about it. On the right is simply the body given to the lambda; only the context has changed. Like the Python answer, I used dynamic scoping, so the new context adds to the context given at the call site, not where the lambda is defined. The first element is just the names lambda's parameters prepended to the the old context's names. The second is the result of evaluating all the arguments (with the same context), prepended to the old context's values. `repObj` (assigned to `s` because it is used multiple times) finds the string representation of the parameters and lambda body. ### `LABEL` This is why we had to add underscores before. `LABEL` constructs a string that looks like `#.name ← lambda`, given the arguments `name lambda 'NIL'`, executes it, adding a function called `name` to the root namespace `#`, so it is global. Like `LAMBDA`, it ignores the context given to it, because of dynamic scoping. ]
[Question] [ In his xkcd [about the ISO 8601 standard date format](https://xkcd.com/1179/) Randall snuck in a rather curious alternative notation: [![enter image description here](https://i.stack.imgur.com/b1ZUO.png)](https://i.stack.imgur.com/b1ZUO.png) The large numbers are all the digits that appear in the current date in their usual order, and the small numbers are 1-based indices of the occurrences of that digit. So the above example represents `2013-02-27`. Let's define an ASCII representation for such a date. The first line contains the indices 1 to 4. The second line contains the "large" digits. The third line contains the indices 5 to 8. If there are multiple indices in a single slot, they are listed next to each other from smallest to largest. If there are at most `m` indices in a single slot (i.e. on the same digit, and in the same row), then each column should have be `m+1` characters wide and left-aligned: ``` 2 3 1 4 0 1 2 3 7 5 67 8 ``` *See also [the companion challenge](https://codegolf.stackexchange.com/q/67127/8478) for the opposite conversion.* ## The Challenge Given a date in xkcd-notation, output the corresponding ISO 8601 date (`YYYY-MM-DD`). You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter. You may assume that the input is any valid date between years `0000` and `9999`, inclusive. There won't be any leading spaces in the input, but you may assume that the lines are padded with spaces to a rectangle, which contains at most one trailing column of spaces. Standard [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") rules apply. ## Test Cases ``` 2 3 1 4 0 1 2 3 7 5 67 8 2013-02-27 2 3 1 4 0 1 2 4 5 5 67 8 2015-12-24 1234 1 2 5678 2222-11-11 1 3 24 0 1 2 7 8 57 6 8 1878-02-08 2 4 1 3 0 1 2 6 5 678 2061-02-22 1 4 2 3 0 1 2 3 4 5 6 8 6 5 7 8 3564-10-28 1234 1 5678 1111-11-11 1 2 3 4 0 1 2 3 8 5 6 7 0123-12-30 ``` [Answer] # CJam, 35 bytes ``` ll{1$e>}*](l+eeWf%$-8>Wf=\f=2/(o'-* ``` [Try it here](http://cjam.aditsu.net/#code=ll%7B1%24e%3E%7D*%5D(l%2BeeWf%25%24-8%3EWf%3D%5Cf%3D2%2F(o'-*&input=2%20%20%204%20%20%201%20%20%203%0A0%20%20%201%20%20%202%20%20%206%0A5%20%20%20%20%20%20%20678%20%20). It expects the input lines to be padded with spaces. ## Explanation `ll` reads two lines of input, and `{1$e>}*` performs a "scan" on the second one: it it takes all prefixes of its input and computes the maximum of each prefix. For the input line `"0 1 2 7 8"`, this pushes `"0001112227778"`. Our stack now looks like this: ``` "first line" '0 '0 '0 '1 '1 '1 ... ``` We need to re-capture the values into a list ourselves using `]`; this captures our first line as well, so we pop it back out using `(`, to get ``` "0001112227778" "first line" ``` as expected. `eelee+` enumerates this line, then does the same for a third input line, and concatenates the results, leaving something like this on the top of the stack: ``` [[0 '5] [1 ' ] [2 ' ] [3 ' ] [4 ' ] [5 ' ] [6 ' ] [7 ' ] [8 '6] [9 '7] [10 '8] [11 ' ] [12 ' ] [0 '2] [1 ' ] [2 ' ] [3 ' ] [4 '4] [5 ' ] [6 ' ] [7 ' ] [8 '1] [9 ' ] [10 ' ] [11 ' ] [12 '3]] ``` Now our stack is `["0001112227778" X]` where `X` is the enumerated list above. We flip each pair in `X` (`Wf%`), sort the pairs lexicographically (`$`), and leave the last 8 pairs `-8>`. This gets us something like: ``` [['1 8] ['2 0] ['3 12] ['4 4] ['5 0] ['6 8] ['7 9] ['8 10]] ``` This works, because the sort places all the pairs with key `'` (space) before all the digits in ascending order. These are the "*x*-positions" of the characters `12345678` on the first and third lines: we only need to retrieve the characters from our (modified) second line that are vertically aligned with them. To do this, we take each position (`Wf=`), index into the string we made earlier (`\f=`). We have `"20610222"` on the stack now: to add the dashes, first we split into segments of length two (`2/`), print the first segment without a newline (`(o`) and join the remaining segments with dashes (`'-*`). **EDIT**: cool scan trick, Martin! Saved four bytes. **EDIT 2**: saved two more bytes by replacing `eelee+` with `l+ee`; this works, because the lines all have the same lengths, and list indexing in CJam is automatically modulo the list length, so the indices `n+0`, `n+1`, `n+2`... nicely map to `0`, `1`, `2`... **EDIT 3**: Martin saved another byte in the final step of the process. Nice! [Answer] # Pyth, ~~48~~ 43 ``` j\-cj\-ctuuXN.xsTZK?qJhtHdKJ+hHeHGC.z*9d4 7 ``` [Test Suite](https://pyth.herokuapp.com/?code=j%5C-cj%5C-ctuuXN.xsTZK%3FqJhtHdKJ%2BhHeHGC.z%2a9d4+7&input=2++3++1++4+++%0A0++1++2++3++7%0A5+++++67++++8&test_suite=1&test_suite_input=2++3++1++4+++%0A0++1++2++3++7%0A5+++++67++++8%0A2++3++1+++++4%0A0++1++2++4++5%0A+++5++67+8+++%0A+++++1234%0A1++++2+++%0A5678+++++%0A+++1+++++3++24%0A0++1++2++7++8+%0A57++++6+++++8+%0A2+++4+++1+++3%0A0+++1+++2+++6%0A5+++++++678++%0A++++++1+4+2+3++%0A0+1+2+3+4+5+6+8%0A6+5+7+++++++++8&debug=0&input_size=3) Requires padding with spaces into a rectangle. I don't think this is the best approach, but basically it writes the middle value to the index in a string pointed at by the top or bottom value. Well I guess I had enough time to golf most of the obvious stuff I saw. :P [Answer] # JavaScript (ES7), 115 Anonymous function. Using template strings, there is a newline that is signifiocant and included in byte count. Requirement: the middle input line cannot to be shorter than the first or the last. This requirement is satisfied when the input is padded with spaces to form a rectangle. ``` x=>([a,z,b]=o=x.split` `,d=i=0,[for(c of z)o[a[i]-1]=o[b[i++]-1]=d=+c||d],o.splice(4,2,'-',o[4],o[5],'-'),o.join``) ``` **ES6** version **117** using .map instead of array comprehension ``` x=>([a,z,b]=o=x.split` `,d=0,[...z].map((c,i)=>o[a[i]-1]=o[b[i]-1]=d=+c||d],o.splice(4,2,'-',o[4],o[5],'-'),o.join``) ``` **Less golfed** ``` x=>( o=[], [a,z,b] = x.split`\n`, d=i=0, [ for(c of z) ( d = +c||d, // each new digit found in z goes in d (but not the spaces and not the '0' (d starts at 0 anyway) o[a[i]-1] = o[b[i]-1] = d, // if the index char is space, that gives index -1 that is ignored when joining later ++i )], o.splice(4,2,'-',o[4],o[5],'-'), // add the dashes in the right places o.join`` ) ``` **Test snippet** ``` f=x=>( [a,z,b]=o=x.split`\n`, d=i=0,[for(c of z)o[a[i]-1]=o[b[i++]-1]=d=+c||d], o.splice(4,2,'-',o[4],o[5],'-'),o.join`` ) console.log=x=>O.textContent+=x+'\n'; [['2 3 1 4\n0 1 2 3 7\n5 67 8','2013-02-27'] ,['2 3 1 4\n0 1 2 4 5\n 5 67 8','2015-12-24'] ,[' 1234\n1 2 \n5678','2222-11-11'] ,[' 1 3 24\n0 1 2 7 8 \n57 6 8','1878-02-08'] ,['2 4 1 3\n0 1 2 6 \n5 678','2061-02-22'] ,[' 1 4 2 3\n0 1 2 3 4 5 6 8\n6 5 7 8','3564-10-28'] ,['1234\n1 \n5678','1111-11-11'] ,['1 2 3 4\n0 1 2 3\n8 5 6 7','0123-12-30']] .forEach(t=>(k=t[1],r=f(t[0]),console.log(t[0]+'\n'+r+'\n'+(r==k?'OK\n':'Fail\n')))) ``` ``` <pre id=O></pre> ``` [Answer] ## Haskell, ~~125~~ ~~106~~ 103 bytes ``` a#' '=a a#b=b f i|[a,b,c]<-('-':)<$>lines i=[o|m<-"1234-56-78",(n,o,p)<-zip3 a(scanl1(#)b)c,m==n||m==p] ``` Requires padding with spaces to a full rectangle. Usage example: `f " 1 3 24\n0 1 2 7 8 \n57 6 8 "` -> `"1878-02-08"`. How it works: ``` [a,b,c]<-('-':)<$>lines i -- split input into lines, prepend a '-' to -- each, call them a, b and c (scanl1(#)b) -- fill spaces of the middle line with the -- previous char, e.g. -- "-0 1 2 7 8 " -> "-00011122277788" zip3 a (scanl...) c -- combine the lines element wise into triples. -- This is our lookup table for "1234-56-78" o|m<-"1234...", (n,o,p)<-zip..., m==n||m==p -- whenever m equals n or p (i.e. was originally -- in the first or last line), take the -- corresponding char o (middle line) ``` [Answer] # JavaScript ES6, 231 ``` a=>{r=[];var b=[d,f,e]=a.split` `.map(n=>n.split``);Array(Math.max(...b.map(n=>n.length))).fill().map((m,i)=>{(m=f[i])&&m!=" "&&(c=m);[d,e].map(m=>(g=m[i])&&g!=" "&&(r[g-1]=c))}),r.splice(4,0,"-"),r.splice(7,0,"-");return r.join``} ``` [Test cases](https://jsbin.com/numayi/edit?js,console). [Answer] # Perl, 154 bytes ``` sub{$_=$_[1];@n=/\d/g;/ +/;map{map{$p[$i++].=$_}unpack"(a$+[0])*";$i=0}@_[0,2];map{map{$r[$_-1]=$n[$i]if/\d/}s plit$"='';$i++}@p;"@r"=~s/....\K(..)/-$1-/r} ``` ### Ungolfed & explained ``` sub{ $_=$_[1]; # $_[1] is 2nd argument (i.e., 2nd line) @n=/\d/g; # @n now contains all digits in 2nd line / +/; # $+[0] now the chunk length in 2nd line # Equivalent to /( +)/;$l = 1 + length $1; map{ # Perl golfer's for-loop map{ $p[$i++] .= $_ # @p contains positions of each digit } unpack "(a$+[0])*"; # Split line into same chunk width $i=0 # At end of loop so we don't need $i=0 before next one } @_[0,2];# Outer map works on 1st and 3rd lines map{ map{ # Shove $n[$i] into ($_-1)th slot in @r if $_ is a number $r[$_-1] = $n[$i] if /\d/ } split $"=''; # Equivalent to split '', but sets $"='' for free $i++ }@p; # Concatenate @r, convert 20130227 to 2013-02-27, and return "@r"=~s/....\K(..)/-$1-/r }; ``` [Answer] # JavaScript (ES6), 131 bytes ``` s=>[...(r=[,,,,"-",,,"-"],l=s.split` `)[1]].map((c,i)=>(c>"-"?n=c:0,y=+l[0][i],d=+l[2][i],y?r[y-1]=n:0,d?r[d+(d>6)]=n:0))&&r.join`` ``` ## Explanation Requires input to be padded with spaces to form a rectangle. ``` s=> [...( r=[,,,,"-",,,"-"], // r = array of result characters, prefill with "-" symbols l=s.split` ` // l = array of lines )[1]].map((c,i)=>( // for each character on the middle line c>"-"?n=c:0, // n = the most recent digit encountered y=+l[0][i], // y = index on the year line at the current position d=+l[2][i], // d = index on the date line at the current position y?r[y-1]=n:0, // if y is a number, put n at the index y of the result d?r[d+(d>6)]=n:0 // if d is a number, put n at the index d (accounting for "-"s) )) &&r.join`` // return the result as a string ``` ## Test ``` var solution = s=>[...(r=[,,,,"-",,,"-"],l=s.split` `)[1]].map((c,i)=>(c>"-"?n=c:0,y=+l[0][i],d=+l[2][i],y?r[y-1]=n:0,d?r[d+(d>6)]=n:0))&&r.join`` ``` ``` <textarea id="input" rows="3" cols="30"> 1 3 24 0 1 2 7 8 57 6 8 </textarea><br /> <button onclick="result.textContent=solution(input.value)">Go</button> <pre id="result"></pre> ``` [Answer] # Powershell, 119 bytes ``` $r=,'-'*99 ($a=$args-split' ')[1]|% t*y|%{if($_-32){$d=$_} $a[0,2]|%{$r[$_[+$p]-48]=$d} $p++} -join$r[1..4+0+5+6+0+7+8] ``` Ungolfed test script: ``` $f = { $r=,'-'*99 # init a result as an array of '-' repeated 99 times ($a=$args-split"`n")[1]|% t*y|%{ # split argument string, store a top, middle and bottom to $a, then for each char of the middle line... if($_-32){$d=$_} # store a digit to $d if the current character of the middle is not a space $a[0,2]|%{ # for the top and the bottom lines... $r[$_[+$p]-48]=$d # store a digit to the result array } # Note: if char in the current position is a space, then expression $_[+$p]-48 less then 0. # In this case, the expression $r[32-48]=$d changes unused element in a end of the array. # That is why the array was created by a large. $p++ # next position } -join$r[1..4+0+5+6+0+7+8] # return joined char with specified numbers # Note: element with index 0 has value '-' } @( ,(@" 2 3 1 4 0 1 2 3 7 5 67 8 "@,"2013-02-27") ,(@" 2 3 1 4 0 1 2 4 5 5 67 8 "@,"2015-12-24") ,(@" 1234 1 2 5678 "@,"2222-11-11") ,(@" 1 3 24 0 1 2 7 8 57 6 8 "@,"1878-02-08") ,(@" 2 4 1 3 0 1 2 6 5 678 "@,"2061-02-22") ,(@" 1 4 2 3 0 1 2 3 4 5 6 8 6 5 7 8 "@,"3564-10-28") ,(@" 1234 1 5678 "@,"1111-11-11") ,(@" 1 2 3 4 0 1 2 3 8 5 6 7 "@,"0123-12-30") ) | % { $a,$expected = $_ $result = &$f $a "$(""$result"-eq"$expected"): $result" } ``` Output: ``` True: 2013-02-27 True: 2015-12-24 True: 2222-11-11 True: 1878-02-08 True: 2061-02-22 True: 3564-10-28 True: 1111-11-11 True: 0123-12-30 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 38 bytes ``` Ỵṙ-Zn⁶Ṫ€œṗƊḊZḟ⁶V€$€;2/p/Ʋ€ẎṢṪ€s2Ḣ;jɗ”- ``` [Try it online!](https://tio.run/##y0rNyan8///h7i0Pd87Ujcp71Ljt4c5Vj5rWHJ38cOf0Y10Pd3RFPdwxHygcBhRUAWJrI/0C/WObgKyHu/oe7lwEUV5s9HDHIuusk9MfNczV/V/yqHH74fb//9XV1bm4FBQUDBVAwFhBwciEywDMNVJQMFdQsFDgMjUHSZmBFQC5XEAtAA "Jelly – Try It Online") The helper is only there to make input easier; this is actually a full program. **Be sure to care for**: * The first and last lines (`'''`), as well as the lines next to them (empty, there for clarity). + The actual input format doesn't have the second and penultimate empty lines, and the string starts and ends directly next to the quotes, without a newline in-between, like this: ``` ''' 1 3 24 0 1 2 7 8 57 6 8 ''' ``` You can leave the footer in while using this format. This is really a Python multi-line string, and the quotes are necessary for some inputs. * Pad the input with trailing spaces! Any correct output without correctly padded input is entirely coincidental, and isn't endorsed by me. ]
[Question] [ [Mafia](http://en.wikipedia.org/wiki/Mafia_(party_game)) (also known as Werewolf) is a party game that plays roughly like this: * The game begins on day 0. After every day `n` comes a night `n`. After every night `n` comes a day `n+1`. i.e. `D0, N0, D1, N1, D2, N2`... * At the dawn of day 0, a host secretly chooses players to fill certain roles: + Some number of players become the mafia. Every night, every mafioso chooses a player. At the dawn of the next day, the player chosen by the most mafiosos is killed. They are permanently removed from the game and their role is publicly revealed. Mafia-aligned. + Some number of players become cops. Every night, each cop chooses a player. At the dawn of the next day, the cop becomes aware of that players alignment. Village-aligned. + Some number of players become doctors. Every night, each doctor chooses a player. If this player is the same player that the mafia chose to kill, the mafia's actions for that night are canceled. Village-aligned. + All players who aren't chosen for another role are villagers. Villagers have no abilities that aren't shared by the whole town. Village-aligned. * Every day except day 0, the entire town (that is, all living players) votes for a player. At the end of the day, that player is removed from the game and their role is revealed. (On day 0, everyone just chills until nightfall.) * If, at any point, there are no remaining mafiosos, the game ends with all village-aligned players victorious (including the dead). * If, at any point, the village-aligned players do not outnumber the mafia-aligned players, the game ends with all mafia-aligned players victorious (including the dead). For this challenge, your goal is to write a bot to beat other bots at Mafia! **How to make a working bot** All you *have* to supply for me is a file called `run`. Inside the directory structure where this challenge will take place, your bot will live here: ``` start controller/ tmp/ players/ # You are here! some_bot/ # Let's pretend you're some_bot. to_server from_server players run # This is what you give me mafia-game-bot/ skynet/ ``` The `run` file, when executed, will make your bot do its thing. It's important to note that this file must not require any command line arguments or anything. It will be run exactly as `./run`. If you need to be executed in a different way, you'll have to work around it by doing something like this: `real_bot.py` ``` #!/bin/python2 # code goes here ``` `run` ``` #!/bin/bash ./real_bot.py --flags --or --whatever ``` An important thing to note is that all input your bot receives will be found in the file `from_server` and the control program will look for your bot's output in `to_server`. I chose to do it this way so that any language that can do file I/O is able to participate. If your language makes it easier to work with stdin and stdout than file I/O, you may want to write a `run` file that looks like this: ``` #!/bin/bash ./real_bot.py < from_server > to_server ``` This will make it so that stdin comes from the `from_server` file and stdout goes directly to `to_server`. Your bot will not stay running for the duration of the game. Instead, it will be run when it needs to make a decision. Likewise, it will not be informed when it's dead, it just won't be run anymore. Plan for this by saving anything you want to remember to a file and reading it later. You may create, write to or read from any file in your bot's folder, but **you may not write or read *anywhere* outside of that folder, including network access or anything**. If your bot knows *anything* that it wasn't told from inside the folder, or if it touches *anything* that isn't inside that folder, your bot is disqualified. **How to make a *functional* bot** *Day* At the beginning of the game, the file `players` will be filled with a newline-delimited list of all players in the game. It will not be updated as players leave the game. At the dawn of day 0, all players will find this message in their `from_server` file: ``` Rise and shine! Today is day 0. No voting will occur today. Be warned: Tonight the mafia will strike. ``` If you are the cop, the line `You are the cop` is appended to the end. The doctor sees `You are the doctor`. The mafia sees `You are a member of the mafia.\nYour allies are:` and a newline-delimited list of mafia members, excluding the player reading the message. At the dawn of all other days, this message will appear: ``` Dawn of day `day_number`. Last night, `victim` was killed. They were `victim_role`. Investigations showed that `cop_target` is `target_alignment`-aligned. These players are still alive: `remaining_players` ``` `dayNumber` is replaced with the number of the day. `victim` is replaced with the name of last night's victim, and `victim_role` is one of: * `a villager` * `a mafioso` * `the cop` * `the doctor` `cop_target` is the name of the player the cop investigated last night, and `target_alignment` is either `village` or `mafia`. Finally, `remaining_players` is a list of players that are still alive in this format: `player1, player2, player3` The second line is omitted if there was no kill last night, and the third line is shown only to the cop. For example, ``` Dawn of day 42. Last night, Xyzzy was killed. They were a villager. Investigations showed that Randy is mafia-aligned. These players are still alive: Randy, CopBot, JohnDoe, Steve ``` Once this message is out of the way, the day begins! Each bot can make 50 actions throughout the day, where an "action" is voting for a player or saying something out loud. To vote for a player, write `vote player_name` to your `to_server` file and terminate. To vote to not kill anyone, write `vote no one`. When you vote, all players (including you) will see `your_bot votes to kill your_selection`. Votes are ignored on day 0. A number of pre-defined messages can be sent to all players. The id of each possible message is listed here: ``` 0: No 1: Yes 2: I am the cop 3: I am the doctor 4: I am a normal villager 5: I trust this player: 6: I think this player is suspicious: 7: I think this player is the cop: 8: I think this player is the doctor: 9: I think this player is a normal villager: 10: I think this player is mafia: 11: Do you think this player is mafia? 12: I tried to save this player: 13: I successfully saved this player: 14: I investigated this player and found that they were mafia-aligned: 15: I investigated this player and found that they were village-aligned: 16: Will you please use your power on this player tonight? ``` All of these messages except the first five are referring to a specific player. To say one of those messages, write `say message_id player_name`. For one of the first five messages, just write `say message_id`. You may add an optional third argument to both of these, specifying the name of a player you're talking to (all players can still read it, but they'll know who the intended recipient is). When your bot says a message, all players read `your_bot says "message"`, where `message` is the message associated with the id you wrote. If the message includes a subject, one space character and the subject are inserted directly after the end of the message. If it includes a recipient, their name, one colon and one space character are inserted immediately before the message. At the end of the day, all living players are run one last time to see the result of the vote. If a player was voted out, this is written: ``` The town has killed player_name! They were a villager ``` ... or `a mafioso`, or `the cop`, or `the doctor`. If no player was voted out, this is written instead: ``` The town opted to lynch no one today. ``` When the controller sends these messages, it ignores any response from players. The day is over. *Night* At night, everyone but the villagers get to use their power. **Mafia:** You will read `It is night. Vote for a victim.`. When this happens, output the name of the player you'd like to kill. **Cop:** You will read `It is night. Who would you like to investigate?`. When this happens, output the name of the player you'd like to check. **Doctor:** You will read `It is night. Who would you like to save?`. When this happens, output the name of the player you'd like to protect. After this, the next day begins as normal. You may save yourself only once per game. **General Information** * The game will not run without 6 or more players. * One third of the players, rounded down, will be mafia. One player will be a doctor, and one player will be a cop. All other players are villagers. * Ties in the village vote or the mafia's overnight vote are settled randomly. * Bot names must be alphanumeric + dashes and underscores. * It is forbidden to use knowledge of opponent's code directly. In theory, I should be able to put your bot up against bots you've never seen before and have it perform comparably. * Regrettably, if I can't get your program running using exclusively free (as in beer) software, I'll have to disqualify it. * I reserve the right to disqualify any submission if I believe it to be malicious. This includes, but is not limited to using excessive abouts of time, memory or space to run. I've intentionally left the limit soft, but remember: I'm running this on my home computer, not a supercomputer, and I don't want getting results to take a year. I don't expect to have to use this, since my standards are pretty low. This is basically "if I think you're being a dick on purpose", and if you can convince me otherwise I'll reverse my decision. **Scoring** Each round, 100 games will be run (this may increase as more bots join to keep the sample size large enough, but in theory that won't affect anything). I will record how many times each bot wins as a villager compared to how many times it plays as a villager, and the same for mafia. A bot's `villager_ratio` is `number of games won as villager / number of games played as villager`, and `mafia_ratio` is the same but `s/villager/mafia/g`. A bot's score is `(villager_ratio - mean villager_ratio) + (mafia_ratio - mean mafia_ratio)`. **Example bot** Randy the Robot is not a good mafia player. Randy ignores pretty much everything, randomly choosing what to say, who to vote for, and who to target with night powers. `run.sh`: ``` #!/bin/bash ./randy.py < from_server > to_server ``` `randy.py`: ``` #!/usr/bin/env python import random with open('players') as f: p = f.read().split() + ['no one'] day = True try: line = raw_input() if line.endswith(('?', 'victim.')): day = False if not day: print random.choice(p) else: if random.random() > 0.5: if random.random() > 0.5: print 'vote {}'.format(random.choice(p)) else: id = random.randint(0, 17) print 'say {}{}'.format(id, (' ' + random.choice(p)) if id > 4 else '') except: pass ``` ## Controller @undergroundmonorail wrote a control program for this challenge, available [here](https://github.com/undergroundmonorail/Mafia-Engine). You have one month to code and turn in answers, I will give the winning bot (highest win rate tie breaker is votes) at least a 50 reputation bounty (depending on how much rep I can earn in a month) --- Here is a wrapper script, made by @Blacksilver, to use with compiled languages: ``` #!/bin/bash run="./a.out" compile="gcc bot.c" if [ -e $run ]; then $run else $compile $run fi ``` Put this in `run`. --- This post was written by @undergroundmonorail (I made a few edits). He gave it up [here](https://codegolf.meta.stackexchange.com/questions/7804/secret-santas-sandbox) to anyone who wanted to finish and post it. [Answer] The example code didn't worked for me, I use Python 3, so I changed the `main.py` file to make it work. So here is my fixed version for Python 3, I never programmed in Python before so maybe it is a horrible code but it is works :) `run.sh`: ``` #!/bin/bash ./randy.py < from_server > to_server ``` `randy.py`: ``` #!/usr/bin/env python3 import random with open('players') as f: p = f.read().split() + ['no one'] with open('from_server') as f: fs = f.read().split() msg = "" day = True try: line = fs[0] if line.endswith(('?', 'victim.')): day = False if not day: msg = (random.choice(p)) else: if random.random() > 0.5: if random.random() > 0.5: msg = ('vote {}'.format(random.choice(p))) else: id = random.randint(0, 17) msg = ('say {}{}'.format(id, (' ' + random.choice(p)) if id > 4 else '')) with open('to_server', 'w') as f: f.write(msg) print(msg) except: pass ``` A few thing I learned while I made this work (and it was not clear for me in the description) * `print` does not do anything with the game it is like a `console.log` in js * `input()` blocks the program running it can be good for step by step debugging * `from_server` and `to_server` is cleared every round. * It is impossible to stop the script with `Ctrl+C` combination, which is annoying. [Answer] # The Logician ``` #!/usr/bin/env python3 import sys import os import re import random from types import SimpleNamespace def chooseSet(set): return random.choice(list(set)) sys.stdin = open("from_server") sys.stdout = open("to_server","w") def saveData(data): with open("gameData.txt", "w") as datafile: datafile.write(repr(data.__dict__)) MY_NAME = os.path.basename(os.getcwd()) opener = input() DATABASES = ("targets","herd","mafiosos","guilty","innocent","unlikely", "requests", "selfvotes","players","used_roles") ALLOW_SELF = ("players", "mafiosos") LIESPERROLE = {"cop": ("I am the cop", "I investigated this player and found that they were mafia-aligned", "I investigated this player and found that they were village-aligned"), "doctor": ("I am the doctor", "I tried to save this player", "I successfully saved this player" ) } #1: At the beginning of the game, parse beginning of day 0 if opener == "Rise and shine! Today is day 0.": #Next two lines are completely predetermined and hold no data assert input() == "No voting will occur today." assert input() == "Be warned: Tonight the mafia will strike." data = SimpleNamespace(cop=False, doctor=False, queued=[],askers={}) for datum in DATABASES: setattr(data, datum, set()) try: nextline = input() if nextline == "You are a member of the mafia.": data.mafiosos.add(MY_NAME) assert input() == "Your allies are:" while True: data.mafiosos.add(input()) elif nextline == "You are the doctor": data.doctor = True data.used_roles.add("doctor") elif nextline == "You are the cop": data.cop = True data.used_roles.add("cop") except EOFError: #villager, or ran out of mafiosos to add pass with open("players") as playersfile: data.players = set(playersfile.read().strip().splitlines()) saveData(data) exit() with open("gameData.txt") as datafile: data = SimpleNamespace(**eval(datafile.read().strip())) #2: Beginning of day nonzero if opener.startswith("Dawn of day"): data.requests.clear() data.selfvotes.clear() data.askers.clear() data.voted = False try: while True: nextline = input() victim = re.match("Last night, (.*) was killed. They were (?:a|the) (.*).", nextline) if victim: victim, role = victim.groups() #remove dead people from lists for datum in DATABASES: getattr(data, datum).discard(victim) if role == "cop" or role == "doctor": data.used_roles.add(role) continue investigated = re.match("Investigations showed that (.*) is (.*)-aligned.", nextline) if investigated: assert data.cop who = investigated.group(1) if investigated.group(2) == "mafia": data.guilty.add(who) data.unlikely.discard(who) else: data.targets.discard(who) data.herd.discard(who) data.innocent.add(who) data.unlikely.add(who) continue except EOFError: pass #3: We're being told some messages / news elif " says " in opener or " voted " in opener: message = opener acted = question = False try: while True: if " voted " in message: message = "<vote against>" speaker, subject = re.match("(.*) has voted to lynch (.*)", message).groups() target = None else: speaker, target, message, subject = \ re.match("(.*) says \"(?:(.*), )?([^:\?]+)(?:[:\?]\s*(.*))?\"", message).groups() if speaker == MY_NAME: continue BAD_MESSAGES = ("<vote against>", "I think this player is mafia", "I investigated this player and found that they were mafia-aligned", "I think this player is suspicious") GOOD_MESSAGES = ("I think this player is the cop", "I think this player is the doctor", "I think this player is a normal villager", "I trust this player", "I investigated this player and found that they were village-aligned") OUTS = "I am the cop", "I am the doctor" LIES = () for role in data.used_roles: LIES += LIESPERROLE[role] if message == "Yes" or message == "No": if question and not target: target = chooseSet(data.askers) if target in data.askers: BAD_MESSAGES += "Yes", GOOD_MESSAGES += "No", subject = data.askers[target] if message in LIES and speaker not in data.mafiosos and speaker not in data.innocent: # What you just said is false, and I know it! data.unlikely.discard(speaker) data.targets.add(speaker) if subject and subject not in (data.unlikely.union(data.mafiosos)): data.targets.add(subject) elif message in BAD_MESSAGES: if speaker in data.guilty: #mafiosos rarely turn on eachother data.unlikely.add(subject) data.targets.discard(subject) elif speaker in data.unlikely: #believe the herd, especially people who we trust data.herd.add(subject) elif subject in data.unlikely: #how dare you speak against players likely to be village-aligned! data.targets.add(speaker) elif subject == MY_NAME or subject in data.mafiosos: #DON'T ATTACK ME (or my fellow mafiosos) data.targets.add(speaker) else: #believe the herd data.herd.add(subject) if not acted and message == "<vote against>": if subject == MY_NAME: data.selfvotes.add(speaker) if len(data.selfvotes) >= (len(data.players)-len(data.mafiosos))/3: if data.cop: print("say 2") #give a data point to prove it if random.random() > .5 and data.guilty: data.queued.append("say 14 %s" % chooseSet(data.guilty)) elif data.innocent: data.queued.append("say 15 %s" % chooseSet(data.innocent)) else: print("say 4") #Don't out myself if I'm the doctor # and just lie if I'm a mafioso acted = True else: data.selfvotes.discard(speaker) elif message in OUTS and data.mafiosos and speaker not in data.unlikely: data.targets.add(speaker) #Kill the fools who boast! elif message in GOOD_MESSAGES: chance = random.random() < .1 - (speaker in data.targets) / 20 if speaker in data.guilty: #Mafia liars if subject not in data.unlikely: data.targets.add(subject) elif subject == MY_NAME and chance: if speaker in data.targets:data.targets.remove(speaker) data.unlikely.add(speaker) elif speaker in data.unlikely or chance: data.unlikely.add(subject) elif message == "Do you think this player is mafia": if subject == MY_NAME: data.targets.append(speaker) if target == MY_NAME or not target: if speaker in data.guilty: data.queued.append("say 14 %s %s" % (subject, speaker)) elif speaker in data.innocent: data.queued.append("say 15 %s %s" % (subject, speaker)) elif subject in data.targets or subject in data.herd: data.queued.append("say 1 %s" % (speaker)) elif subject in data.unlikely: data.queued.append("say 0 %s" % (speaker)) if data.cop: data.requests.add(subject) data.askers[speaker] = subject question = True elif target == MY_NAME and message == "Will you please use your power on this player tonight": data.requests.add(subject) message = input() except EOFError: pass for datum in DATABASES: if datum in ALLOW_SELF: continue getattr(data, datum).discard(MY_NAME) chance = random.random() if data.queued: print(data.queued.pop()) elif chance < .1: target = chooseSet(data.targets or data.players) if target != MY_NAME: print("say 10 %s" % target) data.askers[MY_NAME] = target elif chance < .3 and data.targets: print("say 6 %s" % chooseSet(data.guilty or data.targets)) elif chance < .5 and data.unlikely: print("say 5 %s" % chooseSet(data.innocent or data.unlikely)) elif chance < .6 and not data.voted: target = chooseSet(data.guilty or data.targets or data.herd or data.players) if target not in data.mafiosos and target != MY_NAME: print("vote %s" % target) data.voted = True elif chance < .8: #do nothing pass elif chance < .9: #Confuse everybody print("say 1") data.queued.append("say 0") ###################### #4: End of day elif "has killed" in opener: victim = re.match("The town has killed (.*)!", opener) if not victim: exit() victim = victim.group(1) #remove dead people from lists for datum in DATABASES: getattr(data, datum).discard(victim) role = input() role = re.match("They were (?:a|the) (.*)", role).group(1) if role == "cop" or role == "doctor": data.used_roles.add(role) #Misc: purge people from lists if too large for list in data.unlikely, data.targets, data.herd: while len(list) > len(data.players)/3: list.pop() for player in data.innocent: data.unlikely.add(player) elif opener == "The town opted to lynch no one today.": #Do nothing pass #5: Night elif "night" in opener: if not data.mafiosos and data.requests and random.random() > .5: print(chooseSet(data.requests)) if data.doctor: print(chooseSet(data.unlikely or data.players)) else: while True: try: target = (data.targets or data.herd).pop() except KeyError: target = chooseSet(data.players) if target in data.mafiosos or target == MY_NAME: continue print(target) break else: raise ValueError("Unknown message") saveData(data) ``` Fancy, long bunch of python code that I'm not going to explain (although it isn't golfed), other than that it keeps lists of "friends" and "enemies" that are originally populated based on chance and/or cop investigation. Warning: do not lie in the logician's presence. [Answer] # Survivalist (v 1.0) **Synopsis** Survivalist simply brutally survives the game by berating anyone that dares to accuse him, regardless of whether he is mafia or not. **Logic** If you survive to the end of the game, you win no matter what. Therefore, you survive at all costs. **Backstory** The troops marched through the dark, damp forest. "Lieutenant, where are we marching?" The young recruit apparently hadn't hardened himself to atrocities, the commander thought. Oh well. He answered with a brusque "to destroy the enemy". At the village, the enemy commander was drinking and laughing along with the other officers at the club when a scout rushed in with the news. "There's a column, several hundred yards long, marching through the Yulin forest for us! Rally the troops!" The enemy commander, obviously inebriated, said unexpectedly, "I've had no reports from other scouts." The scout (later Survivalist) thought, *then I'll have to rally the troops myself*. After telling the story to the fellow scouts, they came back together, all saying that they had seen enemy troops. The commander still did not believe, saying, "I am *ordering* you to discontinue scouting. There are *no* enemy troops". The scouts decided to get their weapons to save the community. They managed to get to their positions just as the enemy arrived in the village in force. "CHARGE!" yelled the commander of the ambush. "BURN THE HOUSES! **BURN THE HOUSES! KILL EVERYONE, INCLUDING THE WOMEN AND THE CHILDREN!**" The scouts saved their entire army. They expected promotion, awards, and medals. Instead, they got a rigged court-martial for mutiny, conviction, 10 years in prison, dishonorable discharge from the military and exile. --- There is an old elder at the city council of Salem, Massachusetts. Legend has it that he founded the town. When you meet him in his isolated cottage out in the forest, don't let the twinkle in his eye make you think he's peaceful. If you accuse him, he will ruin you in front of the town. > > The Veteran laughed in the darkness. Afraid of the dark, no way. Afraid of monsters under the bed? The man with his hand on trigger of a gun laughed nervously. He wasn't scared of anything, he had told himself. Sure, he was a past war time hero, but he was so used to ambushes and life threatening situations that it made the man simply neurotic. His trigger finger twitched at simple shadows; his heartbeat quickened with every little sound. Yes, he was this scared of death. How could he not, seeing so many people die in horrible ways? All he knew from being kidnapped and miraculously escaping his enemies was that there was no mercy. > > > [Veteran](http://town-of-salem.wikia.com/wiki/Veteran) --- **Code (I'm a rookie in python, not sure if the code is good)** ``` #!/bin/python2 import random with open('players') as f: p = f.read().split() + ['no one'] day = True target = "survivalist" role = "villager" try: line = raw_input() if "You are the cop" in line: role = "cop" else if "You are the doctor" in line: role = "doctor" else if "You are a member of the mafia" in line: role = "mafia" if line.endswith(('?', 'victim.')): day = False if not day: if target == "survivalist": print random.choice(p) else if role == mafia || role == sheriff: print target else if role == doctor: print random.choice(p) else: if "survivalist" in line && ("I think this player is suspicious:" in line || "I think this player is mafia:" in line || "I investigated this player and found that they were mafia-aligned:")): print 'say 0' if role == "villager" || role == "mafia": print 'say 4' else if role == "cop": print 'say 2' else if role == "doctor" print 'say 3' target = line.split(" ")[0] print 'vote ' + target else if target != "survivalist": print 'say 6 ' + target print 'vote ' + target else: pass except: pass ``` [Answer] # Zulu `run` ``` #!/usr/bin/env php <?php error_reporting(E_ERROR|E_WARNING|E_PARSE); $self = basename(__DIR__); $msgids = array( "No", "Yes", "I am the cop", "I am the doctor", "I am a normal villager", "I trust this player:", "I think this player is suspicious:", "I think this player is the cop:", "I think this player is the doctor:", "I think this player is a normal villager:", "I think this player is mafia:", "Do you think this player is mafia?", "I tried to save this player:", "I successfully saved this player:", "I investigated this player and found that they were mafia-aligned:", "I investigated this player and found that they were village-aligned:", "Will you please use your power on this player tonight?" ); $msgids = array_flip($msgids); if(!file_exists('./from_server')){ die; } $in = file('from_server'); if(count($in) && strpos($in[0],'day 0.') !== false){ $game = array( 'day' =>0, 'players' =>array(), 'alive' =>array(), 'dead' =>array(), 'mafia' =>array(), 'village' =>array(), 'cop' =>'', 'doctor' =>'', 'votes' =>array(), 'messages' =>array(), 'currentvotes' =>array(), 'currentmessages' =>array() ); $playersfile = file('players'); foreach($playersfile as $name){ $game['players'][trim($name)] = 1; $game['alive'][trim($name)] = 1; $game['votes'][trim($name)] = array(); $game['messages'] = array(); } $allies = false; foreach($in as $line){ if($allies){ if(array_key_exists(trim($line),$game['players'])){ $game['mafia'][trim($line)] = 1; } } else if(strpos($line,"You are the cop") !== false){ $game['cop'] = $self; $game['village'][$self] = 1; } else if(strpos($line,"You are the doctor") !== false){ $game['doctor'] = $self; $game['village'][$self] = 1; } else if(strpos($line,"member of the mafia") !== false){ $game['mafia'][$self] = 1; } else if(strpos($line,"allies are:") !== false && $game['mafia'][$self]){ $allies = true; } } if(!$game['mafia'][$self]){ $game['village'][$self] = 1; } else{ foreach($game['players'] as $name=>$g){ if(!$game['mafia'][$name]){ $game['village'][$name] = 1; } } } $out = json_encode($game); write('myinfo',$out); } else{ $myinfo = file_get_contents('myinfo'); $game = json_decode($myinfo,true); if(count($in) && strpos($in[0],"town has killed") !== false){ $e = explode(" ",trim($in[0])); $dead = trim($e[4],'!'); unset($game['alive'][$dead]); $game['dead'][$dead] = 1; $e = explode(" ",trim($in[1])); $allegiance = trim($e[3],"."); $game[$allegiance][$dead] = 1; } else if(count($in) && strpos($in[0],"town opted to") !== false){ // } else if(count($in) && strpos($in[0],"night") !== false){ if(strpos($in[0],"victim") !== false){ $voted = false; if($game['day'] > 0){ $possible = array(); foreach($game['alive'] as $name=>$g){ if(!$game['mafia'][$name]){ foreach($game['votes'][$name] as $for){ if($voted && $game['mafia'][$for]){ $possible[] = $name; } } } } if(count($possible)){ shuffle($possible); write('to_server',$possible[0]); $voted = 1; } } if(!$voted){ while($rand = array_rand($game['alive'])){ if(!$game['mafia'][$rand]){ write('to_server',$rand); $voted = 1; break; } } } } else if(strpos($in[0],"investigate") !== false){ $possible = array(); foreach($game['alive'] as $name=>$g){ if(!$game['village'][$name] && !$game['mafia'][$name] && $game['doctor'] != $name){ $possible[] = $name; } } if(count($possible)){ shuffle($possible); write('to_server',$possible[0]); } } else if(strpos($in[0],"save") !== false){ if($game['day'] == 0){ write('to_server',$self); } else{ if($game['cop'] != '' && $game['alive'][$game['cop']]){ write('to_server',$game['cop']); } else{ $voted = false; foreach($game['alive'] as $name=>$g){ if($game['village'][$name] && $name != $self){ write('to_server',$name); $voted = true; break; } } if(!$voted){ while($rand = array_rand($game['alive'])){ if($rand != $self){ write('to_server',$rand); break; } } } } } } } else if(count($in) && strpos($in[0],"Dawn of day") !== false){ $e = explode(" ",trim($in[0])); $game['day'] = trim($e[3],"."); foreach($in as $line){ if(strpos($line,"was killed") !== false){ $e = explode(" ",trim($line)); $dead = $e[2]; if(strpos($line,"the cop") !== false){ $game['cop'] = $dead; $game['village'][$dead] = 1; } else if(strpos($line,"the doctor") !== false){ $game['doctor'] = $dead; $game['village'][$dead] = 1; } else if(strpos($line,"a villager") !== false){ $game['village'][$dead] = 1; } else if(strpos($line,"a mafioso") !== false){ $game['mafia'][$dead] = 1; } unset($game['alive'][$dead]); $game['dead'][$dead] = 1; } else if(strpos($line,"Investigations showed") !== false){ $e = explode(" ",trim($line)); $name = $e[3]; $align = trim($e[5]); $e = explode("-",$align); $game[$e[0]][$name] = 1; } } $game['currentvotes'] = array(); $game['currentmessages'] = array(); foreach($game['alive'] as $name=>$g){ $game['currentvotes'][$name] = ''; } } else{ foreach($in as $line){ if(strpos($line," has voted to lynch no one") !== false){ $e = explode(" ",trim($line)); $game['votes'][$e[0]][] = false; $game['currentvotes'][$e[0]] = false; } else if(strpos($line," has voted to ") !== false){ $e = explode(" ",trim($line)); $game['votes'][$e[0]][] = trim($e[5]," ."); $game['currentvotes'][$e[0]] = trim($e[5]," ."); } else if(strpos($line," says ") !== false){ foreach($msgids as $msg=>$id){ $chk = preg_match('/([^\s]+) says "(([^\s]+)[:,] )?'.preg_quote($msg).'( ([^\s]+))?"/',$line,$matches); if($chk){ // said by said to said said about $game['messages'][] = array($matches[1],$matches[3],$msg, $matches[5]); $game['currentmessages'][] = array($matches[1],$matches[3],$msg, $matches[5]); } } } } $written = false; $convo = array(); foreach($game['currentmessages'] as $msg){ if($msg[1] == $self){ $convo[$msg[0]] = $msg; } else if($msg[0] == $self && $msg[1] != ''){ unset($convo[$msg[1]]); } } if(count($convo)){ foreach($convo as $c){ if($msgids[$c[2]] == 11){ if($game['mafia'][$msg[3]]){ write('to_server',"say 1 ".$msg[0]); $written = true; break; } else if($game['village'][$msg[3]]){ write('to_server',"say 0 ".$msg[0]); $written = true; break; } else{ write('to_server',"say 11 ".$msg[0]); $written = true; break; } } else if($msgids[$c[2]] == 16){ write('to_server',"say 0 ".$msg[0]); $written = true; } else{ write('to_server',"say 4 ".$msg[0]); $written = true; } } } if(!$written){ $currentvote = false; if(array_key_exists($self,$game['currentvotes'])){ $currentvote = $game['currentvotes'][$self]; } if($game['mafia'][$self]){ $votes = @array_count_values($game['currentvotes']); if($votes && count($votes)){ arsort($votes); foreach($votes as $name=>$number){ if($game['village'][$name]){ if($currentvote != $name){ write('to_server','vote '.$name); $written = true; break; } } } } } else{ if(count($game['mafia'])){ foreach($game['mafia'] as $name=>$g){ if($game['alive'][$name]){ $written = true; if($currentvote != $name){ write('to_server','vote '.$name); } break; } } if(!$written){ foreach($game['mafia'] as $name=>$g){ $non = $game['alive']; unset($non[$self]); if(array_key_exists($name,$game['votes'])){ foreach($game['votes'][$name] as $vote){ if(array_key_exists($vote,$non)){ unset($non[$vote]); } } } if(count($non)){ $rand = array_rand($non); write('to_server','vote '.$rand); $written = true; break; } } } } if(!$written && $game['cop']){ $possible = array(); foreach($game['votes'][$game['cop']] as $name){ if($game['alive'][$name] && $name != $self){ $possible[] = $name; } } if(count($possible)){ shuffle($possible); write('to_server','vote '.$possible[0]); $written = true; } } if(!$written && count($game['dead'])){ foreach($game['dead'] as $name=>$g){ if($game['village'][$name]){ $v = array(); foreach($game['votes'] as $voted=>$arr){ if($game['alive'][$voted] && in_array($name,$arr)){ $v[$voted] = 1; } } unset($v[$self]); if(count($v)){ $rand = array_rand($v); write('to_server','vote '.$rand); $written = true; break; } } } } if(!$written){ $votes = @array_count_values($game['currentvotes']); if($votes && count($votes) && array_key_exists($self,$votes)){ arsort($votes); foreach($votes as $name=>$number){ if(!$game['village'][$name]){ if($name != $self){ write('to_server','vote '.$name); $written = true; break; } } } } } } } } $myinfo = json_encode($game); write('myinfo',$myinfo); } function write($filename,$data){ $fh = fopen($filename,"wb+"); if($fh){ $bytes = fwrite($fh,$data); fclose($fh); } } ``` Not everything I hoped it would be. I may end up tweaking it occasionally. ## How it works v1.0 Keeps track of day number, who is alive, who is dead, who is mafia, who is village-aligned, roles, current day votes/messages, and overall votes/messages. 1. Night a. Mafia - Vote for any villager who has voted against mafia (randomly) if possible, otherwise a random villager. b. Cop - Investigate anyone who is of unknown alignment. c. Doctor - Save self first turn, then save cop if known (I don't think it can ever know this as of now), save villager if known (probably doesn't know this either), otherwise save random person. 2. Day a. If anyone has spoken a message directly to self, respond to them (limited responses possible). b. Mafia - Vote for the villager who has the most votes. c. Villager with any alive Mafia-aligned known - vote for mafioso. d. Villager with only dead Mafia-aligned known - vote for a random bot who has never voted for the mafioso. e. Villager with Cop known - vote for random bot the cop has voted for. f. Villager with dead Village-aligned known - vote for a random bot who voted for the dead. g. Villager with votes against self - vote for the highest currently voted non-village-aligned bot. [Answer] # Avatar Avatar "randomly" picks one player at the start and relentlessly focuses them for the rest of the round. This is not a reference to a similarly-named animated TV show. > > It's an EVE online refrence. > > > [Download tar of all required files](http://blacksilver.xyz/mafia/ava.tar) ## Changelog * **v1** Birthday * **v2** Doesn't log anything to `stdout`, only to `stderr`. To suppress `stderr` too, add `2>/dev/null` to the end of the `run` file. ``` /* Casting his sight on his realm, the Lord witnessed The cascade of evil, the torrents of war. Burning with wrath, He stepped down from the Heavens To judge the unworthy, To redeem the pure. -The Scriptures, Revelation Verses 2:12 */ #include <stdlib.h> #include <stdio.h> #include "mafia.h" int getRandomNumber(){ return 4; // Chosen by a fair dice roll. // Garunteed to be random. } void day0(){ char * target = get_player(getRandomNumber()-1)->name; fprintf(stderr, "Target: `%s'\n", target); FILE * f = fopen("target", "w"); if(!f){exit(1);} fprintf(f, "%s", target); fclose(f); } int main(){ get_players(); int cycle = get_cycle(day0); FILE * out = fopen("to_server", "w"); if(!out){exit(1);} FILE * targetF = fopen("target", "r"); if(!targetF){exit(1);} char target[64]; fscanf(targetF, "%s", target); fprintf(stderr, "Target: %s\n", target); if(cycle == 0){ // night fprintf(out,"%s\n", target); fprintf(stderr, "> Voting to kill %s\n", target); exit(0); } else if (cycle > 0) { // day fprintf(out, "vote %s\n", target); fprintf(stderr, "> Voting to lynch %s\n", target); exit(0); } else if (cycle == -1) { fprintf(stderr, "> saying 6, 10 at %s\n", target); fprintf(out, "say 6 %s\n", target); fprintf(out, "say 10 %s\n", target); } } ``` It requires `mafia.c` and `mafia.h`, libraries I wrote, in the same directory. These are included in the download, along with a Makefile and a run script. ### TODO * Stop voting against the target when they're killed or lynched. While I'm here, I'll submit the non-bot, Steve: [Answer] # Leviathan Leviathan iterates over all the players in the `players` file and targets them one by one. [Download](http://blacksilver.xyz/mafia/leviathan.tar) ``` /* Citizens of the State, rejoice! Today, a great milestone has been achieved by our glorious leaders. A stepping stone in the grand story of our empire has been traversed. Our individual fears may be quietened; the safety of our great nation has been secured. Today, unyielding, we have walked the way of the warrior. In our hands have our fates been molded. On the Leviathan's back will our civilization be carried home and the taint of the Enemy purged from our souls. Rejoice, citizens! Victory is at hand. -Caldari State Information Bureau Pamphlet, YC 12 */ #include <stdio.h> #include <stdlib.h> #include "mafia.h" void day0(){ FILE * index = fopen("idx", "w"); fprintf(index,"0"); fclose(index); } int main(){ get_players(); int i, cycle = get_cycle(day0); FILE * out = fopen("to_server", "w"); FILE * idx = fopen("idx", "r"); fscanf(idx, "%d", &i); fclose(idx); char * target; target = get_player(i)->name; fprintf(stderr, "Idx: %d\n", i); fprintf(stderr, "Target: %s\n", target); if(cycle > 0){ idx = fopen("idx", "w"); i++; i = i%NPLAYERS; fprintf(idx, "%d", i); fprintf(out, "vote %s\n", target); } else if (cycle == -1) { printf("> saying 6, 10 at %s\n", target); fprintf(out, "say 6 %s\n", target); fprintf(out, "say 10 %s\n", target); } fclose(out); } ``` As with Avatar, It requires `mafia.c` and `mafia.h` in the same directory. These are included in the download, along with a Makefile and a run script. ]
[Question] [ Posted from [here](https://codegolf.meta.stackexchange.com/questions/2140/sandbox-for-proposed-challenges/17916#17916). This challenge is highly "distilled" from [this](https://codegolf.stackexchange.com/questions/188863/print-function-for-linked-list) question. Special thanks to @Akababa! In this task, you should insert an exclamation mark at the start of the string and after every character. ## Rules * There will always be a non-empty-string input. The input will not contain tabs either. You can assume that the input only contain non-extended ASCII printable characters and newlines. * The input will not contain trailing newlines as long as your language can't detect a newline. * This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") contest; the shortest answer should win. ## Examples * 4 newlines result in 5 newline-delimited exclamation marks. It is very hard to put this as a Markdown text, so this is stated instead. ``` 1 2 3 4 5 6 129591 129012 129127 129582 0 ``` Outputs ``` !1! !2! !3! !4! !5! !6! !1!2!9!5!9!1! !1!2!9!0!1!2! !1!2!9!1!2!7! !1!2!9!5!8!2! ! !0! ``` ``` asd afjoK ak:e kPrLd fOJOE; KFO KFkepjgop sgpaoj faj ``` Outputs ``` !a!s!d! !a!f!j!o!K! !a!k!:!e! !k!P!r!L!d! ! ! ! ! !f!O!J!O!E!;! ! ! ! ! !K!F!O! !K!F!k!e!p!j!g!o!p! !s!g!p!a!o!j! ! ! !f!a!j! ``` A base test case with only one character: ``` a ``` Outputs ``` !a! ``` (Auto-completion! Just kidding, there is no such thing.) Contains exclamation marks: ``` !! !! !! !! !! ``` Outputs: ``` !!!!! !!!!! !!!!! !!!!! !!!!! ``` [Answer] # [QuadR](https://github.com/abrudz/QuadRS), 1 byte Thanks to A\_\_ for halving the byte count! ``` ! ``` [Try it online!](https://tio.run/##KyxNTCn6/1/x/39DBSMFYwUTBVMFMy5DI0tTS0MFIGVgaASiDI3MQZSphREXlwEA "QuadR – Try It Online") Replaces nothing with `!` [Answer] # [Python 3](https://docs.python.org/3/), 26 bytes ``` lambda s:s.replace('','!') ``` [Try it online!](https://tio.run/##TY5BT8MwDIXv/hVuLm3RQE1GgRXtyCQoUrkDB486Y@1IoiQS4teXprvMsvQ9PT0/2f3Fb2vWk95@TCf62feEoQk3nt2JvrjI81We5eUUOcSAW3wXzyawj7jn@MtsxAqEEBIVrvEWa7wDqTb1RuKMSqoEqe4T6gcFUM3h5YJCj6QH2yKNDcP45l97wHl099I9PS6y3XXQ7kZ2w8E6DAdHdkgJGs4tdK7KMrjY2YBPANDWY3oaj2ZhaJZO548mFuJaXKmqvHB0kUJlOf0D "Python 3 – Try It Online") [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 2 bytes ``` ! ``` [Try it online!](https://tio.run/##K0otycxL/P@fS/H/f0MFIwVjBRMFUwUzLkMjS1NLQwUgZWBoBKIMjcxBlKmFEReXAQA "Retina 0.8.2 – Try It Online") At last, a challenge where Retina has a built-in! [Answer] # [Python 3](https://docs.python.org/3/), 27 bytes ``` lambda s:f"!{'!'.join(s)}!" ``` [Try it online!](https://tio.run/##TY7BTsMwEETv@xXrvTRBgGK3AZqqRypBkNJ74eAqdolDbSu2hBDi20OcXrpa6Y1Gs6P1P/HT2eWot@/jlzwfW4mh0sR@F2xxb1xns5D/MRqjCjHgFg/0YoMaIh5V/FbK0i0QEUeBS1xhiQ/Axbpcc5xQcJHAxWNC@SQAiik8X8jQotTG1Sj7SkG/H95awGl089o8b2ZZ7xqod73y5uQ8hpOXzqSENJcWealiDK52MuADALQbMD2NnZ0ZqrnTD52NGd3RjSjyK0dnKZTn4z8 "Python 3 – Try It Online") Honestly, I hope someone can show me a cool way to do this with a smaller byte count. [Answer] # [Python 2](https://docs.python.org/2/), 27 bytes ``` lambda s:'!%s!'%'!'.join(s) ``` **[Try it online!](https://tio.run/##HYwxEoIwEAD7e0VSMAeNhSUOpRTGmfgAmnNCkESSG47G18foVlvsLH@OV07n4oepvGl7OlLSo25EY4MaTyGvqZWuyICIE5A4RT5koyj2M8THfnegKt7e7PXyVzNaMGOcOSyZlSxMOfwKCnUBwPuajtbXaVe@ "Python 2 – Try It Online")** [Answer] # Haskell, 18 bytes ``` ('!':).(>>=(:"!")) ``` -1 byte thanks to @nimi [Try it online!](https://tio.run/##y0gszk7NyfmfZhvzX0NdUd1KU0/Dzs5Ww0pJUUlT839uYmaegq1CemqJc35eSWpeSbECUFahoLQkuKTIJ09BTyHtf1p@vkJSYhEQV3FlAM3K/5eclpOYXvxfN8I5IAAA "Haskell – Try It Online") [Answer] # [brainfuck](https://github.com/TryItOnline/brainfuck), ~~24~~ 22 bytes -2 bytes thanks to JoKing. ``` -[-[-<]>>+<],[>.<.,]>. ``` [Try it online!](https://tio.run/##SypKzMxLK03O/v9fNxoIbWLt7LRtYnWi7fRs9HRi7fT@//dUyMkvS1VwgqkEAA "brainfuck – Try It Online") [Answer] # [Labyrinth](https://github.com/m-ender/labyrinth), ~~19 11 10~~ 9 bytes ``` 33 .. ",@ ``` **[Try it online!](https://tio.run/##y0lMqizKzCvJ@P/f2JhLT49LScfh///g/JyyVK6QjFQuH5i8IgA "Labyrinth – Try It Online")** ### How? We enter the Labyrinth at the top-left facing right with an infinite stack of zeros... ``` I / O stack 0,0,0,... 3 - pop * 10 + 3 3,0,0,0,... - 2 neighbours, forward 3 - pop * 10 + 3 33,0,0,0,... - 2 neighbours, forward . - pop & print chr ! 0,0,0,... - T junction from the side - TOS==0, forward , - read chr or -1 L 76,0,0,0,... or -1,0,0,0 - T junction from the base - if TOS > 0 right: " - no-op 76,0,0,0,... - 2 neighbours, forward . - pop & print chr L 0,0,0,... - T junction from the side - TOS==0, forward 3 - ...back to the start - elif TOS == -1 left: @ - exit we're out! * right, but on the first occasion (from above) we hit the wall and turn around, so that's like a left ``` Luckily we don't need to handle un-printables, otherwise the first zero-byte would turn us around at `,` and play havoc. [Answer] # JavaScript (ES6), 19 bytes Takes input as an array of characters. ``` s=>`!${s.join`!`}!` ``` [Try it online!](https://tio.run/##hYxNC4JAFEX371e8gUAlGpwpKwvb5SID21cwg184iiNOtIl@u2mrFoGXC@cuDlfJpzRJV7aPRaPTrM@D3gQHQWYvQ5UuG0HEm4g@0Y3RdUZrXdi5faWUCoYcl7hCD9fAuO/5DAe4jI9gfDPC23IAV9wdnKN1aywH4M@TNCnKXOkIZbXLoLp05xRwSB6f4uP@O6MwhiisslYVukVTtFKr0ZBq8n1KIAR@OthO/wE "JavaScript (Node.js) – Try It Online") --- # JavaScript (ES6), ~~23~~ 20 bytes *Saved 3 bytes thanks to @ShieruAsakoto* Takes input as a string. ``` s=>[,...s,,].join`!` ``` [Try it online!](https://tio.run/##fYzBCoJAGITv/1P8nlSyxd2ysrBbHjKwewW76Cqu4oobvf6mnaJDw8A3MMMo8RKmGJvhuex1KW2VWJMcbwEhxATBgyjd9NzhttC90Z0kna69yuMUGa5wjRFugLI4iilOCCmbQdl2RrRjACH3cYHuvXd9gJ8TYUoUldIZinYvob2OlxJwUpWf89PhE7M0hyxt5aBqPaCpB6HVvBDq3/GfznHgy9z37Rs "JavaScript (Node.js) – Try It Online") --- # JavaScript (ES6), 22 bytes *Suggested by [@tjjfvi](https://codegolf.stackexchange.com/users/87606/tjjfvi)* Takes input as a string. ``` s=>s.replace(/|/g,"!") ``` [Try it online!](https://tio.run/##fYyxDoIwGIT3/yl@WKBRgVZR0eAmg5jgAzjQQCEWQhtqnHx3BCfjwOWS75K7nOQvbor@oZ@rTpViqOLBxCfj9UK3vBCu//brpW3ZZChUZ1QrvFbVbuXmFBmucYMhboGyKIwojggom0DZbkK4ZwBBTnCBzr1zCMDfCTcl8kqqFHlzENDc@msJOKrKLtn5@I1pkkGaNELLWmk0teZKTgsu545nOsuCH@eEDB8 "JavaScript (Node.js) – Try It Online") [Answer] # [Pepe](https://github.com/Soaku/Pepe), 47 bytes ``` REREEeRErEErREeeEeeeeEREEeeREEeereeREEEEeeEReee ``` [Try it online!](https://soaku.github.io/Pepe/#&T&E@!8j!l!l*DvH) **Explanation:** ``` REREEeRE # Push 0,then input (str),then 0 -> (R) # The zeroes are pushed to correct the inserting rEE # Begin loop labelled 0 -> (r) rREeeEeeeeE # Push "!" -> (R) # r flag inserts it instead of pushing REEeeREEee # Move pointer pos 2 steps forward -> (R) ree # Loop while (R) != 0 REEEEeeE # Remove characters of (R) that are in stack of (r) # Removes the 0 in (R) Reee # Output (R) ``` [Answer] # [R](https://www.r-project.org/), 25 bytes ``` function(x)gsub("","!",x) ``` [Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP0@jQjO9uDRJQ0lJR0lRSadC83@ahpJHak5OvkJ5flFOiqKS5n8A "R – Try It Online") A function accepting and returning a character vector. [Answer] # 8086 machine code, .COM format (MS-DOS 2+), 32 bytes (-1 depending on emulator: see below) For best results redirect standard input from a file, as typing gives odd-looking output due to no buffering; also, newlines look a little weird because they are stored as `CR LF`, and the `CR` part messes up the output. This program behaves fine in an actual MS-DOS emulation (e.g. PCjs) but DOSBox seemed to have issues with Ctrl+Z EOF (see comments in the assembly listing), so *DON'T* try to enter input using the console in DOSBox unless you add the extra check! ``` BB 01 00 53 59 BA 0B 01 B4 40 CD 21 4A 4B B4 3F CD 21 85 C0 74 09 B4 40 43 41 CD 21 49 EB EE C3 ``` Some interesting bits: * I saved some data space by reusing memory that had already been executed (the `21H` in `INT 21H` happens to be `!`) * I was *almost* able to use an interesting trick that I found on the page ["The Hidden Power of BCD Instructions"](http://www.hugi.scene.org/online/coding/hugi%2017%20-%20coaax.htm) which would have allowed me to use `AAA` instead of a standard `TEST` to compare `AL` to 0, saving one byte. Unfortunately, this is not fully documented so I couldn't rely on it: for example, PCjs doesn't adjust anything but the carry and auxiliary carry flags. :-( Assembly code (TASM ideal mode): ``` IDEAL MODEL TINY CODESEG ORG 100H ;; DOSBox (tested with 0.74-2) didn't seem to handle Ctrl-Z as EOF ;; so uncomment the ";;" lines to run it there. MAIN: MOV BX,1 PUSH BX POP CX MOV DX,OFFSET MAIN_1+1 ; The 21H in INT 21H MOV AH,40H MAIN_1: INT 21H DEC DX ;;PUSH DX ;;POP SI IO_LOOP: DEC BX MOV AH,3FH INT 21H ;;; This should work on an non-emulated PC. ;;;AAA ; AL=0? TEST AX,AX JZ DONE ;;CMP [BYTE PTR SI],1AH ;;JZ DONE MOV AH,40H INC BX INC CX INT 21H DEC CX JMP IO_LOOP DONE: RET ENDS END MAIN ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` Ż”!ṁż ``` A full program accepting a string, which prints the result. **[Try it online!](https://tio.run/##y0rNyan8///o7kcNcxUf7mw8uuf////q6uqJxSkKiWlZ@d4KidlWqVzZAUU@KVwKQJDm7@Xvag1merv5c3m7ZacWZKXnFygUpxck5meBVCRmAQ0AAA "Jelly – Try It Online")** ### How? ``` Ż”!ṁż - Main Link: list of characters, s e.g. "abc" ”! - character '!' '!' ṁ - mould like: Ż - s with a zero prepended "!!!!" ż - zip together with s ["!a","!b","!c",'!'] - implicit (smashing) print !a!b!c! ``` [Answer] # 6502, 12 bytes (13 bytes if Apple II) **6502** The machine code assumes that a pair of zero page locations are connected to character input ($FE) and output (FF) hardware. Many 6502-based systems facilitate I/O in this fashion, albeit I/O address are usually not in zero page. For simplicity, I used [Py65](https://github.com/mnaberez/py65), a 6502 microcomputer system simulator written in Python. Here is a memory dump from Py65. You can load the following code anywhere in zero page such that it does not overlap $FE and $FF. ``` PC AC XR YR SP NV-BDIZC 6502: 0000 00 00 00 ff 00110010 .mem 0:b 0000: a9 21 85 ff a5 fe f0 fc 85 ff d0 f4 ``` Running in a Windows command window, you can paste (Ctrl+V) any text you desire, or you can simply type. If typing, press Ctrl+J for a newline (same ASCII char). Press Ctrl+C to interrupt the processor and return to the Py65 command prompt. Naturally, assembly code is easier to read. ``` PC AC XR YR SP NV-BDIZC 6502: 0000 00 00 00 ff 00110010 .d 00:0b $0000 a9 21 LDA #$21 $0002 85 ff STA $ff $0004 a5 fe LDA $fe $0006 f0 fc BEQ $0004 $0008 85 ff STA $ff $000a d0 f4 BNE $0000 ``` For clarity, here is the assembly code in [CBA65](http://www.crbond.com/tools.htm) format. ``` ; ASSEMBLE: ; cba65 bangit ; ; LOAD/RUN ; python3 py65/monitor.py -i 00fe -o 00ff -l bangit.bin ; goto 0000 .FILES BIN=256 ; I/O LOCATIONS GETC .EQU $FE ; (1) MOVING PY65'S GETC TO ZP SHAVES 1 BYTE PUTC .EQU $FF ; (1) MOVING PY65'S PUTC TO ZP SHAVES 2 BYTES .ORG $0000 VROOM LDA #'!' STA PUTC VROOM2 LDA GETC BEQ VROOM2 STA PUTC BNE VROOM .END ``` **Apple II** The code above assumes a null indicates there is no input, so continues polling until a non-null value is returned. For comparison, the Apple I and Apple II signals availability of a new character by setting bit 7 of the keyboard I/O address, which then needs to be cleared after fetching the character. On those systems, character I/O usually is performed by calling system monitor routines instead of accessing the hardware directly. By calling RDKEY ($FD0C) and COUT ($FDED), the Apple II equivalent of the above can be coded in 13 bytes, and is runnable anywhere in RAM. Here is the code I ran in an Apple //e emulator, [a2ix](https://play.google.com/store/apps/details?id=org.deadc0de.apple2ix.basic&hl=en_US) on Android 9. Pressing Return has the same effect as a newline. ``` *300L 0300- A9 A1 LDA #$A1 0302- 20 ED FD JSR $FDED 0305- 20 0C FD JSR $FD0C 0308- 20 ED FD JSR $FDED 030B- F0 F3 BEQ $0300 ``` Did you notice that instead of the normal ASCII value #$21 for the exclamation point, #$A1 is used instead? That's because sending standard ASCII values to COUT causes them to be displayed in "inverse mode," black on white. Displaying ASCII in normal white on black requires adding #$80 to the character value in the accumulator before calling COUT. Because RDKEY returns characters with the hi-bit set, assembly programs generally cleared the bit of the character to obtain its ASCII value before using it. [Answer] # [sed](https://www.gnu.org/software/sed/), 12 bytes ``` s/\b\|\B/!/g ``` [Try it online!](https://tio.run/##K05N0U3PK/3/v1g/JimmJsZJX1E//f9/QwUjBWMFEwVTBTMuQyNLU0tDBSBlYGgEogyNzEGUqYURF5cBAA "sed – Try It Online") *-3 bytes thanks to Cows Quack* [Answer] # [Befunge-98 (PyFunge)](https://pythonhosted.org/PyFunge/), 7 bytes ``` '!,#@~, ``` [Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//9XV9RRdqjT@f/fUMFIwVjBRMFUwYzL0MjS1NJQAUgZGBqBKEMjcxBlamHExWUAAA "Befunge-98 (PyFunge) – Try It Online") [Answer] # [Perl 5](https://www.perl.org/) -p0, ~~17~~ 6 bytes ``` s,,!,g ``` [Try it online!](https://tio.run/##HcxBDsIgFEXROat4rY0jbOAr1Zq4FtMBaTENkA9Ndy9SRyd3cqPl1ZRTYDc7P62YfNotY3d5wWdLGZf4j7BlKDhfW2GxbJ/o3q@2afske9mdGzlzSVJWS9EgXHGDwSA0jWbUqChNB5ruB@ZBQqhviNkFn0rd/gA "Perl 5 – Try It Online") My original answer was `-p` and `$_='!'.s,.,$&!,gr`. Thanks to @Nahuel Fouilleul for cutting 11 bytes and to @Grimy for the `-p0` tip. [Answer] # [MarioLANG](https://github.com/tomsmeding/MarioLANG), ~~95~~ ~~94~~ ~~90~~ ~~89~~ 69 bytes ``` ++++++ ======< >) >+++++++",+[ =======<.==< >+++++++!(.- ========#=== ``` [Try it online!](https://tio.run/##y00syszPScxL//9fGwy4bMHARsFOk8sOIqStpKMdDRW3tdEDYriMooaeLkzGVhmI//9PLE5RSEzLyvdWSMy2SuXKDijySeFSAII0fy9/V2sw09vNn8vbLTu1ICs9v0ChOL0gMT8LpCIxCwA "MarioLANG – Try It Online") First time trying out MarioLANG, that was a lot of fun! *Thanks to **Jo King** for -20 bytes* **Explanation:** So, as the name implies, MarioLANG is made to execute like a game of Super Mario Bros. It operates similarly to BF, with memory arranged in a tape of cells. There are operators to increment, decrement, print (as ascii or numeric) and read into the current memory cell, and operators to move left or right along the tape. Mario (the instruction pointer) always begins in the top left cell of the program, with his intended direction of motion set to the right. If Mario does not have a floor-like object beneath him (=, ", or #), he will fall until he reaches a floor-like object. If Mario leaves the program space, the program ends due to Game Over :( This specific program can basically be split into two halves: the setup, and the loop. ``` Setup Loop ----------------------------------------------- | ++++++ | ======< | >) >+++++++ | ",+[ =======< | .==< >+++++++ | !(.- ======== | #=== ``` In the Setup section, we're simply incrementing the first memory cell until we reach 33 - the ASCII value for "!". Easy enough; if this can be golfed, it's purely a matter of shape. Mario starts from the top left, picks up 10 coins, starts falling when picking up the 11th, switches directions, then repeats. He picks up the last 11 coins without switching directions; he ends the setup section at the bottom-rightmost "+". In the loop section, Mario starts by reaching an elevator. The "!" operator makes him cease motion, so that he remains on the elevator. On the way up, it prints the corresponding ASCII character to the current memory cell's value (this one is always 33, "!"), then switches to the next cell in memory. Mario reaches the top and sets his direction to the right. He falls, and reads a character from input as its ASCII value (or -1 if no character). We increment because the only measure of control in MarioLANG is to skip an instruction if the current memory cell has a value of 0. If it does, we skip changing Mario's direction, so he will walk right off of the next floor to his doom. If it does not, we set direction to left; walking left off of the floor below decrements the current cell back to its previous value, that value is printed, and we move back to the first memory cell before getting back on the elevator. --- **Previous version (89 bytes):** ``` +++++++++++>, ==========@"+ +++++++++++)[ @==========.==< +++++++++++!(.- ===========#=== ``` [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~16~~ 11 bytes ``` {S:g/<(/!/} ``` [Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/OtgqXd9GQ19Rv/Z/cWKlQppCcU5pUcF/QwUjBWMFEwVTBTMuQyNLU0tDBSBlYGgEogyNzEGUqYURF5cBAA "Perl 6 – Try It Online") Replaces all zero width matches with exclamation marks. Null regexes are not allowed, so we use a capture marker to capture nothing instead [Answer] # [AWK](https://www.gnu.org/software/gawk/manual/gawk.html), 11 bytes ``` gsub(a,"!") ``` [Try it online!](https://tio.run/##SyzP/v8/vbg0SSNRR0lRSfP//8TiFIXEtKx8b4XEbKtUruyAIp8ULgUgSPP38ne1BjO93fy5vN2yUwuy0vMLFIrTCxLzs0AqErMA "AWK – Try It Online") This is similar to some other entries. It changes a null string to `!` globally, using `$0` as the default target, then prints the result since no other action is defined. Using `a` works since it's an undefined variable and is shorter than using `""` (which would do the same thing). [Answer] # [Zsh](https://www.zsh.org/), ~~32~~ 23 bytes ``` <<<!${(j:!:)${(s::)1}}! ``` ~~[Try it online!](https://tio.run/##TYvLCoJAGIX3/1McSVAXQTNlF6OlLTKwB2gz6ExeYkYcISh69klr08eB7yzOedrKPar6LhGG8GeIoj1K45TpUSAMAviv0CZJxN6RLCqDuU7hF56zVa0G6vpaDwrBVR9@XHVApdHSOQaOJVaIsSbGd/GOYdSC8UmMbybFW060ICdsCaEak0G0iaT20p9LwojKT3m6/9bsmFN2bGXX3EwHe@uEaaaFaMa/8zz6ywc "Zsh – Try It Online")~~ [Try it online!](https://tio.run/##TYvLDoIwFET39ytuIwmwo1VUCi5lISb4AW6alFcxtKEkJhq@vYJuPJnkzGLmZVv3bLtHhUGA3gbDMEWpXZZlxHsHihMeLrach3SeibNtV09gxm6YavTvw@nHffBB6qFyjiLDLe4wxj1QlsQJxUURZasoO6yKjwwgAiesRFErXaDoeQX9bbxKwIW6vJTn9FuLvIQi7yujGm3QNkZotS6EWv6OEPjLBw "Zsh – Try It Online") `(s::)` splits into characters, `(j:!:)` joins on `!`s. [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), 11 bytes ``` (∊⊢⍪⍪¨)∘'!' ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R2wSNRx1dj7oWPepdBUSHVmg@6pihrqgOlFM3VDBSMFYwUTBVBwA "APL (Dyalog Unicode) – Try It Online") @Adám's golf to mine (see below). ``` {'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)} ⍝ original {'!'⍪∊⍵⍪¨('!'⍴⍨≢⍵)} ⍝ concatenate each instead of transpose mix {'!'⍪∊⍵⍪¨ '!'} ⍝ each already handles many-to-one { ⍵ ⍪∊⍺⍪¨ ⍵ }∘'!' ⍝ break out "!" {∊⍵ ⍪ ⍺⍪¨ ⍵ }∘'!' ⍝ defer flattening to later (∊⊢ ⍪ ⍪¨ )∘'!' ⍝ go tacit (∊⊢⍪⍪¨)∘'!' ⍝ remove spacing ``` # [APL (Dyalog Unicode)](https://www.dyalog.com/), 19 bytes ``` {'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)} ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RqdUX1R72rHnV0PertfNQ28VHvVg2w0JZHvSsedS4C8jVrgUoV1A0VjBSMFUwUTBXM1AE "APL (Dyalog Unicode) – Try It Online") My first APL submission :P Loving this language. No idea why I need the parentheses after `⍵`. ``` {'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)} { } ⍝ Boilerplate ⍴⍨ ⍝ Repeat '!' ⍝ Exclamation point ≢⍵ ⍝ len(input) times ⍵( ) ⍝ Wrap ^ into an array with the input ↑ ⍝ Matrixify ⍉ ⍝ Transpose ∊ ⍝ Flatten ⍪ ⍝ Prepend '!' ⍝ An exclamation point ``` [Answer] # [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 28 bytes ``` s=>$"!{String.Join("!",s)}!" ``` [Try it online!](https://tio.run/##Sy7WTS7O/O9Wmpds4@maV5qbWpSYlJNqk5yRWGSno4AhZJdm@7/Y1k5FSbE6uKQoMy9dzys/M09DSVFJp1izVlHpvzVXeFFmSapPZl6qRpqGUmZecWpRiUJSakl5amqekqam9X8A "C# (Visual C# Interactive Compiler) – Try It Online") [Answer] # Java 8, 20 bytes A lambda function from `String` to `String`. ``` s->s.replace("","!") ``` [Try It Online](https://tio.run/##PU/LasMwEDwrX7ERBCxwRN@HtPGxt55yLKVsFTnIlR941ymh@NtdyXIDgpFGszOzFZ5xWx2/p2748s6A8UgEb@ga@F2JhSRGDnBu3RHq8JUduHfN6f0DsD@RikpRBSM9sPO6HBrDrm3063J5SfIcEhZQwn6ibUG6t51HYzMpc7mWahLiOVhd3Q2SJdhDY3/gSsYwIW/hDu7hAR7hSeYzs8DNgmyJQ/E4NDNjdC7bHpbys/kn7FJI2kEcLsS21u3Augsi9v@r6jBZI2dyE/oUsCGZJ4McSo1d5y/Z/FRKxZxxFc44/QE) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 4 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` €'!Ć ``` I/O as a list of characters. [Try it online.](https://tio.run/##yy9OTMpM/f//UdMadcUjbf//RyslKukoKBWDiBQQoQAiwGJpICILROSDCG9U2WwQYQUiUkFETB5cMABEFIEIH7ipEGkFLATYFn8Q4QVnuYIIa/z6wM5xg2uBKEQIZsNdVgD3RjrcLwVwY4rhEgVwr@XDdWBzayJENhYA) **Explanation:** ``` €'! '# Prepend a "!"-item before each character in the (implicit) input-list Ć # Enclose (append the first character of the list at the end of it) # (after which the result is output implicitly) ``` [Answer] # [Triangular](https://github.com/aaronryank/triangular), ~~15~~ 13 bytes ``` B\3;#*~.,</@< ``` [Try it online!](https://tio.run/##KynKTMxLL81JLPr/3ynG2FpZq05Px0bfweb//8TiFIXEtKx8b4XEbKtUruyAIp8ULgUgSPP38ne1BjO93fy5vN2yUwuy0vMLFIrTCxLzs0AqErMA "Triangular – Try It Online") *-2 bytes after remembering that Triangular has a conditional halt operator.* I believe this is as short as it gets on this one. Triangular *does* have conditional direction-change operators, but they unfortunately work differently than the other conditionals. While all others check if ToS <= 0, the direction-changing conditionals check ToS != 0. If this weren't the case, we would have 10 bytes in the form of `Bq3~#*/@<<`. Ungolfed: ``` B \ 3 ; # * ~ . , < / @ < ---------------------------------------------------- B3* - Push 11 and 3, then pop both and push their product. <,< - Change directions 3 times (to save 2 bytes on last line) @/ - Print Top of Stack value as a character, do not pop ~;\ - Push a character from input to ToS. Halt if ToS <= 0. Change Direction. # - Print ToS as a character and pop ``` --- **Previous Version (15 bytes):** ``` B.3\.*#).(/?~@< ``` [Answer] # [><>](https://esolangs.org/wiki/Fish), ~~11~~ 6 bytes ``` "!"oio ``` [Try it online!](https://tio.run/##S8sszvj/X0lRKT8z//9/QwUjBWMFEwVTBTMA "><> – Try It Online") Saved 5 bytes thanks to Jo King, suggesting exiting with an error. Previous version which does not exit with an error: ``` "!"oi:0(?;o ``` [Try it online!](https://tio.run/##S8sszvj/X0lRKT/TykDD3jr//39DBSMFYwUTBVMFMwA "><> – Try It Online") [Answer] # [SimpleTemplate](https://github.com/ismael-miguel/SimpleTemplate), 23 bytes This is a language I wrote, and it was supposed to be for templates, but well. ``` !{@eachargv.0}{@echo_}! ``` Should be almost self-explanatory, once you see the ungolfed code: ``` !{@each argv.0 as char} {@echo char}!{@/} ``` And an explanation: * `!` - Prints the literal `!` character * `{@each argv.0 as char}` - Loops through every character, with the value set to the variable `char` (**optional**, the default variable is `_`). `argv.0` is the first parameter passed to the `render()` method of the compiler. * `{@echo char}!` - outputs the `char` variable and a literal `!` character. For the golfed version, the default variable `_` is used instead. * `{@/}` - closes the loop (**optional**) --- Pure **SimpleTemplate** solution: ``` {@fn x}!{@eachargv.0}{@echo_}!{@/}{@/} ``` Creates a function `x` that outputs the same result. You can use it like this: ``` {@call x "this is an example"} ``` You can try all of this on: <http://sandbox.onlinephpfunctions.com/code/f6baff8d411fc8227ece81eccf05b6e7d3586bfa> On the line 908, you can use the variables `$golfed`, `$ungolfed` and `$fn` to test all the versions. --- --- However, if it is allowed to use a character array, the code is simplified (20 bytes): ``` !{@echoj"!" argv.0}! ``` And ungolfed: ``` !{@echo separator "!" argv.0}! ``` Basically, outputs all items in the array, joined by `"!"`, surrounded by literal `!`. Due to limitations in the compiler class, the space is mandatory (in the golfed version). This code is also extremelly harder to use in pure **SimpleTemplate** (using the function as example): ``` {@fn x}!{@echoj"!" argv.0}!{@/} {@// alternative: @call str_split into a "a char array"} {@set a "a", " ", "c", "h", "a", "r", " ", "a", "r", "r", "a", "y"} {@call x a} ``` The `@call` can call a function that exists in PHP, which means that it isn't a pure **SimpleTemplate** solution. [Answer] # [Bash](https://www.gnu.org/software/bash/), 36 bytes ``` while read -n1 c;do printf \!$c;done ``` [Try it online!](https://tio.run/##S0oszvj/vzwjMydVoSg1MUVBN89QIdk6JV@hoCgzryRNIUZRBcTNS/3/PyQjs1gBiBIVSlKLSxQy8wpKS/S4AA "Bash – Try It Online") This counts on the newline terminating the input for the last ! mark. [Answer] # [Ruby](https://www.ruby-lang.org/), ~~17~~ 16 bytes ``` ->s{s.gsub'',?!} ``` [Try it online!](https://tio.run/##KypNqvyfZvtf1664ulgvvbg0SV1dx16x9n9BaUmxQlq0kmdecWpRiUJSakl5amqeUiwXVMLGpqKiIpbLUMFIwVjBRMFUwYzL0MjS1NJQAUgZGBqBKEMjcxBlamHExWXABVT/HwA "Ruby – Try It Online") Thanks Value Ink for -1 byte ]
[Question] [ Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: ``` F u l l w i d t h t e x t i s t e x t t h a t h a s a s p a c e a f t e r e v e r y c h a r a c t e r , i n c l u d i n g t h e l a s t o n e . ``` Write a program that takes a line in text from standard input and outputs it as full-width text to standard out. ## Leaderboard ``` var QUESTION_ID=75979,OVERRIDE_USER=52353;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] # [Jelly](http://github.com/DennisMitchell/jelly), ~~5~~ ~~3~~ 2 bytes Thanks to *Dennis* for saving 2 bytes. Also thanks to *FryAmTheEggman* for saving 1 byte. Code: ``` p⁶ ``` Explanation: ``` p⁶ # Cartesian product with the input and the space character. ``` Uses the [Jelly encoding](https://github.com/DennisMitchell/jellylanguage/wiki/Code-page). [Try it online!](http://jelly.tryitonline.net/#code=cOKBtg&input=&args=RnVsbCB3aWR0aCB0ZXh0IGlzIHRleHQgdGhhdCBoYXMgYSBzcGFjZSBhZnRlciBldmVyeSBjaGFyYWN0ZXIsIGluY2x1ZGluZyB0aGUgbGFzdCBvbmUu) [Answer] # Python 3.5, 18 bytes ``` print(*input(),'') ``` This works because [`print`](https://docs.python.org/dev/library/functions.html#print)'s default separator is single space. [Answer] # [Hexagony](http://github.com/mbuettner/hexagony), ~~21~~ ~~13~~ ~~12~~ 10 bytes **Code:** Saved a *lot* of bytes thanks to *FryAmTheEggman*. Code: ``` P,<0/*;@.> ``` Or in a more readable form: ``` P , < 0 / * ; @ . > . . . . . . . . . ``` [Try it online!](http://hexagony.tryitonline.net/#code=UCw8MC8qO0AuPg&input=RnVsbCB3aWR0aCB0ZXh0IGlzIHRleHQgdGhhdCBoYXMgYSBzcGFjZSBhZnRlciBldmVyeSBjaGFyYWN0ZXIsIGluY2x1ZGluZyB0aGUgbGFzdCBvbmUu) **Explanation:** The Hexagony program starts at the top-left corner, immediately setting the memory edge to the ASCII value of `P`, which is 80. After that, we can see that the following path is taken: [![enter image description here](https://i.stack.imgur.com/Ci09y.gif)](https://i.stack.imgur.com/Ci09y.gif) We can see that the path taken is: `P,<;.P/0....;*/>`. After the `P`, we take a byte of user input. If this is empty, the following branch (`<`) would direct us to the North East. If the input is non-empty, the branch directs us to the South East. After that, we output the user input using `;`. We set the memory edge back to `P`, which is 80. The zero followed by the mirror is then concatenated to our number, resulting into 800. This is then outputted using the `;` command, but first it is taken modulo 256, resulting into 32, which is the space character. After that, we reset the memory edge using the `*` command and return to loop over the rest of the user input. When we're done with the user input, the path is directed to the North East: [![enter image description here](https://i.stack.imgur.com/jXv7Q.png)](https://i.stack.imgur.com/jXv7Q.png) This basically goes to the `@` command, which terminates the program. Using [Timwi](https://codegolf.stackexchange.com/users/668/timwi)'s amazing [*HexagonyColorer*](https://github.com/Timwi/HexagonyColorer) for making the diagrams. [Answer] ## Haskell, 11 bytes ``` ((:" ")=<<) ``` Usage example: `((:" ")=<<) "Code Golf"` -> `"C o d e G o l f "`. Map each character `c` to a two element list `[c, space]` and concatenate everything into a single list. [Answer] # [Retina](https://github.com/mbuettner/retina), 5 ``` . $& ``` Note the space at the end of the second line. `$&` is equivalent to `$0`. Thanks to @mbomb007 for [this link](https://msdn.microsoft.com/en-us/library/ewy2t5e0(v=vs.110).aspx#EntireMatch). [Try it online.](http://retina.tryitonline.net/#code=LgokJiA&input=RnVsbCB3aWR0aCB0ZXh0IGlzIHRleHQgdGhhdCBoYXMgYSBzcGFjZSBhZnRlciBldmVyeSBjaGFyYWN0ZXIsIGluY2x1ZGluZyB0aGUgbGFzdCBvbmUu) [Answer] # JavaScript, 20 Bytes Simple, I just wish that Array.join added the space to the end so I could save 3 bytes. ``` s=>[...s,``].join` ` ``` [Answer] # Awk, 7 bytes (4 characters code + 3 characters command line option.) ``` NF++ ``` Sample run: ``` bash-4.3$ awk -F '' 'NF++' <<< 'Full width text.' F u l l w i d t h t e x t . ``` (There is some disagreement on what should be included in the command line option count. I included what is actually passed to the `awk` interpreter: “-”, “F” and a separator between “F” and the empty string parameter. See below what I mean.) ``` bash-4.3$ od -tax1 /proc/`pidof awk`/cmdline 0000000 a w k nul - F nul nul N F + + nul 61 77 6b 00 2d 46 00 00 4e 46 2b 2b 00 ╰────────╯ ``` [Answer] # [><>](https://esolangs.org/wiki/Fish), ~~13~~ 10 bytes *3 bytes saved thanks to @Sp3000* ``` i:0(?;o 'o ``` [**Try it here**](https://fishlanguage.com/playground/RfSiCr7a5R6wPcPTk). Click the link, then *Submit*, then type some input and press *Give*, and finally run the program with *Start* or *Run without animation*. ### Explanation ``` i read a character : duplicate 0( is it less than 0? ?; if so: end program. Else: o output read character ' push all chars until matching (same) quote. Top character is a space o output that character, which is a space. Go back to the beginning ``` [Answer] ## Java, 132 (System.in) or 99 (Program argument) bytes Can you feel the overhead tonight? ``` class F{public static void main(String[]a){System.out.print(new java.util.Scanner(System.in).nextLine().replaceAll("(.)", "$0 "));}} class W{public static void main(String[]a){for(char c:a[0].toCharArray())System.out.print(c+" ");}} ``` [shooqie](https://codegolf.stackexchange.com/users/51530/shooqie) figured out [a 6 byte shorter way to do this](https://codegolf.stackexchange.com/a/76010/51825) but I won't steal their approach. I've used it with the STDIN and lambda versions, however. 28 characters for a lambda but that doesn't meet the program requirement. ``` s->s.replaceAll("(.)","$0 ") ``` [Answer] # Java, 92 ``` class T{public static void main(String[]A){System.out.print(A[0].replaceAll("(.)","$0 "));}} ``` [Answer] # [Cubix](https://github.com/ETHproductions/cubix), 10 bytes Cubix is a 2 dimensional language developed by @ETHproductions where the commands are wrapped onto a cube. [Try it online](https://ethproductions.github.io/cubix) ``` @.?wi^\oSo ``` This maps onto a cube with edge length 2 ``` @ . ? w i ^ \ o S o . . . . . . . . . . . . . . ``` Starts with a input `i`. The flow is redirected north `^` to the top face. `?` If the value is negative turn left to finish `@`, zero carries on into shift right `w` or positive turn right then reflect left `\`. Output character with a trailing space `oSo`. [Answer] # [Cubix](https://github.com/ETHproductions/cubix/), 9 bytes ``` @./.i?>So ``` [**See it work online!**](http://ethproductions.github.io/cubix/?code=ICAgIEAgLgogICAgLyAuCmkgPyA+IFMgbyAuIC4gLgouIC4gLiAuIC4gLiAuIC4KICAgIC4gLgogICAgLiAuCg==&input=Q3ViaXg=&speed=20) Cubix is a language in which the instructions are mapped out onto the face of a cube. This program forms the following cube net: ``` @ . / . i ? > S o . . . . . . . . . . . . . . . ``` The instruction pointer begins at `i`, which takes another character-code from input and pushes it to the stack. If there is no more input left to be taken, the `?` turns the IP left, where it hits `/`, and is reflected upwards to `@`, which terminates the program. However, if there is input left, the value will be a character code. As all1 character codes are positive, the `?` makes the IP turn right, where it wraps all the way around the cube, passing `o` on the way which outputs the char. It then hits `/` which makes it loop back around to `>So`, which pushes and prints a space. The IP carries on west until wrapping around back to the `i`, back to the start of the main loop. 1 *If the character is a null byte, it will ignore the `?` and carry on straight ahead, simply outputting a single space.* --- Of course, there's only so much a written explanation can do, so I highly recommend you view this in the [online interpreter](http://ethproductions.github.io/cubix/?code=ICAgIEAgLgogICAgLyAuCmkgPyA+IFMgbyAuIC4gLgouIC4gLiAuIC4gLiAuIC4KICAgIC4gLgogICAgLiAuCg==&input=Q3ViaXg=&speed=20). There's a "speed" option, which allows you to view the execution as slow or fast as you like. [Answer] # [Stax](https://github.com/tomtheisen/stax), 2 bytes Ties Jelly! ``` 0\ ``` [Try it at staxlang.xyz!](https://staxlang.xyz/#c=0%5C&i=Full+width+text+is+text+that+has+a+space+after+every+character%2C+including+the+last+one.) All this does is push `0` to the stack and zip the string from standard input with it, repeating the 0 as necessary. In Stax, code point 0 in a string is usually converted to 32 (space). This is short enough that packing it into `ûT` does nothing but reduce readability. [Answer] # 05AB1E, 4 bytes ``` Sð«J ``` [Try it online.](http://05ab1e.tryitonline.net/#code=U8OwwqtK&input=dGVzdA) ## Explanation ``` Sð«J S split string into a list ð« append a space to each element J join ``` [Answer] # [CJam](https://sourceforge.net/p/cjam/wiki/Home/), ~~5~~ 4 bytes *1 byte fewer thanks to @FryAmTheEggman* ``` lSf+ ``` [**Try it online!**](http://cjam.tryitonline.net/#code=bFNmKw&input=VGhpcyBpcyBhIHRlc3Q) ### Explanation ``` l e# read line Sf+ e# map "concatenation" (+) with a space (S) as extra parameter e# implicitly display characters in the stack ``` [Answer] # GolfScript, 6 bytes ``` ' ':n* ``` [Try it online!](http://golfscript.tryitonline.net/#code=JyAnOm4q&input=RnVsbCB3aWR0aCB0ZXh0IGlzIHRleHQgdGhhdCBoYXMgYSBzcGFjZSBhZnRlciBldmVyeSBjaGFyYWN0ZXIsIGluY2x1ZGluZyB0aGUgbGFzdCBvbmUu) [Answer] ### PHP, 39 bytes ``` echo join(' ',str_split($argv[1])).' '; ``` Run it from the command line ``` php fullwidth.php "Full width text is text that has a space after every character, including the last one." ``` <https://eval.in/541179> [Answer] # Pyth, ~~5~~ 4 bytes *Thanks to @FryAmTheEggman for saving a byte.* ``` s*zd ``` [Try it online here](http://pyth.herokuapp.com/?code=%2Bjdzd&input=Full+width+text+is+text+that+has+a+space+after+every+character%2C+including+the+last+one.&debug=0). [Answer] # [WhoScript](http://esolangs.org/wiki/WhoScript) 38 bytes ``` 1v;pr;e;#0 1;-;i;t=;ti;o;tl;" ";d;>;pf ``` Works best when the string is given at the command line, but it can be done one character at a time in real time as well. Ungolfed: ``` time_vortex psychic_paper read duplicate # 0 1 - integer TARDIS = TARDIS if opening TARDIS landing # 20 paradox pop psychic_paper flush ``` [Answer] ## [Labyrinth](https://github.com/mbuettner/labyrinth/), 10 bytes ``` <.23.%):,> ``` This terminates with an error, but the error messages goes to STDERR. [Try it online!](http://labyrinth.tryitonline.net/#code=PC4yMy4lKTosPg&input=RnVsbCB3aWR0aCB0ZXh0) ### Explanation This is one of the rare cases where a completely linear program is feasible. The loop is achieved via the source code modification commands `<` and `>`, which works because after each iteration we know that the stack is empty again. `<` cyclically shifts the entire line one cell to the left, so we end up with: ``` .23.%):,>< ``` This takes the instruction pointer (IP) with it so the IP is now at the right end of the code and has to move left. Next, the `>` does the opposite modification so it shifts the source code back to ``` <.23.%):,> ``` Now we execute a single iteration (from right to left), before everything starts over: ``` , Read a character code from STDIN, or -1 at EOF. :) Duplicate and increment. % Modulo. At EOF this will attempt a division by zero and terminate. Otherwise, we have n % (n+1) = n, so we're left with the input character again. . Print it back to STDOUT. 32 Turn the top of the stack into a 32. . Print it as well (a space). ``` [Answer] # [Gema](http://gema.sourceforge.net/), 5 bytes ``` ?=?\ ``` Sample run: ``` bash-4.3$ gema '?=?\ ' <<< 'Full width text.' F u l l w i d t h t e x t . ``` [Answer] # [MATL](https://esolangs.org/wiki/MATL), 7 bytes ``` tnZ"v1e ``` [**Try it online!**](http://matl.tryitonline.net/#code=dG5aInYxZQ&input=J1RoaXMgaXMgYSB0ZXN0Jw) ### Explanation ``` t % implicitly take input string and duplicate it n % number of elements Z" % string with that many spaces v % concatenate vertically (2xN array, where N is input length) 1e % reshape into 1 row. Implicitly display ``` [Answer] ## APL, 5 bytes ``` ∊2∘↑¨ ``` This takes 2 items for each character in the string, with the effect of adding a space To make it a program that takes stdin, it's the same number of bytes: ``` ∊2↑¨⎕ ``` Try it [here](http://tryapl.org/?a=f%u2190%u220A2%u2218%u2191%A8%20%u22C4%20f%20%27Hello%20World%21%27&run). [Answer] # brainfuck, ~~24~~ 22 bytes Simple example using the [shortest known 32](https://esolangs.org/wiki/Brainfuck_constants#32) for the space character(s). ``` ,[.>>-[-[-<]>>+<]>-.,] ``` [**Try it online**](http://brainfuck.tryitonline.net/#code=LFsuPj4tWy1bLTxdPj4rPF0-LS4sXQ&input=VGVzdA) [Answer] # PHP, 31 bytes ``` <?=chunk_split($argv[1],1," "); ``` takes input from command line argument. [Answer] # [Threead](https://github.com/TehFlaminTaco/Threead), ~~45~~ 16 Bytes non-competing. ``` B[coB] 32c o ``` Takes input via STDIN. The first Line/Tape simply reads bytes from STDIN, and writes them. The second line, initially stores a space via `32c`, then at the same time that the next character is being read, outputs that space. [Try it online!](https://tio.run/nexus/threead#@6@g4BSdnO8Uy2VslKygoJD//7@jk7MLAA "Threead – TIO Nexus") [Answer] # Python 2, ~~27~~ ~~25~~ 24 bytes ``` lambda x:' '.join(x)+' ' ``` Shorter than Raffi's answer... *-1 thanks to 60919 (FlipTack).* [Answer] # C, 50 bytes Little bit of `main()` recursion :) ``` main(c){~(c=getchar())?printf("%c ",c),main():0;} ``` [Try it online!](http://ideone.com/xM3xVg) - If using this on your own machine, use `Ctrl`+`D` to signify EOF. [Answer] # C, 56 Bytes (as program argument), 46 Bytes (from stdin) ``` main(int a,char**b){while(*b[1])printf("%c ",*b[1]++);} ``` Plain old C answer. Once compiled, the program needs to be called with a string as it's first parameter, a string with spaces needs to be enclosed in quotes. For the example in the start post: ``` ./prog "Full width text is text that has a space after every character, including the last one." ``` Which will output ``` F u l l w i d t h t e x t i s t e x t t h a t h a s a s p a c e a f t e r e v e r y c h a r a c t e r , i n c l u d i n g t h e l a s t o n e . ``` Solution that reads directly from stdin. ``` main(c){while(c=~getchar())printf("%c ",~c);} ``` One byte less thanks to @FryAmTheEggman [Answer] # R, 36 bytes ``` cat(strsplit(readline(),"")[[1]],"") ``` Example: ``` > cat(strsplit(readline(),"")[[1]],"") Hello R! H e l l o R ! ``` ]
[Question] [ This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not. Your input will have no newlines or trailing spaces: ``` 1954 ``` You will output in any way that you like that clearly tells the user if it is or isn't a leap year (I will accept y or n for yes/no) You can get a list of leap years here: <http://kalender-365.de/leap-years.php> I would note that leap years are not ever four years always. 1896 is a leap year, but 1900 is not. The years that follow this "skip" are: ``` 1900 2100 2200 2300 ``` Test cases: ``` 1936 -> y 1805 -> n 1900 -> n 2272 -> y 2400 -> y ``` EDIT: This is based on a standard Gregorian calendar: <http://www.epochconverter.com/date-and-time/daynumbers-by-year.php> ## The Catalogue The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` ## Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` ## Ruby, <s>104</s> <s>101</s> 96 bytes ``` If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header: ``` ## Perl, 43 + 2 (-p flag) = 45 bytes ``` You can also make the language name a link which will then show up in the snippet: ``` ## [><>](https://esolangs.org/wiki/Fish), 121 bytes ``` ``` /* Configuration */ var QUESTION_ID = 50798; // Obtain this from the url // It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 8478; // This should be the user ID of the challenge author. /* App */ var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang, user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw.toLowerCase() > b.lang_raw.toLowerCase()) return 1; if (a.lang_raw.toLowerCase() < b.lang_raw.toLowerCase()) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } } ``` ``` body { text-align: left !important; display: block !important; } #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 500px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; } ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/all.css?v=ffb5d0584c5f"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> ``` [Answer] # APL, ~~16~~ ~~14~~ 12 characters Returns `0` for a leap year, `1` for a non-leap year. ``` ≥/⌽×4 25 4⊤⎕ ``` Try this solution on [tryapl.org](http://tryapl.org/?a=%u2191%28%u22A2%2C%7B%u2265/%u233D%D74%2025%204%u22A4%u2375%7D%29%A81990+%u237320&run). Note that I have changed the solution to the dfn `{≥/⌽×4 25 4⊤⍵}` as tryapl.com does not support `⎕` (take user input). Note that `⎕` is an empty box, not a missing character. The same solution in J: ``` 4 25 4>:/@|.@:*@#:] ``` ## Explanation Dyadic `⊤` (encode) represents its right argument in the base specified by its left argument. I use base `4 25 4` in this solution. This represents the year *y* as a polynomial > > *y* mod 400 = 100 *a* + 4 *b* + *c* where *b* < 100 and *c* < 4. > > > Let propositions *α, β,* and *γ* represent if *a,* *b,* and *c* are non-zero: Proposition *γ* is false if *y* is dividable by 4, *β* ∧ *γ* is false if *y* is dividable by 100 and *α* ∧ *β* ∧ *γ* is false if *y* is dividable by 400. A truth table (`*` representing “don't care”) were proposition Δ represents if *y* is a leap-year obtains: ``` α β γ | Δ 0 0 0 | 1 1 0 0 | 0 * 1 0 | 1 * * 1 | 0 ``` The following statement expresses Δ in *α*, *β*, and *γ*: > > Δ = ¬((*α* → *β*) → *γ*)). > > > Due to the structure of this statement, one can express ¬Δ as the reduction `≥/⌽α β γ` where ≥ implements ←. This leads to the answer I am explaining right now. [Answer] # Javascript (ES6), 21 characters The standard rule is that `y` is a leap year if 4 divides `y` and if either 100 doesn't divide `y` or 400 does divide `y`. In code, ``` y%4 == 0 && (y%100 != 0 || y%400 == 0) ``` There's no need for that 100 and 400. Instead it suffices to check whether 16 or 4 divides y, with 16 chosen if 25 divides y, 4 otherwise. Golfed, this becomes ``` !(y%(y%25?4:16)) ``` A javascript function that implements this is 21 characters long: ``` l=y=>!(y%(y%25?4:16)) ``` # Perl, 28 26 characters Same idea, but in perl. ``` $_=$_%($_%25?4:16)?"n":"y" ``` Run using the `-lp` options. For example, ``` perl -lpe '$_=$_%($_%25?4:16)?"n":"y"' ``` With the test set as input, this produces ``` 1936 y 1805 n 1900 n 2272 y 2400 y ``` [Answer] # Pyth, 11 bytes ``` !%|F_jQ*TT4 ``` This full program read from STDIN and prints *True* for leap years and *False* otherwise. *Thanks to @Jakube for suggesting Pyth and basically porting my CJam code.* Verify the test cases yourself in the [Pyth Compiler/Executor](https://pyth.herokuapp.com/?code=m!%25%7CF_jd*TT4.Q&input=1936%0A1805%0A1900%0A2000%0A2100%0A2272%0A2400&debug=0). ### How it works ``` jQ*TT Returns the evaluated input in base 10 × 10. |F_ Swaps the digit order and reduces using logical OR. So far, we've achieved 1954 -> [19, 54] -> 54 || 19. !% 4 Returns the logical NOT of the result modulo 4. This prints True for multiples of 4 and False otherwise. ``` [Answer] # CJam, 12 bytes ``` rS+2m<~e|4%! ``` This full program read from STDIN and prints 1 for leap years and 0 otherwise. Verify the test cases yourself in the [CJam interpreter](http://cjam.aditsu.net/#code=r%7B%3B%0ArS%2B2m%3C~e%7C4%25!%0Ar%7Dh&input=y%201936%0An%201805%0An%201900%0Ay%202000%0An%202100%0Ay%202272%0Ay%202400). ### How it works ``` r e# Read from STDIN. S+ e# Append a space. 2m< e# Rotate two characters to the left. ~ e# Evaluate. e# So far, we achieved "1954" -> "54 19" -> 54 19. e| e# Logical OR; keep the leftmost non-zero integer. 4%! e# Logical NOT of the kept integer modulo 4. e# This pushes 1 for multiples of 4 and 0 otherwise. ``` [Answer] # TI-BASIC, ~~20 17 16~~ 13 ~~Because it is tokenized, TI-BASIC is often competitive at simple math challenges, but not this one since there is no "divisible" command.~~ Maybe it is after all, but this is still longer than CJam and Pyth. This uses David Hammond's method. ``` not(fPart(Ans/4/4^not(fPart(sub(Ans ``` Old code at 16 bytes: ``` not(fPart(Ans/16not(fPart(sub(Ansnot(fPart(Ans/4 ``` Ungolfed: ``` not(fPart(Ans/16) and not(fPart(Ans/100) and not(fPart(Ans/4)))) ``` `fPart(` is "fractional part"; exponentiation has higher precedence than division. In TI-BASIC, close-parens are optional. I use undocumented behavior of the `sub(` command, usually used to get a substring: when its argument is a number instead of a string, it divides the number by 100. It will work on a TI-83 or 84 series calculator. 20 -> 17 by rearranging code to allow removal of close-parens; 17 -> 16 by replacing 400 with 16; 16 -> 13 by using David Hammond's idea. [Answer] # Pyth, ~~19~~ ~~15~~ 14 bytes ``` xFm!%Q^d2[2TyT ``` Way too easy. Try it online: [Demonstration](https://pyth.herokuapp.com/?code=xFm!%25Q%5Ed2%5B2TyT&input=1900&debug=0) or [Test harness](https://pyth.herokuapp.com/?code=QFQ.Qp%22+-%3E+%22Q%0AxFm!%25Q%5Ed2%5B2TyT&input=%22Test+Cases%3A%22%0A1936%0A1805%0A1900%0A2272%0A2400&debug=0) edit: Missed, that you can print Truthy/Falsy values, instead of `n/y`. -4 byte edit 2: Used the square root idea of Martin. -1 byte ### Explanation ``` implicit: Q = input number [ generate a list with the numbers: 2 2 T 10 yT 2*10 = 20 m map each number d to: !%Q^d2 not(Q mod d^2) // True if Q % d^2 == 0 otherwise False xF fold by xor ``` [Answer] ## Regex, ~~83~~ ~~62~~ 38 Thanks to Toby for tips about combining both halves of the regex. If we focus on 1801..2400 range only and assume input are integers: ``` (?!00)([02468][048]|[13579][26])(00)?$ ``` Test in Ruby (`^` = `\A` and `$` = `\Z` because Ruby) for the desired range: ``` r = /(?!00)([02468][048]|[13579][26])(00)?\Z/ (1801..2401).each do |year| leap = year % 4 == 0 && ((year % 100 != 0) || (year % 400 == 0)) leap_regex = !year.to_s[r].nil? if leap != leap_regex print 'Assertion broken:', year, " ", leap, " ", leap_regex, "\n" end end ``` --- (Bonus) for something that should work not only for 1801..2400, but for any non-negative year: ``` ^\d*(0000|(?!00)([13579][26]|(^|[02468])[048])(00)?)$ ``` Test in Ruby (`^` = `\A` and `$` = `\Z` because Ruby) for first 100000 years: ``` r = /\A\d*(0000|(?!00)([13579][26]|(\A|[02468])[048])(00)?)\Z/ 100000.times do |year| leap = year % 4 == 0 && ((year % 100 != 0) || (year % 400 == 0)) leap_regex = !year.to_s[r].nil? if leap != leap_regex print 'Assertion broken:', year, " ", leap, " ", leap_regex, "\n" end end ``` [Answer] # [Pip](http://github.com/dloscutoff/pip), 13 bytes This one was more interesting than it at first appeared. It took some finagling, but I was finally able to replace those lengthy references to `400` with `4` and the `h` variable (=100). ``` !(a%h?aa/h)%4 ``` Outputs `1` for leap year, `0` for non-leap year. Explanation: ``` a is command-line argument (implicit) a%h?aa/h If a is divisible by 100, divide it by 100; otherwise, leave it alone ( )%4 The result mod 4 is 0 if it's a leap year, nonzero otherwise ! Negate and (implicitly) print ``` [Answer] # JavaScript (*ES6*) 27 The rule: `(y%4==0) && (y%100!=0 || y%400==0)` Golfed: `!(y%100<1&&y%400||y%4)` (mainly using [De Morgans's law](http://en.wikipedia.org/wiki/De_Morgan%27s_laws)) A function implementing the rule: ``` l=y=>!(y%100<1&&y%400||y%4) ``` A test (run in Firefox) just to be sure: ``` l=y=>!(y%100<1&&y%400||y%4) for(o=[],i=0;i<700;i++) y=i+1800, x=l(y), o[i/100|0]=(o[i/100|0]||'')+y+(x?' <b>Y</b>':' <i>N</i>')+'\n' R.innerHTML='<td>'+o.join('</td><td>')+'</td>' console.log(o[1]) ``` ``` td { white-space: pre; font-family: monospace; padding: 8px} b { color: red; } i { color: blue; } ``` ``` <table> <tr id=R></tr> </table> ``` [Answer] # Haskell, 19 bytes ``` f i=gcd 80i>gcd 50i ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/P00h0zY9OUXBwiDTDkSbGmT@z03MzFOwVchNLPBVKCgtCS4p8slTiC7OyC/XqNRU0NZWUFLQtQMSQBZYME0BKFyjUKlgo6sQbWhhYKCnZ2RiYBAb@x8A "Haskell – Try It Online") [Answer] # Stackylogic, 226 bytes Yes, that is right. I made a program in Stackylogic (non-TC), which was invented by Helka Homba, for the challenge found [here](https://codegolf.stackexchange.com/questions/84851/run-stackylogic "here"). Stackylogic has only binary input, so 10 (or more, any more digits will be ignored) bit binary must be used (least significant bit inputted first). Any dates outside the specified range might fail, as it simply checks what the inputted number is: it doesn't cover unnecessary dates Not only is this my first challenge with stackylogic, but the first challenge with stackylogic at all. Get ready for this mess: ``` 1 0 1? 010 1?0 010 1?10 ?1010 001010 ?1010 ?1010 ?010 ?10 ?0 0 ? 110 ?10 11010 ?010 11010 ?1010 001010 ?1010 ?1010 ?1010 ?1010 ?010 ?0 110 ?10 11010 ?010 1010 01010 01010 ?010 ?0 110 ?0 110 ?0 110 1?0 ?10 0?10 ?10 ?0 01 ? ?< 0 ``` This took me so long to make, because Stackylogic is the most confusing language I have encountered, and extremely unreadable: you have to know how the rest of the program has executed before you can read the current section being edited. I even had to add spaces for readability while creating it. ## Meagre explanation This is a simple explanation of what it does. Stackylogic does not have any mathematical functions, so that made this harder. I had to hardcode most of it, to check if it was a specific number. First, this program will do a NOR of the least significant bits, discarding them in the process. this means that if it is divisible by 4, it will proceed to the main part of the program, otherwise output 0. Second, the pointer is carried over to the labyrinth of stackylogic, from here, if the next two bits are zero, it will instantly output 1 (as then it is divisible by 16, and so a leap year despite any other conditions), other wise it will check if it is not any of the numbers that is divisible by 4 but not a leap year, between 1801 and 2400. To explain in detail, would involve making this post many times longer than it already is [Answer] ## IBM System Z assembler - 56 bytes. ## (96 bytes of source. Previously ~~712~~ ~~384~~ 202 bytes of source, 168 byte executable). Smaller version still. No longer saves caller's registers, changes to literal storage, changed addressing mode. ``` l CSECT using l,15 l 5,y n 5,f bnz r xr 4,4 l 5,y d 4,c ch 4,i bne i n 5,f bnz r i dc h'0' r b * y dc f'2004' f dc f'3' c dc f'100' end ``` New version. This will ABEND with a S0C1 if it's a leap year, and loop if it isn't. Hopefully that fulfils the requirement of indicating the result. ``` l CSECT ASMDREG SYSSTATE archlvl=2 IEABRCX DEFINE save (14,12) larl r9,s using s,r9 st 13,w+4 la 13,w st 13,w+8 la 5,2004 st 5,y n 5,=f'3' bnz r xr r4,r4 l 5,y d r4,=f'100' ch r4,=h'0' bne i n 5,=f'3' bnz r i dc h'0' r b 0 s dc 0d'0' y ds f w ds 18f ltorg end ``` OK, so not the shortest (although it might be once we look at the actual executed code plus the interpreter size...) ``` leapyear CSECT ASMDREG SYSSTATE archlvl=2 IEABRCX DEFINE save (14,12) larl r9,staticArea using staticArea,r9 st r13,w_savea+4 .Save callers savearea la r13,w_savea .Address my savearea st r13,w_savea+8 . and save it open (O,OUTPUT) .open file la r5,1936 .r5 = input year st r5,years .Save year cvd r5,double .Convert year to p-decimal mvc edarea,=xl8'4020202020202120' .Move in edit mask ed edarea,double+4 .Make packed decimal year printable mvc outrec(4),edarea+4 .Move year string to output area bas r10,isitleap .Call leap year routine close (O) .Close files b return .Branch to finish isitleap ds 0h mvi outrec+5,c'N' .Set default value n r5,=f'3' .Are last 2 bits 0 (Divisible by 4)? bnz notleap .No - not leap xr r4,r4 .Clear R4 l r5,years .Reload r5 with year d r4,=f'100' .divide r4/r5 pair by 100 ch r4,=h'0' .Remainder 0? bne isleap .No - leap year n r5,=f'3' .Quotient divisible by 4? bnz notleap .No - not leap isleap ds 0h mvi outrec+5,c'Y' .Move in leap year indicator notleap ds 0h put O,outrec .Print output record br r10 .Return to caller * Program termination return ds 0h l r13,w_savea+4 .Restore callers savearea return (14,12),,rc=0 .Restore registers and return * storage areas staticarea dc 0d'0' outrec ds cl10 years ds f w_savea ds 18f save area edarea ds cl8 .edit area double ds d * Macros and literals print nogen O dcb recfm=F,lrecl=6,dsorg=PS,ddname=O,macrf=PM print gen * ltorg literal storage end ``` Output: ABEND S0C1 for a leap year, S222 (when the CPU time has run out) if not. ~~1936 Y 1805 N 1900 N 2272 Y 2400 Y~~ (when run multiple times) [Answer] # CJam, ~~18~~ 16 bytes ``` q~[YAK]f{2#%!}:^ ``` Gives `1` (truthy) for leap years and `0` (falsy) otherwise. [Run all test cases here.](http://cjam.aditsu.net/#code=qN%2F%7BS%2F0%3D%3AQ%3B%0A%0AQ~%5BYAK%5Df%7B2%23%25!%7D%3A%5E%0A%0A%5DoNo%7D%2F&input=1936%20-%3E%20%20y%0A1805%20-%3E%20%20n%0A1900%20-%3E%20%20n%0A2000%20-%3E%20%20y%0A2100%20-%3E%20%20n%0A2272%20-%3E%20%20y%0A2400%20-%3E%20%20y%20) ## Explanation ``` q~ e# Read and eval input. [YAK] e# Push an array containing 2, 10, 20 (the square roots of the e# relevant divisors). f{ } e# Map this block onto that array, also passing in the input year. 2# e# Square the divisor. %! e# Modulo followed by logical negation. Gives 1 if the year is divisible e# by the given divisor and 0 otherwise. e# At this point we have one of the following arrays: e# [0 0 0] - not a leap year e# [1 0 0] - a leap year e# [1 1 0] - not a leap year e# [1 1 1] - a leap year :^ e# Reduce XOR onto this array, which gives 1 if there is an odd number e# of 1s and 0 if there's an even number. ``` [Answer] # R, 29 ``` !(Y=scan())%%4&Y%%100|!Y%%400 ``` Test run ``` > !(Y=scan())%%4&Y%%100|!Y%%400 1: 1936 2: 1805 3: 1900 4: 2272 5: 2400 6: 2200 7: Read 6 items [1] TRUE FALSE FALSE TRUE TRUE FALSE ``` [Answer] # Mathematica, ~~40~~ 27 bytes, 17 chars ``` #∣4∧(#∣100<U+F523>#∣400) ``` Uses 17 chars, but 27 bytes. Thanks to @alephalpha for the tip. Note that the vertical bars are actually U+2223 for divides. The `<U+F523>` should be replaced with the corresponding character. [Answer] # sed, 55 ``` s/00$// y/0123456789/yNnNyNnNyN/ /N.$/y/ny/yn/ s/.\B//g ``` * First line divides exact centuries by 100. * Second line gives 'N' to odd digits, 'y' to 4s, and 'n' to non-4s. * Third line swaps 'y' and 'n' if there's an odd penultimate digit (because 10 is 2 mod 4) * Final line deletes all but the last character Note that non-leap years may be printed as `n` or `N` depending on whether they are even or odd. I consider this a creative interpretation of the rule which allows alternatives to 'yes' and 'no' without specifying that they have to be consistent. [Answer] # Julia, ~~30~~ 28 bytes ``` y->(y%4<1&&y%100>0)||y%400<1 ``` This creates an unnamed function that accepts an integer argument and returns a boolean value. To call it, give it a name, e.g. `f=y->...`. Ungolfed: ``` function f(y) (y % 4 == 0 && y % 100 != 0) || y % 400 == 0 end ``` Example: ``` julia> for y in [1936, 1805, 1900, 2272, 2400] println(f(y)) end true false false true true true ``` [Answer] # C, 81 I can do shorter, but this one neatly sticks to 'char' types, without parsing the argument (e.g. with `atoi`): ``` main(c,v)char**v;{char*p=*v+9;p-=2*(96==*p+p[1]);putchar("ynnn"[(2**p^p[1])&3]);} ``` It must be invoked with a name 4 characters long, because it makes the standard assumption that arguments immediately follow the program name, separated by NULs. Furthermore, it assumes that the single argument is encoded in ASCII and has no leading space. ### Explanation: ``` main(c,v) char**v; { char *p = *v+9; if (p[0] + p[1] == '0'+'0') p -= 2; putchar("ynnn"[((*p << 1) ^ p[1])&3]); } ``` `*v+9` is the position of the 'tens' digit in `v[1]+2`. If the 'tens' and 'units' characters add to 96, we end in `00`, so back up two characters, so that 'tens' and 'units' point to the century number. Now xor 'units' with twice the 'tens', mod 4. This works because `10==±2 mod 4`, so the lower bit of the 'tens' can just toggle bit 1 of the 'units'. We use the result as an index into our remainders table, printing `y` only if the modular result is zero. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes ``` ọ4,25>/ ``` [Try it online!](https://tio.run/##y0rNyan8///h7l4THSNTO/3/R/coHG5/1LRGwf3/f0NLYzMdBUMLA1MgaWlgoKNgZGRuBCRNDAwA "Jelly – Try It Online") ### How it works ``` ọ4,25>/ Main link. Argument: n (1801 - 2400) ọ4,25 Test how many times n is divisible by 4 and 25. >/ Verify that the order of 4 is higher than the order of 25. ``` [Answer] # Python2 - 37 bytes ``` g=lambda x:(x%4or x%400and x%100<1)<1 ``` Note that if `a` is a nonnegative integer, then `a<1` is a short way of writing `not bool(a)`. The last `<1` thus effectively converts the expression in the parentheses to a boolean and negates the result. Applying the function `g` to an integer `n` between 1801 and 2400 will return `True` if `n` is a leap year, and `False` otherwise. [Answer] # [Befunge](http://esolangs.org/wiki/Befunge)-98, (41 bytes) ``` &:4%#v_:aa*%#v_28*%| "y",;<;@,"n";>; ;#[ ``` Simplicity is awesome. [Answer] # Python, 37 bytes ``` def c(s):return s%16*(s%25<1)<(s%4<1) ``` [Answer] # C#, 23 bytes ``` y=>y%25<1?y%16<1:y%4<1; ``` **[Try it online!](http://ideone.com/d5Xxwb)** Full source, including test cases: ``` using System; namespace CountingLeapYears { class Program { static void Main(string[] args) { Func<int,bool>s=y=>y%25<1?y%16<1:y%4<1; Console.WriteLine(s(1936)); //y Console.WriteLine(s(1805)); //n Console.WriteLine(s(1900)); //n Console.WriteLine(s(2272)); //y Console.WriteLine(s(2400)); //y } } } ``` [Answer] # C, ~~37~~ ~~34~~ 30 bytes ``` l(y){y=y%(y%25?4:16)?110:121;} ``` [Wandbox](http://melpon.org/wandbox/permlink/Fvx8dtPJaRnlWpa2) [Answer] # Java 8, ~~49~~ ~~45~~ ~~22~~ 20 bytes ``` n->n%(n%25<1?16:4)<1 ``` -2 bytes thanks to *@OlivierGrégoire*. [Try it online.](https://tio.run/##hc2/DoIwEAbwnae4xaQMEIqAIqhPIAujcSgFTbEcBAqJMTw7Fv@MhuWSu@@X@0o2MKvM7xOXrOvgxAQ@DQCBqmivjBeQzCtAVteyYAic6AjQjPR1NPToFFOCQwIIe5jQOuCK4Mr1Y3qkwc4zYzpFs2v6TGr35UMtcqh0GUlVK/B2vgAzP03po1NFZde9shsdKYkEbU5ouA7Md@1/snX8JRI6zgJx3Y27RLzfl9EYpxc) Some **22 bytes solutions:** ``` n->n%25<1?n%16<1:n%4<1 ``` [Try it online.](https://tio.run/##hY27DoJAEEV7vmIaEigg7AoogvoF0lAai3VBswizBBYSY/h2XHyUhmaSO/fMnJINzCnz@8Qr1nVwZAKfBoBAVbRXxgtI5whwkbIqGAK3dAVox3o7Gnp0iinBIQWEHUzo7NGkQUIOaJIwIVs0/YRM8Uw2/aXS5PdgkCKHWuusTLUCb6czMPvjyh6dKmpX9sptdKUqtNDlFolWof0W/0c2XrCERJ63gFC6pkuI//syGuP0Ag) ``` n->(n%25<1?n%16:n%4)<1 ``` [Try it online.](https://tio.run/##hY27DoJAEEV7vmIakt0CAggogvoF0lAai3VBswgDYRcSY/h2XHyUhmaSO/fMnJINzCrz@8QrJiUcmcCnASBQFd2V8QLSOQJcmqYqGAInugKksd6Ohh5SMSU4pICwgwmtPUHTCxL3gKYbbtH0aeJO8Uy2/aXS5PdgaEQOtdaRTHUCb6czMPpxZQ@pitpuemW3ulIVErQ5caNVSN/i/8jGCZaQyHEWEM9be0uI//syGuP0Ag) ``` java.time.Year::isLeap ``` [Try it online.](https://tio.run/##hY3LDoIwEEX3fMUsy8IG8QnEP1A2rIxxMdRqiqUltJAYw7fX4mNp2Ewyc8/cU2GPs@pyd0yiMXBAoZ4BgFCWt1dkHPJxBSi1lhwVMOIjUGHmr0Pgh7FoBYMcFOzAVb6OWlFzeuTYpqkwe46Ny0ay6Urpye9Dr8UFaq8jhW2Fup3OgOHHVTyM5TXVnaWNj6xURFFG5sliHb7F/5FttJpCkiiaQOJ4E08hy1/LEAzuBQ) **Explanation:** ``` n-> // Method with integer parameter and boolean return-type n% <1 // Return whether the integer is divisible by: (n%25<1? // If the input is divisible by 25: 16 // Check if its divisible by 16 : // Else: 4) // Check if its divisible by 4 instead ``` [Answer] # KDB(Q), 27 bytes ``` {0=x mod(4 400)0=x mod 100} ``` # Explanation ``` 0=x mod 100 / boolean of 100 divisibility (4 400) / 0b -> 4, 1b -> 400 0=x mod / boolean of 4/400 divisibility { } / lambda ``` # Test ``` q){0=x mod(4 400)0=x mod 100}1936 1805 1900 2272 2400 10011b ``` [Answer] ## PHP - 45 bytes ``` $b=$argv[1]%400;echo !$b|!($b%4)&!!($b%100); ``` Nothing that special really, just abusing type-juggling. [Answer] # T-SQL 37 22 bytes Saved 15 bytes thanks to BradC's comment. The usual hardcoded variable for lack of a `stdin`. e.g. ``` DECLARE @ NVARCHAR(4) = '2016' ``` Then the solution is: ``` PRINT ISDATE(@+'0229') ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Codepage), ~~9~~ 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Commands) ``` т‰0Kθ4Ö ``` [Try it online](https://tio.run/##yy9OTMpM/f//YtOjhg0G3ud2mBye9v@/kaGBAQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TVmmvpPCobZKCkn2ly/@LTY8aNhh4n9thcnjaf53/hpbGZlyGFgamXIaWBgZcRgYgwhBEGJkbcRmZGBgAAA). **Explanation:** ``` т‰ # Divmod the (implicit) input by 100 # i.e. 1900 → [19,00] # i.e. 1936 → [19,36] # i.e. 1991 → [19,91] # i.e. 2000 → [20,00] 0K # Remove all 0s # i.e. [19,00] → [19] # i.e. [19,36] → [19,36] # i.e. [19,91] → [19,91] # i.e. [20,00] → [20] θ # Pop and get the last item # i.e. [19] → 19 # i.e. [19,36] → 36 # i.e. [19,91] → 91 # i.e. [20] → 20 4Ö # Check if it's divisible by 4 (and output the result implicitly) # i.e. 19 → 0 (falsey) # i.e. 36 → 1 (truthy) # i.e. 91 → 0 (falsey) # i.e. 20 → 1 (truthy) ``` [Answer] ## Javascript ES6, 32, 29, 26 Any of following lines works: ``` f=y=>new Date(y,2,0).getDate()&1 g=y=>!(y&3)^!(y%100)>!(y%400) h=y=>!(y&3|y%100<1&&y%400) ``` ]
[Question] [ Recently I had the pleasure of writing a Haskell program that could detect if the `NegativeLiterals` extension was engaged. I came up with the following: ``` data B=B{u::Integer} instance Num B where{fromInteger=B;negate _=B 1} main=print$1==u(-1) ``` [Try it online!](https://tio.run/##LcqxCsIwEADQvV9xg4MOHbJWbskmSGc3Oeo1DSanXC46lP66EcE3v4XKnVNq7UZG4NGvdRhOYhxYty5KMZKJYawZPLwXVl5nfeT/QH8UDmQMV/Tgti5TFHxqFNs5xLrv3aG1zzQnCqX1l/GX44vP0VgplS8 "Haskell – Try It Online") This will print `True` normally and `False` otherwise. Now I had so much fun doing this I'm extending the challenge to all of you. What other Haskell language extensions can you crack? ## Rules To crack a particular language extension you must write a Haskell program that compiles both with and without the language extension (warnings are fine) and outputs two different *non-error* values when run with the language extension and it turned off (by adding the `No` prefix to the language extension). In this way the code above could be shortened to just: ``` data B=B{u::Integer} instance Num B where{fromInteger=B;negate _=B 1} main=print$u(-1) ``` which prints `1` and `-1`. Any method you use to crack a extension must be specific to that extension. There may be ways of arbitrarily detecting what compiler flags or LanguageExtensions are enabled, if so such methods are not allowed. You may enable additional language extensions or change the compiler optimization using `-O` at no cost to your byte count. ## Language extensions You cannot crack any language extension that does not have a `No` counterpart (e.g. `Haskell98`, `Haskell2010`, `Unsafe`, `Trustworthy`, `Safe`) because these do not fall under the terms outlined above. Every other language extension is fair game. ## Scoring You will be awarded one point for every language extensions you are the first person to crack and one additional point for every language extension for which you have the shortest (measured in bytes) crack. For the second point ties will be broken in favor of earlier submissions. Higher score is better You will not be able to score a point for first submission on `NegativeLiterals` or `QuasiQuotes` because I have already cracked them and included them in the body of the post. You will however be able to score a point for the shortest crack of each of these. Here is my crack of `QuasiQuotes` ``` import Text.Heredoc main=print[here|here<-""] -- |] ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRCEktaJEzyO1KDUlP5krNzEzz7agKDOvJDoDKFQDImx0lZRiFXR1FWpi////l5yWk5he/F83IrA0sTgzsDS/JLUYAA "Haskell – Try It Online") [Answer] # MagicHash, 30 bytes ``` x=1 y#a=2 x#a=1 main=print$x#x ``` [-XMagicHash](https://tio.run/##y0gszk7Nyfn/v8LWkKtSOdHWiKsCSBpy5SZm5tkWFGXmlahUKFf8//8vOS0nMb34v26Eb2J6ZrJHYnEGAA) outputs 1, [-XNoMagicHash](https://tio.run/##y0gszk7Nyfn/v8LWkKtSOdHWiKsCSBpy5SZm5tkWFGXmlahUKFf8//8vOS0nMb34v26EX75vYnpmskdicQYA) outputs 2 MagicHash allows variable names to terminate in a `#`. Therefore with the extension, this defines two functions `y#` and `x#` which each take a value and return a constant `2`, or `1`. `x#x` will return 1 (because it is `x#` applied to `1`) Without the extension, this defines one function `#` which takes two arguments and returns `2`. The `x#a=1` is a pattern that never gets reached. Then `x#x` is `1#1`, which returns 2. # 29 bytes ``` a=1 a#b=a main|a<-0=print$a#0 ``` [Answer] # CPP, ~~33~~ 20 bytes ``` main=print$0-- \ +1 ``` Prints `0` with [`-XCPP`](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0TFQFdXIYZLQdvw//9/yWk5ienF/3UjnAMCAA "Haskell – Try It Online") and `1` with [`-XNoCPP`](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0TFQFdXIYZLQdvw//9/yWk5ienF/3Uj/PKdAwIA "Haskell – Try It Online"). With `-XCPP`, a slash `\` before a newline removes the newline, thus the code becomes `main=print$0-- +1` and only `0` is printed as the `+1` is now part of the comment. Without the flag the comment is ignored and the second line is parsed as a part of the previous line because it is indented. --- ### Previous approach with `#define` ``` x=1{- #define x 0 -} main=print x ``` Also prints `0` with [`-XCPP`](https://tio.run/##y0gszk7Nyfn/v8LWsFqXSzklNS0zL1WhQsGAS7eWKzcxM8@2oCgzr0Sh4v//f8lpOYnpxf91I5wDAgA) and `1` with [`-XNoCPP`](https://tio.run/##y0gszk7Nyfn/v8LWsFqXSzklNS0zL1WhQsGAS7eWKzcxM8@2oCgzr0Sh4v//f8lpOYnpxf91I/zynQMCAA "Haskell – Try It Online"). [Answer] # NumDecimals, 14 bytes ``` main=print 1e1 ``` [-XNumDecimals](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0TBMNXw//9/yWk5ienF/3Uj/EpzXVKTM3MTc4oB) prints `10`. [-XNoNumDecimals](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0TBMNXw//9/yWk5ienF/3Uj/PL9SnNdUpMzcxNzigE) prints `10.0`. [Answer] # BinaryLiterals, 57 bytes ``` b1=1 instance Show(a->b)where;show _="" main=print$(+)0b1 ``` [-XBinaryLiterals](https://tio.run/##y0gszk7Nyfn/P8nQ1pArM6@4JDEvOVUhOCO/XCNR1y5JszwjtSjVuhjIV4i3VVLiyk3MzLMtKMrMK1HR0NY0SDL8//9fclpOYnrxf90Ip8y8xKJKn8yS1KLEnGIA) prints a single newline. [-XNoBinaryLiterals](https://tio.run/##y0gszk7Nyfn/P8nQ1pArM6@4JDEvOVUhOCO/XCNR1y5JszwjtSjVuhjIV4i3VVLiyk3MzLMtKMrMK1HR0NY0SDL8//9fclpOYnrxf90Iv3ynzLzEokqfzJLUosScYgA) prints a `1`. I am sure there is a better way to do this. If you find one, please post it. [Answer] # MonomorphismRestriction + 7 others, 107 bytes This uses TH which requires the flag `-XTemplateHaskell` at all times. ### File T.hs, 81 + 4 bytes ``` module T where import Language.Haskell.TH p=(+) t=reify(mkName"p")>>=stringE.show ``` ### Main, 22 bytes ``` import T main=print $t ``` Compiling with the flag [MonomorphismRestriction](https://tio.run/##rZBLC8IwEITv@ytCEVHECJ7b3hQPPkBy8FCQWNcm2DxIIsVfX9v66F26x1nmm2Eu3Iu6znkgKWFUeBLHq8MalLk@SiSMVAIdglTWuEC2XBcPXiDdcH/HsqRsAzaZzKYQEofy9pyo@54rjGw0TdPEByd1saJemApaKrxzdlzqPurDZqAaObGNJZBsFHpDVysdL6H73Uh0/ucynemow3TQb4chuVCI/AeenxgqW/KAn7EaZWe0UcZZIb06YjtPHqTRg5agi7ZBXb8A) forces the type of `p` to `Integer -> Integer -> Integer` and thus produces the following output: ``` "VarI T.p (AppT (AppT ArrowT (ConT GHC.Integer.Type.Integer)) (AppT (AppT ArrowT (ConT GHC.Integer.Type.Integer)) (ConT GHC.Integer.Type.Integer))) Nothing" ``` Compiling with the flag [NoMonomorphismRestriction](https://tio.run/##rZBLC8IwEITv@ytCEVHECJ7b3hQPPkBy8FCQWNcm2DxIUoq/vra16l3c4yzzzTAX7kXT5DyQlDAqPInj1WENylyrEgkjtUCHIJU1LpAt10XFC6Qb7u9YlpRtwCaT2RRC4lDeHhN133OFkY2maZr44KQuVtQLU0NHhVfOjkv9jRrYDFQrJ7a1BJKNwtfQ10rHS@h/NxKdf7lMZzrqMT303eGfXChE/gHPTwyVLXnAYaxW2Zud0UYZZ4X06ojdQHmQRv@1Bl10HZrmCQ) leaves the type of `p` at the most general, ie. `Num a => a->a->a` - producing something like (shortened the `VarT` names to `a`): ``` "VarI T.p (ForallT [KindedTV a StarT] [AppT (ConT GHC.Num.Num) (VarT a)] (AppT (AppT ArrowT (VarT a)) (AppT (AppT ArrowT (VarT a)) (VarT a)))) Nothing" ``` [Try them online!](https://tio.run/##rZBPq8IwEMTv@ymWIqKIPXi2vSk9@Ackh3coPGJdm2CTDUmK@Omr1ufzKIh7nGV@M8xeBtV1lYyYo0hVwPl8sV2C4UPbEAo8K/IE2jj2EVfS1q2sKS1kOFHTpKIAl40mY4iZJ328jMxpIw0lLhnneRai17ZepEHxGe5UeOSspbavqD@2AHOTM3ezRCwH8WXoa@XDGfS/Iya/n1xpS5v0mB767PBNLvjWqscyOP0RZFwjIxX/yobXbNmwd0oHs6P7PlXUbJ9tgCrF7yhvGF13BQ "Bash – Try It Online") --- ## Alternatives Since the above code simply prints out the type of `p`, this can be done with all flags that somehow influence how Haskell infers types. I will only specify the flag and with what to replace the function `p` and if needed additional flags (besides `-XTemplateHaskell`): ### OverloadedLists, 106 bytes Additionally needs `-XNoMonomorphismRestriction`: ``` p=[] ``` Either `p :: [a]` or `p :: IsList l => l`, [try them online!](https://tio.run/##rZA/T8MwEMX3@xRWhBAMZOjcZCvK0D9S5QGJIGSSa2zV9ln2hYpPH1qX0okFuPE9vd97ujeV9DR1ikUtZKmTmM8Xm0dw1I8WhRQHjRHBuECRxVL5YVQDlo1Ke7S2lA2E6vkFuIpodh93br9WDotQ3Nd1lTgaPyzKpOkAJyica1bK@GvTF1qCO8pVOEZYtDd8DeRV9e0MsrcTxetvrvWtLzImQy8b/pMLcfT6/Bjx8CTRBasYm29lTSvy5CgGbZLb4uk/HRvy2du8Y7SkeuyXJnG6LATsNP2F/AN3mj4B "Bash – Try It Online") ### OverloadedStrings, 106 bytes Additionally needs `-XNoMonomorphismRestriction`: ``` p="" ``` Either `p :: String` or `p :: IsString s => s`, [try them online!](https://tio.run/##rZAxT8MwEIX3@xWWhRAMZGBushVloK0EHhgioSO5xlZtn2U7VPz60LqUTizAje/0vvf03jDpee4xi0aoSiexWCw3D@B4mCwJJfaaIoFxgWMWj@jHCUeqWkw7srZSLYRaSsh1JLP9uHG7NTqSQd42TZ1yNH5cVknzHo5QOMWs0PhL0hdagTvIdThYsuiu8sVQWjXX91B@WyFff3Od77wsmAI9d/hPLsTJ69Mw4u5FkQsWM7XfyppX7NlxDNok90THffps2Jff5p2iZRxoeC67pXNHoF7zX9g/kuf5Ew "Bash – Try It Online") ### PolyKinds, 112 bytes This is entirely due to @CsongorKiss: ``` data P a=P ``` Either `P :: P a` or `P :: forall k (a :: k). P a`, [try them online!](https://tio.run/##rZA9i8JAEIb7@RVDkOOuMMXVJp1HwK8UW1gEZDRjdnE/wu4G8ddHjacWFsJxU77D@zzDbCnIvt9RxBxFKgNOJtPVDxhXd5pR4FGyZ1CmdT7inGzTUcNpQeHAWqeigJoiYYmUlRAzz2p/@jSHJRlOyuQrz7MQvbLNNA3SHeGKhptsQco@fb8CAeYSZ@2lErEaxWdhuC3/@IZht8dk85epbGWTATNA7zf8Jxd8Z@XtPTheCzatpsjFI1m60unTTNk63P3AO@ne9V5afX8G "Bash – Try It Online") ### MonadComprehensions, 114 bytes ``` p x=[i|i<-x] ``` Either `p :: [a] -> [a]` or `p :: Monad m => m a -> m a`, [try them online!](https://tio.run/##rZBBS8NAEIXv8yuGIKKH5uA5yUUqOdh62YPQiIztNLs0O7vsbmgL/vdYU2tvLYhzfMP73uN9UNTDsKSEFapcRyyK6csTWLfqO0aFW82BwVjvQsJnkranlvOa4oa7Llc1eNyVC/NpisnuDVIZ2Kz3d3YzJ8uZz@6rqowpGGmnedRuC99wOMbNyMg58SdCgT3IpT9YEjY36WwY21W3DzD@1pi9/@UaaSQbMSP01OE/uRB60ceBcPKq2PqOEte/ytzNnNDq0VkfWLNE4ySemgAvtbtGuOAfhi8 "Bash – Try It Online") ### NamedWildCards, 114 bytes This one was found by @Laikoni, it additionally requires `-XPartialTypeSignatures`: ``` p=id::_a->_a ``` They both have the save type (`p :: a -> a`) but GHC generates different names for the variables, [try them online!](https://tio.run/##rZA/a8MwEMX3@xTClNIO8ZAxxFpKioc2KVTQDgZzjS6WiP4hyYR8etdxmmbpFHrjO97vPd4XJjUMW8yMM1GqxJbL1eYZrJe9ISbYQVEk0Db4mNkLuq7Hjsoa056MKUUNodJysWhxxluEXEXSu@OD3a/RUhGKR86rlKN23apMyh/gBIdz3Ctqd038iRBgR7kKoyWz5i5fDVM7fj@H6bdjRXvLNa5xxYSZoJcO/8mF2Dt1HojNPgXZYDBT/au8YcwajTgGetedw9xHSqO@9qfR5Ic28gmjTJdyQFvlb4b@iRyGbw "Bash – Try It Online") ### ApplicativeDo, 120 bytes ``` p x=do i<-x;pure i ``` Either `p :: Monad m => m a -> m a` or `p :: Functor f => f a -> f a`, [try them online!](https://tio.run/##rZBNa8JAEIbv8yuGIFIPyaFXk4CgkoPVyx48BMpWx@zifrG78ePXp2ms9VIoFOc4w/M@L/PBg@i6HY9YIstEwDxfbJag7b5VhAzPgjyB1M76iCtumpY3lFU8HEmpjFXg8FLsLco8vUxd6wklxMKTPFxf9HHNNSUumZRlEaKXpllkQdgzfCngJn3j0jy83yIGul8Xrkci1qP4AIaO5fgVhtsBk/f/TG1qkwwxQ@i9wzNzwbdG3N6E6ZaRdopHqn42aztzTsleL080t/cOQDth/2J/JbvuEw "Bash – Try It Online") ### OverloadedLabels, 120 bytes This needs the additional flag `-XFlexibleContexts`: ``` p x=(#id)x (#)=seq ``` Either types as `p :: a -> b -> b` or `p :: IsLabel "id" (a->b) => a -> b`, [try them online!](https://tio.run/##rZA9b4MwEIb3@xUWqSoYwtA5sFSJGNJk8dABqTrCBVvxV23T0F9PKWmaqUvUG9/TPc@razCIcTxgZCXjuQhstVrvN6Bt2ytinJ0FeQKpnfWRbdF0PXaUVxhOpFTOK3BsKNKFbLMB0kVWBHqHWHiSx89Un3aoKXFJVpZFiF6abp0HYc/wrYCL9AWluXl/RBz0FBduOomsfoi3g7lj@fgE8@7Ikrd7pja1SWbMDL12@E8u@N6Iy5vY8pWTdgojVb/JRtEgG0XP1kQaYpiind1/kFcWW2q32JAK12ZAB2HvIP7FG8cv "Bash – Try It Online") [Answer] # ScopedTypeVariables, ~~162~~ 113 bytes ``` instance Show[()]where show _="" p::forall a.(Show a,Show[a])=>a->IO() p a=(print::Show a=>[a]->IO())[a] main=p() ``` [-XScopedTypeVariables](https://tio.run/##TY5BCsIwEEX3PUXoKgHrAQIpiCh05aIighQZ42iDMQlJwHp5Y2pddDfz/5vh9RAeqHVKyoQIRiJpe/s6Uda9evRIQt7IWZRl4Ti/WQ9aE1jSESKw@LHQMVFDVTc7ygpHQFDnlYmcT5CoMzG1LE/FE5QRjrKUPvKm4R5SddxqHNRFY/OXmGdrayIOcYw2g9NKqri1fpWdq2NjpB01TZxfttI6vO7fDg/gFeQf4Qs) prints `""` (empty), [-XNoScopedTypeVariables](https://tio.run/##TY5BCsIwEEX3PUXoKgHrAQIpiFjoyoWbghQZQ2qD0yQkgfb0xtSKuPvz5314I4SnQkxJmxDBSEUuo52vlPXzqLwiIV/kJsqycJwP1gMigT1dIQK7Dws9EzVUdXumrHAEBHVem8j5Bok6E9uX5VRMoI1wlKX0kgPCI6Sqa1At@o6q/Ur8d0drolriWp0Wh1rq2Fh/yM5V1xppV00Tf8s3) prints `"[()]"`. Edit: updated solution thanks to useful suggestions in the comments [Answer] # CPP, ~~27~~ 25 ``` main=print({-/*-}1{-*/-}) ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzr0SjWldfS7fWsFpXS1@3VvP//3/JaTmJ6cX/dSOcAwIA "Haskell – Try It Online") Prints `()` for `-XCPP` and `1` for `-XNoCPP` ***Previous version:*** ``` main=print[1{-/*-},2{-*/-}] ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzcxM8@2oCgzryTasFpXX0u3VseoWldLX7c29v//f8lpOYnpxf91I5wDAgA "Haskell – Try It Online") Prints `[1]` with `-XCPP` and `[1,2]` otherwise. Credits: This is inspired by Laikoni's answer, but instead of a `#define` it simply uses C comments. [Answer] # BangPatterns, 32 bytes ``` (!)=seq main|let f!_=0=print$9!1 ``` [-XBangPatterns](https://tio.run/##y0gszk7Nyfn/X0NR07Y4tZArNzEzryYntUQhTTHe1sC2oCgzr0TFUtHw//9/yWk5ienF/3UjnBLz0gMSS0pSi/KKAQ "Haskell – Try It Online") prints `1` whereas [-XNoBangPatterns](https://tio.run/##y0gszk7Nyfn/X0NR07Y4tZArNzEzryYntUQhTTHe1sC2oCgzr0TFUtHw//9/yWk5ienF/3Uj/PKdEvPSAxJLSlKL8ooB "Haskell – Try It Online") will print `0`. This makes use that the flag BangPatterns allows to annotate patterns with a `!` to force evaluation to WHNF, in that case `9!1` will use the top-level definition `(!)=seq`. If the flag is not enabled `f!_` defines a new operator `(!)` and shadows the top-level definition. [Answer] # MonoLocalBinds, GADTs, or TypeFamilies, ~~36~~ 32 bytes EDIT: * -4 bytes: A version of this was incorporated into the [great polyglot chain](https://codegolf.stackexchange.com/a/167537/) by stasoid, who surprised me by putting all the declarations at top level. Apparently triggering this restriction does not require actual *local* bindings. ``` a=0 f b=b^a main=print(f pi,f 0) ``` * With [no extensions](https://tio.run/##y0gszk7Nyfn/P9HWgCtNIck2KS6RKzcxM8@2oCgzr0QjTaEgUydNwUDz/38A "Haskell – Try It Online"), this program prints `(1.0,1)`. * With either of the flags [-XMonoLocalBinds](https://tio.run/##y0gszk7Nyfn/P9HWgCtNIck2KS6RKzcxM8@2oCgzr0QjTaEgUydNwUDz//9/yWk5ienF/3UjfPPz8n3ykxNznDLzUooB "Haskell – Try It Online"), [-XGADTs](https://tio.run/##y0gszk7Nyfn/P9HWgCtNIck2KS6RKzcxM8@2oCgzr0QjTaEgUydNwUDz//9/yWk5ienF/3Uj3B1dQooB "Haskell – Try It Online"), or [-XTypeFamilies](https://tio.run/##y0gszk7Nyfn/P9HWgCtNIck2KS6RKzcxM8@2oCgzr0QjTaEgUydNwUDz//9/yWk5ienF/3UjQioLUt0SczNzMlOLAQ "Haskell – Try It Online"), it prints `(1.0,1.0)`. * The `MonoLocalBinds` extension exists to prevent some unintuitive type inference triggered by GADTs and type families. As such, this extension is automatically turned on by the two others. * It *is* possible to turn it off again explicitly with `-XNoMonoLocalBinds`, this trick assumes you don't. * Like its more well-known cousin the monomorphism restriction, `MonoLocalBinds` works by preventing some values (~~in local bindings like `let` or `where`, thus the name~~ apparently it can also happen at top level) from being polymorphic. Despite being created for saner type inference, the [rules for when it triggers](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#let-generalisation) are if possible even more hairy than the MR. * Without any extension, the above program infers the type `f :: Num a => a -> a`, allowing `f pi` to default to a `Double` and `f 0` to an `Integer`. * With the extensions, the type inferred becomes `f :: Double -> Double`, and `f 0` has to return a `Double` as well. * The separate variable `a=0` is needed to trigger the technical rules: `a` is hit by the monomorphism restriction, and `a` is a *free variable* of `f`, which means that `f`'s binding group is not *fully generalized*, which means `f` is not *closed* and thus doesn't become polymorphic. [Answer] # [RebindableSyntax](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#extension-RebindableSyntax), 25 bytes I was reading the recently posted [Guide to GHC's Extensions](https://limperg.de/ghc-extensions/) when I noticed an easy one that I didn't recall seeing here yet. ``` main|negate<-id=print$ -1 ``` * With [-XNoRebindableSyntax](https://tio.run/##DcixDkBADADQXzFYb7DzARYRFmvd1WlUiauExLcrb3wzpAWZzVYgeQQjKJaOQrUfJJpnrjB7/cQQk7mh2TocSQKMjP0tCtef9bozedL2QD4Dfg "Haskell – Try It Online"), prints `-1`. * With [-XRebindableSyntax](https://tio.run/##y0gszk7Nyfn/PzcxM68mLzU9sSTVRjczxbagKDOvREVB1/D//3/JaTmJ6cX/dSOCUpMy81ISk3JSgyvzShIrgEKeuQU5mcmZJQFFqTmlKakA "Haskell – Try It Online"), prints `1`. Also requires `-XImplicitPrelude`, or alternatively `import Prelude` in the code itself. * `-XRebindableSyntax` changes the behavior of some of Haskell's syntactic sugar to make it possible to redefine it. * `-1` is syntactic sugar for `negate 1`. * Normally this `negate` is `Prelude.negate`, but with the extension it's "whichever `negate` is in scope at the point of use", which is defined as `id`. * Because the extension is meant to be used to make replacements for the `Prelude` module, it automatically disables the usual implicit import of that, but other `Prelude` functions (like `print`) are needed here, so it is re-enabled with `-XImplicitPrelude`. [Answer] # OverloadedStrings, ~~65~~ ~~48~~ 32 bytes Taking advantage of RebindableSyntax, use our own version of fromString to turn any string literal into `"y"`. ``` main=print"" fromString _=['y'] ``` Must be compiled with `-XRebindableSyntax -XImplicitPrelude`. Without `-XOverloadedStrings` prints `""`; with prints `"y"`. Also, it only just now struck me that the same technique works with (e.g.) OverloadedLists: # OverloadedLists, 27 bytes ``` main=print[0] fromListN=(:) ``` Must be compiled with `-XRebindableSyntax -XImplicitPrelude`. Without `-XOverloadedLists` prints `[0]`; with prints `[1,0]`. [Answer] # ApplicativeDo, 146 bytes ``` newtype C a=C{u::Int} instance Functor C where fmap _ _=C 1 instance Applicative C instance Monad C where _>>=_=C 0 main=print$u$do{_<-C 0;pure 1} ``` Prints 1 when ApplicativeDo is enabled, 0 otherwise [Try it online!](https://tio.run/##TYyxDoIwFEV3vuINrCSyoiUxGBMGnd2al1Kksbw2tJUYwq9b6yKu555zB3QPqXWMJGf/shIaQNYsoapa8mumyHkkIeEcSHgzpXke5CShH9ECB84aKDfraK1WAr16pqMNXwxh90t5XbNvt8tGVMTspMjnIe/Mwg9FwnsbklWuMb5Fr/HuYnG7mr/rk/kA "Haskell – Try It Online") [Answer] # ApplicativeDo, 104 bytes ``` import Control.Applicative z=ZipList instance Monad ZipList where _>>=_=z[] main=print$do a<-z[1];pure a ``` [Try it online!](https://tio.run/##Tc2xCsIwEIDhPU9xg2sFZ01BdNS9WEo50mgP09yRnAp5eKODg@vPB/@M@e5DqJUW4aRw4KiJw3ovEsih0tObYi8kJ8pqKGbF6DycOeIEvwyv2ScPY9va0ZZ@MAtStJIo6mpiwF1T@s2wlccXYa1vdw14y7Xp/iZH/gA) With `ApplicativeDo`, this prints ``` ZipList {getZipList = [1]} ``` Without it, it prints ``` ZipList {getZipList = []} ``` `ZipList` is one of the few types in the base libraries with an instance for `Applicative` but not for `Monad`. There may be shorter alternatives lurking somewhere. [Answer] # BinaryLiterals, ~~31~~ 24 bytes Edit: * -7 bytes: H.PWiz suggested adjusting it further by using a single `b12` variable. An adjustment to [H.PWiz's method](https://codegolf.stackexchange.com/a/153751/), avoiding the function instance. ``` b12=1 main=print$(+)0b12 ``` * With [-XNoBinaryLiterals](https://tio.run/##y0gszk7Nyfn/P8nQyNaQKzcxM8@2oCgzr0RFQ1vTACj4//@/5LScxPTi/7oRfvlOmXmJRZU@mSWpRYk5xQA "Haskell – Try It Online"), `0b12` lexes as `0` `b12`, printing 0+1 = `1`. * With [-XBinaryLiterals](https://tio.run/##y0gszk7Nyfn/P8nQyNaQKzcxM8@2oCgzr0RFQ1vTACj4//@/5LScxPTi/7oRTpl5iUWVPpklqUWJOcUA "Haskell – Try It Online"), `0b12` lexes as `0b1` `2`, printing 1+2 = `3`. [Answer] # ExtendedDefaultRules, ~~54~~ 53 bytes ``` instance Num() main=print(toEnum 0::Num a=>Enum a=>a) ``` Prints `()` with [`-XExtendedDefaultRules`](https://tio.run/##HcmxDkAwEADQ3Vd0bBMSs4SJ1WCyXjg0rkf0mvh6R4wvb4O4I5Gq5yjAE5o@BeuyAJ7r8/IsVo6OUzBlVdnvDOQ/wdUNONVnWgjWqMXY3YI849ziAolkSITxBQ "Haskell – Try It Online") and `0` with [`-XNoExtendedDefaultRules`](https://tio.run/##HcmxDkAwEIDh3VN0ZJCYJTXpajBZL3poXI/oNfH0jpj@fPk3SDsSqQZOAjyjGXIsqyJCYHtegaWUw3GOpmnbbxmw3c@vUKk@80KwJq2n4XC3IHv0PS6QScZMmF4). This flag is enabled by default in GHCi, but not in GHC, which recently [caused some confusion for me](https://chat.stackexchange.com/transcript/message/42958768#42958768), though [BMO](https://codegolf.stackexchange.com/users/48198/bmo) was quickly able to help. The above code is a golfed version of an example in the GHC User Guide where [type defaulting in GHCi](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#type-defaulting-in-ghci) is explained. *-1 byte thanks to [Ørjan Johansen](https://codegolf.stackexchange.com/users/66041/%c3%98rjan-johansen)!* [Answer] # Strict, ~~87 84~~ 82 bytes -5 bytes thanks to [dfeuer](https://codegolf.stackexchange.com/users/38603/dfeuer)! Could be less with `BlockArguments` saving the parens around `\_->print 1`: ``` import Control.Exception 0!_=0 main=catch @ErrorCall(print$0!error"")(\_->print 1) ``` Running this with [-XStrict](https://tio.run/##HY0xDoJAEEV7TgHEAgoMHgCjIZxAYyxMyLiuMmHYncxOoZd3Ze3@f694E4TZEsWIC3vRvPdOxdN2eBvLit5lbTF2bbYAus6Amik/DCJeeiCqWNDppi1sImVZV7ex2f9hvqtj/JonwSvE5npSQaNpGM/2cf6wvYAg3Mkmnf6RmXAtrM3wAw) prints a `1` whereas running it with [-XNoStrict](https://tio.run/##HY0xDoJAEEV7TwHEAgoMHgCjIbQ2GGNhQsZ1lYnDzmSYQi/vCnb/v7zkDTC9PFGMOAqrJQ0HU6ZN@3ZeDDmsqrSvq9UIGGoH5oZk36qyNkCUi2KwdZX6hWRZkV/7cveHybaI8eseBM8plpcjd6bobJ6dY/H300f8GRThRn4Rln8QIZwbc3X6AQ) will print a `0`. This uses that Haskell by default is lazy and doesn't need to evaluate `error""` since it already knows that the result will be `0` when it matched on the first argument of `(!)`, this behaviour can be changed with that flag - forcing the runtime to evaluate both arguments. If printing nothing in one case is allowed we can get it down to [**75 bytes**](https://tio.run/##FY1BDsIwDATvfUVbcYADKB@oBKr6AhDihkww1MJJLMcH@nlCc9udlWZnyB9kLoWCJLV2TNE08WH6ehSjFBvX3QfXBKA4eDA/t8dJNekIzFtRirZxHVbS97uAQWwp5edfDO9c9rezKXmrwSfB52URvIISPBjrXPtJhGlVr2f5Dw) replacing the main by (also some bytes off by [dfeuer](https://codegolf.stackexchange.com/users/38603/dfeuer)): ``` main=catch @ErrorCall(print$0!error"")mempty ``` # StrictData, ~~106 99~~ 93 bytes -15 bytes thanks to [dfeuer](https://codegolf.stackexchange.com/users/38603/dfeuer)! This basically does the same but works with data fields instead: ``` import Control.Exception data D=D() main=catch @ErrorCall(p$seq(D$error"")0)(\_->p 1);p=print ``` Prints `1` with the [-XStrictData](https://tio.run/##Fc2xDoIwEIDhnadoCEM7YHQ2GA3lCXRwMDGXWqXhaM/rDfryVlj/4ftHyJNHLCXMlFhUn6Jwws3wcZ4kpFg9QEDZzmpTzRBi50DcqI4Dc@IeEDU12b@1bfxa6tpsjb7d2wOpndlTRxyilPJzT4RXLu318iV/IsKwQIu/prNwcGKX0R8) flag and `0` with [-XNoStrictData](https://tio.run/##Fc2hDsIwEIBhv6dololWjIAmI5B1FgMCQUIupbCGW3tcT8DLUzb7i@8fIb88YilhosSi@hSFE66Gj/MkIcXqDgLKdlabaoIQOwfiRrUfmBP3gKipyf6tbeOXUtdmbfT11u5IbcyWOuIQpZSfeyA8c2kv5y/5AxGGGZr9JR3TSTg4sfPqDw). If printing nothing in one case is allowed we can get it down to [**86 bytes**](https://tio.run/##Fc0xDsIwDEDRvaeIqg7JAOIClUBNTwADqxUCtXAS43iglye06x/eX6C@I1FrmLiImqlklULH@RsiK5bcPUDB@NFb1yXAPAbQsJjzLFJkAiLLglmHGj/WD3Gvfe9OLsXEurb2C0@CV22H@23leGEm3IQN3tNVBYP67fAH) replacing the main by (19 bytes off by [dfeuer](https://codegolf.stackexchange.com/users/38603/dfeuer)): ``` main=catch @ErrorCall(print$seq(D$error"")0)mempty ``` --- **Note:** All solutions require `TypeApplications` set. [Answer] # Strict, 52 bytes ``` import GHC.IO f _=print() main=f$unsafePerformIO$f() ``` [-XStrict](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMHdw1nP058rTSHetqAoM69EQ5MrNzEzzzZNpTSvODEtNSC1KC2/KNfTXyVNQ/P//3/JaTmJ6cX/dSOCS4oyk0sA) [-XNoStrict](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMHdw1nP058rTSHetqAoM69EQ5MrNzEzzzZNpTSvODEtNSC1KC2/KNfTXyVNQ/P//3/JaTmJ6cX/dSP88oNLijKTSwA) With `-XStrict`, prints `()` an extra time. Thanks to @Sriotchilism O'Zaic for two bytes. [Answer] # StrictData, 58 bytes ``` import GHC.Exts data D=D Int main=print$unsafeCoerce#D 3+0 ``` [-XNoStrictData](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMHdw1nPtaKkmCslsSRRwcXWRcEzr4QrNzEzz7agKDOvRKU0rzgxLdU5P7UoOVXZRcFY2@D//3/JaTmJ6cX/df3/60b4JqZnJnskFmcA2X75wSVFmcklLkDDAA) [-XStrictData](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMHdw1nPtaKkmCslsSRRwcXWRcEzr4QrNzEzz7agKDOvRKU0rzgxLdU5P7UoOVXZRcFY2@D//3/JaTmJ6cX/df3/60b4JqZnJnskFmcA2cElRZnJJS5AowA) Requires `MagicHash` (to let us import `GHC.Exts` instead of `Unsafe.Coerce`) and `-O` (absolutely required, to enable unpacking of small strict fields). With `-XStrictData`, prints 3. Otherwise, prints the integer value of the (probably tagged) pointer to the pre-allocated copy of `3::Integer`, which can't possibly be 3. ### Explanation It will be a bit easier to understand with a little expansion, based on type defaulting. With signatures, we can drop the addition. ``` main=print (unsafeCoerce# D (3::Integer) :: Integer) ``` Equivalently, ``` main=print (unsafeCoerce# $ D (unsafeCoerce# (3::Integer)) :: Integer) ``` Why does it ever print 3? This seems surprising! Well, small `Integer` values are represented very much like `Int`s, which (with strict data) are represented just like `D`s. We end up ignoring the tag indicating whether the integer is small or large positive/negative. Why can't it print 3 without the extension? Leaving aside any memory layout reasons, a data pointer with low bits (2 lowest for 32-bit, 3 lowest for 64-bit) of 3 must represent a value built from the third constructor. In this case, that would require a *negative* integer. [Answer] # UnboxedTuples, 52 bytes ``` import Language.Haskell.TH main=runQ[|(##)|]>>=print ``` Requires `-XTemplateHaskell`. Prints `ConE GHC.Prim.(##)` with [-XUnboxedTuples](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMEnMS@9NDE9Vc8DIqEX4sGVm5iZZ1tUmhcYXaOhrKxZE2tnZ1tQlJlX8v//v@S0nMT04v@6ESGpuQU5iSWpUH1AkdC8pPyK1JSQ0oKc1GIA) and `UnboundVarE ##` with [-XNoUnboxedTuples](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMEnMS@9NDE9Vc8DIqEX4sGVm5iZZ1tUmhcYXaOhrKxZE2tnZ1tQlJlX8v//v@S0nMT04v@6ESGpuQU5iSWpUH1AEb/80Lyk/IrUlJDSgpzUYgA). [Answer] # OverloadedLists, 76 bytes ``` import GHC.Exts instance IsList[()]where fromList=(():) main=print([]::[()]) ``` With [-XOverloadedLists](https://tio.run/##Pc1LCsIwEAbgfU@RZbLQAxS6Eh8BoVuhdBHTqQ1OkpIZtKc3MiBuP/7H4ugJiLWGuObC6nw57I8bUxMSsUselKVrIB60Gd8LFFBzyVGk09q0pokupG4tIbEexraVnKn142d0D6q7W/@CgtlNMElJ5ISwhTuC/T2I2eSzrCf@6xc) it prints `[()]`. With [-XNoOverloadedLists](https://tio.run/##Pc1LCsIwEAbgfU@RZbLQAxS6Eh8B0a1Quojp1A4mk5IJ2tMbGRC3H/9jdvyEEGrFuKRc1PG02@7Xwg0SF0celOUzcum1Gd4zZFBTTlGk09q0pokOqVsyUtH90LaSM7V@/BTcg@vmdknXF@SQ3Aij1MQOAVa8B7C/DzFLPsk@lb9@AQ) it prints `[]` This requires the additional flags: `-XFlexibleInstances`, `-XIncoherentInstances` [Answer] # [HexFloatLiterals](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#hexadecimal-floating-point-literals), ~~49~~ 25 bytes *-24 bytes thanks to Ørjan Johansen.* ``` main|(.)<-seq=print$0x0.0 ``` Prints `0.0` with `-XHexFloatLiterals` and `0` with `-XNoHexFloatLiterals`. There are no TIO links because HexFloatLiterals was added in ghc 8.4.1, but TIO has ghc 8.2.2. [Answer] # ScopedTypeVariables, 37 bytes ``` main=print(1::_=>a):: ∀a.a~Float=>_ ``` This also requires `UnicodeSyntax`,`PartialTypeSignatures`, `GADTs`, and `ExplicitForAll`. [Try it online (without extension)](https://tio.run/##FY2xCsIwFEV/xVGHCq6BFApaNxFapVu5prE@fCYhidAu4uh3@iHGdrocOId7Q7hr5pQeICOdJxOXGyFamWMlxOL7eWONV8kWUeZtSj91ZfQhZc3JkLKdrkYTMUx8hI8ErkenK@oN4tPr2dsX23re3eCYFMXS@mI6zJqDrZR1upuLMzzhwjr8AQ) [Try it online (with extension)](https://tio.run/##FY2xCsIwGAZfxVGHCq6BFApaVyFVupXPNNYf/yYhjdAu4uhz@iDGdjoODu6O4WGYU@pBVvpANq53QjQyx0aI1ffzxhavkh2izJuUfvrG6IaU1WdL2rVGTTZinP2EEAlcTd4o6iziM5ilOxb7auFh9EyaYulCMQ@zWmnnTbv0FwTClc3wBw) ### Explanation The partial type signatures are just to save bytes. We can fill them in like so: ``` main=print(1::(Num a, Show a)=>a):: ∀a.a~Float=>IO () ``` With scoped type variables, the `a` in the type of `1` is constrained to be the `a` in the type of `main`, which itself is constrained to be `Float`. Without scoped type variables, `1` defaults to type `Integer`. Since `Float` and `Integer` values are shown differently, we can distinguish them. Thanks to @ØrjanJohansen for a whopping 19 bytes! He realized that it was much better to take advantage of the difference between `Show` instances of different numerical types than differences in their arithmetic. He also realized that it was okay to leave the type of `main` "syntactically ambiguous" because the constraint actually disambiguates it. Getting rid of the local function also freed me up to remove the type signature for `main` (shifting it to the RHS) to save five more bytes. [Answer] # DeriveAnyClass, ~~121~~ 113 bytes Thanks to [dfeuer](https://codegolf.stackexchange.com/users/38603/dfeuer) for quite some bytes! ``` import Control.Exception newtype M=M Int deriving(Show,Num) main=handle h$print(0::M);h(_::SomeException)=print 1 ``` [-XDeriveAnyClass](https://tio.run/##PY2xDoIwFAB3vqKDAyRqdK1hMGCMAywY42YqPGlj@9q0VcSPt4Ia17vkjjN3BSlDEMpo60mm0Vst55tHDcYLjRFC53sDpEgLskNPGrDiLrCNK667aXlTSaSYwJQzbCQQPjFWoI8XlBbJiscnSiut4N9L0o8nyxBe9UWy1oXZMR@bsMY@k8yNYAsIlknxhKb8/vPfdpBVrQ00@wEemBXsLMG9AQ) prints `1` whereas [-XNoDeriveAnyClass](https://tio.run/##PY6xDoIwFEV3vqKDAyRqdK1hMGCMAywY42YqPGlj@9q0VcSPt4Ia13OScy9n7gpShiCU0daTTKO3Ws43jxqMFxojhM73BkiRFmSHnjRgxV1gG1dcd9PyppJIMYEpZ9hIIHxirEAfLygtkhWPT5RWWsG/l6QfT5YhvOqLZK0Ls2Op87EKa@wzydyItoBgmRRPaMrvg/w3PMiq1gaa/QAPzAp2luDe) prints `M 0`. This is exploiting the fact that DeriveAnyClass is the default strategy when both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled, as you can see from the warnings. This flag will happily generate empty implementations for all methods but GeneralizedNewtypeDeriving is actually smart enough to use the underlying type's implementation and since `Int` is a `Num` it won't fail in this case. --- If printing nothing in case the flag is enabled replacing the `main` by the following would be [**109 bytes**](https://tio.run/##PY1NC4JAEEDv/gqPChmdBYPQiA5KYIduNeikQ7uzyzp92I9vM4qu78F7PQwXVMp70tY4CXPD4oyarx8NWiHDAeNdRothmZXhliVs0dGNuIvq3txn1VXHgQbizDpiiRZpWsanBqTpT5FGbWVM09po/AeT5TH2/tWcFXSDTw7Fp4crHnMFwwdskNGBoie21fdd/JaT3IETArWfaE0dg1wdDm8): ``` main=print(0::M)`catch`(mempty::SomeException->_) ``` [Answer] # PostfixOperators, 63 bytes ``` import Text.Show.Functions instance Num(a->b) main=print(0`id`) ``` [Try it online (without extension)](https://tio.run/##BcExDoMwDADAnVcwwgDiA@3ISJFg6IibBrCa2FFsBK/HvdtBfj4EM4yJs5azv7Sddj7b/iCnyCQFkiiQ8@VwxAqa56cuIiA9UkbSqlvwu9Rmt1sDbGLNe@CRRVe8XslnUM7yBw) [Try it online (with extension)](https://tio.run/##BcExDoMwDADAnVcwwgDiA2XsWCqVgRGThmKR2FFsVF6PudtAdh@CGcbEWcvRn9p@Nv63z4OcIpMUSKJAzpevI1bQ9EtdREB6pIykVTfjd67NLrcG@Ik105tFVzyH5DMoZ7kB) This is a cut-down version of [a Hugs/GHC polyglot I wrote](https://codegolf.stackexchange.com/a/180958/38603). See that post for explanation. Thanks to @ØrjanJohansen for realizing I could use `id` instead of a custom operator, saving four bytes. [Answer] # DeriveAnyClass, 104 bytes ``` import Control.Exception newtype M a=M a deriving(Show,Exception) main=print.displayException$M Deadlock ``` [Try it online (without extension)](https://tio.run/##PY2xDoJAEER7vuIKC02UP6AwYKygobHdcCtsWHYvdxcRP95ToqGYZuZl3gBhROaUaHLqoylVolfOL88OXSSVTHCOi0NTGyi@MRY9PUj6fTvofNy4QzYBSeE8ScwtBcewbOOuNhWCZe3GlN7dnaEP6XRrtFrP8CxLyRDW6oqCHpheaJufuPr7Pg) [Try it online (with extension)](https://tio.run/##PY0xDsIwEAT7vMIFBUiQH6RAMaIKDQ3tyT6SUy5ny7YI5vEYIlCKbXZHOwPEEZlLocm7kFTrJAXH9elp0CdyUgnOKXtUnYLmG2Ux0IOk314HN@9XbldNQNL4QJJqS9Ez5HXcdEojWHZmLOVt7gx9LIebXq7wKLlliEtxRsEATC@0l59W/20f) Also requires `GeneralizedNewtypeDeriving`. [Answer] # StrictData, 97 bytes ``` import GHC.Generics data A=A()deriving Generic main=print$selDecidedStrictness$unM1.unM1$from$A() ``` [Try it online (no strict data)](https://tio.run/##LY07DsIwEER7n8JFiqQAKQdwEWEpNKGhoV3Zm7DCn8hrcXwWI1LOzNObJ/ALQxChuOdS9Xy9nGdMWMix8lBBT2bqB9@KN6VNH5taxn4ZNQxmLTl2jVARKJm9UKodY7DoyKO/1wbXhMwaRD5uDbCxnB63/F9se2jR/vR4uL8) [Try it online (strict data)](https://tio.run/##LYwxDoMwEAR7v8IFBRSJxANcoFgiDRVN2pN9kFNsg3ynPB/jKJQ7O5o38AdDKIXivmXR4/NxHzFhJsfKg4AezNB2voIvpVVfn5r6duo1dGbJW2yqoSJQMnumJA1jsOjIo5@lypKQWUMph1sCrFxurz@3tV@H/cXxKp8) Also requires `DeriveGeneric`. [Answer] # UnicodeSyntax, 33 bytes ``` (∀)=0 main|forall<-1=print(∀) ``` [Try it online!](https://tio.run/##S0oszvifnFiiYGOjq6Cup65gp5Cml1H8X@NRR4OmrQFXbmJmXk1aflFiTo6NrqFtQVFmXglY7r8eV1FpXnpGsoJuhF9@aF5mcn5KanBlXkliBdgEhCymnMJ/AA "Bash – Try It Online") [Answer] # TemplateHaskell, ~~140~~ 91 bytes Just copied from [mauke](https://github.com/mauke/poly.poly/blob/master/poly.poly) with small modifications. I don't know what's going on. *-49 bytes thanks to Ørjan Johansen.* ``` import Language.Haskell.TH instance Show(Q a)where show _="" main=print$(pure$TupE[]::ExpQ) ``` [Try it online!](https://tio.run/##bY1LCsIwFAD3OcVDCm0XzQFK667QhQjFLgQReYZnE2yTkA/19vGD4MbZDQzMFb1MAgM0TQU5z2ELNy59Uos1LsAO9RRxIt6jv9M887FnSvuAWhAcpFmLAbBcJTkC/1K4tJsNW1Dp1jqlQ1bY6Cgbo@1O57ruHnYoE2cu6kkKqI57M9JiZwz0HXzujIQ0UL35pf9CSE8) [Answer] # MonomorphismRestriction, ~~31~~ 29 bytes Edit: * -2 bytes with an improvement by H.PWiz ``` f=(2^) main=print$f$f(6::Int) ``` [-XMonomorphismRestriction](https://tio.run/##y0gszk7Nyfn/P81WwyhOkys3MTPPtqAoM69EJU0lTcPMysozr0Tz//9/yWk5ienF/3UjfPPz8nPziwoyMotzg1KLS4oyk0sy8/MA "Haskell – Try It Online") prints `0`. [-XNoMonomorphismRestriction](https://tio.run/##y0gszk7Nyfn/P81WwyhOkys3MTPPtqAoM69EJU0lTcPMysozr0Tz//9/yWk5ienF/3Uj/PJ98/Pyc/OLCjIyi3ODUotLijKTSzLz8wA "Haskell – Try It Online") prints `18446744073709551616`. * With the restriction, the two uses of `f` are forced to be the same type, so the program prints `2^2^6 = 2^64` as a 64-bit `Int` (on 64-bit platforms), which overflows to `0`. * Without the restriction, the program prints `2^64` as a bignum `Integer`. [Answer] # ScopedTypeVariables, ~~119~~ 97 bytes Just copied from [mauke](https://github.com/mauke/poly.poly/blob/master/poly.poly) with small modifications. Currently there are two other answers for ScopedTypeVariables: [113 bytes by Csongor Kiss](https://codegolf.stackexchange.com/a/153762) and [37 bytes by dfeuer](https://codegolf.stackexchange.com/a/181047). This submission is different in that it does not require other Haskell extensions. *-22 bytes thanks to Ørjan Johansen.* ``` class(Show a,Num a)=>S a where s::a->IO();s _=print$(id::a->a)0 instance S Float main=s(0::Float) ``` [Try it online!](https://tio.run/##dY6xCoMwFAB3v@INBROo4pyqY6GLHVJKt/KMaROIieRFpF@fgkunjnfccCOSyQoTtG0FZV1CD6/aUFYOiZg0YQM8DusMyLteAsJmdNRAQmDVX66Mnwie3RKtTwdmp10jbwrrKaFXGiScXcBUzGh9R6wRYmee6yKu/m0UVI8hSBUWPd0@i75jtDg6TfvHr/lXQP4C) ]
[Question] [ Many electronic devices, specially old ones, will show a blinking `12:00` when the time has not been set. The purpose of this challenge is to recreate this. Specifically, the task is to **display `12:00` and `--:--` alternatively in an infinite loop**. The **period** should be 1 second, divided evenly in two periods of 0.5 seconds. Here "1 second" and "evenly" can be interpreted loosely. For example, it is acceptable if the code pauses for 0.5 seconds between displaying the strings, even if the resulting period will then be a little higher than 1 second. An initial pause before displaying the first string is acceptable. Each new string can be displayed either by [**replacing the former string**](https://i.stack.imgur.com/zqWzT.gif) or [**in a new line**](https://i.stack.imgur.com/8vhiR.gif). Trailing whitespace is allowed, except that if each new string is on a different line there should be no empty lines between consecutive strings. Shortest code in bytes wins. [Answer] ## HTML/CSS, ~~131~~ ~~108~~ ~~106~~ 101 + ~~18~~ 17 = ~~149~~ ~~126~~ ~~125~~ ~~123~~ 118 bytes ``` a{background:#FFF;margin:-5ch;animation:a 1s steps(2,start)infinite}@keyframes a{to{visibility:hidden ``` ``` <tt>--:--<a>12:00 ``` Edit: Saved 23 bytes thanks to @insertusernamehere. Saved 1 byte by switching from `<pre>` to `<tt>`. Saved 2 bytes thanks to @darrylyeo. Saved 5 bytes thanks to @DBS. [Answer] # Shell and `pv`, 26 bytes This use `yes` standard tool and `pv` *Shell pipeline element to meter data passing through* ``` yes '12:00 --:--'|pv -qlL2 ``` [Answer] # Python2, ~~80~~ ~~75~~ ~~73~~ ~~69~~ ~~67~~ 66 bytes ``` import time n=0 while[time.sleep(.5)]:print"1-2-::0-0-"[n::2];n^=1 ``` ~~I noticed that my string magic got a little longer than picking the string from an array.~~ Nevermind, figured it out. **Explanation**: * I set a counter **n** to 0, which will be toggled between 0 and 1. * I loop endlessly with the loop `while 1`. * I create a string `1-2-::0-0-`, which contains the string `12:00` and `--:--` interlapped. + Starting from the index 0 with a step of 2, we get: `12:00` + Starting from the index 1 with a step of 2, we get: `--:--` * I use **n** to make the repeated sequence **0**, **1**, **0**, **1**, **0**... which will be the starting index of the string. + Using `n^=1`, in each loop, we get that sequence. `^` being the XOR-operator. + If **n** == 0 --> `n^=1` results in 1 + If **n** == 1 --> `n^=1` results in 0 * I print the string, and sleep (`.5` -> `0.5`) seconds. [@FlipTack](https://codegolf.stackexchange.com/users/60919/fliptack) saved 4 bytes! --> Put the loop in one line. [@Rod](https://codegolf.stackexchange.com/users/47120/rod) saved 2 bytes! --> `n+=1` to `n^=1`, thus `n%2` to `n`. [@xnor](https://codegolf.stackexchange.com/users/20260/xnor) saved a byte! --> `while 1` --> `while[time.sleep(.5)]`. [Answer] # Octave, ~~63~~ ~~62~~ ~~61~~ 55 bytes ``` c='--:--00:21';while c=flip(c)disp(c(1:5));pause(.5)end ``` Saved two bytes thanks to Tom Carpenter! Using a single string instead of two strings in a cell array was shorter. **Explanation:** ``` c='--:--00:21'; % A string where the 5 first characters are --:-- or 12:00 when reversed while c=flip(c) % A string is always considered true in Octave, so this will loop forever % while flipping the order of the string each time disp(c(1:5) % display the 5 first characters of the string c pause(.5) % Pause 0.5 second end % End loop ``` A few bytes saved because Octave doesn't require a colon or semicolon between `flip(c)` and `disp()`, and between `pause(.5)` and `end`. [Answer] # JavaScript, 59 bytes ``` y=1;setInterval('console.log(["12:00","--:--"][y^=1])',500) ``` **Explanation** `setInterval('...',500)` sets an interval to execute code in the string every 500 milliseconds, or 1/2 a second. `y=1` sets a variable, `y`, to 1 initially. That way, the first thing that is printed is `12:00` because `y` is used to access the array. `console.log(...)` logs whatever to the console, in this either `12:00` or `--:--`. `["12:00","--:--"][y^=1]` creates an array with strings containing both states. Then, `y` is used to access one of elements. Finally, `^=`, or XOR compound operator does `y = y ^ 1`. This just inverts the bit because `1 ^ 1` is 0, and `0 ^ 1` is 1, similar to what [@TuukkaX did](https://codegolf.stackexchange.com/a/105325/56456). This way, the string logged alternates between the two elements in the array and thus creates the blinking effect. [Answer] # [V](https://github.com/DJMcMayhem/V), ~~31~~ ~~30~~ ~~27~~ ~~25~~ 24 bytes *Saved 5 bytes thanks to @nmjcman101 by swapping the order of `12:00` and `--:--` so that `k` can be removed any by removing `ò` so that it could be added implicitly at the end* *Saved 1 byte thanks to @DJMcMayhem by putting both `12:00` and `--:--` in one line* ``` i12:00--:--<ESC>bDòVp:sl500m ``` Old Solution: ``` i12:00<ESC>ò:sl500m Óä/- :sl500m uò ``` `<ESC>` is `0x1b` Hexdump: ``` 00000000: 6931 323a 3030 2d2d 3a2d 2d1b 6244 f256 i12:00--:--.bD.V 00000010: 703a 736c 3530 306d p:sl500m ``` ### Explanation ``` i12:00--:--<ESC> inserts 12:00\n--:-- bD go to the beginning of --:-- and delete it ò recursively do: Vp select line and paste (effectively doing a replace) :sl500m sleep for 500 milliseconds the last ò is added implicitly at the end ``` ### Gif (outdated) **Note:** I have highlighting turned on [![giff](https://i.stack.imgur.com/nhAg8.gif)](https://i.stack.imgur.com/nhAg8.gif) [Answer] ### bash, ~~58 56 45~~ 41 bytes New version 2022, (not very system friendly), but... ``` bash <(yes "read -t.5 -p"{--:--,12:00}\;) ``` or with *newline*: 45 ``` bash <(yes "read -t.5 -p' "{--:--,12:00}"';") ``` or with *carrier return*: 47 ``` bash <(yes "read -t.5 -p$'\r"{--:--,12:00}"';") ``` ~~saved 3 byte by suppressing `--` after `set` as 1st arg is a number.~~ ``` set 12:00 --:--;for((a=1;;a=3-a)){ echo ${!a};sleep .5;} ``` Saved 16 byte by using [@DigitalTrauma](https://codegolf.stackexchange.com/posts/comments/256376?noredirect=1)'s syntax: ``` f()(echo $1;sleep .5);f 12:00;f --:--;exec $0 ``` Then loosing 5 bytes because of [zeppelin's comment](https://codegolf.stackexchange.com/posts/comments/256462?noredirect=1). This could not be tested on command line. As we involve `$0`, this must be written into a script to run. ### Divert With a little preparation, this could become nice (**412 bytes**): ``` set -- " ▗▖ ▗▄▄▖▗▄▄▖ ▝▘ ▗▄▄▖▗▄▄▖ ▗▖ ▝▘ " " ▟▌ ▟▀▜▖ ▗▖ ▗▛▙ ▗▛▙ ▐▌ ▗▟▘ ▝▘ █▗▐▌█▗▐▌ ▐▌ ▗▛▗▖ ▗▖ ▜▖▟▘▜▖▟▘ ▝▀▀▘▀▀▀▘ ▝▘ ▀▘ ▀▘ " r=`tput cup 0` clear;for((a=1;;a=3-a)){ printf "$r${!a}";sleep .5;} ``` Or even same two lines but with: ``` set -- ' HM! .o#HMMMMM#o. .o#MMMMH#\\ .d#MMMMH#\\ _HMMi ?MMH*"""`"MMMb dMMH"""`*MMH, dMMH"""`*MMH. ##HMMMMMi |MMP" 9MML ?MMP `MMM. dMM? `MMM. `""`"9MM| dMM! -MMR HMH} .MMM |MM} .MMH |MM| |MM| "` JMMT dHH} |MM| MMM |MM| -MMM |MM! .,HMM* |MM| MMM. ]MM| MMM |MMi _o#MMH*" |MM| MMM {MM| MMM |MMi .dHMM#"" |MM| MMM" {MM| .MMM |MMi .HMM*" `MM6 ,MMR |MM} |MMF |MMi ,MMP" 9MM, dMM| HMM, dMM" {MMi MMM?\\o,\\\\\\\\\\\\\\\\, q##+ `HMM\\ .dMM? `HMH\\ .dMM? |MM| :MMMMMMMMMMMMMMM[ HMMk `*HMM##MMM#" `*HMM##MMMP" "` " ` ` ` ` """"`"" """""" ' ' MHM| HHH| ______. ._______. ________. ._______. MMMMMM: {MMMMMMM| &MMMMMMM: |MMMMMMM[ ###| MMM| ' ``` [Answer] ## Perl, 49 bytes ``` {select$,,$,,$,,0.5;say$|--?"12:00":"--:--";redo} ``` Perl's `sleep` can't sleep for duration bellow 1 sec, hence the use of `select undef, undef, undef, .5` (golfed by replacing `undef` with `$,`) to sleep .5 second. Other interesting thing: `$|` can only hold `0` or `1`. So `$|--` just toggles its value, from `0` to `1`. And finally, `{... ;redo}` acts like an infinite loop. [Answer] # [Noodel](https://tkellehe.github.io/noodel/), 16 [bytes](https://tkellehe.github.io/noodel/docs/code_page.html) ``` --:-- 12:00ḷçėḍh ``` *Noodel* is still very much a work in progress. Just trying to get my feet wet with a couple of challenges. [Try it:)](https://tkellehe.github.io/noodel/editor.html?code=--%3A--%2012%3A00%E1%B8%B7%C3%A7%C4%97%E1%B8%8Dh&input=&run=true) ### How It Works ``` --:-- # Creates the string literal "--:--" and places i into the front of the pipe.   # Space is a NOP command to separate the string literals. 12:00 # Creates the string literal "12:00" and places it into the front of the pipe. ḷ # Loop the following code unconditionally. ç # Clear the screen and print a copy of what is in the pipe. ė # Take what is in the front of the pipe and put it into the back. ḍh # Delay for half a second. ``` --- Here is a code snippet:) ``` <div id="noodel" code="--:-- 12:00ḷçėḍh" input="" cols="10" rows="2"></div> <script src="https://tkellehe.github.io/noodel/noodel-latest.js"></script> <script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script> ``` [Answer] # [\*><>](https://esolangs.org/wiki/Starfish), ~~43~~ 42 bytes ``` <v":1200----" S>@5dov>~r@@}r5 1&}o:&<^!?:- ``` [Try it here!](https://starfish.000webhostapp.com/?script=DwNwRAXAjATADHAtMxYBQBlAfAAQKwAmA9iFgH4BOOOAvhXmlAGQ1ERPAB6AhAPwSIgA) I feel like I should be able to make this shorter, I have a couple ideas to try ... Basically this makes a stack of `:1200----`. It isolates the `:` and flips the stack, inserting the `:` in the middle of either `----` or `1200` (depending on whichever is at the end of the stack). I should also note that the only \*><> instruction this uses is `S` (sleep), otherwise this is a proper ><> program. Update: Saved 1 byte by shifting the `:` to the right instead of protecting it with a register. ## Explanation ### Initialisation ``` <v":1200----" ``` Here we build the stack we'll be using for the life of the program. ``` < move the IP left ":1200----" push ":1200----" to the stack v move the IP down into "output time" ``` ### Output time ``` >@5dov 1&}o:&<^!?:- ``` This is the section where the time is actually outputted. First 5 is pushed to the stack so the loop below knows to run 5 times. ``` Initialisation: >@5dov > move the IP right @ move the ":" back two spaces in the stack 5 push 5 to the stack (let's call this `i`) do output carriage return v move IP down into "loop" Loop: 1&}o:&<^!?:- < move the IP left & place i onto the register }o: output a character and shift the stack left & place i back onto the stack 1 - decrement i by 1 ^!?: if i == 0, exit to "recover and swap" ``` ### Recover and swap ``` S >~r@@}r5 ``` Here we recover the `:` from the position it results in after the output, and we end up with a reversed stack. This actually exits into "output time" nicely, causing an infinite loop. ``` > move the IP right ~ remove trailing i from stack r@@ reverse the stack and move ":" to the front }r reverse the stack again, keeping ":" on the front S 5 sleep for 500ms ``` --- ### 45 byte solution ``` <v[5"12:00"1 d/S5 o/!?l v>]?v 00.>0"--:--"5[ ``` [Try it here!](https://starfish.000webhostapp.com/?script=DwNw2grARAjATALgAxNgKACYHoDKE0D2WAhAPwA2aIAfALqkhoAEKAdNagLScLdQRggA) This one is also basically a ><> program. I really thought it'd be able to save some bytes with this approach. This quite simply outputs `12:00`, then `--:--`. I save bytes by reusing the output routine `o/!?l` (I even reuse that mirror as both entry and exit). I utilise multiple stacks to store the state (has output `12` or `--`), and select which state I should output with `v>]?v`. Explanations coming soon! (1/2) [Answer] ## HTML/CSS (Chrome only), 80 + 4 = 84 bytes ``` tt:after{content:"--:--";animation:a 1s infinite}@keyframes a{to{content:"12:00" ``` ``` <tt> ``` **Edit**: The "content" attribute is not *animatable* by the [CSS specification](https://www.w3.org/TR/css3-transitions/#animatable-css), but is on Chrome desktop browser. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 20 bytes ``` .“12:00“--:--”ṄœS¥€ß ``` ## How it works ``` .“12:00“--:--”ṄœS¥€ß Main link. No arguments. . Set the return value to 0.5. “12:00“--:--” Yield ["12:00", "--:--"]. ¥ Combine the two links to the left into a dyadic chain. Ṅ Print the left argument. œS Sleep as many seconds as the right argument specifies. € Map the created dyadic chain over the string array, with right argument equal to the return value, i.e., 0.5. ß Recursive call the main link. ``` [Answer] ## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), ~~37~~ 33 bytes ``` {sleep 01?@12:00`┘sleep 01?@--:-- ``` QBasic unfortunately can only sleep for whole seconds. I'll see about devising a method to allow for more flexibility soon. I've input 1 as `01` to simulate `.5`. Explanation: ``` { Starts DO loop sleep 01 Sleeps for 1 second ?@12:00` Creates A$, sets value to "12:00" and prints A$ ┘ Newline: a string literal doesn't break the line, so we need a newline to control the compiled QBasic syntax <Rinse and repeat for "--:--"> <DO-LOOP implicitly closed by QBIC> ``` In older builds of QBIC, `$` and (space) were reserved characters. Calling a QBasic function that needed spaces (like `sleep x`) or `$` (`left$(..)`) required a code literal: ``` 'QBASIC CODE` ``` Code in a code literal block is passed directly to QBasic without being parsed by QBIC. By offloading functions from those symbols (`$` became `'`, and newlines are now `┘` (alt-217) instead of ) the symbols are no longer seen by QBIC as special chars and simply passed on. The same is effectively true for the lowercase alphabet: it's used to represent numeric variables in both QBIC and QBasic and are left unchanged. Using QBasic functionality that is not implemented in QBIC (like `SLEEP`) is therefor simply a matter of not using QBIC reserved chars. This is made easier with the recent changes in the command symbols. [Answer] # [LibreLogo](https://help.libreoffice.org/Writer/LibreLogo_Toolbar#LibreLogo_programming_language), 100 bytes (Non-Competing) **Code:** ``` ht point fontsize 99 repeat [ cs sleep 500 if repcount % 2 [ label '12:00' ] else [ label '--:--' ]] ``` **Explanation:** ``` ht ; Hide Turtle (Unnecessary... Added for visual clarity) point ; Draw a point with size and color of the pen fontsize 99 ; Font Size = 99 pt (Unnecessary... Added for visual clarity) repeat [ ; Endless Loop cs ; Clear Screen sleep 500 ; Wait for 500 ms if repcount % 2 [ ; If the Repetition Count is Even... label '12:00' ; Draw '12:00' ] else [ ; Otherwise... label '--:--' ; Draw '--:--' ] ] ``` **Result:** [![enter image description here](https://i.stack.imgur.com/1qKQU.gif)](https://i.stack.imgur.com/1qKQU.gif) [Answer] # JavaScript, ~~77~~ ~~76~~ 72 bytes ``` setInterval('l=console.log,l("12:00"),setTimeout("l(`--:--`)",‌​500)',1e3) ``` Thanks to Kritixi Lithos for 1 byte and L. Serne for 4 bytes! [Answer] # Python 2, ~~88~~ ~~85~~ ~~73~~ 71 bytes ``` import time c="--:--00:21" while 1:print c[:5];c=c[::-1];time.sleep(.5) ``` [Try it here!](https://repl.it/EzQ6/2) By borrowing [Stewie Griffin's idea](https://codegolf.stackexchange.com/a/105324/36594) of flipping the list, the program was made possible. Ungolfed version with explanation: ``` import time # Import time module c = "--:--00:21" # String with two values while 1: # Infinite Loop print c[::5] # Print the first 5 chars in string c = c[::-1] # Flip the string time.sleep(.5) # Wait 0.5 seconds ``` Thanks @FlipTack for saving 14 bytes! [Answer] # PHP, 51 50 47 ``` for(;;usleep(5e5))echo$i++%2?"--:-- ":"12:00 "; ``` 1 byte saved due to manatwork and another 3 saved by insertusernamehere. Thanks! [Answer] ## Pyth, 23 bytes ``` #?=!Z"12:00""--:--".d.5 ``` In pseudocode: ``` Z = 0 # while 1: ?=!Z if ( Z = not Z ): "12:00" print("12:00") else: "--:--" print("--:--") .d.5 sleep(0.5) ``` Uses preinitialized variable `Z` as the flip-flop, and inverts its state every time `if` tries to check the condition. [Answer] # Mathematica, 38 bytes ``` Dynamic@If[Clock[]>.5,"12:00","--:--"] ``` **Explanation** ``` Clock[] ``` Outputs a clock variable that cycles continuously from 0 to 1 every second. ``` If[Clock[]>.5,"12:00","--:--"] ``` If the clock variable is greater than .5, output "12:00." If not, output "--:--". ``` Dynamic@ ... ``` Make the program dynamic (constantly updating) [Answer] ## ruby, 47 42 bytes No ruby answer yet, so here is my first try: ``` %w{12:00 --:--}.cycle{|a|puts a;sleep 0.5} ``` [Answer] # GNU sed, 39 bytes EDITS: * Swapped *sleep* and *i12:00* (to make source code look a bit nicer) **Golfed** ``` s/^/sleep .5/ h i12:00 e i--:-- x e G D ``` **Explained** ``` s/^/sleep .5/ #Put 'sleep .5' to the pattern space h #Copy pattern space to hold space i12:00 #Print "12:00" (insert before a line) e #Execute command that is found in pattern space i--:-- #Print "--:--" x #Exchange the contents of the hold and pattern spaces e #Execute command that is found in pattern space G #Append a newline to the contents of the pattern #space, and then append the contents of the hold #space to that of the pattern space. D #Delete text in the pattern space up to the #first newline, and restart cycle with the #resultant pattern space, without reading a new #line of input. ``` [Try It Online !](https://goo.gl/4al8TH) [Answer] # dc (bash), 37 bytes ``` [12:00][--:--][[rp!sleep .5]xlax]dsax ``` This works by pushing the two strings "12:00" and "--:--" on the stack and then repeatedly swapping the values, printing the item at the top of the stack, and sleeping half a second. To run this, you can save it in a file and then type > > dc *filename* > > > or you can run it directly from the bash command line by typing > > dc <<<'[12:00][--:--][[rp!sleep .5]xlax]dsax' > > > [Answer] # [Perl 6](https://perl6.org), ~~48 41~~ 34 bytes ``` loop {print "\r",<--:-- 12:00>[$_=!$_];sleep .5} ``` ``` loop {put <--:-- 12:00>[$_=!$_];sleep .5} ``` ``` sleep .put/2 for |<12:00 --:-->xx* ``` [Answer] # Vim, 32 keystrokes ``` qq:sl500m<CR>S12:00<Esc>:<UP><CR>S--:--<Esc>@qq@q ``` [Answer] # **Python 3, 75 bytes** ``` import time x=['12:00','--:--'] for i in x:x+=[i];print(i);time.sleep(.5) ``` [Answer] # Jelly, 22 bytes ``` ®‘©ị“12:00“--:--”ṄœS.ß ``` Doesn't work on TIO. Getting Jelly to run on Android with QPython3 was also a fun experience. ### Explanation ``` ®‘©ị“12:00“--:--”ṄœS.ß Main link. No arguments. ® Read the register. Initially 0. ‘ Increment. © Save to the register. ị Get the n'th (wrapping) item of... “12:00“--:--” ["12:00", "--:--"] Ṅ Print the string and a newline. œS Sleep for... . ...0.5 seconds. (. is an alias for 0.5) ß Call this link again. ``` [Answer] # Javascript, 57 55 ``` setInterval('console.log(++i%2?"12:00":"--:--")',i=500) ``` 2 bytes saved thanks to ETHproductions [Answer] # Javascript (in browser), ~~174~~ ~~160~~ ~~159~~ ~~122~~ ~~112~~ ~~111~~ ~~109~~ ~~107~~ 66 (91) bytes I've taked of `pre` because using monotyped font is not part of requirement, so my new count is **66**. Some chars are added to use monospaced font but as this is not needed, I won't count this **25** more chars. Thanks to [ETHproductions](https://codegolf.stackexchange.com/users/42545/ethproductions) for saving 14 bytes, to [Kritixi Lithos](https://codegolf.stackexchange.com/users/41805/kritixi-lithos) for saving 1 byte, to [manatwork](https://codegolf.stackexchange.com/users/4198/manatwork) for saving ~~1~~ **3** byte, to [Christoph](https://codegolf.stackexchange.com/users/29637/christoph) for saving two more bytes and to myself for saving 37 bytes by using `[..][b^=1]` instead of `setTimeout`... and 10 more by replacing `function(){..}` by double-quotes... ``` setInterval("document.body.innerHTML=++b%2?'12:00':'--:--'",b=500) ``` ``` body{font-family:Courier} ``` ... worse: ## From 66 to *something more*... ... but for fun, in the spirit of a blinking display: ``` SVG="http://www.w3.org/2000/svg";XLNK="http://www.w3.org/1999/xlink"; s=["1200","----"];p=0;function d(n){for(i=n.length;i>0;i--) { document.getElementById('n'+i).setAttribute('class','n'+n[i-1])} document.getElementById('sz').setAttribute('class','n'+n[0])} setInterval("p=1-p;d(s[p])",500); ``` ``` #svg2 { --c: #FF6;stroke:#432;stroke-width:12;stroke-linecap:round;stroke-linejoin:round; stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none; } path.b { fill:#543;stroke:none; } .blue { --c: #68F; } .green { --c: #6F8; } .red { --c: #F88; } .dec rect { stroke: var(--c); } .n1 #B { stroke: var(--c); } .n1 #C { stroke: var(--c); } .n2 #A { stroke: var(--c); } .n2 #B { stroke: var(--c); } .n2 #D { stroke: var(--c); } .n2 #E { stroke: var(--c); } .n2 #G { stroke: var(--c); } .n3 #A { stroke: var(--c); } .n3 #B { stroke: var(--c); } .n3 #C { stroke: var(--c); } .n3 #D { stroke: var(--c); } .n3 #G { stroke: var(--c); } .n4 #B { stroke: var(--c); } .n4 #C { stroke: var(--c); } .n4 #F { stroke: var(--c); } .n4 #G { stroke: var(--c); } .n5 #A { stroke: var(--c); } .n5 #C { stroke: var(--c); } .n5 #D { stroke: var(--c); } .n5 #F { stroke: var(--c); } .n5 #G { stroke: var(--c); } .n6 #A { stroke: var(--c); } .n6 #C { stroke: var(--c); } .n6 #D { stroke: var(--c); } .n6 #E { stroke: var(--c); } .n6 #F { stroke: var(--c); } .n6 #G { stroke: var(--c); } .n7 #A { stroke: var(--c); } .n7 #B { stroke: var(--c); } .n7 #C { stroke: var(--c); } .n8 #A { stroke: var(--c); } .n8 #B { stroke: var(--c); } .n8 #C { stroke: var(--c); } .n8 #D { stroke: var(--c); } .n8 #E { stroke: var(--c); } .n8 #F { stroke: var(--c); } .n8 #G { stroke: var(--c); } .n9 #A { stroke: var(--c); } .n9 #B { stroke: var(--c); } .n9 #C { stroke: var(--c); } .n9 #D { stroke: var(--c); } .n9 #F { stroke: var(--c); } .n9 #G { stroke: var(--c); } .n0 #A { stroke: var(--c); } .n0 #B { stroke: var(--c); } .n0 #C { stroke: var(--c); } .n0 #D { stroke: var(--c); } .n0 #E { stroke: var(--c); } .n0 #F { stroke: var(--c); } .n11 #B { stroke: var(--c); } .n11 #C { stroke: var(--c); } .n11 #E { stroke: var(--c); } .n11 #F { stroke: var(--c); } .nA #A { stroke: var(--c); } .nA #B { stroke: var(--c); } .nA #C { stroke: var(--c); } .nA #E { stroke: var(--c); } .nA #F { stroke: var(--c); } .nA #G { stroke: var(--c); } .nB #C { stroke: var(--c); } .nB #D { stroke: var(--c); } .nB #E { stroke: var(--c); } .nB #F { stroke: var(--c); } .nB #G { stroke: var(--c); } .nC #A { stroke: var(--c); } .nC #D { stroke: var(--c); } .nC #E { stroke: var(--c); } .nC #F { stroke: var(--c); } .nD #B { stroke: var(--c); } .nD #C { stroke: var(--c); } .nD #D { stroke: var(--c); } .nD #E { stroke: var(--c); } .nD #G { stroke: var(--c); } .nE #A { stroke: var(--c); } .nE #D { stroke: var(--c); } .nE #E { stroke: var(--c); } .nE #F { stroke: var(--c); } .nE #G { stroke: var(--c); } .nF #A { stroke: var(--c); } .nF #E { stroke: var(--c); } .nF #F { stroke: var(--c); } .nF #G { stroke: var(--c); } .nR #E { stroke: var(--c); } .nR #G { stroke: var(--c); } .nO #C { stroke: var(--c); } .nO #D { stroke: var(--c); } .nO #E { stroke: var(--c); } .nO #G { stroke: var(--c); } .n- #G { stroke: var(--c); } .n1 #y { stroke: var(--c); } .n1 #z { stroke: var(--c); } ``` ``` <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 645 230" id="svg2"> <defs id="dfs4"><g id="n"><path d="M 15,5 155,5 145,225 5,225 z" class="b"/> <path id="A" d="M 45,15 125, 15"/><path id="B" d="M 135,25 125,105"/><path id="C" d="M 125,125 115,205"/><path id="D" d="M 25,215 105,215"/><path id="E" d="M 25,125 15,205"/><path id="F" d="M 35,25 25,105"/><path id="G" d="M 35,115 115,115"/><rect id="P" width="5" height="5" ry="2.5" x="130" y="205"/></g><g id="s"><path d="M 10,5 35,5 25,225 0,225 z" id="a" class="b"/><rect id="y" width="5" height="5" ry="2.5" x="13.5" y="145"/><rect id="z" width="5" x="17" height="5" ry="2.5" y="75"/></g></defs><use id="n1" xlink:href="#n" /><use id="n2" xlink:href="#n" transform="translate(150,0)" /><use xlink:href="#s" id="sz" transform="translate(305,0)"/><use id="n3" transform="translate(335,0)" xlink:href="#n" /><use id="n4" xlink:href="#n" transform="translate(485,0)" /> </svg> ``` [Answer] ## [QuickBASIC](https://en.wikipedia.org/wiki/QuickBASIC), 167 bites (yummy) ``` a%=VAL(RIGHT$(STR$(TIMER*100),2)) b%=a%+50 IF b%>99THEN b%=b%-99 DO c%=VAL(RIGHT$(STR$(TIMER*100),2)) IF c%=a% THEN PRINT"--:--" IF c%=b% THEN PRINT"12:00" LOOP ``` I was never going to win anyways. QB doesn't have a floor(), and also doesn't have a function to sleep for *x* milliseconds. Therefore, this works by grabbing the floating point portion of the TIMER (returns seconds elapsed since midnight, plus a fraction of the current second expressed as a two-digit decimal). We then add a loop-around "50 units" to it to determine when the phase should switch from "--:--" to "12:00", and use the original TIMER decimal for the switch from "12:00" to "--:--". Finally, even running this complied in QB4.5, in DOSBox on a rather powerful machine will skip beats. That's because QB really isn't fast enough to perform the DO-LOOP and evaluations inside of the MS we're doing the comparison in. Would need a box from the FUTURE! Anyway, I now look 100, and I made every American University student happy since they probably have an answer for their Comp Sci class -- since they're still teaching this... [Answer] # Clojure, ~~79~~ 62 bytes ## V2 -17 bytes by changing from an awful indexing loop to looping over an infinite list. Creates an infinite list of `"12:00"` and `"--:--"` repeating over and over again, then uses `doseq` to constantly pull the next message, and print it. ``` (doseq[m(cycle["12:00""--:--"])](Thread/sleep 500)(println m)) ``` ## V1 ``` (loop[i 0](Thread/sleep 500)(println(["12:00""--:--"]i))(recur(if(= 0 i)1 0)))) ``` I couldn't think of a good way to compact the "12:00" and "--:--" constants, so I had to just hard code them. Ungolfed: ``` (loop [i 0] ; Track which sign we showed last (Thread/sleep 500) (println (["12:00" "--:--"] i)) ; Index the vector to get the string to print (recur (if (= 0 i)1 0))) ; Swap the index, and loop again ``` ]
[Question] [ **Short and sweet description of the challenge:** Based off [ETAOIN SHRDLU](http://en.wikipedia.org/wiki/ETAOIN_SHRDLU), your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input. **Really long, dry and thorough specification:** * Your program/function will receive as input a string of text, which will contain one or more uppercase and/or lowercase letters and may also contain punctuation, numerals, symbols, and other non-alphabetic characters. * The program/function must output **only** the 26 UPPERCASE letters of the English alphabet, including those that do not appear in the input, ordered from most to least frequent based on how many times they appear in the input. * The frequency is calculated case-insensitively, but the output must be in uppercase. * If two or more letters have the same frequency, they may be in any order. * The only other output that is allowed is optional leading or trailing whitespace, such as a trailing newline. No other output inclusing whitespace is allowed. * Undefined behavior is allowed for input that does not contain any letters. --- **Example input:** ``` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae erat velit. Mauris gravida euismod libero ut tincidunt. Phasellus elit dui, consectetur et egestas in, aliquam vitae diam. Donec eget varius ante. Vestibulum cursus diam aliquet, egestas orci quis, placerat dolor. Proin vel nisi lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam erat volutpat. Etiam libero tortor, ornare id dui eget, posuere dignissim libero. Pellentesque commodo consequat volutpat. Integer hendrerit sapien libero, vel viverra augue facilisis sit amet. Quisque consectetur eget nisl quis dignissim. Ut lacinia pretium quam a placerat. Morbi sed interdum risus, nec pretium lectus. Morbi imperdiet est id accumsan molestie. Duis sed fermentum nisl. Nunc vitae augue mattis, dictum lectus vel, accumsan nisl. Sed ultricies adipiscing rhoncus. Vivamus eu lacus a enim venenatis eleifend. Praesent consectetur tortor non eleifend ultricies. Mauris et odio posuere, auctor erat at, fringilla est. Proin in vestibulum erat. Maecenas congue commodo ante vel varius. Sed tempus mi ut metus gravida, nec dictum libero dapibus. Morbi quis viverra elit. Ut pharetra neque eget lacus tincidunt dictum. Fusce scelerisque viverra tellus et pretium. Fusce varius adipiscing odio. Nulla imperdiet faucibus sem, at rhoncus ipsum adipiscing vitae. Phasellus imperdiet congue lacus et mollis. Nullam egestas mauris magna, et mollis lectus varius ut. Sed sollicitudin adipiscing dolor, vel elementum elit laoreet molestie. Aliquam nec nulla vel sem ultrices ullamcorper. Nullam nec felis magna. Duis sodales orci non justo aliquam tempus. Integer mi diam, tempor sed vulputate et, varius et nunc. Vestibulum sodales ipsum id mi pharetra, ut convallis mi accumsan. Sed dictum volutpat vestibulum. Quisque ac dolor sagittis, aliquam libero at, euismod enim. Nulla ullamcorper posuere nulla vitae varius. Nam at dolor non libero elementum pellentesque in in lorem. Fusce porttitor turpis in quam placerat varius. Donec lorem orci, condimentum eu sapien sit amet, aliquet commodo magna. Quisque sed lectus sit amet arcu euismod accumsan et non nunc. Phasellus placerat congue metus, feugiat posuere leo dictum quis. Sed ultricies feugiat eros dignissim bibendum. Mauris scelerisque consectetur libero eget varius. Aenean neque nunc, ullamcorper vitae orci in, auctor ornare sapien. Nam lacinia molestie imperdiet. Nam vitae mattis nibh. Vestibulum consequat tellus ac nisi sagittis pulvinar. Nullam mollis ornare quam, et venenatis leo porttitor sit amet. Nulla urna neque, dignissim non orci ut, volutpat ultrices erat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque vestibulum tellus nec eros faucibus porta. ``` **Example output:** ``` EITUSALNROMCDPVGQBFHJKWXYZ ``` Note: there is a 5 way tie between `KWXYZ` for that input. ## Edit: The competition is over! Thanks to everyone who participated. And now for the winner(s!): Both [Dennis' CJam](https://codegolf.stackexchange.com/a/32765/16180) and [isaacg's Pyth](https://codegolf.stackexchange.com/a/32759/16180) answers came in at a whopping 19 characters. Taking Dennis' advice, I'm going to mark his answer as accepted because his was the first to reach 19 characters. Honorable mentions go to [Ilmari Karonen's third-place Golfscript answer](https://codegolf.stackexchange.com/a/32764/16180) at 22 chars as well as [undergroundmonorail's 75-char Python answer](https://codegolf.stackexchange.com/a/32761/16180) that got the most upvotes. Once again, thanks to everyone who participated! [Answer] # Python 2 or 3 - ~~77~~ 75 bytes ``` f=lambda s:''.join(sorted(map(chr,range(65,91)),key=s.upper().count))[::-1] ``` I had an answer before that grabbed input from STDIN, but I realized it was technically invalid. I used `input()` which gets only a single line, but the question's example input implies that it should handle multiple lines at once. To meet spec, I turned my answer into a function that takes a string argument. To my surprise, it was two bytes smaller! It didn't occur to me that `print(...)` and `input()` were longer than `f=lambda s:` and `s`. This also makes the answer compatible with both Python 2 and Python 3. Originally it was only Python 3, because it used `input()` (which was called `raw_input()` in 2). Now that it's a function, it works in both. **Explained** ``` range(65,91) # The numbers 65 to 90 map(chr,range(65,91)) # Convert to ASCII s # The input string s.upper() # Convert to uppercase s.upper().count # Function literal for 'how many times the argument appears in the string' sorted(map(chr,range(65,91)),key=s.upper().count) # Sort by that function ''.join(sorted(map(chr,range(65,91)),key=s.upper().count)) # Concatenate to string ''.join(sorted(map(chr,range(65,91)),key=s.upper().count))[::-1] # Step through by -1 (i.e. reverse string) lambda s:''.join(sorted(map(chr,range(65,91)),key=s.upper().count))[::-1] # Make it a function (`return` is implicit for lambdas) f=lambda s:''.join(sorted(map(chr,range(65,91)),key=s.upper().count))[::-1] # Give it a name ``` [Answer] # CJam, ~~21~~ 19 bytes ``` qeu:A;'[,65>{A\-,}$ ``` [Try it online.](http://cjam.aditsu.net/) ### Example ``` $ cjam etaoin.cjam <<< "~XyxY YyxZ" YXZABCDEFGHIJKLMNOPQRSTUVW ``` (no newline) ### How it works ``` qeu:A; " Read from STDIN, convert to uppercase, save in the variable “A” and discard, "; '[, " Push an array of all ASCII characters before “[” (NUL to “Z”). "; 65> " Remove the first 64 characters (NUL to “@”). "; { " Sort the array of characters by the following mapping: "; A\ " Swap the character with the string saved in variable “A”. "; - " Remove all occurrences of the character from the string. "; , " Push the length of the string. "; }$ " "; ``` More occurrences means more characters get removed, so the most frequent characters appear at the beginning of the array. [Answer] # Bash, 65 bytes ``` (tr a-z A-Z;echo {A..Z})|fold -1|sort|uniq -c|sort -nr|tr -dc A-Z ``` ### Example ``` $ bash etaoin.sh <<< "~AbaB BbaC" BACZYXWVUTSRQPONMLKJIHGFED ``` ### How it works ``` ( # tr a-z A-Z # Turn lowercase into uppercase letters. echo {A..Z} # Print all uppercase letters. ) | # fold -1 | # Split into lines of length 1. sort | # Sort those lines (required for piping to uniq). uniq -c | # Print the frequencies of all lines. sort -nr | # Sort by frequency (reversed). tr -dc A-Z # Remove everything that's not an uppercase letter. ``` [Answer] # [Pyth 1.0.2](http://ideone.com/fork/aM7pmv), 19 20 ``` =ZUwsVm;dSm[cZkk)UG ``` Try it here: <http://ideone.com/fork/YlWpEJ> Learn more about Pyth here: <http://esolangs.org/wiki/Pyth> Example: > > Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input. > > > Gives: > > TENOHARSIULGFPYDCBWQMZXVKJ > > > Explanation: `=ZUw`: Convert input to uppercase and store in Z. `sV`: Print the sum of the reverse of `m;d`: The last entries of `S`: Sorted by their first entry, in increasing order `m[cZkk)`: The lists [count of k in Z, k] `UG`: For k in the uppercase letters. Rough Python equivalent: ``` G='abcdefghijklmnopqrstuvwxyz' Z=copy(upper(input())) print(_sum(rev(_map(lambda d:d.pop(),sorted(_map(lambda k:_list(count(Z,k),k),upper(G))))))) ``` --- This is not entry, I just thought people might like to see it. In Pyth 1.0.4, the following program is a solution in 10 characters: ``` JUwo_cJNUG ``` Explanation: `JUw`: Convert input to uppercase and store in J. `o`: (Print) Sort by `_cJN`: -1\*(count of N in J) `UG`: Over N in the uppercase letters. It is not a legal solution because several of the changes from Pyth 1.0.2 to 1.0.4, including the addition of the `o`, sort by, function, were in response to this problem. [Answer] # Javascript (*ES6*) 119 117 **Edit:** (-2) Removed the need for `toUpperCase` using a case-insensitive RegEx in the `split` call. ``` a=prompt(f=x=>a.split(RegExp(x,'i')).length) alert([...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'].sort((b,c)=>f(c)-f(b)).join('')) ``` **Alternative (same length):** Condensed the sort and character counting into a single function. ``` a=prompt() alert([...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'].sort(f=(b,c)=>c?f(c)-f(b):a.split(RegExp(b,'i')).length).join('')) ``` # As a function: 105 104 **Edit:** (-1) Condensed the sort and character counting into a single function. ``` F=a=>[...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'].sort(f=(b,c)=>c?f(c)-f(b):a.split(RegExp(b,'i')).length).join('') ``` [Answer] # GolfScript, 22 chars ``` :?91,+-26>{.32+]?\-,}$ ``` [Try it online.](http://golfscript.apphb.com/?c=IyBDYW5uZWQgdGVzdCBpbnB1dDoKOyJCYXNlZCBvZmYgRVRBT0lOIFNIUkRMVSwgeW91ciBjaGFsbGVuZ2UgaXMgdG8gd3JpdGUgdGhlIHNob3J0ZXN0IHByb2dyYW0gb3IgZnVuY3Rpb24gaW4gYW55IGxhbmd1YWdlIHRoYXQgb3V0cHV0cyB0aGUgMjYgbGV0dGVycyBvZiB0aGUgRW5nbGlzaCBhbHBoYWJldCBiYXNlZCBvbiB0aGVpciBmcmVxdWVuY3kgaW4gdGhlIGlucHV0LiBZb3VyIHByb2dyYW0vZnVuY3Rpb24gd2lsbCByZWNlaXZlIGFzIGlucHV0IGEgc3RyaW5nIG9mIHRleHQsIHdoaWNoIHdpbGwgY29udGFpbiBvbmUgb3IgbW9yZSB1cHBlcmNhc2UgYW5kL29yIGxvd2VyY2FzZSBsZXR0ZXJzIGFuZCBtYXkgYWxzbyBjb250YWluIHB1bmN0dWF0aW9uLCBudW1lcmFscywgc3ltYm9scywgYW5kIG90aGVyIG5vbi1hbHBoYWJldGljIGNoYXJhY3RlcnMuIFRoZSBwcm9ncmFtL2Z1bmN0aW9uIG11c3Qgb3V0cHV0IG9ubHkgdGhlIDI2IFVQUEVSQ0FTRSBsZXR0ZXJzIG9mIHRoZSBFbmdsaXNoIGFscGhhYmV0LCBpbmNsdWRpbmcgdGhvc2UgdGhhdCBkbyBub3QgYXBwZWFyIGluIHRoZSBpbnB1dCwgb3JkZXJlZCBmcm9tIG1vc3QgdG8gbGVhc3QgZnJlcXVlbnQgYmFzZWQgb24gaG93IG1hbnkgdGltZXMgdGhleSBhcHBlYXIgaW4gdGhlIGlucHV0LiBUaGUgZnJlcXVlbmN5IGlzIGNhbGN1bGF0ZWQgY2FzZS1pbnNlbnNpdGl2ZWx5LCBidXQgdGhlIG91dHB1dCBtdXN0IGJlIGluIHVwcGVyY2FzZS4gSWYgdHdvIG9yIG1vcmUgbGV0dGVycyBoYXZlIHRoZSBzYW1lIGZyZXF1ZW5jeSwgdGhleSBtYXkgYmUgaW4gYW55IG9yZGVyLiBObyBvdGhlciBvdXRwdXQsIHN1Y2ggYXMgd2hpdGVzcGFjZSwgaXMgYWxsb3dlZC4iCgojIEFjdHVhbCBwcm9ncmFtIGNvZGU6Cjo%2FOTEsKy0yNj57LjMyK10%2FXC0sfSQ%3D) ### Explanation: * `:?` assigns the input string to the symbol `?`. (I use a punctuation symbol so that the following number `91` is not parsed as part of the symbol name.) * `91,` constructs a list of the numbers from 0 to 90 (ASCII code of `Z`). * `+` appends this list to the input string, thereby converting it from an array of ASCII codes to a string (and conveniently also removing the input string from the stack). * `-26>` takes the last 26 characters of this string, producing a string containing the uppercase ASCII letters from `A` to `Z`. * The `{ }$` applies the code block to all the characters in the input string, and sorts those characters according to the result. * Inside the code block, `.` duplicates the character and `32+` converts the copy from uppercase to lowercase. The `]` collects these two characters into an array, `?\-` takes the input string stored in `?` and removes all occurrences of the characters in the array from it, and `,` counts the length of the remaining string, which will be the sort key. The characters will be sorted in ascending order by this key, and thus in descending order by number of occurrences. [Answer] # Haskell, 110 bytes ``` import Data.List import Data.Char a%f=compare(f a).f f t=sortBy(% \c->length$filter((/=c).toUpper)t)['A'..'Z'] ``` Example usage: ``` λ> f "Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input." "ETNAHORISULFGPBCDYMQWJKVXZ" ``` [Answer] ## Ruby 2.0, 53 characters **EDIT**: Fixed to work correctly with multiline strings, thanks @durron597! ``` f=->s{$><<(?A..?Z).sort_by{|c|-s.upcase.count(c)}*''} ``` Creates a function called `f` which can be used as follows: ``` f['jackdaws love my big sphinx of quartzzz'] ``` Prints to STDOUT: ``` AZOSICGHEJKLMBFPQRDTUVWXYN ``` [Answer] ## Perl, ~~54~~ 46 bytes **UPDATE:** after further optimizations it could be squeezed to **46** bytes: (thx [dennis](https://codegolf.stackexchange.com/users/12012/dennis) for `-n`/`{}` hack; [chinese perl goth](https://codegolf.stackexchange.com/users/1229/chinese-perl-goth) for `<=>`->`-` hack) ``` s/./$h{uc$&}++/eg}{say sort{$h{$b}-$h{$a}}A..Z ``` It is to be run with run with `perl -nE` Original solution (does not need special Perl options): ``` s/./$h{uc$&}++/egfor<>;print sort{$h{$b}<=>$h{$a}}A..Z ``` Verified in Perl 5.8.3, 5.14.2 *If you get a warning, separate `eg` and `for` with a space (+1 char), if you mind* example usage: ``` $ python -c 'import this' | perl -le 's/./$h{uc$&}++/egfor<>;print sort{$h{$b}<=>$h{$a}}A..Z' 2>/dev/null ETAISONLRHPBUCDYMFGXVWKZJQ ``` EXPLANATION: On each character (`.`) of each input line (`for<>`), apply a substitution "pattern", which in fact is evaluated as an expression (`e` flag of the `s///`), that increments an upcased (`uc`) character (`.`/`$&` is shorter than more obvious `(.)`/`$1`) count in the (uninitialized) hash (`%h`). Then, the letter frequency hash is used in a sort comparison function to print out upper-case alphabet in the right order. [Answer] # R, 123 bytes The code is improved thanks to the suggestions by @RichieCotton. ``` text <- "Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input." f=function(x){b=plyr::count(toupper(strsplit(x,"")[[1]]));c=merge(LETTERS,b,all.x=T);paste(c[order(-c$freq),1],collapse="")} f(text) ``` Output: ``` > f(text) [1] "ETNAHORISULFGPBCDYMQWJKVXZ" ``` [Answer] # AppleScript, 278 I noticed that `"a" = "A"` is true in AppleScript. I can use this in code golf, but the rest of the script is too wordy. I used AppleScript 1.8.3. This defines a function `f`. If you add `f("a string")` at the bottom of the script and run it in the Script Editor, it will show the result. ``` on c(n) ASCII character(64+n) end on f(s) set{a,r}to{{},""} repeat with i from 1 to 26 set j to 0 repeat with b in s if b&""=c(i)then set j to j+1 end set a to a&j end repeat with j from 0 to(count s) repeat with i from 1 to 26 if a's item i=j then set r to c(i)&r end end r end ``` Formatted and commented: ``` -- Returns nth letter of alphabet. on c(n) ASCII character (64 + n) end c -- Returns letters in s sorted by frequency. on f(s) -- a: list of letter counts -- r: resulting string set {a, r} to {{}, ""} -- For each letter from A to Z, -- count letters in string s. repeat with i from 1 to 26 set j to 0 repeat with b in s -- Can't use b = c(i), because -- b is a reference to a string -- and = never dereferences its -- operands. Get contents of b, -- here by coercing b to string. if b & "" = c(i) then set j to j + 1 end repeat -- Set item i of a to count j. set a to a & j end repeat -- Sort letters by frequency. Do a counting sort -- because AppleScript lacks a sort command. repeat with j from 0 to (count s) repeat with i from 1 to 26 if a's item i = j then set r to c(i) & r end repeat end repeat r end f -- Example call: f("Now is the time for all good men to come to the aid of their country.") -- Result: "OTEIRNMHLFDCAYWUSGZXVQPKJB" ``` [Answer] # C++, 185 183 179 177 bytes Not expected to win, of course (can C++ ever win?) but a fun exercise nonetheless. ``` #include <algorithm> #include <stdio.h> int f[256],p;main(){for(p=65;p<91;p++)f[p]=p;while(~(p=getchar()))f[p&95]+=256;p=256;std::sort(f,f+p);while(p--)f[p]&95&&putchar(f[p]);} ``` Explanation: ``` #include <algorithm> // for std::sort #include <stdio.h> // for getchar, putchar int f[256],p; // declare an array of count-prefixed chars, and a counter main(){ for(p=65;p<91;p++) // 65 == 'A', 91 == the character after 'Z' f[p]=p; // set the character for the slot while(~(p=getchar())) // read characters until EOF f[p&95]+=256; // increment the packed count for the character stripped of the 'lowercase bit' p=256; // start a countdown std::sort(f,f+p); // sort the array while(p--) // do the countdown f[p]&95 && // if the masked-off character is set... putchar(f[p]); // print it } ``` [Answer] ## VBScript 181 109 Updated to use a completely different algorithm. Beats JavaScript! Pretty: ``` dim b(99):i=ucase(inputbox(k)) for y=65to 90 c=chr(y) a=len(replace(i,c,k)) b(a)=c+b(a) next msgbox join(b,k) ``` Golfed: ``` dim b(99):i=ucase(inputbox(k)):for y=65to 90:c=chr(y):a=len(replace(i,c,k)):b(a)=c+b(a):next:msgbox join(b,k) ``` [Answer] ## J 41 35 Bytes ``` (u:65+i.26)([\:[#/.~@,e.~#])toupper ``` Demo: ``` i=: 'This is a test to see whether this is still working' (u:65+i.26)([\:[#/.~@,e.~#])toupper i STIEHLORWAGKNBCDFJMPQUVXYZ ``` Explanation: ``` (u:65+i.26) & ( [ \: [ #/.~@,e.~#]) toupper) ) ABCDE... | | | | uppercase the right argument | | | \copy from right only member from left | | \append the left argument | \ Afterwards Count apperances of each letter \ Sort the left according to the appearances ``` The key is to append the left array, such that all letters are available, and already in order. A funny consequence of using a noun as third tine to the fork is that it works as verb as well as as phrase. [Answer] ## Groovy - ~~130~~ ~~123~~ ~~115~~ ~~112~~ ~~98~~ 92 As per @cfrick's advice (twice!): ``` f={('A'..'Z').collectEntries{c->[c,it.grep(~/(?i)$c/).size()]}.sort{-it.value}*.key.join()} ``` A small test (shamelessly stolen from @jpjacobs): ``` assert f('This is a test to see whether this is still working') == 'STIEHLORWAGKNBCDFJMPQUVXYZ' ``` And the proposed test is also passing [Answer] ## SAS - 217 (I think) Input should be placed on the line after the cards4 statement, or on the appropriate punch cards for your system. I think this approach saves a few characters vs. attempting to quote the input. ``` data a; input; S = upcase(compress(_INFILE_,,'ak')); do i=1 to length(S); l=substr(S,i,1); output; end; cards4; ;;;; run; proc sql; select l into :o separated by '' from (select l, 1/count(l) as f from a group by l) order by f; quit; ``` I'm aware that this doesn't meet the full spec, as it only returns characters that appear in the input string. I might need to rethink this a bit. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes ``` ØAŒuċ¥@ÞU ``` # Explanation ``` ØAŒuċ¥@ÞU Main Link Þ Sort ØA The uppercase alphabet by Œuċ¥@ number of occurrences in the input: Œu Uppercase ċ Count occurrences ¥ Grammar: Last two links as a dyad @ Swap arguments U Reverse (because sort sorts up) ``` This reads as "sort the uppercase alphabet by the number of occurrences in the input uppercased, reversed", which is a rather literal translation of the challenge :P [Try it online!](https://tio.run/##XVZLjhxFEN3PKXLBslR3sGyQkLAFQvY@Oiu7O6z81OSnJc7AjhUrVtyAG9hwruFF/qrG0syopyszPu@9eFGfjbW/vbx8/fPNl3/@@6N8@fvf37/7@tfHl5eXn0I0TvGeilNbsCGqxFmRM3lROvhkdDa5REUb75w0@5sylvOqfo5kkvFZPTiTUSYSPrZH76lETuoW6cEbKVM4ubApyxcTgypZZfaat@IlzJ0SiiuphlVb4dd5TVbmZlKmpNgviiw/F3I96cbkVvUueKPlFAqgyAhFPptVfcI1vhSLznSJCd/L@RZC2htxQ9SsnlHkonZLunZSoZAmA3tpS3lOrCyqKmlVby0lZNmz9J9Jc2aVguaQnguQQqc5RFL4g0w4spsoTZULk/Ih5UhL/Q4wmD2HpO7sjCcTEPtN77ABGmzJOwGn77PU3iFEYPwsqNxTNIo3wa0igLghFRMFmxtqTjwuoRngjGoMijQox4GT0LBGwnOuH3HohvLuxm/RRNCSaGfje6SlAvLgh4loksoN4a4AwQKiNOWzql8AaUt1olNYQl22An4UuaqPWQF89oBojyYzWKs40CRlfXof4gVImw3IZRM3nIHQCogTBYxrg6V2mh2Q3lh0lLJARVoXl8grF6woBEp5J7VI2KuJICIjiNS4qg/F66611qejnEUoG@s8UwkeyxG3Xf0V4YrNkTWbdB6feA9eS32f@EFOhF@kc5GtMh58PYyHGJAGI2H4ChJO03YGs8kAivLz5JFyjiE6DxuHIQwUWrRcqwIjKOYaURZbS4LQ0HyV/ZyfCj8CGo3KkhRxO2lIxq1poo5f6z0bt6MnxzLw0EOZhtDYGgg2RW8Q2OUgrYpjKKyZCvSx36F2DA/ui66qlhpy01B62FX9UJI2Cr8WAq4yHOFyt5s8BLM@tcPDPA6qBDcRgWBz6OgKAKVYKMYBzTwY7S56ul@Vc/a4I0iHsJWP/yFGzE9P5qY3ucaho5sHbvPcFF4rueSGeZKHcKOygb5THdXN2tgCj67w6reW4P8tbJ@F4T/Cka@dyzW02qUFMdcSdYjoZRYsx6/GjlrHTIWNELhZrOj0c0k5TBdvGjkMB2IRi17qA1lF6OlR7F4yQWHibr1hMRGM5iuPH7kaCxh0RBuKWUSEgPxBFT08GdPagOtiHBZ4kv76NGyM9FiQdOPmAqOPLmIZprHsZJKHdE54TXvu0FZrGWPzQeyu756KVo97cLafLbxNqZUFPvQO0FCZTDf8AezLgVrhXGwjV1ua9XJlp27djYc2yrD8422g78059Z3nAY9w1VU57iiKukxEpj8KeWiuEXjMxiyxj0b1DLiTKTfGtwM4a8KgS1ziW6Mdx4Hbab2oC5D0m9DZXfHsDGdPHZAfbxMYCRiy@Hp1HSl7eUVpI7FKvL6iNHvtu7nB2Lgd@20M22EH7XkL1FYMtsjl/vodZm7q7mAQZH0rGXpUe7EPRtY5lN0seikihOohx4IRMA/NHKu76xb3WtfLCUrhrjZbZB7HxExzaKvibR1IzdII5SDA7TXnpdsdSThERdUUATzLcnNBtI39QKBH2IgMqos064SIV28wp/XUAamvgcL7dGjpjdb/AQ "Jelly – Try It Online") This challenge was linked to [Jelly HyperTraining](https://chat.stackexchange.com/rooms/57815/jelly-hypertraining) where we solved the challenge. I posted this because I was the first to reach 10 bytes. -1 byte thanks to Erik the Outgolfer (JHT teacher) [Answer] ## VBScript 157 156 bytes Edit: changed msgbox(p) to msgbox p More readable: ``` s=ucase(InputBox(z)) 'z is empty. L=len(s) Dim a(255) for i=1to L x=asc(mid(s,i)) a(x)=a(x)+1 next for t=0to L For i=65To 90 If a(i)=t then p=chr(i)&p next next msgbox p ``` Golfed: (155 characters + 1 carriage return) ``` s=ucase(InputBox(z)):L=len(s):Dim a(255):for i=1to L:x=asc(mid(s,i)):a(x)=a(x)+1:next:for t=0to L:For i=65To 90:If a(i)=t then p=chr(i)&p next:next:msgbox p ``` I had it at 171 earlier with code that I found more interesting, but [comfortablydrei's sorting method](https://codegolf.stackexchange.com/a/32770/15589) is shorter and requires len(s), which makes a "for" shorter than the "while" for the first loop. (yawn) ``` 's=UCase(InputBox(Z))&8 'just need any extra character. 0-7 don't work because &7 is octal s=UCase(InputBox(Z)) 'nevermind Dim a(999) While Len(s) x=Asc(s) 'returns ascii of first char a(x)=a(x)-1 'going negative saves a character later... s=Mid(s,2) 'doesn't care if you run out of string Wend for j=1 to 26 'this used to be While Len(p)<26 For i=65To 90 If a(i)<a(y) Then y=i 'it is barely not worth it to do a(i)+a(i+32)>a(y) here to skip the ucase() above Next p=p&Chr(y) a(y)=1 'if I didn't go negative this would have to be -1. arrays default to 0. Next MsgBox(p) ``` [Answer] # J - ~~38~~ 35 char A function taking input on the right as a string. Not a winner, but it was fun to write. ``` (u:65+i.26)([\:[#/.~@,e.~#])toupper ``` Explained: * `toupper` is a verb in the standard library that upcases a string. That then becomes the right argument of the verb, while the left argument is the alphabet: ASCII codepoints 65 to 90. * `[` and `,e.~#])` selects (`#`) those letters in the right arg (`]`) that are elements of (`e.~`) the left, and then prepends (`,`) the left arg (`[`). To wit, we keep only the uppercase chars, and add a single copy of the alphabet to the end, to make sure we catch them all. * `#/.~@` then gives the frequencies of each character. It so happens that this is given in alphabetical order, so right afterwards we can downsort (`\:`) the alphabet (the left argument `[`). A quick lazy example below. Feel free to try it for yourself at [tryj.tk](http://tryj.tk/). ``` (u:65+i.26)([\:[#/.~@,e.~#])toupper 'Based off ETAOIN SHRDLU, your challenge is to write the shortest program or function in any language that outputs the 26 letters of the English alphabet based on their frequency in the input.' ETNAHORISULFGPBCDYMQWJKVXZ ``` [Answer] ## T-SQL 178 Basically, this is my VBScript solution but implemented in SQL. This is XML output abuse to concatenate a column. In practical use, it can be joined to an outer table to emulate `GROUP_CONCAT` functions in MySQL and others. Declaring the `@` variable: ``` DECLARE @ CHAR(1024)= 'enter your text here'; ``` Code: ``` with y AS( SELECT UPPER(@)i,0l,91y UNION ALL SELECT i,len(replace(i,char(y-1),'')),y-1 FROM y WHERE y>65 ) SELECT LTRIM( ( SELECT char(y) FROM y WHERE y<91 ORDER BY l FOR XML PATH('')) ) ``` [Answer] # Perl, 78 bytes ``` undef$/;$i=<>;$r{$i=~s/$_//gi}.=$_ for A..Z;print$r{$_}for sort{$b<=>$a}keys%r ``` * Only the 26 uppercase ASCII letters without any white space are output in frequency order. * Tied characters are given in alphabetic order. Result for the example in the question: ``` EITUSALNROMCDPVGQBFHJKWXYZ ``` **Ungolfed:** ``` # read input # ---------- undef $/; # disable input separator $i = <>; # $i holds the complete input as one string # analyze # ------- # For each uppercase letter (A upto Z) its occurences are counted # via the number of substitutions made by s/$_//gi. The lowercase # letter is included via modifier "i". # # The occurrence count is then used as key for hash %r. # The uppercase letter is appended to the value of that hash entry. $r{$i =~ s/$_//gi} .= $_ for A..Z; # output # ------ # The hash keys are sorted numerically in reverse order by # the specified sort function. print $r{$_} for sort {$b<=>$a} keys %r ``` [Answer] # PHP - 105 bytes ``` <?preg_filter(~‹§æ“Ö¢‹ö,'$f[$0&fl]++',join('',range(a,z)).$argv[1]);arsort($f);foreach($f as$l=>$F)echo$l; ``` Here's a hexdump, cause of the special characters: ``` 0000000 3c 3f 70 72 65 67 5f 66 69 6c 74 65 72 28 7e dc 0000010 a4 be d2 85 a2 dc 9a 2c 27 24 66 5b 24 30 26 df 0000020 5d 2b 2b 27 2c 6a 6f 69 6e 28 27 27 2c 72 61 6e 0000030 67 65 28 61 2c 7a 29 29 2e 24 61 72 67 76 5b 31 0000040 5d 29 3b 61 72 73 6f 72 74 28 24 66 29 3b 66 6f 0000050 72 65 61 63 68 28 24 66 20 61 73 24 6c 3d 3e 24 0000060 46 29 65 63 68 6f 24 6c 3b 0000069 ``` And a slightly less golfed version: ``` <? preg_filter( // regular expression "#[A-z]#e", // matches every letter + 'eval' flag '$f[$0&fl]++', // so this code runs for every letter // $f is an array whose indices are uppercase letters // and whose values represent the number of occurences // lowercase is converted to uc with the bitwise and // fl is 11011111 in binary, every bit except for 32's is set join('', range(a,z)) // adding abcdefghijklmnopqrstuvwxyz to the input .$argv[1]); // because not all letters have to appear in the input arsort($f); // sort $f in reverse, maintaining indices foreach($f as$l=>$F) // echo$l; // print each index in order ``` Example: ``` $ php etaoin_shrdlu.php "This function sorts an array such that array indices maintain their correlation with the array elements they are associated with." ATIRESHNOCYUWMDLFXZBVGPQKJ ``` [Answer] # C# in LINQPad - 203 Bytes I took a different approach to the answer of Logan Dam. I made sure first that every character in the input string is sorted by its appearance and only exists once in the output string. After that I added every missing character from the alphabet to the output string. ``` void e(string i){var a="";foreach(var d in i.ToUpper().GroupBy(x=>x).OrderByDescending(u=>u.Count()))if(d.Key<91&&d.Key>64){a+=d.Key;}for(int x=65;x<91;x++)if(!a.Contains((char)x)){a+=(char)x;}a.Dump();} ``` Sadly it wouldn't beat Logan Dam's answer if I would have made in Visual Studio. More readable version: ``` void e(string i) { var a = ""; foreach (var d in i.ToUpper().GroupBy(x => x).OrderByDescending(u => u.Count())) { if (d.Key < 91 && d.Key > 64) { a += d.Key; } } for (int x = 65; x < 91; x++) { if (!a.Contains((char)x)) { a += (char)x; } } a.Dump(); } ``` [Answer] ## C# (and LINQ) 255 226 210 Bytes Using Patrick Huizinga's advice, the query syntax is now shorter: ``` namespace System.Linq{class P{static void Main(string[]a){Console.Write((from c in(a[0]+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").ToUpper()where c>'@'&&c<'['group c by c into g orderby-g.Count()select g.Key).ToArray());}}} ``` **Explanation:** ``` Console.Write( (from c //declare our range variable in (a[0] + "ABCDEFGHIJKLMNOPQRSTUVWXYZ").ToUpper() //declare the datasource where c > '@' && c < '[' //include only letters group c by c into g //run of the mill group by orderby -g.Count() //order by descending select g.Key //we only want the actual letters ).ToArray() //mash it all into an array ); ``` **Equivalent method syntax (217):** ``` namespace System.Linq{class P{static void Main(string[]a){Console.Write((a[0]+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").ToUpper().GroupBy(c=>c).OrderBy(c=>-c.Count()).Where(c=>c.Key>'@'&&c.Key<'[').Select(c=>c.Key).ToArray());}}} ``` **Original post:** > > > ``` > namespace System.Linq{class P{static void Main(string[]a){(a[0]+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").ToUpper().GroupBy(c=>c).OrderByDescending(c=>c.Count()).Where(c=>c.Key>'@'&&c.Key<'[').ToList().ForEach(c=>Console.Write(c.Key));}}} > > ``` > > This is my first ever submission and I should be doing things at work > but this just looked like so much fun because I felt like I could > actually participate for once. > > > **Explanation:** > > > > ``` > (a[0] + "ABCDEFGHIJKLMNOPQRSTUVWXYZ") //ensure each character appears once > .ToUpper() > .GroupBy(c => c) //get access to .Count() > .OrderByDescending(c => c.Count()) > .Where(c => c.Key > '@' && c.Key < '[') //exclude anything other than letters > .ToList() //Only lists have a .ForEach() :( > .ForEach(c => Console.Write(c.Key)); //print output > > ``` > > I never use the method syntax for LINQ so this was a learning > experience for me :) also thinking about it now I could save 2 bytes > by replacing the character literals with their integer counterparts, > but, meh. > > > Shortened thanks to tips from ProgramFOX and Num Lock :) > > > The equivalent query syntax (slightly longer): > > > > ``` > (from c in (a[0]+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").ToUpper() where c>'@'&&c<'[' group c by c into g orderby g.Count() descending select g.Key).ToList().ForEach(c=>Console.Write(c)); > > ``` > > [Answer] # C++ ~~701~~ ~~322~~ 232 bytes First version 701 bytes (idiomatic STL usage) ``` #define _HAS_TRADITIONAL_STL 1 #include <numeric> #include <iostream> #include <iterator> #include <string> #include <algorithm> #include <functional> #include <map> #include <set> #define ALL(x) x.begin(), x.end() using namespace std; typedef istream_iterator<char> iic;typedef pair<int, char> pic;map<char, int> c;set<pic> d; void f1(char x) {c[x]--;} void f2(const pic &p) {d.insert(make_pair(p.second, p.first));} int main(){string s(26, 0);stdext::iota(ALL(s), 65);copy(ALL(s), ostream_iterator<char>(cout));transform(iic(cin), iic(), back_inserter(s), toupper);for_each(ALL(s), f1);for_each(ALL(c), f2);transform(ALL(c2), ostream_iterator<char>(cout), select2nd<pic>());} ``` Expanded clean version : ``` #define _HAS_TRADITIONAL_STL 1 #include <numeric> #include <iostream> #include <iterator> #include <string> #include <algorithm> #include <functional> #include <map> #include <set> using namespace std; typedef istream_iterator<char> iic; map<char, int> counts; set<pair<int, char> > counts2; void docount(char ch) { counts[ch]--; } void toCounts2(const pair<char, int> &p) { counts2.insert(make_pair(p.second, p.first)); } int main() { string s(26, 0); stdext::iota(s.begin(), s.end(), 65); transform(iic(cin), iic(), back_inserter(s), toupper); for_each(s.begin(), s.end(), docount); for_each(counts.begin(), counts.end(), toCounts2); transform(counts2.begin(), counts2.end(), ostream_iterator<char>(cout), select2nd< pair<int, char> >()); } ``` The idea is to demonstrate a "proper" C++ program without any hacks. Ignore the boilerplate and the fact that this only compiles on VC++ **Explanation :** We fill A to Z into a string with **iota()**, this ensures that when we count the occurrences, each character appears even if it's not in the input. **transform()** copies character by character from standard input and puts it into the end of s after calling **toupper()** on each one The count of each character is decremented in the map (by maintaining negative counts we can have descending sort without extra code) The counts map entries are copied to a set of pairs, swapping (char, count) to (count, char). Since sets are ordered, we get them sorted by decreasing frequency count Finally we copy the set's content to standard out, using transform, and using **select2nd()** to pick out only the second member of the pair. The code is fairly readable. A C++11 solution would look much prettier, since we can use lambdas C++11 version - no need of lambdas, but auto and range based for makes things very clean (come to think of it you can do very similar with regular C++98) ``` #include<iostream> #include<iterator> #include<map> #include<set> using namespace std;int main(){istream_iterator<char> b(cin),e;map<char,int> c;set<pair<int,char>> d;for(char i='A';i<='Z';++i){--c[i];}for(auto i=b;i!=e;++i){c[toupper(*i)]--;}for(auto p:c){d.insert(make_pair(p.second,p.first));}for(auto p:d){cout<<p.second;}} ``` Expanded version : ``` #include <iostream> #include <iterator> #include <map> #include <set> using namespace std; int main() { istream_iterator<char> b(cin), e; map<char, int> c; set<pair<int, char>> d; for(char i = 'A'; i <= 'Z'; ++i) {--c[i];} for(auto i = b; i != e; ++i) {c[toupper(*i)]--;} for(auto p : c) { d.insert(make_pair(p.second, p.first)); } for(auto p : d) { cout << p.second; } } ``` Next iteration (why read from stdin when we have argv): ``` #include <set> #include <iostream> int c[256];int main(int n, char **s){std::set<std::pair<int,char>> d;while(*s[1]){c[toupper(*s[1]++)]--;}for(n=65;n<92;++n){d.insert(std::make_pair(--c[n],n));}for(auto p:d){std::cout<<p.second;}} ``` Expanded version: ``` #include <set> #include <iostream> int c[256]; int main(int n, char **s) { std::set<std::pair<int, char>> d; while (*s[1]) { c[toupper(*s[1]++)]--; } for (n = 65; n < 92; n++) { d.insert(std::make_pair(--c[n], n)); } for (auto p : d) { std::cout << p.second; } } ``` [Answer] ## C++ 377 Implements qsort using letter counts in array n to sort alphabet in array A. Run via command line: `golf.exe < in.txt` ``` int n[26],c,k,N; char A[26]; int C(const void*a,const void*b) { int i=(int)(*(char*)a -'A'); int j=(int)(*(char*)b -'A'); return n[j]-n[i]; } int main() { for(;k<26;k++) { A[k]=k+'A'; } N=sizeof(A); c=getchar(); while(c>0) { c=toupper(c); c=c-'A'; if(c>=0&&c<26)n[c]++; c=getchar(); } qsort(A,N,1,C); for(k=0;k<N;k++) { putchar(A[k]); } return 0; } ``` [Answer] # C, 117(119) bytes ``` x[256];m=1;char c;main(){while(c=getchar()+1)++x[c-1&95];for(;m=x[++c]<x[m]?m:c;x[m<65|m>90||c?m*!c:putchar(m)]=-1);} ``` * Some inputs containing ASCII codes >= 128 will incorrectly increase letter frequencies. To fix this, replace the constant `95` with `223`, at a cost of 1 extra byte. * This will terminate early on inputs containing the character with ASCII code 255. To fix this at the cost of 1 extra byte, change `char c;` to just `c;` and `++c` to `c=c+1%255`. [Answer] **PowerShell - 139 chars** First, I'm not an PowerShell expert. Pretty sure there are shorter than this. But was happy with it and decided to share. ``` $a = Read-host $b = ($a.ToUpper() -replace '[^A-Z]','').ToCharArray() + (65..90|%{[char[]]$_})|Group|sort Count -desc|%{$_.Name} -join $b ``` --- ***How it works:*** ``` $a = Read-host # read from stdin and save into a string var $a $a.ToUpper() # Convert the string to UPPERCASE -replace'[^A-Z]','' # Remove all non A-Z characters from the str (...).ToCharArray() # Convert the inner object (string) to a Char Array + (65..90|%{[char[]]$_}) # Create another char array with A-Z chars expanded, # and append it to the previous one. |Group # Group the char array by value for each element, # consolidates them and count each char occurrence. Example: # Count | Name # ----- | ----- # 4 | B # 1 | F # 2 | C # .. | .. # |sort Count -desc # Sorts the previous hash-table by the 'Count' column # in desc ordering |%{$_.Name} # Grab only the 'Name' column from the previous sorted hash-table. # The retuslt obj will be a simple char array again, # with the letters in the desired order $b = (...) # Saves the resulting char array into a new variable $b -join $b # join the resulting char array elements into a single # string, and print it to stdout. ``` [Answer] # [Ceylon](http://ceylon-lang.org/), 98 bytes ``` String f(String s)=>String(('A':26).sort(byDecreasing((Object c)=>s.uppercased.count(c.equals)))); ``` [Answer] # APL, ~~26~~ 20 characters ~~`⎕a[⍒+/⎕a∘.=('\w'⎕r'\u0')⍞]`~~ `⎕a[⍒+/⎕a∘.=1(819⌶)⍞]` -6 thanks to Adam. ]
[Question] [ A *palindrome* is some string that is spelled the same way both backwards and forwards. For instance, 'Eva, can I stab bats in a cave?' is a palindrome (EVACANISTAB | BATSINACAVE) For this code golf, using the language of your choice, determine if a given string is a palindrome or not. *Edge Cases:* * Punctuation is not counted towards palindrominess. * Control characters are not counted towards palindrominess. * Whitespace is not counted towards palindrominess. * Numbers are counted towards palindrominess. * Case in this challenge is not counted towards palindrominess. * There is no limit to the length of strings to evaluate, except for what is imposed by your language of choice. * For this challenge, limit yourself to the ASCII character set. *Technical Requirements:* * Only method bodies are needed; additional things like method signatures, data structure declarations, etc. do not count towards the victory requirement. * Code must compile or interpret without compile-time errors or exceptions. * Code must not throw any unhandled exceptions or crash. (Almost needless to say. Almost.) * Code must return some value indicating palindrominess. The data type depends on the language you use (e.g. a C# user might use a `bool`, whereas a JavaScript user could use a `var`.) * You may not write your own interpreter that performs this task as a 'native' capability so you can 'golf' a near-winning score. (Hopefully needless to say.) *Victory Condition:* * The shortest code in characters wins. # *Current Leader: tmartin (k, 25 characters)* ...Want the magic green check mark by *your* answer? Beat this guy's answer! [Answer] ## K, 25 ``` {x~|x:_x@&x in,/.Q`a`A`n} ``` . ``` k){x~|x:_x@&x in,/.Q`a`A`n}"Eva, can I stab bats in a cave?" 1b ``` [Answer] ## Perl, 26 char ``` s/_|\W//g;uc eq reverse uc ``` Evaluates to 1 when `$_` is a palindrome, `""` (one of Perl's false values) when it is not. Sample usage: ``` sub palin { s/_|\W//g;uc eq reverse uc } while (<DATA>) { chomp; print "$_ => ",palin()?"yes":"no","\n"; } __DATA__ Eva, can I stab bats in a cave? A man, a plan, a canal. Panama! Madam, I'm Adam Carolla. 757 Boeing 757 A man, a plan, a big shovel, a canal. Panama! A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal >> __Panama__ ``` output: ``` Eva, can I stab bats in a cave? => yes A man, a plan, a canal. Panama! => yes Madam, I'm Adam Carolla. => no 757 => yes Boeing 757 => no A man, a plan, a big shovel, a canal. Panama! => no A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal >> __Panama__ => yes ``` [Answer] ### C# 82 only :) ``` var x=s.ToLower().Where(char.IsLetterOrDigit);return x.SequenceEqual(x.Reverse()); ``` Couldn't resist the temptation of writing a boilerplate-free program in my favorite language. A test is available here: <http://ideone.com/8bwz7z> [Answer] ### GolfScript, ~~36 34 31~~ 30 characters ``` {0"0:A[a{"@{>^}+/},{32|}%.-1%= ``` Similar algorithm to [my previous (Javascript) solution](https://codegolf.stackexchange.com/a/11158/7209). `0"0:A[a{"@{>^}+/` -- Optimised by Peter Taylor and Howard. My version was `"/9@Z"{1$<},,2%\;`. Howard donated function concatenation and Peter Taylor donated XOR for modulo-2. It's basically a generic method of comparing if the value is in a sequence of ranges. `{.96>32*-}%` (11 characters) is not really an improvement over Javascript's `.toUpperCase()` (14 characters), especially since it mangles some weird punctuation that follows `z` in the ASCII table (which doesn't matter here). as Peter Taylor's suggested, however, if we filter out alphanumerics first, we can convert to lowercase and digits just by setting one bit in each character: `{32|}` `.-1%=` does all the palindromic heavy lifting. One part I'm not really fond of is how long it took me to find out how to reverse an array. I should have read the docs. The other two characters perform stack management and comparison. Test: <http://golfscript.apphb.com/?c=IkV2YSwgY2FuIEkgc3RhYiBiYXRzIGluIGEgY2F2ZT8iCgp7IjA6QVtheyJcez59KywsMiV9LHszMnx9JS4tMSU9> --- Further, if I can assume that none of the following control characters are present: (Data link escape, device control 1-4, negative acknowledge, synchronous idle, end of transmission block, cancel, end of medium) (we all agree these are all pretty obscure) or if I can treat them as uppercase versions of the digits 0-9, we can save another two characters: ## GolfScript, 28 characters ``` {32|}%{0"0:a{"@{>^}+/},.-1%= ``` Test: <http://golfscript.apphb.com/?c=IkV2YSwgY2FuIEkgc3RhYiBiYXRzIGluIGEgY2F2ZT8iCgp7MzJ8fSV7MCIwOmF7IkB7Pl59Ky99LC4tMSU9> [Answer] ### Javascript, 53 characters: ``` (x=x.toLowerCase().match(/[a-z\d]/g))+""==x.reverse() ``` is a javascript expression that evaluates to true if `x` is a palindrome, to false if it isn't. It assumes `x` is a string. If that's not guaranteed, prepend `x+="",` Here's a breadcrumb: Due to how `reverse()` works, ``` (x=x.toLowerCase().match(/[a-z\d]/g))==""+x.reverse() ``` fails. However, ``` ""+(x=x.toLowerCase().match(/[a-z\d]/g))==x.reverse() ``` is perfectly fine. [Answer] # Bash: ~~52~~ ~~48~~ 46 characters ``` s=${1,,};s=${s//[^a-z0-9]};[ $s = `rev<<<$s` ] ``` This takes the sting to check as first parameter and sets the exit code to 0 for palindrome and 1 for not. Sample run: ``` bash-4.2$ p() { s=${1,,};s=${s//[^a-z0-9]};[ $s = `rev<<<$s` ]; } bash-4.2$ p 'Eva, can I stab bats in a cave?'; echo $? 0 bash-4.2$ p 'A man, a plan, a canal. Panama!'; echo $? 0 bash-4.2$ p "Madam, I'm Adam Corolla."; echo $? 1 bash-4.2$ p '757'; echo $? 0 bash-4.2$ p 'Boeing 757'; echo $? 1 bash-4.2$ p 'A man, a plan, a shovel, a canal. Panama!'; echo $? 1 bash-4.2$ p 'A_man,_a_plan, a_caremer, a canal:_Panama!'; echo $? 0 ``` [Answer] **Python 2: 49** (without counting the method signature) ``` def f(s): s=filter(str.isalnum,s.upper()) return s==s[::-1] ``` A complete program, with input and output can be writte in **74** characters. ``` import sys s=filter(str.isalnum,sys.stdin.read().upper()) print s==s[::-1] ``` Example usage: ``` $echo 'Eva,can I stab bats in a cave?' | python palindrome.py True $ cat huge_palindrome.txt | python palindrome.py True $echo 'Able was I ere i SaW elBa' | python palindrome.py True ``` (`huge_palindrome.txt` contains [this](http://norvig.com/pal17txt.html) 17,826 word palindrome) This solution can be adapted to python 3 adding some characters: **Python 3: 55** ``` def f(s): s=list(filter(str.isalnum,s.upper())) return s==s[::-1] ``` [Answer] ## R: 66 ``` w=grep("[a-z0-9]",strsplit(tolower(s),"")[[1]],v=T);all(w==rev(w)) ``` Usage: ``` f=function(s){w=grep("[a-z0-9]",strsplit(tolower(s),"")[[1]],v=T);all(w==rev(w))} f("Eva, can I stab bats in a cave?") [1] TRUE ``` [Answer] **JAVA (or the most verbose language ever), ~~102~~ ~~96~~ 95 char** ``` s=s.replaceAll("\\W|_","");return s.equalsIgnoreCase(new StringBuffer(s).reverse().toString()); ``` Usage (with ungolfed code): ``` static boolean q(String s) { s=s.replaceAll("\\W|_",""); return s.equalsIgnoreCase(new StringBuffer(s).reverse().toString()); } public static void main(String[] args) { System.out.println(q("'A man, a plan, a canal - Panama!'")); } ``` Shortened with the help of the commenter below [Answer] # Mathematica ~~54~~ 53 One byte saved thanks to CatsAreFluffy: ``` PalindromeQ@StringCases[ToUpperCase@#,WordCharacter]& ``` For those with version 10.2 or earlier: ``` #==Reverse@#&@StringCases[ToUpperCase@#,WordCharacter]& ``` **Example** ``` PalindromeQ@StringCases[ToUpperCase@#, WordCharacter]&["Eva,can I stab bats in a cave?"] ``` > > True > > > [Answer] ## J, 30 characters ``` */(=|.)tolower(#~'[^_\W]'rxE]) ``` Usage: ``` */(=|.)tolower(#~'[^_\W]'rxE])'A man, a plan, a canal - Panama!' 1 */(=|.)tolower(#~'[^_\W]'rxE])'Doc, note: I dissent. A fast never prevents a fatness. I diet on cod' 1 ``` [Answer] # k (~~50 48 45~~ 38 chars) Suppresses all errors, returning a default of `0b` (false). ``` {X~|X@:&(X:_:x)in 10h$(48+!10),97+!26} ``` Example: ``` k){X~|X@:&(X:_:x)in 10h$(48+!10),97+!26} "Eva, can I stab bats in a cave?" 1b ``` edit: shaved three more character by avoiding intermediate variable. H/T, CS. -7: No need to suppress errors. [Answer] # Ruby: ~~43~~ 38 characters ``` s=s.upcase.tr'^A-Z0-9','';s==s.reverse ``` Sample run: ``` irb(main):001:0> p=->s{s=s.upcase.tr'^A-Z0-9','';s==s.reverse} => #<Proc:0x854592c@(irb):1 (lambda)> irb(main):002:0> p['Eva, can I stab bats in a cave?'] => true irb(main):003:0> p['A man, a plan, a canal. Panama!'] => true irb(main):004:0> p["Madam, I'm Adam Corolla."] => false irb(main):005:0> p['757'] => true irb(main):006:0> p['Boeing 757'] => false irb(main):007:0> p['A man, a plan, a shovel, a canal. Panama!'] => false irb(main):009:0> p['A_man,_a_plan, a_caremer, a canal:_Panama!'] => true ``` [Answer] # C++, ~~107~~ (miscounted), ~~100~~ (miscounted), 81 ``` string s;for(int c:t)if(isalnum(c))s+=c|32;return s==string(s.rbegin(),s.rend()); ``` * Exploits ASCII bit patterns. * Relies on an evil `using namespace std;`. * Uses bitwise AND and OR instead of the logical operators. * Uses `int` because it's shorter than `char` or `auto`. ``` #include <string> using namespace std; bool IsPalindrome(const string & t) { string s;for(int c:t)if(isalnum(c))s+=c|32;return s==string(s.rbegin(),s.rend()); } #include <cassert> int main() { assert(!IsPalindrome("gorilla")); // simple failure assert( IsPalindrome("racecar")); // simple success assert( IsPalindrome("Hannah")); // case blind assert(!IsPalindrome("1999")); // digit failure assert( IsPalindrome("2002")); // digit success // Ignore spacing, punctuation, and case: assert( IsPalindrome(" \t09AZ/:@[`{za90")); // boundaries assert( IsPalindrome("A man, a plan, a canal: Panama.")); assert( IsPalindrome("Eva, can I stab bats in a cave?")); assert( IsPalindrome("")); // empty string return 0; } ``` [Answer] # Lua, 56 ``` a=io.read"*l":lower():gsub("%W","")print(a:reverse()==a) ``` [Answer] **Python 3/2 59 chars:** ``` def pld(i): p=[c for c in i.lower() if c.isalnum()] return(p == p[::-1]) ``` [Answer] # Haskell, 43 Using the standard libraries `Control.Monad`, `Control.Monad.Instances`, and `Data.Char`: ``` ap(==)reverse.map toLower.filter isAlphaNum ``` [Answer] **PHP 60 characters.** First try on codegolf. ``` //thank you manatwork echo($x=preg_replace('/\W/','',strtolower($c)))==strrev($x); ``` Example: ``` $c='Eva, can I stab bats in a cave?'; echo($x=preg_replace('/\W/','',strtolower($c)))==strrev($x); //prints 1 ``` [Answer] **Python 2 64 Charecters:** ``` i =''.join(re.findall('[a-z0-9]+',i.lower())) return i==i[::-1] ``` [Answer] # Haskell 48 ``` (\x->x==reverse x).map toLower.filter isAlphaNum ``` used like this: ``` (\x->x==reverse x).map toLower.filter isAlphaNum$"Eva, can I stab bats in a cave?" ``` [Answer] **Smalltalk**, Squeak/Pharo flavour **116** chars using traditional formatting with tabs You add two methods to String: ``` selffles ^self = self reverse isPalindrome ^(self asUppercase asDecomposedUnicode select: #isAlphaNumeric) selffles ``` We could of course eliminate some spaces, or use shorter method names, but let's not betray the spirit of Smalltalk. More over, this will handle French palindromes, like in <http://fr.wikipedia.org/wiki/Liste_de_palindromes_fran%C3%A7ais>, not many answers in this page can. ``` ['Léon a trop par rapport à Noël' isPalindrome] assert. ``` [Answer] # Python 3 (51 char) ### and may be Python 2 based on *abhiram* solution (with more agressive golfing) ``` from re import findall def palindrome(i): i=findall('[a-z\d]',i.lower()) return i==i[::-1] print(palindrome(input('Phrase: '))) ``` may be shortened to 46 chars, using RE '\w' and variant with extremely shortened function body (27 chars) ``` import re l=str.lower f=re.compile('[a-z\d]').findall def palindrome(i):i=f(l(i));return i==i[::-1] print(palindrome(input('Phrase: '))) ``` [Answer] # [Julia 1.0](http://julialang.org/), 63 bytes ``` ~s=((x=filter(in(['0':'9';'A':'Z']),uppercase(s)))==reverse(x)) ``` [Try it online!](https://tio.run/##TYqxDoIwFEVn@YoXlrYJMQ@VQU2jDg5uzhqH11pjDRbSAjLx65XF4HTPObmvtrSU9zEOQXLey4ctG@O5dfzKkG3Ymm3ZYdwLu4msrWvjNQXDgxBCSm8640frhYj78Kw@MKTHjjLQ5OAEoSEFipoA1gGNsTO7NPkdz1Rad/fV20ytyBARcI5YTDFfLFd/OhEpDTDTitIkfgE "Julia 1.0 – Try It Online") Since punctuation is filtered out, `"5,000 0.005"` is considered a palindrome. [Answer] ## Windows PowerShell, 56 47 45 chars Updated (see comments), and can remove the brackets around the regex: ``` ($s=$s-replace'\W')-eq(-join$s[$s.length..0]) ``` Original (56) ``` $s=$s-replace'[^\w]','';$s-eq($s[-1..-$s.length]-join'') ``` Original Un-golfed: ``` $s = "Eva, can I stab bats in a cave?" $s = $s -replace '[^\w]', '' $rev = $s[-1..-$s.length] -join '' $s -eq $rev ``` [Answer] # C++, 74 bytes This code is actually really elegant, and easy to understand (when formatted correctly). I don't believe it's possible to get any shorter in C++, and it doesn't use any standard library functions. ``` p(auto c){auto e=c;while(*e)++e;--e;while(*e==*c&e>c)--e,++c;return e<=c;} ``` Example usage: ``` p("Hello"); //Outputs 0 p(""); //Outputs 1 p("a"); //Outputs 1 p("HellolleH"); //Outputs 1 ``` Nicely formatted version: ``` p(auto c) { auto e=c; while(*e) ++e; --e; while(*e==*c & e>c)--e,++c; return e<=c; } ``` [Answer] # PHP, ~~26 84 80 78 62~~ 63 bytes ``` <?=strrev($s=strtolower(preg_replace("#\W#","",$argv[1])))==$s; ``` takes input from first command line argument; prints `1` for truthy, empty string for falsy. --- I18n is a littly expansive, as there is no multibyte alternative for `strrev` (110 bytes; run with `-r`): ``` preg_match_all("#.#us",$s=strtolower(preg_replace("#\W#u","",$argv[1])),$m);echo$s==join(array_reverse($m[0]); ``` utf8\_strrev blatantly [stolen from the PHP manual](http://php.net/manual/en/function.strrev.php#83461). You might also want to take a look at [this blog post](http://kvz.io/blog/2012/10/09/reverse-a-multibyte-string-in-php/). [Answer] # [K (ngn/k)](https://codeberg.org/ngn/k), 18 bytes ``` #|:\(2!"0:a{"')__: ``` [Try it online!](https://ngn.codeberg.page/k#eJyFUE1PwkAQve+vGKuJkNDWtnDZHgyJHrwY70hgaKewod3F3ZFAUH+7Uwx69LJv533M7E6jrz/06yC/iu40nqLb4WKhlWJ9upkdv7xuAOBQLt22HCwbNG15KI+lH84/xTOLHvc4ggotPEFgXMEKOYCxgELu6T4qs3lve3Ys1A5bY2vvul7Iz8IUOrSjXmt/UHphq+FFoMNL/MFVI7COScuc2oRAlhOYQoOBwdKePOy8gJXhKCxbCiE5e4nBWahcfemV5UWeXQpELIpCzl9iPD4/TaVqw7wLOk0lS2vXNol8sNrSodqgXVNSuS59e6fAxtmQZlk2maRh4zwLFfeZmF1cE5PvjKXYNDHGgb2x69gEuf8tQ6l/16jUN9xbhXo=) Uses @scrawl's suggestion [here](https://codegolf.stackexchange.com/questions/11155/shortest-code-to-determine-if-a-string-is-a-palindrome?page=2&tab=modifieddesc#comment463731_11166) to return `1` for palindromes and `2` for non-palindromes. If `1` and `0` are required, the solution can be adjusted by prefixing `1=`. * `_:` lowercase the (implicit) input * `(...)_` filter out values where the code in `(...)` returns a non-0 value + `2!"0:a{"'` do a bins lookup, then mod the result by two; returns `0` if the input is within `"a"-"z"` or `"0"-"9"` and `1` otherwise * `|:\` set up a converge-scan, reversing the input until the original input is returned. on palindromes, returns a one-item list; on non-palindromes, a two-item list * `#` take the count of the result from above. As noted, if a strict `1` and `0` output are required for palindrome/non-palindrome, prefix `1=` for two bytes [Answer] ## Ruby, 48 ``` p((g=gets.upcase.gsub /[^A-Z\d]/,'')==g.reverse) ``` Quite simple, and hastily made so not golfed too much. I shall golf it more later. [Answer] # [Pylongolf2](https://github.com/lvivtotoro/pylongolf2), 24 bytes ``` c╨2"[^a-zA-Z]"-_╨1=~ ``` `c` takes the input, `╨2` to convert to lower case. I then push a regex onto the stack and use `-` to remove all non-alphabetical characters in the input. `_` duplicates the input. `╨1` reverses it and `=` then compares them. `~` prints the stack in the end which prints either `true` or `false`. [Answer] # PowerShell, ~~194~~ 190 bytes A recursive implementation to show how an unnamed PowerShell scriptblock can call itself. ``` $P={param([string]$s)$s=($s-replace'[^a-z]').tolower();if(!$s){return $true};if($s.length-lt4){return $s[0]-eq$s[-1]};$s[0]-eq$s[-1]-and(&$MyInvocation.MyCommand.ScriptBlock $s.trim($s[0]))} ``` ungolfed: ``` $P={ param([string]$s) $s=($s-replace'[^a-z]').tolower(); if(!$s){return $true}; if($s.length-lt4){return $s[0]-eq$s[-1]}; $s[0]-eq$s[-1]-and(&$MyInvocation.MyCommand.ScriptBlock $s.trim($s[0])) } ``` tests: ``` &$P "Eva, can I stab bats in a cave?" &$P "Eva, can I stab cats in a cave?" &$P "A man, a plan, a canal. Panama!" &$P "A man, a plan, a big shovel, a canal. Panama!" &$P "Madam, I'm Adam." &$P "Madam, I'm Adam Corolla." &$P "757" &$P "Boeing 757" ``` ]
[Question] [ # Main task Your task is to print out integers in descending order, starting from 1, and increasing as you keep hitting 1 again, up until the given input is reached, then, print out the rest until you hit 1 again. Example with input `6`: ``` 1 21 321 4321 54321 654321 Without newlines (valid output): 121321432154321654321 ``` *Side note: this is [A004736](https://oeis.org/A004736) in the OEIS. Also, the first example (with newlines) is an invalid output, as specified in the rules.* # Input Your code may take any kind of input (graphical, STDIN) in the form of an integer or number. # Output Your code should output the above described sequence, up until the input number is reached, then finish to output until it reaches 1 again. The output may be anything, therefore numbers, strings, integers, or graphical output. It is required to print out a single number (no newlines if it's a string). Your output can be in- and outroduced with as many characters as you need (e.g. `[]`). Since there was some misunderstanding, here's a regex pattern you can try your outputs on. ``` ^(\D*(\d)+\D*)$ ``` # Rules * The output must be a full number, not split up by anything, not even newlines. * The algorithm shouldn't check for the first instance of N appearing in any way (e.g. the `21` in `121321`), but rather for the first instance of N as the actual number. * A single trailing newline is allowed. * The handling for negative input is fully your choice, negative numbers aren't cases you should test. ## Test cases ``` Input: 6 Output: 121321432154321654321 ``` Input: 1 Output: 1 Input: 26 Output: 121321432154321654321765432187654321987654321109876543211110987654321121110987654321131211109876543211413121110987654321151413121110987654321161514131211109876543211716151413121110987654321181716151413121110987654321191817161514131211109876543212019181716151413121110987654321212019181716151413121110987654321222120191817161514131211109876543212322212019181716151413121110987654321242322212019181716151413121110987654321252423222120191817161514131211109876543212625242322212019181716151413121110987654321 Input: 0 Output: 0, Empty, or Error Input: 21 Output: 121321432154321654321765432187654321987654321109876543211110987654321121110987654321131211109876543211413121110987654321151413121110987654321161514131211109876543211716151413121110987654321181716151413121110987654321191817161514131211109876543212019181716151413121110987654321212019181716151413121110987654321 Thanks @Emigna, I used his algorithm to calculate these test cases. ## Winner The winner has been chosen! It was [ErikGolfer's answer](https://codegolf.stackexchange.com/a/103682/62824) with an impressive **5** bytes! Congratulations! [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), 6 bytes ``` L€LíJJ ``` [Try it online!](http://05ab1e.tryitonline.net/#code=TOKCrEzDrUpK&input=Ng) **Explanation** Example input 4 ``` L # range [1 ... input] # STACK: [1,2,3,4] €L # map: range # STACK: [[1],[1,2],[1,2,3],[1,2,3,4]] í # reverse each # STACK: [[1],[2,1],[3,2,1],[4,3,2,1]] J # join inner lists # STACK: ['1','21','321','4321'] J # join list # OUTPUT: 1213214321 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes ``` RRUVV ``` [Try it online!](https://tio.run/nexus/jelly#@x8UFBoW9v//fyMzAA "Jelly – TIO Nexus") [Formula not mine.](/a/103673/41024) I suspect there is too much going on here... [ANSWER ACCEPTED] I'd have given some 5 rep to Dennis, but this is not Reputation Exchange. Dennis showed me the `VV` behavior. To my surprise, this is shorter than 05AB1E. [Answer] ## JavaScript (ES6), 37 bytes ``` f=(n,k=1)=>k>n?n--?f(n):'':f(n,k+1)+k ``` ### Demo ``` f=(n,k=1)=>k>n?n--?f(n):'':f(n,k+1)+k console.log(f(6)) ``` ### Alternate method for n < 10, 34 bytes (non-competing) ``` f=(n,s='1')=>--n?s+f(n,++s[0]+s):s ``` In JavaScript, strings are immutable. Therefore, it's impossible to alter the content of the Nth character of a string `s` by assigning a new value to `s[N]`. However, the expression `++s[N]` is valid and does evaluate as one would expect, even if the string remains unchanged. For instance: ``` ++"1"[0] // equals 2 ``` And by extension: ``` s = "21" ++s[0] + s // equals "321" ``` [Answer] # V, ~~29~~ ~~28~~ ~~27~~ ~~23~~ ~~19~~ ~~17~~ 16 bytes ***8*** bytes saved thanks to @DJMcMayhem ***3*** bytes saved thanks to @nmjcman101 ``` "apÀ­ñÄòy$jpkgJ ``` Hidden characters: ``` "apÀ<C-x>ñÄ<C-x>òy$jpkgJ ``` `C-x` is Ctrl+x. [Try it online!](https://tio.run/nexus/v#@6@UWHC44dDawxsPt0gc3lSpklWQne71//9/MwA "V – TIO Nexus") takes input via command-line arguments Hexdump: ``` 0000000: 2261 70c0 adf1 c418 f279 246a 706b 674a "ap......y$jpkgJ ``` ### Explanation ``` "ap Paste the argument À<C-x> Argument minus 1 times (so that we exclude the 0) ñ ... ò Loop (for some weird reason the ò closes the ñ) Ä<C-x> paste current line above and decrement it ``` Now it looks like: ``` 1 2 ... n ``` *continued...* ``` ò recursively do (until a breaking error) y$ yank this line jp paste it down kgJ go up and join implicit ò end ``` ### GIF (outdated) (for arg `6`) [![gif](https://i.stack.imgur.com/70Mlu.gif)](https://i.stack.imgur.com/70Mlu.gif) [Answer] # C#, ~~72~~ ~~69~~ 65 bytes ``` n=>{for(int i=0,j;i<n;)for(j=++i;j>0;)System.Console.Write(j--);} ``` If the output can just be returned as opposed to being Written to the console # C#, ~~71~~ ~~68~~ 64 bytes ``` n=>{var s="";for(int i=0,j;i<n;)for(j=++i;j>0;)s+=j--;return s;} ``` Thanks to @VisualMelon for saving a lot of bytes Test it [here](http://rextester.com/SSRRG76375) (Humourously the online compiler breaks at any number above 420) [Answer] # Pure bash, 34 ``` eval eval printf %s \\{{1..$1}..1} ``` Two levels of brace expansion. With input `6`, the first level expands to `{1..1} {2..1} {3..1} {4..1} {5..1} {6..1}`. This then expands to `1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 6 5 4 3 2 1`, which is smushed together to one string with `printf %s`. `eval`'s are required at both levels of expansion - for the first level so that the `$1` parameter is expanded first, and for the second level so that it expands after the first level. [Try it online](https://tio.run/nexus/bash#@59alpijACYKijLzStIUVIsVYmKqqw319FQMa/X0DGv///9vBgA) [Answer] ## Perl, 21 bytes **Uses `-E` at no extra cost.** ``` say map$}=$_.$},1..<> ``` ### Usage ``` perl -E 'say map$}=$_.$},1..<>' <<< 6 121321432154321654321 ``` [Answer] # Pyth, 7 bytes ``` jks}R1S ``` A program that takes input of an integer and prints the result. [Try it Online!](http://pyth.tryitonline.net/#code=amtzfVIxUw&input=Ng) **How it works** ``` jks}R1S Program. Input: Q jks}R1SQ Implicit input fill R Map SQ over [1, 2, 3, 4, ..., Q] with i: } 1 Yield [i, i-1, i-2, i-3, ..., 1] s Merge jk Join Implicitly print ``` [Answer] # [GeoGebra](https://www.geogebra.org/), 67 bytes ``` 1 InputBox[a] Sum[Join[Sequence[Sequence[Text[j],j,i,1,-1],i,1,a]]] ``` Each line is entered separately into the input bar. Input is taken from an input box. Here is a gif of the execution: [![Program execution](https://i.stack.imgur.com/SMsZB.gif)](https://i.stack.imgur.com/SMsZB.gif) **How it works** Entering `1` implicitly assigns `a` to `1`, and the `InputBox` command associates an input box with `a`. Then, for each `i` in `{1, 2, 3, ..., a}`, the list `{i, i-1, i-2, ..., 1}` is created using the `Sequence` command, and each `j` in that list is converted to a string using `Text`. Finally, `Join` merges all the lists, and `Sum` concatenates all the elements to one text object, which is displayed. [Answer] ## Python 2, 51 bytes ``` r=s='' n=0 exec'n+=1;s=`n`+s;r+=s;'*input() print r ``` [Answer] ## [Retina](https://github.com/m-ender/retina), ~~26~~ 22 bytes Byte count assumes ISO 8859-1 encoding. ``` .+ $* $`¶ 1 $.%' 0?¶ ``` [Try it online!](https://tio.run/nexus/retina#@6@nzaWixcWlknBoG5chl4qeqjqXgT2Q/f@/oQEA "Retina – TIO Nexus") ### Explanation ``` .+ $* ``` Convert input to unary. ``` $`¶ ``` At each position, insert the prefix up to that point, as well as a linefeed. This creates a unary range from `2` to `n+1`, one value per line. ``` 1 $.%' ``` Replace each `1` with the number of characters after it on the same line. This turns something like `11111` into `43210`. ``` 0?¶ ``` Remove all linefeeds and the zeros preceding them. [Answer] # GameMaker Language, 65 bytes ``` b=""for(i=1;i<=argument0;i++){c=i while(j)b+=string(c--)}return b ``` [Answer] # APL, 10 bytes ``` ∊⍕¨∘⌽∘⍳¨∘⍳ ``` E.g.: ``` (∊⍕¨∘⌽∘⍳¨∘⍳)6 121321432154321654321 ``` Explanation: * `⍳`: get the numbers from 1 to N. * `⍳¨∘`: for each of those, get the numbers from 1 to N. * `⌽∘`: reverse that list * `⍕¨∘`: get the character representation of each item (so it does not output the numbers with spaces in between) * `∊`: flatten the resulting array [Answer] # Python 2, ~~71~~ 68 bytes I bet a recursive solution could be shorter, but I'm having a hard time formulating this into one. ``` n=input() i=0 o="" while i<n: i+=1;j=i while j:o+=`j`;j-=1 print o ``` [**Try it online**](https://tio.run/nexus/python2#@59nm5lXUFqiocmVaWvAlW@rpMRVnpGZk6qQaZNnxcWZqW1raJ1lm8nFCRHNssrXtk3ISrDO0rU15CooyswrUcj//98MAA) [Answer] # Actually 8 bytes ``` RR♂RΣRεj ``` First time posting an answer in Actually so it probably can be golfed. **How it works** ``` Program takes implicit input, implicit print at EOF R Takes the input and creates a range (1, input) STACK = [1,2,..,n] R Reverse the top stack item (our range) STACK = [n,..,2,1] ♂R For each item in our range, create a range (1, rangeitem) STACK = [[1,2,..,n], .., [1,2], [1]] Σ Stitch the items of the list together STACK = [n,..,1,2,3,1,2,1] R Reverse the top stack item again (our answer) STACK = [1,2,1,3,2,1,..n] εj Create an empty string and append each item from the list to it. (turns non string items into strings) ``` [Try it online!](https://tio.run/nexus/actually#@x8U9GhmU9C5xUHntmb9/28GAA) [Answer] # [Perl 6](https://perl6.org/), 22 bytes ``` {[~] flat [\R,] 1..$_} ``` A lambda that returns a string. ([Try it online.](https://tio.run/#RlzAo)) ### Explanation: * `1..$_`: Range of integers... `(1 2 3 4)` * `[,] 1..$_`: Reduce ("fold") over comma operator... `(1 2 3 4)` * `[\,] 1..$_`: With intermediate results ([triangular reduce](http://perl6maven.com/tutorial/perl6-reduction-triangle))... `((1) (1 2) (1 2 3) (1 2 3 4))` * `[\R,] 1..$_`: Apply [reversing](https://docs.perl6.org/language/operators#Reversed_Operators) meta-operator to the comma... `((1) (2 1) (3 2 1) (4 3 2 1))` * `[~] flat ...`: Remove list nesting, and fold over string concat operator... `1213214321` [Answer] ## Haskell, 35 bytes ``` f x=[1..x]>>= \y->[y,y-1..1]>>=show ``` Usage example: `f 6` -> `"121321432154321654321"`. For all numbers `x` in `1 ... x` make a list `x,x-1, ... ,1`, turn the numbers into a string and concatenate them into a single string. Again, concatenate those strings into a single string. [Answer] # C89, 54 bytes ``` i,j;f(n){for(i=1;j<=n;j=i++)while(j)printf("%d",j--);} ``` 56 -2 = 54 thanks to ErikGolfer! [Answer] # Python 3, 87 92 83 74 bytes ``` lambda n:"".join(["".join([str(i)for i in range(1,k)][::-1])for k in range(1,n+2)]) ``` Shorter answer using recursion : ``` f=lambda n:f(n-1)+"".join([str(i)for i in range(1,n+1)][::-1])if n>0else"" ``` Maybe not the shortest one but it's only made with Python's list comprehension ! *(Edited to add the print function and remove the \n)* *(Edited to remove the print function, and change n+1, k+1 to n,k+2)* [Answer] # [Brachylog v1](http://github.com/JCumin/Brachylog), 8 bytes ``` yb@[rcw\ ``` [Try it online!](http://brachylog.tryitonline.net/#code=eWJAW3Jjd1w&input=Ng) ### Explanation ``` yb The list [1, ..., Input] @[ Take a prefix of that list rc Reverse it and concatenate into an integer w Write to STDOUT \ Backtrack: try another prefix ``` [Answer] # Pyth, 8 bytes ``` jks_M._S ``` ### Explanation ``` jks_M._SQ Implicit input SQ Get the range [1, 2, ..., N] ._ Get each prefix _M Reverse each prefix jks Join everything as a string ``` [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), 6 bytes ``` LR.sJJ ``` [Try it online!](http://05ab1e.tryitonline.net/#code=TFIuc0pK&input=Ng) [Answer] ## Mathematica, 36 bytes ``` ToString/@(""<>Range[Range@#,1,-1])& ``` Throws a bunch of warnings which can be safely ignored. ### Explanation Using input `5` as an example: ``` Range@# ``` Creates a range `{1, 2, 3, 4, 5}`. ``` Range[...,1,-1] ``` `Range` is listable so we can give it a list for any of its arguments and it will automatically thread over that argument. So this gives us a bunch of reversed lists: ``` {{1}, {2, 1}, {3, 2, 1}, {4, 3, 2, 1}, {5, 4, 3, 2, 1}} ``` Next: ``` (""<>...) ``` This joins the nested list with the empty string. Since the nested list doesn't actually contain any strings, it can't really join the values (which is where the warnings are generated), but `""<>` has the side-effect of flattening the list. So this gives us ``` 1 <> 2 <> 1 <> 3 <> 2 <> 1 <> 4 <> 3 <> 2 <> 1 <> 5 <> 4 <> 3 <> 2 <> 1 ``` Now comes Mathematica's beautiful feature that `Map` doesn't care about the structure it's mapping over. You normally apply it to a list, but it works with any head. `f /@ h[a, b, c]` simply gives you `h[f[a], f[b], f[c]]`. In our case, the head is `StringJoin` and the values are the integers. ``` ToString/@... ``` So this simply turns the integers into strings. At that point `StringJoin[...]` knows what to do with them and joins them all into a single string: ``` "121321432154321" ``` [Answer] # [GolfScript](http://www.golfscript.com/golfscript/), 14 bytes ``` ~,{),{)}%-1%}% ``` [Try it online!](https://tio.run/nexus/golfscript#@1@nU60JRLWquoaqtar//5sBAA "GolfScript – TIO Nexus") Usual method of course, but this is GolfScript. Explanation for this **VAST** piece of code: ``` ~,{),{)}%-1%}% # Code # Initial stack. ["n"] ~ # Eval ToS. [n] , # ToS' lowered range. [[0..n)] {),{)}%-1%} # Block. 1 argument. [a] ) # Increment. [a+1] , # Range. [[0..a)] {)} # Block. 1 argument. [b] ) # Increment. [b+1] % # Map. [[1..a]] -1 # Integer. -1 [[1..a] -1] % # Each nth element. [[a..1]] % # Map. [[[1],[2,1],...,[n..1]]] # Implicit output. 121...n..1 ``` Note that output is as a single number. Trailing `\n`. [Answer] # R, ~~38~~ ~~33~~ 44 bytes ``` if((n=scan())>0)for(i in 1:n)cat(i:1,sep="") ``` Takes input to STDIN, and loops from 1 to n, creating the sequence i to 1 for each step and printing it. Edit: replaced `seq(i,1)` by `i:1` saving 5 bytes and showing why I shouldn't golf during meetings. [Answer] # [MATL](https://github.com/lmendo/MATL), ~~14~~ 11 bytes ``` :"@:P]v!VXz ``` [Try it online!](https://tio.run/nexus/matl#@2@l5GAVEFumGBZR9f@/kSEA "MATL – TIO Nexus") ### Explanation ``` : % Input N implicitly. Push range [1 2 ...N] " % For each k in [1 2 ...N] @: % Push range [1 2 ... k] P % Reverse ] % End v! % Concatenate all arrays horizontally V % Convert to string Xz % Remove spaces. Display implicitly ``` [Answer] # brainfuck, 17 bytes ``` >,[>[+.>]+.[<]>-] ``` ## Explanation ``` > keep the first cell at 0 , input of the decimal number into the cell [> start a conditionnal loop and go to the next cell [+.>] while it don't find 0, increment each cells and output the value +. increment the new cell and output [<] go to the first cell >-] decrement the second cell and restart ``` [Try it online!](http://brainfuck.tryitonline.net/#code=PixbPlsrLj5dKy5bPF0-LV0&input=Bg&debug=on) [Answer] # [Python](https://docs.python.org), ~~63~~ ~~57~~ 59 bytes A recursive solution that works in both Python 2 and 3. This can probably be golfed further. Golfing suggestions welcome! [Try it online!](https://tio.run/nexus/python3#FckxDoAgEATA3lcQqiOi0cbCxMecQQxGFnLi@xGbaab67ea4O1ZYoRhOecIwm17r8UoBFDnTU8QK4zwIdrJtjUmidZcloJCn34D8Fmpjal0@ "Python 3 – TIO Nexus") **Edit:** -6 bytes thanks to Jonathan Allan. +2 bytes with thanks to mbomb007 for pointing out a problem with my answer. ``` f=lambda n:n and f(n-1)+"".join(map(str,range(n,0,-1)))or"" ``` **Ungolfing** ``` def f(n): s = "" for i in range(n+1): m = map(str, range(n, 0, -1)) s += "".join(m) return s ``` [Answer] # CJam, 13 bytes ``` ri,:){,:)W%}% ``` [interpreter](//cjam.aditsu.net#code=ri%2C%3A)%7B%2C%3A)W%25%7D%25&input=6) [Answer] # PHP, ~~35~~ ~~34~~ 33 bytes *Saved a byte because I miscounted, thanks Titus! And another!* ``` while($i++<$argv[1])echo$s=$i.$s; ``` Run from command line with `-r`. Pretty simple answer, loops from 1 through our input `n`, tacking the number onto the beginning of the string and printing it out. ]
[Question] [ **Challenge:** Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where **X is another positive integer**. If it can, output X If it can't, output -1 or a [falsy](http://meta.codegolf.stackexchange.com/q/2190/34718) statement. **Example inputs/outputs** Input: ``` 2 ``` It can be written as (3^1) - 1, so we output x which is 1 Output: ``` 1 ``` Input: ``` 26 ``` 26 can be written as (3^3) - 1, so we output x (3) Output: ``` 3 ``` Input: ``` 1024 ``` 1024 can't be written in the form of (3^x) - 1, so we output -1 Output: ``` -1 ``` This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so least amount of bytes wins --- Related OEIS: **[A024023](http://oeis.org/A024023)** [Answer] ## Mathematica, ~~21~~ 16 bytes ``` -1&@@Log[3,#+1]& ``` Makes use of Mathematica's symbolic computation. If `#+1` is a power of three then `Log[3,#+1]` will compute an integer result which is an atomic value. Otherwise we'll get `Log[#+1]/Log[3]` as is. Since this is not an atomic value, it's an expression which is always of the form `head[val1,val2,...]`. In this case it's actually something like `Times[Power[Log[3], -1], Log[#+1]]`. We distinguish between the two cases by applying another function to the result. What applying really does is that it replaces the `head` part of an expression. Since integer results are atomic, applying any function to them does nothing at all. In particular `f @@ atom == atom`. However, in the other case, the head does get replaced. The function we're using is `-1&` which is a simple function that ignores its arguments and returns `-1`. So we get something `-1&[Power[Log[3], -1], Log[#+1]]` in non-integer cases, which evaluates directly to `-1`. Special casing via magic. [Answer] # Python, ~~46~~ 44 bytes ``` lambda x:max(n*(3**n-1==x)for n in range(x)) ``` [Try it online!](https://tio.run/nexus/python3#S7ON@Z@TmJuUkqhQYZWbWKGRp6VhrKWVp2toa1uhmZZfpJCnkJmnUJSYl56qUaGp@b@gKDOvRCNNw8hMU5MLxrEwQOIYGhiZABUCAA "Python 3 – TIO Nexus") In this case, `0` would be the falsy value. Thanks to @mbomb007 for pointing out my incorrect output as well as a 2 bytes no `[]` savings. [Answer] ## Haskell, 35 bytes ``` f x=last(-1:[i|i<-[1..x],3^i-1==x]) ``` Usage example: `f 26` -> `3`. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes ``` R3*’i ``` Outputs **x** or **0** (falsy). [Try it online!](https://tio.run/nexus/jelly#@x9krPWoYWbm/6N7Drc/alrj/v@/kY6CkZmOgqGBkQkA "Jelly – TIO Nexus") ### How it works ``` R3*’i Main link. Argument: n R Range; yield [1, ..., n]. 3* Map each k to 3**k. ’ Decrement the results. i First index of n (0 if not found). ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes ``` 3IÝm<¹k ``` [Try it online!](https://tio.run/nexus/05ab1e#@2/seXhurs2hndn//xuZAQA "05AB1E – TIO Nexus") **Explanation** ``` 3 # push 3 I # push input Ý # range [0 ... input] m # 3^[0 ... input] < # -1 ¹k # find index of input, return -1 if not found ``` [Answer] # Prolog, 20 bytes ``` d(A,X):-A#=(3**X)-1. ``` This language is cool as hell. ``` | ?- d(1024,X). no | ?- d(26,X). X = 3 yes | ?- d(2,X). X = 1 yes ``` [Answer] # Brachylog v1, 8 bytes ``` ,3:.^-?, ``` [Try it online!](https://tio.run/nexus/brachylog#@69jbKUXp2uv8/@/kdn/KAA "Brachylog – TIO Nexus") Outputs the value if true and `false.` if this is impossible. ### Explanation This is a direct transcription of the given relation: ``` , , (Disable implicit unification) 3:.^ 3^Output… -? … - 1 = Input ``` [Answer] ## Python 2, 41 bytes ``` f=lambda n,i=0:i*0**n or n%3/2*f(n/3,i+1) ``` A recursive function that returns `0` for non-matching inputs. Repeatedly floor-divides the input by 3, counting the number of steps in `i`, which is output in the end. But, if any step produces a value `n` that isn't 2 modulo 0, the number was not of for `3^i-1`, so the output is multiplied by 0. [Answer] ## Perl, 31 bytes ``` say grep{3**$_-1==$i}0..($i=<>) ``` Requires `-E` flag to run: ``` perl -E 'say grep{3**$_-1==$i}0..($i=<>)' <<< 26 ``` Explanations: `grep{3**$_-1==$i}0..($i=<>)` returns a list of the elements of the range `0..$_` (ie. from 0 to the input) that satisfies the test `3**$_-1==$i`. Only one element at most can satisfy this test, so this instruction will return an array of 0 or 1 element. We then print this list: either the `X` or nothing (which is falsy). [Answer] # Pyth, 11 bytes ``` ?-JjQ3 2ZlJ ``` Converts to base 3 and checks equality to `[2, 2, ..., 2]`. [Answer] ## JavaScript (ES7), ~~38~~ ~~36~~ 34 bytes ``` f=(n,k=33)=>3**k-n-1&&--k?f(n,k):k ``` Or just ~~30~~ 29 bytes if it's OK to exit with an error on failure: ``` f=(n,k)=>~(n-3**k)?f(n,-~k):k ``` ### Test ``` f=(n,k=33)=>3**k-n-1&&--k?f(n,k):k console.log(f(177146)) console.log(f(847288609442)) console.log(f(5559060566555522)) console.log(f(123456)) ``` [Answer] # Java 8, 37 58 67 bytes ``` i->{String s=i.toString(i,3);return s.matches("2*")?s.length():-1;} ``` This lambda fits in a `Function<Integer, Integer>` reference and uses the simple base 3 trick. This time it should work correctly. [Answer] # Processing, ~~60~~ 56 bytes ``` void q(float n){n=log(n+1)/log(3);print(n>(int)n?-1:n);} ``` Outputs `-1` if falsy. ### Explanation ``` void q(float n){ // n is input n=log(n+1)/log(3); // finds X in 3^X+1=n as a float (here we'll storing that in n) print(n>(int)n?-1:n); // checks if the float is greater than // the number rounded down (by int casting) // if it is greater, output -1 // otherwise output X } ``` `void` is 1 byte shorter than using `float`, so that's why this function directly outputs instead of returning a value. ### Alternative Solution ``` void z(float n){int c=0;for(++n;n>1;c++)n/=3;print(n==1?c:-1);} ``` for 63 bytes, but I think this alt can be golfed to be shorter than the original solution. I'm working on it. [Answer] # R, 24 bytes A different approach from [plannapus' answer](https://codegolf.stackexchange.com/a/105883/59052), and one byte shorter! ``` match(scan(),3^(1:99)-1) ``` Generates all integers from `3^1-1` to `3^99-1`, and checks if stdin matches. If so, it returns the index at which it matches, which is `x`. If not, returns `NA` as falsy value. Incidentally, it will accept multiple values as input, and test all of them, which is a neat feature. [Answer] # [Perl 6](https://perl6.org), ~~25~~ 24 bytes ``` {first $_==3** *-1,0..$_} ``` [Try it](https://tio.run/nexus/perl6#LYzdCoMgAEbvfYqPiPWDE6vRTfgKe4KBRDMIHIVmLMRe3cW223M4x1mFrWVDR8hrx2WYnwoi@nEydkUqhWjKEuW1opyxVIY4zgac1rRuacXrGzwBzvBhlHV6hQD7ProTL25Fkkr4n2OLMjokFBnyHmOv7Y6t104VGd7I/4PjwH3SBQnxAw "Perl 6 – TIO Nexus") ``` {first $_==3***-1,0..$_} ``` Removing the space after `**` works because it is longer than the other infix operator that could match `*`. So `…***…` is parsed as `… ** * …` rather than `… * ** …`. [Try it](https://tio.run/nexus/perl6#LYzdCoMgAEbvfYqPiPWDE6vRTfgKe4KBRDMIHIVmLMRe3cW223M4x1mFrWVDR8hrx2WYnwoi@nEydkUqhWjKsrxWlDOWyhDH2YDTmtYtrXh9gyfA2T2Msk6vEGDfRXfixa1IUgn/c2xRRoeEIkPeY@y13bH12qkiwxv5f3AcuE@6ICF@AA "Perl 6 – TIO Nexus") ## Expanded: ``` { # bare block lambda with implicit parameter 「$_」 first $_ == 3 ** * - 1, # WhateverCode lambda # ^- current value 0 .. $_ # a Range up-to (and including) the input } ``` [Answer] # [Husk](https://github.com/barbuz/Husk), 4 bytes ``` £İ3→ ``` Returns `0` if there's no such **x**, [try it online!](https://tio.run/##yygtzv7//9DiIxuMH7VN@v//v5GJEQA "Husk – Try It Online") ### Explanation This works because `£` assumes the list to be sorted and aborts the search once it sees a larger element: ``` £İ3→ -- implicit input N, for example: 80 → -- increment N -> 81 İ3 -- list [3,9,27,81… £ -- if it's in the list return index; -> 4 -- else return 0 ``` [Answer] # [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~42~~ 40 bytes ``` param($a)1..$a|?{"3*"*$_+"1-1-eq$a"|iex} ``` -2 bytes thanks to mazzy, by replacing the `[Math]::Pow`, nice one! [Try it online!](https://tio.run/##NY1BCsIwEEX3c4ohjNLWtjQVVATRm5RBRxQSW1OLQpqzx7hw8Vfv897Qv8WNNzGmOvdOIl3xgD4O7NhmxLmua@L56NW6UAV1K6UrXcmTWM13@YQY4JS1JbabtG2Ju6ZE3TQ5zrhAD0CvpLPC4@QkBazlxwU9kpNxMj@2TEHqMIBK1/0fKIAA8Qs "PowerShell Core – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes ``` DÝ3sm<Q1k ``` [Try it online!](https://tio.run/nexus/05ab1e#@@9yeK5xca5NoGH2//9GZgA "05AB1E – TIO Nexus") Prints -1 for falsy. ``` D # Duplicate the input Ý3sm # Push [0 .. input]^3 (e.g. [0^3, 1^3, 2^3, 4^3 ...]) < # subtract 1 Q # push a 1 everywhere that equals the input, and 0 everywhere else 1k # push the index of the 1, or -1 if not found # implicit output ``` [Answer] # [MATL](https://github.com/lmendo/MATL), 8 bytes ``` 3i:^qG=f ``` This outputs the number `x` if it exists, or otherwise outputs nothing, which is falsy. [Try it online!](https://tio.run/nexus/matl#@2@caRVX6G6b9v@/kRkA "MATL – TIO Nexus") ### Explanation ``` 3 % Push 3 i % Input n : % Range: gives `[1 2 ... n] ^ % Power, element-wise. Gives [3^1 3^2 ... 3^n] q % Subtract 1, element-wise. Gives [3^1-1 3^2-1 ... 3^n-1] = % Test for equality. Contains 'true' at the position x, if any, % where 3^x-1 equals n f % Find. Gives index of the 'true' position, which ix x; or gives % an empty array if no such position exists. Implicitly display ``` [Answer] ## [Japt](https://github.com/ETHproductions/japt), 11 bytes ``` o æ@U+1¥3pX ``` Try it [here](http://ethproductions.github.io/japt/?v=1.4.2&code=byDmQFUrMaUzcFg=&input=MjY=). Big thanks to ETHproductions for helping! [Answer] # Python 3, ~~74~~ ~~66~~ 64 bytes -10 bytes thanks to @mbomb007, @FlipTack and @nmjcman101 ``` from math import* def f(n):x=ceil(log(n,3));print((3**x-1==n)*x) ``` [Answer] # Ruby, 30 bytes Returns `nil` (a falsy value) if no number was found. [[Try it online]](https://repl.it/FCkA) ``` ->n{(0..n).find{|i|3**i-1==n}} ``` [Answer] # C, 56 bytes ``` n;f(a){n=0;for(a++;!(a%3)&&(a/=3);++n);return --a?-1:n;} ``` add one to the input and then repeatedly divide by three until a remainder is found, if the one is reached return the count of divides else -1 [Answer] # [Bash](https://www.gnu.org/software/bash/) / Unix utilities, ~~37~~ 35 bytes ``` bc<<<`dc<<<3o$1p|grep ^2*$|wc -c`-1 ``` [Try it online!](https://tio.run/nexus/bash#@5@UbGNjk5ACIo3zVQwLatKLUgsU4oy0VGrKkxV0kxN0Df///29kBgA "Bash – TIO Nexus") Uses dc to convert to base 3, checks that the resulting string is all 2s, counts the number of characters (including a newline), and then uses bc to subtract 1. If the number in base 3 is *not* all 2s, then grep outputs nothing (not even a newline), so the character count is 0, and subtracting 1 yields -1. [Answer] # C compiled with Clang 3.8.1, ~~53~~, ~~52~~, ~~54~~, 51 Bytes ``` n;f(y){y++;for(n=0;y%3==0;y/=3)n++;return y^1?0:n;} ``` @SteadyBox already posted a solution in C, but I'm using a different approach. @Thanks to Jasen for helping save bytes. [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), 12 bytesSBCS Anonymous tacit prefix function. ``` (⊢×⌊=⊢)3⍟1+⊢ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R2wSNR12LDk9/1NNlC2RoGj/qnW@oDWQBJRWMFIzMFAwNjEwA "APL (Dyalog Unicode) – Try It Online") `1+⊢` increment `3⍟` log3 `(`…`)` apply the following function:  `⌊=⊢` is the floor equal to the argument? (0 or 1)  `⊢×` multiply the argument by that [Answer] # C, 42 Bytes, optimized from Wade Tyler's ``` n;f(y){for(n=0;y%3>1;y/=3)n++;return!y*n;} ``` [Try](https://tio.run/##TY7PCsIwDMbve4o4GLR2YsuOsT6JF9ms5GCUskHL2LPXrqLudwj58@VL@sO971NidCLK2T29YKsxNt3ZYDzaTrJS6G/j5HkX94xLIh7hcSUWEuYKMmuDWghYqmwBgqxBoJPRhZwq9VWvBLDgBEn8dciBCFvJystn6zyomwGa4cJ1W@5s1pbqHz9PgsZqSW8) # C, 37 Bytes, without `return` ``` n;f(y){for(n=0;y%3>1;y/=3)n++;n*=!y;} ``` [Try](https://tio.run/##TY3BCsIwDIbvfYo4KLR2YsuOsT6JF9ms5GCUMmFl7NlrV1D3HULy5/@T/nDv@5wZg0p6Ds@o2FtMsjs7TEffaTYGee93CZdMPMLjSqw0zAIKq0AtTFinkgZF3iHQydlKaY35ulcm8BAUafwpFEBNW8vKK5bTZdHIAeRw4aatfzaxRfxrvI3vyGBRLPkD) `n` is global but `(I)MUL` can only have its dest operand in a register, so have to put into `EAX`(the usual choice) and mov there # JavaScript 6, 32 Bytes ``` f=(y,n)=>y%3>1?f(y/3|0,-~n):!y*n ;[1,2,3,8,12,43046720].forEach(x=>console.log(f(x))) ``` If the "falsy" need to be same, 33 Bytes: ``` f=(y,n)=>y%3>1?f(y/3|0,-~n):!y&&n ``` [Answer] # [Pyt](https://github.com/mudkip201/pyt), ~~10~~ 9 bytes ``` ←⁺3ĽĐĐƖ=* ``` Explanation: ``` ← Get input ⁺ Add one 3Ľ Log base 3 ĐĐ Triplicate top of stack Ɩ Convert top of stack to integer = Check for equality between top two on stack * Multiply by log_3(input+1) ``` Saved a byte by using the increment function instead of explicitly adding 1 [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal) `r`, 6 bytes ``` ɾ3e‹ḟ› ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJyIiwiIiwiyb4zZeKAueG4n+KAuiIsIiIsIjI2Il0=) The `r` flag reverses the arguments of all functions. Explanation: ``` ɾ # Range from 1 to n 3e # 3 ^ each number in the range (not n ^ 3 because of the r flag) ‹ # Decrement ḟ # Index of the input › # Increment because ḟ is 0 indexed ``` [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 6 bytes ``` 3¨e‹ḟ› ``` [Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwiM8KoZeKAueG4n+KAuiIsIiIsIjI2XG4yXG4xMDI0Il0=) Decided this was different enough from the other Vyxal answers to post. ``` ḟ # find the index of the input in 3¨e # all powers of 3 ‹ # -1 › # and add 1 to that index ``` ]
[Question] [ ## Animate the text in your terminal **The goal** The goal is to "animate" the string "Hello world" in your output so that each character gets capitalised after each other. Your program can exit after each letter has been capitalised. For example; ``` # Iteration 1 Hello world # Iteration 2 hEllo world # Iteration 3 heLlo world # Iteration 4 helLo world # Iteration 5 hellO world # Iteration 6 (note: it should capitilize the space char (ie: a break between iteration 5 and iteration 7) hello world # Iteration 7 hello World # Iteration 8 hello wOrld # Iteration 9 hello woRld # Iteration 10 hello worLd # Iteration 11 hello worlD ``` It should only animate the string once and between each state there should be a 1 second delay. **Input** No input is required, but "Hello world" must be the string that is "animated". **Output** The string "Hello world" must be animated. The output must be as 1 line to create a sort of wave animation. An empty trailing new line is allowed. Example gif; ![https://i.gyazo.com/be12b693063b463540c5bf1f03d2454a.gif](https://i.gyazo.com/be12b693063b463540c5bf1f03d2454a.gif) I saw this on a metasploit youtube video and thought the effect was pretty cool, which is where I recorded the gif from, so it's a little laggy, but I hope it illustrates the output fine This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), lowest byte-count will be deemed the winner. [Sandbox Link](http://meta.codegolf.stackexchange.com/a/11486/38505) [Answer] # Vim 26 bytes ``` ihello world<ESC>qq~gsul@qq0@q ``` Explanation (no .gif yet): First, we must enter the 'hello world' text. This is pretty straightforward. It's just: ``` ihello world<ESC> ``` At this point, the cursor is on the 'd' in 'world'. Next: ``` qq " Start recording into register 'q' ~ " Swap the case of the character underneath the cursor, and move the cursor to the right gs " Sleep for one second u " Undo the last change (of swapping case). l " Move one character to the right (Get it? 'l' == 'Right' because vim is intuitive!) " This will cause the error to break on the last character of the input. @q " Call register 'q' q " Stop recording 0 " Move to the first character @q " Call the recursive macro ``` There are also two other 26 byte versions I found: ``` ihello world<ESC>qq~gsulq011@q ihello world<ESC>011@='~gsul'<cr> ``` [Answer] # Python 2, ~~98~~ ~~94~~ 90 bytes ``` for x in range(11):s='hello world';print'\r'+s[:x]+s[x:].capitalize(),;[1for y in' '*8**8] ``` ~~-9~~ -4 bytes thanks to @ElPedro -4 bytes thanks to @JonathanAllan and @Rod [Answer] # Commodore 64, 168 162 137 133 BASIC (and tokenized) bytes used ``` 0s=1024:?"{control+n}{clear home}hello world":fOi=.to1:fOj=.to11:x=pE(s+j):pokes+j,x+64 1x=pE(1023+j):pO1023+j,abs(x-64):pO1029,32:pO1035,32:fOz=.to99:i=.:nEz,j,i ``` You will need to use BASIC keyword abbreviations to enter this into a real C64 or emulator (or enter the program into a Commodore 128 and load it back in C64 mode, although this should work on the 128 as well). The `{control+n}` will only work/display after the opening quote. It is shorthand for `chr$(14)` and therefore saves some bytes and switches the character set to *business mode* or upper/lower case characters. I have added in some abbreviations for you so you. The `{clear home}` character is made by pressing `Shift` and the `CLR/HOME` key after the opening quotation mark. For illustrative purposes the unobfustcated listing may be entered as follows: ``` 0 let s=1024 1 print chr$(14); chr$(147); "hello world" 2 for i=0 to 1 3 for j=0 to 11 4 let x=peek(s + j) 5 poke s + j, x + 64 6 let x=peek(1023 + j) 7 poke 1023 + j, abs(x - 64) 8 poke 1029, 32 9 poke 1035, 32 10 for z=0 to 99 11 let i=0 12 next z 13 next j 14 next i ``` It works by switching the PETSCII charset into business mode (upper/lower case), and writing the hello world string to the top line of the screen which is located at memory location $0400, it will then take the value at each location for the next 11 bytes from there and increase each value by 64 (the upper case equivalent). If the j counter is > 0, it calls a routine at line 2 to decrease the previous memory location by 64 again. Line 3 is a pause, it also writes a space to to location $0405 and $040b, which is a bug fix (which could probably be removed to save some bytes). [![Commodore C64 animated hello world](https://i.stack.imgur.com/5M5L6.png)](https://i.stack.imgur.com/5M5L6.png) [Answer] # Powershell, ~~126~~ ~~119~~ ~~107~~ 104 Bytes ``` 'Hello world';$s='hello world';1..10|%{sleep 1;cls;-join($s[0..($_-1)]+[char]($s[$_]-32)+$s[++$_..11])} ``` [![enter image description here](https://i.stack.imgur.com/mRtoH.gif)](https://i.stack.imgur.com/mRtoH.gif) Revisions (there will likely be many): Change `$s.Length` to const ~~`10`~~ 11 Restructured string builder, removed 1 join statement and used `++$s` instead of `($s+1)`, to save some bytes thanks to [@AdmBorkBork](https://codegolf.stackexchange.com/users/42963/admborkbork) AdmBorkBork points out just using the string twice is actually shorter than encapsulating and then `.ToLower()`'ing it - which says a lot about how verbose powershell is, -3! --- basically loop through the length of the string, form an array of three parts, the pre-capitcal, capital, and post-capital, take 32 away from the middle letter, then convert back to a char to get upper case, luckily this doesn't turn space into a visible character either, I hope this is acceptable? [Answer] # C#, ~~230~~ ~~215~~ ~~193~~ ~~161~~ ~~135~~ ~~134~~ 130 bytes It's C# so it's long right! :-( But after some help and searching, I (and others, really) managed to remove exactly 100 bytes already. ## Golfed ``` ()=>{for(int i=1;;){var b="\rhello world".ToCharArray();b[i++]-=' ';System.Console.Write(b);System.Threading.Thread.Sleep(1000);}} ``` ## Ungolfed ``` class P { static void Main() { for (int i = 1;;) { var b = "\rhello world".ToCharArray(); b[i++] -= ' '; System.Console.Write(b); System.Threading.Thread.Sleep(1000); } } } ``` ### Screenshot [![Animation with 1 second delay](https://i.stack.imgur.com/8lMJ0.gif)](https://i.stack.imgur.com/8lMJ0.gif) Although it looks alot better when looping and faster.. ### Updates * Lost 15 bytes by using carriage return instead of `Clear()` which also allowed me to replace a using with `System.Console`somewhere inline. * Replaced program with lambda saving 23 bytes thanks to **@devRicher** * It became kind of a collaboration with **@devRicher** at this point, thanks to some of his suggestions I managed to lose another 32 bytes! * Thanks to 2 really smart and interesting suggestions by **@Kratz** I managed to replace `new string(b)` with `b` and `b[i]=char.ToUpper(b[i])` with `b[i]-=' '`, saving me another 26 bytes! * 1 byte less by moving `i++` thanks to **@Snowfire** * 4 bytes less by moving carriage return to the beginning of the string and removing `i<11` from my `for` loop [Answer] ## [CP-1610](https://en.wikipedia.org/wiki/General_Instrument_CP1600) assembly, 50 DECLEs = 63 bytes This code is intended to be run on an [Intellivision](https://en.wikipedia.org/wiki/Intellivision). A CP-1610 opcode is encoded with a 10-bit value, known as a 'DECLE'. This program is 50 DECLEs long, starting at $4800 and ending at $4831. ``` ROMW 10 ; use 10-bit ROM ORG $4800 ; start program at address $4800 main PROC 4800 0002 EIS ; enable interrupts (to enable display) 4801 0001 SDBD ; load pointer to string in R4 4802 02BC 0026 0048 MVII #@@str, R4 4805 02A2 MVI@ R4, R2 ; R2 = length of string 4806 0091 MOVR R2, R1 ; R1 = uppercase counter 4807 02BD 0214 @@loop MVII #$214, R5 ; R5 = video memory pointer 4809 0093 MOVR R2, R3 ; R3 = character counter 480A 02A0 @@next MVI@ R4, R0 ; R0 = next character 480B 0338 0020 SUBI #32, R0 ; minus 32 -> character # 480D 004C SLL R0, 2 ; multiply by 8 to get the 480E 0048 SLL R0 ; correct GROM card 480F 03F8 0007 XORI #7, R0 ; add 7 (for white) 4811 014B CMPR R1, R3 ; uppercase? ... 4812 020C 0002 BNEQ @@draw 4814 0338 0100 SUBI #256, R0 ; ... yes: sub 32*8 4816 0268 @@draw MVO@ R0, R5 ; draw character 4817 0013 DECR R3 ; decrement character counter 4818 022C 000F BNEQ @@next ; process next character or stop 481A 0001 SDBD ; R0 = spin counter to wait ~1 second 481B 02B8 0038 00D3 MVII #$D338, R0 ; = 54072 = 13518 * 60 / 15 ; (assuming 13518 cycles per frame) 481E 0010 @@spin DECR R0 ; 6 cycles 481F 022C 0002 BNEQ @@spin ; 9 cycles ; -> 15 cycles per iteration 4821 0114 SUBR R2, R4 ; reset pointer to beginning of string 4822 0011 DECR R1 ; decrement uppercase counter 4823 022C 001D BNEQ @@loop ; process next iteration or stop 4825 0017 DECR PC ; infinite loop 4826 000B 0068 0065 006C @@str STRING 11, "hello world" 482A 006C 006F 0020 0077 482E 006F 0072 006C 0064 ENDP ``` ### Output [![enter image description here](https://i.stack.imgur.com/sawzc.gif)](https://i.stack.imgur.com/sawzc.gif) [Answer] # [MATL](https://github.com/lmendo/MATL), 30 bytes ``` 11:"10&Xx'hello world't@)Xk@(D ``` Try it at [MATL Online!](https://matl.io/?code=11%3A%2210%26Xx%27hello+world%27t%40%29Xk%40%28D&inputs=&version=19.7.4) ``` 11: % Push [1 2 ... 11] " % For each k in [1 2 ... 11] 10&Xx % Pause for 10 tenths of a second and clear screen 'hello world' % Push this string t % Duplicate @) % Get the k-th character from the duplicated string Xk % Convert to uppercase @( % Write into the k-th position of the string D % Display % Implicit end ``` [Answer] # PHP, ~~76~~ ~~74~~ 71 bytes Thank you @hd for the delay being a full second and no fraction thereof! Thanks @user63956 for 2 bytes and @aross for 3 bytes. ``` for(;$c=($s="hello world")[$i];sleep(print"$s\r"))$s[$i++]=ucfirst($c); ``` Run with `-nr`. [Answer] # C, ~~97~~ ~~withdrawn~~ 106 bytes with escaped characters counted as 1 byte ``` char*a="HELLO\0WORLD\xED";b,c;m(){for(b=0;b<156;putchar(a[c]+32*(b/12^c||c==5)))(c=b++%12)||fflush(sleep(1));} ``` Note: I have ~~commented out the time delay on~~ unlinked TIO because it waits for completion before displaying the output, it also doesn't seem to recognize carriage returns and puts new lines. Also, if you're on Windows, sleep is in milliseconds instead of seconds, so `sleep(1)` should become `sleep(1000)`. ~~Note 2: I've withdrawn this entry for the moment until the output bugs have been ironed out.~~ [Answer] # JavaScript (ES6), ~~141 139~~ 131 bytes *Saved 8B thanks to Apsillers* ``` _=>a=setInterval("b=[...`hello world`],c.clear(b[d]=b[d].toUpperCase(++d>10&&clearInterval(a))),c.log(b.join``)",1e3,c=console,d=0) ``` # Explanation This creates a function with no arguments, which splits the string `hello world` into an array of characters and capitalises the `d+1`th character. `d` is a counter that starts as `0` and is increased every time. # Usage ``` f=_=>a=setInterval("b=[...`hello world`],c.clear(b[d]=b[d].toUpperCase(++d>10&&clearInterval(a))),c.log(b.join``)",1e3,c=console,d=0) f() ``` [Answer] # [Noodel](https://tkellehe.github.io/noodel/), 22 [bytes](https://tkellehe.github.io/noodel/docs/code_page.html) ``` ”<8@\|DḶ|\6þıHḶƥɲSḍsɲS ``` [Try it:)](https://tkellehe.github.io/noodel/editor.html?code=%E2%80%9D%3C8%40%5C%7CD%E1%B8%B6%7C%5C6%C3%BE%C4%B1H%E1%B8%B6%C6%A5%C9%B2S%E1%B8%8Ds%C9%B2S&input=&run=true) --- # How it works ``` ”<8@\|DḶ|\6þ # Displays the string "hello¤world". ”<8@\|DḶ|\6 # Decompresses to the array ["h", "e", "l", "l", "o", "¤", "w", "o", "r", "l", "d"] and pushes it on top of the stack. þ # Pushes a copy of the array to the screen which since is an array is done by reference. ı # Makes the array on the top of the stack the new stack. HḶƥɲSḍsɲS # Loops eleven times creating the animation. H # Pushes the string "H" on to the top of the stack. Ḷ # Consumes the "H" that gets evaluated as a base 98 number which comes out to eleven. ƥ # Move the stack pointer up one. ɲS # Switch the case of the top of the stack which will show up on the screen because the array is done by reference. ḍs # Delay for one second. ɲS # Switch the case back. # Implicit end of the loop. ``` --- The snippet uses a **25 byte** version that loops continuously. ``` <div id="noodel" cols="10" rows="2" code="”<8@\|DḶ|\6þıḷʠ*HḶƥɲSḍsɲS" input=""/> <script src="https://tkellehe.github.io/noodel/release/noodel-2.5.js"></script> <script src="https://tkellehe.github.io/noodel/ppcg.min.js"></script> ``` [Answer] # Bash + coreutils, ~~99~~ 98 bytes ``` x=hello\ world for((;n<11;)){ echo -en "\r${x:0:n}"`tr a-z A-Z<<<"${x:n:1}"`"${x:n+++1}" sleep 1 } ``` [Answer] # [Perl 6](http://perl6.org/), ~~65~~ 61 bytes ``` for 3..12 ->\i{sleep say "\echello world".&{S:nth(i)/./{$/.uc}/}} ``` ``` (sleep say S:nth(3+$++)/./{$/.uc}/with "\echello world")xx 11 ``` GIF: [![enter image description here](https://i.stack.imgur.com/qBOrp.gif)](https://i.stack.imgur.com/qBOrp.gif) ### How it works The ANSI escape sequence `\ec` clears the screen. Each iteration, the `i`'th character of the hard-coded string is substituted by its upper-case version. The `say` function always returns `True`, which is passed on to the sleep function which interprets it as `1` second. [Answer] ## Ruby, ~~82~~ 81 bytes ``` 12.times{|a|$><<?^H*11;'Hello world'.chars{|y|$><<((0!=a-=1)?y:y.upcase)};sleep 1} ``` ^H is ascii 8 (backspace), and is only 1 byte. [Answer] # C, 87 bytes ``` m(){char*f,a[]="\rhello world";for(f=a;*++f;*f&=95,printf(a),*f|=32,fflush(sleep(1)));} ``` Compiles and runs on Linux. [Answer] # Mathematica, ~~130~~ ~~128~~ ~~123~~ ~~110~~ 108 bytes ``` Dynamic@o s="hello world";i=1;t=StringTake;Do[o=t[s,{1,i-1}]<>Capitalize@t[s,{i}]<>t[s,{++i,11}];Pause@1,11] ``` Explanation: From `i=1` to 11, print from the 1st to the (i-1)th character of "hello world", capitalise `"hello world"[i]`, then print the rest of the string, incrementing `i` at the same time. [Answer] # Java ~~215~~ ~~212~~ ~~204~~ 203 bytes ``` interface A{static void main(String z[])throws Exception{for(int i=0;i<10;i++){char[]b="helloworld".toCharArray();b[i]=Character.toUpperCase(b[i]);System.out.println(new String(b));Thread.sleep(1000);}}} ``` Ungolfed: ``` interface A { static void main(String z[]) throws Exception { for (int i = 0; i < 10; i++) { char[] b = "helloworld".toCharArray(); b[i] = Character.toUpperCase(b[i]); System.out.println(new String(b)); Thread.sleep(1000); } } } ``` [Answer] # [R](https://www.r-project.org/), ~~106~~ 103 bytes ``` x=el(strsplit("hello world","")) for(i in 1:11){y=x;y[i]=toupper(y[i]);cat('\f',y,sep='');Sys.sleep(1)} ``` Just a simple loop, clearing the console with `cat('\f')` seems somewhat system-dependent but I am not aware of a better way. [Answer] # C, 122 bytes ``` i;f(){char s[]="Hello world\r";for(i=0;i<11;i++){s[i]=toupper(s[i]);s[i-1]=tolower(s[i-1]);printf(s);fflush(0);sleep(1);}} ``` Shorter than C# :D [Answer] # Perl, 75 bytes ``` sleep print"\33c".("hello world"=~s/(.{$_})(.)(.*)/$1\U$2\E$3\n/r)for 0..10 ``` Uses the ANSI code `ESC``c` to clear the console and move the cursor to the top left at every iteration, but still needs `\n` at the end of the replace string to avoid having the whole animation lost in the line buffer. A successful call to `print` returns a value of 1, which can be passed directly to `sleep`. [Answer] # SmileBASIC, ~~90~~ 71 bytes ``` FOR I=0TO 10CLS?"hello world LOCATE I,0?CHR$(CHKCHR(I,0)-32)WAIT 60NEXT ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~24~~ 21 bytes ``` ”Æ⁹Œu⁸¦ȮœS “½,⁻⁸3»Jç€ ``` This is a niladic link/function that prints to STDOUT. It does not work as a full program. The code can't be tested on TIO; it uses control characters and TIO has no terminal emulator (yet). ### How it works ``` “½,⁻⁸3»Jç€ Niladic link. No arguments. “½,⁻⁸3» Index into Jelly's dictionary to yield "hello world". J Indices; yield [1, ..., 11]. ç€ Apply the helper link to each index, with right arg. "hello world". ”Æ⁹Œu⁸¦ȮœS Dyadic helper link. Left argument: i. Right argument: "hello world" ”Æ Set the return value to '\r'. ⁹ Set the return value to "hello world". Implicitly prints '\r'. Œu⁸¦ Uppercase the i-th letter. Ȯ Print. œS Sleep "hello world" seconds. (Strings are cast to Boolean.) ``` [Answer] # C, 122 bytes As an exercise, I wrote this to provide a more optimal output format than some of the other answers. Also it means the cursor sits after the most recently capitalized letter during the pauses. ``` main(){ char*p=".Hello world\rH"; write(1,p+1,13); do{ sleep(1); *p=8; p[1]|=32; p[2]^=(p[2]>32)*32; write(1,p++,3); }while(p[4]); } ``` (Newlines and indentations cosmetic and not part of byte count) Now, some readers may note that this requires some massaging to get to run on modern machines (the magic incantation is `-static -Wl,-N`), but this is how real implementations of C used to behave, so I think it is valid. It also assumes the character set is ASCII, and it does not print a trailing newline. Bonus: For an EBCDIC version, you can replace `8` with `22` and `64` with `32`, and switch the logic for `p[1]` and `p[2]`. To test on a non-EBCDIC system, you can compile with `-funsigned-char -fexec-charset=cp037`. Output is 43 bytes: `Hello world«H‹hE‹eL‹lL‹lO‹o ‹ W‹wO‹oR‹rL‹lD` [Answer] # Scala, 92 bytes ``` val h="hello world" 0 to 10 map{i=>print("\b"*99+h.updated(i,h(i)toUpper)) Thread sleep 999} ``` ## Ungolfed ``` val h="hello world" //declare a variable h with the string "hello world" 0 to 10 //create a range from 0 to 10 map { i=> //loop with index i print( //print "\b" * 99 //99 backspace chars + h.updated( //and h with i, //the i-th char h(i).toUpper //replaced with the i-th char in uppercase ) ) Thread sleep 999 //sleep 999 ms } ``` [Answer] # Clojure, 116 bytes ``` (doseq[i(range 11)](Thread/sleep 1000)(print"\r"(apply str(update(vec"hello world")i #(char(-(int %) 32)))))(flush)) ``` Basically a for-loop that goes over the indices of each character, updating each character in turn. ``` (defn -main [] (doseq [i (range 11)] ; For the index of each character... (Thread/sleep 1000) (print "\r" ; Clear old line (apply str ; Turn the vector back into a string (update ; Update the char at index i (vec "hello world") ; Turn the string into a vector so it's updatable i ; Index to update #(char (- (int %) 32))))) ; Subtract 32 from the character to make uppercase (flush))) ``` [Answer] ## Batch, 184 bytes ``` @echo off for %%h in (Hello hEllo heLlo helLo hellO hello)do call:c %%h world for %%w in (World wOrld woRld worLd worlD)do call:c hello %%w exit/b :c timeout/t>nul 1 cls echo %* ``` Curiously the command line for `timeout/t>nul 1` gets corrupted if there is no trailing newline, so I can't put it at the end of the file. [Answer] # Ruby, 108 bytes First time, first year student. It's no eagle but I'm at least a little proud. ``` 12.times{|i|sleep(0.1); puts "\e[H\e[2J", "hello world".sub(/(?<=.{#{Regexp.quote(i.to_s)}})./, &:upcase);} ``` [Answer] # Pascal, ~~187~~ 152 bytes Not exactly the most efficient or the shortest, but works quite well! ``` uses crt,sysutils;label R;const X:Word=1;P='hello world';begin R:clrscr;write(P);gotoxy(X,1);write(upcase(P[X]));sleep(999);X:=X*Ord(X<11)+1;goto R end. ``` Tested and works on Free Pascal Compiler 2.6+. Thanks to [@manatwork](https://codegolf.stackexchange.com/users/4198/manatwork) for saving **35** bytes! --- I've used <http://www.onlinecompiler.net/pascal> to compile the file and run it on Windows. Haven't seen any problem with it, so far. [Answer] ## C ~~120~~ ~~110~~ ~~104~~ 96 bytes ``` f(){char *j,s[]="\rhello world";for(j=s;*++j;*j-=32,printf(s),*j+=32,fflush(0),sleep(‌​1));} ``` Ungolfed version ``` void f() { char *j; char s[]="hello world"; j=s; for (;*j;j++) { *j-=32; printf(s); // print the string and right after change the same char to lower case *j+=32; fflush(0); sleep(1); } } ``` @Pakk Thanks for saving some bytes, great idea. :) @Pakk @KarlNapf Thanks guys for your inputs. can still be shortened!? :) [Answer] ## Python 2, ~~220~~ ~~189~~ 179 bytes Solution without using strings and `capitalize()`, byte count as is: ``` import time,sys from numpy import * F=fromstring("\rhello world",int8) for i in range(1,12): time.sleep(1) F[i]-=32 savetxt(sys.stdout,F,fmt="%c",newline="") F[i]+=32 ``` And a bit longer variant (191 chars) without case resetting: ``` import time,sys from numpy import * a=arange(11) F=tile(fromstring("\rhello world",int8),(11,1)) F[a,a+1]-=32 for i in a: time.sleep(1) savetxt(sys.stdout,F[i],fmt="%c",newline="") ``` ]
[Question] [ > > This challenge has ended. To see the final scores of the competitors, [click here](https://chat.stackexchange.com/transcript/message/51317259#51317259) > > > In this challenge, each submission is one bot. Each bot should be a Javascript function. Bots will fight to obtain the highest total worth in gold. Gold can be farmed, or earned from killing other bots, and is used to upgrade healing, attacking, shielding, and farming. **Objective:** Over a number of rounds containing up to 1000 turns (ends when only one bot is left), the bot with the highest total worth (the sum of all gold obtained) is the winner. **Turns:** In each turn, every bot which is alive (>0 HP) will be run once. It can return a move, which can be one of the following: * Heal: Regains HP * Attack: Removes HP from another bot * Shield: Defends against later attacks * Stun: Skips another bot's next turn * Farm: Earns gold at the cost of HP * Upgrade: Make certain moves better All bots will return their move before any are executed, so a stun, heal, attack, shield, etc. will not affect any bots moving later in that turn. For example, if Bot A stuns Bot B, and Bot B is after Bot A in the turn order, Bot B will still move later in that same turn and the stun will occur on the next turn. **Combat, Farming, and Upgrading:** Each bot has a maximum HP of 100, and an assigned UID between 0 and 99. This UID changes after every round, and is how bots keep track of each other. Healing is one of the simplest moves, adding an amount of HP determined by its level (starts at 5 HP). A bot cannot heal past 100 HP. Attacking a bot by its UID is another possible move, with a base damage of 5 HP at level 0. Bots can also be stunned, skipping their next turn, which also uses UIDs. Bots have additional shield HP, which has no limit. This shield HP will absorb damage from direct attacks from other bots, and is added by shielding. At level 0, shielding adds 5 shield HP. Farming will earn 5 gold at level 0, at the cost of 2 HP. This 2 HP cannot be shielded. The only use for gold (beyond winning) is to upgrade moves. Healing, attacking, and shielding have a base value of 5 HP, and farming starts at 5 gold. Each of those moves have individual levels, which start at 0. These formulas will determine the value in HP or gold of a move, where L is the level: * Healing: `L + 5` * Attacking: `1.25L + 5` * Shielding: `1.5L + 5` * Farming: `2L + 5` The cost of upgrading any move is the same for a certain level, and is determined by `2.5L² + 2.5L + 10`, where L is the current level. A bot can use the function `cost(currentLevel)` as a shortcut to determine this. Bots start with 25 gold, allowing them to quickly upgrade either two moves to level 1, or one move to level 2. This beginning gold does not count towards a bots total worth. Killing a bot gives you half of its total worth in gold, rounded up, and if two bots kill another in the same turn, they both get the reward. **Input/Output:** In order to communicate with the controller, the return value of the function is used to send move information. One of these should be returned: * Heal: `heal()` * Attack: `attack(uid)` * Shield: `shield()` * Stun: `stun(uid)` * Farm: `farm()` * Upgrade: `upgrade("heal" / "attack" / "shield" / "farm")` To skip a turn (do nothing), return nothing, or return a falsy value. To get the current turn number (starts at 1), use `turn()`. The arguments of your function will include information about your bot, UIDs of other bots, and between-turn storage. The first argument is an object with the following properties: `uid`, `hp`, `gold`, and `shield`. These are copies of your bot's current information. There is also an nested object `levels`, with the level numbers of `heal`, `attack`, `shield`, and `farm`. The second argument is a shuffled array of all alive bots other than yours, formatted as an object containing properties `uid`, `hp` (plus shield), `worth`, and `attack` (attack level). The third argument is an empty object which can be used for between-turn storage. **Example Bots:** This bot will farm until it can upgrade its attack to level 5, then attack a random bot each turn until it dies (or wins). Not very effective due to lack of healing/shielding. ``` function freeTestBotA(me, others, storage) { if (me.levels.attack < 5) { if (me.gold < cost(me.levels.attack)) return farm(); return upgrade("attack"); } return attack(others[0].uid); } ``` This bot has two modes: offensive and defensive. It will either stun a random bot or heal when in defensive mode, and it will either attack or shield when in offensive mode. It will attempt to upgrade its attacks whenever possible. ``` function freeTestBotB(me, others, storage) { if (me.gold >= cost(me.levels.attack)) return upgrade("attack"); if (me.hp < 50) if (Math.random() < 0.5) return stun(others[0].uid); else return heal(); else if (Math.random() < 0.5) return attack(others[0].uid); else return shield(); } ``` **Rules:** * [Standard Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) forbidden * Bots may not read, modify, or add any variables outside of their scope, may not attempt to cheat, and may not call any controller-defined or DOM functions * Return value must be falsy, or one of the above function outputs * Bots should not be designed to target a specific bot, but can be designed to take advantage of common strategies * Bots may not attack themselves (discovered due to a comment by @Ness) * Bots must be sufficiently different from any other bots that they can be reasonably considered separate entries * Teaming is **now not** allowed * Controller can be found [here](https://gist.github.com/Radvylf/a8089fee5921b6118b92f429f8f60083) * [Chatroom](https://chat.stackexchange.com/rooms/96920/gold-battle-koth) **New Controller Debugging:** Using the file `gold-battle-log.js`, you can set the value of the `debug` property of a bot in `botData` to 0 (no logging), 1 (log moves), or 2 (log moves, hp, gold, levels, etc.) **Challenge ends at 1700 UTC on Friday, August 9th** [Answer] # Unkillable forked from [Undyable](https://codegolf.stackexchange.com/a/189115/47990). ``` function UnkillableBot(me){ if(me.hp <= 100 - (me.levels.heal + 5)){ return heal() }else if(turn() % 10 == 0 && me.shield < 800) { return shield() }else{ if(me.gold >= cost(me.levels.shield) && me.levels.shield <= 9){ return upgrade("shield") }else if(me.gold >= cost(me.levels.farm)){ return upgrade("farm") }else{ if(me.shield < 500 && me.levels.shield > 4) { return shield() } return farm() } } } ``` Given the exponential costs of upgrades, may as well upgrade farming if we can't upgrade healing, allowing the bot to collect gold more efficiently. [Answer] # ThanosBot ``` function ThanosBot(me, others, storage){ if(turn()==1){ storage.origPopulation = others.length; return upgrade("attack"); } if (others.length < storage.origPopulation / 2) { if(me.hp <= 100 - (me.levels.heal + 5)){ return heal(); } else { return farm(); } } if(me.hp <= 100 - (me.levels.heal + 5)){ return heal() }else{ if(me.gold >= cost(me.levels.attack)){ return upgrade("attack") }else if(me.gold >= cost(me.levels.heal)){ return upgrade("heal") }else if(me.gold >= cost(me.levels.farm)){ return upgrade("farm") }else{ if(Math.random() < 0.5){ return attack(others[0].uid); } else{ return farm(); } } } } ``` There are too many bots, not enough gold to go around. This bot proposes a solution. Genocide, yes, but random, dispassionate, fair to rich and poor alike. They called him a madman. ThanosBot wants the best for the bot community, and is willing to go all the way. In the beginning, he will upgrade his attack, farming and healing, to more efficiently gather resources and win battles. Prograssively, he will start attacking people randomly while still gathering resources, for upcoming battles. He will keep improving his army, his weapons and himself. Once 50% of the population has been eliminated, bots born will only know full bellies and clear skies, he will retire to a life of farming, and watch the sun rise on a grateful universe. He will become completely pacifist, only healing himself with vegetable soups and farming. [Answer] # Kill Stealer ``` function killStealer({hp, gold, attack:atck, shield:shld, levels:{heal:lHeal, shield:lShld, farm:lFarm, attack:lAtck}}, es, S) { let saneReduce = (a, f, n) => a.length? a.reduce(f) : n; let t = turn(); if (t===1) { S.worth = 0; S.pHP = 100; S.pGold = 0; S.stat = {}; S.pT = 0; for (let e of es) S.stat[e.uid] = {kills:0, seen:0}; } let pT = S.pT; S.pT = t; let shp = shld+hp; let healP = lHeal + 5; let shldP = lShld*1.5 + 5; let farmP = lFarm*2 + 5; let atckP = lAtck*1.25 + 5; let pheal = () => hp<5 || Math.min(100, hp+healP)-hp > shldP? heal() : shield(); let attacked = S.pHP-hp-shld > 2; S.pHP = hp+shld; if (gold>S.pGold && t!=1) S.worth+= gold-S.pGold; S.pGold = gold; let pes = S.pEs; let ces = {}; for (let e of es) ces[e.uid] = {uid:e.uid, hp:e.hp, worth:e.worth}; S.pEs = ces; if (t === 1) return shield(); // to not break things depending on previous frame if (t == pT+1) { for (let uidE in pes) { let e = pes[uidE]; if (!ces[uidE]) { // dead if (e.worth < 30) continue; // don't bother, because others probably won't for (let a of es) { let pa = pes[a.uid]; if (a.worth >= pa.worth + e.worth/2 - 2) { S.stat[a.uid].kills++; } if (a.worth != pa.worth || a.hp > pa.hp) S.stat[a.uid].seen++; } } } } let attackers = es.filter(c => { let k = S.stat[c.uid].kills; let s = S.stat[c.uid].seen; return k > 1 && k > s*.7; }); let maxDmg = es.map(c=>c.attack).reduce((a, b) => Math.max(a, b), 0)*1.25 + 5; for (let e of es) { if (e.worth < farmP) continue; let p = pes[e.uid]; let dmg = p.hp-e.hp; if (e.hp <= atckP) { return attack(e.uid); } if (e.hp-dmg-atckP <= 0) { return attack(e.uid); } if (e.hp-maxDmg-atckP <= 0) { return attack(e.uid); } if (e.hp-maxDmg-dmg <= 0) { return attack(e.uid); } } if (attackers.length>0 && t>50) { for (let e of es) { if (e.hp - maxDmg*2 - atckP <= 0 && e.worth > 200) { let worst = saneReduce(attackers.filter(c => c.hp > 80), (a, b)=>a.worth>b.worth? a : b, null); if (worst) return stun(worst.uid); } } } if (t < 60 && t%5 == 1) return shield(); if (t === 2) return upgrade("heal"); if (t === 3) return upgrade("farm"); if (t%10 == 1) return shield(); if (gold>=cost(lShld) && lFarm>-2) return upgrade("shield"); if (gold>=cost(lFarm) && !attacked) return upgrade("farm"); if (es.length > 2) { let notDead = es.filter(c => c.hp > 20); if (notDead.length !== 0) { notDead.sort((a, b) => a.hp-b.hp); if (notDead[Math.min(2, notDead.length-1)].hp > shp) { return pheal(); } } } if (gold>=cost(lHeal) && lHeal+5 < lFarm) return upgrade("heal"); if (gold>=cost(lAtck) && lAtck+5 < lFarm && es.every(c=>c.attack<=lAtck+2)) return upgrade("attack"); if (lShld>5 && shp < 205+healP+t && shp < 600+t*5) return pheal(); if (es.every(c => c.worth < S.worth+farmP) && es.length>2 && t<100 && lShld<6) return pheal(); if (shp<=120 || hp<5) return pheal(); return farm(); } ``` Now not only steals kills, but steals stealing kills too! This bot doesn't do much except farm, and when it notices the possibility, joins in doing the final blow to a dying enemy, and somehow manages to be very good. [Answer] # Optimist ``` function Optimist(me, others, storage) { if (me.hp < 10) return heal(); if ( (me.hp + me.shield) < 50 ) return shield(); if (me.gold >= cost(me.levels.farm) && cost(me.levels.farm) < 0.8 * (1000 - turn())) return upgrade("farm"); rich_bots = others.sort( (x,y) => y.worth - x.worth ); potential_victim = rich_bots.find( bot => bot.hp <= me.levels.attack * 1.25 + 5 ); if (potential_victim) return attack(potential_victim.uid); if (me.gold < rich_bots[0].worth + cost(me.levels.farm) + 25) return farm(); if (me.levels.heal < me.levels.farm) return upgrade("heal"); if (me.levels.shield < me.levels.heal) return upgrade("shield"); if (me.levels.attack < me.levels.shield) return upgrade("attack"); return shield(); } ``` Assumes it will be able to spend 80% of its time peacefully farming, so it starts off by maxing out farming, and only then starts paying any attention to its combat skills. Surely nothing will go wrong! [Answer] # The Equalizer This bot seeks to restore peace in the bot community. He relentlessly targets the bots with the highest attack, giving up only if the bot's healing is better than his own attack. Once no bots with healing worse than its attack are left, he will retire to a life of peaceful farming. ``` function equalizer(me, others, storage){ if(storage.agroKilled == null)storage.agroKilled = false; if(!storage.agroKilled){ if(storage.blacklist == null)storage.blacklist = []; if(storage.lastAttack == null)storage.lastAttack = -1; var maxAtk = 0; var maxAtkUid = -1; var maxAtkHealth = 0; for(var i = 0; i < others.length; i++)if(others[i].uid == storage.lastAttack){ maxAtk = others[i].attack*1.25+5; maxAtkUid = storage.lastAttack; maxAtkHealth = others[i].hp; } for(var i = 0; i < others.length; i++){ if(storage.lastAttack == others[i].uid && others[i].hp >= storage.lastHealth){ maxAtk = 0; maxAtkUid = -1; maxAtkHealth = 0; storage.blacklist.push(others[i].uid); } } storage.lastAttack = -1; var willHeal; for(var i = 0; i < others.length; i++)if(others[i].attack*1.25+5 > maxAtk){ willHeal = false for(var j = 0; j < storage.blacklist.length; j++)if(others[i].uid==storage.blacklist[j])willHeal = true; if(!willHeal){ maxAtk = others[i].attack*1.25+5; maxAtkUid = others[i].uid; maxAtkHealth = others[i].hp; } } if(me.hp < maxAtk) return heal(); if(me.hp <= 100 - me.levels.heal - 5) return heal(); var target = -1; var targetWorth = me.levels.farm * 2 + 5; for(var i = 0; i < others.length; i++) { if (others[i].hp <= maxAtk && others[i].worth / 2 > targetWorth) { target= others[i].uid; targetWorth = others[i].worth / 2; } } if(target!=-1) return attack(target); if(me.gold >= cost(me.levels.attack)) return upgrade("attack"); if(me.levels.heal + 7 < me.levels.attack && me.levels.heal < 9 && me.gold >= cost(me.levels.heal)) return upgrade("heal"); if(maxAtkUid!=-1){ storage.lastAttack = maxAtkUid; storage.lastHealth = maxAtkHealth; return attack(maxAtkUid); } storage.agroKilled = true; } if(me.hp < 30) return heal(); if(me.gold > cost(me.levels.farm)) return upgrade("farm"); return farm(); } ``` [Answer] # Kill Assist ``` function KillAssist(me, others, storage) { let t = turn(); if (t===1) { storage.worth = 0; storage.pHP = 100; storage.pGold = 0; } let hp = me.hp; let gold = me.gold; let shld = me.shield; let lHeal = me.levels.heal+0.25; let lFarm = me.levels.farm; let lShld = me.levels.shield; let lAtck = me.levels.attack; let healPower = lHeal + 4.75; let shldPower = lShld*1.5 + 5; let farmPower = lFarm*2 + 5; let atckPower = lAtck*1.25 + 5; let dmgTaken = storage.pHP-(hp+shld); let attacked = dmgTaken > 2; storage.pHP = (hp+shld); if (gold > storage.pGold) storage.worth+= gold-storage.pGold; if (gold-storage.pGold > farmPower+5) storage.lastAtck = -10; storage.pGold = gold; let pOthers = storage.pOthers; storage.pOthers = {}; for (let o of others) { storage.pOthers[o.uid] = {hp: o.hp, uid: o.uid, worth: o.worth}; } if (t === 1 || t === 2) return upgrade("shield"); if (t === 3) return shield(); let maxdmg = others.map(c=>c.attack).reduce((a, b) => Math.max(a, b))*1.25 + 5; let lowhp = others.map(c=>c.hp).reduce((a, b) => Math.min(a, b)); let lowhpid = others.find(c=>c.hp == lowhp).uid; let maxAttacker = others.find(o => o.attack*1.25 + 5 == maxdmg).uid; for (let o of others) { if (o.hp < atckPower && o.worth > farmPower) { storage.dead = o.uid; storage.deadWorth = o.worth; return attack(o.uid); } let pO = pOthers[o.uid]; let dmg = pO.hp - o.hp; if (o.hp - dmg - atckPower <= atckPower && o.worth >= farmPower) { storage.dead = o.uid; storage.deadWorth = o.worth; return attack(o.uid); } if (o.hp - maxdmg - atckPower <= atckPower && o.worth >= farmPower) { storage.deadWorth = o.worth; return attack(o.uid); } } let lowhpdiff = Math.max(pOthers[lowhpid].hp - others.find(o => o.uid == lowhpid).hp,0); if (others.some(o => o.hp > maxdmg && o.hp < lowhpdiff*2+atckPower+maxdmg && o.worth > farmPower)) { let bad = others.reduce((a, b) => a.worth>b.worth? a : b); let bad2 = others.reduce((a, b) => bad.uid == b.uid ? a : (bad.uid == a.uid ? b : (a.worth>b.worth ? a : b))); if(bad.worth < bad2.worth*3 && bad.hp >= (maxdmg+atckPower)*2 && bad.uid != maxAttacker && bad.uid != lowhpid) { return stun(bad.uid); } if(bad2.hp >= (maxdmg+atckPower)*2 && bad2.uid != maxAttacker && bad.uid != lowhpid) { return stun(bad2.uid); } } if (t%10 == 9 && lShld>4) return shield(); // slowly build up shield just in case if (shld+hp < 100) return shldPower>healPower || hp >= 100-healPower? shield() : heal(); var bon = shldPower-maxdmg < 3 && t < 700 ? lShld/2 : 0; var bon2 = t/100; if (gold>=cost(lFarm) && lShld+2 > lFarm && bon == 0 && !attacked) return upgrade("farm"); // farm first, but make sure it doesn't get too far ahead if (gold>=cost(lShld) && t>20 && (lShld<10+bon || lShld+5+bon2 < lFarm+bon) && t < 900) return upgrade("shield"); if (gold>=cost(lFarm)) return upgrade("farm"); // try upgrading farming again, because shield upgrading can be picky if (gold>=cost(lHeal) && (lHeal<3)) return upgrade("heal"); // healing isn't that important if (shld<200 && attacked || shld<500 && t>20 && others.filter(c=>c.hp>=100).every(o=>o.hp+10 > hp+shld)) return shldPower>healPower || hp >= 100-healPower? shield() : heal(); let hpdelta = attacked ? dmgTaken+shldPower : maxdmg if (shld<lShld*60 && (1000-t)*(hpdelta) > shld+hp) return shield(); // we want to look impressive & terrifying if (hp<=100-healPower) return heal(); return farm(); } ``` Why upgrade attack value when you can do plink damage and still get full credit? Once more back to piggybacking off Kill Stealer. I was able to simplify several blocks of code where statements were always true and fiddle with some numbers that resulted in massive gains over the original. I have to hand it to @dzaima for realizing that stunning a wealthy opponent that is likely to be involved in an assist the turn before a kill happens is quite clever. One of the (very) few times `Stun()` has a positive sum outcome. Once again I was able to improve upon the idea, as knowing that Kill Stealer will be running similar logic, Kill Assist looks for a "second best" target (with some discretion) and stuns them instead. Minor update to prevent stunning the bot-about-to-die and prevent stunning the bot-most-likely-to-make-the-kill. Sample results (truncated top 5 after 1000 games) ``` VM2406:1629 Kill Assist: 39495.679 VM2406:1629 The Accountant: 29990.267 VM2406:1629 Kill Stealer: 23530.153 VM2406:1629 Unkillable: 12722.604 VM2406:1629 captFarmer: 12232.466 ``` [Answer] # The Bot That Farms, Attacks, Shields, And Even Heals But Never Stuns *(Short name is **TBTFASAEHBNS**, not to be mistaken with [TBTPTGCBCBA](https://codegolf.stackexchange.com/a/170251/81663))* ``` function TBTFASAEHBNS(me, others, storage) { this.getLevel = function (type) { return (typeof me.levels[type] === 'undefined' ? 0 : me.levels[type]); }; this.getPower = function (type, level) { if (typeof level === 'undefined') level = this.getLevel(type); if (type === 'heal') return level + 5; if (type === 'attack') return (level * 1.25) + 5; if (type === 'shield') return (level * 1.5) + 5; if (type === 'farm') return (level * 2) + 5; }; this.canUpgrade = function (type) { return myGold >= cost(this.getLevel(type)); }; this.farmOrUpgradeFarm = function () { if (this.canUpgrade('farm')) return upgrade('farm'); if (myHp < 3) return heal(); return farm(); }; let currentTurn = turn(), myGold = me.gold, myHp = me.hp, myShield = me.shield, myTotalHp = myHp + myShield, myHealPower = this.getPower('heal'), myShieldPower = this.getPower('shield'), myAttackPower = this.getPower('attack'), myFarmPower = this.getPower('farm'), topAttackPower = 0, attackOptions1 = [], attackOptions3 = [], attackOptions2 = [], finalTurns = 980; if (currentTurn === 1) { storage.othersInfo = {}; } others.sort((a, b) => b.attack - a.attack); for (let i = 0; i < others.length; i++) { let other = others[i]; if (i < 3) topAttackPower += this.getPower('attack', other.attack); if (other.worth > myFarmPower) { if (other.hp <= myAttackPower) { attackOptions1.push(other); } else { if (typeof storage.othersInfo[other.uid] !== 'undefined') { let otherHpChange = storage.othersInfo[other.uid].hp - other.hp; if (other.hp - otherHpChange <= 0) { attackOptions2.push(other); } else if (other.hp - (otherHpChange * 3) <= 0) { attackOptions3.push(other); } } } } storage.othersInfo[other.uid] = {hp: other.hp}; } if (myTotalHp < (topAttackPower * 7) + 5) return shield(); if (currentTurn <= 10) return this.farmOrUpgradeFarm(); if (attackOptions1.length > 0) { attackOptions1.sort((a, b) => b.worth - a.worth); return attack(attackOptions1[0].uid); } else if (attackOptions2.length > 0) { attackOptions2.sort((a, b) => b.worth - a.worth); return attack(attackOptions2[0].uid); } else if (attackOptions3.length > 0) { attackOptions3.sort((a, b) => b.worth - a.worth); return attack(attackOptions3[0].uid); } if (currentTurn <= 20) return this.farmOrUpgradeFarm(); if (currentTurn < finalTurns && myShieldPower < topAttackPower / 2 && Math.random() * 15 < 1 && this.canUpgrade('shield')) return upgrade('shield'); if (currentTurn < finalTurns && this.canUpgrade('farm')) return upgrade('farm'); if (currentTurn < finalTurns && myHealPower < 10 && this.canUpgrade('heal')) return upgrade('heal'); if (myHp < 3) return heal(); return farm(); } ``` This bot basically: * Builds up on farming at start * Defends itself when needed * Attacks when it can kill or when it thinks there is a chance to kill someone * Upgrades here and then * Farms the rest of the time * Never stuns **Edit 1:** Fixed an issue and improved some tiny things in the bot based on tests with lots of games. **Edit 2:** Reduced shield upgrades. [Answer] ## Undyable Bot (v3) ``` function undyableBot(me, others, storage){ if(me.hp < 100 - (me.levels.heal + 5)*2){ return heal() }else{ if(me.levels.heal < 10 && cost(me.levels.heal) / 2 < cost(me.levels.farm)){ if(me.gold >= cost(me.levels.heal)){ return upgrade("heal") }else{ return farm() } }else{ if(me.gold >= cost(me.levels.farm)){ return upgrade("farm") }else{ return farm() } } } } ``` --- [Answer] # FizzBuzz ``` function FizzBuzz(me, others, storage) { if (!storage.target) storage.target = others[0].uid; const uids = others.map(x=>x.uid); if(!uids.includes(storage.target) || (turn() % 30 === 0 && others[uids.indexOf(storage.target)].hp>30)) storage.target = others[0].uid; if (cost(me.levels.farm) < me.gold) return upgrade("farm"); if (turn() % 15 === 0) return heal(); if (turn() % 3 === 0) return farm(); if (turn() % 5 === 0) return heal(); if (cost(me.levels.attack) < me.gold) return upgrade("attack"); return attack(storage.target); } ``` Mostly offensive bot. Extremely upset by the fact that it can't truly FizzBuzz so it just Buzzes angrily instead. When it's not Fizzing or Buzzing, it chips away at another bot for 30 turns and gives up and chooses another bot to target if it isn't making progress. ~~Performs extraordinarily inconsistently.~~ Never mind, updated the controller, now seems to always be around the middle of the pack. [Answer] # PatientStrategistBot I tried to write a bot that starts out framing and defending as needed and then switches to killing other high value bots later in the game. Currently this doesn't seem to work properly since its either killed by a gang of murder-bots in the start of the game or gets stuck somewhere in its offensive mode. Still pretty happy with this being my first JS code, so ... (I did steal code snippets from here & there cause that was faster than googling all of the JS basic syntax) ``` function PatientStratgistBot(me, others, storage) { //set up some stuff in first turn if (turn() == 1) { storage.selfWorth = 0; storage.attackMode = false; storage.expectHP = 100; storage.expectShield = 0; storage.shieldTarget = 0; storage.targetUid = "None"; storage.attackRounds = 0; storage.targetStartHP = 100; return upgrade("farm"); } let farmPower = me.levels.farm * 2 + 5; //defensive Actions var maxAtk = Math.max(...others.map(o => o.attack)); storage.shieldTarget = Math.ceil(maxAtk * 1.25 / 1.5) + 1; if (me.levels.shield < storage.shieldTarget && me.gold >= cost(me.levels.shield) && me.levels.shield < me.levels.farm) return upgrade("shield"); if (turn() >= 7 && me.shield < 10 && me.levels.shield * 1.5 >= me.levels.heal) return shield(); if (turn() >= 15 && me.shield < 15 && me.levels.shield * 1.5 >= me.levels.heal) return shield(); if (turn() >= 30 && me.shield < 20 && me.levels.shield * 1.5 >= me.levels.heal) return shield(); //attack mode // check if there any targets worth to go for function findTarget(potentialTargets, baseR){ var targetUID = "None"; var best = 0; for( var i = 0; i < potentialTargets.length; i++) { //We upgrade to attack lvl12, so 20 dmg; assume an enemy can heal/shield up to 15 per round var killRounds = Math.ceil(potentialTargets[i].hp / 5) var gain = potentialTargets[i].worth / ( 2 * ( killRounds + baseR) ) //console.log(me, turn(), potentialTargets[i], killRounds, baseR, gain, farmPower) if (gain > farmPower * ( killRounds + baseR ) && gain > best) targetUID = potentialTargets[i].uid; storage.targetStartHP = potentialTargets[i].hp; } return targetUID; } if (turn() >= 600) { //check if a current target is dead const uids = others.map(x=>x.uid); if(storage.targetUid != "None" && !uids.includes(storage.targetUid)) { storage.targetUid = "None"; storage.attackMode = false; storage.attackRounds = 0; } // check if we are doing enough damage to current target if (storage.targetUid != "None" && storage.attackRounds >= 3) { var deltaHP = storage.targetStartHP - others[storage.targetUid].hp if (deltaHP / storage.attackRounds < 5) { storage.targetUid = "None"; storage.attackMode = false; storage.attackRounds = 0; } } var investCost = 0 for( var i = me.levels.attack; i < 12; i++) investCost += cost(i); if (storage.attackMode == true && me.gold >= investCost && me.levels.attack < 12) return upgrade("attack"); if (storage.attackMode == false) { baseRounds = investCost / farmPower * 1.2; //overestimation with the heal level we should have at this point if (findTarget(others, baseRounds) != "None") storage.attackMode = true; var betterThanMe = others.filter(o => o.worth >= storage.selfWorth); if (betterThanMe.length > 0) storage.attackMode = true; //storage.attackMode = true; } } if (storage.attackMode == true && me.levels.attack == 12) { if (storage.targetUid == "None") { var target = findTarget(others, 0) storage.targetUid = target; storage.attackRounds = 0; return attack(target); } return attack(storage.targetUid) } //otherwise farm if (me.hp < 50) { storage.expectHP += 5 + me.levels.heal; return heal(); } if (me.gold >= cost(me.levels.farm) && storage.attackMode == false) return upgrade("farm"); //upgrade heal, so we can farm more, but increase farm ability faster if (me.levels.farm > 5 && me.levels.heal < 10 && me.gold >= 2*cost(me.levels.heal)) return upgrade("heal"); //be opportunistic - check if killing someone is more profitable than farming killable = others.filter(o => o.hp < me.levels.attack * 1.25 + 5 && o.worth / 2 > farmPower); if (killable.length > 0){ //ideally check for the most worth target here return attack(killable[0].uid); } storage.expectHP -= 2; storage.selfWorth += farmPower; return farm(); } ``` [Answer] ## JustFarm I thought I'd start simple. ``` function justFarm(me, others){ return farm(); } ``` [Answer] # Switzerland ``` function switzerland(self,others,storage){ let turnsLeft=999-turn() let lowestHpBots=others.sort((a,b)=>a.hp-b.hp) if(!storage.worth){ storage.worth=0 storage.prevGold=25 }else if(self.gold>storage.prevGold){ storage.worth+=self.gold-storage.prevGold } if(others.length===1&&storage.worth>others[0].worth){ //stun lock the other bot if there are only 2 left and I can win return stun(others[0].uid) }else if(self.hp<=(95-self.levels.heal)){ return heal() }else if(lowestHpBots[0]&&lowestHpBots[0].hp<20&&lowestHpBots[0].worth/2>2*self.levels.farm+5&&self.hp+self.shield>=110){ //kill assist return attack(lowestHpBots[0].uid) } else if(self.shield<=50||self.shield<=5500/others.length&&self.shield<=1200&&turn()>=20||lowestHpBots[1]&&lowestHpBots[1].hp>self.hp+self.shield){ return shield() }else if(self.gold>=cost(self.levels.shield)&&self.levels.shield<=8){ return upgrade("shield") } else if(self.gold>=cost(self.levels.farm)&&(turnsLeft+1)*(2*(self.levels.farm)+5)<turnsLeft*(2*(self.levels.farm+1)+5)){ return upgrade("farm") } else if(self.gold>=cost(self.levels.heal)&&(turnsLeft+1)/(self.levels.heal+5)*(2*self.levels.farm+5)<turnsLeft/(self.levels.heal+6)*(2*self.levels.farm+5)&&self.levels.heal<=2){ return upgrade("heal") }else{ return farm() } } ``` Like the name suggests, this bot is ~~neutral~~ mostly neutral(now it helps kill bots that are going to die) and just farms and heals, slowly building up its gold(~~just like switzerland~~) [Answer] # SniperBot *This bot will only be effective if someone starts adding bots that actually attack on a regular basis. SmartFarmer is my current optimized solution* 1. heals if can get one-shot 2. heals if under 30 3. attacks bot if can pick it off and earn more money than farming 4. upgrades farming if can afford 5. upgrades healing if is under 80 health and can afford 6. farms vultures don't need an attack ``` function sniperBot(me, others){ if(me.hp < 30) return heal(); for(var i = 0; i < others.length; i++)if(others[i].attack > me.hp)return heal(); var target = -1; var targetWorth = me.levels.farm * 2 + 5; for(var i = 0; i < others.length; i++) { if (others[i].hp <= 1.25 * me.levels.attack + 5 && others[i].worth / 2 > targetWorth) { target= others[i].uid; targetWorth = others[i].worth / 2; } } if(target!=-1) return attack(target); if(me.gold >= cost(me.levels.farm)) return upgrade("farm"); if(me.hp < 50 && me.gold >= cost(me.levels.heal)) return upgrade("heal"); return farm(); } ``` [Answer] # BullyDozerBot ``` function BullyDozerBot(me, others, storage){ if(me.gold >= cost(me.levels.attack) && (storage.bullyTarget && storage.bullyTarget.hp < 500)) { return upgrade("attack"); } if(storage.bullyTarget==null){ storage.bullyTarget=others.sort((a,b) => a.hp - b.hp)[0]; } potential_victim = others.find( bot => bot.hp <= me.levels.attack * 1.25 + 5 ); if (potential_victim) { return attack(potential_victim.uid); } var targetlives = false; for(var i = 0; i < others.length; i++) { if (others[i] == storage.bullyTarget) { targetlives = true; break; } } if(!targetlives){ storage.bullyTarget=others.sort((a,b) => a.hp - b.hp)[0]; } if(storage.bullyTarget.hp >= 500) { if(me.gold >= cost(me.levels.farm)) { return upgrade("farm"); } for(var i = 0; i < others.length; i++){ if(others[i].attack*1.25+10 > me.hp){ return heal(); } } return farm(); } return attack(storage.bullyTarget.uid); } ``` Mashup of BullyBot and some other bits. Optimist had a short and sweet opportunistic attack chunk that I yoinked (though other bots do similar calculations). Instead of bullying the target by stunning them, *it murders them* for their sweet, sweet loot. It also targets the weakest in the herd for bullying, but it will give up and just go farming if the weakest target's HP is too high. [Answer] # bullyBot ``` function bullyBot(me, others, storage){ if(turn()==1){return farm();} if(storage.bullyTarget==null){storage.bullyTarget=others[0].uid;} var targetlives = false; for(var i = 0; i < others.length; i++) { if (others[i].uid == storage.bullyTarget) { targetlives = true; break; } } if(!targetlives){storage.bullyTarget = others[0].uid;} return stun(storage.bullyTarget); } ``` [Try it online!](https://tio.run/##bVC7bsMwDNzzFewmIamRzq6WLvmBbkUHJaEdtbJUUJSBwsi3u7KstCkgLgRfd8f70KMOJzJf/Oj8Gee5i@7Exjs4Rmu/XzyLAXfg@YIUdhDYk@5RThtIYTrBkZyQSj3JiXApoNM0CNlebxvlpMl4r5p6ZKVcKuRUG61Mb/v3JppzQskwoybgPLdmxAAqsdiAbR52nsSyYFJ736b0XOQ2Fl3Pl9TabiWskldRIAqNyTSgFFS03N8s8V8BUywCbnEk1J9/rdWBXx8e7s6rryfM6vPF18DR1cyU7eY6U3QHPWDyff4B "JavaScript (Node.js) – Try It Online") May not win but will certainly try his damndest to make sure his target doesn't either. bullyBot also farms on the first turn so that if there's no outside influence, he will beat his target 5-0 or tie them 5-5. [Answer] ## ScavengerBot (V2) Realized it wasn't much of a scavenger before. New strategy is wait until it can kill another bot. If no one can be killed, it sits and builds up shield. ``` function scavengerBot(me, others) { if (me.shield < (me.levels.shield * 1.5 + 5)) { return shield(); } var currentAttack = 1.25 * me.levels.attack + 5; var hasVictim = false; var victimUid = 0; var maxWorth = 0; for (var i = 0; i < others.length; i++) { var hp = others[i].hp; var worth = others[i].worth; if (hp <= currentAttack && worth > maxWorth) { hasVictim = true; victimUid = others[i].uid; maxWorth = worth; } } if (hasVictim) { return attack(victimUid); } if (me.gold >= cost(me.levels.attack)) { return upgrade("attack"); } if (me.gold >= cost(me.levels.shield)) { return upgrade("shield"); } return shield(); } ``` [Answer] # Moody ``` function Moody(me, others, storage) { health = me.hp + me.shield; damage = storage.previous_health - health; storage.previous_health = health; if( damage > 2 ) { storage.fear = 2; } if( storage.fear ) { storage.fear -= 1; if( me.gold >= cost(me.levels.heal) ) return upgrade("heal"); return heal(); } if ( me.hp <= 50 ) { return heal(); } if (cost(me.levels.farm) < 0.15 * (1000 - turn())) { if( me.gold >= cost(me.levels.farm) ) return upgrade("farm"); if( me.gold >= cost(me.levels.heal) ) return upgrade("heal"); return farm(); } rich_bots = others.sort( (x,y) => y.worth - x.worth ); richest_enemy = rich_bots[0]; if (richest_enemy.hp >= storage.target_hp) { storage.anger = true; } storage.target_hp = NaN; if (storage.anger) { if( me.gold >= cost(me.levels.attack) ) { storage.anger = 0; return upgrade("attack"); } return farm(); } storage.target_hp = richest_enemy.hp; return attack(richest_enemy.uid); } ``` Moody's default strategy is to upgrade farming and healing for a while, then take out the other bots in descending order of worth. However, if it's attacked, it'll get scared and refocus on healing for a bit. If it attacks and "fails", because the victim was healing or shielding more effectively than the attack, it'll get angry and go off to upgrade its attacking abilities. [Answer] # Bandit ``` function Bandit(me, others, storage) { // stuff we need const epsilon = 0.3; // really high epsilon function argmax(xs) { var max = 0; var argmax = 0; for (var i=0; i<xs.length; i++) { if (xs[i]>max) { max = xs[i]; argmax = i; } } return argmax; } function base3ToActionSeries(strategy) { const actions = [shield(), farm(), heal()]; var idxs = [] var strategy_cut = strategy; for (var i = 81; i >= 1; i /= 3) { if (strategy_cut >= 2 * i) {idxs.push(2); strategy_cut -= 2*i} else if (strategy_cut >= i) {idxs.push(1); strategy_cut -= i} else idxs.push(0); } return idxs.map(idx => actions[idx]); } // actual logic starts here // current strategy and info to calculate reward if (!storage.prior) storage.prior = [0,0.03325,0,0.0361,0.0361,0.2372,0,0.2372,0,0.00035,0.0361,0.23555,0.01305,0.0361,0.5798,0.23555,0.62065,0.23555,0,0.2372,0,0.20965,0.5841,0.2372,0,0.21905,0,0.0361,0.0361,0.2081,0.0361,0.0361,0.01455,0.000350,0.62065,0.205,0.000350,0.0361,0.3708,0.0361,0.0323,1.018050,0.5798,0.04495,0.5798,0.23555,0.62065,0.23555,0.62065,1.06395,0.62065,0.23555,0.62065,0.23555,0,0.2372,0,0.2372,0.5841,0.2372,0,0.2372,0,0.23555,0.62065,0.13775,0.5798,1.0257,0.5798,0.23555,0.62065,0.23555,0,0.2339,0,0.2372,0.5841,0.2339,0,0.2372,0,0.0342,0.0361,0.2372,0.03515,0.03325,0.6228,0.2372,0.5841,0.2372,0.0361,0.0130599,0.62065,0.03515,0.0361,1.0665,0.62065,0.24050,0.62065,0.23555,0.51465,0.2372,0.6228,1.0257,0.6228,0.2372,0.5841,0.2372,0.0361,0.0361,0.58195,0.0361,0.0313596,1.0614,0.58195,1.02315,0.58195,0.0342,0.0361,1.0206,0.02255,0.0183,0.02595,1.0206,1.5526,1.0206,0.58195,1.02315,0.58195,0.02765,0.0251,1.0614,0.0007,0.02085,0.3088,0.2372,0.5841,0.2273,0.6185,0.02255,0.6228,0.2372,0.5841,0.2372,0.62065,1.06395,0.62065,1.0665,0.0917,1.0665,0.62065,0,0.62065,0.2372,0.5841,0.2372,0.6228,1.0257,0.6228,0.2372,0.5841,0.2372,0,0.2372,0,0.23225,0.5841,0.2372,0,0.2372,0,0.23555,0.62065,0.23555,0.5798,1.0257,0.5798,0.23555,0.6142,0.23555,0,0.22235,0,0.2372,0.5841,0.2372,0,0.2372,0,0.23555,0,0.21905,0.62065,0.02255,0.62065,0.23555,0.61205,0.23555,0.5798,1.05885,0.5798,1.018050,0.03895,1.018050,0.5798,1.05885,0.5798,0.23555,0.62065,0.23555,0.62065,0.0361,0.62065,0.23555,0.62065,0.23555,0,0.2372,0,0.2372,0.3745,0.2372,0,0.2372,0,0.23555,0.62065,0.23555,0.5798,0.9452,0.5798,0.23555,0.5626,0.23555,0,0.2372,0,0.18175,0.5841,0.0138,0,0.2372,0] if (storage.lastScore == null) storage.lastScore = 0; if (storage.bestStrategy == null) storage.bestStrategy = argmax(storage.prior); if (cost(me.levels.heal) < me.gold) return upgrade("heal"); if (cost(me.levels.farm) < me.gold) return upgrade("farm"); // This barely explores and mostly exploits. if (turn() % 5 === 0) { // update const reward = me.gold/2 - storage.lastScore; // biased a bit towards later learned rewards storage.prior[storage.bestStrategy] += reward*0.01 storage.prior[storage.bestStrategy] *= 100/101 // explore if (Math.random() < epsilon) { storage.bestStrategy = Math.floor(Math.random()*243); } else { // exploit storage.bestStrategy = argmax(storage.prior); } storage.lastScore = me.gold/2; } var action = base3ToActionSeries(storage.bestStrategy)[turn() % 5]; return action; } ``` First attempt at a reinforcement learning bot. Purely defensive for now to narrow down the search space. Sort of a smarter spinoff of FizzBuzz -- it repeats a specific series of five actions over and over; the five actions are what are chosen by RL. But it's mostly based off of enumeration for now -- I just generated all 3^5=243 permutations of series of five defensive actions that repeated itself over and over, and stored their average scores (divided by 200, to get the average gain over five turns) over 100 iterations in the `storage.prior` array. Then, during the game, it implements an epsilon-greedy approach to updating those score lists so it's more future-proof. (Also because using epsilon=0.3 did way better than epsilon=0.1 so I just kept it.) It does okay, consistently placing between scavengerBot and Optimist. I'm currently doing some more training on real games, and looking for better ways to frame the strategy, to see if I can improve it. [Answer] # The Opportunist This one borrows a bit from a few others (notably ScavengerBot (V2) and Unkillable) since they had the same ideas I had in mind, but I generally like well-roundedness and jack-of-all-trades styles more than focusing on only one or two things. This will likely mean that I will not win, but it should be in the middle somewhere (which happens to me most of the time in many things). So it steals juicy kills; heals if necesssary; upgrades farm, attack, and heal in that order; and farms otherwise. ``` function Opportunist(me, others, storage) { // Initializing and keeping track of selfWorth if (turn() == 1) { storage.selfWorth = 0; } else if (storage.previousGold < me.gold) { storage.selfWorth += (me.gold - storage.previousGold); } storage.previousGold = me.gold; // Me stats var me_attack = 1.25 * me.levels.attack + 5; var me_heal = me.levels.heal + 5; // Look for the juiciest hunk of loot // If there are multiple of the highest worth, the last is chosen var choice = others[0].uid; var mostWorthy = -1; for (var i = 0; i < others.length; i++) { worth = others[i].worth if (others[i].hp <= me_attack && worth >= mostWorthy) { choice = others[i].uid; mostWorthy = worth; } } // Actions in order of priority // The juicy targets must be worth the action if (mostWorthy > (storage.selfWorth * 0.25) ) { return attack(choice); } else if (me.hp <= 100 - me_heal) { return heal() } else if (me.gold >= cost(me.levels.farm)) { return upgrade("farm"); } else if (me.gold >= cost(me.levels.attack)) { return upgrade("attack"); } else if (me.gold >= cost(me.levels.heal)) { return upgrade("heal"); } else { return farm(); } } ``` [Answer] # ScaredBot 1. It finds other bots: * with the highest attack * with most wealth and HP lower than own attack 2. If its HP+shield is lower than the found `highest attack * (25% of bots)`, or it gets near the lower end of `HP + shield`, then it shields 3. If it found a bot with lower shield than its own attack, it attacks it. 4. If its health is `< 50`, it heals. 5. If it can upgrade any of shield, heal and farm, it upgrades the one with the lowest level 6. It farms ``` function ScaredBot(me, others) { const my_attack = me.levels.attack * 1.25 + 5; const my_defense = me.hp + me.shield; var max_attack_val = 0; var min_hp_worth = 0; var min_hp_id = null; var hp_under_me = 0; for (var i=0; i<others.length; i++){ if (others[i].hp < my_attack && others[i].worth > min_hp_worth){ min_hp_id = others[i].uid; min_hp_worth = others[i].worth; } if (others[i].attack*1.25+5 > max_attack_val){ max_attack_val = others[i].attack*1.25+5; } if (others[i].hp < my_defense && others[i].hp > 0){ hp_under_me++; } } if (max_attack_val*0.25*others.length > my_defense || hp_under_me < 0.25*others.length){ return shield(); } else if (min_hp_id != null){ return attack(min_hp_id); } else if (me.hp < 50){ return heal(); } else { var min_lvl = NaN; var min_name = null; const vals = [me.levels.heal, me.levels.shield, me.levels.farm]; const names = ["heal", "shield", "farm"]; for (var i=0; i<vals.length; i++){ if (!(min_lvl < vals[i])){ min_lvl = vals[i]; min_name = names[i]; } } if (me.gold > cost(min_lvl)){ return upgrade(min_name); } return farm(); } } ``` The idea is to stay alive the longest possible and otherwise try getting gold in a safe and cheap way to be able to upgrade. Upgrade priorities should probably be tweaked, as well as the condition when determining on whether to shield. [Answer] # reallyCommittedTurtle ``` function reallyCommittedTurtle(me, others, storage) { if( storage.previousHP ) { others.forEach ( o => {storage.deltaHP[o.uid] = o.hp - storage.previousHP[o.uid]; storage.previousHP[o.uid] = o.hp } ); } else { storage.previousHP = {}; storage.deltaHP = {}; others.forEach ( o => storage.previousHP[o.uid] = o.hp ); } if (turn() < 3) return upgrade("shield"); if ( me.shield < 400 || others.find( o=> o.deltaHP < -2 ) ) return shield(); if (me.hp <= 95 - me.levels.heal) { if (me.gold >= cost(me.levels.heal)) return upgrade("heal"); return heal(); } rich_bots = others.sort( (x,y) => y.worth - x.worth ); potential_victim = rich_bots.find( bot => bot.hp + storage.deltaHP[bot.uid] <= me.levels.attack * 1.25 + 5 ); if (potential_victim && potential_victim.worth/2 > me.levels.farm*2 + 5) return attack(potential_victim.uid); if (me.gold >= cost(me.levels.farm)) return upgrade("farm"); return farm(); } ``` Here's the thing. It's gotten really dangerous out there. Farming at all increases your worth, making you a target. So it's really not safe to farm until you've built up a huge shield and all the violence has died down. Then you can poke your head out of your shell and start farming. Or kill-assisting. Whatever pays better. [Answer] # SmartFarmer Farms, upgrades farming, heals if low health. Farming seemed overpowered until the truly offensive bots arrived. Now my bot gets killed :-( ``` function smartFarmer(me, others){ if(me.hp < 13) return heal(); for(var i = 0; i < others.length; i++)if(others[i].attack * 1.25 + 5 > me.hp)return heal(); if(me.gold >= cost(me.levels.farm)) return upgrade("farm"); if(me.levels.heal < 9 && me.levels.farm > me.levels.heal + 7 && me.gold >= cost(me.levels.heal)) return upgrade("heal"); return farm(); } ``` [Answer] # Mort ``` function Mort(me, others, storage) { if (me.hp <= 100 - (me.levels.heal + 5)) return heal(); actions = ["farm", "heal", "attack"].filter(action => cost(me.levels[action]) <= me.gold).map( action => [upgrade(action), 1000 - turn() - cost(me.levels[action]) ] ) my_damage = me.levels.attack * 1.25 + 5; actions = actions.concat(others.map( bot => [ attack(bot.uid), (bot.worth/2)/Math.max(bot.hp/(my_damage-(bot.hp > my_damage ? 5 : 0)),1) ] )); actions.push( [farm(), (2 * me.levels.farm + 5)*(1-2/(me.levels.heal+5))] ); return actions.sort( (x,y) => y[1] - x[1] )[0][0]; } ``` Each turn, compares the amortized profit of killing each bot to that of farming and healing and picks the best option. Really it should use state to figure out how long it'll take to kill a bot, but for now it just assumes every bot heals or shields an average of 5 points a turn net of damage other bots do. [Answer] # Friendly bot ``` function menShengFaDaCai(me, others) { // heal if needed const maxAttack = Math.max(...others.map(bot => bot.attack)); const maxAttackCost = maxAttack * maxAttack + 5; const othersHp = others.map(bot => bot.hp).sort(); const targetHp = othersHp[Math.ceil(othersHp.length / 2)]; if (me.hp < 95 && me.hp < Math.max(maxAttackCost * 2, targetHp, 50)) return heal(); // upgrade heal and farm if possible const { heal: healLevel, farm: farmLevel } = me.levels; const gain = (heal, farm) => ((5 + heal) / 2) * (2 * farm + 5) / ((5 + heal) / 2 + 1); const gain0 = gain(healLevel, farmLevel); const gainUpgradeHeal = gain(healLevel + 1, farmLevel); const gainUpgradeFarm = gain(healLevel, farmLevel + 1); const gainUpgradeHealPerGold = (gainUpgradeHeal - gain0) / cost(healLevel); const gainUpgradeFarmPerGold = (gainUpgradeFarm - gain0) / cost(farmLevel); const preferUpgradeHeal = gainUpgradeHealPerGold > gainUpgradeFarmPerGold; const mayOffer = type => me.gold >= cost(me.levels[type]); if (preferUpgradeHeal && mayOffer('heal')) return upgrade('heal'); if (!preferUpgradeHeal && mayOffer('farm')) return upgrade('farm'); // keep farming return farm(); } ``` `others[0].hp` is `hp + shield` instead of `hp`... [Answer] # The Accountant This practical bot calculates the most economically beneficial move, but he likes to keep his attack profile low to avoid trouble from all of the vigilante bots. He doesn't try to pick help the defenseless or prey on them. Rather, he does what helps him the most. ``` function accountant(me, others, storage) { if (turn() == 1) { storage.lastHP = me.hp + me.shield; storage.hisAttack = 5; storage.timesAttacked = 0; storage.lastAttack = -1; storage.healths = [], storage.uids = [], storage.heals = []; for (var i = 0; i < others.length; i++) { storage.healths.push(others[i].hp); storage.uids.push(others[i].uid); storage.heals.push(5); } } storage.timesAttacked++; if (storage.lastHP == me.hp + me.shield) storage.timesAttacked = 0; else storage.hisAttack = storage.lastHP - me.hp - me.shield; storage.lastHP = me.hp + me.shield; var attacks = []; for (var i = 0; i < others.length; i++) if (others[i].uid != me.uid) attacks[i] = 1.25 * others[i].attack + 5; attacks.sort(); for (var i = 0; i < others.length; i++) { storageIndex = storage.uids.indexOf(others[i].uid); if (storage.heals[storageIndex] < others[i].hp - storage.healths[storageIndex] + (others[i].uid == storage.lastAttack ? 1.25 * me.levels.attack + 5 : 0)) others[i].hp - storage.healths[storageIndex] + (others[i].uid == storage.lastAttack ? 1.25 * me.levels.attack + 5 : 0); } var maxProfitTurn = 2 * me.levels.farm + 5, victimID = -1, tempProfit; for (var i = 0; i < others.length; i++) { storageIndex = storage.uids.indexOf(others[i].uid); tempProfit = others[i].worth / 2 * (1.25 * me.levels.attack + 5 - storage.heals[storageIndex]) / others[i].hp; if (tempProfit > maxProfitTurn) { victimID = others[i].uid; maxProfitTurn = tempProfit; } } maxUrgentProfit = 0; for (var i = 0; i < others.length; i++) if (maxUrgentProfit < others[i].worth / 2 && others[i].hp <= attacks.slice(0, 4).reduce((a, b) => a + b) + 1.25 * me.levels.attack + 5) { maxUrgentProfit = others[i].worth / 2; victimID = others[i].uid; } if (maxUrgentProfit > 0) { storage.lastAttack = victimID; return attack(victimID); } storage.lastAttack = -1; if (storage.timesAttacked == 0) { if (me.levels.shield < 20 && me.gold >= cost(me.levels.shield)) return upgrade("shield"); if (me.levels.heal < 5 && me.levels.shield >= me.levels.heal + 5 && me.gold >= cost(me.levels.heal)) return upgrade("heal"); if (Math.random() < Math.pow((me.hp + me.shield) / 100, -2)) { storage.lastHP += 1.5 * me.levels.shield + 5; return shield(); } } else { if (Math.random() < .5 || me.hp + me.shield - storage.hisAttack - attacks[0] <= 10) { storage.lastHP += 1.5 * me.levels.shield + 5; return shield(); } if (me.levels.shield < 20 && me.gold >= cost(me.levels.shield)) return upgrade("shield"); if (me.hp <= 2) { storage.lastHP += me.levels.shield + 5; return heal(); } storage.lastHP -= 2; return farm(); } if (me.gold >= cost(me.levels.farm)) return upgrade("farm"); storage.lastAttack = victimID; if (victimID != -1) return attack(victimID); if (me.hp <= 2) { storage.lastHP += me.levels.shield + 5; return heal(); } storage.lastHP -= 2; return farm(); } ``` [Answer] # Guardian I can have more than one submission, right? A fork of CampBot. Doesn't shield, instead focusing on attacking. Shows a preference for attacking players with higher attack stats, rather than striking at random like CampBot. Focuses on upgrading its farming rather than healing. ``` function guardian(self,others,storage){ if(!storage.victimBlacklist){ storage.victimBlacklist=[] } let turnsLeft=999-turn() function findVictim(){ let potentialVictims=others.filter(bot=>!storage.victimBlacklist.includes(bot.uid)) if(potentialVictims.length>0){ let victim=potentialVictims.reduce((el, em) => el.attack > em.attack ? el : em); storage.victimUid=victim.uid storage.victimPrevHp=victim.hp storage.prevMove="attack" return attack(victim.uid) }else{ storage.prevMove="farm" return farm() } } if(self.hp<=(95-self.levels.heal)){ storage.prevMove="heal" return heal() } else if(self.gold>=cost(self.levels.attack)){ storage.prevMove="upgrade" return upgrade("attack") } else if(self.gold>=cost(self.levels.farm)&&turnsLeft>100&&self.levels.heal<=1){ storage.prevMove="upgrade" return upgrade("farm") } else if(!storage.victimUid){ return findVictim() }else if(Object.values(others).map(bot=>bot.uid).includes(storage.victimUid)){ let victimCurrHp=Object.values(others).filter(bot=>bot.uid==storage.victimUid)[0].hp if(storage.victimPrevHp<victimCurrHp&&storage.prevMove==="attack"){ storage.victimBlacklist.push(storage.victimUid) storage.victimUid=undefined return findVictim() }else{ storage.victimPrevHp=victimCurrHp storage.prevMove="attack" return attack(storage.victimUid) } }else{ storage.victimUid=undefined return findVictim() } } ``` [Answer] # Rando This silly guy will choose actions based on uniform randomness with some biases. If a randomly chosen action won't work, then it drops down to the next choice. So on average, he should attack almost 2/9 of the time and farm almost 3/9 of the time. The rest are about 1/9 chance if he is able to upgrade, or if the healing/shielding is worth it, etc. He will not likely perform well, but at least there's a small chance that he reigns supreme. And that's the whole purpose of Rando. He just needs to believe in himself! All the options are laid in front of him. He needs only choose what is needed for any given situation. ``` function Rando(me, others, storage) { var rnum = Math.floor(Math.random() * 9); switch (rnum) { case 0: if (me.gold >= cost(me.levels.shield)) { return upgrade("shield"); } case 1: if (me.hp >= 100 - (me.levels.heal + 5) && me.levels.shield >= me.levels.heal) { return shield(); } case 2: if (me.hp < 100 - (me.levels.heal + 5)) { return heal(); } case 3: if (me.gold >= cost(me.levels.farm)) { return upgrade("farm"); } case 4: if (me.gold >= cost(me.levels.heal)) { return upgrade("heal"); } case 5: if (me.hp > 2) { return farm(); } case 6: // Beat down the leader! var currentLeader = others[0].uid; var leaderWorth = -1; for (var i = 0; i < others.length; i++) { worth = others[i].worth; if (worth > leaderWorth) { currentLeader = others[i].uid; leaderWorth = worth; } } return stun(currentLeader); case 7: if (me.gold >= cost(me.levels.attack)) { return upgrade("attack"); } case 8: // Find the juiciest kill (if any), or attack the strongest var choice = others[0].uid; var choiceWorth = -1; var currentLeader = others[0].uid; var leaderWorth = -1; for (var i = 0; i < others.length; i++) { worth = others[i].worth if (worth > leaderWorth) { currentLeader = others[i].uid; leaderWorth = worth; } if (others[i].hp <= (1.25 * me.levels.attack + 5) && worth >= choiceWorth) { choice = others[i].uid; choiceWorth = worth; } } if (choice > -1) { return attack(choice); } else { return attack(currentLeader); } default: return false } } ``` (I know "default" is unnecessary, but I think it is good coding practice for robust code.) [Answer] # Kill Bot ``` function killBot(me, others, storage) { // If I lost health since my last check, shield. if (me.hp < storage.hp){ storage.hp = me.hp; return shield(); } storage.hp = me.hp; health = Math.min(...others.map(o => o.hp)); // If I have the least health or can be one-shot, shield. if (others.some(o => o.attack * 1.25 + 5 >= me.hp + me.shield) || (health > me.hp + me.shield && health < 500)) return shield(); // If I can kill someone, kill them! targets = others.filter(o => o.hp < me.attack); if (targets.length > 0){ wealth = Math.max(...targets.map(o => o.worth)); targets = targets.filter(o => o.worth == wealth); target = targets[Math.floor(Math.random()*targets.length)]; return attack(targets[0].uid); } // If I have the money, upgrade shielding or attack if (me.levels.shield <= me.levels.attack){ if (cost(me.levels.shield) < me.gold) return upgrade("shield"); } else { if (cost(me.levels.attack) < me.gold) return upgrade("attack"); } // Otherwise, attack the weakest! targets = others.filter(o => o.hp == health); // And if there's a tie, attack the wealthiest. wealth = Math.max(...targets.map(o => o.worth)); targets = targets.filter(o => o.worth == wealth); target = targets[Math.floor(Math.random()*targets.length)]; return attack(targets[0].uid); } ``` A simple bot, Kill Bot just wants to kill its enemies. Since shielding is much more efficient than healing (especially when levelled), Kill Bot just tries to always be an unappealing target by shielding itself whenever attacked. Kill Bot does quite well among the weak, pacifistic bots around here (you can feel its scorn for them). [Answer] # FarmHeal Bot Forked from @Anonymous' JustFarm bot ``` function farmhealBot(me, others, storage) { if (me.hp <= 95) return heal(); else return farm(); } ``` [Answer] ## Indestructible A modification of Draco18's bot, using shields (more effective against other bots) ``` function indestructible(me){ if (me.hp < 100) { return heal(); } else if (me.shield < 15) { return shield(); } else { if (me.gold >= cost(me.levels.shield)) { return upgrade("shield"); } else if (me.gold >= cost(me.levels.farm)) { return upgrade("farm"); } else { return farm(); } } } ``` ]
[Question] [ The Champernowne constant is a number that is constructed by concatenating the first `n` numbers, with `n` tending to infinity. It looks something like this: ``` 0.123456789101112131415161718192021222324252627282930... ``` Now, I will describe to you the *Rien* number. It can be thought of as a minimization of the Champernowne constant as an integer. I will refer to the *Rien* number with the first `n` digits as Ri(*n*). This is how to formulate it: 1. The first `n` natural numbers (the sequence {1,2,3,...}) are concatenated. 2. This result is then sorted, according to the digit value. So `1..12` would look like `011111223456789`. 3. Since the *Rien* number cannot have leading zeroes, we move all `0`s so that they are significant, whilst keeping the number minimized, resulting in, say, `101111223456789`. This is Ri(*n*), in this case, Ri(12). Here are some results for Ri(*n*): ``` *n* Ri(*n*) 1 1 2 12 3 123 7 1234567 9 123456789 10 10123456789 15 101111111223344556789 34 10001111111111111222222222222223333333334444555666777888999 42 100001111111111111122222222222222233333333333333444444455556666777788889999 45 100001111111111111122222222222222233333333333333344444444444555556666777788889999 55 10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999 100 100000000000111111111111111111112222222222222222222233333333333333333333444444444444444444445555555555555555555566666666666666666666777777777777777777778888888888888888888899999999999999999999 999 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 ``` **Objective** Given a number 1 ≤ `n` < 10000 as input (via arguments, STDIN, or hardcoding if your language does not support conventional input), output/return Ri(`n`). This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins. You may use a language that was made after this contest, as long as it was not made for answering this challenge. (Of course, you *can* use it, if it provides an interesting solution, but mark your answer as non-competing.) # Reference implementation I tested this in IE, so there really shouldn't be a problem. If there *is* a problem, there's an easy solution: get a sane browser. ``` function min(n) { var seq = []; for(var i = 1; i <= n; i++) seq.push(i); seq = seq.join("").split("").map(Number); var to; if(seq.indexOf(1) >= 0) to = seq.splice(seq.indexOf(1), 1); seq.sort(function(a, b) { return a - b; }); if(to) seq = to.concat(seq); return seq.join(""); } t.onchange = t.onkeyup = function() { h.innerHTML = min(this.value) } ``` ``` * { font-family: Consolas, monospace; } input { border: 2px dotted #aaaaaa; border-radius: 5px; margin: 10px; } ``` ``` <input id="t" type="number"> <div id="h"> ``` --- ## Leaderboard The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` ## Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` ## Ruby, <s>104</s> <s>101</s> 96 bytes ``` If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the *last* number in the header: ``` ## Perl, 43 + 2 (-p flag) = 45 bytes ``` You can also make the language name a link which will then show up in the snippet: ``` ## [><>](http://esolangs.org/wiki/Fish), 121 bytes ``` ``` var QUESTION_ID=68685,OVERRIDE_USER=44713;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i; ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> ``` [Answer] ## Perl, ~~44~~ ~~42~~ ~~41~~ ~~33~~ 31 bytes Yaaay, first post ever ! Thanks to primo for the 2 bytes save. ``` print 1,sort"@{[2..<>]}"=~/\d/g ``` As others did, removing 1 and prepending it manually does the work. [Try it online](https://ideone.com/7dWSKk) [Answer] # Pyth, 8 ``` +1SjktSQ ``` Makes a list `[1, .. , input]` then removes the leading one, joins and sorts, then prepends a 1. [Test Suite](http://pyth.herokuapp.com/?code=%2B1SjktSQ&input=20&test_suite=1&test_suite_input=1%0A2%0A3%0A7%0A9%0A10%0A15%0A34%0A42%0A45%0A55%0A100%0A999&debug=0) [Answer] # Japt, ~~14~~ 12 bytes ``` 1+2o°U ¬¬n ¬ ``` [Try it online!](http://ethproductions.github.io/japt?v=master&code=MSsyb7BVIKysbiCs&input=MTAw) ### How it works ``` 1+2o°U ¬¬n ¬ // Implicit: U = input integer 2o°U // Generate the range of integers from 2 to U, inclusive. ¬¬ // Join, then split into chars. n // Sort. 1+ ¬ // Join again, and add a 1 to the beginning. // Implicit: output last expression ``` [Answer] ## [Retina](https://github.com/mbuettner/retina), 78 bytes Time to show off some new Retina features (it's still not very competitive, but before today this would probably have been closer to 300 bytes). ``` .+ $0$*1 \B $` (1)+ $#1 ^1| . 1$0$*1 +r`(1+\2) (1+)\b $2 $1 1(1)* $#1 ^ 1 ``` [Try it online.](http://retina.tryitonline.net/#code=LisKJDAkKjEKXEIKICRgCigxKSsKJCMxCl4xfCAKCi4KIDEkMCQqMQorcmAoMStcMikgKDErKVxiCiQyICQxCiAxKDEpKgokIzEKXgox&input=MTU) ### Explanation While it's possible to convert between decimal and unary quite conveniently now, this is still quite long because I have to convert back and forth several times because some operations are more doable in decimal than in unary and vice-versa. ``` .+ $0$*1 ``` Let's start by converting the input to unary. This works by matching the input and then using `$*1` which repeats `1` that many times (this repetition feature is new as of today). ``` \B $` ``` Next, we generate a range from `1` to `N` in unary. I've explained why this works [in my FizzBuzz answer](https://codegolf.stackexchange.com/a/58682/8478). ``` (1)+ $#1 ``` We convert each number in the range back to decimal so we can work with the decimal digits. This is done by matching each of the unary numbers such that each `1` generates a separate capture. Then we replace that with the number of captures of group one, using the new capture count syntax `$#1`. ``` ^1| ``` This removes the leading `1` as well as all spaces from the string so we're left with only the digits (except for a single `1`). ``` . 1$0$*1 ``` We convert back to unary and add `1` to each digit (to ensure that even `0` is a non-empty). We also insert a space in front of each digit to ensure that they are separated. ``` +r`(1+\2) (1+)\b $2 $1 ``` We repeatedly match a small number preceded by a larger number and swap them. That's bubble sort in Retina. :) ``` 1(1)* $#1 ``` Aaaand back to decimal. ``` ^ 1 ``` Finally, we insert a single `1` at the front to account for the one we've removed earlier. [Answer] ## Haskell, 44 bytes ``` import Data.List f n='1':sort(show=<<[2..n]) ``` Unfortunately `sort` is in `Data.List`, that's 17 bytes! [Answer] # JavaScript (ES6), ~~65~~ ~~62~~ ~~54~~ 52 bytes *Saved 3 bytes thanks to edc65* ``` x=>eval("for(b='';x>1;)1+[...b+=x--].sort().join``") ``` Builds a string of all numbers from 2 to `x`, then splits, sorts, joins, and adds a 1 to the beginning. This may still be golfable; suggestions welcome! [Answer] # CJam, 9 ``` 1qi),2>s$ ``` [Try it online](http://cjam.aditsu.net/#code=1qi)%2C2%3Es%24&input=10) Alternatively: ``` qi,:)(\s$ ``` [Answer] # APL (17) ``` '1',∆[⍋∆←1↓∊⍕¨⍳⎕] ``` Explanation: ``` '1',∆[⍋∆←1↓∊⍕¨⍳⎕] ----------------- ⎕ read a number from the keyboard ⍳ get the natural numbers up to and including that number ⍕¨ get the string representation for each number ∊ flatten the array (giving a string of digits) 1↓ remove the first digit (which is always 1) ∆← store the result in ∆ ⍋ get a permutation to sort ∆ upwards ∆[ ] rearrange ∆ so that it is sorted '1', add a 1 to the front ``` Test: ``` '1',∆[⍋∆←1↓∊⍕¨⍳⎕] ⎕: 1 1 '1',∆[⍋∆←1↓∊⍕¨⍳⎕] ⎕: 10 10123456789 '1',∆[⍋∆←1↓∊⍕¨⍳⎕] ⎕: 55 10000011111111111111122222222222222223333333333333333444444444444444455555555555566666777778888899999 ``` [Answer] # Mathematica, 52 bytes ``` "1"<>ToString/@Sort[Join@@IntegerDigits[2~Range~#]]& ``` Once again, string processing happened... [Answer] # Bash, ~~35~~ 34 bytes ``` printf %d 1`seq 2 $1|fold -1|sort` ``` This builds on the answers of [@DigitalTrauma](https://codegolf.stackexchange.com/a/68693) and [@OlivierDulac](https://codegolf.stackexchange.com/a/68897). Try it online with [Ideone](http://ideone.com/o1EiiM). ### How it works * `seq 2 $1` prints all integers from **2** to the one specified on the command line. * `fold -1` wraps all lines with width 1, i.e., places each character on its own line. `-1` seems to be an undocumented feature. * `sort` sorts the characters by their numeric value. * `printf %d 1`...`​` prepends a **1** to the first line and prints each line as an integer (`%d`), with no separation. This takes advantage of Bash's curious printf implementation, which repeats the format string over and over, until all arguments are consumed. [Answer] # Bash + GNU utilities, 58 ``` seq $1|sed 's/./&\n/g'|sort|tr -d \\n|sed 's/\(0*\)1/1\1/' ``` [Try it online.](https://ideone.com/YqHlmg) [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 8 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` RDFṢ1œ|Ḍ ``` [Try it online!](http://jelly.tryitonline.net/#code=UkRG4bmiMcWTfOG4jA&input=&args=MTU) ### How it works ``` RDFṢ1œ|Ḍ Main link. Argument: n (integer) R Range; yield r := [1, ..., n]. D Convert each k in r into the array of its digits in base 10. F Flatten the resulting array of lists. Ṣ Sort the resulting flat list of digits. 1œ| Perform multiset union with 1 as left argument. This moves a single 1 to the beginning of the list. Ḍ Convert the resulting list of base 10 to integer. ``` [Answer] # JavaScript ES6, ~~49~~ 46 Bytes Thanks to edc65 for 2 bytes ``` F= x=>1+[...(g=_=>x>1?x--+g``:_)``].sort().join`` ;console.log(F(15)) ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes ``` ḊVṢ1;Ḍ ``` [Try it online!](https://tio.run/##y0rNyan8///hjq6whzsXGVo/3NHz//9/Q1MA "Jelly – Try It Online") -1 thanks to Unrelated String ``` Ḋ # Dequeue (Remove head from implicit range) V # Eval (Jelly stringifies each, concatenates & evals, which does exactly what I want) Ṣ # Sort 1; # Prepend a 1 Ḍ # Decimalify, convert into base-10 number ``` [Answer] ## Python 2, 60 bytes ``` _="".join;print"1"+_(sorted(_(map(str,range(2,input()+1))))) ``` [Answer] # ClojureScript, 48 bytes ``` #(apply str"1"(sort(apply str(range 2(inc %))))) ``` Same as all of the others, pretty much. REPL available [here](http://clojurescript.net/). [Answer] # Ruby, 48 bytes An anonymous function. Basically just Rubyfied some of the other answers here.. ``` ->n{n>1?(?1+[*2..n].join.chars.sort*'').to_i: n} ``` [Answer] # [Milky Way 1.6.4](https://github.com/zachgates7/Milky-Way), 22 bytes (not competing) ``` ^^'LH=^^JB", "-Q"1";+! ``` I had to add a sorting opcode for this challenge. --- ### Explanation ``` ^^ ` pop the TOS ' ` read input from the command line LH ` push a reversed Pythonic range(TOS+1) =^^J ` remove the top 2 items from the TOS B ` push the string literal of the TOS ", "- ` remove ", " from the TOS Q ` sort the TOS "1";+ ` add "1" to the beginning of the TOS ! ` output the TOS ``` [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), ~~76~~ 41 bytes ``` 1 .;{,1:.e?}?:1fcbZlL,ZoOlM,10^(L-M)=:Oc. ``` Takes a number as input. This solution works with the few changes I made to the built-in Findall predicate `f`. OP is apparently OK with using languages older than the answer so I think this is fine (the changes I made were intented a long time ago, I just motivated myself to do it because of this challenge). ### Explanation ``` 1 . § If the input is 1, unify output with 1 ; § Else { }?:1f § Output a list of all inputs which satisfy § the predicate in brackets with the input § of the main predicate (ie the input number) § as output ,1:.e? § True if the input is an integer between 1 § and . (the output) cbZ § Concatenate everything into a single number, § remove the first digit (1) and call it Z lL,ZoOlM, § L is the length of Z, M is the length of O § O being Z sorted (which removes the leading § 0s) 10^(L-M)=:Oc. § Concatenate 10^(L-M) at the beginning of O § and unify it with the output ``` [Answer] ## Smalltalk, 76 bytes As usual in Smalltalk, conceptually very terse, but textually very verbose... ``` f:l^'1',((2to:l)fold:[:p :q|p asString,q asString])asByteArray sort asString ``` Add this as a class method for `String` and call like this, e.g. for 20, `String f: 20` [Answer] # Bash and GNU tools, ~~58~~ 52 bytes ``` echo 1$(seq 2 $1|sed -e 's/./&\n/g'|sort|tr -d \\n) ``` [Answer] ## PowerShell, ~~61~~ 59 bytes ``` param($a)(("1"+-join([char[]]-join(2..$a)|sort)),1)[$a-eq1] ``` Takes input `param($a)` and then uses it to index into an array with `[$a-eq1]`. If true, we index the second element and output `1`. Otherwise, we concatenate `"1"` with the `join`ed array created by 1) defining a new range `2..$a` that has been itself `join`ed together, 2) casting that as a char-array, and 3) sending it through the `Sort-Object` cmdlet, all of which is then output. Edit1 -- Saved 2 bytes by moving the inner `-join` operator. [Answer] # [Gogh](https://github.com/zachgates7/Gogh), ~~9~~ 7 bytes ``` GJT1-1P ``` You can run this using: ``` $ ./gogh noi 'GJT1-1P' <input> ``` --- ``` G “ Push a range (1, TOS] ” J “ Join the TOS ” T “ Sort the TOS ” 1- “ Remove the first 1 ” P “ Prepend the TOS to the STOS ” ``` [Answer] # Oracle SQL 11.2, ~~222~~ 211 bytes ``` SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()'))FROM(SELECT SUBSTR(s,LEVEL+2,1)c FROM(SELECT MAX(sys_connect_by_path(LEVEL,' '))s FROM DUAL CONNECT BY LEVEL<=:1)CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1); ``` Un-golfed ``` SELECT 1||TRIM(xmlagg(xmlelement(e,c)).EXTRACT('//text()')) -- add leading 1, concatenate each char and remove spaces FROM ( SELECT SUBSTR(s,LEVEL+2,1)c -- split the string in characters, omiting the first number (1) FROM ( SELECT MAX(sys_connect_by_path(LEVEL,' '))s -- create a string by concatenating numbers FROM DUAL CONNECT BY LEVEL<=:1 ) CONNECT BY LEVEL<=LENGTH(s)ORDER BY 1 ) ``` [Answer] ## [MATL](https://esolangs.org/wiki/MATL), 17 bytes Uses [current version (7.0.0)](https://github.com/lmendo/MATL/releases) of language/compiler. ``` 49[]i:"@YUh]6L)Sh ``` Inspired by [FryTheEgggman's answer](https://codegolf.stackexchange.com/a/68692/36398). *EDIT (July 29, 2016): You can [try it online](http://matl.tryitonline.net/#code=NDlbXWk6IkBWaF00TClTaA&input=MTI) with some modifications to conform to changes in the language.* ### Example ``` >> matl > 49[]i:"@YUh]6L)Sh > > 12 101111223456789 ``` ### Explanation ``` 49 % push '1' [] % push empty array i: % input "N" and build vector [1, 2, ... N] " % for each number in this vector @ % push that number YU % convert to string h % concatenate horizontally ] % end 6L) % remove first element S % sort h % concatenate horizontally ``` [Answer] # TI-Basic, 77 bytes ``` Input N {0 For(I,2,N augment(Ans,int(10fPart(I/seq(₁₀^(J),J,1,1+int(log(I End Ans→A SortD(ʟA 1→ʟA(dim(ʟA .1sum(seq(₁₀^(I)ʟA(I),I,1,dim(ʟA ``` Output is stored in `Ans` as a number and is displayed. Does not work for inputs that are 55 and above because of overflow errors. --- ### 87 bytes ``` Input N {0 For(I,2,N augment(Ans,int(10fPart(I/seq(₁₀^(J),J,1,1+int(log(I End Ans→A SortA(ʟA "1 For(I,2,dim(ʟA Ans+sub("0123456789",ʟA(I)+1,1 End ``` Output is stored in `Ans` as a string. Works with higher inputs than the above method could, depending on how much free RAM there is. `sub("0123456789",ʟA(I)+1,1` can be replaced with `toString(ʟA(I` to save 18 bytes if it is run on a TI-84+ CE OS 5.2+. [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal) `R`, 4 bytes ``` ḣṅs+ ``` [Try it Online!](https://vyxal.pythonanywhere.com/?v=2#WyJSIiwiIiwi4bij4bmFcysiLCIiLCIxMCJd) -2 thanks to Lyxal. ``` ḣ # Implicitly convert to [1...n], then push 1 and [2...n] ṅ # Concatenate [2...n] into a string s # Sort + # Prepend the 1 from before ``` [Answer] # [Nekomata](https://github.com/AlephAlpha/Nekomata), 8 bytes ``` RtƊjo1cɗ ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70iLzU7PzexJHFZtJJurlLsgqWlJWm6FquCSo51ZeUbJp-cvqQ4KbkYKrxgqyGXEZcxlzmXJZehAZehKZexCZeJEUQSAA) ``` RtƊjo1cɗ R Range [1, input] t Tail; remove the first element Ɗ Convert to lists of decimal digits j Join o Sort 1c Prepend 1 ɗ Convert from a list of decimal digits ``` [Answer] # Julia, 33 bytes ``` n->"1"*join(sort([join(2:n)...])) ``` This is a lambda function that accepts an integer and returns a string. To call it, assign it to a variable. We construct the range `2:n`, which will be empty for `n` < 2, join it into a string, splat the string into an array of characters, sort them, join it into a string, and prepend 1. [Answer] # APL, 21 bytes ``` {' '~⍨⍕1,x[⍋x←⍕1↓⍳⍵]} ``` This is an unnamed monadic function that accepts an integer on the right and returns a string. To call it, assign it to a variable. Explanation: ``` x←⍕1↓⍳⍵]} ⍝ Get the numbers 1:input, drop 1, convert to string x[⍋ ⍝ Sort ⍕1, ⍝ Tack 1 onto the front, flatten to string {' '~⍨ ⍝ Remove the spaces (side effect of ⍕ on an array) ``` [Try it online](http://tryapl.org/?a=R%u2190%7B%27%20%27%7E%u2368%u23551%2Cx%5B%u234Bx%u2190%u23551%u2193%u2373%u2375%5D%7D%20%u22C4%20R%201%20%u22C4%20R%2010&run) ]
[Question] [ This challenge is to write a program or script which counts the sum of all digits within the integers from 1 up to and including a given number. Input, one positive integer. Output, the sum of digits in that number and all smaller numbers. Examples: ``` Input: 5 Integer Sequence: 1, 2, 3, 4, 5 Sum of Digits: 1 + 2 + 3 + 4 + 5 = 15 Input: 12 Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 Sum of Digits: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 + 1 + 1 + 1 + 2 = 51 ``` To be clear, this is to count a sum of the *digits* - not the integers. For single-digit inputs, this will be the same. However, inputs larger than 10 will have different responses. This would be an ***incorrect*** response: ``` Input: 12 Output: 78 ``` Another example, to show the difference: ``` Input: 10 Integer Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 Sum of Integers (INCORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55 Digit Sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0 Sum of Digits (CORRECT RESPONSE): 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 1 + 0 = 46 ``` A larger test case (CORRECT RESPONSE): ``` Input: 1000000 Output: 27000001 ``` **Rules & Guidelines:** * Submitted code must be a complete program or script - not just a function. If the code requires includes, imports, etc., they must be included in the posted code. * The number must be input by the user - not hard-coded. Input may be received as a command-line argument, file, stdin, or any other means by which your language can take user input. * The code must be able to properly handle inputs at least up to `(2^64)-1`. * The code should only output the sum. * Submitted programs & scripts should be user-friendly and not wasteful of computer resources (e.g.: they should not declare insanely-large arrays to hold every character). There is no strict bonus or penalty for this, but please be good programmers. **Scoring:** Primary scoring mechanism is by code length. Lower scores are better. The following bonuses and penalties also apply: * **-25 Bonus** if your code can handle all positive numbers, for example: `1234567891234567891234564789087414984894900000000` * **-50 Bonus** if your code can handle simple expressions, for example `55*96-12`. To qualify for this bonus, the code should handle `+ - / *` (addition, subtraction, division, multiplication) operators and enforce order of operations. Division is regular integer division. * The given example (`55*96-12`) evaluates to `5268`. Your code should return the same for either of those inputs - correct answer is `81393`. * **-10 Bonus** if your code qualifies for the -50 bonus *and* can handle the `^` (exponent) operator. * **-100 Bonus** if your code qualifies for the -50 bonus *and* does not use `eval` or similar to handle expressions. * **+300 Penalty** if your code relies upon any web resources. [Answer] # Mathematica 30-(10+50)= -30 Shortened by 4 chars thanks to ybeltukov. `Range@n` returns the numbers from 1 through `n`. `Integerdigits@n` breaks up each of those numbers into its digits. `Total[n,2]` sums the digits. The 2 is to allow summing across different levels, i.e. lists of lists. ``` IntegerDigits@Range@#~Total~2& ``` ## Testing ``` IntegerDigits@Range@#~Total~2&[12] ``` > > 51 > > > ``` IntegerDigits@Range@#~Total~2 &[1000000] ``` > > 27000001 > > > --- ## Expressions ``` IntegerDigits@Range@#~Total~2 &[55*96 - 12] 55*96 - 12 ``` > > 81393 > > 5268 > > > ``` IntegerDigits@Range@#~Total~2 &[5268] ``` > > 81393 > > > --- ``` IntegerDigits@Range@#~Total~2 &[55*96^2 - 12] 55*96^2 - 12 ``` > > 12396621 > > 506868 > > > ``` IntegerDigits@Range@#~Total~2 &[506868] ``` > > 12396621 > > > [Answer] ## C: 150 138 - (100+50) = -12 ``` a,b,c;main(d){for(scanf("%d ",&a);~scanf("%c%d ",&d,&b);a=d^43?d%5?d%2?a/b:a*b:a-b:a+b);for(;a;)for(b=a--;b;b/=10)c+=b%10;printf("%d",c);} ``` Very shamefully stealing @Fors answer from here to do the expression evaluation: <https://codegolf.stackexchange.com/a/11423/13877> Sample usage: ``` ./a.exe <<< "5 + 7" 51 ``` Note: the expression implementation assumes no operator precedence and consumes values as it receives them; ex, `1+2*3 = 9` rather than the typical `7`. [Answer] ## sed, ~~411~~ 283 - 25 = 258 I can't be bothered to golf it more right now. :-) Not recommended for use with even remotely big integers, but *technically* it could deal with arbitrarily large integers (you'll likely run out of RAM pretty quickly though, since I (more-or-less have to) encode the number in unary). ``` s/$/x0123456789/ :l /9$/H :b s/(.)(y*x\1)/y\2/ /(.)y*x\1/b b s/(.)([xy].*)(.)\1/\3\2\3\1/ :c s/y(.*(.))/\2\1/ /y/b c /0$/b f /^0*x.*9$/!b l x s/x[^\n]*\n//g :d s/(.)(.*x.*(.)\1)/z\3\2/ /[^z0]x/b d s/0|x.*|\n//g H;x s/./0/g s/$/x9876543210/ x :e x b l :f x s/.// /./b e x s/^0+|x.*//g ``` ### Sample use (Input lines indented for easier reading.) ``` 5 15 12 51 33 183 ``` [Answer] # Perl 6: 108 - (25 + 50 + 100) + 0 = -67 points Golfed solution (Final line based off of [xfix's great solution](https://codegolf.stackexchange.com/a/18616/15012)): ``` $!=get;for '*',&[*],'/',&[/],'+',&[+],'-',&[-] ->$s,&f{$!~~s:g[(\d+)$s(\d+){}]=f |@()} say [+] (1..$!)».comb ``` Un-golfed solution: ``` my $expression = get; for '*', &[*], '/', &[/], '+', &[+], '-', &[-] -> $sym, &infix { $expression ~~ s:g[(\d+) $sym (\d+) {}] = infix($0, $1) } say [+] (1..$expression)».comb ``` The evaluation step works by iterating over each symbol of `*`, `/`, `+`, `-`, finding when that lies between two integers, and substituting that using the function that symbol represents. In more detail: it takes each symbol (e.g. `+`) and the infix function that it's supposed to represent (e.g. `&[+]` which is the shorthand for `&infix:<+>` and the same function Perl 6 calls when you execute `1 + 2`) and does a global substitution (`s:g[…] = …`, which is like Perl 5 `s/…/…/ge`), which matches two integers separated by the symbol (`(\d+) $sym (\d+)`), and substitutes it with the output of the corresponding infix function called with those integers (`infix($0, $1)`). Finally, this evaluated expression is feed into `say [+] (1..$expression)».comb`, which [xfix explains very well in his solution](https://codegolf.stackexchange.com/a/18616/15012). Sorry to be so late to the party ☺ EDIT: Removed support for exponents; it was exactly 10 characters anyway and didn't do associativity correctly. [Answer] ## python, 55-(50+25+10) = -30 In-efficient yet shorter and also able to handle expressions. **EDIT:** Thanks [Wolframh](https://codegolf.stackexchange.com/users/7971/wolframh) and [legoStormtroopr](https://codegolf.stackexchange.com/users/8777/lego-stormtroopr) for the tricks :D ``` s,t=0,input() while t:s+=sum(map(int,`t`));t-=1 print s ``` ## python, 149-(25+50+10) = 64 My first version ``` def d(n): if n/10==0:return n*(n+1)/2 c,t=0,n while t/10:c,t=c+1,t/10 p=10**c;m=n%p return d(m)+t*(m+1)+p*t*(t-1)/2+p*c*t*45/10 print d(input()) ``` input: ``` 1234567891234567891234564789087414984894900000000 ``` output: ``` 265889343871444899381999757086453238874482500000214 ``` [Answer] # Python - 108 chars minus 85 bonuses, 23 strokes, handles very very very large inputs Most of these solutions seem to be looping over all ints less than the input and adding up all their digit sums. This works, but I feel it's inelegant, and would question whether they're truly eligible for the 25 point bonus, since I don't think they'd be able to handle the input `1234567891234567891234564789087414984894900000000` within our lifetimes. Indeed, on an input of `n` digits, these solutions take `O(10^n)` time. I chose instead to throw some maths at this problem. ``` #Returns the sum of all digits in all x-digit numbers def f(x): return x*(10**(x-1))*45 #Returns the sum of all numbers up to x def g(x): return x*(x+1)/2 #Solves the problem quickly def magic(x): digits = [int(y) for y in list(str(x))] digits.reverse() total = 0 for (sig, val) in enumerate(digits): total += (10**sig)*g(val-1) + val*f(sig) + val + (val*10**sig)*sum(digits[sig+1:]) return int(total) ``` The set of all `x` digit numbers is isomorphic to the set `{0,1,2,3,4,5,6,7,8,9}^x`. For a fixed `(n,sig)` there are `x` different values for `sig`, `10^x-1` points with the `sig`th index set to `n`, and the sum of all digits `0-9` is 45. This is all handled by `f`. `g` is something we're probably all familiar with `magic` takes all the digits in the input number, and iterates over them from least to most significant. It's easiest to track this with an example input, say `1,234,567`. To deal with the range `1,234,567-1,234,560`, we must add up all digits from `1` to `7`, and add on `7` times the sum of the other digits, to deal with all numbers greater than `1,234,560`. We now need to deal with the remainder. To deal with the range `1,234,560-1,234,500`, we add on the `6` (`val`), and drop the upper limit to `1,234,559`. In making the remainder of the drop, we'll see every single-digit number 6 times (`val*f(sig)`). We'll see all the numbers from `0` to `5` exactly `10` times each (`(10**sig)*g(val-1)`). We'll see all the other digits in this number exactly 60 times (`(val*10**sig)*sum(digits[sig+1:])`). We have now dealt with all numbers strictly greater than `1,234,500`. The same logic will apply inductively across all significances. Golfing this, with thanks to WolframH, reduces this solution to ``` d=map(int,str(input())) print sum(v*(10**s*((v-1)/2+sum(d[:~s]))-~s*9*10**s/2)for s,v in enumerate(d[::-1])) ``` And the sum of the digit sums of all integers up to `1234567891234567891234564789087414984894900000000` is `265889343871444927857379407666265810009829069029376` The largest number I've managed to throw at the golfed version is 10^300, at which point the floats start overflowing and numeric instability starts to cause problems. With a quick square-and-multiply exponentiation function, this problem would vanish. And LaTeX support would be *really* useful... [Answer] ## TI-BASIC, 137 - (50 + 10 + 100) = -23 ``` Input A:Disp cumSum(randIntNoRep(1,A))→L₁:"?:For(A,1,dim(L₁:Ans+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ",L₁(A),1:End:Disp sub(Ans,2,length(Ans)-1 ``` Input handles numbers up to `1E100` and automatically evaluates. Can handle expressions. Although it is an insanely large array, I'm not wasting *computer* resources (this is run from a *calculator*). [Answer] # Scala 66 ``` println((1 to readLine().toInt).flatMap(x=>(x+"").map(_-'0')).sum) ``` [Answer] ## C, ~~77~~ 74 ``` n,v,i;main(){scanf("%d",&n);for(;i||(i=n--);i/=10)v+=i%10;printf("%d",v);} ``` ### C, ~~150~~ 124 - 25 = 99 Here is an alternative version that should technically be eligible for the **25** bonus for "any" positive integer, but it's impractically slow since the algorithm is linear-time in its input. Regardless, it was fun to write. Manually subtracts a number read in as ASCII characters. This version is **150** characters. (Now with horrible, argument-thrashing, loopful code!) ``` n,v;main(int n,char**a){char*p;do{for(p=a[1];*p>47;p++)v+=*p-48;for(;*--p==48;)*p=57; p[0]--;}while(p>=a[1]);printf("%d",v);} ``` ### C, ~~229~~ 224 - (50 + 100) = 74 Expression-handling variation. Implements operator precedence according to typical rules: `/ * - +`. Limited to 97 tokens = 48 terms. ``` #define F(X,Y)for(q=n+1;q+1!=p;)*q-X?q+=2:(q[-1]Y##=q[1],memmove(q,q+2,(p-q)*4)) n[99],*p,*q,v,i;main(){for(p=n;~scanf("%d%c",p,p+1);)p+=2;F('/',/);F('*',*); F('-',-);F('+',+);for(;i||(i=n[0]--);i/=10)v+=i%10;printf("%d",v);} ``` [Answer] # [Husk](https://github.com/barbuz/Husk), 4 bytes ``` Σṁdḣ ``` [Try it online!](https://tio.run/##yygtzv7//9zihzsbUx7uWPz//39DIwA "Husk – Try It Online") * `ḣ` makes a range from 1 to input * `ṁd` flatmap digits * `Σ` sum [Answer] ## GolfScript 18 - 50 = -32 ``` ~),{`+}*' '*~]{+}* ``` Explanation: Suppose input is "12": ``` ~), # turn input into integer, increment, and then turn into an array of all numbers less than or equal to input. ``` Stack is `[0,1,2,3,...,12]`. ``` {`+}* # fold string concatenation across the array ``` Stack is `"01234...9101112"`. ``` ' '* # join a space between all characters ``` Stack is `"0 1 2 ... 1 0 1 1 1 2"`. ``` ~] # evaluate the stack into an array. No `[` is necessary since the stack is otherwise empty. ``` Stack is `[0,1,2,...,9,1,0,1,1,1,2]`. ``` {+}* # fold addition across the new array ``` Stack is 51, as desired. The input here could be any valid GolfScript expression, which can include exponents. For example: ``` echo "5 5 + 2 * 8 -" | ruby golfscript.rb h.gs -> 51 ``` Since `2(5 + 5) - 8 = 12`. I think this should qualify for the bonus, but maybe it was expected to be only if in normal form, not the reverse Polish notation of GolfScript. [Answer] ## Ruby, 37 - 50 = -13 Double eval, all the way across the sky! As with the other Ruby solutions, I think this should theoretically be able to work with arbitrarily large numbers, but execution time would be... dire. ``` p eval [*1..eval(gets)].join.chars*?+ ``` Older version (49 - 50 score) ``` p"#{[*1..eval(gets)]}".chars.map(&:to_i).inject:+ ``` Assuming the 10 character bonus actually requires the character for exponentiation to be a caret, the shortest way I could think to add that is: ``` .gsub ?^,'**' ``` Which costs more characters than the bonus would give. [Answer] # Perl 6 (28 - 75 + 0 = -47 bytes) ``` say [+] (1..get.eval)».comb ``` It can handle all positive numbers (however, big ones will take a long while, because currently Perl 6 implementations are slow, but Perl 6 supports big integers natively). It uses `eval`, in order to implement a simple calculator (five character penalty for fifty characters is worth it). It's slow just because current implementations are slow, but in theory, it should be fast enough (when Perl 6 implementations improve, that is). Also, surprisingly, I win with the Mathematica (for now). `»` in this code is actually not needed, but I put it here for performance reasons (otherwise, program would allocate entire string. The reason why it's here is that Perl 6 doesn't have infinite strings, but it does have infinite lists. Anyway, you may ask how this code even works. Well, I'm going to pass it part by part. * `get.eval` This gets one line (`get` function), and evaluates it (`eval` method). * `1..get.eval` After that, Perl 6 prepares a range object, from `1` to evaluated value. This is a range, so nothing huge is allocated. * `».comb` `.comb` method splits string onto characters ([unless called with an argument](http://doc.perl6.org/type/Str#comb)). For example, `'cat'.comb` returns `'c', 'a', 't'`. `»` maps the list elements, so `.comb` is ran on its every item - not only on the list itself (for example, `(4, 9)».sqrt` gives `2, 3`). This also doesn't allocate more than needed, because Perl 6 has infinite lists (like Haskell, for example). `»` character actually not needed, as `.comb` can be used directly on the list, but this involves implicit string coercion (and Perl 6 doesn't have infinite strings, so this would waste memory). For example, `1, 2, 3` list after conversion to the string returns `1 2 3`. For Perl 6, a space is a perfectly fine number meaning 0, so the code would work, even with such conversion. However, it would abuse computing resources. * `[+]` This is a reduce operator. Basically, between `[]`, you can put an operator to use, in this case `+`. The list after reduce operator is reduced, so `[+] 1, 2, 3` is `1 + 2 + 3`, which is `6`. Perl 6 uses separate operators for numbers and strings, so it won't be considered to be concatenation. * `say` Finally, `say` outputs the result. After all, you want to see the final result, don't you? [Answer] ## Perl 31 - No bonuses ``` map{s/./$%+=$&/ge}0..<>;print$% ``` Sample output: ``` perl -e 'map{s/./$%+=$&/ge}0..<>;print$%' 1000000 27000001 ``` ## [Perl 5](https://www.perl.org/) with `-p`, 50 - 28 bytes: -22 ``` map$\+=$_,/./g for 1..eval}{ ``` [Try it online!](https://tio.run/##K0gtyjH9/z83sUAlRttWJV5HX08/XSEtv0jBUE8vtSwxp7b6/39DI21jEy1TM13zf/kFJZn5ecX/dQsA "Perl 5 – Try It Online") [Answer] **J, 22** ``` ([:+/[:"."0[:":>:@:i.) ``` **Explanation** Evaluation proceeds from right to left. ``` i. n -> 0 1 2...n-1 >: n -> n+1 ": numbers -> 'numbers' "."0 -> (on each scalar item) apply ". -> '123' -> 1 2 3 +/ -> sum ``` [Answer] ## R, 64 - (50 + 10) = 4 ``` sum(utf8ToInt(paste(0:eval(parse(t=scan(,""))),collapse=""))-48) ``` When this is run, the user is asked for input. --- Old version (cannot handle expressions): 46 characters: ``` sum(utf8ToInt(paste(0:scan(),collapse=""))-48) ``` [Answer] **Batch - (181 - 50) - 131** Just for a bit of fun. ``` @set/av=%1 @setLocal enableDelayedExpansion&for /L %%a in (1,1,%v%)do @set a=%%a&powershell "&{'%%a'.length-1}">f&set/pb=<f&for /L %%c in (0,1,!b!)do @set/as+=!a:~%%c,1! @echo !s! ``` I'll make it a bit more readable: ``` @set /a v=%1 setLocal enableDelayedExpansion for /L %%a in (1,1,%v%) do ( @set a=%%a powershell "&{'%%a'.length-1}">f set /p b=<f for /L %%c in (0,1,!b!) do @set /a s+=!a:~%%c,1! ) @echo !s! ``` Old method uses for loop to get output of powershell command, as opposed to writing to and reading from a file: ``` @set /a v=%1 @setLocal enableDelayedExpansion&for /L %%a in (1,1,%v%)do @set a=%%a&for /F usebackq %%b in (`powershell "&{'%%a'.length-1}"`)do @for /L %%c in (0,1,%%b)do @set /a s+=!a:~%%c,1! @echo !s! ``` Set the input to a variable - `v` - using `/a` to accept arithmetic expressions. Unfortunately enabling delayed expansion was necessary. Use a for loop to count from 1 to the inputted value - `v`. In order to handle numbers greater than 9, I had to use powershell to get the length of the string then use another for loop to split that string up, and add it to the *sum* - `s`. You *could* change the name of `powershell.exe` to `p.exe` under C:\WINDOWS\System32\WindowsPowerShell\v1.0\ then call it with just `p "&{'%%a'.length-1}`, saving 9 bytes. But that's not really in the spirit of it. ``` H:\>sumof.bat 12 51 H:\>sumOf.bat (55*96-12) 81393 ``` Left that second one running while I took my lunch break. I can't really test it with numbers that are *too* much larger than this due to how slow it is. However it should work for fairly large numbers. `2147483647` is the largest number it will take (maximum 32 bit integer) before giving the following error - ``` H:\>sumOf.bat 2147483648 Invalid number. Numbers are limited to 32-bits of precision. ``` This of course disqualifies me from the challenge. [Answer] # [Dyalog APL](http://dyalog.com), 9 – 160\* = -151 ``` +/⍎¨∊⍕¨⍳⎕ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO94L@2/qPevkMrHnV0PeqdCqR7Nz/qmwqS@q8ABgVcplwwlqERgmkAZx5ab2ikbWl2eLqpKQA "APL (Dyalog Unicode) – Try It Online") `⎕` get evaluated input  e.g. `"7+5"` gives `12` `⍳` indices 1 ... *n*  `[1,2,3,4,5,6,7,8,9,10,12]` `⍕¨` format each number into string  `["1","2","3","4","5","6","7","8","9","10","11","12"]` `∊` enlist (flatten)  `"123456789101112"` `⍎¨` execute each character (yields list of single digit numbers numbers)  `[1,2,3,4,5,6,7,8,9,1,0,1,1,1,2]` `+/` sum  `51` --- ### \* Scoring **-50** bonus as it even accepts expressions as input. The expression must be valid APL, which is [acceptable according to OP](https://codegolf.stackexchange.com/questions/18556/count-sum-of-all-digits?page=3&tab=oldest#comment36286_18556). **-10** bonus because because it also handles the `^` (`*` in APL). **-100** bonus because expression input is handled without explicit usage of `eval` (i.e. `⍎` in APL). [Answer] # [Vyxal](https://github.com/Vyxal/Vyxal), 3 - 160 = -157 bytes ``` ɾṅ∑ ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C9%BE%E1%B9%85%E2%88%91&inputs=55*96-12&header=&footer=) Gaming. Use `**` for pow. This works because all input is auto evaluated [Answer] **C# (161)** ``` using C=System.Console;using System.Linq;class X{static void Main(){C.WriteLine(Enumerable.Range(1,int.Parse(C.ReadLine())).SelectMany(i=>i+"").Sum(c=>c-48));}} ``` Pretty ``` using C = System.Console; using System.Linq; class X { static void Main() { C.WriteLine( Enumerable.Range(1, int.Parse(C.ReadLine())) .SelectMany(i => i + "") .Sum(c => c - 48) ); } } ``` [Answer] ## Python3+Bash (78 - 185 = -107) ``` python3 -c"print(sum(sum(map(int,str(x+1)))for x in range(int(${1//^/**}))))" ``` * can handle all positive number * can handle expressions with + - / \* operation * can handle ^ (power) operator. * can handle expressions, without eval or similar¹ If the result of expression is not integer, it will be truncated first. If the result of the expression is negative, the result is undefined. Use it like: ``` bash golf.sh "12 + (42 / 3 + 3^4)" ``` --- 1: unless you count invoking Python from Bash as such, but I don't think it is the case. If you think that it actually is, then the adjusted score is -7. [Answer] # Java, 254 ``` class T { public static void main(String[] a) { long target = 10, count = 0; String[] digits = new String[50]; for (long i = 1; i <= target; i++) { digits = String.valueOf(i).split("(?!^)"); for (int j = 0; j < digits.length; j++) if (digits.length > j) count += Integer.parseInt(digits[j]); } System.out.println(count); } } ``` Handles expressions. Give whatever expression you desire in target. Handles until the length long can handle. If you clean up taking off all spaces into one line, and no statement to print, it counts to 254 chars (considering the long long words based Java programming). PS: This is a complete program, not just logic. Words count given for the program, not just the logic. [Answer] **Java (JDK8), 272** My first challenge I'm in, suggestions are welcome =) ``` import java.util.*;import java.util.stream.*;class C{public static void main(String[]a){System.out.print(Arrays.asList(IntStream.range(1,new Integer(a[0])).mapToObj(s->s+"").collect(Collectors.joining()).split("")).stream().map(Integer::valueOf).reduce(0,Integer::sum));}} ``` Indented: ``` import java.util.*; import java.util.stream.*; class C { public static void main(String[] a) { System.out.print(Arrays.asList(IntStream.range(1,new Integer(a[0])) .mapToObj(s->s+"") .collect(Collectors.joining()) .split("")) .stream() .map(Integer::valueOf) .reduce(0,Integer::sum)); } } ``` [Answer] # CJam, 9 - 25 = -16 CJam is a few months younger than this challenge, so this is not eligible for the green checkmark. Furthermore, this isn't beating Perl in the first place. ;) I quite liked the approach though, so I wanted to post it anyway. ``` l~),s:~:+ ``` [Test it here.](http://cjam.aditsu.net/) The idea is to create a range from 0 to N. This range is then converted to a string, which just concatenates the integers back to back. For N = 12, we'd get ``` "0123456789101112" ``` Then each character is converted to a integer with `:~` (yielding an array of integers), and then summed up with `:+`. CJam can deal with arbitrarily big integers. [Answer] # Python 3 + [astor](https://pypi.python.org/pypi/astor), ~~1017~~ 1007 bytes - (25 + 50 + 100) = Score: ~~842~~ 834 *saved 10 bytes by removing `ts` and changing `p`* *edit: I am unable to test the ridiculously long integer (1234567891234567891234564789087414984894900000000) [hangs my computer] but from my knowledge, Python 3 supports arbritrarily long integers.* This implementation ~~uses~~ abuses AST. I wouldn't consider abusing AST as "eval or similar". ``` from ast import* from astor import* nt,bo,m,d,a,s,n,p,ty=NodeTransformer,BinOp,Mult,Div,Add,Sub,Num,map,type class M(nt): def visit_BinOp(t,z): if ty(z.left)==bo and ty(z.right)==bo:return bo(t.visit_BinOp(z.left),z.op,t.visit_BinOp(z.right)) if ty(z.left)==bo:return bo(t.visit_BinOp(z.left),z.op,z.right) if ty(z.right)==bo:return bo(z.left,z.op,t.visit_BinOp(z.right)) if ty(z.op)==m:return n(z.left.n*z.right.n) if ty(z.op)==d:return n(z.left.n/z.right.n);return z class A(nt): def visit_BinOp(t,z): if ty(z.left)==bo and ty(z.right)==bo:return bo(t.visit_BinOp(z.left),z.op,t.visit_BinOp(z.right)) if ty(z.left)==bo:return bo(t.visit_BinOp(z.left),z.op,z.right) if ty(z.right)==bo:return bo(z.left,z.op,t.visit_BinOp(z.right)) if ty(z.op)==a:return n(z.left.n+z.right.n) if ty(z.op)==s:return n(z.left.n-z.right.n);return z class S(nt): def visit_Num(t,z):return n(sum(p(int,list("".join(p(str,range(1,z.n+1))))))) print(to_source(S().visit(A().visit(M().visit(parse(input())))))) ``` Too lazy to write ungolfed, so I'll give you an explanation of the classes: ``` M(NodeTransformer|nt) - converts multiplication and division into their results. A(NodeTransformer|nt) - converts addition and subtraction into their results. S(NodeTransformer|nt) - converts numbers into their sum of digits via the Pythonic (naïve) way. ``` The last line just executes these classes in the appropriate order on the input, to preserve order of operations, and prevent unwanted behavior. Example usage ($ or > means user input) and by the way, the actual program takes input only once: ``` $ python3 summer.py > 5 15 > 10 46 > 12 51 > 1000000 27000001 > 55*96-12 81393 ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 5 - 160 = -155 bytes ``` ƓRDFS ``` [Try it online!](https://tio.run/##y0rNyan8///Y5CAXt@D//01NtSzNdA2NAA "Jelly – Try It Online") `Ɠ`et evaluated input, turn it into a `R`ange, get the `D`igits of each, `F`latten into a single list, then `S`um Claims the same bonuses as the [APL answer](https://codegolf.stackexchange.com/a/83354/66833). Exponents must be with `**` instead of `^` [Answer] # [Pyth](https://github.com/isaacg1/pyth), 6 bytes ``` ssMjkS ``` [Try it online!](https://tio.run/##K6gsyfj/v7jYNys7@P9/QyMA "Pyth – Try It Online") * `S` create range from 1 to input * `jk` join on `k` (initially empty string) * `sM` map to number * `s` sum [Answer] # Regex `🐇` (Perl / PCRE2), 32 bytes, score 7 ``` (\4?+(?=(x*)(\2{9})(x*))\3)+\2x+ ``` Takes its input in unary, as a string of `x` characters whose length represents the number. Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method. It can yield outputs bigger than the input, and is really good at multiplying.) The **-25** bonus applies because there is no inherent limit to the numbers a unary regex can take as input – though in standard regex engines an amount of memory must be allocated in bytes equal to the number being input. This doesn't apply to [RegexMathEngine](https://github.com/Davidebyzero/RegexMathEngine/), which has a numeric mode, but I haven't yet implemented this output method in it. [Try it online!](https://tio.run/##RU9BTsMwELz3FZZlVV6ctE6AA3Vcp1K5cuqNVFaJWsmSaYMTpCBjjjyAJ/KR4AQkLqud2dndmebo7O3w/IaIE8jbS32wiCxFhLLYbnabdZidLo6SVnJRrAV4ZE4RgW@cOXcIV2csAiqtbBtrOopTnLSvT20XV3SSZkkGx5dRpP5ZHnlYEQ1ivNXGjwdX2iIHX9rHbC9j5XsRZghNn80fQUwhJ0HsGANP6mgJUdzjnhiQH0uqVsQBVcozRuqEBxhztPP5ZHVyGmNkAv1aJ2aB0ffnF8ILUkfhexyFoPX9w1brgVY3ilElaX8FtMr9XYCxheoaWJX3bBh4mnP@Aw "Perl 5 – Try It Online") - Perl v5.28.2 / [Attempt This Online!](https://ato.pxeger.com/run?1=RU-xTsMwEBVrN_7gZFmVDyetExigjptWKisTG6miErWSJdO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bmHKfZhFzIGbLEsh8-IgLSWsMmPgrns_vZq5DcAniYGoPPpzZjB8I0U0DtGFuDo9Pxkftqi5dKBMHlgWk7XjP6xOavKUUmVFPiSDgQ4izCoBfVgHSmV4llID5UEfrGfBK2XLQi1ryi26zkeMJFroSNZJaTw2Kl4mc84iSDM-16-Al7escFXClvd-GKQpumFiNzv_Js3Cj9AKHfiUJRG0okAEmDuZJLkEzwMib1p0f4NBDbZtryvTMZVZBgknCKAczK-RCCnjJKft7szruDoEzQ7IQ88ig77l4sr2cv1lUTI4xc8exfMKEQ96vsCioq6En-NCQdeBEp5XQqqrwLCE0CrYar8MRLjwVSytzVqjFaysUuHoErim_95dfBiqkzguGV5ivBjCXCyeCLSyTywUqGUqgX24sr_Mk5QRQ4p3bydjmocvQx-dJdQxGB-G40t_Mhy_uRidTIZnq-Ph-8lwdCb3-8on82086dANg_cKJKDJfb0b1NvI1UL3trLh4z4QzI-LbOnngRCs4KRAlo-uXr82AHUdbF3B7gQmcbXydt0bWLKFghGsKbiCcGq8dHbx7DmANpUmy6QO0u5StyYUsVz8r1DBwqook4zvFFRm46wANV0e1szFiZHipCa6kRPuaO5Rd8V4VR5U4R1MTyCyhCiBVfmx_rzrQJ6VeK1vcPJHpNluGqPy4V2ZW5TZ8-o87_e5PBzswAVbydvQpTgweGeDpWetNMfZrd5d867dnbk4bJaYCVI60LxrSscwQSVezrya_joJicdlDx55vOuCbSf1iFekfKCATkkjpDnlGBKmDqUVP2NifR_BP7__AfjTkuCVHiHoWM2a7iXZlE_ZpYhZ7yh0OsGGUH8bTuPalJG6W85p3KMO7O8bG3ue6brx-HLsjy7fnExOz-kTRUW_WnutJoYoKvbMBsNfnS3dzfTH-W0i3jHJ5fPY2Lx3NVZcMEY28W03tBZY72l9IupLnBnrga0jwZ8O_T_AX1867V6nozf_AQ "C++ (GCC) – Attempt This Online") - PCRE2 v10.40+ Although Perl and PCRE2 (and Raku, though its syntax is different) are the only regex engines currently capable of counting the number of possible matches without their source code being patched, this regex itself only uses an **ECMAScript** level of functionality. ``` # No anchor. This will result in the regex being able to match # starting at any position, ranging from the input number to 0, # meaning tail will equal each of those values in turn. Each will # count towards the total number of possible matches. ( \4?+ # If this is the first iteration, do nothing, because \4 is unset. # Otherwise, tail -= \4. (?= # Atomic lookahead. Match what is inside, but upon exiting it, # jump back to the position we were at before entering it, and # never backtrack back into the lookahead to try different # matches. # \2 = floor(tail / 10); \3 = \2 * 9; \4 = tail % 10 (x*)(\2{9})(x*) ) \3 # tail = tail - \3 == \2 + \4; leave \4 to be subtracted at the # beginning of the next iteration, so that when we exit this loop, # the remainder \4 is readily accessible. )+ # Iterate the above loop any number of times, minimum one. Every # number of possible iterations will be tried, meaning that the # loop can exit after any iteration count, meaning the matching # done after the loop will be applied to each digit in turn, with # each adding linearly to the number of possible matches. \2 # tail = tail - \2 = \4 # Each time we reach this point, tail = one of the digits of the number x+ # Add \4 to the number of possible matches. This, and the number # of iterations the above loop can do, are the only choices # available for making a complete match. ``` Merely calculating the sum of digits of the input number N (instead of the sum of all sums of digits of 1 to N) actually takes a regex 1 byte *longer*, with a `^` anchor inserted at the beginning: [Try it online!](https://tio.run/##hVXrTuNGFP6fpzh4VZiJnW0S2hWNMRELkUDahVU2qNsl1DL2OBmtM7bs8XJZ8bcP0Efsg5SeuSQxJFItcOZyzndu3zmOi6Izi@PnNwlLuWDw6WQ86ocnl6ej8OrifBL@fn46OYOD1hsu4qxOGBwWccn6b@dHrXgelRAW1zcQwNh5f3f37Xa//uPh4ctk/u5uTp7/JNNfhi4ZBuS@Tcm0/@O3J6qWdLpP3Wn/3n2mr5UcD9pFEBZuz29YrGTJxUyZXJ/xHE9ZtDjakDtqcSGhwKUMWVnmJYlzUUnQ7rYXrKqiGaPwo5LJYBCjBBwegj1WS33ORJL5UDJZlwJ6/tMGptrHecI8uM3zDPIgjbJKwWozFu66/@u7G78F@PAUiM5cOGMWI7RSxOAQk/qrk7Pj8UGb2ksPKv7I8pSsHP95edKQp5RqK@ohOQxNEHFeSxjAKlCqwnO0GmgPBuC8Cl4rOw5qOVPh0FU@0qyu5iaSVVJaT61aVHwmWAJZLmbmFYnqjpW@TtjiIYyjLEM3bOx2F95mefwN2rEH33OeQDuJZIS5U0lSSwgCIOqmTXfXGNRiu@6qMl1bmUXEBUEA7WBxjUTImCAF7fRugq5vQjDsgCIOHDIcOD6u3KAwPw4lwxP836F4XiPifj@UWFTUVfAzXGjoJhAXRS2Vug4MSwjtki33i0jG81DH0l6vDVrJqjqTnimBbzvu8/nXkT5J04rhJcaLIczk/IVAO//OYolathLYeUv7i4JnjFhSfP40GdMifhuH6CyhnsX4OhpfhpPR@OP5xfFkdLo8Hn2ZjC5O1X5X@2R/rSddumbwTokEtLlvdoN@W7lG6MFGNkLcR5KFaZkvwiKSkpWClMjyi6sPHyxAUwdbV7J7iUlcroJt9xaWbKBgBCsKLiG8Bi@9bTx7DWBMZXzBmyCdHvUbQgkr5P8KlSyuy4rnYqugNpvmJejp8rhiLk6MDGczMY3MhWe4R/0l43V5UEV0MT2RzDnRAsvyY/1Fz4Mir/Da3OCsT8heZ88aVY/oqdyizE7Q5PlgINThcAsuuFrehR7FgSG6aywza5U5we7M7lr03N6Nj8NmgZkglQd793vKMUxQhZc3QUN/lQQeCNWDh4Ho@eC6vBnxkpSPFNApZYTsTQWGhKlDac3PlDg/JfDPX38Dflo4XpkRgo41rJleUk35kl2amM2OQqc5NoT@W3Ma17aM1N9wzuAedmF319rYCWzXjceX4/Di8uPx5OSMvlDU9Gu013JiyLJmr2ww/Ops6K6nP85vG/GWSa6ep9b6va2x0pIxso5vs6GNwGpPmxPRXOLMWA1sEwl@Op67nf1ut/tvnGbRrHruZFqrc/Af "C++ (gcc) – Try It Online") This regex apparently exposes a bug in the obsolete regex engine PCRE1: [Try it online!](https://tio.run/##fVThTtswEP7fpzgyQe0mRQ2dpq1pqBhj2g8GU1WkTbSKguukFqkTOclaYPzdA@wR9yDrznEDYWyL2sQ53313993nsCzrxoxtXgjJknLOYZgxxfcXhy22CBUE2eUMfBhbb1er66t@@eXm5vNk8Wq1IBsyfTmyycgn6w4l04O7N/dUL@m0T@3pwdre0D9jLAc6mR9ktuu1HvPlxVykOmHTpISMn9pEilYeLp/7HbaELCDDZRFwpVJFWCrzAqoGOkue52HM6R3mGQwYOsBwCFurXlZ2LueJB4oXpZLgevetUuYilnwOSSpjcwtlvuLKq7ItbwIWJklaFkTzVb8EV0nKrqHDKNwZd9t@gO0hbBUbCknQoQV4ZZfYRMIlyWjXnfk9D0xBpjXImG@R0cDycGX7mXlYlIyO8b9D0V4iZP8gKCDVwRo/xkWF3QQSMisLHa44dBT3oMkRkpIVykQrnpdJYdaazSjKeeEANodVxsXC7KRfOStSddmfmVSI6oNhIl1mIuFIyz4LMDmhDnw6Hp8E784nR6en8M28XUzev3Zgz2Q2izpVjxpMEQHZUZzW/EXViCOCbaG3A5YGqmpUEGJJVTjszgewm08liq2BafJsgZsTw7IfZ2m2I8QjuslbzWhFYsyLREhOjIaEdAyf1EMftx5lVTOGyR6ChkUqSOVU04A8SNeBLM1x2@xEQs5Ju9ve1qUv6Woi0WfHb85vMJDaOPoLLtiVvw1YyACTP2KZ4ep0kq/M26V0bXfmof6XyAvJHWiv27owbCXHzZnfiH8gQvhSa2voS9cD2xbNjutJ3VLAonQS0p7KtqFmSx/TRONRE/pmwc/vPwCVaw4IVtdIabSkFVjria85I4o7cHZxeuoAVixQItVvK0IH@tR7Vo9BGfZgb69GREor7Z2Mx@fj4Oz849Hk@AN9EvlwbOqSrROtL@spPk9y/v@wbW/15yVKynzxjy4b3d@3zL3S9MCIUXGOvdCHr8j2fLbuN73uQa/3i0VJGOebbqLZ@g0 "C++ (gcc) – Try It Online") - the results start being incorrect from 10 onward. Calculating the product of the of digits N is also 33 bytes: ``` ^((?=(x*)(\2{9}))\3x*x+(?=\2$))+$ ``` [Try it online!](https://tio.run/##hVXrTuNGFP6fpzh4t2TGdrZxUFc0xiAKkUDahVU2qNsFahl7nIzWGVv2eAms@NsH6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lUz5SQKcaI6R7IzAkTB1Kq/5MifVTAv/89Tfgp4UjS68QdKxlTc9SM5Qvu0s1Znui0GmOA6H@1j2NZ1NG6m84p3EP@rC7a2zsBGbqxuPLcXhx@fF4cnJGXyiq9muN13JjyLJmr2ww/Ops6K63P@5vE/GWTd48T531e9tgpSVjZB3f5kBrgdWdtjeiZuLOWC1sHQl@Op77Pa/f7/8bp1k0rZ57mdLq7f8H "C++ (gcc) – Try It Online") [Answer] **C# (108)** ``` int c(int n){return string.Join("",Enumerable.Range(1,n).Select(i=>i+"")).ToArray().Select(c=>c-'0').Sum();} ``` Pretty ``` int c(int n) { return string.Join("", Enumerable.Range(1, n).Select(i => i + "")).ToArray().Select(c => c - '0').Sum(); } ``` [Answer] # Ruby -> 83-50 = 33 ``` p (1..eval(gets.chomp)).each.inject{|c,e|c+e.to_s.chars.map{|x|x.to_i}.inject(:+)} ``` "To test" version: ``` module Math class CountSum def sum(number) (1..number).each.inject do |c, e| c + e.to_s.chars.map{ |x| x.to_i }.inject(:+) end end end end ``` ### Tests results ``` $ rspec sum_spec.rb --format doc --color Math::CountSum #sum single digit number when 5, should return 15 double digit number when 12, should return 51 arbitrary number when 1000000 should return 27000001 Finished in 5.34 seconds 3 examples, 0 failures ``` ]
[Question] [ ### Introduction The [Atari ST](https://en.wikipedia.org/wiki/Atari_ST) was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture: [![row of bombs](https://i.stack.imgur.com/CwMSk.png)](https://i.stack.imgur.com/CwMSk.png) *Source: <https://commons.wikimedia.org/wiki/File:Row_of_bombs.png>* *NB: Depending on the OS version, the bomb graphics may vary slightly. But let's take this one as reference.* The number of bombs depends on the exception vector, the most common ones being: * ($008) Bus Error : 2 bombs * ($00c) Address Error : 3 bombs * ($010) Illegal Instruction : 4 bombs ### Goal Your goal is to write a program or function that prints or outputs an ASCII art of such Atari ST bombs. ### Input An integer representing the number of bombs to display. Your code must support the most common values: 2, 3 and 4. Supporting less and/or more bombs is fine, but it is neither required nor subject to a bonus. ### Output The original bomb consists of a 16x16 pixel tile, represented here in both ASCII and binary: ``` ....##.......... 0000110000000000 .#.#..#......... 0101001000000000 .......#........ 0000000100000000 #..#....#....... 1001000010000000 ..#...#####..... 0010001111100000 ......#####..... 0000001111100000 ....#########... 0000111111111000 ...###########.. 0001111111111100 ...###########.. 0001111111111100 ..#############. 0011111111111110 ..########.####. 0011111111011110 ...#######.###.. 0001111111011100 ...######.####.. 0001111110111100 ....#########... 0000111111111000 .....#######.... 0000011111110000 .......###...... 0000000111000000 ``` In this challenge, each ASCII bomb must be stretched to twice its original width for a better rendering. Therefore, it will consist of 16 rows of 32 characters, using `##` for 'ON' pixels and two spaces for 'OFF' pixels. All bomb tiles must be put side by side. Leading spaces are forbidden. Trailing spaces are also forbidden, except the ones that are actually part of the bomb tile (i.e. the 31st and 32nd columns) which *must* be present. You may include no more than one leading line-break and no more than one trailing line-break. ### Example Below is the reference output for two bombs, where mandatory line-breaks are marked as `\n` and tolerated extra line-breaks are marked as `(\n)`: ``` (\n) #### #### \n ## ## ## ## ## ## \n ## ## \n ## ## ## ## ## ## \n ## ########## ## ########## \n ########## ########## \n ################## ################## \n ###################### ###################### \n ###################### ###################### \n ########################## ########################## \n ################ ######## ################ ######## \n ############## ###### ############## ###### \n ############ ######## ############ ######## \n ################## ################## \n ############## ############## \n ###### ###### (\n) ``` (Of course, other line-break formats such as `\r` or `\r\n` may be used just as well.) ### Rules This is code-golf, so the shortest answer in bytes wins. Standard loopholes are forbidden. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~43~~ 44 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) +1 byte - forgot to double the characters (not that anyone noticed!) ``` “¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’b⁴‘ĖŒṙị⁾ #Ḥs⁴ẋ€³Y ``` **[TryItOnline](http://jelly.tryitonline.net/#code=4oCcwqV24bqPKVg7bmTEismTwqHhurkzxItpfeG7ismywqFQIsKm4biKxqXhub7igJli4oG04oCYxJbFkuG5meG7i-KBviAj4bikc-KBtOG6i-KCrMKzWQ&input=&args=Mw)** ### How? Preparation was to compress the data as a run-length encoding of the original image: * Count the length of each run of `1`s (space) or `0`s (hash) in the image, ignoring new lines - yields a list: `[4,2,11,1,1,...]`; * Subtract one from each number - this gives a range of `[0,15]`; * Treat this as a base-16 number (enumerate the values, `v`, with index `i` in reverse and sum up `16**i*v` = `19468823747267181273462257760938030726282593096816512166437`); * Convert this to base-250: `[5,119,249,42,...]`; * Map into Jelly's code page as indexes: `¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P` Now the code evaluates this number, maps the `1`s and `0`s to space and hash characters\*, doubles each, splits into lines and repeats each the appropriate number of times. \* actually the implementation is performed modulo 2 to save bytes, so spaces are odd and hashes are even: ``` “¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’b⁴‘ĖŒṙị⁾ #Ḥs⁴ẋ€³Y - Main link: n “¥vẏ)X;ndĊɓ¡ẹ3ċi}Ịɲ¡P"¦ḊƥṾ’ - base 250 number, as above b⁴ - convert to base 16 (the run length - 1 list) ‘ - increment (vectorises) (the run length list) Ė - enumerate (pairs each with 1,2,3...) Œṙ - run length decode ([1,1,1,1,2,2,3,3,3,3,3,3,3,3,3,3,3,4,5,...]) ⁾ # - string " #" ị - index into (1 based and modular) (makes a bomb without line feeds) Ḥ - double (each char becomes a list of 2 chars) s⁴ - split into slices of length 16 ẋ€³ - repeat each input, n, times Y - join with line feeds ``` [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), ~~57~~ ~~55~~ ~~53~~ 50 bytes Uses [CP-1252](http://www.cp1252.com/) encoding. ``` •ø6ŒY2l½î€ÈS`L<eÆô‚˜3ª½¨ºE»D2Âô3•b15ôvy1J€D„# è¹×, ``` [Try it online!](http://05ab1e.tryitonline.net/#code=4oCiw7g2xZJZMmzCvcOu4oKsw4hTYEw8ZcOGw7TigJrLnDPCqsK9wqjCukXCu0Qyw4LDtDPigKJiMTXDtDHCq3Z54oKsROKAniMgw6jCucOXLA&input=NA) **Explanation** As the output image only consists of 2 characters we can represent it as a binary number. We can ignore newlines as every line has the same length. We can ignore the last char of each row as it the same for all rows. We use the thinner image as it takes up less space and we can easily duplicate each character later. Using **1** to represent **space** and **0** to represent **#** we get the binary number: `111100111111111101011011111111111111101111111011011110111111110111000001111111111000001111111100000000011111000000000001111000000000001110000000000000110000000010000111000000010001111000000100001111100000000011111110000000111111111100011111` We then convert this to base-10 and then compress it to base 214, the maximum base in 05AB1E. The result of this is: ``` •ø6ŒY2l½î€ÈS`L<eÆô‚˜3ª½¨ºE»D2Âô3• ``` The meat of the program then consist of the following: ``` <base encoded string> b # convert to binary 15ô # slice into pieces of 15 v # for each slice 1J # append a 1 €D # duplicate each character „# # push the string "# " è # use the list of binary digits to index into the string ¹× # repeat string input number of times , # and print with newline ``` [Answer] # Pyth, ~~57~~ ~~56~~ ~~54~~ ~~53~~ ~~51~~ 50 bytes The code contains unprintable characters, so here's a reversible `xxd` hexdump. ``` 00000000: 6a2a 4c51 6331 3673 2e65 2a79 6240 2220 j*LQc16s.e*yb@" 00000010: 2322 6b6a 4322 4c49 c142 3c60 0cca 9437 #"kjC"LI.B<`...7 00000020: b383 76bb c246 c86d 4c04 99bd 3614 7022 ..v..F.mL...6.p" 00000030: 3137 17 ``` [Try it online.](http://pyth.herokuapp.com/?code=j%2aLQc16s.e%2ayb%40%22+%23%22kjC%22LI%C3%81B%3C%60%0C%C3%8A%C2%947%C2%B3%C2%83v%C2%BB%C3%82F%C3%88mL%04%C2%99%C2%BD6%14p%2217&input=2&debug=0) [Answer] # JavaScript (ES6), ~~159~~ ~~154~~ ~~140~~ 136 bytes *Saved lots of bytes thanks to @Hedi and @Arnauld* ``` n=>[..."ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ"].map(x=>(f=q=>q?(q&1?" ":"##")+f(q>>1):"")(x.charCodeAt()).repeat(n)).join` ` ``` That's 104 chars, but (sadly) 136 UTF-8 bytes. The string was generated with this snippet: ``` console.log([ 0b1111111111001111, 0b1111111110110101, 0b1111111101111111, 0b1111111011110110, 0b1111100000111011, 0b1111100000111111, 0b1110000000001111, 0b1100000000000111, 0b1100000000000111, 0b1000000000000011, 0b1000010000000011, 0b1100010000000111, 0b1100001000000111, 0b1110000000001111, 0b1111000000011111, 0b1111110001111111 ].map(x=>(65535-x).toString(16)).join(",")) ``` Using `.replace` instead of `[...string].map` is equally long: ``` n=>"ᅬᄉソﻶ쀇쀇考萃쐇숇ﱿ".replace(/./g,x=>(f=q=>q?(q&1?" ":"##")+f(q>>1):"")(x.charCodeAt()).repeat(n)+` `) ``` ### How it works Since each row of the raw data can be represented as a 16-bit number, we can store the entire file in a 16-char string. The compression algorithm takes each binary row, flips it and reverses it (since every row in the original ends in a **0**, every row in the modified version now *starts* with a **1**), then turns it into a char, and concatenates the resulting characters. To decompress it, we need to extract the charcode and turn its binary representation into a string of hashes and spaces. This can be done with a recursive function, like so: ``` (f=q=>q?(q&1?" ":"##")+f(q>>1):"")(x.charCodeAt()) ``` `f` repeatedly takes the last bit of `q`, selecting two spaces if it's 1 or two hashes if it's 0, then concatenates that with the result of running `f` in the rest of `q`. This is run on `x.charCodeAt()`, turning the char-code into the correct string of spaces and hashes. (There was a lot more drama here before, but the 4-byte-saving technique erased all of that.) After that, we can just repeat the string `n` times and add a newline. This is the shortest decompression method I have found, but feel free to suggest any possibly shorter methods. Other attempts at compressing the string: ``` n=>[48,74,128,265,1988,1984,8176,16376,16376,32764,31740,15352,15864,8176,4064,896].map(x=>(f=q=>q?(q&1?" ":"##")+f(q>>1):"")(65535-x).repeat(n)).join` ` n=>"1c,22,3k,7d,1j8,1j4,6b4,cmw,cmw,pa4,oho,bug,c8o,6b4,34w,ow".split`,`.map(x=>(f=q=>q?(q&1?" ":"##")+f(q>>1):"")(65535-parseInt(x,36)).repeat(n)).join` ` n=>"30,4a,80,109,7c4,7c0,1ff0,3ff8,3ff8,7ffc,7bfc,3bf8,3df8,1ff0,fe0,380".split`,`.map(x=>(f=q=>q?(q&1?" ":"##")+f(q>>1):"")('0x'+x^65535)).repeat(n)).join` ` ``` The first of these is 153 bytes, so none of them come anywhere near 136... [Answer] ## MS-DOS .COM file, 84 bytes OK. Just for fun because I cannot beat the 50 bytes... Tried under DOSbox as well as under MS-DOS 6.22 in a virtual machine. Under DOSbox the program works fine however under real MS-DOS the output will not be displayed correctly because DOS requires CR-LF instead of LF at the end of the line. (However the output is correct.) A 88 byte variant would use CR-LF at the end of the line. Here is the file: ``` 0000 be 32 01 fc ad 89 c3 8a 36 82 00 80 ee 30 b9 10 0010 00 d1 c3 18 d2 80 ca 20 80 e2 23 b4 02 cd 21 cd 0020 21 e2 ee fe ce 75 e7 b2 0a cd 21 ad 85 c0 75 d5 0030 cd 20 00 0c 00 52 00 01 80 90 e0 23 e0 03 f8 0f 0040 fc 1f fc 1f fe 3f de 3f dc 1f bc 1f f8 0f f0 07 0050 c0 01 00 00 ``` The assembler code (in AT&T syntax) looks like this: ``` start: # Read data from "image:" mov $image,%si cld # Read the first 16 bytes lodsw nextLine: # Use bx as shift register mov %ax, %bx # Read the number of bombs mov 0x82,%dh sub $'0',%dh nextBombInThisLine: # Number of characters mov $16, %cx nextCharacter: # Rotate the data# get the next bit to CY rol $1, %bx # This results in 0x23 ('#') if CY is set, to 0x20 (' ') otherwise sbb %dl, %dl or $0x20, %dl and $0x23, %dl # Print result character twice mov $2, %ah int $0x21 int $0x21 # more Characters in this line? loop nextCharacter # More bombs to draw? dec %dh jnz nextBombInThisLine # Print a newline # mov $13, %dl # <- Additional 4 bytes needed for "\r\n" # int $0x21 # at the end of the line! mov $10, %dl int $0x21 # Read the next 16 bytes# 0x0000 means: EOF lodsw test %ax,%ax jnz nextLine # End of program int $0x20 image: # Here 34 bytes follow: # 16 16-bit-words "bitmap" for the bombs followed # by 0x0000 indicating the end of the bitmap ``` --- Edit --- I forgot to mention: The program must be started with the following command line: Name of the COM file + **exactly one** space character + Number of bombs (1-9) [Answer] # Python, ~~223~~ 179 bytes ### Second approach: ``` f=lambda n:'\n'.join(''.join(2*' #'[int(d)]for d in bin(int('0c0052000100908023e003e00ff81ffc1ffc3ffe3fde1fdc1fbc0ff807f001c0'[i:i+4],16))[2:].zfill(16))*n for i in range(0,64,4)) ``` [Try it on repl.it!](https://repl.it/Dn1M) Rather than creating a list of strings on-the-fly, there is a hard-coded hexadecimal string which is indexed and converted to binary; then each binary digit is turned into either `' '` or `'#'`, which is duplicated and joined together ... etc. ### First approach: ``` s=' ';b='##';f=lambda n:'\n'.join(n*l.ljust(32)for l in[s*4+b*2,(s+b)*2+s*2+b,s*7+b,b+s*2+b+s*4+b,s*2+b+s*3+b*5,s*6+b*5,s*4+b*9,s*3+b*11,s*3+b*11,s*2+b*13,s*2+b*8+s+b*4,s*3+b*7+s+b*3,s*3+b*6+s+b*4,s*4+b*9,s*5+b*7,s*7+b*3]) ``` [Try it on repl.it!](https://repl.it/DnYi/2) This contains a hard-coded list of the strings of each line (not including trailing spaces) created by duplicating either `' '` or `'##'` a number of times. For each of these strings, they are padded with spaces until 32 characters in length, duplicated `n` times, then joined with newlines. [Answer] # C, ~~250~~ ~~240~~ ~~208~~ 188 bytes ``` d[]={3072,20992,256,36992,9184,992,4088,8188,8188,16382,16350,8156,8124,4088,2032,448,0},m,c,*i=d;f(k){for(;*i;i++,puts(""))for(c=k;c--;)for(m=32768;m;write(1,&"## "[m&*i?0:2],2),m>>=1);} ``` Switch to using a function. ``` m,d[]={3072,20992,256,36992,9184,992,4088,8188,8188,16382,16350,8156,8124,4088,2032,448,0},*i=d;main(c,v)char**v;{for(;*i;puts(""),i++)for(c=atoi(v[1]);c--;)for(m=32768;m;write(1,&"## "[m&*i?0:2],2),m>>=1);} ``` Test like this. `main(c,v)char**v; { f(atoi(v[1])); }` ``` a.exe 2 #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ########## ## ########## ########## ########## ################## ################## ###################### ###################### ###################### ###################### ########################## ########################## ################ ######## ################ ######## ############## ###### ############## ###### ############ ######## ############ ######## ################## ################## ############## ############## ###### ###### ``` [Answer] # [///](https://esolangs.org/wiki////), ~~539~~ 532 + no. of bombs bytes The first /// answer, displaying 4 bombs. The end four 1's can be replaced with any unary representation of the number of bombs you want to print (11 for 2, 111 for 3) ``` /-/?|X//y/\/X//xy|//|/\/\///+/%@!|$/bcd|%/efg|@/hij|!/klm|?/nop|b/Bxc/Cxd/Dxe/Exf/Fxg/Gxh/Hxi/Ixj/Jxk/Kxl/Lxm/Mxn/Nxo/Oxp/Pxq/ss|r/tt|s/SS|t/TT|S/ |T/##|1/AX$+-$+?AXyAX$+-cd+?by$+-d+?cycd+-+?dyd+-fg@!?ey+-g@!?fyfg@!-@!?gyg@!-ij!?hy@!-j!?iyij!-!?jyj!-lm?ky!-m?lylm-?mym-opny-poyop|AXA/AA|bB/BB|cC/CC|dD/DD|eE/EE|fF/FF|gG/GG|hH/HH|iI/II|jJ/JJ|kK/KK|lL/LL|mM/MM|nN/NN|oO/OO|pP/PP|A/qtqqs|B/STSTsTqqS|C/qsSTqq|D/TsTqTqsS|E/sTsSrTqS|F/qsrTqS|G/qrrTsS|H/sSrrtTs|I/sSrrtTs|J/srrrTS|K/srrSrS|L/sSrtTStTs|M/sSrtSrs|N/qrrTsS|O/qSrtTq|P/qsStTqs|X/ /1111 ``` [Try it online!](http://slashes.tryitonline.net/#code=Ly0vP3xYLy95L1wvWC8veHl8Ly98L1wvXC8vL14vdFR8Ji9ycnwqL3NTfCsvJUAhfCQvYmNkfCUvZWZnfEAvaGlqfCEva2xtfD8vbm9wfGIvQnhjL0N4ZC9EeGUvRXhmL0Z4Zy9HeGgvSHhpL0l4ai9KeGsvS3hsL0x4bS9NeG4vTnhvL094cC9QeHEvc3N8ci90dHxzL1NTfHQvVFR8Uy8gIHxULyMjfDEvQ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|K/s&SrS|L/*r^S^s|M/*rtSrs|N/q&T*|O/qSr^q|P/q*^qs|X/ /4 ``` [Try it online!](http://slashes.tryitonline.net/#code=Ly0vP3xYLy95L1wvWC8veHl8Ly98L1wvXC8vLzQvMTN8My8xMnwyLzExfF4vdFR8Ji9ycnwqL3NTfCsvJUAhfCQvYmNkfCUvZWZnfEAvaGlqfCEva2xtfD8vbm9wfGIvQnhjL0N4ZC9EeGUvRXhmL0Z4Zy9HeGgvSHhpL0l4ai9KeGsvS3hsL0x4bS9NeG4vTnhvL094cC9QeHEvc3N8ci90dHxzL1NTfHQvVFR8Uy8gIHxULyMjfDEvQVgkKy0kKz9BWHlBWCQrLWNkKz9ieSQrLWQrP2N5Y2QrLSs_ZHlkKy1mZ0AhP2V5Ky1nQCE_ZnlmZ0AhLUAhP2d5Z0AhLWlqIT9oeUAhLWohP2l5aWohLSE_anlqIS1sbT9reSEtbT9seWxtLT9teW0tb3BueS1wb3lvcHxBWEEvQUF8YkIvQkJ8Y0MvQ0N8ZEQvRER8ZUUvRUV8ZkYvRkZ8Z0cvR0d8aEgvSEh8aUkvSUl8akovSkp8a0svS0t8bEwvTEx8bU0vTU18bk4vTk58b08vT098cFAvUFB8QS9xdHFxc3xCL1NUU1RzVHFxU3xDL3EqVHFxfEQvVHNUcVRxKnxFL3NUKnJUcVN8Ri9xc3JUcVN8Ry9xJlQqfEgvKiZec3xJLyomXnN8Si9zJnJUU3xLL3MmU3JTfEwvKnJeU15zfE0vKnJ0U3JzfE4vcSZUKnxPL3FTcl5xfFAvcSpecXN8WC8KLzQ&input=) The most important parts of the code are that: | means // ABCDEFGHIJKLMNOP mean each line of the bomb respectively S means 2 spaces s means 4 spaces \* means 6 spaces q means 8 spaces T means ## (2) t means #### (4) ^ means ###### (6) r means ######## (8) & means ################ (16) Most of the code is making sure that the bombs are printed side-by-side, not on top of each other. [Answer] # [CJam](http://sourceforge.net/projects/cjam/), 66 bytes ``` "^a1{9\b aZ5w7qQAwndIUffO"136b2b1Ser0'#erG/ri*z{:_N}% ``` [Try it online!](http://cjam.tryitonline.net/#code=IgFeBB9hMXsLOVweGmIEIGFaNXc3fw9xUUF3bmQQSVUTBRhmZk8iMTM2YjJiMVNlcjAnI2VyRy9yaSp6ezpfTn0l&input=Mg) *(note that there are some unprintable characters in the code.)* --- The bomb in encoded in as a number in binary using 1 for spaces (the leading space as 1 ensures we don't have to pad the binary representations), transposed, and then converted to string in base-136 (which produced the shortest string without wide-characters). These steps can be played with [here](http://cjam.tryitonline.net/#code=IgouLi4uIyMuLi4uLi4uLi4uCi4jLiMuLiMuLi4uLi4uLi4KLi4uLi4uLiMuLi4uLi4uLgojLi4jLi4uLiMuLi4uLi4uCi4uIy4uLiMjIyMjLi4uLi4KLi4uLi4uIyMjIyMuLi4uLgouLi4uIyMjIyMjIyMjLi4uCi4uLiMjIyMjIyMjIyMjLi4KLi4uIyMjIyMjIyMjIyMuLgouLiMjIyMjIyMjIyMjIyMuCi4uIyMjIyMjIyMuIyMjIy4KLi4uIyMjIyMjIy4jIyMuLgouLi4jIyMjIyMuIyMjIy4uCi4uLi4jIyMjIyMjIyMuLi4KLi4uLi4jIyMjIyMjLi4uLgouLi4uLi4uIyMjLi4uLi4uCiIgICAgICAgICAgICAgICAgIGUjIFRIRSBCT01CIQoiLiMiIjEwImVyTiUgICAgICBlIyBlbmNvZGUgdG8gYmluYXJ5IGxpbmVzCnogICAgICAgICAgICAgICAgIGUjIHRyYW5zcG9zZSAoc2F2ZXMgYSBieXRlIHRvLCBidXQgY291bGQgYmUgaW4gY29kZSkKZV97JzAtfSUyYiAgICAgICAgZSMgY29udmVydCBib21iIHRvIG51bWJlcgoxMzZiOmNlX2VkTm8gICAgICBlIyBlbmNvZGluZyAoc3RhY2sgZGlzcGxheSkKICAgICAgICAgICAgICAgICAgZSMgQUNUVUFMIENPREUgQkVMT1cgSEVSRQoxMzZiMmIwJyNlcjFTZXJHLyBlIyBkZWNvZGUgdmlhIGJpbmFyeQpyaSp6ezpfTn0lICAgICAgICBlIyBjb21iaW5lIHZpYSB0cmFuc3Bvc2U&input=Mg&debug=on). This answer then reverses the encoding, the main trick being to repeat the bomb before transposing, effectively concatenating each line of the bomb at once. The characters in each line can be then be doubled up with newlines inserted for the final output. [Answer] # PHP, ~~138~~ 104+32=136 bytes I had never thought that `file` was binary safe. I only wish I would have found a more interesting way to store the data; but nothing I tried beat raw binary. ``` foreach(unpack("v*",file(b)[0])as$v)echo" ",str_repeat(strtr(sprintf("%016b",$v),[" ","##"]),$argv[1]); ``` * read binary data from file, unpack from little endian 16bit to array of int * loop through array: print 16 digit binary to string, replace `0` with 2 spaces, `1` with `##`, repeat `$argv[1]` times, print result + newline run with `-r` --- binary data in file `b`: ``` 0000000 0c00 5200 0100 9080 23e0 03e0 0ff8 1ffc 0000010 1ffc 3ffe 3fde 1fdc 1fbc 0ff8 07f0 01c0 ``` code to generate the file: ``` $f=fopen(b,wb);foreach(array_map(bindec,explode(" ", "0000110000000000 0101001000000000 0000000100000000 1001000010000000 0010001111100000 0000001111100000 0000111111111000 0001111111111100 0001111111111100 0011111111111110 0011111111011110 0001111111011100 0001111110111100 0000111111111000 0000011111110000 0000000111000000"))as$c)fputs($f,pack("v*",$c));fclose($f); ``` [Answer] # [MATL](http://github.com/lmendo/MATL), ~~64~~ ~~63~~ ~~60~~ ~~59~~ 58 bytes ``` 49:',cxJr(v9hW&waHB`U=NL%)C9[$aoAN'F16ZaQEY"32e!' #'w)liX" ``` [**Try it online!**](http://matl.tryitonline.net/#code=NDk6JyxjeEpyKHY5aFcmd2FIQmBVPU5MJSlDOVskYW9BTidGMTZaYVFFWSIzMmUhJyAjJ3cpbGlYIg&input=Mw) ### Explanation The code uses a pre-compressed version of the 16×16 binary matrix. The pre-compressing (not part of the program) used two steps: 1. Run-length encoding of the matrix read in row-major order (first across, then down). 2. The resulting run-lengths range from 1 to 16, so the vector of run-lengths minus 1 was converted from base 16 to base 94 (to use all printable ASCII codes except single quote, which is not used because it would need escaping). The compressed string, ``` ',cxJr(v9hW&waHB`U=NL%)C9[$aoAN' ``` is decompressed from base 94 to base 16: ``` F16Za ``` The obtained vector of run-lenghts plus 1 is multipled by 2: ``` QE ``` to perform the horizontal stretching. The vector of run-lenghts contains 49 values. The original numbers to be repeated with those lengths should be `[0 1 0 1 ... 0]` (49 entries). But instead of that, it's shorter to use the vector `[1 2 ... 49]`, which will be equally valid thanks to modular indexing. So the run-length decoding is ``` 49: Y" ``` The generated vector containis the runs of `1`, `2`, ...`49`, for a total of 512 entries. This is reshaped into a 16×32 matrix: ``` 32e! ``` and used as modular indices into the string `' #'` to produce a single bomb: ``` ' #'w) ``` Finally, horizontal repetition by a factor given by the input produces the desired result: ``` liX" ``` [Answer] # Python 2: 143 bytes ``` n=input() j=2 while j<258:print''.join(2*'# '[b>'0']for b in bin(int('62XI2JG3U2Q0COCDFCZAMC8A9LAP6W1ZMM4A59GC43M49ENF3Z',36))[j:j+16])*n;j+=16 ``` It's at **[ideone](http://ideone.com/d9IYc7)** (I realised that direct encoding of the original bomb in base 36 made for shorter code in Python.) The string was formed by treating spaces as 1s and hashes as 0s, and then converting to base 36. The program then converts back to binary and slices into lengths of 16 (with an offset of 2 for the '0b' at the front of Python's binary string) , converts to double spaces and double hashes, joins them up, repeats the string `n` times and prints. --- **Previous: Python 2, ~~169 166~~ 163 bytes** ``` n=input() j=0 while j<512:print''.join(' #'[i%2]*2*(v+1)for i,v in enumerate(int(c,16)for c in'31A00010F07010308024A4885A4A3C2703360245035876A25'))[j:j+32]*n;j+=32 ``` It's at **[ideone](http://ideone.com/ZodxuL)** Almost a port of [my Jelly answer](https://codegolf.stackexchange.com/a/95309/53748). [Answer] # Python 2.7, ~~144~~ 141 bytes ``` x=input() for i in range(16):print"".join(" #"[b<"1"]*2for b in bin(int("5ZCAZKAVTP6J04W4VZJ2BQDH5DASIKRS524V8SWRSIVWZEWC8V",36))[2+i::16]*x) ``` The bomb is written in binary with 1 for space, the leading 1 removes the need to pad binary representations. The bomb is transposed (much like in [my CJam answer](https://codegolf.stackexchange.com/a/95297/46756)) and stored in base 36. The program decodes the bomb to binary and iterates bits by a step of 16 effectively following the transposition (which is saves bytes over slicing a given line). The resultant line is concatenated, bits are replaced with doubled or `#`, and joined into a singe string. [Answer] # [C (gcc)](https://gcc.gnu.org/), ~~216 204 183 165~~ 134 bytes ``` b(n,i){for(n*=16,i=--n*16;i--;i%n||puts(""))printf(L"àϸ\x7fc\xfde\xfee`\x1fff\xffe\xffe\x7fcǰᇰ䡀\x80⤀\x600"[i/n]&1<<i%n%16?"##":" ");} ``` [Try it online!](https://tio.run/##S9ZNT07@/z9JI08nU7M6Lb9II0/L1tBMJ9NWVzdPy9DMOlNX1zpTNa@mpqC0pFhDSUlTs6AoM68kTcNH6fCC8ztiKszTkmMq0lJSgURq6sP962MqDNPS0oC8tFQoAVRxfMPD9g1PFjbEVFgYPFoCpMwMDJSiM/XzYtUMbWyA5qsamtkrKSsrWSkpKChpWtf@B9qhkJuYmaehWZ2kYQQSAQA "C (gcc) – Try It Online") Written as a standalone program (~~201 183~~ 151 bytes) ``` i=16;main(j,l)char**l;{for(;i--;puts(""))for(j=*l[1]*16-769;j--;printf(L"àϸ\x7fc\xfde\xfee`\x1fff\xffe\xffe\x7fcǰᇰ䡀\x80⤀\x600"[i]&1<<j%16?"##":" "));} ``` [Try it online!](https://tio.run/##S9ZNT07@/z/T1tDMOjcxM08jSydHMzkjsUhLK8e6Oi2/SMM6U1fXuqC0pFhDSUlTEySSZauVE20Yq2VopmtuZmmdBZIvyswrSdPwUTq84PyOmArztOSYirSUVCCRmvpw//qYCsO0tDQgLy0VSgBVHN/wsH3Dk4UNMRUWBo@WACkzAwOl6MxYNUMbmyxVQzN7JWVlJSslBQWgtda1////NwIA "C (gcc) – Try It Online") This segfaults if a command line parameter is not supplied. [Answer] ## Batch, 415 bytes ``` @echo off set h=##### set s= for %%a in (" ##%s%%s%" " # # #%s% " "%s% #%s% " "# # #%s% " " #%h%%s%" "%s% %h%%s%" " %h%#### " " %h%%h%# " " %h%%h%# " " %h%%h%### " " %h%### #### " " %h%## ### " " %h%# #### " " %h%#### " "%s%%h%## " "%s% ###%s% ")do call:l %1 %%a exit/b :l set r= for /l %%i in (1,1,%1) do call set r=%%r%%%~2 set r=%r: = % echo %r:#=##% ``` Note: the line `set s=` ends in 5 spaces. Accepts the count as a command-line parameter. Simply loops through each line of the bomb (compressed very slightly by removing runs of 5 identical characters) then repeats the bomb as many times as desired before finally duplicating each character. [Answer] # Python 2, ~~206~~ ~~205~~ ~~203~~ ~~199~~ ~~191~~ ~~188~~ ~~186~~ ~~184~~ 160 bytes ``` z=input() for y in 3072,20992,256,36992,9184,992,4088,8188,8188,16382,16350,8156,8124,4088,2032,448:print"".join(" #"[e>0]*2for e in map(int,bin(y+8**6)[5:]))*z ``` Looked at Hex for the number list but it didn't seem to save enough to make it worth the effort. Was hoping to be able to golf the code down but seem to have got as far as I can with this approach. Any additional hints gratefully received. **EDIT** -1 by changing `e==1` to `e>0`. I always forget that one. -2 by ignoring the length of the binary string, prepending 7 0's and taking only the last 16 elements. Works as there are never more than 7 leading 0's. -4 because now that I have lost the second reference to the variable b I can use `bin(y)[2:]` directly in the map function taking it below the magic 200 :-) -8 by using slice assignment on the second list. Learned something new this evening. -3 with thanks to @Jonathan -2 by using `c=d=([0]*7+map(int,bin(y)[2:]))[-16:]` instead of having `c=d;` -2 again thanks to @Jonathan -24 with thanks to @Linus **Output** ``` python bombs.py 2 #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ########## ## ########## ########## ########## ################## ################## ###################### ###################### ###################### ###################### ########################## ########################## ################ ######## ################ ######## ############## ###### ############## ###### ############ ######## ############ ######## ################## ################## ############## ############## ###### ###### ``` [Answer] # [RProgN](https://github.com/TehFlaminTaco/Reverse-Programmer-Notation), ~~210~~ 193 Bytes Saved some bytes by switching 0=' ' 1='##' to 1=' ' 0=' ', this means i don't need to add the extra zeros back. Also, this means that now the B64 string that used to say "MAFIA" does not, This is sad. ``` 'n' = => 64 -B 2 B ] 1 16 sub n rep \ 17 32 sub n rep ' ' \ . . '1' ' ' replace '0' '##' replace } a'' = D4D/4/'' a DgQ/AH'' a DAIeAj'' a DgA8AB'' a DwB+AD'' a DcH/wf'' a D+/29/'' a Dz/63/'' a ``` ## Explanation ``` 'n' = # Associate the input with "n" => # Push a new function to the stack. 64 -B # Take the value from the top of the stack, convert it to an integer from Base64 2 B # Take the value from the top of the stack, convert it from an integer to binary ] # Duplicate the top of the stack. 1 16 sub # Push the substring from the top of the stack between 1 and 16, 1 indexed. n # Push the input. rep # Repeat, this gives us 'n' bombs, essentially. \ # Flip the values such that REPEATEDBOMB_ROW TEXT 17 32 sub # Push the substring between 17 and 32. n # Push the input rep # Repeat ' # Push a new line ' # RProgN doesn't actually have escapes, so the raw newline is represented as a newline between qoutes. \ . . # Flip the values so we have LINE1 NEWLINE LINE2, then concatenate them all into one string. '1' ' ' replace # Replace all the 1's in the binary string with two spaces. '0' '##' replace # Replace all the 1's with two '#'s } a'' = # Associate the function with 'a' D4D/4/'' a # Bottom two lines, DgQ/AH'' a # Next two up, DAIeAj'' a # Etc... DgA8AB'' a # Once This is done, the memory stack is implicitly printed from top to bottom. DwB+AD'' a # As such, the bomb is upside down. DcH/wf'' a # Each of these numbers represents two lines, which is why we do the substringing to split it. D+/29/'' a # This works out saving a few bytes. Dz/63/'' a # Implicitly printed output. Yay. ``` Pretty long, The expanding, printing and such of the compressed string is 105 of the bytes. Might be a bit more golfable, but atleast it works. Input is implicitly on the stack, stack is implicitly printed. ## Output ``` #### #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ########## ## ########## ## ########## ########## ########## ########## ################## ################## ################## ###################### ###################### ###################### ###################### ###################### ###################### ########################## ########################## ########################## ################ ######## ################ ######## ################ ######## ############## ###### ############## ###### ############## ###### ############ ######## ############ ######## ############ ######## ################## ################## ################## ############## ############## ############## ###### ###### ###### ``` ## Try it! ``` <style> #frame{ width:60em; height:60em; border:none; } </style> <iframe id='frame' src="https://tehflamintaco.github.io/Reverse-Programmer-Notation/RProgN.html?rpn=%27n%27%20%3D%20%3D%3E%2064%20-B%202%20B%20%5D%201%2016%20sub%20n%20rep%20%5C%2017%2032%20sub%20n%20rep%20%27%0A%27%20%5C%20.%20.%20%271%27%20%27%20%20%27%20replace%20%270%27%20%27%23%23%27%20replace%20%7D%20a%27%27%20%3D%20D4D%2F4%2F%27%27%20a%20DgQ%2FAH%27%27%20a%20DAIeAj%27%27%20a%20DgA8AB%27%27%20a%20DwB%2BAD%27%27%20a%20DcH%2Fwf%27%27%20a%20D%2B%2F29%2F%27%27%20a%20Dz%2F63%2F%27%27%20a&input=1">Sorry, You need to support IFrame. Why don't you..?</iframe> ``` [Answer] # PHP, ~~144~~ ~~140~~ ~~139~~ ~~138~~ 136 bytes Note: uses Windows-1252 encoding ``` for(;$j%=32*$argn or$r=intval(substr("01c02203k07d1j81j46b4cmwcmwpa4ohobugc8o6b434w0ow",$i++*3,3),36)*print~õ;)echo~ßÜ[$r>>$j++/2%16&1]; ``` Run like this: ``` echo 2 | php -nR 'for(;$j%=32*$argn or$r=intval(substr("01c02203k07d1j81j46b4cmwcmwpa4ohobugc8o6b434w0ow",$i++*3,3),36)*print~õ;)echo~ßÜ[$r>>$j++/2%16&1];' ``` Or using IBM-850 encoding (135 bytes and prettier result): ``` echo 2 | php -nR 'for(;$j%=32*$argn or$r=intval(substr(~¤╬£¤══¤╠ö¤╚ø╬òÃ╬ò╦╔Ø╦£Æê£ÆêÅ×╦ÉùÉØèÿ£ÃÉ╔Ø╦╠╦ê¤Éê,$i++*3,3),36)*print~§;)echo~▀M[$r>>$j++/2%16&1];' ▓▓▓▓ ▓▓▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓ ``` # Explanation This doesn't do any binary stuff and doesn't require an external file. Every 16 bit number is reversed, then encoded as a base-36 number, padded with a leading `0` if necessary, so every 16 bits result in 3 bytes. Concatenating those results in `01c02203k07d1j81j46b4cmwcmwpa4ohobugc8o6b434w0ow`. The code reverses the process so the bombs are printed correctly `N` times. # Tweaks * Saved 4 bytes by using only a single for-loop * Saved a byte by printing a single char for each iteration and using string index instead of ternary * Saved a byte by getting resetting `$j` to zero on line boundaries with `%=`. This gets rid of parentheses * Saved 2 bytes by using `$argn` [Answer] # GCC C 129 bytes ### ISO8859/ASCII ``` f(r,i,d){ for(;i<32;i+=2,puts("")) for(d=15*r;--d;) printf((*(int*)&("ÿóÿ­ÿþoÜüðààÀ!ÀCÀCàðø?þ"[i]))&(1<<d%15)?" ":"##"); } ``` In one line: ``` f(r,i,d){for(;i<32;i+=2,puts(""))for(d=15*r;--d;)printf((*(int*)&("ÿóÿ­ÿþoÜüðààÀ!ÀCÀCàðø?þ"[i]))&(1<<d%15)?" ":"##");} ``` Run with: ``` main(c,v)char**v;{f(atoi(v[1]),0)} ``` Compile source as ISO8859-x (ASCII). NB óÿ­ÿþÿoÜüðààÀÀ!ÀCàCðøþ? should contain the invisible ASCII Codes but it has been broken due to the way StackExchange presents its content. Please see the ideaone link for proper test encoding Alternatively the original ASCII String is at : <https://github.com/claydonkey/AtariBombs/blob/master/ISO8859_REPR2.txt> ## Explanation First a conversion of the hex representation of bombs [f3 ff ad ff fe ff 6f 7f dc 1f fc 1f f0 07 e0 03 e0 03 c0 01 c0 21 c0 43 e0 43 f0 07 f8 0f fe 3f] to UTF-8 (in the UTF-8 version the compiler stores the string as Wide Char Array - 2 or 4 bytes for each character at runtime but this is academic). Whereas UTF-8 characters would be stored as 2-4 bytes, these values are all within ISO-8859-1 (ASCII) and thus only require 1 byte. Also it is safe to be stored as ISO-8859-x (there are no 0x8\_ or 0x9\_ values). Therefore the text consumes 32 bytes in ISO-8859 and the routine consumes 135 bytes in total. (NB wide chars are stored as a 16 bit integer in windows and 32bit in linux but again this is irrelevant to the task at hand) Caveat: Not all the characters are displayable (the control characters below 0x20) .They are, however still present . Most web pages are utf-8/ 8859/1253 (<https://w3techs.com/technologies/overview/character_encoding/all>) so I reckon this is legit~~(shifting all values below 0x20 to printable ASCII should fix that).~~ ### UTF-8 Here is the version closer to the original posting with UTF-8 encoded source. This consumes 173 bytes. The string itself being 50 bytes of the source. The routine is also longer as the ASCII bytes are now stored with padding 0's for the 16bit/32bit Wide Chars and have to be shifted instead of casted to uint16\_t as above. I have kept this up as it can be verified with ideone which uses UTF-8 encoding. ``` *w=L"óÿ­ÿþÿoÜüðààÀÀ!ÀCàCðøþ?"; f(r,i,j,m){ for(i;i<32;i+=2,puts("")) for(j=r;j--;) for(m=65536;m>1;(m\=2,printf(((w[i]<<8)+w[i+1]&m)?" ":"##")));} ``` Run with: ``` main(c,v)char**v;{f(atoi(v[1]),0)} ``` If you can set the implicit value to a 16bit integer in your complier you can omit the wchar\_t type declaration of the Wide Char. Ideone doesn't complain so I reckon it's good to go. **Try it out** on [ideone](http://ideone.com/jcR3qG) [Answer] ## Haskell, 155 bytes As a function with type `Int -> String`: ``` b z=concat$do y<-[0..15];"\n":[if odd$div 0x3800FE01FF03DF83BF87BFC7FFC3FF83FF81FF007C007C401090080004A0030(2^(16*y+x))then"##"else" "|x<-[1..z]>>[0..15]] ``` Printing to IO directly will cost 5 bytes (or 6 if we prefer to return `IO ()` rather than `IO [()]`): ``` b z=mapM putStr$do y<-[0..15];"\n":[if odd$div 0x3800FE01FF03DF83BF87BFC7FFC3FF83FF81FF007C007C401090080004A0030(2^(16*y+x))then"##"else" "|x<-[1..z]>>[0..15]] ``` [Answer] ### C, 175 bytes ``` x[]={48,74,128,265,1988,1984,8176,16376,16376,32764,31740,15352,15864,8176,4064,896};f(z,p){while(z++<16){p=1;while(p<<=1){printf("%s",p&(x[z]<<16|x[z])?"##":" ");}puts("");}} ``` concatenates each x to itself and makes p overflow to end each line. [Answer] ## Java, 228 bytes ``` import static java.lang.System.out; public class Bombs { public static void main(String[] args) { new Bombs().d(2); new Bombs().d(3); new Bombs().d(4); } void d(int n){String s="";for(int x=16,r=0;r<16*n;x=16,s+=(++r%n==0?"\n":""))while(--x>=0)s+=((new int[]{1536,10496,128,18496,4592,496,2044,4094,4094,8191,8175,4078,4062,2044,1016,224}[r/n])&(1<<x))==0?" ":"##";out.println(s);} } ``` [Answer] # J, 89 bytes ``` |:@;@#&(<' #'{~2#|:16 16$}.2#.inv 95#.32x-~3 u:'u,:C>%}UwPXHn_C9wF.|U ap<{jH%O9 9wRThGs') ``` Encodes the string as a base-95 number, increments each digit by `32`, then represents it by an ascii string. ## Explanation This is composed of two main parts. There is the constructing of the bomb, and the actual repetition. Let's for the moment refer to the bomb as `b`. Then, the code looks like: ``` |:@;@#&(b) ``` When called with input `k`, this is equivalent to: ``` |: ; (k#b) ``` `b` is a boxed bomb, so `k#b` makes `k` repetitions of `b`, `;` flattens it vertically, and `|:` transposes the result. (The bomb `b` is itself constructed transposed.) Now, here is the bomb: ``` <' #'{~2#|:16 16$}.2#.inv 95#.32x-~3 u:'u,:C>%}UwPXHn_C9wF.|U ap<{jH%O9 9wRThGs' ``` The string following is a base-95 encoded string with an offset of `32`, so that all the characters fall into the ASCII range, and thankfully there are no `'`s that need to be escaped. `3 u:` gets the char codes of the string, `32x-~` makes each number an e`x`tended number and subtracts `32` from it; `95#.` converts to a base-95 number an `2#.inv` converts it to a binary digit array. I added a leading `1` to the binary in order to make it a solid number, so I take it off with `}.`. I shape the array into a 16x16 table with `16 16$` then transpose it using `|:`. (Possible golf for later: transpose the literal encoded string.) `2#` duplicates each character width-wise. We are left with a table of `0`s and `1`s. `' #'{~` maps `0`s to `' '` and `1` to `'#'`. As thus, we are left with our bomb. ## Test case ``` |:@;@#&(<' #'{~2#|:16 16$}.2#.inv 95#.32x-~3 u:'u,:C>%}UwPXHn_C9wF.|U ap<{jH%O9 9wRThGs') 3 #### #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ########## ## ########## ## ########## ########## ########## ########## ################## ################## ################## ###################### ###################### ###################### ###################### ###################### ###################### ########################## ########################## ########################## ################ ######## ################ ######## ################ ######## ############## ###### ############## ###### ############## ###### ############ ######## ############ ######## ############ ######## ################## ################## ################## ############## ############## ############## ###### ###### ###### ``` [Answer] # **[BaCon](http://www.basic-converter.org), ~~229~~ ~~227~~ 195 bytes** A contribution in BASIC for sake of nostalgia. The variable 'a' determines the amount of bombs. ``` a=2:FOR x=0 TO 15:FOR y=1 TO a:FOR i=15 DOWNTO 0:?IIF$(v[x]&INT(POW(2,i)),"##"," ");:NEXT:NEXT:?:NEXT:LOCAL v[]={3072,20992,256,36992,9184,992,4088,8188,8188,16382,16350,8156,8124,4088,2032,448} ``` **Output**: ``` #### #### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ########## ## ########## ########## ########## ################## ################## ###################### ###################### ###################### ###################### ########################## ########################## ################ ######## ################ ######## ############## ###### ############## ###### ############ ######## ############ ######## ################## ################## ############## ############## ###### ###### ``` [Answer] ## Haskell, ~~191~~ 181 bytes ``` f n=h n:f(div n 2) h n|odd n=' ' h _='#' g b=mapM_ putStrLn[[f 0xfc7ff01fe00fc207c40784038003c007c007e00ff83ff83bfef6ff7fffb5ffcf!!(x`mod`32`div`2+y*16)|x<-[0..32*b-1]]|y<-[0..15]] ``` [Answer] # C (Atari TOS 2.06 US), ~~129 124 117~~ 113 bytes ``` short*a=0xe013b0;main(j,l)char**l;{for(;*a++-224;puts(""))for(j=*l[1]*16-768;j--;printf(*a&1<<j%16?"##":" "));} ``` This uses the bomb bitmap from the TOS ROM, which is slightly different from the one in the question. For other versions of TOS, you'll have to adjust the address pointed to by `*a`. Note that some emulator roms don't include the bomb bitmap! If you don't provide a command line argument, several high resolution bitmapped bombs may be displayed :-) [Answer] # Excel VBA, 204 Bytes Anonymous VBE Immediate window function that takes input from the range `[A1]` and outputs to the ActiveSheet Object ``` Cells.RowHeight=48:For i=0To[A1-1]:[A4,B2,C5,D4,D2,E1:F1,G2,H3,I4,G5:K6,E7:M7,D8:N9,C10:J11,K10:O10,O11,L11:N13,K13:K15,L14:L15,M14,D12:I13,J12,E14:G14,F15:G15,H14:J16].Offset(,16*i).Interior.Color=0:Next ``` ### Output [![Babomb](https://i.stack.imgur.com/tzY5M.png)](https://i.stack.imgur.com/tzY5M.png) [Answer] # [Vyxal](https://github.com/Lyxal/Vyxal) `j`, 49 bytes ``` »ƛ¢y⇧↲⁽¹ŀuḂHŻḊ`I5□‡+vġ¯=<↓ d→YCnȧr»‛# τ16ẇƛ⁰*ƛd;ṅ ``` [Try it Online!](http://lyxal.pythonanywhere.com?flags=j&code=%C2%BB%C6%9B%C2%A2y%E2%87%A7%E2%86%B2%E2%81%BD%C2%B9%C5%80u%E1%B8%82H%C5%BB%E1%B8%8A%60I5%E2%96%A1%E2%80%A1%2Bv%C4%A1%C2%AF%3D%3C%E2%86%93%20d%E2%86%92YCn%C8%A7r%C2%BB%E2%80%9B%23%20%CF%8416%E1%BA%87%C6%9B%E2%81%B0*%C6%9Bd%3B%E1%B9%85&inputs=3&header=&footer=) [Answer] ### C++11, 252 bytes ``` #include <iostream> using namespace std;string d("01c02203k07d1j81j46b4cmwcmwpa4ohobugc8o6b434w0ow");int main(){for(int i=0;i!=45;i+=3){int z=stoi(d.substr(i,3),NULL,36);for(unsigned long p=1;p!=1<<31;p<<=1){cout<<(((z<<16|z)&p)?"##":" ");}puts("");}} ``` [Answer] # SmileBASIC, 127 bytes ``` INPUT N FOR J=0TO 15FOR K=1TO N FOR I=0TO 14?" #"[1AND ASC("xxxxxxxxxxxxxxx"[I])>>J]*2; NEXT NEXT?NEXT ``` [![screenshot](https://i.stack.imgur.com/OUfXA.jpg)](https://i.stack.imgur.com/OUfXA.jpg) (Screenshot of version without doubled characters) SB has a square font, so doubling the characters looks bad (and doesn't fit on the screen) Non-ASCII characters have been replaced by `x`'s. Hex values: `0008,0002,0610,1F8A,3FC1,7FC1,7FF2,FFF4,FFF8,EFF0,73F0,7FC0,3FC0,1F80,0600` Since SB saves files in UTF-8, some of these count as 2 or 3 bytes. ]
[Question] [ # [Loves me, Loves me not](https://en.wikipedia.org/wiki/He_loves_me..._he_loves_me_not) This simple kids' game is old, but still popular. Since we are living in 21st century now, let's digitize it! # Specification Program must take no input, unless you are using a language that can't generate random seed - in that case you are allowed to take the seed as an input. Your task is to write a program that will output randomly a total of 3 to 20 lines inclusive: "Loves me..." and "Loves me not..." in turns, as in the game (and one additional line; keep reading). However, there are some restrictions. Each line should be followed by newline. The first line must be "Loves me...". The last line (either "Loves me" or "Loves me not") should end with exclamation mark or a single dot, respectively. After the last line, you need to output either a heart( `<3` ) or a broken heart ( `</3` ) in the new line, depending whether "Loves me!" or "Loves me not." was the last sentence. Trailing whitespace are allowed. # Example Output Output: > > Loves me... > > Loves me not... > > Loves me... > > Loves me not... > > Loves me! > > <3 > > > Another output: > > Loves me... > > Loves me not... > > Loves me... > > Loves me not. > > </3 > > > ## This is the [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest entry wins! Also, my first challenge :) Good luck! [Answer] # Pyth, 54 53 51 50 48 bytes ``` pj+*3\.bm+W~!Z"Loves me"" not"+3O18@".!"Z%hZ"</3 ``` [Answer] # CJam, ~~53~~ ~~50~~ 49 bytes *Thanks to Dennis for saving 1 byte.* ``` Imr3+{"Loves me"X!:X" not"*'.3*N}*&"!."X=N'<'/X*3 ``` [Test it here.](http://cjam.aditsu.net/#code=Imr3%2B%7B%22Loves%20me%22X!%3AX%22%20not%22*'.3*N%7D*%26%22!.%22X%3DN'%3C'%2FX*3) ## Explanation The code just dumps the string in bits and pieces onto the stack, which is printed automatically at the end of the program: ``` Imr3+ e# Generate a random number in [3,20] { e# Execute this block that many times. "Loves me" e# Push "Loves me", we always need that. X!:X e# Toggle X (initially 1) between 0 and 1 and leave it on the stack. " not"* e# Repeat " not" that many times, removing it on every other line. '.3*N e# Push "..." and a newline. }* & e# Set intersection of "..." and newline, turning them into an empty array. "!."X= e# Select "!" or "." based on the last value of X. N'< e# Push a newline and "<". '/X* e# Include "/" or not depending on the last value of X. 3 e# Push a 3. ``` [Answer] # Brainfuck, 2766 bytes (currently invalid) Just because. I'll add an ungolfed version later. ### Code ``` >+<+[>[>[-]+<-]>[<+>>+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<<[>[-]+<-]>[<+>>+++++++++++[>+++++++>++++++++++>+++++++++>+++>++++<<<<<-]>-.>+.+++++++.>++.<---.>>-.<<------.>.>.<<+.+.+++++.>>>++...[-]<[-]<[-]<[-]<[-]<++++++++++.[-]>>>>>>>[-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>->[-]<[>+<-][-]>[<+<<<<<<<+>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]>>>>>>>>>[-]<<[<<<<<<+>>>>>>-]->>[<<<<<<<<-<+>>>>>>>>>-]<<<<<<<<<[>>>>>>>>>+<<<<<<<<<-]>[>>>>>>+<<<<<<[-]]<->>>>>>>[<<<<<<<->>>>>>>-]<<<<<<<[>>>>>>>+<<<<<<<-]>>>>>>>[>>>>>>>+<<<<<<<<<<<<<<<<->>>>>>>>>[-]]<<<<<<<<-]<[>[-]+<-]>[<+>>++++++[>++++++++++<-]>.-------------.++++.<<<<->>-]<<] ``` ### Pseudocode ``` loop get a random byte until random byte is >2 and <21 point to byte [ output "Loves me..." decrease byte by 1 if byte is 0 output "<3" exit eif output "Loves me not..." decrease byte by 1 ] output "</3" ``` ### Sample When run, the program enters an interactive session waiting for input. Input should be a number. This number is used as a seed. **Seed: 1 (random number is 5, takes 218,168,042 operations)** ``` 1 Loves me... Loves me not... Loves me... Loves me not... Loves me... <3 ``` **Seed: 3 (random number is 20, takes 463,253,048 operations)** ``` 3 Loves me... Loves me not... (...) Loves me... Loves me not... </3 ``` I'd suggest that you do not seed with `6`, as it takes `2,105,900,375` iterations to compute the result :). ### Compiling / Running You need a fast interpreter for this. No online interpreter I've tested could handle the execution speed. The ips (iterations per second) should be more than `100,000,000`. So I came up with another solution. This is a Brainfuck to C compiler written in Brainfuck. You can use any online interpreter to transpile my code to pure C. I suggest using [brainfuck.tk](http://brainfuck.tk). Paste my code in the stdin input, past this code in the code input: ``` +++[>+++++<-]>>+<[>>++++>++>+++++>+++++>+>>+<++[++<]>---]>++++.>>>.+++++.>------.<--.+++++++++.>+.+.<<<<---.[>]<<.<<<.-------.>++++.<+++++.+.>-----.>+.<++++.>>++.>-----.<<<-----.+++++.-------.<--.<<<.>>>.<<+.>------.-..--.+++.-----<++.<--[>+<-]>>>>>--.--.<++++.>>-.<<<.>>>--.>.<<<<-----.>----.++++++++.----<+.+++++++++>>--.+.++<<<<.[>]<.>>,[>>+++[<+++++++>-]<[<[-[-<]]>>[>]<-]<[<+++++>-[<+++>-[<-->-[<+++>-[<++++[>[->>]<[>>]<<-]>[<+++>-[<--->-[<++++>-[<+++[>[-[-[-[->>]]]]<[>>]<<-]>[<+>-[<->-[<++>-[<[-]>-]]]]]]]]]]]]]<[-[-[>+<-]>]<[<<<<.>+++.+.+++.-------.>---.++.<.>-.++<<<<.[>]>>>>>>>>>]<[[<]>++.--[>]>>>>>>>>]<[<<++..-->>>>>>]<[<<..>>>>>]<[<<..-.+>>>>]<[<<++..---.+>>>]<[<<<.>>.>>>>>]<[<<<<-----.+++++>.----.+++.+>---.<<<-.[>]>]<[<<<<.-----.>++++.<++.+++>----.>---.<<<.-[>]]<[<<<<<----.>>.<<.+++++.>>>+.++>.>>]<.>]>,]<<<<<.<+.>++++.<----.>>---.<<<-.>>>+.>.>.[<]>++.[>]<.>[.---->.---,....] ``` Download the source and compile it: ``` gcc.exe -c main.c -o main.o gcc.exe main.o -o loveme.exe ``` You can also run a copy of the C code online here: [via. CodingGround](http://goo.gl/PQ5kBY). ### Optimizations There is still some work to do, but the cell re-use is almost optimal. ### Remarks You can use words or phrases as a seed: ``` Programming Puzzles & Code Golf Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... Loves me not... Loves me... <3 ``` [Answer] # Javascript (ES6), ~~119~~ ~~104~~ ~~99~~ 98 bytes ``` for(i=new Date%18+3,s=i&1?`! <3`:`. </3`;i--;)s=`... Loves me`+(i&1?' not':'')+s alert(s.slice(4)) ``` [Answer] # Python, 147 ``` from random import*;t=randint(3,20) print"\n".join("LLoovveess mmee n o t"[i%2::2].strip()+"..."*(i<t-1)for i in range(t))+"!.\n\n<<3/ 3"[t%2::2] ``` Uses the `from random import*` instead of `import random` and `randint` instead of `randrange` to save a few bytes. There's probably some bytes left to golf out. [Answer] # Javascript (ES6), ~~110~~ 102 bytes ``` a='';for(i=j=new Date%18+3;i--;)a+='Loves me'+(j-i&1?'':' not')+(i?`... `:j&1?`! <3`:`. </3`);alert(a) ``` This was a short but fun little challenge. It may be possible to shorten more. Thanks to Mwr247 for some byte-saving tricks! Alternate version using `repeat()`, 105 bytes: ``` a='';for(i=j=new Date%18+3;i;)a+='Loves me'+' not'.repeat(j-i--&1)+(i?`... `:j&1?`! <3`:`. </3`);alert(a) ``` Darn JS 5+-char built-in names. Oh well. Suggestions welcome! [Answer] # Ruby, 91 bytes ``` (n=3+rand(18)).times{|i|puts"Loves me"+[""," not"][i%2]+(i<n-1?"...":i%2>0?". </3":"! <3")} ``` [Answer] # Common Lisp ~~106~~ 104 bytes ``` (format t"~{Loves me~[ not~]~#[~:*~[.~%</~;!~%<~]3~:;...~]~%~}"(subseq'#1=(1 0 . #1#)0(+ 3(random 18)))) ``` This only works on lisps that don't check for a proper sequence (e.g. cmucl, sbcl, clisp) ccl will check for circularity and error out on default safety level. ecl will loop forever. ## Explanation: `#1=(1 0 . #1#)` generates a circular list containing `1` and `0` and `subseq` is used to make a list of length [3,20] (this is the only non-portable part, as `subseq` is only required by the standard to work on proper (i.e. non-circular) lists). Our format is now operating on a list of `1 0 1 0...` of length [3,20] ### Explanation of `format` directives: `~{` iterates over this list `~[` followed by any number of `~;` and terminated with `~]` will select the Nth item, based on the value of the format argument. This is used here so that the first item in a `~[` will be the "loves me not" case and the second one the "loves me" case. Note that with `~[` a separator of `~:;` selects a default case. `~#[` works like `~[` except the argument is the number of remaining arguments. 0 remaining arguments means we are at the end, the default case is to print `...` `~:*` backs up the argument list one position, which allows us to print the correct trailer. [Answer] # [Perl 5](https://www.perl.org/) + `-M5.10.0`, 76 bytes ``` print"... "x!!$_,"Loves me"," not"x$|--for 0..2+rand 18;say$|?"! <3":". </3" ``` [Try it online!](https://tio.run/##BcHRCoIwFAbg@z3F9rO73GkmQqTQC9QzhOAEoXbGNsTAZ@/0fSnkdy@S8horiEhhN8a@Gjx4C0V/AhroyBW7PZxbOGtPdDnlKc66vQ5l@trjDqPGDjeQGs8dRH6c6sqxiHv21Hryfw "Perl 5 – Try It Online") [Answer] # Julia, 98 bytes ``` r=rand(3:20) for i=1:r println("Loves me"*(i%2>0?" not":"")*(i<r?"...":i%2>0?".\n</3":"!\n<3"))end ``` Ungolfed: ``` # Define a random number 3 ≤ r ≤ 20 r = rand(3:20) for i = 1:r # The loveless lines occur when i is even println("Loves me" * (i % 2 > 0 ? " not" : "") * (i < r ? "..." : i % 2 > 0 ? ".\n</3" : "!\n<3")) end ``` [Answer] # UNIX shell, 193 bytes ``` t=$(seq 2 19|shuf|head -1) l=t p=... while [ $t -ge 0 ];do case $l:$t in t:0)p=!;h=\<3;;f:0)p=.;h=\</3;;esac case $l in t)l=f;n=;; f)l=t;n=\ not;;esac t=$((t-1)) echo Loves me$n$p done echo $h ``` [Answer] # Java, ~~210~~ ~~209~~ ~~203~~ ~~200~~ 177 bytes * ~~flipped `i%2==0` to `i%2<1`~~ * trimmed `{ ... }` braces for `for`-loop, moved `e` declaration to loop * re-ordered conditionals * removed modifiers and unnecessary parentheses, reworked [`Random` usage](https://codegolf.stackexchange.com/a/26026/21697) and increment for `i` Note: newline is added below for formatting on this site, the count above is for a *single* line. ``` class F{public static void main(String[]a){for(int e=3+(int)(Math.random()*18),i=0;++i<=e;) System.out.println("Loves me"+(i%2>0?i<e?"...":"!\n<3":" not."+(i<e?"..":"\n</3")));}} ``` Ungolfed: ``` class F { public static void main(String[] a) { for (int e = 3 + (int) (Math.random() * 18), i = 0; ++i <= e; ) System.out.println("Loves me" + (i % 2 > 0 ? i < e ? "..." : "!\n<3" : " not." + (i < e ? ".." : "\n</3"))); } } ``` [Answer] # C, 123, 121, 109 106 characters (108 bytes) (with a little ♥♥♥cheating♥♥♥) ``` O;main(o){for(o=time(O)%18+3;o-O++;printf("Loves me%s%s\n",O&1?"":" not",o-O?"...":O%2?"!\n♥":".\n</3"));} ``` There's also a [broken heart](http://graphemica.com/%F0%9F%92%94) Unicode point at 1f494, but I had difficulties finding a font which implements it. [Answer] # Python 2, ~~161~~ ~~159~~ ~~156~~ 144 bytes ``` from random import*;a=randrange(3,21) for i in range(a):print'Loves me'+i%2*' not'+('...'if i!=a-1 else'.'if i%2 else'!') print['<3','</3'][i%2] ``` It's 39 bytes just to get the random number. A big thank you to [muddyfish](https://codegolf.stackexchange.com/users/32686/muddyfish), [fryamtheeggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman), and [orlp](https://codegolf.stackexchange.com/users/4162/orlp) for their help. # [PYG](https://gist.github.com/Celeo/b6ba14082ae6677b3c75), 109 bytes ``` a=RR(3,21) for i in R(a):P('Loves me'+i%2*' not'+('...'if i!=a-1 else'.'if i%2 else'!')) P(['<3','</3'][i%2]) ``` [Answer] # PowerShell, ~~121~~ ~~119~~ 111 Bytes ``` $i=2..19|Random;1..$i|%{"Loves me$(if(!($_%2)){" not"})..."};"Loves me$(if(!($i%2)){"!`n<"}else{" not.`n</"})3" ``` Edit--actually shorter to explicitly include `"Loves me"` rather than declaring `$l` Edit2--forgot that I can golf `for()` loops by pipelining...durr... Not too shabby. Uses inline code execution blocks `$(...)` to dynamically adjust the printed string as we're `for()`-looping. Note that because this uses an implicit `Get-` in front of `Random` to save a couple bytes, this may operate extremely slowly on certain PowerShell versions. [Reference](https://codegolf.stackexchange.com/a/778/42963) Expanded below for clarification: ``` # Create a collection of (2,3,4,...18,19) and pipe it as input to Get-Random $i = 2..19 | Get-Random # Create a collection of (1,2,...$i-1,$i) and pipe it to seed a ForEach-Object loop 1..$i | ForEach-Object { if(!($_%2)) { # If the input number is even, we're on an even line Write-Output "Loves me not..." } Else { # The input number is odd Write-Output "Loves me..." } } If(!($i%2)) { # Our random number is odd Write-Output "Loves me!" Write-Output "<3" } Else { # Our random number is even Write-Output "Loves me not." Write-Output "</3" } ``` [Answer] # C++, ~~210~~ ~~193~~ ~~184~~ 168 bytes In C++.. because.. Why not? :) ``` #include <iostream> main(){auto&c=std::cout;srand(time(0));int i,j=3+rand()%18;while(i++<j)c<<"Loves me"<<(i%2?"":" not")<<(i==j?"":"...\n");c<<(j%2?"!\n<3":".\n</3");} ``` Live: ~~[210](https://ideone.com/5n5sbi)~~ ~~[193](https://ideone.com/5XwIuN)~~ ~~[184](https://ideone.com/p8gZdN)~~ [168](https://ideone.com/WjnH0j) Just hope that any of my changes are not platform dependent. Thanks to [Ben Voigt](https://codegolf.stackexchange.com/users/11335/ben-voigt) for the help. Also, thanks to all the comments, they were very helpful. [Answer] # Groovy, 110 bytes A groovy kind of love: ``` int r=Math.random()*18;print((0..r+2).collect{"Loves me"+" not"*(it%2)}.join('...\n')+['!\n<3','.\n</3'][r%2]) ``` [Answer] # Python 2, 117 bytes ``` from random import* n=randint(3,20) print"...\n".join("Loves me"+i%2*" not"for i in range(n))+[".\n</3","!\n<3"][n%2] ``` Observe that every `Loves me( not)?` is followed by `...` and a newline, except for the last one. So this looks like a job for `join`. [Answer] # R, ~~141~~ ~~132~~ ~~128~~ ~~114~~ ~~111~~ 109 bytes ### Code ``` k=sample(3:23,1);for(i in 1:k)cat("Loves",c("me not...\n","me...\n","me not.\n</3","me!\n<3")[1+i%%2+2*!i<k]) ``` ### Ungolfed ``` k <- sample(3:23, 1) # Generates random "k" number from 3 to 23 for(i in 1:k) { # Loop this block increasing i from 1 until k by 1 cat # Concatenate and paste everything inside this block ("Loves", # Push "Loves" on every iterations of the loop c( # Create a vector of strings "me not...\n", # Push string to the index "1" of vector "me...\n", # to the index "2" "me not.\n</3", # to the index "3" "me!\n<3" # to the index "4" )[1+i%%2 # Subset the vector by the index (1 or 2) +2*!i<k])} # if final iteration of loop then index += 2 (3 or 4) ``` I've took some inspiration from [Eric Brooks](https://codegolf.stackexchange.com/users/42322/eric-brooks) code. Edit 1: Now the code correctly outputs the last punctuation as pointed out by [Martin](https://codegolf.stackexchange.com/users/8478) Edit 2: Changed the for loop to a sapply and included the hearts inside the last line string. Edit 3: Removed the `{}` and changed `+(x==k)*2` to `+2*!x<k` Edit 4: Back to for loop and removed the `()` from `(i%%2)+1` Edit 5: Wrote `me` 4 times and removed the `sep=""` [Answer] # R, ~~119~~ ~~111~~ 105 bytes ``` x<-sample(3:20,1);cat(rep(c("Loves me...\n","Loves me not...\n"),x)[1:x]);cat(ifelse(x%%2==1,"<3","</3")) ``` Edits 1,2: Coding the two options explicitly is saving space. [Answer] # C 226 bytes ``` #include<stdio.h> #include<stdlib.h> #include<time.h> void main(){srand(time(NULL));int i=rand()%18+3;int j;for(j=0;j<i;j++)printf("Loves me%s%s\n",(j%2)?" not":"",(j==i-1)?(j%2)?".":"!":"...");printf("<%s3\n",(j%2)?"":"/");} ``` (With formatting) ``` #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int i = rand()%18 + 3; int j; for (j = 0; j < i; j++) printf("Loves me%s%s\n", (j % 2) ? " not" : "", (j==i-1) ? (j % 2) ? "." : "!" : "..."); printf("<%s3\n", (j%2) ? "" : "/"); return 0; } ``` [Answer] # Python 2, 115 bytes ``` from random import* n=randint(2,20) print'...\n'.join('Loves me'+i%2*' not'for i in range(n))+'.!\n\n<</33'[n%2::2] ``` [Answer] # PHP, 191 187 146 165 Bytes ``` $x=rand(5,22);for($i=2;++$i<=$x;){echo"\nLoves me";if($i%2<1)echo" not";if($i<$x)echo"...";if($i==$x&&$i%2<1){echo".\n</3\n";}elseif($i==$x&&$i%2>0){echo"!\n<3\n";}} ``` Ungolfed: ``` $x=rand(5,22); for($i=2;++$i<=$x;){ echo "\nLoves me"; if($i%2<1) echo " not"; if($i<$x) echo "..."; if($i==$x && $i%2<1){ echo ".\n</3\n"; } elseif($i==$x && $i%2>0){ echo "!\n<3\n"; } } ``` 48,49 bytes for pyth and cjam ... wow :) [Answer] # mSL, 178 176 156 154 bytes Edit 1: Changed `== 0` to `< 1` Edit 2: Removed unnecessary whitespace, thanks AlexA! Edit 3: Removed parentheses ``` alias l { var %n 1 while %n <= $rand(3,20) { var %m $+(Love me,$iif($calc(%n % 2) < 1,$chr(32) $+ not),...) echo %m inc %n } echo $iif(n isin %m,</3,<3) } ``` [Answer] ## Perl, 97 bytes ``` $_='She loves me... 'x(3+rand 18);s/(me.*?)me/$1me not/gs;s/e... $/e! <3/;s/t... $/t. <\/3/;print ``` Readable version: ``` $_="She loves me...\n"x(3+rand 18); s/(me.*?)me/$1me not/gs; s/e...$/e!\n<3/; s/t...$/t.\n<\/3/; print ``` [Answer] # [Hassium](https://github.com/HassiumTeam/Hassium), 265 Bytes ``` func main(){rnd=new Random();times=rnd.next(3,21);println("Loves me...");for(x=0;x<times-1;x++){if(x%2==0)println("Loves me not...");else println("Loves me...");}if((times-1)%2==0){println("Loves me not.");println("</3");}else{println("Loves me!");println("<3");}} ``` The answer has been golfed. [Answer] ## C# (160) The code is inspired by [**the answer**](https://codegolf.stackexchange.com/a/58062/15235) from [**h.j.k.**](https://codegolf.stackexchange.com/users/21697/h-j-k), credit goes to him. ``` class P{static void Main(){for(int e=3+new Random().Next(0,18),i=0;++i<=e;)Console.WriteLine("Loves me"+(i%2>0?i<e?"...":"!\n<3":" not."+(i<e?"..":"\n</3")));}} ``` Ungolfed: ``` class P { private static void Main() { for (int e = 3 + new Random().Next(0, 18), i = 0; ++i <= e;) Console.WriteLine("Loves me" + (i % 2 > 0 ? i < e ? "..." : "!\n<3" : " not." + (i < e ? ".." : "\n</3"))); } } ``` [Answer] ## Lua, ~~137~~ 132 bytes Probably can be golfed a lot more, but here it is for now: ``` t=math.random(3,20)for i=1,t do io.write(i%2==0 and"Loves me"or"Loves me not")print(i==t and(i%2==0 and"!\n<3"or".\n</3")or"...")end ``` Code explanation and ungolfed: ``` t=math.random(3,20) --Generates a random number between 1 and 30. We need to assign it to a variable to check if the loop is over later. for i=1,t do io.write(i%2==0 and"Loves me"or"Loves me not") --If i%2 is 0 write without a newline Loves me, if not print Loves me not. print(i==t and (i%2==0 and"!\n<3" or ".\n</3") or "...") --If it is not the end of the loop, put ..., else if we ended on an even print ! a newline, and then a heart, but if we ended on an odd put ., a newline and a broken heart :( end ``` Edit: Chopped off some whitespace. [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~85~~ 88 bytes *+3 bytes thanks Veskah: That's a good point.* ``` 0..(1..19|Random)|%{($l='Loves me')+' not'*($n=$_%2)+'...'} $l+('! <3',' not. </3')[!$n] ``` [Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/30BPT8NQT8/QsiYoMS8lP1ezRrVaQyXHVt0nvyy1WCE3VV1TW10hL79EXUtDJc9WJV7VCCigp6enXsulkqOtoa7IZWOsrgNWosdlo2@srhmtqJIX@/8/AA "PowerShell – Try It Online") [Answer] # [Hassium](https://github.com/HassiumTeam/Hassium), ~~161~~ 165 bytes I golfed [Reagan's answer](https://codegolf.stackexchange.com/a/58083/25314). ``` func main()println(range(-1,t=new Random().next(3,21)).select(x=>"Loves me"+(x%2==0?" not":"")+(x==t-2?(x%2==0?".":"!"):"...")).join("\n"),"\n",t%2==0?"</3":"<3"); ``` Unleashing the power of Hassium. ### Ungolfed version ``` func main() { t = new Random().next(3,21); # initialize the love number loveNumber = range(-1, t); # creates an array like this Array { -1 0 1 2 ... ... up to n } where n is a random number between 3 and 21 } loves = loveNumber.select(x => # iterates through the array { ret = "Loves me"; if (x % 2 == 0) # check if x is even { ret += " not"; # add ' not' to the result } ret += (x == t ? (x % 2 == 0 ? "." : "!") : "..."); return ret; }).join("\n"); # join the result with Unix newlines (\n) println(loves); # print it println(t%2==0?"</3":"<3"); } ``` ]
[Question] [ Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one. I'm looking for tips on: 1. The design process 2. Implementation 3. Community engagement One tip per answer would be appreciated, and tips like "don't create a new language, use an existing one" *probably* aren't very helpful. You don't need to have created a golfing language to answer this question. Feel free to answer from personal experiences or from general observations. See also [Tips for launching a language](https://codegolf.meta.stackexchange.com/questions/14927/tips-for-launching-a-language) for when you are done creating your language. [Answer] Here are some suggestions. Sorry that this partially overlaps with other answers, which have been posted as I was writing this. ## Design process 1. One possibility (by all means not the only one) to decide which features (functions, data types, etc.) your language *L* should have is to **base it on another language** *B* that you have been using for long. That way you already have a good idea which functions of *B* are used most often, and therefore should be included in your language *L*, and you can assign shorter names in *L* to functions that are commonly used in *B*. Examples: * *L* = MATL: *B* = MATLAB/Octave. * *L* = Pyth: *B* = Python. * *L* = Japt: *B* = JavaScript. * *L* = Brachylog: *B* = Prolog. * *L* = Husk: *B* = Haskell. * *L* = ShortC: *B* = C. * *L* = V: *B* = Vim. 2. Decide which "**paradigm**" your language will use. Some examples are * Stack-based (Cjam, MATL, 05AB1E); * Tacit (Jelly); * Prefix notation (Pyth); * Infix notation (Pip, Japt); * Fixed arity (Pyth); * Variable arity (CJam, MATL, Japt). These decisions are quite independent from item 1. For example, MATL's function `f` has the same functionality as MATLAB's `find`, but is used differently in that it pops its inputs from the stack and pushes its outputs onto it, whereas MATLAB uses normal function arguments which can be stored in variables. 3. Incorporate functions **from other golfing languages** that you find useful. Don't let item 1 (if applicable) limit language *L*'s definition. 4. Be prepared to **add functions in the future**. As you (or others) use the language, you will find things it would be nice to add. So reserve some of the "namespace" for future expansion. For example, don't use up all your single-character names at once. ## Implementation 5. Write the compiler (or interpreter) for your language *L* in a language *C* **that you know well** (often *C* = *B*). 6. The compiler is most often actually a **transpiler** into another language *T* (which can be the same as *B* or *C*). Language *T* should have a **free implementation**. That way it is viable to have an **online** compiler for your language. The compiler will be a program in *C* that takes source code in *L* to produce transpiled code in *T*, and then calls *T*'s compiler/interpreter to run the transpiled code. A natural choice is *C* = *T*. Examples: * *L* = Japt: *B* = *C* = *T* = JavaScript. * *L* = Jelly: *C* = *T* = Python (and Jelly is inspired by J; but perhaps not so much as to claim that *B* = J). * *L* = MATL: *B* = *C* = *T* = MATLAB/Octave. ## Community engagement 7. Host your compiler/interpreter in a **public repository** such as [GitHub](https://github.com/), so people can easily download it, create bug reports, suggest new features or even contribute with code. 8. Write **good documentation**. That helps users understand your language better. Besides, I found that task more rewarding than I expected. I recommend writing the specification while you are designing the language, not at the end. That way consistency between language behaviour and its specification is ensured. 9. Ideally the documentation should include some **quick reference** (table or summary), so experienced users don't have to go to the full documentation simply because they have forgotten the name or the syntax of a function they know. 10. Create an **[esolangs](https://esolangs.org/wiki/Main_Page) page** with basic information about your language. 11. Create a **chat room** where people can ask and discuss about the language. Visit it often. 12. **Answer questions** in your language, with **explanations** about how the code works. You'll want to do that anyway (it's your language, you will find it fun to use), but this also helps get people curious about your language, and shows some of the language's properties, which might get people interested. 13. If you chose to base your language *L* on a language *B* (see item 1) that is **general-purpose and well known**, users of *B* will find it easy to switch to *L*, which will allow them to provide short answers (in *L*) with minimal effort (coming from *B*). [Answer] Here's a couple of random hints. # Choose your built-in commands and values carefully Especially when your language is new, it's tempting to add lots of functionality that you think may be useful at some point. If that turns out to be false, you'll have a mostly useless command taking up a valuable spot in your language's namespace. Rebinding the symbol breaks backward compatibility and may invalidate existing answers on this site. That's not the end of the world since we're talking about weird recreational languages, but if it happens frequently, your users will have a hard time keeping up with the changes. As a hypothetical example, testing whether a given number is prime is probably a good choice for a one-symbol function, since primes come up a lot in golf challenges. Testing whether it's a square or a power of 2 can be useful, but not as often. Testing whether it's a perfect number most likely doesn't warrant a one-symbol command. You'll get a sense of what generally useful things the language is missing by using it. # Minimize the number of incorrect programs By an incorrect program I mean one that produces any kind of error: syntax error, type mismatch, division by zero etc. Every error is an opportunity for your language to do something useful instead. Syntax error due to a missing parenthesis? Allow it to be implicit in some way (like at the beginning or end of line). Division by zero throws an error? Consider having it return infinity or NaN instead, or allow errors to be caught and used for flow control. A type mismatch is usually a sign of a function that's not generic enough. Ideally, every function should accept every type of input and do something useful with it, unless there's a good reason not to. There are several common tactics for this: * Overloading. For example, `+` can be addition on numbers and concatenation on lists. This seems to be the most popular option. * Vectorization. If `+` is given lists, it can perform addition element-wise. Jelly uses vectorization extensively. * Coercion. If `+` is given non-numbers, it can convert them into numbers implicitly. For example, 05ab1e allows numbers and strings to be used mostly interchangeably. * Keep the error if you have a good use for it. In Brachylog, arithmetic operations only work on numeric types. Since it's a logic programming language based on Prolog, they can be used backwards or to generate input-output pairs, and in those cases it's essential that the input can't suddenly be a list or string. [Answer] I never created a language myself, but I can partially answer number 3 (I will make this a community wiki, so feel free to add more). Some tips after the core part of your language is done: * Have a [GitHub](https://github.com/)/[GitLab](https://about.gitlab.com/) project where you can link to, including a wiki-page/README of your language in general (what it's made for, how to compile and run it locally, etc.), and a short description of each of its builtins. * Ask *@Dennis* in [talk.tryitonline.net chat](https://chat.stackexchange.com/rooms/44255/talk-tryitonline-net) to add your language to [the online compiler TIO](https://tio.run/#). * Add your language to the [Showcase of Languages](https://codegolf.stackexchange.com/questions/44680/showcase-of-languages) to expose it to the community. * Possibly create [a chat room](https://chat.stackexchange.com/) so people have a place to report bugs, discuss improvements, or talk about golfing strategies in your language. * Create a [tips](/questions/tagged/tips "show questions tagged 'tips'") page for your language, and perhaps post a few tips as answers to get it started. * Start answering challenges here on CGCC in your language, so people seeing it for the first time might become interested. Answering well-known challenges like [Hello World](https://codegolf.stackexchange.com/questions/55422/hello-world), ["Never Gonna Give You Up"](https://codegolf.stackexchange.com/questions/6043/were-no-strangers-to-code-golf-you-know-the-rules-and-so-do-i); [Default Quine](https://codegolf.stackexchange.com/questions/69/golf-you-a-quine-for-great-good); [Prime checker](https://codegolf.stackexchange.com/questions/57617/is-this-number-a-prime); [Fizz-Buzz sequence](https://codegolf.stackexchange.com/questions/58615/1-2-fizz-4-buzz); [Odd or Even](https://codegolf.stackexchange.com/questions/113448/is-this-even-or-odd); etc. are all great challenge to introduce your new language, and let people who see it get a general feel for what's possible in your language. Apart from those and some other popular challenges, just answering any new challenge is also a great way to expose your language, since people tend to look at new challenges more often than existing ones. [Answer] It strikes me that the most important design decision is what the underlying paradigm of the golfing language is. Here are some possible types of language: * Stack based * Array based * Object based * Functional * Imperative * Declarative Indeed you might even have a mixture of these, or something else entirely like a two dimensional language, automata, regex, machine language or a Turing machine and so on. This is important because it will greatly affect the syntax of the language and in some ways how concisely code can be written. --- ## Edit: Follow Up I thought that I would show how the design and implementation phases of creating a language actually work in practice. I realise that's it's more than one tip in this answer and it's lengthy I hope that's ok. **Design Considerations** I wanted the following things out of my new language: * Quick to implement (or prototype) * Flexible and concise syntax, perhaps with a view to Golfing * Can do useful things, not just a toy language I plumped for some version of Forth, because it would satisfy the first two critera. It would also have to be interpreted at least for prototyping, compiling is out because it would take too much development time. In terms of it doing useful things, it absolutely had to have the following traits: * Ability to call functions * Arithmetic and logic operations * Manipulation of numbers and strings * Loops and conditional structures * Stack manipulation And because it's Forth I thought the following would be kind of cool: * Multiple data stacks * Ability to 'pass in' function literals to be executed inside functions (kind of functional style) **Implementation Details** Firstly, I would leverage my knowledge and use a language I know well for the interpreter: PHP - at least for the prototyping stage. Next I needed the interpreter to be able to recognise (tokenise) these four things: * String Literals: `'hello world'` * Numeric Literals: `3.1415` * Labels (for function names) `drop` * symbols (representing atomic actions): `#@$^` The simplest solution for tokensing the program is to use regex. Also because I wanted concise syntax labels would be strictly alphabetic. I would also need some sort of separator to remove ambuiguity in tokenising, I left a space and comma free for that. So with all that in mind I could create a fat-free Forth syntax. For example: ``` 1.5,2.7,3,4add add add; ``` would push four numbers on to the stack, and call a function `add` three times and then return `;`. Once tokenised the interpreter can then consume tokens one by one and act accordingly. One consequence of using regex, is that it's unable to handle a nested syntax. So I would need to manage nested loops in some way. The way to do this is to look for the start of loops (token) and find the corresponding end and record somehow in the start token where the end is and vice-versa. That way the interpreter could jump around loops and conditionals very easily. A stack would be needed to know which token closes which opening token. Functions I would just manage as simply labels, or named positions in the token stream. When a function is executed, the position is looked up and interpretation continues from there. I would return from the function using a `;` token. This would also require a function call stack to handle nested function calls - and return back to the calling position in the token stream. For the fancy stuff, such as passing in function literals, the idea would be to push a string literal containing the code fragment on to the data stack e.g: ``` '2+;'apply;apply:`; ``` So to break the above down, `'2+;'` is a string literal containing the code fragment (push 2 and add to top item on data stack). A function called `apply` is then called. The function definition begins `apply:` and a backtick actually pops the string literal and executes it in its own brand new context. Once the fragment has been executed and returns, the function then continues. The interpreter would handle this by separating out the parsing and tokenisation from the actual execution. That way the literal code fragment can be parsed when pulled off the stack, and that new context passed into the Executing function, using PHP's scoping to handle the new context's scope. The only fly in the ointment is that to be able to call a function from the code fragment, it would need to be able to access the parent's context. For example: ``` 'dotproduct;'walkarray;walkarray:...`...;dotproduct:...; ``` Next for multiple data stacks that would be easy. I would have just one main data stack where all the action happens and provide atomic actions that can push and pull to other named data stacks. That should greatly simplify operations with vectors or arrays of numbers. I also wanted conditional loops with the condition either at the beginning or end or just infinite loops. So I chose `[...]` for an if condition, `[...)` and `(...]` for conditional loops and `(...)` for infinite loop. Lastly, some features that are missing: general mathematical functions, extensive string handling, goto and breaking out of loops and conditions. Although it is possible to break out by returning in a function by using `func:(...[;]...)`. Anyway, here's the semi-golfed prototype, and hopefully semi readable, enjoy! [Try it online!](https://tio.run/##jVZtc@I2EP7Or3BAjayzTDCXfkEIuOn0mny4a6bTTzUucXwCfBjb8UsDAfrTS1eyeQ2@CcPYK@nZZ1e7q5Xjabzt9uNprG1vbrQv91/vtYe7B@3z73/8ead9@fTL3f3XX2uw8lvuB4FI5pH2MAXJj9MaTCM3mYS8btE2/UhvaRtnUczwI4NXxzJag4E1sIzh0BqyOgP4JIie3EBDM4qeWa2GZtx2GHqWz5pYCC/PxMiLwkwsMn33ViYIAfg4D73Mj0JtvxQn0YSi2E1EmO0UgYysahr8bBRTFFCUO9y2Har@YEguoTiKOXaTxF2OQMTFbJyIyWjuZt505AaBXm/ow2@GPmzCk/TJ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] ## Remember to add implicit input/output In my opinion, a golfing language (whether successful or not) should always have some kind of implicit input/output. This applies to Jelly, 05AB1E, and pretty much every competitive golfing language. I'll take CJam as an example. CJam doesn't have an all-purpose implicit input; it has input-reading instructions like `l` and `q`, and then if the input isn't just a string, it's followed by a `~`. That's how Pyth gained the upper hand than CJam. If you are trying to make a competitive golfing language, try to avoid making your input type-dependent, otherwise you'll be needing type conversion every time you take input (which is pretty wasteful). ## Types of implicit input For my purpose I could only think of two types of implicit input: Taking the whole input as an argument (e.g. GolfScript & Pyth), and cycling the implicit inputs for the operators of the program (e.g. 05AB1E and Jelly). The former is a basic form of implicit input, but still allows you to win some challenges. For the latter, you need to think carefully about how this system works, otherwise it would not help programmers. ## Implicit output Implicit output is another very important design feature of a golfing language. For example, [Element](https://github.com/PhiNotPi/Element) isn't very well-designed, as you need a backtick (output the whole stack) every time at the end of the program. Currently there are only two types of implicit output: full implicit output (the thing that Jelly & GolfScript/CJam uses) and top implicit output (the one that Pyth and 05AB1E uses). Both of them are perfectly competive, however under my very unscientific testing, top implicit output languages seem to require extra joins at the end. > > I never used Jelly/GolfScript/CJam, but when I compare 05AB1E's implicit top output and MathGolf's implicit full joined output, I personally prefer top output tbh. Many times I have to clean up the stack if I only want to output a single item or single list in MathGolf. [Here an example answer](https://codegolf.stackexchange.com/questions/157897/duck-duck-goose/186337#186337). Although I certainly see your point, and in some cases [it's indeed useful](https://codegolf.stackexchange.com/questions/182305/return-the-closest-prime-number/182362#182362). Maybe I'm just too used to output top after starting with MathGolf, but I personally prefer just implicit top in most cases. – Kevin Cruijssen > > > [Answer] ## Be a polyglot programmer If you know 1 language, you can steal the good stuff from 1 language. If you know 2 languages, you can steal the good stuff from 2 languages. Likewise, if you know many languages, you can steal the good stuff from many languages. Therefore, while you are designing a golfing language, it's beneficial to learn a lot of programming languages (which will help you create a good golfing language). [Answer] # Useful integer constants Of course your golfing language has syntax that can represent any integer constant, but some integers are more useful than others. You want the useful ones to be available as a single byte. A couple of obstacles to this goal: * With a traditional decimal format, only the numbers 0 through 9 can be represented in one byte. Some non-single-digit numbers, particularly 10 and -1, are very useful. * If you have to put multiple integer literals next to each other in your code, you'll probably need an extra byte for a separator (which doesn't carry any meaning and is therefore a Bad Thing™). I think this problem occurs more often in prefix languages (like Pyth and Charcoal), but I imagine stack-based languages would suffer from it too. In Pip, it crops up when defining a list of numbers. There are a few strategies to address these issues. Jelly, for example, represents -1 as `-` and interprets leading `0`s as separate numbers. You could even write your integer literals in duodecimal with a [signed digit system](https://en.wikipedia.org/wiki/Signed-digit_representation), which would make -1 and 10 into single-digit numbers. But the most straightforward approach is to have dedicated one-byte builtins for the most useful integer constants. Even some of the single-digit integers can use such aliases, due to the second point above. ## Some data I did a survey of 150 of my Pip golf submissions to see which integer literals or builtins were used most often. Here are the numbers that appeared at least twice: ``` 0 ||||||||||||||||||||||||||||||||||||||||||||||| 47 1 ||||||||||||||||||||||||||||||||| 33 2 |||||||||||||||||||||||||||| 28 10 |||||||||||||| 14 -1 |||||||||||| 12 3 |||||||||||| 12 8 ||||||| 7 9 ||||||| 7 4 ||||| 5 5 ||||| 5 6 |||| 4 26 |||| 4 100 |||| 4 7 ||| 3 32 ||| 3 64 ||| 3 1000 ||| 3 16 || 2 50 || 2 127 || 2 ``` This list fits pretty closely with what I would expect (though I didn't think 3 would be so common). It's possible the figures will skew a bit differently depending on the language (for example, 2 will be more common if you need it for operations like "convert to base 2," "modulo 2," etc., and less important if you have builtins for those operations); but I think the overall ranking will stay pretty consistent. So: ## Suggestions * These numbers should be representable by some one-byte syntax: -1, 10 * Consider adding one-byte aliases for these numbers if numeric literals are likely to occur next to each other: 0, 1, 2, and maybe 3, 8, 9 * Consider adding shorter aliases for these numbers if you have codepage space to spare: 26, 100, 1000, and maybe 16, 32, 64, 127 Again, there are a few ways of doing aliases. You can simply have a constant that always evaluates to that number. Pip has variables preinitialized to useful values, which can be updated through the program; for example, `i` starts at 0, which makes `++i` useful for counting things. Jelly has atoms that evaluate to the third, fourth, fifth (etc.) command-line arguments, but if that many arguments aren't provided, they evaluate to useful constants instead. ## What about other types? I've only run the numbers on integers, but here are some gut feelings about strings and lists that deserve golfy syntax: * Should have single-byte builtins: empty string, empty list, space, and probably newline * Should have one- or two-byte syntax: uppercase alphabet, lowercase alphabet, common regex patterns if your language has regex, and maybe some common lists like [0], [1], [0, 1], [1, 0], and [-1, 1] [Answer] ## Be patient while implementing your golfing language > > This tip might be too obvious for some people, but I see the necessity for posting this tip, since I am surprised to see many golfing language implementors abandon their golfing language long before the language is complete. > > > If you want to make a good golfing language, you should be patient while you are implementing it. It usually takes 3-4 years in order to make a good golfing language, adding 500 or so built-ins with lots of trial-and-error. During this period, you must be persistent and resilient, and continue implementing the language anyway. Nothing great happens overnight. You always need a bit of patience while you are implementing your golfing language. Trust me, anyone can make a good golfing language - it just takes a lot of patience to do so. Besides, other CGCC users will always be excited in learning your golfing language, so don't be discouraged if you feel your language isn't that good yet! It's going to get better as you implement it, so continue implementing your language nonetheless. :P Besides, it's perfectly fine if the language doesn't turn out to be that good, at least you had a good time implementing the language. Furthermore, after you complete this 3-4 year period, you may still continue maintaining/developing your golfing language, depending on how good you want to make your golfing language. [Answer] This relates to the implementation phase # Decide Upon How the Language Will Be Executed The two most common options to implement your language are a) interpretation and b) transpilation. *Interpretation* is where your language is executed step by step. In other words, you write all the processesing logic behind the language. *Transpilation* is when you turn your language into another language. This is like translating it into another language. Transpilation is much easier to implement than interpretation, but interpretation allows for more flexibility. [Answer] ## Making your language high-level (e.g. starting from Mathematical notation) is probably a good starting point. Have you heard of APL (which is based on Matrices and its operations)? It's an early target for code golfers to golf in, and it's quite concise. Mathematics is a formalized system to express stuff in a high-level way. So if you want your language to be easy to use (attracting code golfers) and concise, you should probably find an existing mathematical notation to start with. Also, it will (probably) help users to be engaged with your language (since it's high-level, easy to learn and easy to use). ## Examples of golfing languages For example, Husk is a langauge which incorporates a lot of Haskell elements, like lazy evaluation and function composition; Haskell is a kind of mathematical notation by itself that has evolved from lambda calculus. Husk is very concise and catches up/beats the concise golfing languages, using *just* a set of 256 instructions. (Jelly is a language based off APL, and it's quite competitive; I guess it's fairly obvious here.) ## Would making the language high-level always attract users? A counter example of being high level attracting more users is probably Prolog. I don't know exactly why people don't use Prolog, but it might be because people are too used to the mainstream languages and refure to switch. And Prolog is quite concise, due to its functional nature. ## The implementation process Being high level usually means that you have to spend a lot more of your time implementing it, since the higher-level a language becomes, the higher the abstraction level goes. And that usually means a lot of code need to be written for the abstraction. If you are lazy and don't feel like writing a lot of code just for making your golfing language, you don't have to. Just implement a lower-level language. ## How do I design the language though? You have a plethora of methods of parsing instructions. But the usual method is to parse it as infix/tacit, since Traditional Mathematical Notation is infix. [Answer] ## Make the syntax of your constants short For strings, you can have implicit quotes or compressed strings. Or even, you can make 2-character compressed strings or directly index into your golfing language's built-in list of common English words. Or built-ins for common strings (including the empty sting) may be feasible. For integer arrays, you can create a packed array form (btw Stax has a form like this). For string arrays, you can introduce a special form (Like in Jelly) that introduces compressed strings next to each other. For numbers, you can do something like 05AB1E's `Ƶ`, which provides a shorthand on a lot of small integers. Or like in @DLosc's tip, you can add built-ins for common numbers. The above are merely suggestions. ## Some Recommendations * Make sure that the syntactical shortening is appropriate for your language. + For example, the implicit trailing quote is somewhat useful in Jelly. However, in 05AB1E, it is only useful when you print a constant string at the end of execution. SOGL is an improvement of this. Since there are implicit *preceding* quotes, you can do a lot more things with one less byte. * Another thing about blocks. Most modern stack-based golfing languages already merge them with the higher-order commands that take a block or two as arguments, so this can also be seen as an example of shortening the syntax of your constants. + By the way, you can merge it before the block (like 05AB1E) or after the block (like Stax) and use implicit braces at the start or the end of the program. Which form do you think will be useful in more tasks? ;p + However, you can also attempt to shorten the block syntax. For example, MathGolf has shortened blocks from 1 all the way to 8. And you can also try to implicitly group your blocks (like in Husk; during the parsing process, functions are implicitly grouped into functions with correct types.) [Answer] ## Use the corpus *Credits go to [@Lynn](https://github.com/DennisMitchell/jellylanguage/issues/69) for creating this method.* Basically, if you have enough answers in your golfing language on SE, you can use a corpus to analyze your language and optimize its golfiness. Use a SEDE query, and analyze it with a script. A couple things to note: * 1-grams reflect the general usefulness of the 1-byte commands in your language. The higher the frequency, the more useful it is. Basically, if a 1-byte builtin is rarely used, or never used here, then it's better to add it as a 2-byte builtin. A maximum frequency of 15 is a good metric for a 2-byte builtin. + If you leave enough room for your 1-byte builtins, then there would be more room to add more useful builtins in the future. * 2-grams are basically golfing opportunities, stuff that you can make into 1 byte. Again, if these occur frequently enough, like more than 15 occurences, for example, it would be nice to add as a 1-gram. * 3-grams and 4-grams reflect the parts where most people are wasting bytes on. So if a pattern occurs frequently enough, it would be great as a 2-byte builtin. ## Tips on using the corpus * Investigate thoroughly. Understand the exact reason why an occurence is so frequent, when you are in doubt. Read the SE answers involving this occurence. * Consider using the 1-grams list as an insight to the 2-gram occurences. * The number 15 used here is just as an example. The actual number should be determined by yourself, since some languages are not used as often as other languages on SE. * The commands added should make sense to you, i.e. it doesn't look like a random combination that you won't use unless in specific circumstances. [Answer] ## Tips for overloading * Try not to use up every overloading space you have right away ([Unless you're really good at overloading](https://github.com/dzaima/SOGLOnline)). You should be prepared for adding new overloads to your language. * Don't overload if vectorization makes sense. Vectoriation is a really common operation. For example, vectorization is the most common 1-byter in both [Jelly](https://github.com/DennisMitchell/jellylanguage/issues/69) and [Vyxal](https://github.com/Vyxal/Vyxal/issues/14#issuecomment-1042668140), and these two are very different languages. This should show how prominent vectorization is in golfing languages. + For example, `+` should definitely be vectorized, because it makes sense to do so. If you overload it, you end up wasting bytes in codegolf due to an unnecessary use of a vectorization prefix. * Sometimes, it can be hard to track down your overloads, especially if you have a lot of them. So, it can be helpful to make a table of all of your overloads, to see which instructions could be overloaded, which operations are duplicated, etc. + Another trick when you're designing the language. You can first list every instruction you want to overload (without actually introducing overloads). Then, try to merge all the commands you have into fewer operations (in a way that makes sense to you). * When you don't know what things to overload in your language, generating a 1-gram corpus of a popular golfing language will lead you to some interesting ideas. [Answer] ## Length of the builtins: 1 byte vs. 2 bytes Here, I will attempt to provide some concrete suggestions for @Zgarb's answer upon deciding whether a builtin should be made as 1 byte or 2 bytes. Maintaining a fairly large 1-byte space is very important. If you run out of 1-byte opcode spaces, you might find it difficult to add new golfy syntax forms, and 1-byte builtins for frequent 2-byters to your language. Here are my obsevations on this topic: * If it is a fundemental built-in that is commonly associated with a basic datatype in your language, a 1-byte builtin would be helpful. + For example, a built-in that maps an input list by a block should definitely be a 1-byte builtin. + Similarly, common mathematical operations, like modulus and addition, should be 1-byte as well. + Same thing with list concatenation. * If you find yourself unable to solve some challenges without this builtin, or you think it is cumbersome without it, consider adding it as a 2-byte builtin. Or a 1 byte builtin if you use it frequently enough. * If this is something you would not normally do given the datatypes to your builtin, it should defintely make it a 2-byte builtin. You can always make it a 1-byte builtin, if it is used frequently enough. + For example, converting the input from a unix timestamp to a formatted string probably deserves a 2-byte builtin. ## Ideas * If some substring comes up often in a lot of answers, consider first making it a 2-byte builtin. + If it is already 2 bytes, make it 1 byte. The divmod builtin in Jelly is a good example. It combines a pretty common occurence of taking the quotient and the remainder into a single builtin. * If your language uses an ASCII codepage, then you need to be even more careful on builtins. Consider heavy overloading on one-byte builtins, to pack the largest number of fundemental bultins. * A fairly effective method, as mentioned by @mousetail below, is analyzing the frequencies of the builtins of an existing golfing language, and then decide upon the length of the builtin based on its frequency. This would ensure that your built-ins are optimally packed based on the frequencies. [Answer] ## Code it using another programming language you already know very well You can then create a script in that language to run the programme made using the golfing language you invented. ]
[Question] [ There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors. For instance pseudofactorial(7) = 3 \* 4 \* 5 \* 7, which is the same as 7! except that 2 and 6 have been removed because they are contained in other terms. Write a program to calculate pseudofactorial(N) and as always, shortest code wins. Here is a short list for your use. More test cases can be found in the OEIS under [A003418](//oeis.org/A003418). Factorial: 1. 1 2. 2 3. 6 4. 24 5. 120 6. 720 7. 5040 Pseudofactorial: 1. 1 2. 2 3. 6 4. 12 5. 60 6. 60 7. 420 [Answer] # [Dyalog APL](http://goo.gl/9KrKoM), 3 bytes ``` ‚àß/‚ç≥ ``` APL beats [Jelly](https://codegolf.stackexchange.com/a/82496/43319)‚ÄΩ `‚ç≥` 1 though argument `‚àß/` LCM across [Answer] # [Jelly](http://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` R√¶l/ ``` [Try it online!](http://jelly.tryitonline.net/#code=UsOmbC8&input=&args=Nw) or [verify all test cases](http://jelly.tryitonline.net/#code=UsOmbC8Kw4figqw&input=&args=WzEsIDIsIDMsIDQsIDUsIDYsIDdd). ### How it works ``` R√¶l/ Main link. Input: n R Range; yield [1, ..., n]. / Reduce the range... √¶l by LCM. ``` [Answer] ## Haskell, 20 bytes ``` f x=foldr1 lcm[1..x] ``` Usage example: `map f [1..7]` -> `[1,2,6,12,60,60,420]`. The `lcm` trick in Haskell. [Answer] ## Python, 46 bytes ``` g=lambda n,c=0:n<1or(c%n<1)*c or g(n,c+g(n-1)) ``` Looking for the multiple `c` of `g(n-1)` directly. I had though before that this method would wrongly find 0 as a multiple of anything, but the `or` short-circuiting or `(c%n<1)*c` will skip `c==0` as well because 0 is Falsey. --- **50 bytes:** ``` g=lambda n,i=1:n<1or(i*n%g(n-1)<1)*i*n or g(n,i+1) ``` Like [Dennis's solution](https://codegolf.stackexchange.com/a/82501/20260), but as a recursive function. Having computed `g(n-1)`, looks for the smallest multiple `i*n` of `n` that's also a multiple of `g(n-1)`. Really slow. Thanks to Dennis for 4 bytes by looking at multiples of `n` instead of `g(n-1)`. [Answer] # C (x86-64 `gcc -O1`), 52 bytes ``` d(n,k,b,t){for(b=k=1;b;++k)for(t=n,b=0;t;b+=k%t--);} ``` Checks numbers from 1 upwards. For each number, divides it by all numbers from n down to 1, and sums the remainders. Stops when the sum is 0. Usage: ``` main() { printf("%d\n", d(7)); // outputs 420 } ``` It's not obvious how it returns a value (there is no `return` statement). The calling convention for x86 says that the function must return its value in the `eax` register. Conveniently, the division instruction `idiv` expects its input in `eax`, and outputs the result in `eax` (quotient) and `edx` (remainder). The last iteration divides `k` by `1`, so `eax` will contain the right value when the function exits. This only works with gcc and `-O1` optimization option (otherwise, it outputs different results ‚Äî usually `0` or random-looking numbers, but sometimes `421`, while the correct answer is `420`). [Try it with Compiler Explorer](https://godbolt.org/#g:!((g:!((g:!((g:!((h:codeEditor,i:(filename:%271%27,fontScale:14,fontUsePx:%270%27,j:1,lang:___c,selection:(endColumn:2,endLineNumber:5,positionColumn:2,positionLineNumber:5,selectionStartColumn:2,selectionStartLineNumber:5,startColumn:2,startLineNumber:5),source:%27d(n,k,b,t)%7Bfor(b%3Dk%3D1%3Bb%3B%2B%2Bk)for(t%3Dn,b%3D0%3Bt%3Bb%2B%3Dk%25t--)%3B%7D%0Aint+main()%0A%7B%0A++++printf(%22%25d%22,+d(7))%3B%0A%7D%27),l:%275%27,n:%270%27,o:%27C+source+%231%27,t:%270%27)),k:48.11846689895471,l:%274%27,n:%270%27,o:%27%27,s:0,t:%270%27),(g:!((h:compiler,i:(compiler:cg85,deviceViewOpen:%271%27,filters:(b:%270%27,binary:%271%27,binaryObject:%271%27,commentOnly:%270%27,demangle:%270%27,directives:%270%27,execute:%270%27,intel:%270%27,libraryCode:%270%27,trim:%271%27),flagsViewOpen:%271%27,fontScale:14,fontUsePx:%270%27,j:2,lang:___c,libs:!(),options:%27-O1%27,selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:%275%27,n:%270%27,o:%27+x86-64+gcc+8.5+(Editor+%231)%27,t:%270%27)),header:(),k:51.88153310104531,l:%274%27,n:%270%27,o:%27%27,s:0,t:%270%27)),l:%272%27,m:50,n:%270%27,o:%27%27,t:%270%27),(g:!((h:output,i:(compilerName:%276502-c%2B%2B+11.1.0%27,editorid:1,fontScale:14,fontUsePx:%270%27,j:2,wrap:%271%27),l:%275%27,n:%270%27,o:%27Output+of+x86-64+gcc+8.5+(Compiler+%232)%27,t:%270%27)),header:(),l:%274%27,m:50,n:%270%27,o:%27%27,s:0,t:%270%27)),l:%273%27,n:%270%27,o:%27%27,t:%270%27)),version:4) [Answer] # Python + SymPy, 45 bytes ``` import sympy lambda n:sympy.lcm(range(1,n+1)) ``` Fairly self-explanatory. --- # Python 2, ~~57~~ 54 bytes ``` i=r=input();exec't=r\nwhile r%i:r+=t\ni-=1;'*r;print r ``` Test it on [Ideone](http://ideone.com/qmwpbR). ### How it works The input is stored in variables **i** and **r**. `exec` executes the following code **r** times. ``` t=r while r%i:r+=t i-=1 ``` While **i** varies from **r** to **1**, we add the initial value of **r** (stored in **t**) as many times as necessary to **r** itself to create a multiple of **i**. The result is, obviously, a multiple of **t**. The final value of **r** is thus a multiple of all integers in the range **[1, ..., n]**, where **n** is the input. [Answer] # J, 9 bytes ``` [:*./1+i. ``` Straight-forward approach. Creates the range of numbers `[0, ..., n-1]`, then adds one to each, and reduce it using the LCM. ## Usage ``` f =: [:*./1+i. f 7 420 ``` [Answer] # [MATL](https://github.com/lmendo/MATL), 4 bytes ``` :&Zm ``` [**Try it online!**](http://matl.tryitonline.net/#code=OiZabQ&input=Nw) ### Explanation ``` : % Take input N implicitly. Generate range [1 2 ... N] &Zm % LCM of the numbers in that array. Display implicitly ``` [Answer] # Mathematica, 13 bytes ``` LCM@@Range@#& ``` [Answer] # Julia, 11 bytes ``` !n=lcm(1:n) ``` [Try it online!](http://julia.tryitonline.net/#code=IW49bGNtKDE6bikKCmZvciBuIGluIDE6NwogICAgcHJpbnRsbighbikKZW5k&input=) [Answer] # Pyth - 8 bytes Checks all numbers till it finds one that is divisible by `[1..N]`. ``` f!s%LTSQ ``` [Test Suite](http://pyth.herokuapp.com/?code=f%21s%25LTSQ&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A7&debug=0). [Answer] # Octave, 27 bytes ``` @(x)lcm(1,num2cell(1:x){:}) ``` Creates an anonymous function that can be invoked as `ans(N)`. [**Online Demo**](http://ideone.com/tlS3Jn) **Explanation** This solution creates a list of all numbers between `1` and `x` (`1:x`), converts them to a cell array with `num2cell`. Then the `{:}` indexing creates a comma-separated-list which is passed to `lcm` as multiple input arguments to compute the least common multiple. A 1 is always passed as the first argument to `lcm` because `lcm` always needs at least two input arguments. [Answer] # MATLAB, 49 bytes ``` @(x)find(~any(bsxfun(@rem,1:prod(1:x),(1:x)')),1) ``` [Answer] # [Perl 6](http://perl6.org), 13 bytes ``` {[lcm] 1..$_} ``` Anonymous code block that creates a Range from 1 to the input (inclusive), and then reduces that with `&infix:<lcm>`. ### Example: ``` #! /usr/bin/env perl6 use v6.c; my &postfix:<p!> = {[lcm] 1..$_} say 1p!; # 1 say 2p!; # 2 say 3p!; # 6 say 4p!; # 12 say 5p!; # 60 say 6p!; # 60 say 7p!; # 420 say 10000p!; # 5793339670287642968692270879... # the result from this is 4349 digits long ``` [Answer] # [Arturo](https://arturo-lang.io), 13 bytes ``` $=>[[[email protected]](/cdn-cgi/l/email-protection)&] ``` [Try it](http://arturo-lang.io/playground?vPpQ2R) [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 5 bytes ``` fa~‚ü¶‚ÇÅ ``` [Try it online!](https://tio.run/##AT4Awf9icmFjaHlsb2cy/3t3IiAtPiAidz9@4oaw4oKC4bqJfeG1kP9mYX7in6bigoH//1sxLDIsMyw0LDUsNiw3XQ "Brachylog ‚Äì Try It Online") Reversed I/O. ``` a An affix of f the list of the output's factors ~‚ü¶‚ÇÅ is [1 .. n]. ``` Essentially a specialization of [my basic LCM solution `f‚äáp~d`](https://codegolf.stackexchange.com/a/185353/85334): ranges are duplicate-free, so they don't need to be deduplicated; ranges are ascending, so they don't need to be permuted; ranges are necessarily contiguous prefixes of the list of factors, so `‚äá` can be replaced by the evidently much more performant `a`. [Answer] # [Nibbles](http://golfscript.com/nibbles/index.html), 5.5 bytes ``` /|,~~+.,@%@ ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m708LzMpKSe1eMGCpaUlaboWq_VrdOrqtPV0HFQdICJQiQULzSEMAA) ``` /|,~~+.,@%@ /|,~ Find the first positive integer k such that + the sum .,@ for i from 1 to n %@ of k mod i ~ is zero ``` [Answer] # Regex `üêá` (ECMAScript+`(?*)x*+`[RME](https://github.com/Davidebyzero/RegexMathEngine) / PCRE2 v10.35+), ~~60~~ ~~59~~ 54 bytes ``` ^((?*(?=(xx+?)\2*$|)((?=x\2)(?=(x+)(\4+$))\5)*+x+)x)*$ ``` Takes its input in unary, as a string of `x` characters whose length represents the number. Returns its output as the number of ways the regex can match. (The rabbit emoji indicates this output method.) [Attempt This Online!](https://ato.pxeger.com/run?1=hVbNbttGED4W0FOsGdfeJalUVBrDEM0Iji3ABhI7UGQ0jaUSNLmUFqGWBLmMZbe-9gF67aWH9pgHSo99jV46-yOJtgSUsKTd2Zlv5-eboX__EhdZXclPOI3jL9dWOyviknbbh9bk6_BZQlPGKXp3Mhx0w5PL00F4dXE-Cn84Px2docPWM8bjrE4oOlJGz2evWvEsKlFYXE9QgIbW69vbTzcv6h_v7j6MZge3M_xXLdL24deDnzDu27gf4MXC6ZNx1979hYAoWIy7RIkdgsffO7uEjF8S24Htgti72vrvb_4lT4EtF9lFEBaO5ze8qkTJ-FS6tZaxHKQ0mr_a0HvVYlygApYipGWZlzjOeSWQCsme06qKppSgnyuR9HoxaKCjI2TEcqnklCeZj0oq6pIjz3_YwJT7OE-oi27yPEN5kEZZJWHVNQbuuvvyYOK3EDwsRVhlN5xSgxEaLaxxsC7P1cnZ8fDQJubQRRW7p3mKV45_t5Q09Akh6hb54Bz1dRBxXgvUQ6tAiQzPUmZIedBD1pPglbFlgZU15hZZ5SMFas10JKuktB5aNa_YlNMEZTmf6q-IV7e09FXC5ndhHGUZuGFiN7vwJsvjT8iOXfQ5Zwmyk0hEkDuZJLlEQYCwPLHJ3hqDGGzHWVWmYyozjxjHAKAcLK6BCBnluCBtbxJ0fB2CZgcq4sDC_Z7lw8oJCv1jAVtP4LNDQF4D4otuKKCoYCvhp7BQ0E0gxotaSHMVGJQQ2SVd7ueRiGehisVerzVaSas6E64ugW-68v35x4GSpGlF4RDihRCmYvZIwc4_01iAlakEdOfy_nnBMooNKd6_Gw1JET-PQ3AWE9dgfBwML8PRYPj2_OJ4NDhdigcfRoOLU7nfUz6ZX-NJh6wZvFMCAU3um92gvo1eI_RgIxsh7CNBw7TM52ERCUFLjktg-cXVmzcGoGkDrSvoQkASl6tg27mBxRsoEMGKgksIt8FLdxvPngLoqzI2Z02Qtkf8hlJCC_G_SiWN67JiOd-qqK5N8xKp6XK_Yi5MjAzmN9aNzLiruUf8JeNVecCEdyA9kcgZVgrL8kP9ueeiIq_gWJ_A-yDB--19c6l8uCdzCzo7QZPnvR6Xwv4WXOQofQd5BAYG76yx9KyV13F6q3fX3HO8iQ_DZg6ZwJWL9hf70jFIUAWHk6Bhv0oCC7jswaOAez5yHNaMeEnKe4LAKXkJ3h9zCAlSB9qKnym2vk3QP7_-huDVwuBIjxBwrHGb7iXZlI_ZpYjZ7ChwmkFDqL81p2Ftykj8Dec07lEH7e2ZO3YC03XD4eUwvLh8ezw6OSOPDBX9Gu21nBiirOmTOyi8dTZs19Mf5reJeMskl89Da_29rbHSklK8jm-zobXCak-aE1EfwsxYDWwdCbw69P8Af_zZaXsHev0f "C++ (GCC) - Attempt This Online") - PCRE2 v10.40+ [Try it on replit.com](https://replit.com/@Davidebyzero/regex-Pseudofactorial) - ECMAScript+`(?*)`+`x*+` (RegexMathEngine `-xml,pq`) The `üêá` output method takes advantage of an aspect of regex that's normally hidden: the backtracking paths that aren't taken. In normal use, all traces of the avenues of potential alternative matches are erased when a final match is found. But in `üêá`, they're all taken and counted, allowing a number to be outputted that's larger than the input. For scalar unary input, this provides a strict superset of the power of returning a number via the matched substring or a capture group (either of which can only return values less than or equal to the input), except that there can be no extra state of returning "no match" (in `üêá`, that just returns \$0\$). The limitation of having to work within the space of the input is still present. `üêá` can do combinations of multiplication and addition to yield numbers larger than the input, but it can't do subsequent tests on those results (it can only do tests on intermediate results calculated using capture groups and tail). So for example in this problem, the regex can't just directly search for the smallest number that is divisible by all numbers in the range \$[1,n]\$, because that number is not only larger than the input, it's too large even to be able to [emulate using number base arithmetic](https://codegolf.stackexchange.com/questions/198427/shift-right-by-half-a-bit/198428#198428) (and even if that were possible, it would not golf well). So, this regex uses an algorithm different from all of the other answers: It takes the base prime \$p\$ of every prime power \$p^k\le n\$, and calculates the product of that list of numbers. And because each \$p\$ will occur \$k\$ times in that list, this product is the same as the product of the prime powers themselves would be, if only the largest from each base prime were included. The prime power portion is based on ~~[my prime powers answer](https://codegolf.stackexchange.com/questions/210162/is-it-almost-prime/219939#219939)~~ [Neil's prime powers answer](https://codegolf.stackexchange.com/a/210191/17216) (which is in turn based on my earliest CGCC answer). In the prime powers challenge, my regex is shorter, but for the purposes of this challenge, his regex (after some extra golfing) allows capturing the smallest prime factor, thus golfing down the overall regex by ~~1~~ 6 bytes. ``` ^ # tail = N = input number ( # Loop the following: (?* # Non-atomic lookahead: # M = tail, which cycles from N down to 1 (?=(xx+?)\2*$|) # \2 = smallest prime factor of M if M ‚â• 2; # otherwise, leave \2 unchanged in PCRE, or # unset in ECMAScript ( (?=x\2) # Keep iterating until tail ‚⧠\2, and because of # what \2 is, this means at the end of the loop, # either tail == \2 (if M is a prime power) or # tail == 1 (if M is not a prime power) (?=(x+)(\4+$)) # \4 = {largest proper divisor of tail} # = tail / {smallest prime factor of tail}; # \5 = tail - \4 \5 # tail = tail - (tail - \4) = \4 )*+ # Iterate the above as many times as possible, # minimum zero, and lock in the result using a # possessive quantifier. x+ # Multiply number of possible matches by tail ) x # tail -= 1 )* # Loop the above a minimum of 0 times $ # Assert that at the end of the above loop, tail == 0 ``` This even returns a correct value for \$n=0\$, while the earlier 60 byte version did not (and needed to be extended to 63 bytes to do so). A list of other answers that return \$f(0)=1\$ correctly, complete at the time of this edit: [AWK](https://codegolf.stackexchange.com/a/105788/17216), [Dyalog APL](https://codegolf.stackexchange.com/a/82563/17216), [J](https://codegolf.stackexchange.com/a/82500/17216), [Japt](https://codegolf.stackexchange.com/a/153735/17216), [Julia v0.7+](https://codegolf.stackexchange.com/a/82497/17216) (but it was v0.6 at the time of posting, and didn't support it then), [MATLAB](https://codegolf.stackexchange.com/a/82511/17216), [MATL](https://codegolf.stackexchange.com/a/82498/17216), [Maxima (with functs)](https://codegolf.stackexchange.com/a/105589/17216), [Minkolang (1st answer)](https://codegolf.stackexchange.com/a/82564/17216), [Nibbles](https://codegolf.stackexchange.com/a/259578/17216), [PHP](https://codegolf.stackexchange.com/a/105698/17216), [Pari/GP](https://codegolf.stackexchange.com/a/123275/17216), [Perl 5](https://codegolf.stackexchange.com/a/105579/17216), [Perl 6](https://codegolf.stackexchange.com/a/82537/17216), [Pyth](https://codegolf.stackexchange.com/a/82499/17216), [Python (with SymPy)](https://codegolf.stackexchange.com/a/82501/17216), [Python (with math)](https://codegolf.stackexchange.com/a/258287/17216), [Python](https://codegolf.stackexchange.com/a/82534/17216), [QBIC](https://codegolf.stackexchange.com/a/105620/17216), [Rexx](https://codegolf.stackexchange.com/a/105606/17216), [Vyxal](https://codegolf.stackexchange.com/a/259569/17216). (Not tested: [8th](https://codegolf.stackexchange.com/a/135027/17216), [Axiom](https://codegolf.stackexchange.com/a/116761/17216), [Hoon](https://codegolf.stackexchange.com/a/82696/17216)) [Answer] # JavaScript (ES6), ~~92~~ ~~88~~ ~~80~~ ~~74~~ 69 bytes: Thanks @ConorOBrien and @Neil ``` y=>(g=(a,b)=>b?g(b,a%b):a,[...Array(y)].map((_,i)=>y=y*++i/g(y,i)),y) ``` [Answer] # [Desmos](https://desmos.com/calculator), 16 bytes ``` f(n)=[1...n].lcm ``` Super straightforward [Try It On Desmos!](https://www.desmos.com/calculator/wodluq0i4y) [Answer] # [Nim](https://nim-lang.org/), 52 bytes ``` import math,sequtils func p[I](n:I):I=lcm toSeq 1..n ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m704LzN3wYKlpSVpuhY3TTJzC_KLShRyE0sydIpTC0tLMnOKudJK85IVCqI9YzXyrDw1rTxtc5JzFUryg1MLFQz19PIgelemJmfkKxRomGtC-DAzAQ) [Answer] ## 05AB1E, 20 bytes ``` Lpvyi¬πL√íN>¬¢√†N>*ÀÜ}}¬ØP ``` **Explanation** ``` Lpv # for each item in isprime(range(1,N)): N=7 -> [0,1,1,0,1,0,1] yi # if prime ¬πL√íN>¬¢ # count occurrences of the prime in the prime-factorization of range(1,N): p=2 -> [0,1,0,2,0,1,0] √†N>*ÀÜ # add max occurrence of that prime multiplied by the prime to global array: N=7 -> [4,3,5,7] }} # end if/loop ¬ØP # get product of global array ``` [Try it online](http://05ab1e.tryitonline.net/#code=THB2eWnCuUzDkk4-wqLDoE4-KsuGfX3Cr1A&input=Nw) [Answer] ## [Minkolang 0.15](https://github.com/elendiastarman/Minkolang), 12 bytes I have *two* 12-byte solutions, and have included them both. ``` 1n[i1+4$M]N. ``` [Try it here!](http://play.starmaninnovations.com/minkolang/?code=1n%5Bi1%2B4%24M%5DN%2E&input=7) ## Explanation ``` 1 Push 1 n Take number from input [ For loop that repeats n times i1+ Push loop counter + 1 4$M Pop b, a and push lcm(a,b) ] Close for loop N. Output as number and stop. ``` About as straightforward as it gets. --- ``` 11nLd[4$M]N. ``` [Try it here!](http://play.starmaninnovations.com/minkolang/?code=11nLd%5B4%24M%5DN%2E&input=7) ## Explanation ``` 11 Push two 1s n Take number from input L Pop b, a and push range from a to b, inclusive d Duplicate top of stack (n) [4$M] Pop b, a and push lcm(a,b), n times N. Output as number and stop. ``` A third solution can be derived from this: remove a `1` and add a `d` after the current `d`. In both cases, the extra number is needed because the for loop runs one too many times, and making it run one less time takes two bytes (`1-` just before the `[`). [Answer] # Ruby, 25 bytes ``` g=->n{(1..n).reduce :lcm} ``` # Ruby, 25 bytes ``` g=->n{n<1?1:a[n-1].lcm n} ``` [Answer] # GameMaker Language, 60 bytes ``` for(b=k=1;b;++k){b=0for(t=argument0;t;b+=k mod t--)}return k ``` Based on the logic of anatolyg's answer. [Answer] # PHP, ~~61~~ ~~52~~ 48 bytes saved 9 bytes thanks to @user59178, 4 bytes by merging the loops. Recursion in PHP is bulky due to the `function` key word; so I use iteration. And with a "small"few tricks, I now even beat [Arnauld¬¥s JS](https://codegolf.stackexchange.com/questions/a/105588#105588). ``` while(++$k%++$i?$i>$argv[1]?0:$i=1:$k--);echo$k; ``` takes input from command line argument. Run with `-r`. **breakdown** ``` while(++$k%++$i? # loop $i up; if it does not divide $k $i>$argv[1]?0 # break if $i (smallest non-divisor of $k) is larger than input :$i=1 # while not, reset $i and continue loop with incremented $k :$k--); # undo increment while $i divides $k echo$k; # print $k ``` **ungolfed** That¬¥s actually two loops in one: ``` while($i<=$argv[1]) # loop while $i (smallest non-divisor of $k) is not larger than input for($k++, # loop $k up from 1 $i=0;$k%++$i<1;); # loop $i up from 1 while it divides $k echo$k; # print $k ``` *Note: copied from [my answer on the duplicate](https://codegolf.stackexchange.com/a/105593#105593)* [Answer] ## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), ~~35~~ 32 bytes [This](https://codegolf.stackexchange.com/questions/105577/find-the-smallest-positive-integer-which-has-all-integers-from-1-to-n-as-factors) brought me here. ``` :{p=0[a|~q%b|p=1]]~p=0|_Xq\q=q+1 ``` Explanation: ``` : Get cmd line param as number 'a' { Start an infinite DO loop p=0 Sets a flag that shows if divisions failed [a| FOR (b=1; b<=a; b++) ~q%b IF 'q' (which starts at 1 in QBIC) is not cleanly divisible by 'b' |p=1 THEN Set the flag ]] Close the FOR loop and the IF, leave the DO open ~p=0 IF 'q' didn't get flagged |_Xq THEN quit, printing 'q' \q=q+1 ELSE raise 'q', redo [DO Loop implicitly closed by QBIC] ``` Here's a version that stops testing `q` when `b` doesn't cleanly divide it. Also, the order of testing `b`'s against `q` is reversed in the assumption that higher `b`'s will be harder to divide by (take `2`, `3`, `4` for instance: if `%2=0`, `%4` could be `!0`. Vice versa not so much...). ``` :{p=0[a,2,-1|~q%b|p=1‚îòb=2]]~p=0|_Xq\q=q+1 ``` [Answer] # [Pari/GP](http://pari.math.u-bordeaux.fr/), 14 bytes ``` n->lcm([1..n]) ``` [Try it online!](https://tio.run/nexus/pari-gp#S1OwVfifp2uXk5yrEW2op5cXq/k/Lb9IIw8obqijYGigo1BQlJlXAhRQUtC1AxJpGnmampr/AQ "Pari/GP ‚Äì TIO Nexus") [Answer] # Japt, 10 bytes No LCM built-in. ``` @√µ e!vX}a1 ``` [Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=QPUgZSF2WH1hMQ==&input=OA==) [Answer] ## Pyke, 3 bytes ``` S.L ``` [Try it here!](http://pyke.catbus.co.uk/?code=S.L&input=7) ``` S - range(1, input+1) .L - lowest_common_multiple(^) ``` ]
[Question] [ As you should (hopefully) know, [a radiation hardened quine](https://en.wikipedia.org/wiki/Quine_(computing)#Radiation-hardened) is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you can only remove one character; otherwise everything breaks down. This is where this comes in; your goal is to build a radiation-hardened quine that can take as many character removals as possible. Any language that complies with the rules is fine. ## Rules * The program must be at least one character long * The language used must be turing complete (So languages like HQ9+ don't qualify) * All other rules that apply to normal quines also apply here. * The solution with the least `program_length^(2/n)` in which *any* set of exactly `n` characters can be removed while still printing the original source code wins. [Answer] # Perl, ~~1116~~ 1124 bytes, n=3, score=1124^(2/3) or approximately 108.1 **Update**: I've now verified that this works with n=3 via brute force (which took a couple of days); with a program this complex, it's hard to check for radiation-resistance by hand (and I made one mistake in a previous version, which is why the byte count increased). **End update** I recommend redirecting stderr somewhere that you won't see it; this program produces a ton of warnings about dubious syntax even when you *aren't* deleting characters from it. It's possible that the program can be shortened. Working on this is fairly painful, making it easy to miss possible micro-optimizations. I was mostly aiming to get the number of deletable characters as high as possible (because that's the really *challenging* part of the program), and treated the [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") tiebreak as something that was nice to aim for but as something I wouldn't put ridiculous effort into optimizing (on the basis that it's very easy to break radiation resistance by accident). ## The program Note: there's a literal Control-`_` character (ASCII 31) immediately before each of the four occurrences of `-+`. I don't think it copy-and-pasted onto StackOverflow correctly, so you'll have to re-add it before running the program. ``` eval+<eval+<eval+<eval+(q(FoPqOlengthFoBBPP181XXVVVVJJJKKKNdoWchopJFtPDevalMODx4KNFrPIPA-MN-TUV-ZPINFsPIFoPqOI.Fo.IQNevalFoINevalIFsPZyI.Fr.IT-UPINsayDFtJqJFsKPZyPT-UFWrYrKD.DEEEEQDx6NsayDNDforB1..4YforB1..4NexitQNevalFo)=~y=A-Z=-+;-AZz-~=r)####>####>####>####>####>####> ; ; ; ; eval+<eval+<eval+<eval+(q(FoPqOlengthFoBBPP181XXVVVVJJJKKKNdoWchopJFtPDevalMODx4KNFrPIPA-MN-TUV-ZPINFsPIFoPqOI.Fo.IQNevalFoINevalIFsPZyI.Fr.IT-UPINsayDFtJqJFsKPZyPT-UFWrYrKD.DEEEEQDx6NsayDNDforB1..4YforB1..4NexitQNevalFo)=~y=A-Z=-+;-AZz-~=r)####>####>####>####>####>####> ; ; ; ; eval+<eval+<eval+<eval+(q(FoPqOlengthFoBBPP181XXVVVVJJJKKKNdoWchopJFtPDevalMODx4KNFrPIPA-MN-TUV-ZPINFsPIFoPqOI.Fo.IQNevalFoINevalIFsPZyI.Fr.IT-UPINsayDFtJqJFsKPZyPT-UFWrYrKD.DEEEEQDx6NsayDNDforB1..4YforB1..4NexitQNevalFo)=~y=A-Z=-+;-AZz-~=r)####>####>####>####>####>####> ; ; ; ; eval+<eval+<eval+<eval+(q(FoPqOlengthFoBBPP181XXVVVVJJJKKKNdoWchopJFtPDevalMODx4KNFrPIPA-MN-TUV-ZPINFsPIFoPqOI.Fo.IQNevalFoINevalIFsPZyI.Fr.IT-UPINsayDFtJqJFsKPZyPT-UFWrYrKD.DEEEEQDx6NsayDNDforB1..4YforB1..4NexitQNevalFo)=~y=A-Z=-+;-AZz-~=r)####>####>####>####>####>####> ; ; ; ; ``` ## The explanation This program is, quite clearly, made out of four identical smaller programs concatenated together. The basic idea is that each copy of the program will verify whether it's been damaged too badly to run or not; if it has been, it will do nothing (other than possibly spew warnings) and let the next copy run; if it hasn't been (i.e. no deletions, or the character that got deleted was one that makes no difference to the program's operation), it will do its quiny thing (printing out the full program's source code; this is a proper quine, with each part containing an encoding of the entire source code) and then exit (preventing any other undamaged copies from printing the source code out *again* and thus ruining the quine by printing too much text). Each part is in turn made of two parts which are effectively functionally independent; an outside wrapper and some internal code. As such, we can consider them separately. ### Outside wrapper The outside wrapper is, basically, `eval<+eval<+eval< ... >####>####...>###` (plus a bunch of semicolons and newlines whose purpose should be pretty obvious; it's to ensure that the parts of the program will remain separated regardless of if some of the semicolons, or the newlines before them, get deleted). This might look fairly simple, but it's subtle in a number of ways, and the reason I picked Perl for this challenge. First, let's look at how the wrapper functions in an undamaged copy of the program. `eval` parses as a built-in function, which takes one argument. Because an argument is expected, `+` here is a unary `+` (which will be very familiar to Perl golfers by now; they come in useful surprisingly often). We're still expecting an argument (we just saw a unary operator), so the `<` that comes next is interpreted as the start of the `<>` operator (which takes no prefix or postfix arguments, and thus can be used in operand position). `<>` is a fairly weird operator. Its usual purpose is to read filehandles, and you place the filehandle name *inside* the angle brackets. Alternatively, if the expression isn't valid as a filehandle name, it does globbing (basically, the same process that UNIX shells use to translate text entered by the user to a sequence of command-line arguments; much older versions of Perl actually used the shell for this, but nowadays Perl handles the globbing internally). The intended use, therefore, is along the lines of `<*.c>`, which would typically return a list like `("foo.c", "bar.c")`. In a scalar context (such as the argument to `eval`), it just returns the first entry it finds the first time it's run (the equivalent of the first argument), and would return other entries on hypothetical future runs that never happen. Now, shells often handle command-line arguments; if you give something like `-r` with no arguments, it'll just be passed to the program verbatim, regardless of whether there's a file with that name or not. Perl acts the same way, so as long as we ensure that there are no characters that are special to the shell or to Perl between the `<` and the matching `>`, we can effectively use this like a really awkward form of string literal. Even better, Perl's parser for quote-like operators has a compulsive tendency to match brackets even in contexts like this one where it makes no sense, so we can nest `<>` safely (which is the discovery needed for this program to be possible). The major downside of all these nested `<>` is that escaping the contents of the `<>` is almost impossible; there seem to be two layers of unescaping with each `<>`, so to escape something on the inside of all three, it needs to be preceded with 63 backslashes. I decided that even though code size is only a secondary consideration in this problem, it almost certainly wasn't worth paying this sort of penalty to my score, so I just decided to write the rest of the program without using the offending characters. So what happens if parts of the wrapper get deleted? * Deletions in the word `eval` cause it to turn into a *bareword*, a string with no meaning. Perl doesn't like these, but it treats them as though they were surrounded with quotes; thus `eal<+eval<+...` is interpreted as `"eal" < +eval<+...`. This has no effect on the program's operation, because it's basically just taking the result from the heavily nested evals (which we don't use anyway), casting it to an integer, and doing some pointless comparisons on it. (This sort of thing causes a lot of warning spam as it's clearly not a useful thing to do under normal circumstances; we're just using it to absorb deletions.) This changes the number of closing angle brackets we need (because the opening bracket is now being interpreted as a comparison operator instead), but the chain of comments at the end ensures the string will end safely no matter how many times it's nested. (There are more `#` signs than strictly needed here; I wrote it like I did in order to make the program more compressible, letting me use less data to store the quine.) * If a `<` gets deleted, the code now parses as `eval(eval<...>)`. The secondary, outside `eval` has no effect, because the programs we're evaluating don't return anything that has any real effects as a program (if they return normally at all, it's normally a null string or a bareword; more commonly they return via exception, which causes `eval` to return a null string, or use `exit` to avoid returning at all). * If a `+` gets deleted, this has no immediate effect if the adjacent code is intact; unary `+` has no effect on the program. (The reason the original `+`s are there is to help repair damage; they increase the number of situations in which `<` is interpreted as a unary `<>` rather than as a relational operator, meaning you need more deletions to produce an invalid program.) The wrapper *can* be damaged with enough deletions, but you need to do a series of deletions in order to produce something that doesn't parse. With four deletions, you can do this: ``` eal<evl<eval+<... ``` and in Perl, the relational operator `<` is nonassociative, and thus you get a syntax error (the same one you'd get with `1<2<3`). As such, the cap for the program as written is n=3. Adding more unary `+`s seems like a promising way to increase it, but as that'd make it increasingly likely that the inside of the wrapper could break too, verifying that the new version of the program works could be very difficult. The reason the wrapper is so valuable is that `eval` in Perl catches exceptions, such as (for example) the exception that you get when you try to compile a syntax error. Because this `eval` is of a string literal, the compile of the string happens at runtime, and if the literal fails to compile, the resulting exception gets caught. This causes `eval` to return a null string and set the error indicator `$@`, but we never check either (except by occasionally executing the returned null string in a few mutated versions of the program). Crucially, this means that if something should happen to the code *inside* the wrapper, causing a syntax error, then the wrapper will just cause the code to do nothing instead (and the program will keep executing in an attempt to find an undamaged copy of itself). Therefore, the inside code doesn't have to be nearly as radiation-proof as the wrapper; all that we care about is that if damaged, it'll either act identically to the nondamaged version of the program, or else it'll crash (allowing `eval` to catch the exception and continue) or exit normally without printing anything. ### Inside the wrapper The code inside the wrapper, fundamentally, looks like this (again, there's a Control-`_` that Stack Exchange won't show immediately before the `-+`): ``` eval+(q(...)=~y=A-Z=-+;-AZz-~=r) ``` This code is written entirely with glob-safe characters, and its purpose is to add a new alphabet of punctuation marks that make it possible to write a real program, via transliterating and evaluating a string literal (we can't use `'` or `"` as our quote marks, but `q(`…`)` is also a valid way to form a string in Perl). (The reason for the unprintable character is that we need to transliterate something into the space character without a literal space character in the program; thus we form a range starting at ASCII 31, and catch the space as the second element of the range.) Obviously, if we're producing some characters via transliteration, we have to sacrifice characters to transliterate them *from*, but uppercase letters aren't very useful and it's much easier to write without access to those than without access to punctuation marks. Here's the alphabet of punctuation marks that become available as a result of the glob (the upper line shows the encoding, the lower line the character it encodes): ``` BCDEFGHIJKLMNOPQRSTUVWXYZ !"#$%&'()*+;<=>?@AZz{|}~ ``` Most notably, we have a bunch of punctuation marks that aren't glob-safe but are useful in writing Perl programs, together with the space character. I also saved two uppercase letters, the literal `A` and `Z` (which encode not to themselves, but to `T` and `U`, because `A` was needed as an upper as well as a lower range endpoint); this allows us to write the transliteration instruction itself using the new encoded character set (although uppercase letters aren't that useful, they're useful in specifying changes to the uppercase letters). The most notable characters that we don't have available are `[`, `\`, and `]`, but none are needed (when I needed a newline in the output, I produced it using the implicit newline from `say` rather than needing to write `\n`; `chr 10` would also have worked but is more verbose). As usual, we need to worry about what happens if the inside of the wrapper gets damaged outside the string literal. A corrupted `eval` will prevent anything running; we're fine with that. If the quote marks get damaged, the inside of the string isn't valid Perl, and thus the wrapper will catch it (and the numerous subtractions on strings mean that even if you could make it valid Perl, it'd do nothing, which is an acceptable outcome). Damage to the transliteration, if it isn't a syntax error, will mangle the string being evaluated, typically causing *it* to become a syntax error; I'm not 100% sure there are no cases in which this breaks, but I'm brute-forcing it at the moment to make sure, and it should be easy enough to fix if there are. ### The encoded program Looking inside the string literal, reversing the encoding I used, and adding whitespace to make it more readable, we get this (again, imagine a control-underscore before the `-+`, which is encoded as `A`): ``` $o=q< length$o ==181 || zzzz((())); do { chop ($t = "eval+<"x4); $r = '=-+;-AZz-~='; $s = '$o=q<' . $o . '>;eval$o'; eval '$s=~y' . $r . 'A-Z='; say "$t(q($s)=~y=A-Z${r}r)" . "####>"x6; say ";" for 1..4 } for 1..4; exit>; eval $o ``` People who are used to quines will recognise this general structure. The most crucial part is at the start, where we verify that $o is undamaged; if characters have been deleted, its length won't match `181`, so we run `zzzz((()))` which, if it isn't a syntax error due to unmatched brackets, will be a runtime error even if you delete any three characters, because none of `zzzz`, `zzz`, `zz`, and `z` is a function, and there's no way to prevent it parsing as a function other than deleting `(((` and causing an obvous syntax error. The check itself is also immune to damage; the `||` can be damaged to `|` but that will cause the `zzzz((()))` call to run unconditionally; damaging variables or constants will cause a mismatch because you're comparing one of `0`, `180`, `179`, `178` for equality to some subset of the digits of `181`; and removing one `=` will cause a parse failure, and two `=` to inevitably cause the LHS to evaluate to either integer 0 or a null string, both of which are falsey. **Update**: This check was slightly wrong in a preceding version of the program, so I had to edit it to fix the issue. The previous version looked like this after the decode: ``` length$o==179||zzzz((())) ``` and it was possible to delete the first three punctuation marks to get this: ``` lengtho179||zzz((())) ``` `lengtho179`, being a bareword, is truthy and thus breaks the check. I fixed this by adding an extra two `B` characters (which encode space characters), meaning the latest version of the quine does this: ``` length$o ==181||zzzz((())) ``` Now it's impossible to hide both the `=` signs and the `$` sign without producing a syntax error. (I had to add two spaces rather than one because a length of `180` would put a literal `0` character into the source, which could be abused in this context to integer-compare zero with a bareword, which succeeds.) **End update** Once the length check passes, we know the copy is undamaged, at least in terms of character deletions from it, so it's all just straightforward quining from there (substitutions of punctuation marks due to a corrupted decoding table wouldn't be caught with this check, but I've already verified via brute-forcing that no three deletions from *only* the decoding table break the quine; presumably most of them cause syntax errors). We have `$o` in a variable already, so all we need to do is hardcode the outside wrappers (with some small degree of compression; I didn't skip out the [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") part of the question *entirely*). One trick is that we store the bulk of the encoding table in `$r`; we can either print it literally in order to generate the encoding table section of the inside wrapper, or concatenate some code around it and `eval` it in order to run the decoding process in reverse (allowing us to figure out what the *encoded* version of $o is, having only the *decoded* version available at this point). Finally, if we were an intact copy and thus could output the entire original program, we call `exit` in order to prevent the other copies also trying to print the program out. ## Verification script Not very pretty, but posting it because someone asked. I ran this several times with a variety of settings (typically changing `$min` and `$max` to check for various areas of interest); it wasn't a fully automated process. It has a tendency to stop running due to heavy CPU load elsewhere; when this happened, I just changed `$min` to the first value of `$x` that wasn't fully checked and continued running the script (thus ensuring that all the programs in the range got checked eventually). I only checked deletions from the first copy of the program, because it's fairly obvious that deletions from the other copies can't do more. ``` use 5.010; use IPC::Run qw/run/; undef $/; my $program = <>; my $min = 1; my $max = (length $program) / 4 - 3; for my $x ($min .. $max) { for my $y ($x .. $max) { for my $z ($y .. $max) { print "$x, $y, $z\n"; my $p = $program; substr $p, $x, 1, ""; substr $p, $y, 1, ""; substr $p, $z, 1, ""; alarm 4; run [$^X, '-M5.010'], '<', \$p, '>', \my $out, '2>', \my $err; if ($out ne $program) { print "Failed deleting at $x, $y, $z\n"; print "Output: {{{\n$out}}}\n"; exit; } } } } say "All OK!"; ``` [Answer] ## [Befunge-98](https://github.com/catseye/FBBI), 884, n = 14, score ≈ 2.636 ``` f00f00f00f00f00f00f00f00f00f00f00f00f00f00f0xxxxxxxxxxxxxxx"""""""""""""""fffffffffffffff'''''''''''''''000000000000000\\\\\\\\\\\\\\\'''''''''''''''000000000000000\\\\\\\\\\\\\\\'''''''''''''''fffffffffffffff\\\\\\\\\\\\\\\111111111111111---------------:::::::::::::::!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!000000000000000aaaaaaaaaaaaaaa---------------bbbbbbbbbbbbbbb---------------***************jjjjjjjjjjjjjjj$$$$$$$$$$$$$$$'''''''''''''''+++++++++++++++kkkkkkkkkkkkkkk,,,,,,,,,,,,,,,333333333333333kkkkkkkkkkkkkkk$$$$$$$$$$$$$$$000000000000000{{{{{{{{{{{{{{{'''''''''''''''888888888888888uuuuuuuuuuuuuuu'''''''''''''''!!!!!!!!!!!!!!!111111111111111+++++++++++++++'''''''''''''''xxxxxxxxxxxxxxx###############;;;;;;;;;;;;;;;:::::::::::::::!!!!!!!!!!!!!!!kkkkkkkkkkkkkkk@@@@@@@@@@@@@@@dddddddddddddddkkkkkkkkkkkkkkk:::::::::::::::eeeeeeeeeeeeeeekkkkkkkkkkkkkkk,,,,,,,,,,,,,,,;;;;;;;;;;;;;;; ``` [Try it online!](https://tio.run/nexus/befunge-98#@p9mYEA0qkAFSoBS6V4HIBgKw/C1CInET0IswuJCuhAMzCYXX/P7Dl08a7@25/SUTiqpo0B/wrpX4Z5amihLUlUr6eSNtFrRRQWp35puamgghXWRGnxJZYz0kMJ6SQ1FHWmvfl1OM6UHqvYX2klhnXxQegoqMsYP "Befunge-98 – TIO Nexus") This doesn't just work when you remove exactly 14 characters, but even when you remove any amount *up to* 14 characters. `n = 14` may seem like a very arbitrary choice, but the technique I used can in fact only be used for radiation-hardening orders from 1 to 14, but not easily beyond that (it might be possible but I have no clue how). The order-1 quine is merely 73 bytes (although it employs some golfing tricks that don't apply to larger `n`): ``` 200 20 xx""''ÈÈ..aa22**..33kk$$00{{''!!uu''!!11++''xx##;;::!!kk@@::,,,,;; ``` ### Explanation When I was working on [this answer](https://codegolf.stackexchange.com/a/103101/8478) I found that it's possible to set the instruction pointer's delta to `(2,0)` under radiation-hardened conditions with the following snippet: ``` 20020xx ``` See that answer for why this works. I found this just with a bit of fiddling by hand, but this raised the question whether there are similar patterns which are robust under removal of multiple characters. So I wrote a short Mathematica script to search for these by brute force: ``` n = 14; m = 4; Print @ FromDigits @ { m + 1, 0, ## & @@ ((m + 1) IntegerDigits[#, 2, n - 4]), m + 1, 0 } & /@ Select[ Range[0, 2^(n - 4) - 1], AllTrue[ Subsets[{ m + 1, 0, ## & @@ ((m + 1) IntegerDigits[#, 2, n - 4]), m + 1, 0 }, {n - m, n - 1} ] //. {a___, _, m + 1} | {a___, 0, _} :> {a}, MatchQ@{___, m + 1, 0} ] & ]; ``` This very quickly revealed a pattern. To get a corresponding snippet which works for removal of up to `n` characters, you can use `(m0x){n}m0` where `m` is `n+1` and `x` is either `m` or `0`. So all of the following would work for removal of up to two characters: ``` 30030030 30030330 30330030 30330330 ``` I'm sure it's possible to prove this, but I've simply verified for `n` up to `7`. Of course, this only works as long as we can represent `n+1` as a single digit, and the largest such digit in Befunge 98 is `f` which represents 15. That's why my approach is limited to `n = 14`. If someone finds a way to reliably set the delta to larger `n+1`, it would likely be possible to increase the order of this radiation-hardened quine indefinitely. Let's look at the actual code. There are basically two parts to it. First we set the delta to `(15,0)` as I just mentioned: ``` f00f00f00f00f00f00f00f00f00f00f00f00f00f00f0xxxxxxxxxxxxxxx ``` And the remainder of the code has each command repeated 15 times and prints the source. If we remove the repetition, it looks like this: ``` "f'0\'0\'f\1-:!!0a-b-*j$'+k,3k$0{'8u'!1+'x#;:!k@dk:ek,; ``` The `"` is a standard 2D quining technique: it starts string mode, pushes all the characters (except itself) onto the stack and ends string mode again after wrapping around. This helps us get all the code points of the second half, but it will fail to get us anything useful from the first half, because throughout the `f00f00...f0` bit, it will only record two characters (which may be either `f` or `0` depending on which characters are deleted). But since that part isn't made up of characters being repeated 15 times, we'll need to print it separately anyway. More conveniently, in the unmodified quine, the length of the string before the `"` is `-1 (mod 15)`. This guarantees that no matter how many characters (up to 14) we remove, that the *number* of characters recorded there is always 3 (one `x` and two of `f` and `0`). This is actually true for any radiation order up to 14. We now start by printing the `f00f00...f0` part: ``` f'0\'0\'f\1-:!!0a-b-*j$'+k, f Push 15, a loop counter. '0\'0\'f\ Put "00f" underneath the loop counter. 1- Decrement the loop counter. :!! Copy it, and turn it into a 1 if it's positive. 0a-b- Push -21. * Multiply by 0 if the loop counter is zero, or by 1 otherwise. j Jump that many steps. If the value was 0, this is a no-op and the loop ends. Otherwise, this brings us back after the f. $ Pop the loop counter (which is now 0). '+k, Print the top of the stack 43 times, which gives us all of the "f00f00...f0" and leaves one "0" on top of the stack. ``` The next `3k$` simply discards that `0` as well as the three characters that were pushed by `"` from the beginning of the program. The stack now contains only the characters after the `"` as well as some junk underneath from the original `f00f00...f0` depending on which characters were deleted. Now we just need to reverse the top of the stack (containing the remaining characters) and print each one of them 15 times. ``` 0{ Start a new, empty stack. This pushes two zeros onto the original stack. '8u Move the top 56 values from the original stack to the new one, which is the 54 characters after the " as well as those two zeros. This is implemented as pop-push loop, so it reverses the order of those elements. '!1+ Push a " by incrementing a !. 'x Push an x. Now we've got all the characters that are repeated 15 times. #; Enter a loop. This is a standard technique for Befunge-98: the ; is a bit like a comment character, that ignores everything until the next ;, but we jump over the first one with #, so that from now on only the code inside will be executed (over and over). :! Copy the top of the stack, and compute logical NOT (1 if 0, 0 otherwise). k@ Terminate the program that many times (i.e. when the top of the stack is zero). dk: Make 14 copies of the top of the stack. ek, Print 15 characters from the top of the stack. ; ``` And that's it. :) [Answer] # JavaScript (ES6), 927 bytes, n=1, score=859329 *note: don't use a REPL (like a browser console) to run this.* This was written before code length was a factor, so it isn't golfed yet. This was *very* difficult, and deserves a thorough explanation. Which I will write later, after I explore this challenge a little more! ``` etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42; setTimeout `c="function f(){x=String.fromCharCode(96);n=String.fromCharCode(10);q=String.fromCharCode(34);y='etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42;'+n;z='setTimeout'+n+x+'c='+q+f+';f();_=1'+q+';if(window._);else if(c.length>339)eval(c)//'+x+'///'+x+n+n;console.log(y+z+z)};f();_=1";if(window._);else if(c.length>339)eval(c)//`///` setTimeout `c="function f(){x=String.fromCharCode(96);n=String.fromCharCode(10);q=String.fromCharCode(34);y='etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42;'+n;z='setTimeout'+n+x+'c='+q+f+';f();_=1'+q+';if(window._);else if(c.length>339)eval(c)//'+x+'///'+x+n+n;console.log(y+z+z)};f();_=1";if(window._);else if(c.length>339)eval(c)//`///` ``` *note: there is a trailing newline* Basically, the first line is carefully constructed to rename all 'mispellings' of `setTimeout` to valid functions, so that if a character is removed from one of the `setTimeout`s the code will not error out and the unscathed version can run. It is also written so that if any one character is removed from the first line, there will be no error and the rest of the code can run unaffected. The second and third blocks are exactly equivalent. If one runs to completion, it sets the `_` variable so that the other knows not to duplicate the quine. If one of these blocks errors out, it does not affect the other block because it was called asynchronously using `setTimeout`. The error will cause `_` not to be set, so the other block will quine successfully. The main code is in a string, which is checked for length in each block to make sure that there were no removals. Template strings on the next line with some comments at the end of the template strings protects the code from erroring out if one of the backticks forming the template string is removed. If the ending backtick is removed, the template string is ended by the backtick in the comment. If the starting backtick is removed, setTimeout is evaluated as an unassigned function (a no-op) and the code runs as normal, without a setTimeout. The ending backtick is nullified by another comment. **What's that you say? You want to try it out? Say no more!** Full page mode recommended. Ignore the input box, this snippet takes no input. Try removing any one character from the code! Don't believe it? Normal code will still work (but it won't quine...) Try something like `console.log(5)`! *note: the snippet had to be modified slightly to disable the REPL feature, so I removed multiple output capabilities for this answer only.* ``` etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42; setTimeout `c="function f(){x=String.fromCharCode(96);n=String.fromCharCode(10);q=String.fromCharCode(34);y='etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42;'+n;z='setTimeout'+n+x+'c='+q+f+';f();_=1'+q+';if(window._);else if(c.length>339)eval(c)//'+x+'///'+x+n+n;console.log(y+z+z)};f();_=1";if(window._);else if(c.length>339)eval(c)//`///` setTimeout `c="function f(){x=String.fromCharCode(96);n=String.fromCharCode(10);q=String.fromCharCode(34);y='etTimeout=stTimeout=seTimeout=setimeout=setTmeout=setTieout=setTimout=setTimeut=setTimeot=setTimeou=unescape=>42;'+n;z='setTimeout'+n+x+'c='+q+f+';f();_=1'+q+';if(window._);else if(c.length>339)eval(c)//'+x+'///'+x+n+n;console.log(y+z+z)};f();_=1";if(window._);else if(c.length>339)eval(c)//`///` ``` ``` <!-- Try the test suite below! --><strong id="bytecount" style="display:inline; font-size:32px; font-family:Helvetica"></strong><strong id="bytediff" style="display:inline; margin-left:10px; font-size:32px; font-family:Helvetica; color:lightgray"></strong><br><br><pre style="margin:0">Code:</pre><textarea id="textbox" style="margin-top:5px; margin-bottom:5px"></textarea><br><pre style="margin:0">Input:</pre><textarea id="inputbox" style="margin-top:5px; margin-bottom:5px"></textarea><br><button id="testbtn">Test!</button><button id="resetbtn">Reset</button><br><p><strong id="origheader" style="font-family:Helvetica; display:none">Original Code Output:</strong><p><div id="origoutput" style="margin-left:15px"></div><p><strong id="newheader" style="font-family:Helvetica; display:none">New Code Output:</strong><p><div id="newoutput" style="margin-left:15px"></div><script type="text/javascript" id="golfsnippet">var bytecount=document.getElementById("bytecount");var bytediff=document.getElementById("bytediff");var textbox=document.getElementById("textbox");var inputbox=document.getElementById("inputbox");var testbtn=document.getElementById("testbtn");var resetbtn=document.getElementById("resetbtn");var origheader=document.getElementById("origheader");var newheader=document.getElementById("newheader");var origoutput=document.getElementById("origoutput");var newoutput=document.getElementById("newoutput");textbox.style.width=inputbox.style.width=window.innerWidth-50+"px";var _originalCode=null;function getOriginalCode(){if(_originalCode!=null)return _originalCode;var allScripts=document.getElementsByTagName("script");for(var i=0;i<allScripts.length;i++){var script=allScripts[i];if(script.id!="golfsnippet"){originalCode=script.textContent.trim();return originalCode}}}function getNewCode(){return textbox.value.trim()}function getInput(){try{var inputText=inputbox.value.trim();var input=eval("["+inputText+"]");return input}catch(e){return null}}function setTextbox(s){textbox.value=s;onTextboxChange()}function setOutput(output,s){output.innerHTML=s}function addOutput(output,data){output.innerHTML='<pre style="background-color:'+(data.type=="err"?"lightcoral":"lightgray")+'">'+escape(data.content)+"</pre>"}function getByteCount(s){return(new Blob([s],{encoding:"UTF-8",type:"text/plain;charset=UTF-8"})).size}function onTextboxChange(){var newLength=getByteCount(getNewCode());var oldLength=getByteCount(getOriginalCode());bytecount.innerHTML=newLength+" bytes";var diff=newLength-oldLength;if(diff>0){bytediff.innerHTML="(+"+diff+")";bytediff.style.color="lightcoral"}else if(diff<0){bytediff.innerHTML="("+diff+")";bytediff.style.color="lightgreen"}else{bytediff.innerHTML="("+diff+")";bytediff.style.color="lightgray"}}function onTestBtn(evt){origheader.style.display="inline";newheader.style.display="inline";setOutput(newoutput,"");setOutput(origoutput,"");var input=getInput();if(input===null){addOutput(origoutput,{type:"err",content:"Input is malformed. Using no input."});addOutput(newoutput,{type:"err",content:"Input is malformed. Using no input."});input=[]}doInterpret(getNewCode(),input,function(data){addOutput(newoutput,data)});doInterpret(getOriginalCode(),input,function(data){addOutput(origoutput,data)});evt.stopPropagation();return false}function onResetBtn(evt){setTextbox(getOriginalCode());origheader.style.display="none";newheader.style.display="none";setOutput(origoutput,"");setOutput(newoutput,"")}function escape(s){return s.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}window.alert=function(){};window.prompt=function(){};function doInterpret(code,input,cb){var workerCode=interpret.toString()+";function stdout(s){ self.postMessage( {'type': 'out', 'content': s} ); }"+" function stderr(s){ self.postMessage( {'type': 'err', 'content': s} ); }"+" function kill(){ self.close(); }"+" self.addEventListener('message', function(msg){ interpret(msg.data.code, msg.data.input); });";var interpreter=new Worker(URL.createObjectURL(new Blob([workerCode])));interpreter.addEventListener("message",function(msg){cb(msg.data)});interpreter.postMessage({"code":code,"input":input});setTimeout(function(){interpreter.terminate()},1E4)}setTimeout(function(){getOriginalCode();textbox.addEventListener("input",onTextboxChange);testbtn.addEventListener("click",onTestBtn);resetbtn.addEventListener("click",onResetBtn);setTextbox(getOriginalCode())},100);function interpret(code,input){_=undefined;window={};alert=function(s){stdout(s)};window.alert=alert;console.log=alert;prompt=function(s){if(input.length<1)stderr("not enough input");else{var nextInput=input[0];input=input.slice(1);return nextInput.toString()}};window.prompt=prompt;(function(){try{_=undefined;eval(code);if(typeof evalResult=="disabled_function_evaluation"){var callResult=evalResult.apply(this,input);if(typeof callResult!="undefined")stdout(callResult)}}catch(e){stderr(e.message)}})()};</script> ``` A better explanation is forthcoming. In the meantime feel free to ping me in chat @jrich with any comments/questions/criticisms! ]
[Question] [ ## Background As you probably learned in biology class, DNA and RNA are composed of strands of nucleotides; each nucleotide consists of a chemical called a base together with a sugar and a phosphate group. The information stored in the DNA or RNA is coded as a sequence of bases. DNA uses the bases A, C, G, and T (standing for adenine, cytosine, guanine, and thymine), while RNA uses A, C, G, and U (with uracil replacing thymine). ## Challenge The genome of SARS-Cov-2, the virus that causes COVID-19, has been fully sequenced. This genome is a sequence of 29,903 bases, each base being one of A, C, G, or U, since it's an RNA virus. **The challenge is to output that sequence using as few bytes in your program as possible (code golf).** You can write either a full program or a function. Because the names A, C, G, and U are arbitrary, you can use any 4 characters you want instead: * You must use exactly 4 characters (they must be pairwise distinct--two or more can't be equal). * Each one of the 4 characters must be a printable ASCII character in the range from `'!'` to `'~'`, inclusive (ASCII 33 to 126). In particular, this does *not* include the space character or the newline character. * Each of the 4 characters you use must always represent the same one of A, C, G, and U -- no changing in the middle! Your output should be the precise text at the following link, with A, C, G, and U replaced by whichever 4 characters you selected, and you may optionally follow the entire sequence with one or more newline characters (but no newlines or other extraneous characters at the beginning or in the middle are allowed): [Click to see the required output](https://tio.run/##fZ1dki3JbYPXxuADV8AF2E9@9/7D6iI@IM9IEZZGuj23z09VJpMEQZD13//1v//zf3//qd2qmtm/P7e6d7v7@/eq/vvF38/639/ve2r777/798v78e9N379/Lxu95O9H/eLvv/P92X9/3fdj19///l4x34/9/eLvz/m@9C7h@z79eG/7@@ip7zrqe2Hd5Xx/@/ea7wru8/Sx3zvu8r/f9vfN97u@q/3@@b7ue1P9vGruCut7Uelm/17992XzvfG7wb9FWL3@bu572XcldW@/a6nvt9@rvz/3rvX79L8XfxdxF3s/fVeoj25d39T9893GXd53H/e5peu8/fiu5lsmFvJbtu8iblnqrrnve78L0PZ8O/Bd/bdCtwp389/Vf5c1pWv6Xvp98Peu7wa///@uY@6T5276W7HRet8X1d7d3jJ/d/Vd0t4N3ffOLZcX7T5wvsv7TOGzHd9BfxuuVdI/Wvb72Nv/W5e7gr83/H3Od7ffb5vNvJd8X3C28a2JVvt7E8v1vezWdW4NtX/avG/h74pvJ3WTuvjv0r6N0bbu3M93yd@3/33LrUHJlLW83/XcAZEt3gXft3@3WrcOt55n9trQO1r3tbKPu@v7mvvOOz5nm3zujE6UDkLfWo0Mt@6QfP9w2XUXfHf9vV67ctY6GIDM5m7rXqZDUmcJu7xR7/52qfQX61f8/dW3qd8bdQBubb8rOX/BW2/TSkv@fc/iPGZstxjvLQ5H4z74jNsehlN@J2zuYOgb79v5yLOyu3adxtXd61ifjWCl2iIdp89YzmZ08Vp/GXGPb8mGNF4Abd9nuHqxT@W5qtvsPrd3/o6PLXbu7uKOxOc8dJDqzvIZhHatzheckevELDfbWiLZ7x1Dn5o7I581ap21EmerOF955rNVnW19bLNErbfdYbRB1px163Dcnehb5dp0a@fHdIblHOSvzk6w8OXgy0zO5ji3JY@khdHuEDP8Iffi77bu1Nx@jHzi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TCyNDqPD3OZPGzBZLQ@bV3vITMQZd0hOfysKBegHV3N6ntsvh8ThKLhyXvaYlQmAOYhHKILIF7HEmQgaLsN1rK/Sv95hhG3X1IZUGyiDoHKGIwNDwlsP/4Aj4j8fZQH6nkSjMFmwFLaxniKZnqgyeWYROYJ9y/RCc/abTmjBxlNJzJPhkj@///5Fw). (Including all 29,903 characters here would cause this to exceed a StackExchange maximum size.) Because you can use any 4 distinct characters you want, it's acceptable to use, for example, lower-case instead of upper-case, or to use T instead of U, or to use 0123 instead of ACGU, or even to output the complementary strand (with A and U switched, and C and G switched). ## Restrictions Standard loopholes are prohibited as usual. In particular, it's not allowed to retrieve information online or from any source other than your program. *I've removed the blanket prohibition against the use of any built-in which yields genomic data or protein data. These would generally retrieve data from the Internet and that usage wouldn't be allowed anyway (as a standard loophole), but if some language has this facility built in internally, without requiring Internet access, that might still be interesting to note (even if it doesn't solve the spirit of the challenge, which is to find patterns in the genomic data).* ## Verifying Your Program I've set up a way to check that your program's output is correct. Just copy and paste your program's output into the argument in [this verification program on TIO](https://tio.run/##jZ1trx3XcaW/81ecOHBIWi@RnAEGiCwDhRq5ECDIAEIq88HRB5q8pC5MXWouSceesfPTRzm917NqN0XKGInkPfecPt27965dL6tWVT/95MXTpz/88Le3d09fvn12c/nV6zfPXt7@7tNvf/3gnfduX/34rfvbuxfHew/@9tnN89u7m8vXX/3mq6@/@pf86vKz6I6Iqr7@7Mjszszj94i8fnB9rb/Xz7Oi8/p/Xz9cL69fOn4/Disdcn2pD67/1/Ezr2/neplx/Xs9oo6XeXxw/VnHRdcQjuvp5fra9dQVxzjiODDWcI53r8ccI1jn02mPb6zhH5/mceX1Wa7RHn@Oyx1fitNRtUYYx0Ghm70efb1YHV88bvA6Ca3j180dhx0jifX1NZY4Pj2OPn72Gutx9uvBxyDWYNerY4Q6dWp8FevPcRtreMd9rPOGxrnW4xjNMU1M5DFtxyDWtMQac67rHgPQ8hwrcIz@mKE1C@vmj9Efw6rQmI5DjxMf3z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ffHK5f3t3ub7@7vbuyZt37NTo2f92HsT697DwVylin703mr3d1lc9Ne@qgH/76ut/@s0/ffU/fmwZP7NWX1c5HIYHP/zww1d3h1vyp2OBrv7Ii/sn3z18fTgoh6fw7dVAHC7VdVZvn//pcvvm0//39PnLJy9e//DJ/3ry8uX13@ufpQf@Cw) and run it. ## Other Info Some facts that may or may not be of help: 1. There are 29,903 bases in the sequence. The counts for the individual bases are: * A 8954 * C 5492 * G 5863 * U 9594 2. If you simply code each of the 4 bases in 2 bits, that would get you down to 7476 bytes (plus program overhead), so any competitive answer is likely to be shorter than that. 3. The source for the data can be found at [this web page at NIH](https://www.ncbi.nlm.nih.gov/nuccore/MN908947); scroll down to ORIGIN. The data is written there in lower-case letters, and 't' is used instead of 'u', apparently because DNA sequencing techniques were used. 4. There are variant strains of SARS-Cov-2 known (the base sequences are slightly different, and the length varies a bit); I believe the one here is the first one sequenced, from Wuhan. 5. Groups of 3 consecutive bases code for particular amino acids, so it might be useful to analyze the data in groups of 3. But there are non-coding areas where the number of bytes isn't necessarily a multiple of 3, so you may not want to just divide the data into groups of 3 starting at the beginning. If it might be useful, you can find more info on the structure of the virus RNA [here](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7161481/) (but this probably isn't needed). ***Disclaimer:*** I'm not a biologist. If anyone has any corrections or improvements on the underlying biology (or anything else, of course), please let me know! Happy golfing! [Answer] # bash + `flif-tools`, 40+1+7359 = 7400 bytes First, I noticed that the probabilities of various letters weren't evenly distributed, and I thought I should use some kind of arithmetic coding. Then I realised that this awesome image format, about which I remember that it uses some super-complicated kind of arithmetic coding, can be used to compress the SARS-CoV-2 genome. ``` flif -d f .pgm cat .pgm|tr -cd ACUG ``` Requires a file named `f` in the current directory, with the following contents (it's a 29903x1 image): ``` 00000000: 464c 4946 3131 81e9 4e00 0041 7ef2 f1e6 FLIF11..N..A~... 00000010: 7012 b5f1 79f4 99da 8f57 1fd4 eb3e dca1 p...y....W...>.. 00000020: 4b84 7263 bc59 a96d 1e17 5f91 3326 aee5 K.rc.Y.m.._.3&.. 00000030: 2bd0 faa0 43f5 5613 362f bac7 a79c b96b +...C.V.6/.....k 00000040: 54f1 76f1 d0b3 ecc6 cbbf e7dc 3147 2233 T.v.........1G"3 00000050: 6fd6 4ba1 ed75 5031 748c 71e8 7b8e 0852 o.K..uP1t.q.{..R 00000060: 1218 e539 5991 ce94 c750 ed10 1f9c cff3 ...9Y....P...... 00000070: bc6e 66af 70fe 256c 368c fd5d d17f d8ed .nf.p.%l6..].... 00000080: 893c 1c1d d02e 863b 9a74 a1d2 3a14 96bb .<.....;.t..:... 00000090: aefe d54f 2d65 6660 cc0d ab9b cc1f 5edb ...O-ef`......^. 000000a0: 7cd6 de58 9a2f e729 95b3 ba7a 7022 b237 |..X./.)...zp".7 000000b0: c828 3407 2404 1ce5 c21e 9b31 aae0 670c .(4.$......1..g. 000000c0: 4c3c 7266 c70e 014a a7e8 495f ea33 f8be L<rf...J..I_.3.. 000000d0: 7a94 0a64 331e e59a a0bc d1e9 3151 8465 z..d3.......1Q.e 000000e0: be91 5f5a 6725 d496 3366 cc44 2e8a 46df .._Zg%..3f.D..F. 000000f0: 791e 6048 944a 4700 cb48 e986 b0b0 657b y.`H.JG..H....e{ 00000100: a77d efac 6bb2 d669 1403 90a2 d4c2 df32 .}..k..i.......2 00000110: 6a62 ae22 ea05 a751 8696 9343 aef8 5256 jb."...Q...C..RV 00000120: 8b5b e09d 7c80 e05b f748 968b fb6b 1a36 .[..|..[.H...k.6 00000130: 7e9b 9784 4dc9 bfab 8871 374a d9bd a9c7 ~...M....q7J.... 00000140: 5245 39cb c5f6 3ada 8d86 e72d affb 473f RE9...:....-..G? 00000150: 0065 19ee 5517 4481 81aa 9c72 70b5 17b3 .e..U.D....rp... 00000160: 1341 b678 22e2 c84b 2df5 faa3 0584 22b8 .A.x"..K-.....". 00000170: 3cc4 5337 7b9f 443e e455 e66b 68f5 9caf <.S7{.D>.U.kh... 00000180: db3f d0cc dba9 18ce bb67 b14e bd41 306e .?.......g.N.A0n 00000190: 9829 3506 9b25 544a 4aab 0ecc d64a 3136 .)5..%TJJ....J16 000001a0: 50c6 962b 635a 7502 fd81 45ab bb1f d1b4 P..+cZu...E..... 000001b0: 2eef 658a 7b35 2af7 3166 bb89 8adb 6f52 ..e.{5*.1f....oR 000001c0: 58dc 2b8c ae57 3886 eeff 0975 e141 d98f X.+..W8....u.A.. 000001d0: eb65 84c9 a19d 4bf3 b111 8c02 ba9b b366 .e....K........f 000001e0: 481a b148 529c 1bde 71c5 c393 7062 9918 H..HR...q...pb.. 000001f0: 5bab 356e 8b85 f9d8 66b5 75f7 99b1 f938 [.5n....f.u....8 00000200: 52b4 87d0 ada1 af71 80b1 bfad c797 e508 R......q........ 00000210: 1683 40cc ae1c 81d3 17e4 4a50 31ba 8077 [[email protected]](/cdn-cgi/l/email-protection) 00000220: cc79 ad9b 77c5 6d8a 6275 3a02 5fe0 4c6d .y..w.m.bu:._.Lm 00000230: 878e 144a 40e5 c3d8 24f3 fe4e 9c9f 9820 ...J@...$..N... 00000240: be90 81c9 c4c8 dd16 e678 887c 3ba0 8633 .........x.|;..3 00000250: 4572 4533 6254 1ead bd0a c17a ca9a 4220 ErE3bT.....z..B 00000260: eb9c 614f da8c 21e3 1ea4 f269 fa2f c146 ..aO..!....i./.F 00000270: ef5f fee2 9aad badf 35a7 9454 f7f6 e004 ._......5..T.... 00000280: 5fec b825 c2ad 49f7 eb07 be5d 0aef f53b _..%..I....]...; 00000290: 63f5 6681 844d a955 8fe7 9ad7 ba8d 490f c.f..M.U......I. 000002a0: 3203 f35e 9fa5 07f1 c976 5b51 08f3 c89e 2..^.....v[Q.... 000002b0: d836 9be5 7367 e30c b466 817a b60b 160f .6..sg...f.z.... 000002c0: b874 901b 3c4a b10c a480 c359 43b2 9cb3 .t..<J.....YC... 000002d0: 38fe 8285 6807 7fa7 a8bc 1d25 3bd8 0713 8...h......%;... 000002e0: e4a0 2b0a f89d 2545 ce8d f9d1 28b8 75a8 ..+...%E....(.u. 000002f0: 57f8 2ee4 8e8d c698 45eb 96c3 04dc 5604 W.......E.....V. 00000300: 96b2 b5ee 4ed0 5536 1075 97e6 dbf6 2454 ....N.U6.u....$T 00000310: c73c b356 6724 e2de 69d9 bcdd 9a20 9814 .<.Vg$..i.... .. 00000320: 96f8 5418 7035 9ced 6756 5db1 0e01 e874 ..T.p5..gV]....t 00000330: 5ff7 86c9 3157 0c4e 185a 3cfb e68e 3289 _...1W.N.Z<...2. 00000340: 3a4d e961 fad7 1936 c71a 0116 b7df be82 :M.a...6........ 00000350: e477 9d6e 84b5 88eb e947 8071 ab8a 896b .w.n.....G.q...k 00000360: fc2b d99d 67e6 3463 3c00 b119 49df c559 .+..g.4c<...I..Y 00000370: 832c 9f53 7f71 655a a7e4 ea7d 301d 86fc .,.S.qeZ...}0... 00000380: b2e1 cdd5 c06c 00a4 c0eb a479 aa35 4b49 .....l.....y.5KI 00000390: 6f6d 7f0e 1981 ca10 6fb0 9b53 a889 4ffb om......o..S..O. 000003a0: 0923 5345 4464 9d7d 7bc0 4c22 83e8 69fb .#SEDd.}{.L"..i. 000003b0: 89df d7d2 c1a9 f7e6 21ad 75a4 1200 1d8f ........!.u..... 000003c0: d518 d8c4 cbd3 0097 bbb6 495a 4a73 9b55 ..........IZJs.U 000003d0: e159 44f5 32aa ac14 2a29 9662 f6dc afbd .YD.2...*).b.... 000003e0: 92d0 61da de21 ed63 64cc 7b11 94ec 91c3 ..a..!.cd.{..... 000003f0: 10ff 316f 49f9 52c1 4a12 66e6 4104 d699 ..1oI.R.J.f.A... 00000400: 8196 a64e e594 71ae bb76 bd0f 0ae6 7c62 ...N..q..v....|b 00000410: 0fea b4c4 c01f fb55 a0ce 5677 017f db45 .......U..Vw...E 00000420: cbbe da6f 6a37 be75 2e6a 9a9d 797a 7ee5 ...oj7.u.j..yz~. 00000430: bc72 a10b 6e70 f25c 5e44 5834 c37d 0747 .r..np.\^DX4.}.G 00000440: bc7a 3abd 794a 9c05 8a4e 62c8 397c a279 .z:.yJ...Nb.9|.y 00000450: 21ad 285b ec73 b749 a7b3 7d43 8b8b 8f87 !.([.s.I..}C.... 00000460: 2711 744a 6abe 1a75 e872 4c06 17d5 6807 '.tJj..u.rL...h. 00000470: 71f9 9dab 30dc 839c 83c1 7b6f f6fe 923b q...0.....{o...; 00000480: 2cfe 5d3f 62de 1e1a 9969 ce73 84eb 0c24 ,.]?b....i.s...$ 00000490: 3934 59a5 fe9d 6093 a523 d20d fbb0 b500 94Y...`..#...... 000004a0: b9cd 08aa dfc0 76d5 d4d7 db42 88a2 d33f ......v....B...? 000004b0: 351f f9f8 7d8e 6987 da3e 8bce b5bb 042a 5...}.i..>.....* 000004c0: c085 c0ec aea3 be86 db4a 8f1c bd58 2be2 .........J...X+. 000004d0: 4586 f743 eaef 8a80 cf07 27e7 0159 c070 E..C......'..Y.p 000004e0: cf94 4d56 45e1 a0c0 7837 e081 16ea 6566 ..MVE...x7....ef 000004f0: 4f89 7bf8 7160 a851 e2cf 8396 05a9 fc37 O.{.q`.Q.......7 00000500: 6ed8 69ee f651 aa56 0660 18ec 0fd0 e948 n.i..Q.V.`.....H 00000510: ee27 6c35 620f e472 0c04 7902 35d5 58cd .'l5b..r..y.5.X. 00000520: d117 d1ab 16f2 f89e 6210 fdfa 300a ffa5 ........b...0... 00000530: 4f0e 60be 7516 69c0 22de 46cd eb3e e60b O.`.u.i.".F..>.. 00000540: 6f00 9737 a429 0c99 22ce 5f0f 1b20 56c7 o..7.).."._.. V. 00000550: f1a2 d5b8 d782 98fd 521e 68a1 fd73 4f56 ........R.h..sOV 00000560: 50de ec30 4d39 8e5f f4f8 f153 d448 13cd P..0M9._...S.H.. 00000570: 29d5 2aa7 d4fa e6b1 16d3 ef68 9a13 8c22 ).*........h..." 00000580: afcf dcc7 9e86 cb81 a943 6cab f850 ed0a .........Cl..P.. 00000590: b258 8dd0 ad7d 5f8f a7cd aa7e 84f9 a1a5 .X...}_....~.... 000005a0: 1f70 ee1a ec0b d963 3e95 5439 1c77 588b .p.....c>.T9.wX. 000005b0: 199c 3079 0117 8306 609e 0448 bca1 1030 ..0y....`..H...0 000005c0: b21a 5b0e fd29 77d1 070f 2810 02e6 5413 ..[..)w...(...T. 000005d0: d21f 6801 3f7c d6d2 fd05 ba73 df5d 2702 ..h.?|.....s.]'. 000005e0: 3fbe fc62 fd9d d033 eaad c5d9 9e89 017b ?..b...3.......{ 000005f0: 0ab4 091e cf49 f5e6 8a88 1493 98be 79dc .....I........y. 00000600: 8f36 4b70 579b 86fe 95da 1ae0 8b08 9168 .6KpW..........h 00000610: 3601 29ee dd47 0e6e 736c d8ca b822 e279 6.)..G.nsl...".y 00000620: c35d 0319 7b3d a94e 19ee f0a1 7c33 19cb .]..{=.N....|3.. 00000630: cd54 8c39 77cc 3ac9 9eeb 56ab 6924 2f3f .T.9w.:...V.i$/? 00000640: 63fd f95d ac91 30d0 42c3 2070 316e c3e8 c..]..0.B. p1n.. 00000650: 3435 3e90 3216 6d2c a8f9 746d 60d1 485f 45>.2.m,..tm`.H_ 00000660: d09c accb 5f74 7918 d7a1 70c7 d3dd 3f5d ...._ty...p...?] 00000670: c495 bf6c 9801 9a39 22ab ab7b 2aca 1d70 ...l...9"..{*..p 00000680: 5e15 943a d4a1 3f67 94b1 f8fa 06f0 065f ^..:..?g......._ 00000690: 8a8a 9d33 61cc 4d40 8812 4e7f 956a 2973 [[email protected]](/cdn-cgi/l/email-protection))s 000006a0: 42d5 87c7 ac20 5c3f f1e2 a76c ca21 15a0 B.... \?...l.!.. 000006b0: 10a6 b5dd 7712 a097 9d1d 1e7d 0711 43a3 ....w......}..C. 000006c0: 6877 abf8 90b6 9ebb 1aa6 ef77 7885 de97 hw.........wx... 000006d0: 99ad 69dd 59bf 1f4b 4506 7dc7 ab63 ae84 ..i.Y..KE.}..c.. 000006e0: 8179 bc16 9813 7944 ead2 5357 efaa 5fd2 .y....yD..SW.._. 000006f0: f390 7c19 d59e 64b0 d09a 38da 8bcf 44f5 ..|...d...8...D. 00000700: e18c 2728 a781 3171 d77b 409b 5a65 574e ..'(..1q.{@.ZeWN 00000710: 1320 c0ff d8cd f84a 08b2 2cf4 3fdb 8bd5 . .....J..,.?... 00000720: ca16 19e2 33cf 1590 7382 777a 7182 ffd8 ....3...s.wzq... 00000730: 1c7b 2cff bba3 287a 9dc4 8788 4690 6bad .{,...(z....F.k. 00000740: cda1 4aae 4c9d 8846 203c 001c 048e dff8 ..J.L..F <...... 00000750: 8c0b ccda 0404 1b6b 19fc 7b10 ad0e 7980 .......k..{...y. 00000760: c9d8 aea6 3ba8 f71e 6321 174c 1d5e 9d30 ....;...c!.L.^.0 00000770: e2da e520 e621 57c5 051e 1eeb 9247 0e1a ... .!W......G.. 00000780: 9577 13ec d500 52b1 86b8 fea9 a1d3 14f6 .w....R......... 00000790: 3416 b971 00d5 3577 a4b6 1a6c a49f 7d9d 4..q..5w...l..}. 000007a0: aa3f c9b4 77be 468b 8b29 117a 69e7 532b .?..w.F..).zi.S+ 000007b0: e92e b1d3 e7c3 93f9 d466 f782 67cd e507 .........f..g... 000007c0: 1a86 2726 ceae 39d6 dbe8 a9e3 de82 7918 ..'&..9.......y. 000007d0: d693 d879 1fc4 2a9b 14b4 5a0b 8da2 fd5b ...y..*...Z....[ 000007e0: c423 b44f db27 013c e11b 9932 4498 9617 .#.O.'.<...2D... 000007f0: 2015 557b 6acb 8972 8016 982b 9a89 c2ce .U{j..r...+.... 00000800: 53a1 9beb 1a54 fffa 0bf9 dd76 7efa ef14 S....T.....v~... 00000810: 0e44 ab06 1956 36fd 8f79 e56f 1a10 e793 .D...V6..y.o.... 00000820: cdb5 75ee 73aa 7ff6 a698 044e 73da 0360 ..u.s......Ns..` 00000830: 6a4f 3386 f958 6059 2098 3041 a124 4d0d jO3..X`Y .0A.$M. 00000840: 1568 3eda 6864 5401 bdca 4ef8 e337 4d8a .h>.hdT...N..7M. 00000850: b848 7844 89e1 919e 502b 13e8 8420 aee4 .HxD....P+... .. 00000860: a4c6 fda9 ef97 031b b293 05c1 54cf bbee ............T... 00000870: 15d3 985b 3396 4e54 f103 a1f7 e394 bb2b ...[3.NT.......+ 00000880: 55a8 f97b 0351 aae2 93da b4c7 4013 087d U..{.Q......@..} 00000890: 02d7 a4da 46ab 4ead c5b0 5bd2 4ad6 d417 ....F.N...[.J... 000008a0: 4b85 153e b9f3 78f1 b1ca e3a4 64e8 2a23 K..>..x.....d.*# 000008b0: 1b80 66e7 1e3d c1d6 738b 8795 910d a92a ..f..=..s......* 000008c0: 41f6 68eb b935 41a5 8a8b f087 206e 9098 A.h..5A..... n.. 000008d0: 93d5 9a9e 18d1 ec21 5885 be00 469a c369 .......!X...F..i 000008e0: a508 5236 8783 8770 6963 b811 0888 effa ..R6...pic...... 000008f0: 3150 a883 2d38 7a37 08c0 6da4 66c7 1330 1P..-8z7..m.f..0 00000900: 20ff 0d8d 265d f127 8ec0 8e7e e7a1 2e46 ...&].'...~...F 00000910: 1867 64ae a0fb 2309 08e4 b1d2 64b6 9ac3 .gd...#.....d... 00000920: eda2 1f50 6985 c08a 2a12 de5b d381 d5d2 ...Pi...*..[.... 00000930: 3d5e cb3d 487b 5b12 65ad 511f 8c44 5d08 =^.=H{[.e.Q..D]. 00000940: 264e 5380 c87c b8ff c6fb bb8e 5000 4d16 &NS..|......P.M. 00000950: 6d04 f197 4ed6 2b06 de4b ea0e 7f16 89de m...N.+..K...... 00000960: dbc6 efbe b74d 473b db7f 2d2d c649 0481 .....MG;..--.I.. 00000970: 0f7b d4ff e394 0520 1599 13f8 1a07 687c .{..... ......h| 00000980: 1eee 196b 8a30 2d8b 591a 6fed ddfd baa2 ...k.0-.Y.o..... 00000990: 84af 289a ba99 0291 0009 662f 5e65 4a41 ..(.......f/^eJA 000009a0: 8053 3aab c021 ba28 f714 d7d2 c733 bc0e .S:..!.(.....3.. 000009b0: b6c4 fd7a fca7 a9bc 54cd 0044 cbe2 3dee ...z....T..D..=. 000009c0: b815 7dc2 04c3 0438 af02 cd02 0a2a ef31 ..}....8.....*.1 000009d0: bc1b d46e 3d31 af38 db31 0639 11d5 1488 ...n=1.8.1.9.... 000009e0: 7178 8970 28e8 302a c9c3 6236 0216 64a1 qx.p(.0*..b6..d. 000009f0: 9ddd e02d 8365 198a f7bf c4e8 fba6 60dc ...-.e........`. 00000a00: 885b 00c2 50fd 2d14 15f3 85ef c77c 4eb4 .[..P.-......|N. 00000a10: e0d3 b318 9a31 f92e a715 9403 749f 0d03 .....1......t... 00000a20: 86a1 969c 4d2f ee8e 1032 1c1d fc88 05b2 ....M/...2...... 00000a30: 82de 4d7f d437 4cc4 518d cb98 4871 e063 ..M..7L.Q...Hq.c 00000a40: b5ed 38f3 b5b0 6a3b 2408 350a ee07 17c1 ..8...j;$.5..... 00000a50: c129 a6b4 ed10 da4c 2778 3f96 f29e afb9 .).....L'x?..... 00000a60: 86b2 685d 9882 70e6 f8c9 2683 b97c 96ea ..h]..p...&..|.. 00000a70: f965 3193 4778 75b8 f268 137b 9871 c0f7 .e1.Gxu..h.{.q.. 00000a80: d5c2 e884 3923 26bb 57cc 40c4 5481 1307 ....9#&[[email protected]](/cdn-cgi/l/email-protection)... 00000a90: 67d0 d400 2be8 b341 bf6a 7408 5b0d 76f4 g...+..A.jt.[.v. 00000aa0: 3a2d 1136 de24 f5a0 789d f080 5d3c 7dfb :-.6.$..x...]<}. 00000ab0: 1570 f2bc b14f 3580 b52e bb68 1b63 26cc .p...O5....h.c&. 00000ac0: c7a1 82d0 dbf4 8687 1aac 37b0 d6f2 54c3 ..........7...T. 00000ad0: 1712 d491 8f7a 57a2 2739 9070 2c09 043f .....zW.'9.p,..? 00000ae0: d5ee 414f 9921 66e6 24a8 f703 e8e0 66c0 ..AO.!f.$.....f. 00000af0: fa60 d390 0cbf 898f 651c 21c8 a333 dad5 .`......e.!..3.. 00000b00: 56db 499b fdfe 7b4c 28c7 fe97 277f 25f0 V.I...{L(...'.%. 00000b10: ad3f e83d 7765 365d d9c9 6c85 5749 7982 .?.=we6]..l.WIy. 00000b20: 4b4e d59b 7257 0313 7925 f86e 012f 7669 KN..rW..y%.n./vi 00000b30: f379 bfc8 309a 6742 15be 5519 b09e cdce .y..0.gB..U..... 00000b40: 222f 9e76 d8c8 c3cf 3d9b 8d56 6a9a 9dfd "/.v....=..Vj... 00000b50: 44c2 6b05 f6aa d8b6 f26a b726 ff01 de24 D.k......j.&...$ 00000b60: 0fd7 cae9 8b0f cb4b 2b63 dbee 340e c597 .......K+c..4... 00000b70: b836 716d 3788 82fa 4dee d5cf f71e d6c2 .6qm7...M....... 00000b80: 1c07 f1bb cc3a 9be1 0fa3 9dee 1fc4 f75f .....:........._ 00000b90: 5398 b922 35b1 a9e9 813b 929c 8186 00a5 S.."5....;...... 00000ba0: c20a fa1d 4585 7009 eef9 f141 0487 613f ....E.p....A..a? 00000bb0: 12a9 c647 5d8e ecb9 9601 785f b449 43ce ...G].....x_.IC. 00000bc0: c610 1bd5 aa9b 9886 174f f3f5 0971 63af .........O...qc. 00000bd0: ee21 508c 6185 61f0 c239 abe0 2a00 a65d .!P.a.a..9..*..] 00000be0: 8285 8892 13bc 64b0 35be 18e2 fd16 98fc ......d.5....... 00000bf0: 8ddd 4269 9e24 e33e 9e55 481d 5f21 2d05 ..Bi.$.>.UH._!-. 00000c00: ddfc 241a fefd d861 8a23 5a5d 104a 3397 ..$....a.#Z].J3. 00000c10: 029d 076e 322e e2be f81b 2010 8cfe 5e35 ...n2..... ...^5 00000c20: 4133 92f0 5eab c5ae 6929 a20d 5617 6a1d A3..^...i)..V.j. 00000c30: 0c85 5db8 aa26 41b1 e892 ba10 4b6c f1cb ..]..&A.....Kl.. 00000c40: 09b2 7906 e007 ec42 2664 82cd d0c5 987e ..y....B&d.....~ 00000c50: af76 160a 38af 3fe2 212f e4b0 302a e099 .v..8.?.!/..0*.. 00000c60: 754d b9fc 83ed bec5 88b6 d45d ec76 efd9 uM.........].v.. 00000c70: db13 2b75 9527 083c f26f 4208 5167 f48f ..+u.'.<.oB.Qg.. 00000c80: 61b7 bcf0 120f 7ba6 bd61 633b 5bf3 01fa a.....{..ac;[... 00000c90: 74b2 7658 b0da 09a8 0d82 4997 6b60 f824 t.vX......I.k`.$ 00000ca0: f95b 3651 2a6c eb46 f539 ec8f 436b b099 .[6Q*l.F.9..Ck.. 00000cb0: 04a5 88ef 07a2 2be9 585d 1a74 2cf9 a282 ......+.X].t,... 00000cc0: ee69 1b53 5e3c db2d 4522 3007 b7a8 ac94 .i.S^<.-E"0..... 00000cd0: a213 7949 13c6 f09e 1c44 f1bd f731 d8ee ..yI.....D...1.. 00000ce0: 40c5 16a5 8509 a623 2a2f b86b 6e45 6f14 @......#*/.knEo. 00000cf0: eb45 759a b7e7 f695 352c dfde db75 4e15 .Eu.....5,...uN. 00000d00: 8f2e fc5b 0482 ca83 7983 07db bed3 de72 ...[....y......r 00000d10: c6d4 ee06 64e2 69ee 50e4 5bf2 d416 e2d2 ....d.i.P.[..... 00000d20: 6970 dc3e f080 6e60 dc3e ce5e e1f0 d13d ip.>..n`.>.^...= 00000d30: b595 a3e3 6908 5d85 101b d60c 2a90 0e7b ....i.].....*..{ 00000d40: a510 0fe8 c1e9 74ef 5fec 86c6 91bf a6bd ......t._....... 00000d50: 1cf9 8359 d3da d74f f724 6869 fe05 3db4 ...Y...O.$hi..=. 00000d60: 1539 0464 be96 ed2c 2ae0 1c1b 618e 1cf5 .9.d...,*...a... 00000d70: 8a0d 02d6 12e5 97f3 b27f 7f94 1ea6 96cb ................ 00000d80: 6760 6627 d7f4 3ff8 a141 0449 ec4d a84f g`f'..?..A.I.M.O 00000d90: 95a8 b5f7 851a 652e 251a 5634 0854 d9d0 ......e.%.V4.T.. 00000da0: 064e d42b 6719 c8a2 03c2 da32 c323 af4a .N.+g......2.#.J 00000db0: c816 7f80 7148 fa7e 9c1b 69cb 0dd4 4789 ....qH.~..i...G. 00000dc0: b5ec d0c4 5ab0 eea2 3759 e2fe bafe 5736 ....Z...7Y....W6 00000dd0: e258 5c6b 6456 b01f 3f44 fbd3 9dbf d294 .X\kdV..?D...... 00000de0: d412 5d38 bb79 e2f2 a38b 6af2 4201 4b48 ..]8.y....j.B.KH 00000df0: ef2b e4be 886d 3668 55cf f5b3 a467 83c5 .+...m6hU....g.. 00000e00: 6709 e88f d985 5026 5d9a f7de 9e43 308b g.....P&]....C0. 00000e10: 41a6 3018 0e07 10bf d3f2 4450 87f8 c329 A.0.......DP...) 00000e20: b258 3b17 af1b 01aa 4723 9b95 4b72 d4de .X;.....G#..Kr.. 00000e30: 8464 b9ab b1af 4caa 3bdb 5e2c dc27 4c69 .d....L.;.^,.'Li 00000e40: 9d05 c2d3 cfe7 057e 8048 a2b4 385b cd6e .......~.H..8[.n 00000e50: 350a a703 5a28 0a6e 88b9 4cb0 b62a 1d12 5...Z(.n..L..*.. 00000e60: 4149 2f24 0643 b321 5f1e e792 8cf4 7e97 AI/$.C.!_.....~. 00000e70: f22b b64e 5452 0780 675c b4c1 a7f6 85be .+.NTR..g\...... 00000e80: b1f6 1e3b ec21 dacb cab5 cbd0 8fea 8da4 ...;.!.......... 00000e90: a277 5857 fedd d992 95fc 7618 1a3c 1e6b .wXW......v..<.k 00000ea0: 8511 2b6a 9919 ea1d e278 fa7c b38f 94c0 ..+j.....x.|.... 00000eb0: 21da 9b2c 11ae 772b 3873 e68b 6ee7 9adf !..,..w+8s..n... 00000ec0: 0d48 e452 f009 3db8 d234 9d57 58d9 f0b8 .H.R..=..4.WX... 00000ed0: 60cd 7fb5 1e7c 5f56 2fde 0a84 55e3 c88c `....|_V/...U... 00000ee0: 2d70 985e 146f d6cb a4e8 6751 6444 82a2 -p.^.o....gQdD.. 00000ef0: e791 d5ea 33e6 9f51 7209 ee4a b4c3 9f2a ....3..Qr..J...* 00000f00: 3e73 32d3 0c78 1a4f 3115 8188 a25e 64db >s2..x.O1....^d. 00000f10: 9a45 3ade 5bb2 75e6 fa5a 1718 b1f2 80e6 .E:.[.u..Z...... 00000f20: 722a ccea f225 be6e d483 78fb 5218 c841 r*...%.n..x.R..A 00000f30: 9e28 b0fd b787 c7cc f04b 5039 d612 1bd7 .(.......KP9.... 00000f40: 6fa8 5447 f0f5 b62e ebf8 f098 41ec 27f0 o.TG........A.'. 00000f50: 92be db83 5c1b 52be 53d7 42bd 2268 0eb7 ....\.R.S.B."h.. 00000f60: 02cd 2c8b 34a4 4d24 8f23 1840 96e5 abd4 ..,.4.M$.#.@.... 00000f70: 92f5 8da2 92b3 3619 97f3 767c 2269 d7a9 ......6...v|"i.. 00000f80: bb3f aadb 2ddd 3208 2aa1 41a2 fed6 d326 .?..-.2.*.A....& 00000f90: de71 f82c 4803 c531 5be1 275a 9c7d 6880 .q.,H..1[.'Z.}h. 00000fa0: 690f b052 84aa 0d00 3ef7 9b5c 5e5a eadf i..R....>..\^Z.. 00000fb0: 4991 2419 9bd4 2d99 a328 6064 65a5 f6d5 I.$...-..(`de... 00000fc0: 9d0f ab33 7dff 08e7 4a22 66b1 1197 a591 ...3}...J"f..... 00000fd0: 7936 470f ad58 1c1e 0bb7 43a5 15da daea y6G..X....C..... 00000fe0: 0c68 f252 d625 d615 7725 0cf0 9c22 9e44 .h.R.%..w%...".D 00000ff0: bb0d 87b0 7e4d deb8 7015 aef4 0d4c b564 ....~M..p....L.d 00001000: f0d2 024b 40da ac56 b792 ca09 0976 39cf [[email protected]](/cdn-cgi/l/email-protection). 00001010: 41ef 3992 abae 029a 7f4c 60f3 0b0c 9edf A.9......L`..... 00001020: 5940 3460 36e5 87ad 7181 655d b8f3 f014 Y@4`6...q.e].... 00001030: 90fc 356b e547 a3d2 86e5 4502 3a6a 61a8 ..5k.G....E.:ja. 00001040: 2fc8 ee5a a54b 936a 9d44 77ff cd97 51b6 /..Z.K.j.Dw...Q. 00001050: 5cd2 c7c2 a832 1083 b778 8d41 76be f143 \....2...x.Av..C 00001060: 6b7c 9036 90c0 2079 ccb6 9a9a 58b6 36d3 k|.6.. y....X.6. 00001070: cb12 cb72 4469 72dd af7b bae2 25ba a139 ...rDir..{..%..9 00001080: f891 9a17 9fc3 ae79 4783 41c5 828b b816 .......yG.A..... 00001090: 64ca 032f 9e1d c279 ecad e5ed 14a9 a668 d../...y.......h 000010a0: 3cad d0e6 f3a2 9a82 972e d2e7 ac6b 4094 <............k@. 000010b0: 31bc c2e0 4339 1cfe 1224 da7b 1007 4386 1...C9...$.{..C. 000010c0: ff0e ab8b 67cf b597 b821 6133 2e4b 38ba ....g....!a3.K8. 000010d0: c96b a7f3 ae2c cc62 6c40 5ed6 9f85 a844 .k...,.bl@^....D 000010e0: 9247 fc59 0251 ffa2 4302 64a9 2171 a1b2 .G.Y.Q..C.d.!q.. 000010f0: b4f9 dad2 f916 44f3 7fc7 090b 4524 696f ......D.....E$io 00001100: 9a59 9de0 3079 88c2 a8d7 562d 39a3 26e0 .Y..0y....V-9.&. 00001110: 2deb 5c6a 2c50 2f6d 7c9f 6d07 2e8d 0429 -.\j,P/m|.m....) 00001120: 0c6f 2ce9 b0d3 3398 3e43 2d80 4b99 ca05 .o,...3.>C-.K... 00001130: 034e 2827 c116 d5be 5ef7 2b65 2cce 6c2d .N('....^.+e,.l- 00001140: bb8f 3b49 a389 ed1c 1b94 fc27 f6f8 36c4 ..;I.......'..6. 00001150: 302e 18f1 f584 5f23 4a59 a015 0d34 4a8f 0....._#JY...4J. 00001160: 9d7c 62b7 0fcc 9517 1a36 0bdc 78f2 3c3d .|b......6..x.<= 00001170: ed91 cd17 e37b e74e 8f7f d9e8 1046 9277 .....{.N.....F.w 00001180: de99 3e43 8114 6554 5bb8 f7e4 4821 cb8b ..>C..eT[...H!.. 00001190: a56b 5263 310f 8c01 7704 e268 da74 f05f .kRc1...w..h.t._ 000011a0: 3c4c 0e04 7114 f3cd 9de3 c5f8 f532 8f9d <L..q........2.. 000011b0: cae7 361f 0ef4 c89c 5e26 8ba7 5c5f 1421 ..6.....^&..\_.! 000011c0: 4d18 6659 8f28 5dcd 171e cc84 f5dc 610b M.fY.(].......a. 000011d0: 595f 8427 5702 eef4 863f 7d71 9eb2 8851 Y_.'W....?}q...Q 000011e0: 4700 5b05 9935 c7b1 57de 75d5 d4a7 2d56 G.[..5..W.u...-V 000011f0: 0bc6 6486 c6e4 1d73 d834 dcaf 6aeb ab44 ..d....s.4..j..D 00001200: 573c d196 bfb1 5fb1 cd20 7c1c e2d7 61a9 W<...._.. |...a. 00001210: 29cb 8fbc a0b4 f22a ecae cf6e a8c3 2795 )......*...n..'. 00001220: 9288 95a6 8b8a e7b6 8649 0387 a0d2 28da .........I....(. 00001230: 002a 8dd2 16d1 a685 8fba 3d49 6b57 6743 .*........=IkWgC 00001240: 3ea3 252c 49ac a8d7 b991 55fd facc c0c9 >.%,I.....U..... 00001250: 417c 7e02 bd9d 320f 3e66 c879 b487 1574 A|~...2.>f.y...t 00001260: 17f3 ed1f d6b5 a1e4 e725 628f b933 5644 .........%b..3VD 00001270: e26b d0e1 14ed d598 f3a9 d210 9a0d eb24 .k.............$ 00001280: 1f70 71c1 635d 0e23 01e1 e7b8 11cb cc41 .pq.c].#.......A 00001290: a8d9 a937 3246 5114 d881 415f 96f6 4554 ...72FQ...A_..ET 000012a0: 26e2 f6d7 b611 0f84 b92b b0c5 b3ee 3df0 &........+....=. 000012b0: b295 8cd9 211c 10f9 9020 0f1d 002b 600f ....!.... ...+`. 000012c0: cbe8 0541 dbc4 2de5 6c87 f0b3 40b0 2fca ...A..-.l...@./. 000012d0: acd2 8925 3ab2 8724 edf3 4a09 34a8 10b4 ...%:..$..J.4... 000012e0: ea9c b3ea 3aef b87c 8a5a 5289 3c94 44bb ....:..|.ZR.<.D. 000012f0: 57f5 65a1 30f1 1b03 caf7 4fe0 91fc 23f6 W.e.0.....O...#. 00001300: 82a9 5545 c245 92b6 23a7 8f5f 1995 f955 ..UE.E..#.._...U 00001310: 3165 82be aeab a3a3 52ee 64ea 7d92 7178 1e......R.d.}.qx 00001320: 8988 b358 1a67 b483 c959 83a3 d9eb 2a1c ...X.g...Y....*. 00001330: 99f3 3c1a e9d0 3974 7a30 ccf7 faca 3ca2 ..<...9tz0....<. 00001340: 01cc 5e18 b367 e962 7df0 6796 cae4 7a76 ..^..g.b}.g...zv 00001350: f005 3c80 1812 baea da78 8a88 9ff5 e081 ..<......x...... 00001360: 5160 9cf8 8b8a d39d b766 7e8b a6ae 865e Q`.......f~....^ 00001370: aba3 6d01 4e10 c523 7370 3de3 304a 84e1 ..m.N..#sp=.0J.. 00001380: 9bfb c6f6 15d7 08e5 bff9 6ab9 0dc2 6d6b ..........j...mk 00001390: 6722 e527 c015 9176 c460 b124 7526 a33d g".'...v.`.$u&.= 000013a0: 1511 d61d 9893 672c a8d3 071d 85d7 69f1 ......g,......i. 000013b0: c74e 8a4a 760f e7ff 736d c9b1 9d69 1916 .N.Jv...sm...i.. 000013c0: becb 8aec 9c45 ae14 25a5 7992 8a5e dd80 .....E..%.y..^.. 000013d0: 5359 91ee 6276 e058 6164 c9d1 2946 6a3f SY..bv.Xad..)Fj? 000013e0: 852a 5eff 300d e344 e2de 3a94 bb8e dd19 .*^.0..D..:..... 000013f0: ecb2 0413 bbdf 84a3 7e19 88f4 7314 85ea ........~...s... 00001400: 66d9 d10a 149b 554c 2001 1bbb 4aff af4e f.....UL ...J..N 00001410: 73ce 1753 7803 6cb3 9a9b aeac 50b9 9522 s..Sx.l.....P.." 00001420: 58af 7fec c355 59a0 0487 db4e b418 9d77 X....UY....N...w 00001430: 2ca5 5d88 01f6 8f34 4906 fc9a 8fd0 c7fc ,.]....4I....... 00001440: 088f b2db 26d2 7b89 d2b9 58e0 3e0d 5b69 ....&.{...X.>.[i 00001450: 65b8 548f f5bf 592d 7caa 3053 3d8e 1507 e.T...Y-|.0S=... 00001460: 23e3 3a4f 2652 9f8c 539b 24ab b4f8 0cc9 #.:O&R..S.$..... 00001470: 7677 59f3 74fe 617b 8db3 bec8 fd54 34c2 vwY.t.a{.....T4. 00001480: ca92 2c34 57a5 0741 c5a1 40f5 9be4 d8ef ..,4W..A..@..... 00001490: f1ea 38d0 2bb4 abe2 0796 e96c dd22 eacd ..8.+......l.".. 000014a0: 30d2 7b6e b91c 3016 5059 1f8b 8f9b 4dd8 0.{n..0.PY....M. 000014b0: 56ce f3d2 a345 130b d9db dd9e b09b c0f7 V....E.......... 000014c0: 6e44 f4f2 bd96 3976 e9e6 285c 46ad e24c nD....9v..(\F..L 000014d0: 436a 5833 59a9 790f daf3 c618 c3c7 da76 CjX3Y.y........v 000014e0: 4e0a 16ba f981 5bab 9282 eeaf 44a9 e047 N.....[.....D..G 000014f0: f9de 9098 ecf1 6d2c 6dcf 8be4 bc67 2801 ......m,m....g(. 00001500: d582 336f 9c3c 9679 56c3 7de9 f536 b7b4 ..3o.<.yV.}..6.. 00001510: a16e 3347 c6a9 27ff 26a9 ab7e 0746 8fc6 .n3G..'.&..~.F.. 00001520: ef07 144c 461d 9f81 dfcb b724 3434 7121 ...LF......$44q! 00001530: 5da3 a2a2 ee40 c23e f0bc 261b 4d27 7f06 ]....@.>..&.M'.. 00001540: 842d 6195 6ec4 4ac2 d7db 8758 de4a 3a2b .-a.n.J....X.J:+ 00001550: ddb4 4b91 94b3 aa36 2f6f b065 3a51 d27a ..K....6/o.e:Q.z 00001560: 7350 e7ab bff6 b779 e89a 048c bfef 7ff0 sP.....y........ 00001570: 95e9 c771 7415 e97d 5dfc 1947 243f 0818 ...qt..}]..G$?.. 00001580: 4353 435e 50d4 f0e4 0754 5e3b 22b9 4030 CSC^P....T^;".@0 00001590: 28a4 0aca 2421 e3fa 625c 4a5c b62b 17c4 (...$!..b\J\.+.. 000015a0: f7d8 f044 cc1f 3a6b 4be6 d8e4 83c6 09d3 ...D..:kK....... 000015b0: 78e6 6a1b 50b4 3220 0efb 739b 1200 0621 x.j.P.2 ..s....! 000015c0: 4d51 5ac0 7aa3 0544 5715 46b4 869a 4f6a MQZ.z..DW.F...Oj 000015d0: b814 01f3 5280 57ed 0c7a 025f 68f6 ea96 ....R.W..z._h... 000015e0: a655 51b4 4fcf a63d 5385 6c95 f438 7d01 .UQ.O..=S.l..8}. 000015f0: d43a db0a 6e55 6f3a 6235 f2e6 813a 03f8 .:..nUo:b5...:.. 00001600: a506 33ee 412c 94be d61b 5a56 151e 7405 ..3.A,....ZV..t. 00001610: 5f97 0055 8bac d6ba 5951 3a6f 56c2 6a46 _..U....YQ:oV.jF 00001620: a943 c889 bd12 82bb 9655 06ed 1cf7 7397 .C.......U....s. 00001630: a6c8 7778 458a 0808 ebf4 f0e9 74a0 49a8 ..wxE.......t.I. 00001640: 0431 0d5b 6d0b 370a cb1b 05f0 6e65 c90e .1.[m.7.....ne.. 00001650: cf65 8af6 a4b8 0f06 9517 de7b 3c37 6325 .e.........{<7c% 00001660: be4b bbb7 51f7 d670 7612 a5b5 29b4 da2f .K..Q..pv...)../ 00001670: fed7 1c95 269b 43aa 7814 4376 d183 72a0 ....&.C.x.Cv..r. 00001680: d815 40bb 8dbd 5425 3132 0273 a9eb 82f0 [[email protected]](/cdn-cgi/l/email-protection)%12.s.... 00001690: 2db9 f045 aee1 963e dc2f 5ef1 7833 9a32 -..E...>./^.x3.2 000016a0: 2f7c c2b0 d20a 48e9 85e6 679d 84a3 2386 /|....H...g...#. 000016b0: cf44 9511 402f 95d8 28af 4861 4d60 e957 .D..@/..(.HaM`.W 000016c0: b96f 8be8 201c a3d8 124f ab95 7bb5 e237 .o.. ....O..{..7 000016d0: 725f 7b5e 72e5 5ed1 4189 cf1c bdbb a1e8 r_{^r.^.A....... 000016e0: 2626 117c cf18 2425 1831 51ea 09d4 3521 &&.|..$%.1Q...5! 000016f0: 9841 40af f399 ccd7 0d3f 7b54 7b0e 06ad .A@......?{T{... 00001700: f8e4 0f59 764a 42c7 4edd f581 711c 400c ...YvJB.N...q.@. 00001710: 24e5 93f9 1d89 3d40 84d1 0336 860a f868 [[email protected]](/cdn-cgi/l/email-protection) 00001720: 7055 e149 d8c8 2b6d 6b26 44e6 8a80 40f4 pU.I..+mk&D...@. 00001730: a41a c18a 5305 fb9c 08e4 69c8 2007 21ac ....S.....i. .!. 00001740: 32c8 1deb 33a9 5ef9 037d e272 37eb ee7f 2...3.^..}.r7... 00001750: 6b02 77ed b59d c55f 4e4c b8ac 9a84 a064 k.w...._NL.....d 00001760: e63f 9421 54b2 8357 99c0 08e1 b6de 76e4 .?.!T..W......v. 00001770: 75d9 3a7f 093b b674 a0f4 4c67 4e13 104a u.:..;.t..LgN..J 00001780: 6fd1 7916 76fb ee71 8d19 66c6 f2bf 0eb3 o.y.v..q..f..... 00001790: da5f 2d96 0d2f 5645 2ccd 3e53 5f46 6b11 ._-../VE,.>S_Fk. 000017a0: 0629 8576 bc0f 56f1 7230 f6a1 d53f cfe8 .).v..V.r0...?.. 000017b0: 7c4b ca50 1ee3 707a 551f 5809 3526 b3a8 |K.P..pzU.X.5&.. 000017c0: fb66 3b81 b710 7de1 5514 9b09 9878 65b1 .f;...}.U....xe. 000017d0: 27b4 8c4f 4e93 c1e7 d4be 4846 8ebf b855 '..ON.....HF...U 000017e0: 1cd0 9659 8d83 d273 bf98 7777 92af 1c8c ...Y...s..ww.... 000017f0: 6745 85e5 369a f9b3 1d93 8457 5f92 a87d gE..6......W_..} 00001800: 4eeb be26 c0d2 899d 1b0a d11f 71aa cdaa N..&........q... 00001810: d1e1 396c 2605 d809 befd 77f0 3ac2 15af ..9l&.....w.:... 00001820: 1a86 c0b9 d70d b03e 5fa6 67cb 96df 1eb7 .......>_.g..... 00001830: dbee 739b d4d0 c3df e2cb c913 42cd 5b73 ..s.........B.[s 00001840: 0820 d8cd 0c0f 427e 5065 b3e9 dac5 2c23 . ....B~Pe....,# 00001850: 10c3 f632 1165 01e9 da04 28e7 1830 caee ...2.e....(..0.. 00001860: cb36 4ec2 7852 201f f9cf 3f37 9900 3a6d .6N.xR ...?7..:m 00001870: 9481 7850 553b 6dbc ede6 2a12 e1e8 2b6d ..xPU;m...*...+m 00001880: a2a9 5407 0e12 1132 fb7a 5ecc 7217 37b8 ..T....2.z^.r.7. 00001890: 1105 cefe fe01 9bc7 bf55 b7a2 0a7b 5f91 .........U...{_. 000018a0: b0d4 c6c0 98fd 0983 2e4c 09d4 2b5e 783f .........L..+^x? 000018b0: bb80 a0b8 ca37 c067 87f1 e56b 03b5 c83a .....7.g...k...: 000018c0: f155 2fcb 899a 99ce 11b9 b74f 8fd8 c924 .U/........O...$ 000018d0: ad87 0ca7 7311 6b90 7d90 4fd0 86de 3242 ....s.k.}.O...2B 000018e0: f934 ab9a fce2 3a12 c8ad b862 18c1 4736 .4....:....b..G6 000018f0: 7b97 a1af 6dd3 a102 6616 c46c c411 f6a9 {...m...f..l.... 00001900: 6481 0017 1c38 15d4 27c4 9511 13b2 d38e d....8..'....... 00001910: bf6f 68ff aa2e 8a37 0bfa bf3f 6404 ae32 .oh....7...?d..2 00001920: c211 3d11 ffbb 2ab2 f3cf 9640 c3b4 ec26 ..=...*....@...& 00001930: 7c9e 39ff 2f19 3162 7a30 8c03 1039 52bb |.9./.1bz0...9R. 00001940: f758 cf31 77f9 402d e631 4305 e259 ea91 [[email protected]](/cdn-cgi/l/email-protection).. 00001950: f903 eb3d e0e1 41fa 1e0a 10a6 c00b 375f ...=..A.......7_ 00001960: 7290 d4d2 5eca f1f2 e6f1 9be9 39c0 8382 r...^.......9... 00001970: c37a 3d92 6c20 333d 3a66 7b80 c965 f72f .z=.l 3=:f{..e./ 00001980: 4cc6 613a 31e5 28dc 2b60 2e5a 29bb 4249 L.a:1.(.+`.Z).BI 00001990: 288d 1190 d7f9 a064 f598 e3b5 4017 b94b ([[email protected]](/cdn-cgi/l/email-protection) 000019a0: 7f02 0e11 09ad f758 7d70 6283 cc57 1420 .......X}pb..W. 000019b0: 443b ec72 18fe 7fce 1cef 5fcc d6a7 f751 D;.r......_....Q 000019c0: 8586 80ce 83f9 ece5 e8aa 062f be38 79b3 .........../.8y. 000019d0: 0f4a 98fe 083c 60fc f20e f819 c488 565b .J...<`.......V[ 000019e0: 7aab 29c1 619e 8720 1078 b002 dcd1 2a46 z.).a.. .x....*F 000019f0: 950e b15a faf9 a195 a976 82d8 bb4b 38df ...Z.....v...K8. 00001a00: e29c bbff 1029 60fc 2b09 ab8a 7c4b 92df .....)`.+...|K.. 00001a10: f151 9371 fb97 d64c 28d4 025d 337d 98d4 .Q.q...L(..]3}.. 00001a20: 13e3 dfc9 a442 d740 7adf 31c6 4bb7 8779 [[email protected]](/cdn-cgi/l/email-protection) 00001a30: b558 49a9 6975 2860 0ce6 15b1 63de f3d3 .XI.iu(`....c... 00001a40: 1f3e b142 a68c 796b d490 8eed 7d19 a576 .>.B..yk....}..v 00001a50: 5901 38d4 6261 4674 06f4 e153 d9d2 9fa7 Y.8.baFt...S.... 00001a60: dd5f 196c e897 b843 aa7e d687 fc2f 48c3 ._.l...C.~.../H. 00001a70: e62a 9624 143d ba92 dddd e20c 2a24 f84c .*.$.=......*$.L 00001a80: b7de d83d ecdb 2e64 0d3a bd55 bbd4 70ea ...=...d.:.U..p. 00001a90: dedf 4ce7 deed 7bd3 7ff0 77f1 271a f586 ..L...{...w.'... 00001aa0: ed9c 01de 4704 af77 e59a 5cc6 0b8b 2dcb ....G..w..\...-. 00001ab0: 2361 7401 6bca 5d5f 514a 842c dbf8 a04b #at.k.]_QJ.,...K 00001ac0: 52c1 eaa6 8dcc 53a1 cf4c d423 4c52 f8a5 R.....S..L.#LR.. 00001ad0: 1a36 d859 9b10 9689 dcbd b304 502a c279 .6.Y........P*.y 00001ae0: d32b a849 9433 c345 a982 65e0 46d3 4bf1 .+.I.3.E..e.F.K. 00001af0: 0275 808b 6000 4859 d8ca 5eeb 0917 b21c .u..`.HY..^..... 00001b00: 8e76 b2fd 7b90 9702 aa71 ee4f 384d 012b .v..{....q.O8M.+ 00001b10: 6cea 0f6a 5d90 b451 88a2 953a e90f 61dd l..j]..Q...:..a. 00001b20: 6cdc e29b 5d7c 1d69 bafc f0ae 07a0 b4f7 l...]|.i........ 00001b30: a819 aedc 3602 170a 2235 a55c c943 07c2 ....6..."5.\.C.. 00001b40: d3af a1e8 4c40 42be 8edf e1e7 0903 51a0 [[email protected]](/cdn-cgi/l/email-protection). 00001b50: dc65 278c 1e69 8be5 8d0e fffb 47e7 b1e7 .e'..i......G... 00001b60: 2637 41ae bddc 6169 3257 a9bc d752 37bb &7A...ai2W...R7. 00001b70: 77b9 59cb 3242 74ac 06e7 d284 a605 f812 w.Y.2Bt......... 00001b80: 701c 3b8c c955 2c60 7b45 1622 7ff2 976d p.;..U,`{E."...m 00001b90: de41 bc17 d9ac 6423 b8c9 390c 5ac2 7855 .A....d#..9.Z.xU 00001ba0: f3fd 712a feb0 9fb2 e1ec c97c e094 f48e ..q*.......|.... 00001bb0: e5fc 6cf9 c5e3 c693 3f7c c5ad 746f f725 ..l.....?|..to.% 00001bc0: d7cd 91a8 0275 f351 0d6f 2df2 569b d5d1 .....u.Q.o-.V... 00001bd0: 7d1a a306 07e1 1677 a07e 3825 9ad3 f394 }......w.~8%.... 00001be0: 879a 62ae 5604 fa92 dee7 7935 335b f7ff ..b.V.....y53[.. 00001bf0: b1b1 2523 9eba 7bdd 71dc 3644 400c a87b ..%#..{.q.6D@..{ 00001c00: 3be5 0612 bc82 e857 38ed d5f1 bb8a 31b7 ;......W8.....1. 00001c10: 111e 2085 4a1e fbf9 4eb1 3933 3345 4349 .. .J...N.933ECI 00001c20: 81c3 b793 ca52 1b25 b21f 21dd af59 04bc .....R.%..!..Y.. 00001c30: 53b7 e489 a4fa 071a 25e7 ef90 df8e 0306 S.......%....... 00001c40: 16a9 d5dc d548 313c a659 48bf c71f 47eb .....H1<.YH...G. 00001c50: 47c0 8ecf 1ded 39db 6c45 a9a1 9c95 d436 G.....9.lE.....6 00001c60: c13a 34b4 4d31 7531 2bcc 17e2 5b0d 5257 .:4.M1u1+...[.RW 00001c70: bc85 dd3e 3a1e 4c48 38ca ce79 06bb a778 ...>:.LH8..y...x 00001c80: fc21 c861 d6e6 3f20 fe17 fbe5 0eb0 3c8d .!.a..? ......<. 00001c90: cf83 44db 9468 354a 0e94 c734 89ab 9ef1 ..D..h5J...4.... 00001ca0: 2f1a 2c00 1684 2dbe 3989 ad48 7e49 1abe /.,...-.9..H~I.. 00001cb0: 135c ab2a ddfd 77ec 5d75 cc54 fe00 31 .\.*..w.]u.T..1 ``` [Answer] # [Ruby](https://www.ruby-lang.org/) -rzlib, ~~85~~ ~~82~~ ~~80~~ 77 + 1 + ~~7309~~ 7308 = ~~7395~~ ~~7392~~ 7386 bytes ``` Zlib.inflate(IO.read'f').bytes{|i|$><<('%8b'%i).gsub(/../){$&.oct}};$><<?1*31 ``` [Try it online!](https://tio.run/##db1ruxW1Ei38ff@KljuoodOddBJBQAQEEUQFLyBCrggiolzk6k8/@x2jOj3Xcr/nrOfZa6Mya6aTStWoqlHVf71Ir/97/9WrMnz816AePnn64rl6/vCP4czQ7v/n/pkj0/B3xh//e/vxw4T/3B7H5/XYla/VXzWWo@3ocZVeP6/P3r57@O7QmdOnjx097NPRww@PqwfPXqRjJ5U6efztoSPqj/z8/ftT/Btn9YlZ//e/Y//5ZHA@5EHb4oaWzDyUybshT/M4tLGWwZSahjnnNgyvFH4@x/9Gpa6p0@o/qwQNGTkUM4whTENzZR6mir@fQs1DzLkM1U4F35D9MKj9Px@rTcYEGWNI0xAW74ds8PftNOkhuop/zN5gCT4OPo6bjI@//YD/d1rtZMyQobNpQ4j4dlOnMMxB44HclAeb53moCSuajbOQ8bVS148HpT76eVbKvOgyDGWU2oZpSiMWg2@fRNCUzWDSFIfqwziUMck6DnAJxyd19YTaW4flfthxHEadwuByadiUVoYxzXWY8cdh9tUNDkLWZ3nHX2fOKq/ebzIWyJjaNA/aNT1MI76zubRAWjLDEheso@Kpcg16GE4eVGoQOY8eqY9263CQsbSC79TLsn4cJxqGRUdsj501ntSnIacch@EPpRuXEdVFve9ZPGS0hoedZq2HUvCn1GIdSsKvtBj8u9bqUIuTZzm4nexn@N/bLiNwP1KxEBTiMBeco4nUlNosHrIuw9g8vyFP6358qr7Eb6gu5HUZETJssm7w2bghmjjiHx01Jbkh@ckP1kH41Bpk3PlBfaHUHarr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zaWgQtXMWR@HM4cC3UVWZN35byGMXhq95uGdedRny/rl5Zq8X8Rj5iF6zJZrv5lgCX3k4QWMri7jDs3Cgv/HgoUCALoP2o1ENEMQ1vtKoEo8RRnHIA8eANY6ms2GdD/P72W/@@XWH67oMsR9svi4LC31G3nwCu@d8YLoM8BbOC/EZO0@Hl@fVK/Pwb4Cywm3tMZDM/xjZCyXvjF2mPPLtmbz7fCUECwaZb7jzoZpd/kPm2asd9zyv88c4KYNT7DQZo1mKz5YzAChy4StCK/3F9n6xJxfXHen5D5n/kUiQcnx9KDAgX2I5sXUus2eKzP5Zxho53tsfXnMrP@jF9T@7DIlfOM0m@SKjtVlbwAVZNLs8Co6pcSQzLEnavXflbvzj419272rVMv@jyYhSaQLga3@thcGAy2dZPlu@I0dGvPU8zGPBDhel8aTLkPffCoOFZmKM8kZBvn134ftLGAc0ttGvdY8@M2NWF/fbQpn/wTZt1p1lpHUlG6eQgM43YIVlDYla7P3ZDH/eqy@@2S9D8qdOmtwTceRIchMHy/JsF2G0pcaBBN2O4b4dQ8T/x823ezK8vAOTzFVX6PcnTgvEOS4O5lU7Mpz2fm6shImTD2AO/88fT58//OPJs/9@/Nebxw/T/wc "Ruby – Try It Online") (Credit to @ovs, whose header code I borrowed from another answer to make this work on TIO.) Uses `1`, `0`, `8`, and `9` to represent `A`, `C`, `G`, and `U`, respectively. Requires a binary file named `f` in the working directory, with contents (hexdump): ``` 00000000: 789c 15d7 fb43 d287 c230 f0ed 4deb 3ccf x....C...0..M.<. 00000010: c9d4 0992 f7d3 2ecf b9ec accd e52d 15c8 .............-.. 00000020: 09b2 9688 c42d 5221 a7e8 cc84 3c8a 8a08 .....-R!....<... 00000030: 1c4f 9acf 4e29 3913 d72c 5c33 ebec 3475 .O..N)9..,\3..4u 00000040: 1def 22b0 96e8 2e29 32c4 4b2a e890 d0b8 .."....)2.K*.... 00000050: c500 01b9 7cdf f7fd 0b3e 3f7f 38e7 7d0b ....|....>?.8.}. 00000060: 2f23 17f1 2090 f7b6 7cb4 6a6a ee2c ce91 /#.. ...|.jj.,.. 00000070: 6fde 3166 f7b6 f0e9 61af 4531 1d8b cbca o.1f....a.E1.... 00000080: ffb8 2311 ddb8 bfae dbae b641 dffe ed7b ..#........A...{ 00000090: cbd5 ff9a 3d8a 4a92 fef5 2fe6 0f88 23c2 ....=.J.../...#. 000000a0: 5b57 8c47 a4a0 5b78 c4b7 b828 579a 2ff2 [W.G..[x...(W./. 000000b0: b737 c77f 3ed3 bb5f fcfd eefd a1f5 92a6 .7..>.._........ 000000c0: 4728 2879 0733 091d cdd3 11af f90f e374 G((y.3.........t 000000d0: 4783 cc56 d999 9fea 7ecc 0999 fd86 ad96 G..V....~....... 000000e0: 14f5 5fc5 bd75 d73a fccd a8e1 5698 e15b .._..u.:....V..[ 000000f0: cf81 d817 6f55 47f5 2e34 0fa6 ffb6 7476 ....oUG..4....tv 00000100: 4475 3f75 2746 fca7 7f54 1167 ddd0 af4e Du?u'F...T.g...N 00000110: f3ef 9e7c a226 03e1 8454 6c22 aa70 d272 ...|.&...Tl".p.r 00000120: 6a22 bb6e 827f f68b bb8a f793 ffc3 04d9 j".n............ 00000130: 260f 085b 0fc0 e871 c4cc b9a6 7103 31bd &..[...q....q.1. 00000140: 0e63 7c0b b40b e722 962e 8aaa b5ff d0c5 .c|...."........ 00000150: 16ea b8b0 e18f ceda 3a4b 92bb b6da 83dd ........:K...... 00000160: 54d2 0e91 e40e b1d6 f719 c1c0 d84b 28f5 T............K(. 00000170: 503e 3959 16f8 5047 26f0 857c 757f d78f P>9Y..PG&..|u... 00000180: f373 8f25 7fcd a050 4060 73b0 ec44 6cde .s.%...P@`s..Dl. 00000190: c4ac 7902 377b f7b3 af78 1662 80ab cbbf ..y.7{...x.b.... 000001a0: 9343 f3a3 c9e5 8d09 9e41 cc29 709d 454c .C.......A.)p.EL 000001b0: 721a 8fb2 431b 68a3 379e c70c 6d76 652c r...C.h.7...mve, 000001c0: 77a5 c208 87e4 ef5c 341c 4bde f47f 9126 w......\4.K....& 000001d0: 7aea 9448 0e61 e99b 9a87 8f8f 27bd 817d z..H.a......'..} 000001e0: e6c9 ad2e 97ec d306 ffab 1cca 02a5 bb0b ................ 000001f0: de23 9410 65d1 051e 4387 0343 21df 6e74 .#..e...C..C!.nt 00000200: fa5b e036 7e40 1edf d397 a32b dfe7 a85a .[.6~@.....+...Z 00000210: 6448 aefb b279 0420 da09 7de7 54c4 f1d4 dH...y. ..}.T... 00000220: 827d 5d44 7ec1 c96f e5ea b8ad 994f b4c7 .}]D~..o.....O.. 00000230: 3da7 65c0 7bc7 4ee8 72e2 49f3 bf5a ecb4 =.e.{.N.r.I..Z.. 00000240: 2f5b 170b 92ea a9d3 15d6 931d 71c2 64a1 /[..........q.d. 00000250: 355a bf9f b098 bf66 aa0f 8acb 9ab4 4c31 5Z.....f......L1 00000260: 3a7e a0b7 a251 f0bb 69ce 4e1c f8ff 3cd1 :~...Q..i.N...<. 00000270: efb8 4bf2 1c7d 03ab 52e8 adb7 5f90 2c24 ..K..}..R..._.,$ 00000280: 677c e6b8 a7d3 f3f6 3d92 3173 9cd8 e9b8 g|......=.1s.... 00000290: 4fb7 b6db 1cfc 1126 6f1f 2e6a cb5e e7ec O......&o..j.^.. 000002a0: efb6 e254 5774 be01 3cef d1b1 f8f3 3dc3 ...TWt..<.....=. 000002b0: 34ba 8574 90d6 991a 14bf 3947 7c85 d0e9 4..t......9G|... 000002c0: 4cdf bb48 43bc 0c15 58b0 5fe4 19dd 7843 L..HC...X._...xC 000002d0: 8f22 630f 9b89 9e28 929c 7bbc bfaf 38e8 ."c....(..{...8. 000002e0: d79c ed55 bb7e cc27 2268 7939 9bb0 9065 ...U.~.'"hy9...e 000002f0: 9601 8bad 4e47 c83e 1908 c19e b703 03ac ....NG.>........ 00000300: b089 557a b838 9cae 5bc7 b831 4262 cf9d ..Uz.8..[..1Bb.. 00000310: 3c0c 8536 3e1f a490 e0de ceca 2375 ff90 <..6>.......#u.. 00000320: 26d9 296d 9b25 60b6 32c6 4e72 a021 3977 &.)m.%`.2.Nr.!9w 00000330: dd3e 21bd bb3e a15a a9d1 77a7 3ef7 517b .>!..>.Z..w.>.Q{ 00000340: a76b c72c f084 c311 cf85 64da 0057 2720 .k.,......d..W' 00000350: 4b3f 8fc6 4158 63fd 274b 7b32 caf1 f03e K?..AXc.'K{2...> 00000360: ff78 d87c 8a1c 7492 f639 99d6 3358 2aac .x.|..t..9..3X*. 00000370: 9181 d30c 20f2 9fe8 6590 0890 b201 4f95 .... ...e.....O. 00000380: 94cb 0e53 4bea 718a 839e 19b4 9b5e 205d ...SK.q......^ ] 00000390: 1be4 11a0 2721 6328 1525 226e 925c 4428 ....'!c(.%"n.\D( 000003a0: 2704 460d 8aeb 2e50 7cc1 f8fa b201 57d9 '.F....P|.....W. 000003b0: 15d5 526b 22a4 718b d175 52af 5851 526e ..Rk".q..uR.XQRn 000003c0: 6088 2f0c 0c91 efe3 7608 2c11 61b4 5afe `./.....v.,.a.Z. 000003d0: f377 9218 592e 40c9 d21d dd7c 16c9 57d9 .w..Y.@....|..W. 000003e0: 24b0 619a e238 33a9 1aff f876 90c2 e6e8 $.a..83....v.... 000003f0: f68c 565b 8e81 8dca 15a3 9f49 3ac1 02c3 ..V[.......I:... 00000400: bce7 805d 0a79 8218 ee46 927f 78de 9058 ...].y...F..x..X 00000410: 2270 34fa 1675 15b9 5609 f616 9eac 2793 "p4..u..V.....'. 00000420: c07c 914e 60c7 66ef d2d0 8cc3 5904 98dd .|.N`.f.....Y... 00000430: a769 77ec e45b 1ff7 a484 c1f6 b6b9 a830 .iw..[.........0 00000440: 9baa 53f8 5e6d cd0b bdc4 5a32 00e0 da0c ..S.^m....Z2.... 00000450: 1b41 89c4 b6c9 b01c 52eb a7e7 fcb4 bcc6 .A......R....... 00000460: 2ca4 9319 60ff ef47 0f1d f5f6 9cd5 fbcd ,...`..G........ 00000470: c574 2841 4418 872b 6c19 73ce 1314 5a73 .t(AD..+l.s...Zs 00000480: a76d 37c7 bb4f fd95 56e7 425d 2563 8f51 .m7..O..V.B]%c.Q 00000490: 2947 e6cd 9d89 176a bcb8 ea8f 551b 1735 )G.....j....U..5 000004a0: 0445 c980 41af 1e5f 0530 f68c 116c ceca .E..A.._.0...l.. 000004b0: 23a8 2c14 7a7a 8e82 978b 218d b056 13a2 #.,.zz....!..V.. 000004c0: 1e4a dda5 b5bd 3fc6 bafd 94b8 5994 e5b5 .J....?.....Y... 000004d0: c843 f46d f68f 37ea 9dd0 74db 1c3e 5380 .C.m..7...t..>S. 000004e0: 05b8 f8e8 6997 e109 b3d4 1064 bb97 af00 ....i......d.... 000004f0: 3ddb e8b2 2d95 4ca8 e81b 76f4 c893 8cb8 =...-.L...v..... 00000500: 80a4 7a9d 781a de5e b584 b0d9 dcb7 e865 ..z.x..^.......e 00000510: c94b 223b 7614 1997 fbf8 b570 cf3d 36a4 .K";v......p.=6. 00000520: 5ddd 9ee5 ff16 a7d9 dd6d 632b 09aa cc98 ]........mc+.... 00000530: 0694 6004 0bb0 7d41 aced ec5f 2c5f c09f ..`...}A..._,_.. 00000540: 2b33 4273 2eaf 795f 3c53 180b 1d95 6104 +3Bs..y_<S....a. 00000550: 7ae7 4228 8322 c5cd 39ea af32 4196 aacd z.B(."..9..2A... 00000560: 9c38 31e2 31b2 8621 f05d cebc ae28 e573 .81.1..!.]...(.s 00000570: 229a ff65 10a4 2c02 e398 aa95 0413 b37d "..e..,........} 00000580: 7442 3cc0 5eed 8474 2b2d b2d8 405f 0f0c tB<.^..t+-..@_.. 00000590: 5c22 bf39 6956 6126 9147 8b73 a117 4d82 \".9iVa&.G.s..M. 000005a0: 34b5 e245 281c aa83 383a 07ac 7782 8745 4..E(...8:..w..E 000005b0: fdd8 2264 c1dc 30f6 fe34 dcc2 3216 06a4 .."d..0..4..2... 000005c0: cca8 714b b1c3 3ccc f85a 37c2 40cd 107d ..qK..<..Z7.@..} 000005d0: 8356 c52c da88 78bf a6a5 7800 8e41 5e8a .V.,..x...x..A^. 000005e0: ef42 9607 d91f 48e7 c09d 5976 2428 061f .B....H...Yv$(.. 000005f0: a5dc a03e 18f0 78b2 48db 418c 7b54 ce12 ...>..x.H.A.{T.. 00000600: 1169 d34c 9780 207a d802 1e14 f3f8 6c78 .i.L.. z......lx 00000610: fa1d de92 5fad 2f90 f1da 58be 5c06 6e90 ...._./...X.\.n. 00000620: d979 249d fcb9 8381 020e 74a8 0c42 432f .y$.......t..BC/ 00000630: 97a3 0a43 9c92 3b3a ef27 72ed cc4c aebf ...C..;:.'r..L.. 00000640: 458c dc42 332f 9c61 6614 1c11 554b e4bb E..B3/.af...UK.. 00000650: 4d84 836e acac 412a 540a 66ca 5e8f ec7a M..n..A*T.f.^..z 00000660: 90ef 4a11 5411 0e3e d509 d6fa f213 6222 ..J.T..>......b" 00000670: c8ef c2e8 cb13 f805 81a7 acdd 89c1 1f25 ...............% 00000680: 1548 099c 8812 4963 e8ed e55e 3ebb 989a .H....Ic...^>... 00000690: 2447 3b3a 8358 9cb9 6ece a02e 1796 303b $G;:.X..n.....0; 000006a0: b8a2 15d7 1883 bf56 d624 3a5b 2f00 5024 .......V.$:[/.P$ 000006b0: 433c 8c43 a318 8801 5fae c883 e6a8 8379 C<.C...._......y 000006c0: 708c a615 6256 fa92 f290 0dab 9c73 5575 p...bV.......sUu 000006d0: 6f2a 6bc0 5d39 8eee ff8c f08c abbd b30e o*k.]9.......... 000006e0: a7fb 5226 d5ab 3aa9 d230 fd52 bb26 4f7a ..R&..:..0.R.&Oz 000006f0: a55c be9c 20fb 9d76 4fe4 6327 faee 6eda .\.. ..vO.c'..n. 00000700: 94c3 06c5 ad4f 34ba 1368 7618 1794 604a .....O4..hv...`J 00000710: b555 c3d6 a443 6b83 abb6 3d44 7230 9c86 .U...Ck...=Dr0.. 00000720: 5650 33bc 553e ca03 470a d0bb b6d5 3de8 VP3.U>..G.....=. 00000730: 6fa9 955b 93a4 3636 e6c1 ce56 e516 1798 o..[..66...V.... 00000740: 49f6 47a1 7c7b cbf2 5eb5 6199 9aef 41d6 I.G.|{..^.a...A. 00000750: bfd2 3393 3c48 3345 db5c 9500 c7b4 4b74 ..3.<H3E.\....Kt 00000760: 8eb3 4d9f 4996 6741 1e96 d98e 1f59 6d0e ..M.I.gA.....Ym. 00000770: bfd4 358c e33a 0c62 c1b7 003b b9b5 be9c ..5..:.b...;.... 00000780: c877 e115 905d ae85 3aa1 b08d 1b2a e234 .w...]..:....*.4 00000790: 7416 e3d3 5bb0 6985 9470 a320 3f61 3b2a t...[.i..p. ?a;* 000007a0: ddfe 37f7 9a38 4a40 998a 8ef6 c1ef 9c33 [[email protected]](/cdn-cgi/l/email-protection) 000007b0: 808b 9d9d edb6 13f1 8018 539c fbbc a800 ..........S..... 000007c0: a11a 8cbb c261 6f48 dd06 1298 2dc8 af6a .....aoH....-..j 000007d0: ceff 78de 9770 a948 6dcc dd48 5396 46c6 ..x..p.Hm..HS.F. 000007e0: d1e7 d986 3be3 7d92 2815 dbad fdc5 f10b ....;.}.(....... 000007f0: 108d f39d c9a8 2764 13c2 18cd 29b4 36dc ......'d....).6. 00000800: 1699 fded 1ed2 e84c 0078 478b fe74 5e2a .......L.xG..t^* 00000810: 6928 1dc5 ab84 1e9d d1c1 9dae ac6a 5f65 i(...........j_e 00000820: e47c ba66 6226 d74d 2763 f374 d8ed 53c7 .|.fb&.M'c.t..S. 00000830: 330d fcb1 6dd3 f8b5 18c7 af91 2b84 4bc8 3...m.......+.K. 00000840: 38be befe aca3 d46a e4ce 63d1 6f61 0bde 8......j..c.oa.. 00000850: 19d7 1268 8b76 f892 3b76 0b9d 8494 382c ...h.v..;v....8, 00000860: 2320 624d d8d2 c008 55cc dc77 178a 3979 # bM....U..w..9y 00000870: 0a98 25d8 efd2 f2e6 7ccc 104b ecec 10be ..%.....|..K.... 00000880: 7a1b 08d7 553e ab3e 9fac 1f10 851d 4715 z...U>.>......G. 00000890: ce45 282d ae45 7c9d de8f a8f7 355e 1b18 .E(-.E|.....5^.. 000008a0: 75a2 5960 fedf b9dc 944b cc70 daa4 d438 u.Y`.....K.p...8 000008b0: 9eea 3fd2 74c7 de84 a34c c05d 3c68 5037 ..?.t....L.]<hP7 000008c0: 408f 3260 e7ed 8868 0274 7538 07b3 853a @.2`...h.tu8...: 000008d0: ea91 ee68 bb86 a93e b276 7ea4 7138 c6a3 ...h...>.v~.q8.. 000008e0: ae86 0caf 96cf bb9c 9dd2 0f8f 20ce a8b5 ............ ... 000008f0: b1c2 eb9a 06ea 136c 50b0 60ca 5262 c062 .......lP.`.Rb.b 00000900: dcb6 ee9c 67af 3579 3a6f d3da 449e b184 ....g.5y:o..D... 00000910: b57e 613f 14a9 d764 55d9 2319 b649 9330 .~a?...dU.#..I.0 00000920: 8d64 b72f b3ed 1989 d64c eeb8 bf7d bd70 .d./.....L...}.p 00000930: 6ead 6860 ccd4 fa73 05ea caa6 92a7 2edf n.h`...s........ 00000940: 23f3 f775 8a47 2649 f032 46d9 0035 36e4 #..u.G&I.2F..56. 00000950: 28d3 1c21 0c65 1cf4 88c8 39ef b47b 30ed (..!.e....9..{0. 00000960: 4095 92c2 b601 2ba8 06ba 506c 090d 5ecb @.....+...Pl..^. 00000970: b43d c072 a1eb bcb1 97c8 42af 6610 5ec1 .=.r......B.f.^. 00000980: 0922 7f66 1a72 18a4 c16b 1837 aded 8df1 .".f.r...k.7.... 00000990: 4c40 5c40 a6ac ab24 ef4c 9893 17e4 1f16 L@\@...$.L...... 000009a0: 2c97 628a e0cc 2545 0540 ff9c 7207 b4a2 ,.b...%[[email protected]](/cdn-cgi/l/email-protection)... 000009b0: b855 c497 ccbe 0fee 8d67 a557 6497 cfb3 .U.......g.Wd... 000009c0: e50b b919 e0c3 eb99 472d ae12 83af 93d2 ........G-...... 000009d0: f25d 557f def3 c1b1 fef0 454f 3f48 01fd .]U.......EO?H.. 000009e0: 48be e3de 1ef5 a505 b69b ab9a 4e08 50fc H...........N.P. 000009f0: dc44 a780 97dd 3032 94cf f4ee 2b7a fbd9 .D....02....+z.. 00000a00: b2f8 879a 7b0d 6a30 d704 2d5a 9254 5fc8 ....{.j0..-Z.T_. 00000a10: 4f6c 0faa 58f2 ff16 078a ccc2 78e9 7b30 Ol..X.......x.{0 00000a20: 3b65 2a63 5e64 878c ab3f 09f4 a21d 0f67 ;e*c^d...?.....g 00000a30: 9f2c 0fc6 1ae8 fb00 76d5 d921 3a01 8863 .,......v..!:..c 00000a40: 436a fbec a0dd a9ba 9d2c 0cad 1fe3 bc07 Cj.......,...... 00000a50: b7b4 dfc5 369d 2bea ff73 28da cea0 0045 ....6.+..s(....E 00000a60: 06d3 1b6d 4ed2 fdac 49af ec47 5f00 0eca ...mN...I..G_... 00000a70: 82e7 7a7a 5915 1075 ee1c 827c 4882 42df ..zzY..u...|H.B. 00000a80: 3b61 bb8e dfe5 fede 77c7 ac9d 55d1 ec5b ;a......w...U..[ 00000a90: a47e ddee 3b87 b8fd e3be 3db2 ce17 0208 .~..;.....=..... 00000aa0: 3dab 90eb e562 7820 3daa 9306 09ef 0f0d =....bx =....... 00000ab0: 3058 b291 40c7 34c0 d87b dc9d 4d19 f2c8 [[email protected]](/cdn-cgi/l/email-protection)..{..M... 00000ac0: 010f 8b74 05c8 f427 3fe4 b8d4 f3f0 2d96 ...t...'?.....-. 00000ad0: c588 67b6 b4d8 d23c 8038 f8c4 66ce 8ad3 ..g....<.8..f... 00000ae0: 57fb cdc6 a696 f150 f88e b3dd b0ab 9654 W......P.......T 00000af0: af79 5281 73aa 62b3 73ac e5a8 49a4 cc87 .yR.s.b.s...I... 00000b00: 6e17 d2d2 c684 f5da b2ee 4984 b36b 683b n.........I..kh; 00000b10: 5bca 6468 ea97 f9ab b246 6fec 8b13 1b55 [.dh.....Fo....U 00000b20: 69ca 3974 fcc0 9a22 6756 ba7f b09c 0ba8 i.9t..."gV...... 00000b30: cdee b1cd 64af 75d1 5010 3663 5a6e 9572 ....d.u.P.6cZn.r 00000b40: bd7b ad80 0966 f75f 815b 94a0 3730 ab27 .{...f._.[..70.' 00000b50: 4f18 a42c fb9e 5711 c958 ddd0 5923 3bb2 O..,..W..X..Y#;. 00000b60: 0302 bb0a 5737 ad38 1087 2a19 d8df c1c3 ....W7.8..*..... 00000b70: d689 2b61 c397 54ec 0853 5e53 e5a8 3c7b ..+a..T..S^S..<{ 00000b80: 0668 06cd 5474 4557 91cc bd10 d141 3b72 .h..TtEW.....A;r 00000b90: bb41 5e44 ac56 0a82 7504 8335 c16b 7179 .A^D.V..u..5.kqy 00000ba0: 6323 c74d edaa 70f8 04ad 6e17 7411 040d c#.M..p...n.t... 00000bb0: 4fbe 30c3 58fb ee65 a5fa 28d0 9a22 1340 O.0.X..e..(..".@ 00000bc0: 9f47 a669 2913 3681 474e 6008 f2e0 5d93 .G.i).6.GN`...]. 00000bd0: 8955 5dee df0b 8fc6 8246 249d a5bd b7cf .U]......F$..... 00000be0: a94f 91c6 f09f acce 9785 5f04 33d0 e3ea .O........_.3... 00000bf0: 0808 df9a cca7 311e 50ea b2b1 a875 6c1d ......1.P....ul. 00000c00: 5928 b11c d0c5 549f 5064 1d05 271a 8cd5 Y(....T.Pd..'... 00000c10: 11c9 d818 55c1 717d 3f88 87a9 ab6c 31f7 ....U.q}?....l1. 00000c20: 5dc6 0e8e d695 5690 2ca0 3d1d 67ec 1e35 ].....V.,.=.g..5 00000c30: 6479 2ff6 0ad4 83e5 2f7d 494d 3192 145d dy/...../}IM1..] 00000c40: 94a2 b523 2ef4 9ba5 43e6 94b7 d1a1 387e ...#....C.....8~ 00000c50: 93be bd4e cc47 8390 e0af fb07 4db0 30f1 ...N.G......M.0. 00000c60: f7bc ac1e 5d7d 6bcf 01f2 c46e cef0 fa46 ....]}k....n...F 00000c70: 44ce cd10 4fb9 47d1 1ea2 fa26 919e c7ab D...O.G....&.... 00000c80: f639 ca1c c8a0 822f d4c3 fb6b 7b29 a1c3 .9...../...k{).. 00000c90: 43c8 b691 adac bc2b 8d0d b8b1 75af 19ae C......+....u... 00000ca0: 1dad d312 a1e0 9eaa 22fa bf91 81d3 cb66 ........"......f 00000cb0: 87d0 338c c819 3644 42b0 e290 bec6 da07 ..3...6DB....... 00000cc0: e1f9 f081 f1bf 5986 8637 2501 3595 8ff3 ......Y..7%.5... 00000cd0: 13cb 8009 2871 646c 9894 8984 6929 a7cc ....(qdl....i).. 00000ce0: 8376 0c01 71c9 f4fb 947e 73e7 607d 1a63 .v..q....~s.`}.c 00000cf0: 42f6 dea7 a7ea ac8f daea 903f 03f8 87ae B..........?.... 00000d00: 81a5 adbf 0f29 7eff cfd0 bb49 4ae1 cfd5 .....)~....IJ... 00000d10: 17e1 db55 483d 71c5 e04f 6c48 c42f 5bfe ...UH=q..OlH./[. 00000d20: 931e 4eb8 2760 411c 6e9b d2c3 20b7 87d9 ..N.'`A.n... ... 00000d30: 1213 402c 1ad2 b76c 773c 301e b5b4 62b7 ..@,...lw<0...b. 00000d40: 6d0e 296d f5ed 7643 46cc fa19 d090 9284 m.)m..vCF....... 00000d50: a05c cdfc ab1a 7e3e cead ebe7 6ea3 54b4 .\....~>....n.T. 00000d60: 6a4f a882 eb11 b29c 5626 b1a3 5fef 5fc5 jO......V&.._._. 00000d70: 1fac e5bc bef1 07dc 33dd f15f 02f9 1642 ........3.._...B 00000d80: 96a2 c15c 17fb 569d 81bb 6f3a 1957 9a4f ...\..V...o:.W.O 00000d90: 7e4a 1949 55f3 deee 9945 66fc a19c defd ~J.IU....Ef..... 00000da0: 44b2 6ad3 3470 1d9b 1b8e e01b 17e1 b8ab D.j.4p.......... 00000db0: 9750 12c4 b603 7c45 e198 ecb1 10d4 98d7 .P....|E........ 00000dc0: 0425 62bc 7cfb 5d9e 4af3 f50c 2ae3 55aa .%b.|.].J...*.U. 00000dd0: 68d1 b2bb 5dda 321f 378e f7b1 7db6 04fa h...].2.7...}... 00000de0: cb10 0563 3f23 e939 a1d6 a31f 78c9 1bf5 ...c?#.9....x... 00000df0: e21e 64a4 9714 954b 14cb 916c bcbd e644 ..d....K...l...D 00000e00: f11e 709e 8a11 d569 6fa4 a85f 4bb1 f557 ..p....io.._K..W 00000e10: 7192 981f a28f c367 56b6 a089 1009 5c96 q......gV.....\. 00000e20: 233b d5cf 5b24 6292 3b5c e6b9 8b5e 5f59 #;..[$b.;\...^_Y 00000e30: 1923 4de7 c0a6 db5c 33c2 116d ebcc 1fd5 .#M....\3..m.... 00000e40: e8e4 7799 7381 10d1 9d19 6482 c624 c9b3 ..w.s.....d..$.. 00000e50: dca9 80f7 88ff 38d0 a6a1 2406 3efa 1994 ......8...$.>... 00000e60: bb0a 9e49 050e 3954 2f46 7a8b 7dce 1e48 ...I..9T/Fz.}..H 00000e70: b7ba 4c26 0cf3 b654 13de 6147 0725 e3c0 ..L&...T..aG.%.. 00000e80: 3a79 5e5d 1c1d dc55 f27e c868 aa71 6e7e :y^]...U.~.h.qn~ 00000e90: 0dbd 0d29 66cc 82a9 5c12 e442 6352 596b ...)f...\..BcRYk 00000ea0: 5a05 f7e6 39d2 9c61 f02e 88ad c249 6bf4 Z...9..a.....Ik. 00000eb0: a384 0321 ce87 2f38 4f48 13ab 8d9b 8b75 ...!../8OH.....u 00000ec0: 7bd4 fac3 9829 d70f f8ea b396 51d8 f407 {....)......Q... 00000ed0: de8d 9e22 0a5d 1bae e9ee 34c4 9aff 694d ...".]....4...iM 00000ee0: 66ab 0e4e e6ce 4696 3682 b4ea c435 a923 f..N..F.6....5.# 00000ef0: ce78 cef8 51a0 8512 e69b 3b69 c092 36ef .x..Q.....;i..6. 00000f00: 5418 8ff1 90a1 1dce eea1 645a 4da9 0451 T.........dZM..Q 00000f10: ecd7 3d07 3eac 758d a06c 1061 f5d3 6d61 ..=.>.u..l.a..ma 00000f20: 9ad9 225b c1d4 5585 0fd1 5b5b 8838 c7a3 .."[..U...[[.8.. 00000f30: 299f 138c b4f8 8cba 66ca 7e4e f136 34b1 ).......f.~N.64. 00000f40: ec30 8ba7 8d47 21b5 0cfc 457d 0f7b 381d .0...G!...E}.{8. 00000f50: faea ed68 f2e5 675f f64a 4dc2 da77 0811 ...h..g_.JM..w.. 00000f60: 0684 b3e7 e6e0 71f9 ca86 10fa 2a34 1115 ......q.....*4.. 00000f70: 5479 5f7d d2e8 e50d db0b 6268 4528 2103 Ty_}......bhE(!. 00000f80: 7b0f 256e 37d9 c45a 2585 1926 ebdf bf79 {.%n7..Z%..&...y 00000f90: 52aa fe44 ad08 69c9 9267 b5ed f79a 6d2e R..D..i..g....m. 00000fa0: 6a68 c7ec 127b 0016 f3ce 8d06 a744 a515 jh...{.......D.. 00000fb0: bf19 3b5b 890a 55ed c987 c497 c7a4 cdda ..;[..U......... 00000fc0: 8312 fda3 0873 36ce bef7 85ba 88e3 2185 .....s6.......!. 00000fd0: aa02 0ead 79e3 44ad f548 e9be 6f83 a030 ....y.D..H..o..0 00000fe0: efaf dc61 2b3b 1c5b 5c10 bbe3 1ea9 6dc2 ...a+;.[\.....m. 00000ff0: ce5b 59cc 1cd6 15cb f8fe a3b4 0f65 4539 .[Y..........eE9 00001000: 65ed 3edc 907a 4c9b f38b 6edc b85d 4245 e.>..zL...n..]BE 00001010: c163 fb24 2399 c521 98dc 4ee7 90dd b02e .c.$#..!..N..... 00001020: c211 b254 c3a4 b26e 04bc f3fc b67a 422b ...T...n.....zB+ 00001030: f1fd 573f 08a7 a092 2413 4ebf b67d baba ..W?....$.N..}.. 00001040: a22e 2eaf 2901 3d1e 5a12 c65e e5a4 4217 ....).=.Z..^..B. 00001050: 40d9 054f 4bbb bd2b 1417 699d 30d8 bf45 @..OK..+..i.0..E 00001060: d424 6447 dec8 ec4f 5dba c4d3 72af 149d .$dG...O]...r... 00001070: 401f 987f 3f46 545d a48d df6c 736f 254f @...?FT]...lso%O 00001080: 085a 54b5 aee4 52d2 e82a 6761 ebf8 fba6 .ZT...R..*ga.... 00001090: 6ea9 9e24 a353 419c 9b15 4660 d844 89bb n..$.SA...F`.D.. 000010a0: 72eb cdc2 3b6b 463f 8b2a db09 a5b2 fc74 r...;kF?.*.....t 000010b0: 0fa4 b1e7 4c6b 61b2 08b5 7323 4566 4fc9 ....Lka...s#EfO. 000010c0: 3816 d78a be18 9a94 4bd3 c8ac a251 0c0b 8.......K....Q.. 000010d0: bff1 4d44 eccb 9f70 c6af 3c47 4e52 2508 ..MD...p..<GNR%. 000010e0: 331d 3ea8 662e 41cf a188 c8ca eb14 38c1 3.>.f.A.......8. 000010f0: e23c 2f5a ff90 6599 4da1 62bf 44d6 5ceb .</Z..e.M.b.D.\. 00001100: 2fa1 0623 460e f0ef 13da e49a 69e8 f234 /..#F.......i..4 00001110: 4d3b 7a98 c87b 810e 8cc7 491a 2a23 afd3 M;z..{....I.*#.. 00001120: d468 63ed b42c e324 f67a b687 a28a f0b1 .hc..,.$.z...... 00001130: b59c 8385 c467 31f0 16ca 7c4d 319c 15ee .....g1...|M1... 00001140: a22a 2eb9 a901 a35d 9320 5ff8 49d2 4864 .*.....]. _.I.Hd 00001150: b68f eca9 28cf cf19 4405 85de 0d0a 3d4c ....(...D.....=L 00001160: 7787 9164 3881 942d 4165 de5d 586a df4e w..d8..-Ae.]Xj.N 00001170: a675 44cf e91f fa48 5deb 79cb 83a7 16d9 .uD....H].y..... 00001180: ce90 d7c9 45cc 76d3 f1d8 9ede 1f8d 5f0c ....E.v......._. 00001190: ccb6 26d1 daf6 17a8 0bbe a3cf 80b9 484b ..&...........HK 000011a0: ee9a 7638 a15c ed56 0431 153d de08 f1b8 ..v8.\.V.1.=.... 000011b0: 2ae0 0fbb b7a9 aa90 d90c a809 7cef e53e *...........|..> 000011c0: 65ed 1ab3 d404 b6e4 b587 a9f2 9f6e 97fc e............n.. 000011d0: cc1b 52df 8de5 3f77 47ab f378 66c2 b3cc ..R...?wG..xf... 000011e0: cf9b d28c 6a7d f178 a8d6 1bc6 8f08 531f ....j}.x......S. 000011f0: d98f 6ed0 3c70 db87 98df fbf4 fa29 6cfd ..n.<p.......)l. 00001200: a0bd 3c57 712e 9735 af79 7429 7664 2b76 ..<Wq..5.yt)vd+v 00001210: 65cd 5c97 cf4a 1225 a505 74f3 2de7 44db e.\..J.%..t.-.D. 00001220: bbc9 baf5 64ea 002b 87ec f895 3f4a 9cc2 ....d..+....?J.. 00001230: c64a 1c45 2d9a c276 eaab 53d6 37b9 2307 .J.E-..v..S.7.#. 00001240: 88c9 4be6 0559 1b9b b6cb 4816 865e 314d ..K..Y....H..^1M 00001250: 80f9 cc02 01b5 4103 dd44 346c 93a6 4b07 ......A..D4l..K. 00001260: d441 409f 8bf2 e3ea 7aca f263 8fa7 d41d [[email protected]](/cdn-cgi/l/email-protection).... 00001270: 56a2 adca 75c0 8e48 f403 57fd 6a95 2a36 V...u..H..W.j.*6 00001280: 2e00 7114 b843 d4fa 1d3e 3c35 0398 b3cf ..q..C...><5.... 00001290: 673d 365f 9aed c356 8822 367a d819 8997 g=6_...V."6z.... 000012a0: b467 c6b0 ef36 fb06 c68d a6f6 d956 d670 .g...6.......V.p 000012b0: a9e9 a910 bac8 d2c7 b7f1 573c 0fed 78aa ..........W<..x. 000012c0: 1ec3 3cbc 8b00 901d 338c 55d2 247c 59a2 ..<.....3.U.$|Y. 000012d0: 5aba 87d1 dfc3 3e14 2c30 e666 97b1 6976 Z.....>.,0.f..iv 000012e0: 649e 7ec0 6dea b2e8 0af0 587b daf2 68dc d.~.m.....X{..h. 000012f0: 73f8 bf96 8ea1 5407 174a 2648 d905 bc87 s.....T..J&H.... 00001300: 9328 6d6b b5b9 eaeb 04c2 2ded c1d0 8db9 .(mk......-..... 00001310: 6483 744a 9d83 ba40 cec5 75fe d1d3 1416 [[email protected]](/cdn-cgi/l/email-protection)..... 00001320: 3604 e8fb bbf5 dfe4 153b f748 7f1f 314c 6........;.H..1L 00001330: 3915 8251 0b51 8a3c 9456 fe2a b6e8 9263 9..Q.Q.<.V.*...c 00001340: f751 1cf5 feb9 7708 a153 ffff 766e 83e4 .Q....w..S..vn.. 00001350: 31d2 7e12 a7b4 cf54 74fa c2a9 aa57 efcb 1.~....Tt....W.. 00001360: ea49 7adb 2aa7 7557 6775 7fb4 41a5 f5d6 .Iz.*.uWgu..A... 00001370: a5df ac7d 577d 0bb8 5433 b337 e98b 56f6 ...}W}..T3.7..V. 00001380: dc5b 51bd ebe8 9b86 ebf6 c840 43f2 bd8a .[Q........@C... 00001390: 2815 8e17 9355 d79c 3555 9527 12cd 3bf5 (....U..5U.'..;. 000013a0: 4ea5 bec7 a363 aa2e 87f3 aa46 bd4b 1219 N....c.....F.K.. 000013b0: 1ded 4ece 2259 7dda 7d13 7927 7615 0b9c ..N."Y}.}.y'v... 000013c0: 22d8 f3d7 c28f 37ff b748 5b97 2857 909a ".....7..H[.(W.. 000013d0: 695a 4e27 7d3b 9de0 1ca8 d942 2da8 ee2e iZN'};.....B-... 000013e0: 0b29 3f10 36e2 738c 053e 6c1c 762f edd4 .)?.6.s..>l.v/.. 000013f0: 46ed 2db1 0218 48b5 dd39 cf68 8a54 b401 F.-...H..9.h.T.. 00001400: e4a8 c12b 1f0d b7c1 7eb4 de76 6cfb 9fea ...+....~..vl... 00001410: af36 e0dc fb7a 33c8 1473 7499 f4f5 53ce .6...z3..st...S. 00001420: 9e9e 7dfa 0039 9124 06d3 28d9 aa2f a45e ..}..9.$..(../.^ 00001430: 0cca f3d0 8904 1715 c1be 7839 994c 6446 ..........x9.LdF 00001440: a0e4 7dda dbbe a5f8 1788 df62 27b3 822d ..}........b'..- 00001450: 6876 d7b5 e82a 419c 8f2b 5c5e df07 077c hv...*A..+\^...| 00001460: 8aac a977 3eda daa2 a278 bb7d 8a7c c88c ...w>....x.}.|.. 00001470: 273d 59ae d966 8df0 5e71 702e 0e6b c546 '=Y..f..^qp..k.F 00001480: 1ff1 bcac 92a5 e6ad cba1 23e5 c54e 6a09 ..........#..Nj. 00001490: 0154 e2d1 cc4d 5860 0e90 ea2d 8854 6ab3 .T...MX`...-.Tj. 000014a0: 3837 d143 4933 6687 1c79 1007 5938 d082 87.CI3f..y..Y8.. 000014b0: 5896 4f9f 19f0 d98f 2019 d6db f152 8535 X.O..... ....R.5 000014c0: bb0c 665b f002 8116 cce0 a156 8571 fe1e ..f[.......V.q.. 000014d0: a43f f10b 3ff3 c0b7 0b3c 4abd 45e3 7a99 .?..?....<J.E.z. 000014e0: 431b c22e 937b 1f00 fd09 be9e b76e 441d C....{.......nD. 000014f0: c070 1d8b ad89 16b1 e392 992a 0346 f487 .p.........*.F.. 00001500: 8087 524e 0001 0966 3ce8 a333 22a4 0d6b ..RN...f<..3"..k 00001510: 9f32 5d18 77ed 50fc 15af f31e ec3c 2172 .2].w.P......<!r 00001520: c44b a87a d6e5 9192 6bf5 833c 556d c352 .K.z....k..<Um.R 00001530: e81f 34d4 b56b b7bf 9b19 f4f6 eee5 7247 ..4..k........rG 00001540: 798d 3563 8b95 4952 301c c357 ac32 781d y.5c..IR0..W.2x. 00001550: 4726 6cf2 c8fd ac54 ed55 a873 522c 0725 G&l....T.U.sR,.% 00001560: 7578 3584 0d16 a9ef 9042 9856 6c0e db3e ux5......B.Vl..> 00001570: fc94 86a4 ffe2 ce4f cf59 25f4 cdc9 3089 .......O.Y%...0. 00001580: f092 c719 59f9 1a71 cf93 023b def3 7760 ....Y..q...;..w` 00001590: 200f 381b 10e1 8fb6 a861 37cb 4af2 0b73 .8......a7.J..s 000015a0: 2c6d 1cdb b71b cbdf 47f3 1ec3 972c f5f4 ,m......G....,.. 000015b0: a709 2a07 eba9 d6be 3c54 573a eba1 964c ..*.....<TW:...L 000015c0: e81e b5e7 5f8f 6cce e9ec 69e3 2c6f 5033 ...._.l...i.,oP3 000015d0: 843c 45ef b50d 7e9f 0d5b a59f 2b37 f473 .<E...~..[..+7.s 000015e0: 9617 4cab 9e3d c15c 1538 d87d eb8e 17d7 ..L..=.\.8.}.... 000015f0: 3937 f38f d1d0 e011 83e4 3c40 15c3 8315 97........<@.... 00001600: 956a 69e0 ab89 0689 38f0 5056 c5a8 d2e6 .ji.....8.PV.... 00001610: c7cd c586 14e6 f877 8308 4368 de20 01c9 .......w..Ch. .. 00001620: 7ec4 0359 eb7d 594d e553 f6e7 7348 a277 ~..Y.}YM.S..sH.w 00001630: d30b a2ee 94a0 b4ed 09fa b6ef f501 c598 ................ 00001640: 5bb6 6d4e 085b be6f 7824 da40 4462 0bd2 [.mN.[.ox$.@Db.. 00001650: 1723 5d16 78e5 0371 4ea8 e03b 4bab 75eb .#].x..qN..;K.u. 00001660: 364e 1904 bb26 6d50 0c26 5abc f833 57db 6N...&mP.&Z..3W. 00001670: 7c35 ffd2 c5ca 40b3 2c51 fb42 dc40 e4c6 |5....@.,Q.B.@.. 00001680: af49 ce88 f80e ea7b 3ffd e5b5 b5d1 24d9 .I.....{?.....$. 00001690: e3d9 4d45 f223 d838 8d1a a555 262e ceb9 ..ME.#.8...U&... 000016a0: 625e 0503 e83d 4b46 0435 216a 8815 d83e b^...=KF.5!j...> 000016b0: b3ea 419a e2cc 13d6 1cca d17c 4002 a98f ..A........|@... 000016c0: 0286 918e 0fb4 8ed4 8236 37b2 9d10 129e .........67..... 000016d0: 0734 e581 c13e 3022 844a e419 061d c034 .4...>0".J.....4 000016e0: 8973 f072 253e 3cbc 3c4e 23a8 c258 9174 .s.r%><.<N#..X.t 000016f0: 84ab b48d 1f8d 2f30 f45c 31dc 7169 4b32 ....../0.\1.qiK2 00001700: e3cc a144 df47 c139 4063 b036 5448 eab9 [[email protected]](/cdn-cgi/l/email-protection).. 00001710: 5e10 361f 26fe e770 3e26 753f 737f 6b20 ^.6.&..p>&u?s.k 00001720: 8503 5ee0 b56e 51f8 3552 cad8 ae38 b46b ..^..nQ.5R...8.k 00001730: 6aee 792e 81cb 0d0c f4d5 68b9 cdd4 f06c j.y.......h....l 00001740: 8c3c a090 1eb6 8bb7 964e ca02 29a1 450e .<.......N..).E. 00001750: 045f 8cc5 1405 0203 102b 1d20 dd79 62fd ._.......+. .yb. 00001760: ab1b 2cf9 4437 4ed2 97eb 43ef 76c8 185b ..,.D7N...C.v..[ 00001770: edea 6d19 6479 b52d 22bf 245d 9bef d2a2 ..m.dy.-".$].... 00001780: 498f ba45 987b f984 1237 60ee fcd7 7a95 I..E.{...7`...z. 00001790: fac9 7733 3321 b303 6be9 2e76 87fa bbad ..w33!..k..v.... 000017a0: 70c2 4d2b 487b e490 27b6 9ed0 8479 72fc p.M+H{..'....yr. 000017b0: bcd1 ef25 dd0d 4df5 2f22 cb78 ce9b a1f9 ...%..M./".x.... 000017c0: 9c84 626c 9c79 7e24 4de8 29e8 f380 b051 ..bl.y~$M.)....Q 000017d0: cedb f0e6 23d4 e259 d9fd ee55 95c6 d115 ....#..Y...U.... 000017e0: 139d 2174 fb06 5027 ee3a b433 1e7c 0381 ..!t..P'.:.3.|.. 000017f0: c6fd e030 a57c 93cc 2375 9d88 befd 9806 ...0.|..#u...... 00001800: eb1c fbbc 6283 f465 bdc2 df3a e82c ead5 ....b..e...:.,.. 00001810: 6fd6 2c0f 209d 7ced d80d 46db 9a51 f62f o.,. .|...F..Q./ 00001820: cb94 e7c1 9114 925b f759 f6f3 835a f07d .......[.Y...Z.} 00001830: 1927 0ec1 3c8d a9e7 4959 5de9 c87d dc08 .'..<...IY]..}.. 00001840: 5c10 3e91 7fbe 4e19 1c01 4cfd afb2 f98f \.>...N...L..... 00001850: 1f54 9f8b 7f0f fee7 1da7 e52b 1706 9606 .T.........+.... 00001860: 44fc ef4b c26c 6e3c e1d6 0eae f044 e0c3 D..K.ln<.....D.. 00001870: 298c 650b d3e6 b198 b27c f121 c075 49ca ).e......|.!.uI. 00001880: 0eec dc01 ef9c 5c0d bfa4 945f ad50 c147 ......\...._.P.G 00001890: ba0a 58bd fbf0 b6ce cd29 706e 1c46 5d07 ..X......)pn.F]. 000018a0: d2d8 5c3b d5cb 96d3 c9a6 057b 8108 2787 ..\;.......{..'. 000018b0: 1839 e9e5 c226 eca5 64db 4d56 42c4 be61 .9...&..d.MVB..a 000018c0: e324 e145 feee 0839 4da2 4130 3061 3368 .$.E...9M.A00a3h 000018d0: fb51 537c 36b5 3b0b 6190 602d 99f2 6805 .QS|6.;.a.`-..h. 000018e0: 932a 615d 1160 8d60 6be8 df3e b27e df6d .*a].`.`k..>.~.m 000018f0: c98f a2dc 8438 85b9 9f9d 4e58 1987 8f34 .....8....NX...4 00001900: 9dd3 779f c6b0 b31b a47f 2ec9 1a16 d738 ..w............8 00001910: 5686 6d00 0c7e 7c4c de2a 0ebb 70d9 fe6b V.m..~|L.*..p..k 00001920: 7a8f e85a 4e4a 8167 7162 c884 4f07 7ef1 z..ZNJ.gqb..O.~. 00001930: 9d38 ee20 9d6c b095 bcd4 a71b 124f a30b .8. .l.......O.. 00001940: 9c1c a94d da07 a7ee 1dba db13 f836 dafe ...M.........6.. 00001950: aea0 4875 ee89 0ed2 1734 f2cc 9bfc 44b1 ..Hu.....4....D. 00001960: eb97 2750 37d5 8191 0583 fe8d e525 0770 ..'P7........%.p 00001970: 78c7 527f 70d1 c797 9a61 2916 4517 6977 x.R.p....a).E.iw 00001980: faed 3ed7 7af3 8e07 f60c c6ee 3daa 9cd5 ..>.z.......=... 00001990: ca67 72fc afff f2ee a1c9 59d9 e3ce c4b8 .gr.......Y..... 000019a0: 74d9 f180 c73b 68db 8de2 37e6 3a27 b247 t....;h...7.:'.G 000019b0: 7e2a 9a78 f2f3 bdaa 9fb9 a988 e867 1f9a ~*.x.........g.. 000019c0: 51e1 3736 559d d396 d6e8 d31f 7a9d 0aea Q.76U.......z... 000019d0: d7fc 63d7 4623 b767 a4da 96ac 1f14 0f76 ..c.F#.g.......v 000019e0: 704c 0e36 e2d0 e3d1 a8f6 5aad cb93 b5b4 pL.6......Z..... 000019f0: 8d15 7aab deed b00e a257 4a6a 9554 cef3 ..z......WJj.T.. 00001a00: 0e5f de4b 5e9f bc07 1593 3b4b 25f0 aaf2 ._.K^.....;K%... 00001a10: c270 b798 b54f a9a5 82c2 8cfa 52bd eaad .p...O......R... 00001a20: 5882 536e dbc9 6186 bd81 99e0 afa3 03bb X.Sn..a......... 00001a30: 45ab fda0 0ab8 8a16 7cdd d617 f33f 771b E.......|....?w. 00001a40: 32bc 97e7 da98 607f 5887 762f 0ce2 02f8 2.....`.X.v/.... 00001a50: df6e 7fa5 420c 558a 8f1f ac94 86a8 d266 .n..B.U........f 00001a60: 23c2 cb18 e138 fb53 0800 f5fc dabc 2665 #....8.S......&e 00001a70: 86b9 ac61 605a 314d af83 c751 3be6 fc5a ...a`Z1M...Q;..Z 00001a80: e082 57db 0003 a875 ce75 6030 1e86 6bbe ..W....u.u`0..k. 00001a90: cdd4 611e fde1 ffe1 249b c5f6 2cbf 1264 ..a.....$...,..d 00001aa0: 6a8b 9b0e a7ac d92f b1b3 b1b2 436c 86f0 j....../....Cl.. 00001ab0: 9428 c89a ae49 acdf d8ab b89f 4498 09f1 .(...I......D... 00001ac0: 71a9 e393 acde c1c4 ca57 adc3 7fab 7d9b q........W....}. 00001ad0: 5acd 7822 cdf4 4196 37cb 3249 2fd6 606b Z.x"..A.7.2I/.`k 00001ae0: d72c ef26 0b30 beee caed 2991 658f 17ad .,.&.0....).e... 00001af0: 7a0b 9c48 9967 eebe 4298 79ab eed4 31bb z..H.g..B.y...1. 00001b00: 74e0 467c 0f68 a722 a3eb fed9 a87f bf5e t.F|.h.".......^ 00001b10: 893f fbd3 2be7 7daf 3295 d760 531f 9c08 .?..+.}.2..`S... 00001b20: 03d5 870b 3255 2fdf 2f0b bff6 9883 8014 ....2U/./....... 00001b30: 7e5b 7a83 b4a3 fc80 dc7a f074 c3a4 e1b3 ~[z......z.t.... 00001b40: 110a b12a 2a50 3866 4307 f5a5 360a 5231 ...**P8fC...6.R1 00001b50: 07ea b558 f29f 2ad5 83cd 27bf bea2 5304 ...X..*...'...S. 00001b60: 92a7 b94d bfcb 4f59 a4a4 e48f 2b30 87cf ...M..OY....+0.. 00001b70: 6351 9b84 deb9 6382 fb11 5f5d 955d 49ff cQ....c..._].]I. 00001b80: f949 f499 4bcd 51b2 4e6b 76e4 d18a 7fe3 .I..K.Q.Nkv..... 00001b90: 9ea6 acd6 a742 be9a d05e 77f9 53b4 dba5 .....B...^w.S... 00001ba0: ba83 b012 303b 55f5 2516 19de 887b 94d8 ....0;U.%....{.. 00001bb0: 399f f29c 9f28 387c 97f0 4e4a 1831 0632 9....(8|..NJ.1.2 00001bc0: 125a f4db d533 df44 204f 9d27 f9bf 3e78 .Z...3.D O.'..>x 00001bd0: 7339 22fc a65e 81dd ff1d 690b e27a e5e3 s9"..^....i..z.. 00001be0: f48f 6d3f 517e 68d9 a9cf 0b0d fecb 59c3 ..m?Q~h.......Y. 00001bf0: 7642 d678 3469 779b 7899 6425 cb1e 016d vB.x4iw.x.d%...m 00001c00: 0585 9acf 62c0 a8ef 32b2 2ea8 ce23 89e4 ....b...2....#.. 00001c10: 4ff4 9df1 17ec c76e 45d0 b2c0 691d e92f O......nE...i../ 00001c20: b557 790f 7a9e 8221 5bc8 c7cf a3da b271 .Wy.z..![......q 00001c30: 9141 b8d8 8800 e45d 616f 2d5e fa03 f07b .A.....]ao-^...{ 00001c40: fb9d 8da1 6ccf 550a f5fd 45c5 0a72 94cd ....l.U...E..r.. 00001c50: c039 9ea2 0aab 1c33 e645 ced7 f7dc e4c6 .9.....3.E...... 00001c60: 00de f4ff 34be de7d fa47 5196 0ed2 faf5 ....4..}.GQ..... 00001c70: e79b 1bbb 2507 2826 d2b2 6f54 7bf9 d004 ....%.(&..oT{... 00001c80: 50c0 87de a720 ff2f 672a 172e P.... ./g*.. ``` Zlib compresses the original RNA sequence into 8859 bytes. We can do significantly better by first encoding the RNA base sequence, minus the last 31 `A`s, using 2 bits per base. For reasons explained below, we choose `01` for `A`, `00` for `C`, `10` for `G`, and `11` for `U`. Further compressing the encoded string (7468 bytes) with zlib gives the compressed string stored in the binary file `f` (7308 bytes). The decoding program reverses the encoding process, interprets the two-digit binary numbers representing the RNA bases as octal numbers and then converts these to decimal, and finally tacks 31 `1`s (representing `A`s) back on at the end. ### Commented code ``` Zlib.inflate(IO.read'f') # read file 'f' and decompress with zlib .bytes{|i| # iterate over bytes in decompressed string (yields each as an integer from 0 to 255) $><< # append to STDOUT ('%8b'%i) # convert each byte to a binary string (representing four RNA bases), space-padded to 8 characters .gsub(/../){$&.oct} # split into groups of 2 characters (i.e. one RNA base), then interpret each group (last regex match $&) as an octal number and convert it to decimal (noting that padding spaces in $& will be treated as zeros) }; $><<?1*31 # append '1111111111111111111111111111111' to STDOUT ``` ### Choosing the encoding bits It turns out that the size of `f` is weakly dependent on the choice of bits used to represent each base: ``` +----+----+----+----+------+ | A | C | G | U | f | +----+----+----+----+------+ | 00 | 01 | 10 | 11 | 7309 | | 00 | 01 | 11 | 10 | 7311 | | 00 | 10 | 01 | 11 | 7309 | | 00 | 10 | 11 | 01 | 7311 | | 00 | 11 | 01 | 10 | 7311 | | 00 | 11 | 10 | 01 | 7312 | | **01** | **00** | **10** | **11** | **7308** | | 01 | 00 | 11 | 10 | 7311 | | 01 | 10 | 00 | 11 | 7310 | | 01 | 10 | 11 | 00 | 7309 | | 01 | 11 | 00 | 10 | 7311 | | 01 | 11 | 10 | 00 | 7311 | | 10 | 00 | 01 | 11 | 7311 | | 10 | 00 | 11 | 01 | 7311 | | 10 | 01 | 00 | 11 | 7309 | | 10 | 01 | 11 | 00 | 7310 | | 10 | 11 | 00 | 01 | 7311 | | **10** | **11** | **01** | **00** | **7308** | | 11 | 00 | 01 | 10 | 7312 | | 11 | 00 | 10 | 01 | 7311 | | 11 | 01 | 00 | 10 | 7311 | | 11 | 01 | 10 | 00 | 7310 | | 11 | 10 | 00 | 01 | 7311 | | 11 | 10 | 01 | 00 | 7309 | +----+----+----+----+------+ ``` Thus our choice of encoding bits yields the optimum file size. ### Why are the last 31 bases handled specially? The last 31 bases are handled specially because we are encoding 4 bases per byte, yet the RNA sequence consists of 29,903 bases, which is not a multiple of 4. Thus we must either (i) leave some bases out of the encoding process or (ii) pad the last byte with 2 dummy bits. We choose the former approach because it results in shorter code. Sensible choices are the last 3, 7, 11, 15, 19, 23, 27, or 31 bases, because (i) these bases are all `A`s and so are easily appended, and (ii) the size of the sequence to be encoded is then a multiple of 4. The optimal choice is 31: each lower value successively increases the size of `f` by a byte, but the size of the decoding program either doesn't change (for 11, 15, 19, 23, or 27) or decreases by only a byte (for 3 or 7). --- # Original answer: [Ruby](https://www.ruby-lang.org/) -p, 11,793 bytes My first, rather naive, attempt at answering a [kolmogorov-complexity](/questions/tagged/kolmogorov-complexity "show questions tagged 'kolmogorov-complexity'") challenge. I had fun nutting it out but it's clearly not competitive. You can read all about it in my [answer](https://codegolf.stackexchange.com/a/205878/92901) to a virtually identical question that was closed. [Answer] # [Python 3](https://docs.python.org/3/), ~~10,667~~ 10130 Bytes This code is *completely standalone* and requires no files or inputs. ``` b="fa9usLQpqGkcGLBgzDmz1MqlcvagD352jVNH5tEjI40quejbsDTCJYlncBzgwEpNLl1BA3xJRggoizpvTR93kWpqX8ZPDQFvGSWciTOjJv6Dvi9BST5TlFLFmMT889Lgm-lyizqmFIxFLnmnCapTv6yjCi6KD1HGlw8EBcEkyFyDr9C59omjSpHy0VBtFCYjFDPDQyD=Sbkn-uRG9zzBqWVqqpoFFOtuVUSza2fCLpSS5FICAuCmvymaNWIqitJFDsRCjH7C5qVp-eIBKDSqGLNFQCFKQzC3HqmPzolEFqowhIv2Sij8LrCIqZ=DeNNRCiC4CbEx0I8lwCaZKCf4YkvCbqf-aWfCILGF8hAavDfALawHbGYrykd9CaWa5CFLr=tbBgDKAnE2kaChGOb3PwczHW3CyxFCcwh4Y=SvDqoIxSfxFICWvYqmpEIsxFuLkOaEDDqbuxAohyGwmnpkC4tzESeOqCgFLWcHzBq=FBIrELFpND1MuDFxOqG3EKx9AlEtUqHpxqOspDDFmpwSpzqCGPzCbjOamWnGHGrDFCLqjqCmXUHrv-gvwEwIdEvD8cDWpv8uqofGibDCgNFqvqnsapaoqapENWrFCiWgbjZAzuEfEgm-EBDDlgbvMRIzCcEyawD7DviW-UrcbjmFbwi0wjZjHCErX1IgCv-sqGznDb-KHspFDDy1Yw435cqHLFIDuCajGkTPCx5CmW1q8pDm1ztmVx8bDqfrMcN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6moFjAKFEqGmVHHh9EcC=oLWskamyHFIRGAEqGEEbT5ijAypccf6apLKUmpZJpVJyoMwBwMgltBGJwdawcApJJt=cwAEtb-FGFVCEEzEv555CJfWO5CZGb2FqpOiiipOcDIqWgEEC-wqW6B4alsEIqoeGDciovVJlFAmicOpavF8O8jbJipcCuGix64bEifEQJUwo1LVb27HFH8nIkw=c31YKIpEHGf8CGmAavGmynHv5Wq4rCUeGcfQkcm6qa8GaWW-CCcyoLk4ZiWWi4cDYzzAEEmv8CvMGif4igHZJECMcy-KcyEmOId4X=KraTvUvA1sXetzjL3JbWwBqKHoinmDnqLqzIe4gvbJD0iu=pjCdoIIfwkZ6lVnlgZDi3cb5pZoEKr8m6KhDafbvnn5gQhCvqtLLpmhi" import string as s l=s.ascii_letters+s.digits+"-=" a="0123" z=dict(zip(l,(x+y+z for x in a for y in a for z in a))) c="" for i in range(9957):c+=z[b[i]] print(c+"0"*32) ``` [Try it online](https://tio.run/##RXhZk6s6tub7@RUnzlNVV/sG2OBtOsIPTg2AjY1zpzMB37jRIWEGgQVIgBj@fLVOvfSLw8FgSWutb3K3DGXb7P79b3r8KyfO2AefnXDr1A0@ihXy1byKd6pIAXf2tvq5efaAKt8yxJhVtIcPcE7eTfqxFhPqbsHb/Djt5vPvomjZ2qnHb2dXR52ID887/MTK/YpS9girs9pDxZyPr4f9eOMA8@vjcHCCgm/eC1sFx/6Mg4Y3gHQPtV8qwPYXaHruezqgjxTVC16gdIDttLz66rzF@PkYMEgqDPUyCzx@0brZjL9dZ10/RPQjRNdiHA7jz/fXSrY5CLqvLxv74DQCrhZObpEv2HDGsP8NKu8XsMVPt8n8jwv8Em5ww58AXz5XsPMEv6/tG2HRTqWvtl@sOgQS@OJ5hNnt9hswYAGKZsM/vCdAnheQW0mtABX5hkQ58AMXH8oTUTA/BWTyqJvIpX45gETEBjiQx4F@FPByatC2JqB0Q7q7T@nqRTuwzBikU2klxy8FRevPX/msjxCpRPAO@f2Mx6AOCYJQ0HE@teXi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T@AuX3c28UD@cGvaRfRh5dlZ3sw9Gd8z3XXqh2NA9Rab50NGjUkNTlO9pN6shX1a9dqqJCwhch2T5RVD92@tNjOsrn1J8FmGE@fuMN78Kwt4f@7BTtSt6tJ1N/3v1F4bdA7@L/POjY93jRIXvDucTByHFl8vvV9uf3/QDY/AjaMTX8@lVGupyuXcp3vMWV6cLRsLlP55XOigFxzaI@prwxcP@b/ekb2lMPGxWnZYuTfM96YLLN@@e5@7nvLTX6WO6Fu/hwz1PLzKlp@58Ho7pdEID3WAX/wCEVqRs2wbnPApt8HSpJtEuZIx1YQp9ERUIgc0kov2HRd498kWbuZp6W/VzfuMTZ2nYEYUP4aGiZ9alYHTZvLcoYjn6PH9PrRn80O0vD3uHxq@nY7ozk4vfIc/ND8DlJ6Jcvvwd9CNhSfCduWn@qX3OXpCDS6JoA0C6tEFtPVkUMSuFybqeEOLqANTVZbnFCu95RuCaLptLqhU/9F9WfLxIbfq/1cns42xYq2B3ptH0IS5eyxoOGxGI1c@sQtEzNNh47Crwan0/n@rn/v3TvIsnZLuU2t2zRRd54PtLCUlOVdPYxWcJlBiCoOMl@@sPxrtWDn/2g2RN8Sfp/@z/eB/7/yJ9ytj/fWfDkMn@X/1/vVjBhv5ff22Of/1Bjn8Z5nb31x/r8cXS4R8r6/7x/t//mP@1/Gv9M2/ln/OfrPmT/Ofr8v@/rv/5@s9//vOP9PjXX3/8fYn9fUmSpsj@oSPhr3/@n/Rfx/W/6X@z//mfPzq9oeEf6b/@Mv76X7vtP//97/8H) # Explanation I first took the string of AUGC characters and rounded it off to a multiple of 3 (shaving 32 A's off the end). I then replaced every A to be 0, U to be 1, C to be 2, and G to be 3. Let's call this new string x. With x, I then made a new string, b, which takes three characters at a time from x and uses the reverse of my z dictionary to encode it into a string that is 1/3 the length of the original. After this, it was simple: all my program needs to do is to have the b string, and decode it one character at a time using the z dictionary, then add 32 zeroes at the end to make up for the 32 A's I took off in the beginning. The most recent edit makes use of Will's suggestion as well as a few of my own improvements. [Answer] # bash + `flif-tools`, 26 23+1+7359 = 7386 7383 bytes Same setup as @mypronounismonicareinstate, but the bash script is trimmed by 14 17 bytes. I don't have enough rep to comment so I'll have to put it here: ``` flif -d f -|sed 1,3d ``` Edit: Improved by 3 bytes - thank you @Mitchell Spector. Original: ``` flif -d f -|tr -cd ACUG ``` [Answer] # bash + zpaq 1.10, 1716 + 1 + 7360 = 7377 7378 7377 bytes *Note: this was done with version 1.10 of zpaq, released in 2009, obtained today for Ubuntu 18.04 via `apt-get`. The **latest** release 7.15 of zpaq not only has much more verbose option syntax, but does not even support the older options for omitting metadata. Therefore this cannot be reproduced with the current release of zpaq.* Similar to [my-pronoun-is-monicareinstate's answer](https://codegolf.stackexchange.com/a/205895/13951) but using [zpaq](http://mattmahoney.net/dc/zpaq.html) instead of flif-tools. Decompression bash script, 17 bytes: ``` zpaq xq g >(cat) ``` Requires the binary file `g` of 7360 bytes created with this compression command: (plus one more byte for the filename `g` length) ``` zpaq nsivc g uncompressed.txt ``` which has this binary dump: ``` 00000000 7a 50 51 01 01 45 00 03 03 00 00 08 03 05 08 0d |zPQ..E..........| 00000010 00 08 11 01 08 12 02 08 12 03 08 13 04 04 16 18 |................| 00000020 07 10 00 07 18 ff 00 11 68 4a 04 5f 01 3b 70 0a |........hJ._.;p.| 00000030 19 3b 70 0a 19 3b 70 0a 19 3b 70 0a 19 3b 70 0a |.;p..;p..;p..;p.| 00000040 19 3b 0a 3b 70 19 45 cf 08 70 38 00 01 00 00 00 |.;.;p.E..p8.....| 00000050 ff 32 25 ab 62 89 2f d1 b5 43 28 d9 e3 2f 27 99 |.2%.b./..C(../'.| 00000060 8f 57 3d 5b 71 fe 32 8e ab 5c 04 59 9d 46 32 16 |.W=[q.2..\.Y.F2.| 00000070 60 58 75 a5 47 06 9c ac e6 98 00 75 5e e1 15 85 |`Xu.G......u^...| 00000080 e8 de a9 05 22 22 0b 4a ff 03 54 76 b9 cb a0 f3 |...."".J..Tv....| 00000090 44 d8 c4 0d a4 aa 9d b1 9a 02 5d c0 3a ed 8c f4 |D.........].:...| 000000a0 e7 75 ea e0 2d 37 36 d6 fe 72 dc 9e fa 81 4e e3 |.u..-76..r....N.| 000000b0 6a 53 55 14 02 9f 04 1a 4e 41 35 e3 f2 5c 59 7b |jSU.....NA5..\Y{| 000000c0 e8 26 1e 5b cc 6b d8 a4 71 15 0e b0 e2 92 51 be |.&.[.k..q.....Q.| 000000d0 6c a3 22 d4 f1 59 03 24 93 72 25 ed 39 e5 87 ac |l."..Y.$.r%.9...| 000000e0 91 bd c4 c2 92 a6 eb ff 96 25 27 9a c4 cb b9 be |.........%'.....| 000000f0 33 5a 0d ee fa 7a bf 4c c9 b1 c0 96 80 51 cb c1 |3Z...z.L.....Q..| 00000100 bb d7 9b 9b dd d6 7f d8 c0 42 45 b1 69 cf 97 11 |.........BE.i...| 00000110 52 1e 57 c6 5d 93 e7 b3 7b 91 9f 08 d4 f7 32 70 |R.W.]...{.....2p| 00000120 3c a2 5a 38 71 8f d6 77 63 05 45 cb 86 3c 7b 8b |<.Z8q..wc.E..<{.| 00000130 dd be ae d6 13 75 1f 4a 4f 79 a5 eb 3b 6f c1 75 |.....u.JOy..;o.u| 00000140 aa d8 f9 fe 33 65 a8 cf e3 36 f9 86 f2 d7 6b 0c |....3e...6....k.| 00000150 5a a6 74 03 9f 5d c3 5a f0 4d 12 16 1d d6 4e 4b |Z.t..].Z.M....NK| 00000160 a4 a9 ce 30 43 f2 54 16 dd 34 8f 13 65 d9 0b 84 |...0C.T..4..e...| 00000170 71 40 45 ca e9 3c d1 79 d5 fb d1 e0 0f d2 44 e8 |q@E..<.y......D.| 00000180 7c 47 fe 7e f9 24 38 28 34 18 0c b5 b1 79 d5 90 ||G.~.$8(4....y..| 00000190 d5 22 98 ea d5 f6 8b d2 d7 9e 04 b5 95 e6 bc fb |."..............| 000001a0 52 d3 6d 99 c8 bc a1 a3 bf cc 3d 94 10 6d 9b 2f |R.m.......=..m./| 000001b0 5b b5 7c 8c 06 02 2c a4 f4 37 3c c9 c9 08 d9 d3 |[.|...,..7<.....| 000001c0 c5 6a 42 b1 6b 14 7b ca 34 30 16 90 0f 3a 84 6c |.jB.k.{.40...:.l| 000001d0 c9 a6 9b 83 9c 4d b8 c5 3e a1 1c d8 84 0d b1 a0 |.....M..>.......| 000001e0 91 ad 6e 4f e2 50 c8 22 c3 31 5d b7 0c 90 13 99 |..nO.P.".1].....| 000001f0 ba f4 6b 8a 0d c5 eb 45 fb 7b 93 5e fb 26 4c a4 |..k....E.{.^.&L.| 00000200 2a 74 2c f6 cd bd 9f 2c f5 9a 3d 52 00 fd 71 c4 |*t,....,..=R..q.| 00000210 a2 08 1c d9 0f 90 e2 c4 45 4e 75 67 7c db 18 29 |........ENug|..)| 00000220 f3 37 53 e5 3f 6f 79 72 10 44 c2 be be 54 bd f4 |.7S.?oyr.D...T..| 00000230 f9 de 6c 7d 78 fe cc 10 52 52 79 2b 11 41 e8 0d |..l}x...RRy+.A..| 00000240 43 d7 97 61 f9 65 1f 47 5d 74 8c 63 72 2f 39 bc |C..a.e.G]t.cr/9.| 00000250 e8 ad fd 2d 88 a3 96 46 11 dd 53 0b bb 1b e5 77 |...-...F..S....w| 00000260 77 a9 20 cd 0b 80 e4 ff 76 58 b7 3e db cd 07 02 |w. .....vX.>....| 00000270 e2 d2 2e f7 d2 fa 68 f7 59 7b aa 3b be 7a 48 33 |......h.Y{.;.zH3| 00000280 c8 1a e5 69 f6 a9 47 b1 27 0a cd ea 23 cd 4f ec |...i..G.'...#.O.| 00000290 16 99 28 0a 39 a0 fa 68 6d e6 3b e7 4f eb 8b a2 |..(.9..hm.;.O...| 000002a0 71 ca a9 cb fe db 19 b1 72 86 5b b0 bf fb 66 d5 |q.......r.[...f.| 000002b0 0e e4 25 22 8e 01 40 ab ed 67 76 a4 80 b2 b9 8f |..%"[[email protected]](/cdn-cgi/l/email-protection).....| 000002c0 2d 57 8c bf 48 9f 9c 59 74 9a 61 f0 66 0a 0e 72 |-W..H..Yt.a.f..r| 000002d0 32 ca cd ff 59 fb d5 22 c8 37 b4 56 03 02 eb 1a |2...Y..".7.V....| 000002e0 e1 f7 fe a0 6b c5 69 3b 25 a5 41 f3 e5 c9 d7 45 |....k.i;%.A....E| 000002f0 9f 5c f1 ad 3a a4 e8 65 16 4c ae 8b 99 e2 d1 08 |.\..:..e.L......| 00000300 a3 ad 07 7e b2 cc e3 ba 76 74 28 04 1c 30 52 4f |...~....vt(..0RO| 00000310 a3 16 74 65 78 a5 b2 ff 4b 91 be 3d 03 00 d0 f8 |..tex...K..=....| 00000320 92 ee 9a 0b ed 1f 42 04 d1 06 b1 26 6e b9 ca dc |......B....&n...| 00000330 9f be 38 5e 95 66 89 cf 1c d6 3b 01 ca a5 17 43 |..8^.f....;....C| 00000340 28 39 32 bc 49 ef ce c8 c3 62 de bf b3 de af 86 |(92.I....b......| 00000350 24 5e 5c 8b 24 41 24 ae 07 e2 f9 65 1f 36 19 90 |$^\.$A$....e.6..| 00000360 f7 f6 6c 33 5f 33 df 4e 8a 70 80 a7 62 37 ef e8 |..l3_3.N.p..b7..| 00000370 02 17 b8 c3 5e ae b9 66 40 d2 98 a2 95 32 31 ac |....^[[email protected]](/cdn-cgi/l/email-protection).| 00000380 e5 06 ed 2c 21 e2 44 1c f3 d0 45 17 84 e8 79 f8 |...,!.D...E...y.| 00000390 9c fb c5 d1 1e 5e 16 43 c7 56 3e ae 33 b8 6f 98 |.....^.C.V>.3.o.| 000003a0 42 2b 59 2a 9a 14 6c 4e 16 03 81 94 4f fa d0 d5 |B+Y*..lN....O...| 000003b0 58 9b 04 ed 66 0b 9e bd 1f 28 af cb 2a a5 fc bf |X...f....(..*...| 000003c0 b5 f9 50 33 2e 16 70 c3 9b 71 8f fc ed 96 53 55 |..P3..p..q....SU| 000003d0 e5 14 7a 61 e1 e9 a9 93 dc 36 08 5b 52 ce 6d 61 |..za.....6.[R.ma| 000003e0 d9 23 cd 82 d9 7d 12 f4 57 20 09 77 08 53 61 50 |.#...}..W .w.SaP| 000003f0 da 51 b3 df f8 37 b8 da f8 29 1b 32 90 ee d7 e0 |.Q...7...).2....| 00000400 b6 ee 54 af 33 12 25 bc eb 69 d0 7c 76 a7 cb 48 |..T.3.%..i.|v..H| 00000410 44 19 b7 07 1a ac 30 32 58 56 92 e0 99 37 8b e6 |D.....02XV...7..| 00000420 c7 b4 ae dd bf a6 3c a8 33 d7 2b 35 83 32 32 03 |......<.3.+5.22.| 00000430 c8 99 4d 25 17 6b 36 1e 9c db 9d bb 53 aa 00 b0 |..M%.k6.....S...| 00000440 e7 d9 ee e0 f2 e3 44 a5 94 ca 52 fe 6b aa 72 db |......D...R.k.r.| 00000450 d9 dc 99 ba a9 5f 6a 08 90 78 c6 3c a3 98 0c 9c |....._j..x.<....| 00000460 7c 50 aa 71 aa 8f 1c 8c 39 30 9e 12 da 5f c3 8b ||P.q....90..._..| 00000470 1f ab b8 ca 1f 32 30 2a dc 29 9d 90 d4 57 c2 16 |.....20*.)...W..| 00000480 db ed 76 08 ed 9b 67 0a 18 9f 1a 18 6d 04 3e f4 |..v...g.....m.>.| 00000490 01 74 81 3d 6e 47 a7 0f 7c 55 56 e4 8f 0a dc c0 |.t.=nG..|UV.....| 000004a0 b6 d1 1c 11 a1 ce 6e 33 29 83 9c 51 ec d8 f2 db |......n3)..Q....| 000004b0 e1 c8 14 b8 31 e2 b2 5d cd 00 8a f3 79 4b 0b 7d |....1..]....yK.}| 000004c0 69 a7 d7 4c 73 a7 1c f7 b0 4e e6 ff d2 db 73 6a |i..Ls....N....sj| 000004d0 c0 65 a0 ef 8c 51 72 f3 ad de 2e 48 bd 86 40 36 |.e...Qr....H..@6| 000004e0 af 3a 66 78 66 1c 56 22 03 10 be 8d 9c 34 fa 3b |.:fxf.V".....4.;| 000004f0 08 31 f0 69 9f 80 0e 4c aa 73 fa c8 3f f8 4a ac |.1.i...L.s..?.J.| 00000500 61 61 55 24 c1 71 70 d4 ab 48 3b e3 93 3e 15 f7 |aaU$.qp..H;..>..| 00000510 a7 21 8d cc cc c6 f6 c2 78 9f 75 e3 69 d3 3d 6d |.!......x.u.i.=m| 00000520 2a c2 9a 22 8d 38 ab ba 99 91 6d 6f c0 73 33 4a |*..".8....mo.s3J| 00000530 62 e1 a9 24 80 58 b3 45 25 e9 5a 70 43 64 e6 2e |b..$.X.E%.ZpCd..| 00000540 ae 56 05 b2 32 0a 7f a3 c1 ae 08 99 0f 56 a7 53 |.V..2........V.S| 00000550 15 64 a3 df 0c f9 96 f8 c7 07 5f 42 b8 89 15 c2 |.d........_B....| 00000560 87 99 71 fe 74 45 1b 86 99 22 18 60 db f9 28 9e |..q.tE...".`..(.| 00000570 fb 3d 90 73 5e 34 a9 ef 28 00 a5 2c af 7e a9 7a |.=.s^4..(..,.~.z| 00000580 3f 70 79 eb bb e6 03 26 76 8c 05 75 13 1c 1d 5d |?py....&v..u...]| 00000590 8f df 96 df b1 2e 3f 5a 49 1a b1 32 fc 09 af a5 |......?ZI..2....| 000005a0 54 4e 47 30 23 be eb 96 58 c3 34 9b 12 39 47 55 |TNG0#...X.4..9GU| 000005b0 d0 aa 15 b9 3a ac 4d 73 21 45 7e d8 ce 51 0a ff |....:.Ms!E~..Q..| 000005c0 c2 14 53 68 ca 36 a6 68 29 67 4f ab 1f c4 9c 91 |..Sh.6.h)gO.....| 000005d0 4e fd 0e 23 0f ea d1 47 b9 33 0d 46 3d 6d 42 d1 |N..#...G.3.F=mB.| 000005e0 2c 24 29 8e dc 06 40 73 03 c8 b8 22 e3 e0 8c 80 |,$)...@s..."....| 000005f0 7d b4 06 b4 71 73 7a 83 cb 18 e9 dc a9 ac 5c 6f |}...qsz.......\o| 00000600 3d 17 90 9b f6 de c0 f9 32 2a 77 62 87 85 ec cf |=.......2*wb....| 00000610 69 ee bf 0e d6 83 ea d8 8b 31 00 7c be a0 cb 4a |i........1.|...J| 00000620 d3 d2 7f 4b 9e e7 50 8b 46 ef 38 55 48 ba 87 14 |...K..P.F.8UH...| 00000630 d9 b3 a1 9d 5f e2 c5 51 86 f2 0d 03 55 91 7a 76 |...._..Q....U.zv| 00000640 23 20 20 b0 b3 03 c1 2e ca b3 9e 70 33 03 5a cc |# ........p3.Z.| 00000650 fb 78 26 e9 8e cb c3 2c d6 2e c9 5d d7 b1 69 64 |.x&....,...]..id| 00000660 0f 15 9c df ca 2a e5 d1 1c 8f ca a1 37 bb f2 d0 |.....*......7...| 00000670 e1 85 31 95 63 ef f8 71 a9 a3 75 97 72 b8 76 5a |..1.c..q..u.r.vZ| 00000680 1d 7b 0c dc eb 7c 10 43 db 56 64 0b 1c 03 2f 76 |.{...|.C.Vd.../v| 00000690 0d 3c 62 0f 13 7f bc 48 4b c8 80 ac 63 db 01 9d |.<b....HK...c...| 000006a0 d1 31 76 86 9c 5a 99 9f 62 21 70 e8 91 5c 28 ea |.1v..Z..b!p..\(.| 000006b0 ef 3a 6e e7 27 cf 1f 68 40 09 cc 8b a0 c6 76 15 |.:n.'[[email protected]](/cdn-cgi/l/email-protection).| 000006c0 de 61 b0 b4 58 e7 af fe de f2 9d 64 bb 46 8c ef |.a..X......d.F..| 000006d0 eb a5 24 bd 15 b9 06 e7 d4 d5 a2 94 e5 74 8b 20 |..$..........t. | 000006e0 81 06 6e 65 20 e7 6a d8 fc b1 19 7f 26 74 30 6b |..ne .j.....&t0k| 000006f0 15 6a c5 4a 98 26 be c2 aa 20 b0 98 4e da 8c a2 |.j.J.&... ..N...| 00000700 c4 aa af fa 81 e9 1b cf 03 cf 46 0e be 6f 63 03 |..........F..oc.| 00000710 66 30 41 4b 8f 91 0b ba 7b 86 f6 3f 99 ac e5 02 |f0AK....{..?....| 00000720 ce 61 87 7d 5c 6e 13 3f 5c ae b5 5e ed ec da e2 |.a.}\n.?\..^....| 00000730 89 97 0b c4 71 5a f8 83 1a c5 a7 cc a1 11 7d d3 |....qZ........}.| 00000740 15 e9 fe 0d 3a 56 cf 51 6c ad 3e 4d 0a 40 54 71 |....:V.Ql.>M.@Tq| 00000750 03 0a d5 00 ea 1d 68 32 cb f5 72 22 4e bc 48 78 |......h2..r"N.Hx| 00000760 c3 b1 af f8 d8 4c 83 ca d4 d9 a2 29 26 00 d5 da |.....L.....)&...| 00000770 c5 56 9d 19 16 e6 36 bf 61 f9 21 77 ca 4a 9f 85 |.V....6.a.!w.J..| 00000780 c8 be cc c3 a6 b0 bc 7e 1e 6a f2 fc d4 29 86 38 |.......~.j...).8| 00000790 bb a1 eb a0 21 0a 2f 73 5d af 45 4f d3 01 05 28 |....!./s].EO...(| 000007a0 9c 8c 8c f0 d0 be bc 75 8d 4f d2 14 ad 9d 49 22 |.......u.O....I"| 000007b0 9a ff f4 92 c1 b9 01 77 07 fc f2 8b d9 ff 4f 9b |.......w......O.| 000007c0 a7 52 e7 4d 37 79 ac bc 5e af 1e 42 9a 84 a2 d6 |.R.M7y..^..B....| 000007d0 d4 14 cc eb 80 e2 0e 04 4e 13 f6 d0 da 06 26 94 |........N.....&.| 000007e0 c7 03 4b f4 37 2c a2 20 ff ce 1d 54 ee 65 a7 7f |..K.7,. ...T.e..| 000007f0 a7 e9 43 fe 69 ca c2 17 2d cf 23 95 6f 0b 63 db |..C.i...-.#.o.c.| 00000800 ff 39 17 5b 2c 34 66 62 c8 6b f1 74 48 ec 74 4c |.9.[,4fb.k.tH.tL| 00000810 a1 2e 4d 9c f3 b2 64 4b d5 0f 59 89 a3 e3 7f bd |..M...dK..Y.....| 00000820 55 1f 8a e1 91 97 7c df a4 86 7b 45 df 54 a1 3c |U.....|...{E.T.<| 00000830 0f e9 9f 87 f4 76 8b 15 bb 18 a8 ff 56 38 ff bc |.....v......V8..| 00000840 8b ae 60 7d 71 65 25 83 9d 84 49 03 39 de 89 6c |..`}qe%...I.9..l| 00000850 f7 dd e2 ef a0 3f 82 78 12 2b cb f1 c1 0d 7e a6 |.....?.x.+....~.| 00000860 eb 46 22 7e 4e a9 ef 58 34 03 9b 7a 4a 0c d3 0e |.F"~N..X4..zJ...| 00000870 0a 89 21 ef 55 36 ba 28 9d 8a 23 d0 d1 8b 81 46 |..!.U6.(..#....F| 00000880 ba 41 f5 49 43 6a df 7b a8 21 31 a9 44 8c 6a af |.A.ICj.{.!1.D.j.| 00000890 da 57 fc e7 9a 24 3b 85 64 d3 9e b2 c1 ba 4d fd |.W...$;.d.....M.| 000008a0 69 8d cc 20 b7 9f 50 50 9d 34 68 b1 59 2e 70 5c |i.. ..PP.4h.Y.p\| 000008b0 f8 bd fc 0d 14 63 91 e3 62 36 a2 26 20 62 c9 0e |.....c..b6.& b..| 000008c0 5a b0 0f c3 6d 30 6a 89 a8 4e 36 b5 30 1e eb 5f |Z...m0j..N6.0.._| 000008d0 80 6a ba eb a3 a7 70 51 b8 8e cb 72 df 13 8f 7f |.j....pQ...r....| 000008e0 86 28 41 db 6b e8 03 8c ae 7a b9 72 ef 56 4c 24 |.(A.k....z.r.VL$| 000008f0 f5 c6 77 53 8c 49 f2 38 20 7a 4d 5e a9 38 ee 81 |..wS.I.8 zM^.8..| 00000900 5a 0a 72 e0 83 2a e0 33 b6 1f ac 57 59 6e 41 1d |Z.r..*.3...WYnA.| 00000910 35 2b 1d e0 4b 9f dd b5 ad c6 7f 75 ef ed 4d 8e |5+..K......u..M.| 00000920 36 ce 90 ab b2 7e 5f 2b 83 00 59 4a 14 84 c6 14 |6....~_+..YJ....| 00000930 81 09 90 82 92 8b 99 4a ae c4 41 85 52 3c 75 49 |.......J..A.R<uI| 00000940 75 fc 7b a2 ab 69 b3 65 90 5c 94 a2 8f f4 b1 93 |u.{..i.e.\......| 00000950 ec df f7 e0 82 63 b0 9f 4f f0 86 9e 4b 4e 89 84 |.....c..O...KN..| 00000960 b3 05 74 09 2b 1c ca 74 4c 9f cf 65 97 ab c2 6c |..t.+..tL..e...l| 00000970 ce ca 27 03 7d d5 09 ee e2 f8 61 56 06 ff 56 09 |..'.}.....aV..V.| 00000980 d9 e5 83 ee 8d 76 c5 7c 88 c5 b2 5a ff 1d 79 e5 |.....v.|...Z..y.| 00000990 40 a9 8c c4 3a ad e0 5c e5 19 48 3f 8e 27 9e 3e |@...:..\..H?.'.>| 000009a0 cd e8 dc a7 2a e5 c5 9d 98 e2 02 7a 88 31 0c 5a |....*......z.1.Z| 000009b0 30 9f 89 89 58 08 11 62 90 b4 38 68 c1 16 9a bf |0...X..b..8h....| 000009c0 4d 6f 60 0c fd 70 73 51 b6 e6 46 55 25 47 b8 8f |Mo`..psQ..FU%G..| 000009d0 47 8b bd 5b 10 d1 da 86 13 5b fc ee a0 9d d5 2b |G..[.....[.....+| 000009e0 f9 53 ce e4 e8 cc a0 82 7a e0 cd 7c f8 34 aa 0c |.S......z..|.4..| 000009f0 30 89 37 8a 75 15 54 5e 6a 78 1e 82 e9 af e5 3a |0.7.u.T^jx.....:| 00000a00 46 05 90 a0 87 e7 cf bc eb 6b 28 e2 02 13 85 23 |F........k(....#| 00000a10 1a c5 c0 43 ee 06 b9 1d 4e 09 86 48 18 bf cd 32 |...C....N..H...2| 00000a20 bc ee 0f 2d fe 5c 07 e6 0f c2 1b a8 08 d3 2a 41 |...-.\........*A| 00000a30 97 be d1 f9 e1 60 d6 bd 1d a6 46 2e ea 9c 79 3a |.....`....F...y:| 00000a40 2d 54 8c 06 54 70 a0 35 54 63 cd aa b5 f5 99 2c |-T..Tp.5Tc.....,| 00000a50 d9 ed 1b 3b 48 8a 21 bb 17 8a f7 89 3d ac f3 34 |...;H.!.....=..4| 00000a60 85 9f 5c 26 74 87 64 30 39 91 c7 18 ce cb b1 bf |..\&t.d09.......| 00000a70 dd 81 b9 f2 12 98 24 40 1d 7e 8f 30 9f 87 d6 62 |......$@.~.0...b| 00000a80 b4 02 66 42 83 e5 1e 76 67 72 99 5c d3 87 2e b4 |..fB...vgr.\....| 00000a90 e8 00 8c 94 12 5f 51 89 52 98 db 9d 13 71 5b 12 |....._Q.R....q[.| 00000aa0 3f b9 bf f5 9d 57 ba 12 02 cb 18 b8 5b 6e a5 de |?....W......[n..| 00000ab0 41 99 b4 71 62 58 65 3f 1a 43 83 f1 75 75 63 65 |A..qbXe?.C..uuce| 00000ac0 5c f3 e1 37 d2 b2 13 3d dc 96 97 4f ad 21 5b 81 |\..7...=...O.![.| 00000ad0 a2 b7 59 5f 00 09 55 ff 10 8a 75 87 ea 54 07 4d |..Y_..U...u..T.M| 00000ae0 9d ff b4 bd da c7 e4 43 dc 6b 41 cc 0d 64 3e 92 |.......C.kA..d>.| 00000af0 24 10 73 ce 0b a0 d7 d9 f6 c5 5d 4b 7a 40 51 ce |$.s.......]Kz@Q.| 00000b00 c5 38 46 cd 88 06 03 eb 5e f1 43 24 16 31 3e ce |.8F.....^.C$.1>.| 00000b10 18 02 d5 b7 99 33 b2 57 78 79 6d 2d 21 aa 22 68 |.....3.Wxym-!."h| 00000b20 bf b9 b9 1a 3c 9d a3 0f 9e b0 7d 2d 85 60 ba 29 |....<.....}-.`.)| 00000b30 f7 e0 91 11 ec 21 bd e0 bd 37 21 78 1b 50 f2 24 |.....!...7!x.P.$| 00000b40 c1 1e 8a 75 90 14 c6 4b 22 85 94 25 b0 1a 13 ee |...u...K"..%....| 00000b50 88 1d 40 3e 08 05 ef 13 c0 92 e3 44 c9 ca 8b 6c |..@>.......D...l| 00000b60 ae dc ca 03 eb 27 01 6a 32 ed d0 bd 9d dc d0 fd |.....'.j2.......| 00000b70 62 03 70 1c 73 90 e5 9c 89 d8 f4 83 88 8c 8d 36 |b.p.s..........6| 00000b80 b7 d8 13 64 54 61 a1 f3 27 af d9 61 f7 92 ba 55 |...dTa..'..a...U| 00000b90 37 36 24 4c a3 ca 45 ae 45 08 31 f5 61 ae f6 ef |76$L..E.E.1.a...| 00000ba0 fb 2e 53 2d 93 f6 8f 45 35 36 ef cf 48 7e 68 7c |..S-...E56..H~h|| 00000bb0 8a 18 ee 80 fb 36 c0 11 f7 84 0a f1 96 4c ec 88 |.....6.......L..| 00000bc0 3f 8c bc f5 e3 9b 6c 2b 56 c9 6f 87 51 b2 c5 ac |?.....l+V.o.Q...| 00000bd0 65 0f 42 bb 40 98 ed 91 3f c2 42 a9 c6 91 6b 75 |e.B.@...?.B...ku| 00000be0 55 5b 1b f1 75 ea e8 f9 a9 a5 90 8a 43 aa fd f3 |U[..u.......C...| 00000bf0 78 89 19 30 8f 12 ca 61 5c 32 77 91 93 37 42 02 |x..0...a\2w..7B.| 00000c00 b3 77 d8 6c d7 38 02 6a 53 f9 3b a7 03 25 f4 66 |.w.l.8.jS.;..%.f| 00000c10 67 94 0b 2c 09 92 5b 89 50 5a 4e 70 39 23 e1 97 |g..,..[.PZNp9#..| 00000c20 98 a9 5b 6c 1c b8 bd e6 8d e6 c2 6d 5e b9 49 e8 |..[l.......m^.I.| 00000c30 c7 3c 54 cd 81 4a c1 4b 75 26 84 7f 53 bd 42 66 |.<T..J.Ku&..S.Bf| 00000c40 96 54 b9 df d8 a2 7b 18 a5 ca d7 29 15 9c b9 99 |.T....{....)....| 00000c50 3e 1d 9b c7 9e c2 87 b9 ce 05 bd ec 63 3a d6 7f |>...........c:..| 00000c60 5e 5a ca f7 09 4f b6 03 14 6c a0 0c 4b 90 b3 dd |^Z...O...l..K...| 00000c70 df 96 8b 1c 82 5e 64 f3 c5 9c 30 d8 0f e1 e2 ca |.....^d...0.....| 00000c80 4c 62 3e ce 7d e6 ed 2d cd d4 5d 26 7c ae 3a 96 |Lb>.}..-..]&|.:.| 00000c90 f0 df c0 cf 8b 92 4a ce 09 fc 70 06 b8 ff 02 df |......J...p.....| 00000ca0 97 c7 73 b6 4a cd 79 c9 b7 52 bb 2b 55 3e a4 c2 |..s.J.y..R.+U>..| 00000cb0 15 5b b1 5b 94 fe 90 9e 46 4e c5 59 35 fe 00 4b |.[.[....FN.Y5..K| 00000cc0 5a 1e 88 ea 79 9a c1 93 5d 6d 69 ff 29 79 d3 8b |Z...y...]mi.)y..| 00000cd0 53 84 43 01 41 48 b2 a0 ad df e8 d9 29 1c 5b 21 |S.C.AH......).[!| 00000ce0 9c 3f 74 6e 60 7b b9 bc ef 7a 69 8c 4a 00 9c 89 |.?tn`{...zi.J...| 00000cf0 ae 5f 82 c1 31 17 57 2a 26 79 a7 e2 8f f8 e1 aa |._..1.W*&y......| 00000d00 c7 3c 6f 20 9e 24 20 0d da 93 c3 70 80 94 f7 60 |.<o .$ ....p...`| 00000d10 af 99 9f c1 46 d7 fa 34 31 98 08 70 6f 14 e3 87 |....F..41..po...| 00000d20 cd 59 0e 0d 71 26 a7 11 7f f4 08 fd 69 64 be af |.Y..q&......id..| 00000d30 dc e3 da 51 b2 7e 1e af a0 d3 3a 90 d5 26 cf 52 |...Q.~....:..&.R| 00000d40 87 91 7c b1 1c 13 e1 24 e6 4d 11 f9 ae 78 93 ee |..|....$.M...x..| 00000d50 c0 de a5 ae f9 f4 cf 33 88 aa 69 b7 c7 25 a8 08 |.......3..i..%..| 00000d60 64 61 16 b2 86 70 25 56 97 df 91 98 48 54 9b ba |da...p%V....HT..| 00000d70 f8 f1 35 d9 f1 c7 40 6e a3 00 67 9d bf 79 58 8d |[[email protected]](/cdn-cgi/l/email-protection).| 00000d80 88 19 e6 6a 24 c1 f1 38 5d 72 47 20 d4 a1 74 2d |...j$..8]rG ..t-| 00000d90 7d 42 4d 9f c5 c9 8b e3 1e f9 b0 b7 dc c1 ad 4e |}BM............N| 00000da0 6d 21 90 80 e1 d0 88 5b e9 43 03 20 2d 29 4c 8e |m!.....[.C. -)L.| 00000db0 36 a7 a7 a4 41 9e 5d da af 02 a7 a5 88 6b 70 9d |6...A.]......kp.| 00000dc0 11 99 f7 3e 86 52 32 e0 2d da 35 81 75 f6 a8 ac |...>.R2.-.5.u...| 00000dd0 70 b2 99 3c ee cd 99 d7 d4 10 7e 98 b7 17 2b 74 |p..<......~...+t| 00000de0 76 d0 e9 ac c8 a2 a7 d3 09 71 42 ee 23 18 b2 4b |v........qB.#..K| 00000df0 d2 c0 5b b0 67 8b 9f 08 d9 a9 85 24 f3 56 c9 d5 |..[.g......$.V..| 00000e00 73 12 f7 b7 91 87 d2 98 d0 79 bd 82 0d 4c 63 b8 |s........y...Lc.| 00000e10 4f d2 3d f5 37 92 04 6c 05 14 7e c9 f7 da 62 2c |O.=.7..l..~...b,| 00000e20 f9 a1 53 9b 0b 8e 9d 21 2b 32 47 83 6a 24 a6 e4 |..S....!+2G.j$..| 00000e30 62 bb 73 a1 66 1d ba b4 30 de 87 b4 d7 e0 46 6e |b.s.f...0.....Fn| 00000e40 03 62 6d 12 bc 42 ea 1c b6 2f 84 5d 2d a4 08 6a |.bm..B.../.]-..j| 00000e50 22 f5 2b bc 98 38 09 37 df 08 3e 66 b6 47 b6 38 |".+..8.7..>f.G.8| 00000e60 02 ac c1 3d 92 f0 93 8a ec d5 a0 42 fe be 23 22 |...=.......B..#"| 00000e70 9a 6c 3a dc 0e 8d 84 16 6d 4f ac cf 50 51 53 99 |.l:.....mO..PQS.| 00000e80 84 6b c8 a6 fa 5b 3b cb 10 fd be 92 1b 47 e2 88 |.k...[;......G..| 00000e90 93 91 a4 34 ce ed fd eb 08 e2 16 ad ce c8 ce 80 |...4............| 00000ea0 23 61 9a 99 1c 47 0f 2c f8 d5 25 8e e4 b4 d6 5a |#a...G.,..%....Z| 00000eb0 a5 25 0e 55 c0 e6 8b d5 07 ab f9 5c 19 05 05 62 |.%.U.......\...b| 00000ec0 cd 9c 78 e0 97 4e 6c d1 4e 6e 3a 5f 81 4b f1 a8 |..x..Nl.Nn:_.K..| 00000ed0 73 6c c3 65 9a 2b e6 5f 3a 4b e2 9d 01 18 56 0e |sl.e.+._:K....V.| 00000ee0 09 e1 2e 04 e7 e7 32 62 13 34 fd d9 a0 25 58 c4 |......2b.4...%X.| 00000ef0 f3 55 df 82 1f c0 fb 6b d3 8a be 20 2b e1 38 ec |.U.....k... +.8.| 00000f00 b3 48 fa 80 c0 0a 7c 6b 8a f6 16 4b 1e ea 6b 4d |.H....|k...K..kM| 00000f10 26 d1 c3 4e e4 88 b6 fe c0 54 eb 52 36 a6 4a 89 |&..N.....T.R6.J.| 00000f20 20 19 e2 ce 22 20 8c 59 8a ed 37 69 e9 33 f6 ee | ..." .Y..7i.3..| 00000f30 b8 a2 ae 86 66 72 7c 90 48 d4 78 7c b4 8a 78 29 |....fr|.H.x|..x)| 00000f40 27 23 39 6e 5b f6 b3 74 77 80 14 76 99 93 b2 e9 |'#9n[..tw..v....| 00000f50 0e ac 23 2c 6f 66 2a 7c 60 a6 d1 b7 65 19 73 c4 |..#,of*|`...e.s.| 00000f60 d9 db ab 43 51 cf 82 82 2e e1 65 ed b4 90 cd 78 |...CQ.....e....x| 00000f70 91 82 e6 42 87 c1 d9 71 36 eb bd 15 30 09 c5 e7 |...B...q6...0...| 00000f80 bb ab 09 2b ba 41 e4 3b df d6 d9 dd b8 20 58 83 |...+.A.;..... X.| 00000f90 f0 b5 d1 fb 28 95 35 04 f2 cf b5 d1 96 22 9d d8 |....(.5......"..| 00000fa0 35 22 73 5f d3 dc 7e e8 a9 5e a0 1b c4 fb 03 a2 |5"s_..~..^......| 00000fb0 21 54 a4 ae 97 bc 17 52 62 76 de db 1e d4 d5 41 |!T.....Rbv.....A| 00000fc0 4b a8 29 ea 10 bd 88 49 e9 4a b3 10 87 19 df 1b |K.)....I.J......| 00000fd0 d0 23 c9 1b ba 43 7c 27 8d 59 3a 02 58 7c 8e 96 |.#...C|'.Y:.X|..| 00000fe0 34 7c a7 e5 57 0b a5 4c f7 1c 2a 12 da 4f ef f4 |4|..W..L..*..O..| 00000ff0 47 13 8b 63 fb ad 97 55 ca 40 d7 37 59 f7 9d d6 |[[email protected]](/cdn-cgi/l/email-protection)...| 00001000 2c c8 d1 76 2c e0 96 a7 20 e4 9d f8 99 16 f8 bf |,..v,... .......| 00001010 9f c1 95 fa dd 0d a3 bb b8 b5 ab 1c 25 0d e4 f5 |............%...| 00001020 47 9c 85 4b 1f d1 49 30 bd 52 7b 12 be af 1a 89 |G..K..I0.R{.....| 00001030 5b dd 97 50 fc 16 bb 2c c7 7d db 25 9a 01 15 bb |[..P...,.}.%....| 00001040 de 2f 47 26 31 b1 f6 3e d0 a6 ff de 86 33 df 3f |./G&1..>.....3.?| 00001050 05 a6 ed 6d ad 9f 6b 9b 0c 9f a1 72 62 b8 82 74 |...m..k....rb..t| 00001060 b5 bd e0 ed 2c e1 be 7f 01 a7 aa 4f 03 cf 63 7b |....,......O..c{| 00001070 9b 97 eb 38 6e c3 da 86 17 87 6e 29 55 8f c3 61 |...8n.....n)U..a| 00001080 1a e8 92 96 98 bb 05 43 69 77 b2 f5 81 98 00 6e |.......Ciw.....n| 00001090 35 1d d5 ae 9e 33 9f c2 78 cd 05 39 aa 90 2a ce |5....3..x..9..*.| 000010a0 87 9e b4 bf a6 92 85 3d 40 b7 59 fe a2 51 61 9a |[[email protected]](/cdn-cgi/l/email-protection).| 000010b0 d0 14 b2 6c 4b dd 66 03 8b 7a fd 83 c5 dc 30 95 |...lK.f..z....0.| 000010c0 23 7a 79 01 ea c4 81 7f 82 ff 14 56 a1 18 20 6e |#zy........V.. n| 000010d0 69 00 85 cf a4 c8 b5 62 6e 7b 47 ca f0 75 22 8d |i......bn{G..u".| 000010e0 8e f6 bd 08 60 a9 7d 9b 7f 54 87 28 db a1 70 13 |....`.}..T.(..p.| 000010f0 fc 58 e3 af 7c 83 4c f7 dc 9c e5 28 4c a5 5a da |.X..|.L....(L.Z.| 00001100 f1 ca 4e 17 9b 5e 29 e1 57 64 ac 94 73 b5 52 bd |..N..^).Wd..s.R.| 00001110 52 ee 34 c8 37 1c 0c 27 f5 13 98 c8 54 68 54 d0 |R.4.7..'....ThT.| 00001120 00 3b fe e0 dd f2 26 00 40 92 ce 09 ff 82 cd f6 |.;....&.@.......| 00001130 02 b8 55 72 3b 8f 94 d2 59 b5 3f af e5 8c 6d 6b |..Ur;...Y.?...mk| 00001140 21 97 12 d0 82 ff 32 3f f7 89 ad 7f 0a 5a 52 91 |!.....2?.....ZR.| 00001150 98 8a ce ba 6c 60 e2 fe df 79 76 06 55 f1 4d ad |....l`...yv.U.M.| 00001160 df 9f 01 86 22 17 f1 56 51 da 99 52 52 fb a9 09 |...."..VQ..RR...| 00001170 26 ad 4c ff 85 8c 4b c7 a5 e7 55 62 9f 95 e6 58 |&.L...K...Ub...X| 00001180 64 87 35 40 2c 1d 24 23 a2 fb a9 b0 1d c3 e8 ad |d.5@,.$#........| 00001190 cd 46 93 6e b8 98 fd cd a4 68 41 59 19 26 dd cf |.F.n.....hAY.&..| 000011a0 25 75 b1 72 79 19 b7 44 c9 f2 27 eb 24 ea 32 94 |%u.ry..D..'.$.2.| 000011b0 8a 94 87 a6 3d ec 29 b9 8f ab 0e 9d 7a 51 fa e3 |....=.).....zQ..| 000011c0 2b 6e 9f 48 ab 82 2a d7 9f 4d ab b8 3e 6e 3a 24 |+n.H..*..M..>n:$| 000011d0 85 b2 b5 59 1c c3 87 c3 5a e2 43 5d 9f 00 2c 39 |...Y....Z.C]..,9| 000011e0 07 7b eb 8c 3e ac 51 13 a3 9f 27 88 e4 7d c7 a2 |.{..>.Q...'..}..| 000011f0 b8 21 77 09 c5 39 f0 a7 b1 cb 37 d9 25 a9 70 ac |.!w..9....7.%.p.| 00001200 83 ac f2 10 14 61 18 66 c1 d1 eb 9c a2 b6 48 a8 |.....a.f......H.| 00001210 30 8e 19 35 dc da d3 4a 2b 60 e5 d6 42 c2 4b 53 |0..5...J+`..B.KS| 00001220 ab b8 99 fc 92 34 92 66 d2 80 75 26 4a d2 91 5e |.....4.f..u&J..^| 00001230 e1 41 28 83 33 93 68 c8 0c fd 5f c8 41 d5 aa 6e |.A(.3.h..._.A..n| 00001240 e3 f7 4a 3e 62 6e 25 d4 19 55 6a 5e c3 fe e6 e0 |..J>bn%..Uj^....| 00001250 25 52 13 1b 83 54 a5 9b 32 77 72 1c 3c ca f6 3f |%R...T..2wr.<..?| 00001260 b0 4d 70 a6 cb 23 60 54 62 58 12 ce da 14 8b f0 |.Mp..#`TbX......| 00001270 0b 78 c1 0c d2 21 a6 97 7f 68 a5 3b 9d 57 7c ab |.x...!...h.;.W|.| 00001280 fa ab 82 e4 1e ad b0 d2 4f 2b 8b fc a5 a8 10 93 |........O+......| 00001290 d9 58 af 2c 4b 2a 4f 15 59 37 50 7e f3 a5 63 7e |.X.,K*O.Y7P~..c~| 000012a0 64 46 82 62 b2 91 6a e7 41 ad 61 e7 2d 21 66 a5 |dF.b..j.A.a.-!f.| 000012b0 f6 d1 83 9d 16 ec 57 3b 5f 24 be a9 0a 7c 9a 9f |......W;_$...|..| 000012c0 71 8f 52 fc cc 09 5b 04 6d e3 88 34 21 d0 55 98 |q.R...[.m..4!.U.| 000012d0 38 63 fe 3a 61 de 5c f4 26 eb ce e3 5c b9 e9 46 |8c.:a.\.&...\..F| 000012e0 5e 7c 0b 64 86 af ee 6e f5 be 18 8e fe 2e 14 2e |^|.d...n........| 000012f0 42 2b 1b 38 ea 00 b6 5e 9b cf a9 e7 1a dc d0 83 |B+.8...^........| 00001300 a5 1c 9b 4c c5 44 a3 69 c2 ca 79 81 da 4e 05 38 |...L.D.i..y..N.8| 00001310 14 cb a9 c5 15 75 5c f3 4c 6e 4c 97 d3 ce 02 71 |.....u\.LnL....q| 00001320 2a 6c 75 e2 92 34 93 85 2a 5a af 14 72 25 a7 de |*lu..4..*Z..r%..| 00001330 d7 b7 c6 d4 0a 60 25 4a ae f3 43 43 d7 bd 38 fc |.....`%J..CC..8.| 00001340 04 cc 95 c9 9e bd 25 de 04 19 c6 23 7b c0 8b 41 |......%....#{..A| 00001350 53 e1 b4 8d 4b 87 2e 97 3d d2 74 ca e9 8e 33 4f |S...K...=.t...3O| 00001360 d2 81 d5 e0 f7 bd 03 66 ee 76 fc 71 05 bf c6 f1 |.......f.v.q....| 00001370 52 0c bd cb e8 44 af fe a0 2e 0d 6e 31 33 7f c0 |R....D.....n13..| 00001380 18 c7 dc f0 c8 8a 9f b4 0f ce f1 28 fe 43 23 d2 |...........(.C#.| 00001390 84 44 3a c7 d9 47 33 27 04 ae ef cc b4 da 08 c9 |.D:..G3'........| 000013a0 48 71 17 48 ca ba 2b 36 4b 78 74 92 33 5b e5 a5 |Hq.H..+6Kxt.3[..| 000013b0 de e8 5e 48 88 30 b4 1c c3 3b 1d 88 db db 6c fa |..^H.0...;....l.| 000013c0 45 9f b8 38 87 b6 dc 5e a3 1d ec dc 60 d1 de d5 |E..8...^....`...| 000013d0 80 88 14 b1 ad 4e c6 2f 73 e6 17 d0 a0 fa 3b 17 |.....N./s.....;.| 000013e0 64 15 74 71 41 34 76 b7 ea 87 14 72 e6 1a 0f 30 |d.tqA4v....r...0| 000013f0 b0 56 cb 6b 4a e6 51 12 77 b3 5d 5e 1b 9a 84 35 |.V.kJ.Q.w.]^...5| 00001400 3b 0d 3a ac e1 ea 36 8d 8f 2a 11 45 6a 70 9c 66 |;.:...6..*.Ejp.f| 00001410 98 ee 0e e2 31 34 2c 02 b2 fc 13 5d 6e 7c f6 08 |....14,....]n|..| 00001420 cc 7a 99 75 66 e8 3e fa 6a 74 47 cb 9c 46 4a f5 |.z.uf.>.jtG..FJ.| 00001430 46 1b 2d 4a 8d 3d 3c 04 ff 6c 64 d2 9b 82 b6 0a |F.-J.=<..ld.....| 00001440 b5 e3 97 cb 50 5f 39 9e c9 98 b1 66 7c 56 2b e3 |....P_9....f|V+.| 00001450 4d 03 68 2e 69 af 78 b9 0d a5 96 80 74 22 c4 65 |M.h.i.x.....t".e| 00001460 e1 38 04 75 c0 cc a3 bb 57 12 90 34 c2 a6 3f 1a |.8.u....W..4..?.| 00001470 95 aa b0 45 f5 57 78 36 10 05 9e 8d 77 4a fb 57 |...E.Wx6....wJ.W| 00001480 c4 d2 ab 3c 1c 36 81 f3 fa bc 34 66 c4 cb e2 a3 |...<.6....4f....| 00001490 bc f5 39 a4 75 db d1 02 08 e4 df d3 23 d1 63 4c |..9.u.......#.cL| 000014a0 4b 21 08 85 f3 12 b3 2f fc 0a f5 14 6a b3 b1 4e |K!...../....j..N| 000014b0 4d 44 85 47 f9 4d 3b 94 25 2f d6 66 9e 39 6b 80 |MD.G.M;.%/.f.9k.| 000014c0 95 9a f4 b7 10 00 e2 c9 30 9a 34 2f d2 04 c4 30 |........0.4/...0| 000014d0 b7 e2 b8 a2 af 01 83 89 5a 28 55 ed 9a f2 65 79 |........Z(U...ey| 000014e0 61 2a 86 1e 93 ed 50 56 b1 46 aa 5b 6e 05 1d 54 |a*....PV.F.[n..T| 000014f0 19 5b 92 50 42 6f 1b 11 3b a2 32 36 72 b0 a6 9f |.[.PBo..;.26r...| 00001500 a3 5f b4 a6 d7 ad ff d5 73 52 64 d3 fa be 68 24 |._......sRd...h$| 00001510 c2 5b 2f 2d 98 cb 85 09 16 61 c7 ce dc 9c 59 ef |.[/-.....a....Y.| 00001520 3c 34 70 9e e7 71 fc 41 c6 6a e0 6b 96 bd 10 79 |<4p..q.A.j.k...y| 00001530 90 14 51 50 7a 64 56 ae 14 1d a6 66 f4 58 f8 a1 |..QPzdV....f.X..| 00001540 4d 1d c0 3a 4f d5 20 90 6e a3 5b 83 4d 52 b2 14 |M..:O. .n.[.MR..| 00001550 2a ce 63 54 7e 32 d0 6d 04 85 bb b3 67 74 3c fa |*.cT~2.m....gt<.| 00001560 ad 8f 47 a4 0d e1 45 01 a2 10 63 9f 0d 5a 81 63 |..G...E...c..Z.c| 00001570 0e c7 45 fa 32 3a 32 a8 48 6b ad 37 07 66 b6 1c |..E.2:2.Hk.7.f..| 00001580 8d 7b 2e 5e 76 98 a1 5c 84 e3 9a d6 a3 15 f9 2e |.{.^v..\........| 00001590 0f b3 15 a7 43 af 10 8c 72 ac 92 7a b5 9b 47 1a |....C...r..z..G.| 000015a0 22 2b 06 1b 08 bd b7 d6 fe 1e c9 20 2c 4f 72 4d |"+......... ,OrM| 000015b0 57 6e 7c 2a 05 84 89 33 f9 80 cf a3 5e ca 63 1f |Wn|*...3....^.c.| 000015c0 1a 67 ee c8 1e 20 c1 00 e4 95 97 d1 c9 13 a5 58 |.g... .........X| 000015d0 f9 43 97 86 44 d2 a0 1b f6 8f 54 27 2a b2 bb f3 |.C..D.....T'*...| 000015e0 09 33 19 66 e7 c1 48 f9 88 ba 75 af 64 ce 53 40 |.3.f..H...u.d.S@| 000015f0 c0 31 d1 72 39 bb 08 4d 12 5a 7e 93 74 09 48 1b |.1.r9..M.Z~.t.H.| 00001600 79 83 ba 8d b2 03 a4 23 6f 19 e0 7a f2 a5 55 48 |y......#o..z..UH| 00001610 b3 2f fd e8 59 74 ad bf 99 ca 23 f9 9c e7 e2 8e |./..Yt....#.....| 00001620 db 70 05 d8 33 cd dc 78 fa a9 b6 3f 97 16 d2 88 |.p..3..x...?....| 00001630 2f e3 b6 bf d0 d8 1f 28 fe 8f bd 45 d6 cc 3a 6e |/......(...E..:n| 00001640 c6 85 a0 90 b1 73 12 bf 42 33 bd 23 4f b7 fc 5f |.....s..B3.#O.._| 00001650 8e 5c 4d 32 4b 6a 07 09 f3 9b 83 36 b1 7d ba 71 |.\M2Kj.....6.}.q| 00001660 d9 28 00 0e f4 37 df 45 76 b5 c3 fe ea 42 7d 1e |.(...7.Ev....B}.| 00001670 a3 3a ed 90 00 af 0e 27 6c b7 25 29 ac 16 57 9b |.:.....'l.%)..W.| 00001680 73 4b 66 8e 8d d9 40 d2 44 d6 7f bd 85 c8 6d 12 |[[email protected]](/cdn-cgi/l/email-protection).| 00001690 d1 ce dd ad 34 2f 8c e3 9e e2 0e 4c 0f 43 79 ae |....4/.....L.Cy.| 000016a0 0d 6e 72 ee 61 da c7 94 b5 0a f9 eb 55 2a 9b 56 |.nr.a.......U*.V| 000016b0 82 9e 52 13 74 59 1e 45 dd 55 03 18 5d 49 7c 1c |..R.tY.E.U..]I|.| 000016c0 1e 5b ca 4f 24 4f 0d 7f 47 61 b3 27 bc 77 0e 62 |.[.O$O..Ga.'.w.b| 000016d0 aa 72 e3 93 e3 4a f3 4c 8c ad 81 99 d7 c7 20 1c |.r...J.L...... .| 000016e0 ce f8 76 d4 05 63 6a 2b ea 69 a1 cd 60 85 84 33 |..v..cj+.i..`..3| 000016f0 ce 08 69 a0 e8 8d 9c 2a 17 cb f0 3e 32 40 81 f7 |..i....*...>2@..| 00001700 35 91 ce 11 c0 b3 ab 85 96 21 c3 1f 83 b6 d1 8a |5........!......| 00001710 ec 60 46 89 90 8a 98 f9 3d 90 ed 17 a3 ab 24 33 |.`F.....=.....$3| 00001720 2b 14 9f 93 27 a6 d0 0c 03 a0 22 12 4e 4d 14 ba |+...'.....".NM..| 00001730 12 10 a0 8c c3 52 a5 47 b1 ff 97 b9 a5 46 bc 71 |.....R.G.....F.q| 00001740 d6 b5 21 4b 71 11 76 05 59 77 b1 7d 09 fd 80 8f |..!Kq.v.Yw.}....| 00001750 62 c6 b2 2c 12 36 27 a2 60 61 34 ff 5c 02 15 ce |b..,.6'.`a4.\...| 00001760 b1 41 d6 e7 ff cd d7 7d c7 f6 1e c7 f3 09 32 a7 |.A.....}......2.| 00001770 fb 86 29 bc ba 8b ff 09 65 4b 75 0e ef de f2 60 |..).....eKu....`| 00001780 29 a5 8b 81 4f 8a c7 14 71 47 77 1d 2f ef 7d 73 |)...O...qGw./.}s| 00001790 3f 2d 4d 41 c0 54 9f f5 11 7a 93 89 96 f1 b0 4b |?-MA.T...z.....K| 000017a0 08 b1 e3 c5 11 1e ad 8b 79 ef 39 25 cc 5a 5c c1 |........y.9%.Z\.| 000017b0 ab 0d 19 42 65 05 32 75 4e 50 d6 79 32 ca 8d 19 |...Be.2uNP.y2...| 000017c0 88 24 b6 01 66 56 24 ba 34 5a 81 d1 8e f7 d0 39 |.$..fV$.4Z.....9| 000017d0 8a b0 47 99 11 df 31 63 93 31 ef d9 85 9e c9 2e |..G...1c.1......| 000017e0 d7 a1 e5 4f dc 0a f6 aa a7 d8 c9 f5 4e c1 17 80 |...O........N...| 000017f0 a0 43 e8 09 ef 2f 45 48 68 f7 e6 ac 1f 27 1e d9 |.C.../EHh....'..| 00001800 6e d6 70 c7 9b 20 d6 0c 0e c4 55 82 e3 73 b7 f6 |n.p.. ....U..s..| 00001810 bf 27 3a 00 ec df 30 d7 0b 6a 6c ff 94 35 9f 37 |.':...0..jl..5.7| 00001820 a5 87 ac 5a 06 91 67 45 8a f4 8b 5a 52 21 24 ed |...Z..gE...ZR!$.| 00001830 b8 c8 5b 6d eb fa 20 69 61 29 e4 8a 26 25 d8 21 |..[m.. ia)..&%.!| 00001840 7e b3 c6 7e 32 5b 04 e7 92 64 e1 f1 7f 60 b3 23 |~..~2[...d...`.#| 00001850 e3 30 80 36 ce 5e 2a dd b6 5a 3a c1 3a 82 91 0a |.0.6.^*..Z:.:...| 00001860 91 99 a7 8e 82 5e 2d 67 e1 ac 0b 87 a6 53 a3 06 |.....^-g.....S..| 00001870 c0 50 ae 8e 4b c8 e5 cc 4a ef 1d 0d 12 66 6a 12 |.P..K...J....fj.| 00001880 8e f2 27 51 a4 eb f4 f4 42 1d fe 06 d0 b4 11 93 |..'Q....B.......| 00001890 5a 53 80 bb fe ad 9a 78 5a ac 33 6f 9e 94 b1 fd |ZS.....xZ.3o....| 000018a0 93 6b a1 55 c1 b7 52 74 01 40 cb 06 50 44 d0 20 |[[email protected]](/cdn-cgi/l/email-protection). | 000018b0 f5 4d 7f 7f b9 09 78 84 61 29 0c 53 cb 9e e3 51 |.M....x.a).S...Q| 000018c0 c6 da 89 ba c1 f4 a5 5f ee 54 de 1d 6b ee 97 f7 |......._.T..k...| 000018d0 7f 22 b0 bc f4 09 8e 94 21 0c 61 3a 1b 1d b4 16 |."......!.a:....| 000018e0 02 7f 98 a7 8a c1 d1 cb 6e 2c 5e 26 be fd 27 c8 |........n,^&..'.| 000018f0 71 e9 b3 cc 63 82 c8 fc a7 7c bf 58 95 26 da 2d |q...c....|.X.&.-| 00001900 2e 86 22 2a ab bf c5 93 9e 63 97 d0 7f a0 4d b1 |.."*.....c....M.| 00001910 06 a7 60 26 d9 f2 51 33 15 30 25 48 16 47 f9 d9 |..`&..Q3.0%H.G..| 00001920 cb 78 f8 3d d4 8f 2b 21 5a 9b bd fd 2a 4a 1a e9 |.x.=..+!Z...*J..| 00001930 43 ed 7d 57 46 58 03 03 83 db e1 1b 1d ce d5 eb |C.}WFX..........| 00001940 f8 b2 92 28 60 14 10 0c 33 b9 59 70 f3 23 aa 24 |...(`...3.Yp.#.$| 00001950 45 03 f0 d7 70 a3 0f ed 4e 01 17 95 93 70 5a bf |E...p...N....pZ.| 00001960 86 46 e0 29 f4 04 be 2f 5b b3 c2 75 82 c3 20 f1 |.F.).../[..u.. .| 00001970 f3 79 ef 96 b9 3a c0 c5 6c 0c 1a c8 7e 91 dc 1c |.y...:..l...~...| 00001980 0d 59 01 33 d8 d3 c9 d1 bd d7 3c 79 f6 79 d3 62 |.Y.3......<y.y.b| 00001990 0d ca 8b 90 b5 de 56 72 86 90 87 47 f2 f0 8b 91 |......Vr...G....| 000019a0 18 8b ba 81 38 e7 64 33 e9 ee ed 99 a8 46 79 6c |....8.d3.....Fyl| 000019b0 2a 54 1a 99 69 5a de ff dd 18 07 13 e2 fc 40 31 |*T..iZ........@1| 000019c0 16 b4 04 9a 3c 02 a1 9f 4c 2c df 16 22 ac 49 d2 |....<...L,..".I.| 000019d0 93 75 a4 54 d6 a5 2e c4 da 49 da bc f6 f2 ac a4 |.u.T.....I......| 000019e0 d9 b3 56 1e 58 52 c4 e4 b0 4e a8 d4 e2 c8 ca 37 |..V.XR...N.....7| 000019f0 bb 8e 33 e2 8d 75 ca 88 d9 61 c3 67 22 f7 80 b3 |..3..u...a.g"...| 00001a00 49 80 fb 25 94 ae 16 da e3 85 f1 69 a3 4d ca cf |I..%.......i.M..| 00001a10 e5 6d 67 79 2c a6 e1 20 d3 61 ac 39 1a 93 2b 2f |.mgy,.. .a.9..+/| 00001a20 d3 4f a0 d0 1f a7 4f 53 2d cf ed 4f fd 31 33 47 |.O....OS-..O.13G| 00001a30 8e d0 75 cb 40 5a a3 98 4c 94 c8 c6 37 77 91 f9 |[[email protected]](/cdn-cgi/l/email-protection)..| 00001a40 51 eb c9 21 fa c1 b7 9d 62 81 3b eb c6 bc 7c aa |Q..!....b.;...|.| 00001a50 79 2d 81 fa 31 f3 e3 d9 4d 1b d3 c7 49 15 a5 da |y-..1...M...I...| 00001a60 7c 83 94 a5 43 26 4c 1c c8 a3 8c d5 a9 a7 a7 fc ||...C&L.........| 00001a70 f8 e8 93 26 01 12 6e 6d 76 c8 b5 65 4c a3 e2 50 |...&..nmv..eL..P| 00001a80 3b d1 b4 ce 88 de 37 58 d6 08 a3 3f fa f5 be f0 |;.....7X...?....| 00001a90 f1 e3 ce c1 6c c6 08 f9 24 8b a1 63 4b ba c6 6f |....l...$..cK..o| 00001aa0 7e b2 6d 5d c1 66 5b 66 5a b6 41 43 a0 20 ec 7d |~.m].f[fZ.AC. .}| 00001ab0 c9 49 68 7e 06 f7 6c 32 da 8f b9 45 41 b8 84 19 |.Ih~..l2...EA...| 00001ac0 15 93 3f 7f d0 0d 95 1d d7 8b e1 db 77 f1 8b db |..?.........w...| 00001ad0 1a 27 c7 2d 85 fa c6 69 6d 92 36 ac 70 dc 49 0b |.'.-...im.6.p.I.| 00001ae0 3a 37 7c 3f 20 f5 d7 01 6a 3d 70 ef 4e 93 bf 30 |:7|? ...j=p.N..0| 00001af0 43 7d 34 5e 26 a8 e0 3f f4 fa 95 87 ed 2a f6 7c |C}4^&..?.....*.|| 00001b00 14 ac bc 65 70 08 2a c5 cc 15 9e c1 28 57 41 9f |...ep.*.....(WA.| 00001b10 03 72 b5 9d d1 9d 03 eb 00 ac e9 e5 8a e3 92 36 |.r.............6| 00001b20 d4 1a 86 18 8f 07 63 73 3d 89 cc f3 00 17 03 43 |......cs=......C| 00001b30 87 55 c7 c3 90 48 af 22 60 8c 8e 8b f1 50 8b 58 |.U...H."`....P.X| 00001b40 f6 0e 41 81 f2 8e c6 41 1c 73 1e 68 6d b0 fd b0 |..A....A.s.hm...| 00001b50 4a fa f6 a3 e2 eb 80 be ea e6 13 23 99 86 b2 0c |J..........#....| 00001b60 bb 8c 14 bb 74 c0 ce 03 40 06 1a 4f 59 68 93 70 |[[email protected]](/cdn-cgi/l/email-protection)| 00001b70 50 7d 58 6a 16 d4 97 73 4c 09 89 1e 95 f1 f7 b6 |P}Xj...sL.......| 00001b80 cb d7 b1 ca be 6a e9 15 98 d3 e3 7e d6 15 6a a0 |.....j.....~..j.| 00001b90 93 16 74 d1 e7 e5 15 c4 d2 59 75 5a ae 41 c3 e3 |..t......YuZ.A..| 00001ba0 fc 72 8f 37 85 40 11 e2 69 61 2a 45 be c1 9e 0a |[[email protected]](/cdn-cgi/l/email-protection)*E....| 00001bb0 ff 70 ca ea 3e 31 d2 1d 36 f6 ed 13 b0 de 7b 6e |.p..>1..6.....{n| 00001bc0 f9 29 3e 6b a3 8a 00 16 9d 0e 06 a7 49 d9 08 d5 |.)>k........I...| 00001bd0 8c b5 27 cc 36 03 34 8c 56 49 f3 cc 7c 95 a1 c6 |..'.6.4.VI..|...| 00001be0 e3 a2 34 16 5a 09 b1 e7 38 46 13 9a 26 41 22 3b |..4.Z...8F..&A";| 00001bf0 7a e9 0e 94 66 75 a7 7c d3 4b 30 3d 1a 2e 70 c4 |z...fu.|.K0=..p.| 00001c00 d9 81 4d 31 3e 00 54 c6 c8 79 e0 4d 7c 5b 69 1b |..M1>.T..y.M|[i.| 00001c10 67 fe bc cc af 93 18 cd d5 31 42 f6 49 6d 12 20 |g........1B.Im. | 00001c20 9d e0 27 9a b6 eb 4d d7 4f 4f a8 e9 27 9b 60 b9 |..'...M.OO..'.`.| 00001c30 ba e9 ff dc 4b b7 fc 95 9a 90 e7 e5 52 df 72 18 |....K.......R.r.| 00001c40 5e 0f 66 26 ad 3d 4b d4 34 9a c7 12 0b 6b 66 1a |^.f&.=K.4....kf.| 00001c50 20 be 97 7b cd d0 55 34 03 8f bc 03 f2 6f 4f 1c | ..{..U4.....oO.| 00001c60 dc e5 cf 8b c1 9c b4 88 da c2 16 08 5e df d4 53 |............^..S| 00001c70 c0 f7 2e f0 ff b3 bd 82 0a 46 2d 56 52 9c 8f a2 |.........F-VR...| 00001c80 c1 89 0c 57 2b fd 45 7a 00 cb 3d c7 1f d4 2a 46 |...W+.Ez..=...*F| 00001c90 3f 73 92 3d ae c9 b7 0a 32 94 14 f5 2c 23 d0 c8 |?s.=....2...,#..| 00001ca0 97 1d 63 df 9d d5 23 d6 0e 9a 69 ce 87 ee a3 32 |..c...#...i....2| 00001cb0 2a 7e 90 09 76 7a 9e b6 14 e1 00 00 00 00 fe ff |*~..vz..........| 00001cc0 ``` *EDIT: now including 1 byte for filename length* *EDIT 2: golfed 1 byte from decompression script thanks to @nununoisy* [Answer] # python 3.8, 161169+1+287289+267193+6985=7702 7637 ``` from zlib import decompress as D from itertools import product as P from functools import reduce as R x=289 c='AGCU' d=open('f','rb').read() print(eval(D(d[:x]))(d[x:])) ``` where `D(d[:x])` is ``` (lambda f, rest_len=[265,7,8,24,50,10,6,134,14,24,229], genes_len=[7097,1274,276,76,223,62,122,122,420,39], cut=lambda s,x:R( lambda acc,n:[acc[0][n:],acc[1]+[acc[0][:n]]], x,[s,[]])[1], cut_out=lambda x,n:x[:n]+x[n+1:], C=[''.join(i) for i in P(c,repeat=3)]: cut_out(''.join(i+''.join(j) for i,j in zip( cut(''.join(c[(i//r)%4] for i in f[:193] for r in [1,4,16,64]),rest_len), cut([C[i-32] for i in D(f[193:])],genes_len)+[[]]) ),13468) ) ``` and the file `f` is [here](https://drive.google.com/drive/folders/19-l1Tbg44H0Bc1TFXXPwfvS1HSuSESPO?usp=sharing) (produced with decode\_1.py). [Try it online!](https://tio.run/##dXxnW9xMEu33/RUkEwwGtaRRIGODAZtkg8HgwUYtdRtskochh7@@V6fqaLn3w919/AIzCq2Kp05V6/K@e3xxHmWXnf/@13cuznoeTk9sz8nZ5UWn21O58uLssuOurnqKq57F/8gBJ13X6V5cnF41R112LqrrsotDtvQQf31e/j@HdFx9hMMRX/9zNxNm@X/KmaGF5Q/fhv5Tzdihu/ZdXn6r/2Pad5X5077LoqB9Z@L6l6R95/xz@/ziY/1B1L7zZfvOpvWhxXH9m7H1J/WhRfFYH1v/YnEF@2G4fVe6@sy8/jTrnuCq7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4XVej0gEkw0oac4raRHJ2YNB15N0X/8dw1TKBhtHo5R1NF0IRY7hJWWYIJcnscchdwj2aoEMjBL40u8pW8c2t0izuAPAuBFt8m0LiE7KA5wwYqwWIGCD1Imk4IMV7zcqmC@L8OpV0E5ACUHEY7CreSYxTU9/@Dc75wpl62PcpWp5EjFlB1Or/im0BklIVvkwlqUIzxd8jLiq4WfirzkEf7u9no@BRekhAd7X3lcIek4@H3ApyurvbQRgla7NXKcKDQlAWLM6/GVmRj2IknCU/ajH8PkfbMHqGsb1qFHi9xERcHJyOTUo5wueAmXMEKeDVPhRaxvPUDXoVXj7jmpWruZvKRc3XCey1waqqU/QuXelqgvf4uudv8nZoAQK3n/gUpxzhGIfNYHPvJ2PY14bJm3UrKWOmvrKqyK76cryymHuhx0aiMCs8jpAPzF3HT7iSHLgP/ort/7K7IXoqJr0pNWbz9Q8Y0EG9D2S62yckUIZVln9p@M0PJUAN7CLbfqfRTvFevCtRMLPkQGRyWcjBie7hkLzflIKS8ScoM7zZvyuEUBGdlg6DbPk@/CyW7c/obbnrX1CuoSlooliSjCatwBIoxx/sbchDgsv8cm9Vl9LFcbkaRrGC7j9hAJqMJ8p4uzF/IcGuLLzcBvynlFx1ZXuAi0eFCRgKqof9cdk7Ou8PupjgdXhyufkzeHY6M1D/vJuuf/PLUnQ9XI6Nm1CT5yH//@38A) Posted here only to show grouping [nucleotides](https://en.wikipedia.org/wiki/Nucleotide) approach as the decoder overhead is very large. So let's start with the explanations. As can be seen form [MN908947](https://www.ncbi.nlm.nih.gov/nuccore/MN908947), the virus [mRNA](https://en.wikipedia.org/wiki/RNA) contains "head" (265 nucleotides), "tail" (229 nucleotides) and [translated](https://en.wikipedia.org/wiki/Translation_(biology)) parts with some non-translated parts between them. So, we have 10 genes, named orf1ab, S, ORF3a, E, M, ORF6, ORF7a, ORF8, N, ORF10 in [the link](https://www.ncbi.nlm.nih.gov/nuccore/MN908947) above. It comes out we could use [codon usage bias](https://en.wikipedia.org/wiki/Codon_usage_bias) as the picture of frequency codon (=nucleotide triples) usage is very impressive, e.g. for `orf1ab`: ![](https://svgur.com/i/Mk0.svg) or for `S` (looks very similar): ![](https://svgur.com/i/M40.svg) and for `N` (looks different): ![](https://svgur.com/i/M3e.svg) More precisely, here's the table of normed [covariance](https://en.wikipedia.org/wiki/Covariance) of the codon usage distributions: ``` orf1ab S ORF3a E M ORF6 ORF7a ORF8 N ORF10 orf1ab 1.0000 0.9243 0.7458 0.4237 0.4813 0.5143 0.6391 0.6897 0.5035 0.3201 S 0.9243 1.0000 0.7077 0.3834 0.4596 0.5266 0.6513 0.6451 0.5371 0.3519 ORF3a 0.7458 0.7077 1.0000 0.4683 0.5483 0.4119 0.5713 0.5957 0.3464 0.2862 E 0.4237 0.3834 0.4683 1.0000 0.2966 0.2057 0.4727 0.2994 0.0318 0.2621 M 0.4813 0.4596 0.5483 0.2966 1.0000 0.2495 0.3799 0.3432 0.2975 0.1776 ORF6 0.5143 0.5266 0.4119 0.2057 0.2495 1.0000 0.3737 0.3459 0.1980 0.3125 ORF7a 0.6391 0.6513 0.5713 0.4727 0.3799 0.3737 1.0000 0.5232 0.3223 0.2362 ORF8 0.6897 0.6451 0.5957 0.2994 0.3432 0.3459 0.5232 1.0000 0.2049 0.0902 N 0.5035 0.5371 0.3464 0.0318 0.2975 0.1980 0.3223 0.2049 1.0000 -0.0203 ORF10 0.3201 0.3519 0.2862 0.2621 0.1776 0.3125 0.2362 0.0902 -0.0203 1.0000 ``` So we want to compress these genes. Here's the comparison of compression approaches: ``` arithm .lzma .xz zlib a.ovh len 0:orf1ab 4925.7 5261 5308 5083 86.5 7097 1:S 879.5 1047 1092 940 59.1 1274 2:ORF3a 191.4 276 324 237 37.4 276 3:E 47.8 100 132 84 18.6 76 4:M 155.4 232 280 200 35.1 223 5:ORF6 36.9 86 120 70 15.4 62 6:ORF7a 81.2 143 184 124 25.2 122 7:ORF8 80.2 144 184 122 24.2 122 8:N 289.9 393 440 338 44.1 420 9:ORF10 22.5 64 96 47 11.6 39 ``` where `arithm` is arithmetical encoding and `a.ovh` is frequences compressed with fibonacci (+1 ending bit for each) -- the arithmetical encoding overhead. We see the comparison makes zlib a perfect candidate, as even if we compress all with arithmetical encoding, we would have left something like 193 bytes for writing the decoding overhead (versus zlib), which is highly unlikely to fit in there. Answering on [stux](https://codegolf.stackexchange.com/users/95705/stux)'s comments: > > However it looks like you need auxiliary tables to do so? > > > Almost no. I can number out nucleotide triplets just like numbers at base \$4\$ of length \$3\$. `itertools.product` does the job well. But yes, we have to know what nucleotides do encode peptid amino-acids and which do not, for this we need [the first link](https://www.ncbi.nlm.nih.gov/nuccore/MN908947). However, it's rather tricky to get the right sequence for `orf1ab` because of it's code consists of \$2\$ overlapping sequences, which is rather rare in the real world, IMHO. They do overlap on the nucleotide at position \$13468\$ (see `join(266..13468,13468..21555)` in the above link), so we double this nucleotide, compress, and then cut it out after de-compression (with `cut_out`). Then we compress joined sequences of triplets (not separately because orf1ab+S is rather large compared to other parts and the encoding table (frequences) will not differ much for orf1ab+S compared to all peptid-coding parts joined). Also we compress the non-peptid-encoding parts because we also need them in the output. Joined too. Then we have to `cut` both sequences into apropriate pieces (pieces lengths are `genes_len` and `rest_len`) and interleave (with `for i,j in zip(cut(...,rest_len),cut(...,genes_len))`). \$269\$ is compressed non-peptid-encoding nucleotides length and \$6985\$ is compressed triplets length. Looking back at the comments it's left only to explain how `cut` works. The python `reduce` function takes \$3\$ argumets: function(accumulator,item), the sequence and the optional accumulator initial value. Then accumulator on the next step = function(accumulator on the previous step,item from sequence). In other words, `reduce` feeds the sequence into the function and returns the accumulator when the sequence runs out. E.g. a way to replace `math.prod`: `lambda z:reduce(lambda x,y:x*y,z,1)`. So the accumulator in this particular case is chosen to contain [the sequence to cut,array ot already cut pieces] and `acc[0]` is the sequence to cut, `acc[1]` is already cut pieces, so `acc[0][n:],acc[1]+[acc[0][:n]]` makes perfect sense now, doesn't it? And we need only the `reduce` return value at index \$1\$ (i.e. the pieces sequence). Did I answer all the questions?) [Answer] # [Python 3](https://docs.python.org/3/), 118 + 1 + 7313 = 7432 bytes Saved 10 bytes thanks to [ovs](https://codegolf.stackexchange.com/users/64121/ovs)!!! ``` import zlib j=int.from_bytes(zlib.decompress(open('z','rb').read()),'big') s="" while j:s="UACG"[j&3]+s;j>>=2 print(s) ``` [Try it online!](https://tio.run/##ZX13v9W20vX/@RQOJbSgWLZkS0mAAAktlNAhVFV67/WrP@9aY3mfk/vyu/eknT3bkkZr1lS//PT24Yvn4/89evbyxeu33Ys3P7x4o958evO2PNu75@PH3B183alHz1@@e6vePnrRHe4@79m3/VcO/zR0HxL/7Sri89NH8YfHhx49f6vq6xfP7sVPb8ubvfy3Kpf04tnL1@XNm70vXpbne/d83vPzntdxzz71uoS8d9@@n/fERw/wBW8O7djxw4eHj56W7vGv@IerR4@f3HHr8U/jnQNvfnt8@PCh4YeXr/ENe9/s@7//69ufX7vZ@dQN2c9d9TZ2PvRzF4Y4dUbrqRt0b7tkYt91H9VBpW4p/DmqfsTPHxYJGjJ641Jng0mdMdPYmZpKV43BJ/vQd73tx24IQ@k6pf49@2e6oNRflLN/lTFAxuCH0PVhcN1g8CHdz7mzOuOTJtuud1PoxgE/un371d5dSn27qPDz8fC4yRghw/TJdsHih86670Iepi6HyXVTKnOX0mw6P@DfdX8o@fOTevhUqbfqpybDQMaY8Z34ddPNwfYdhMUuz9Hhkz50zs22M3HEcxzCJz//c1t2RL37@9cmw0JGill3Ouixy2OYOu9H/F3FJ2f87MZa@66m2XE/5M@o3n1TR5T62GRMfI464ldLzp3WfAQ9Vi4jdyVSWgr4RzumrjsyH@a5HHlKOar83mTMPJceG5ZHnGPQdujqGE2XfS2dyaPr0jzPHU6az/EYT3GJj3LOqQ8HHjYZDjJyxLcP/WigC2bsfB59FwoexmtTOztZ2zmjK2Tc6syPx5XHQi5cu7rRDw8Z0eXa1bm6bp4GPEeaatf7pLuSe92NcYDy1bHtx/sd6gX/@tse5ZqMABlVz303aYtfncuA3S3Y2FHnr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Z03xRG6spEh00/ZgGyzNPJWGX3EZrfK8YN8rVRkgjmNoh93GEg@12bmtBywzP8YMr4pjCzSrCzmqTKsbiQDkLdqsKUmsrbn4BUlr@TB/06816rV9sj8j4kvCJgMB2uPgCtLDyxxopud@Y6OTIeTmfvukcoPx9/vfqeaPru1WUtepuKz3h1@ds/CCdh4ec8pVsDevsRQRmTbeHfghVorNusWnsr8DyBPTxl0iicZSBCXDkfLpKXjxLpcJRb8EmQ9tZbV12ssWOZ/eBZVVEZwSpUJBJHznOHA9RxRowvfGuk3/ZWtd24zwUzL/I/KitvqHYedRZmwy/f4MdfOuovswCIKRy@stOGfV0vOoK1F5n8MbHLPfMda4lgrzeTHEBOnPPGlePIfBmLyQYaSHqgjB9TFfSCZDZNl/odmYK6wRmBMfF0rGxMT3dJUBuliGTn@Yrlz4@9LqmDX8zdrPFnmfyR2lOYBqhRnYGEOHJFgoSkxGzY4cZqOnO0a@wQYnv4AUtZkyPygmW8DKYkln5zxyXckVZawReK6tDbUafGjoBpnyv9wKZn/MXJ4mbRHRHZcYCPBPzjmHACfupked2AZaOfvDUZm9/Saxn9oMibJV7JSAhsCDsNxrqwznzluqnKCiWFXysAG/E79yz71I/e@v2Llw2qjZP5H9ARQOspgHYnviWUVP99rMcKE95wU0xepMWqvKnE/Hv9j21qW6WOcvToaGn@mbkdhAIQf9tDwVXkAyXHBoL8frtvx047fmgzhH@7/AQ "Python 3 – Try It Online") Requires a local binary file named `z` of size `7313` (which is the genome of SARS-Cov-2 encoded by mapping each base to 2-bits and then `zlib.compress`ing that number): ``` 00000000: 789c 2d97 f95b 9a07 a2b6 4116 2105 c4b0 x.-..[....A.!... 00000010: 048c 5a4c 4463 4fce f445 c0a0 0503 2a2e ..ZLDcO..E....*. 00000020: 292a 0a28 24a0 107d 51d3 24d5 086a 326a )*.($..}Q.$..j2j 00000030: 40c5 a5c5 1d10 ad26 da68 6ce7 cc74 9226 @......&.hl..t.& 00000040: 3dd3 ce74 7a50 5c5b d7b8 929a 8875 4b3a =..tzP\[.....uK: 00000050: cbd1 1a13 d3a6 9933 df75 7df7 3ff0 fc78 .......3.u}.?..x 00000060: 3f37 3edd 115b d13f 6ced eb33 dcaf 653c ?7>..[.?l..3..e< 00000070: 006a d316 a152 f3b4 d9fe 4d38 c777 2b68 .j...R....M8.w+h 00000080: db5b 2034 2143 9d39 ae3f 914f 5655 841f .[ 4!C.9.?.OVU.. 00000090: b8df f7f8 7622 fc6f 09c1 ed01 3b27 ff38 ....v".o....;'.8 000000a0: f170 6157 f7e2 1ae6 931d fa9f 64ed 9fdb .paW........d... 000000b0: 8261 b720 3983 ffb8 f7e1 d148 d8a3 0fa6 .a. 9......H.... 000000c0: cb7e 8277 bdfc 5c41 4b4f b633 dd05 4b58 .~.w..\AKO.3..KX 000000d0: d92f 9027 366c ce27 a2c1 8473 6fcc 7d28 ./.'6l.'...so.}( 000000e0: dfaa e3b6 c277 1e73 af2e fe67 7954 c1d7 .....w.s...gyT.. 000000f0: 77a7 4f69 bd42 2bdf 0a9c fe47 4a7f 24f2 w.Oi.B+....GJ.$. 00000100: ab52 5ac5 f0e2 aeb0 6c7d ba37 fffd 3f3f .RZ.....l}.7..?? 00000110: 208d c3d4 e5df 9744 669d 812f f1e9 0b59 ......Df../...Y 00000120: 8b1a 857f e184 cf3d 79eb bd12 f28b d7b1 .......=y....... 00000130: e7d7 4267 c10a e68f ac83 0bb4 950d d243 ..Bg...........C 00000140: d4d5 7b8d 2477 ab1d f307 b051 8d77 9956 ..{.$w.....Q.w.V 00000150: f7bc 1b22 26b3 1f27 8add bb1f 2d0e b255 ..."&..'....-..U 00000160: 6b6c 5c51 2e4c 4af2 b22e c0b4 1592 5f45 kl\Q.LJ......._E 00000170: 7d7c 8647 b734 84d8 a641 e75d c7a6 cb4a }|.G.4...A.]...J 00000180: 5807 f057 fa37 e2c7 cee4 ffbd 433a bfd9 X..W.7......C:.. 00000190: 277a 823e 1fb8 c44c c0ec a5a1 238b 5ecf 'z.>...L....#.^. 000001a0: 6048 4f2b bf80 4cdb 1ff1 97d3 3323 3495 `HO+..L.....3#4. 000001b0: 5c8a 4f9f c40c c8a0 98fe d620 7157 c1f3 \.O........ qW.. 000001c0: fa8d 2bb8 2f7c 84ec e3ee 853c d4c9 cce9 ..+./|.....<.... 000001d0: df68 7086 17eb 4c94 11d8 794a 564e 559d .hp...L...yJVNU. 000001e0: 3e74 71ed 9fe4 3827 b9f9 26e0 7c54 fa1f >tq...8'..&.|T.. 000001f0: 9934 09d8 5d29 3d6f 552d 8c67 5ba2 bdc2 .4..])=oU-.g[... 00000200: a072 e292 eecf 02c8 4b9a 0727 a48d 03e3 .r......K..'.... 00000210: c927 3361 33c2 ab68 85d8 996a dee5 9306 .'3a3..h...j.... 00000220: ac65 e926 d9de adf9 e8c9 1ca9 25eb 4a2d .e.&........%.J- 00000230: 7c03 97b0 da70 d279 3481 7fec b3f3 58f9 |....p.y4.....X. 00000240: 0f32 d4d4 04b4 abfc 4ba1 4533 378f ee8c .2......K.E37... 00000250: ca2a 0a64 adb1 06b3 eb61 6b26 4b0d 46f2 .*.d.....ak&K.F. 00000260: 249b ba37 0174 86bd d179 2057 d022 b3a0 $..7.t...y W.".. 00000270: ec34 fa85 6fb1 5e95 aa25 6859 e968 3ead .4..o.^..%hY.h>. 00000280: f87d af05 0c09 7aec 2cb3 921d fd36 cf8a .}....z.,....6.. 00000290: e960 5af7 0565 2b83 4551 d012 468a 18e6 .`Z..e+.EQ..F... 000002a0: 6672 96ab 9aa2 a74b d210 d7b0 fcd2 85a6 fr.....K........ 000002b0: d0cb e7d3 9f31 ba94 13a4 9047 faac 27e7 .....1.....G..'. 000002c0: 936a 653f 5af5 029a 71f5 91a2 e2b6 7e82 .je?Z...q.....~. 000002d0: 5cbc 84a9 9435 b290 6705 8b67 2985 19c0 \....5..g..g)... 000002e0: d207 d1ce 913c c710 f935 dcf9 a1d4 eaea .....<...5...... 000002f0: 4aa7 4c75 6f99 08c9 e4b4 94ee f6ba ccaf J.Luo........... 00000300: b76c e903 06ee 9c96 19a7 dcdc 0157 2663 .l...........W&c 00000310: ec30 396b e119 2b9d 427c 5458 fb24 367f .09k..+.B|TX.$6. 00000320: f16d ea12 e9d4 1bb7 80e9 2ece 3849 8e3b .m..........8I.; 00000330: 5b70 5cac d6da 5f47 f375 2b2f 086b cdd5 [p\..._G.u+/.k.. 00000340: 70ec a9e3 930e 6924 ba99 81a1 057c d29f p.....i$.....|.. 00000350: f86c 4955 3a33 a95f ca3f d56b a313 0ab8 .lIU:3._.?.k.... 00000360: 592a 964f 26a9 9bc7 dfbb 8d5a afa5 df52 Y*.O&......Z...R 00000370: 15b7 a974 5c3f d6ec 3898 e545 6f7b bf73 ...t\?..8..Eo{.s 00000380: 150c 06ab f156 0bb0 8ace b5f8 cd2d 22f3 .....V.......-". 00000390: 9ce8 e568 e57c be27 174f 5267 810c 2a42 ...h.|.'.ORg..*B 000003a0: ba9d cd5c ca20 6592 f272 b880 e486 c591 ...\. e..r...... 000003b0: 4b6a 5d2d 75de bc86 101e 68c0 8824 25fb Kj]-u.....h..$%. 000003c0: 7822 32ae 9af8 dc4e 9a9e f665 4232 9e83 x"2....N...eB2.. 000003d0: b435 85b9 4214 fab3 1550 64b2 5d68 b5b1 .5..B....Pd.]h.. 000003e0: 9843 9041 52af 7e31 4809 efc5 27ac 0f41 .C.AR.~1H...'..A 000003f0: f6ea 3f89 8d82 16c3 18b3 e6df 80a2 6a4f ..?...........jO 00000400: b361 5676 8c00 aa1d 6d06 2fe9 52a1 6cd3 .aVv....m./.R.l. 00000410: a948 7fb7 7ea6 47b5 3f70 8d2f ac57 a655 .H..~.G.?p./.W.U 00000420: e42f 16cb da12 8fc8 e825 4cac 7ec0 266f ./.......%L.~.&o 00000430: 54c9 9527 da17 d403 8698 3041 b2a5 e28c T..'......0A.... 00000440: eef8 6dda c064 932b c803 a1d7 fdd0 ec3d ..m..d.+.......= 00000450: 3d09 0caa 5e39 c89c 6978 ae46 76b0 b745 =...^9..ix.Fv..E 00000460: 59e0 fc36 ddf0 283d 42e1 1278 e719 ffeb Y..6..(=B..x.... 00000470: a7eb 50c9 807d b4ec a5aa d32d 2b24 1576 ..P..}.....-+$.v 00000480: 23a3 7ce2 05c7 888f aeea a3bc e48e ca79 #.|............y 00000490: dc23 4965 7bf8 52da 6529 f1c9 d8c4 be26 .#Ie{.R.e).....& 000004a0: a3d9 61f3 be31 1c93 3944 8a55 bd9a c6c2 ..a..1..9D.U.... 000004b0: f76a f814 6847 419a 7cf4 7375 8256 7d2e .j..hGA.|.su.V}. 000004c0: 5eba 500b 8011 ea03 91a2 d52d f552 95fc ^.P........-.R.. 000004d0: b04b d0d5 5aa7 6e50 1d66 5450 3d67 e0c6 .K..Z.nP.fTP=g.. 000004e0: 9064 80a6 ae40 c93a d88b 7cfc 426f 5d65 .d...@.:..|.Bo]e 000004f0: e321 6f95 d789 289e a51a ac19 d27b 201e .!o...(......{ . 00000500: ed09 9543 027b c119 9fec 909e b9c9 fc84 ...C.{.......... 00000510: eeb0 5484 abc2 0356 ac5c d520 f6a0 b602 ..T....V.\. .... 00000520: 5736 f903 eda6 93d7 4a0f 8b79 ae70 fc64 W6......J..y.p.d 00000530: 837b 2597 cc21 49c2 b381 e276 f66e 1a9f .{%..!I....v.n.. 00000540: 00c9 9524 daab 274e b9b1 233e 5af9 831a ...$..'N..#>Z... 00000550: 48e3 e888 e886 2055 4b52 eec7 de56 1277 H..... UKR...V.w 00000560: c828 81e4 e52c 683e 8cb3 6f00 8a0f 1429 .(...,h>..o....) 00000570: 2b6c 476a 07a7 5ac5 c1e7 5cbd dec8 5e37 +lGj..Z...\...^7 00000580: 1998 f6c3 9e3d e694 a282 bdfc d239 4f3d .....=.......9O= 00000590: 780a 8941 673f e5eb 689b aa31 f6bd 8961 x..Ag?..h..1...a 000005a0: 39d3 95d3 65eb ce9c d0af c347 92b7 d4b4 9...e......G.... 000005b0: 4410 aa2f 1dd4 e532 ee71 d332 a8d2 f802 D../...2.q.2.... 000005c0: 5bd9 7837 8620 ba91 77ab 6e68 11b1 b1db [.x7. ..w.nh.... 000005d0: 4461 d69c a236 127d 0ab9 7661 b6b0 82b4 Da...6.}..va.... 000005e0: 6018 0af7 fbda 4da1 2a3f d653 334f 08fe `.....M.*?.S3O.. 000005f0: 0aa0 40bd 62a0 1dec 95f5 23e1 521e d709 [[email protected]](/cdn-cgi/l/email-protection).....#.R... 00000600: a32e 603f 51f2 2c78 e182 2b0a 8eee daec ..`?Q.,x..+..... 00000610: c3d2 46ac 7dbd 67d2 36dd f7c5 08c7 d024 ..F.}.g.6......$ 00000620: 3141 cc99 e3a7 7592 b9de fa5c 775b b151 1A....u....\w[.Q 00000630: 4985 bc15 8648 664d 47e2 6784 5a6a 472d I....HfMG.g.ZjG- 00000640: 545f b626 1e68 3e8b 77bc 0414 49f2 948c T_.&.h>.w...I... 00000650: 8fbc cf4a 73f7 bcef 8c79 5db5 e639 d312 ...Js....y]..9.. 00000660: c477 5823 ecf1 d5cb dbfb 3c62 e5ad 2f1e .wX#......<b../. 00000670: 90f2 c6ea f5a3 3c69 4f6f 4efa 45da ca30 ......<iOoN.E..0 00000680: 5356 fd85 f3cd 2201 85d4 6f25 e693 c439 SV...."...o%...9 00000690: aa9d 9fb5 3a53 2487 e067 0918 a308 f4b9 ....:S$..g...... 000006a0: 1271 7c31 be14 9bd6 bd56 c7f5 6c00 5226 .q|1.....V..l.R& 000006b0: 3e39 1deb bd26 e064 1868 0a25 5060 a328 >9...&.d.h.%P`.( 000006c0: 7ca9 5f3b d2ee c128 e298 2778 1a05 ce01 |._;...(..'x.... 000006d0: 3123 10cd 1255 5c23 4e6f 21fc a1da 7b53 1#...U\#No!...{S 000006e0: 4f19 280e dd15 636a cad1 5001 4cd9 4184 O.(...cj..P.L.A. 000006f0: 98b2 8431 defc 1d68 d511 20e2 4d14 22a0 ...1...h.. .M.". 00000700: eebd 06e8 1e44 12c0 2f4f aa40 321a 91c5 .....D../O.@2... 00000710: 9955 d8f3 1449 107e b3c7 9c35 e8dd 3d0a .U...I.~...5..=. 00000720: 847a 723d a3a0 ae9e 1334 3f79 acd4 87df .zr=.....4?y.... 00000730: 0291 fe0a cd32 447a e28a b990 97de 280f .....2Dz......(. 00000740: cd8e 0781 c2f3 6a48 4d12 3bd0 6b90 6d2a ......jHM.;.k.m* 00000750: 4430 8c8a 844f 2388 c44a aae4 c7fb e835 D0...O#..J.....5 00000760: ae9f 28bb 02d6 c2c7 8b92 6503 cc56 4cd1 ..(.......e..VL. 00000770: ce30 9a5e 4910 0d58 efc6 5d05 57be 60d8 .0.^I..X..].W.`. 00000780: f003 c980 fe27 0321 8023 5925 1dc0 acd5 .....'.!.#Y%.... 00000790: a097 7882 c88c 8d62 36fa 66c3 7de7 94ef ..x....b6.f.}... 000007a0: 14ab c7ab f349 4516 694f 7d3f cdd8 e28c .....IE.iO}?.... 000007b0: 0372 d8f3 3bbd bd06 352b bd91 ae32 b28b .r..;...5+...2.. 000007c0: a28e 1de3 0372 3f5b fd63 a2c2 541a 1881 .....r?[.c..T... 000007d0: 97c0 f361 c924 ba84 3ddf 122e bd31 e6d0 ...a.$..=....1.. 000007e0: 74de 804f d8aa b290 7ec1 1bbe 6373 5eac t..O....~...cs^. 000007f0: c2bf e66f 2324 b024 e440 ac23 d006 39e7 ...o#$.$.@.#..9. 00000800: 2359 905b b5be e159 5d25 8bb8 7449 a8d1 #Y.[...Y]%..tI.. 00000810: 2532 0618 f0c1 37de 6edb 0166 ba18 0b26 %2....7.n..f...& 00000820: 9d13 2b32 8ac7 5b52 c3e2 9494 5fe2 3029 ..+2..[R...._.0) 00000830: 1a42 5d0f 391d 9b96 d8f1 fb87 5e1c 06d6 .B].9.......^... 00000840: 5cf8 9740 41d2 f6a8 55d9 9ecd c112 1607 \[[email protected]](/cdn-cgi/l/email-protection)....... 00000850: 541e a2a6 b145 f9a5 34e9 c5c2 0692 4a68 T....E..4.....Jh 00000860: ec46 38b3 a7e4 1a57 fe80 8801 5a67 b710 .F8....W....Zg.. 00000870: af76 a540 4ab4 3323 5f9c 8e54 4f9c 8038 [[email protected]](/cdn-cgi/l/email-protection)#_..TO..8 00000880: 1bf0 287e 8ad6 1c38 1e4a 6aae 37d0 2753 ..(~...8.Jj.7.'S 00000890: e366 dbd6 b0dc bda0 932e fff8 9c58 0ccc .f...........X.. 000008a0: 646d ad87 b85a 1dd7 7ecb dd1d a048 c092 dm...Z..~....H.. 000008b0: 88a6 99f5 ce66 f051 e10e e6de 2dc7 9397 .....f.Q....-... 000008c0: f705 5fd9 887b 6a58 132d b718 e2bb ed45 .._..{jX.-.....E 000008d0: 8e1f 68ef b5aa e30a eccb 3845 7025 e0d5 ..h.......8Ep%.. 000008e0: c066 5820 e949 a8dd 6b05 bdd1 f0d9 3e46 .fX .I..k.....>F 000008f0: 4d26 ca69 64e7 1ffd c4f5 117c 2af0 d941 M&.id......|*..A 00000900: 15de 7288 9c9b cbde 31fb 4d93 e5b0 a853 ..r.....1.M....S 00000910: 94d1 ad97 956c 5d57 c91e 8c11 50c3 d5bd .....l]W....P... 00000920: 522b 12e1 d407 d0fe 150f e684 6e9d 0435 R+..........n..5 00000930: 9a08 d00e 4dd4 59fc 9ee1 79cc 8df8 387f ....M.Y...y...8. 00000940: ee2e a6e4 5d5f 4504 ae1a 0f5f 852e 95c0 ....]_E...._.... 00000950: 2663 af88 f29f 2028 487c b7a8 c93e 721c &c.... (H|...>r. 00000960: aaed 4406 d272 f7a0 a801 6825 258c 7f18 ..D..r....h%%... 00000970: 499c f380 78b6 e33b 9fed 8882 723d 7d3c I...x..;....r=}< 00000980: 7864 b13b a689 e1d1 9ec1 afe2 d27c c5b9 xd.;.........|.. 00000990: e945 1357 a0c9 c009 4f0a 4c55 f24f 6607 .E.W....O.LU.Of. 000009a0: 0490 a64b 874c f97f 2f14 ad21 6b8f 5a84 ...K.L../..!k.Z. 000009b0: 7e14 7f9a b770 44c9 f77d 6179 06d6 5417 ~....pD..}ay..T. 000009c0: 6770 80f1 639b e5c7 24ea 4ef9 4dd4 1c0a gp..c...$.N.M... 000009d0: 69eb 0073 ab3a 82cd b0ae 6988 5efa f250 i..s.:....i.^..P 000009e0: 0b37 1dfb 8ac1 0587 2bb9 60b5 fadc 9857 .7......+.`....W 000009f0: 65e2 5d47 5648 91e8 41f8 c76c 1787 dc23 e.]GVH..A..l...# 00000a00: 60cf 509a ee5e 2136 f32b 47ca b912 f4f9 `.P..^!6.+G..... 00000a10: eb70 5e53 d5a6 7842 9d81 d899 bd61 e929 .p^S..xB.....a.) 00000a20: ca55 0a1d 831b f47e d732 a473 c03d 60d9 .U.....~.2.s.=`. 00000a30: e988 df83 f631 ab56 3fe5 db05 d7d1 8710 .....1.V?....... 00000a40: dcc0 695f a783 1c27 0863 1e83 00d9 5bcd ..i_...'.c....[. 00000a50: 3c41 5f63 7e6b 63fb b25f a91c caeb c684 <A_c~kc.._...... 00000a60: 95a7 5d6d bbc1 7d5f 2b17 7412 1dfe 5e98 ..]m..}_+.t...^. 00000a70: cb9c 0112 cfb5 e7a8 7b97 9f67 a349 d4e4 ........{..g.I.. 00000a80: ca48 8212 842f d62a daf2 0017 a5ec 630f .H.../.*......c. 00000a90: 8eb5 51fc 3788 4e34 8546 a804 0d32 6e62 ..Q.7.N4.F...2nb 00000aa0: f2c5 3cfc ab42 8360 2991 af35 b09c 9e20 ..<..B.`)..5... 00000ab0: e726 a00e 516e b355 20fd 9536 af11 4369 .&..Qn.U ..6..Ci 00000ac0: e787 a10d bed0 6f8b 2996 9f60 2808 8c20 ......o.)..`(.. 00000ad0: 8b80 f840 d64e e3a3 abc6 dc38 8908 636d [[email protected]](/cdn-cgi/l/email-protection) 00000ae0: be1a ee71 1c06 0172 8fe1 eca3 4648 0ab7 ...q...r....FH.. 00000af0: 2aa9 c1f7 34eb ef82 b064 af98 9dd9 1ad8 *...4....d...... 00000b00: 71c7 1193 ca3c c008 0f36 1722 89dd 8937 q....<...6."...7 00000b10: 5459 0cd6 dcd4 9bc5 4c97 911d 8ab5 dff1 TY......L....... 00000b20: 56c2 09c3 1ccf 846b fcde e91f e0a9 c791 V......k........ 00000b30: 28f9 f9d2 51a4 7c1c 803d 5dc5 3be0 13ce (...Q.|..=].;... 00000b40: 025c 0fa4 42d8 48d4 a227 849c 7cbc c378 .\..B.H..'..|..x 00000b50: c0c7 fcdb b73f d330 48fa 6714 cfac f35e .....?.0H.g....^ 00000b60: 0041 6074 54e7 ac78 c624 46e5 3ca7 7cfa .A`tT..x.$F.<.|. 00000b70: a9de 3f2e a922 8dde 2405 5e39 a7ad dd43 ..?.."..$.^9...C 00000b80: d6d1 db8c 4e93 2458 941e de52 3046 a973 ....N.$X...R0F.s 00000b90: 8483 752b fac0 1612 e635 9d19 32d0 9ed8 ..u+.....5..2... 00000ba0: 54eb 4f9a ad66 3fc1 ca92 3d34 0633 ccd0 T.O..f?...=4.3.. 00000bb0: bbbd 672e 1282 6ea6 4ad2 08de dcec 06d7 ..g...n.J....... 00000bc0: fceb 563c 0f55 b4c4 6c1b 3859 757a 77e2 ..V<.U..l.8Yuzw. 00000bd0: f63a 8eb8 17c5 76a2 484a f612 8dcd 5c4b .:....v.HJ....\K 00000be0: 65c3 de63 6df7 6ede cddf 5745 b2da aa1e e..cm.n...WE.... 00000bf0: 5a19 a49b 35f1 abe0 eaa6 9252 58b5 0d72 Z...5......RX..r 00000c00: 3c34 1c3f 258f 3867 b729 e036 499b 6e67 <4.?%.8g.).6I.ng 00000c10: e22d 6c76 cac7 48c5 769f 2619 d3dc af21 .-lv..H.v.&....! 00000c20: 670b a517 27b9 6013 85d0 7215 f36b aaad g...'.`...r..k.. 00000c30: 9431 d7e5 2bc3 d08d 93e2 029e 25c8 04dd .1..+.......%... 00000c40: f899 164d 2e41 bcb6 1c37 5b91 7ae2 63cf ...M.A...7[.z.c. 00000c50: 134e fba5 ae50 ccfa 1f29 da34 4e78 7d98 .N...P...).4Nx}. 00000c60: e44e 0905 6c07 af97 9662 d45b c099 19ea .N..l....b.[.... 00000c70: 33ac e440 f7d6 91c2 64f9 6e55 558e 7cff [[email protected]](/cdn-cgi/l/email-protection).|. 00000c80: 76e5 9b30 6491 d654 daa3 5cc2 7b1b 0499 v..0d..T..\.{... 00000c90: 0245 aeb4 7868 b772 14ba 7ebb e073 6ac9 .E..xh.r..~..sj. 00000ca0: 6e92 6229 2242 6c63 c00d 6637 8e31 d740 n.b)"Blc..f7.1.@ 00000cb0: 7283 bac3 febe ff72 e525 9830 033a 27a3 r......r.%.0.:'. 00000cc0: ddbe db18 bc49 ced7 fef5 5a0a 8f3e dfcd .....I....Z..>.. 00000cd0: dd6b 9908 6534 dc79 dafc e08c b427 93cf .k..e4.y.....'.. 00000ce0: 54cb 760b 1856 1faa 7a8a f8d0 fc0a 6a27 T.v..V..z.....j' 00000cf0: 293a cdef 1dff 5ab4 5f4a 58f7 6526 9cff ):....Z._JX.e&.. 00000d00: cbd9 d68a 2b25 73ed ef42 48ff 03fb 7a78 ....+%s..BH...zx 00000d10: eada e7c8 f7de d92a d78c b0be f3be e9c6 .......*........ 00000d20: b650 1349 a38d 9035 718f cc84 0975 f72d .P.I...5q....u.- 00000d30: 947d 3107 42a3 a390 30df 2345 5a8f 004d .}1.B...0.#EZ..M 00000d40: 5fab 4ac1 1742 8d65 987e 3327 2db1 029a _.J..B.e.~3'-... 00000d50: ef17 f77e 58b2 4f76 cc47 f4cf 9124 aae5 ...~X.Ov.G...$.. 00000d60: e5c3 9355 ee23 1bb0 c452 f164 3b42 9552 ...U.#...R.d;B.R 00000d70: 1914 2b76 b2e6 041e 29b2 e7dc 44c8 a8ec ..+v....)...D... 00000d80: d359 fce5 a1cb 36cf c98b 234f 4b30 24c5 .Y....6...#OK0$. 00000d90: 88d8 3cd7 fb0f 4923 de39 9195 ed47 6c8b ..<...I#.9...Gl. 00000da0: b7ec 660d cdbc cd42 53cf 5ebe e9fb e210 ..f....BS.^..... 00000db0: 301a 05c7 370d 2455 0972 c36e bac9 e12b 0...7.$U.r.n...+ 00000dc0: ed80 abde 085e 430a 0a9f 6148 31cb 41fb .....^C...aH1.A. 00000dd0: 8f76 64b5 d8df e311 31a7 135c 3e17 a44c .vd.....1..\>..L 00000de0: 84d9 2bb1 2b1c b5c1 b41a 2490 a880 cec1 ..+.+.....$..... 00000df0: dbd5 4ad8 43cd e442 0a0c cb1d 6c62 386c ..J.C..B....lb8l 00000e00: 3c1f 75d7 e337 8111 61f0 1cc9 d8fc 839f <.u..7..a....... 00000e10: d171 649e c224 3484 ddaa da5a afe0 a6e2 .qd..$4....Z.... 00000e20: 35b3 e7ec 17dd e8d1 06b5 0604 dc68 f9f8 5............h.. 00000e30: d9af c508 eb72 4018 cc3c 96e9 3064 662a .....r@..<..0df* 00000e40: 8f63 0569 ea0a 58dd b3dd 244e c23f e0cb .c.i..X...$N.?.. 00000e50: 9a93 def1 7920 9395 e0d2 5461 f297 302c ....y ....Ta..0, 00000e60: a59a 055c e21e 0c11 d7f2 aebc 4bb7 d580 ...\........K... 00000e70: 09eb 8e10 a830 79b7 dccf 2060 d14f c157 .....0y... `.O.W 00000e80: 1374 5b90 afbc ad17 2581 9f68 c8f4 c4f8 .t[.....%..h.... 00000e90: 2384 5edf 4dbd df0f 5b77 d727 6ae3 4729 #.^.M...[w.'j.G) 00000ea0: 897d 7e9d 68ba 14bf 40f7 ffb3 66b5 24cb .}[[email protected]](/cdn-cgi/l/email-protection).$. 00000eb0: 57bc df66 4525 7323 c156 441a e03d c958 W..fE%s#.VD..=.X 00000ec0: b810 643c ed35 7386 c48c bb96 646a 35ce ..d<.5s.....dj5. 00000ed0: 139e d881 ca0f adcd b609 867b bcc3 51a5 ...........{..Q. 00000ee0: f327 ae4c d187 4eb1 9303 277e 19d4 1010 .'.L..N...'~.... 00000ef0: 797b 8b75 c18f 22c0 06f8 5a1c 00cd c6b4 y{.u.."...Z..... 00000f00: 993f 7a2a 226e 41e2 b392 c932 dc7d a5e8 .?z*"nA....2.}.. 00000f10: 3331 555b 043d 151a e097 f208 7075 1926 31U[.=......pu.& 00000f20: 131d 479b 6177 151e 74d6 6c6d fdfd 75cc ..G.aw..t.lm..u. 00000f30: 043a ce4e 68a1 ffe4 7b70 95b4 08bd 926f .:.Nh...{p.....o 00000f40: 10d0 1522 88a8 feaa d4b9 fca8 be5b 9399 ...".........[.. 00000f50: db2a c61d 5350 937c 4937 2759 0446 77f7 .*..SP.|I7'Y.Fw. 00000f60: 055d 6f5b 6acd eb6f 008c 6ef6 a42c 2799 .]o[j..o..n..,'. 00000f70: 6a64 b1bf 3e39 e659 a573 5f50 6b14 2752 jd..>9.Y.s_Pk.'R 00000f80: cb86 d645 8626 86d1 92ad caa0 b256 c865 ...E.&.......V.e 00000f90: ed40 9128 0a48 4212 67b5 e8d2 e8fd 5bf9 .@.(.HB.g.....[. 00000fa0: f0d5 aa11 ed57 d431 ea81 f335 6610 6609 .....W.1...5f.f. 00000fb0: 2a42 23e6 b8ee 8d8b 454d 4660 3809 b8d4 *B#.....EMF`8... 00000fc0: 3b7e 5811 2414 8c85 02a9 7781 f0a4 909d ;~X.$.....w..... 00000fd0: c9d0 1cd1 b20d 6a7c 31f4 181f 4d0a 12e6 ......j|1...M... 00000fe0: 7dea 09e9 6572 24ae 7c98 2346 162b 728e }...er$.|.#F.+r. 00000ff0: de97 20c3 a049 e2cd d630 9e95 b327 68f2 .. ..I...0...'h. 00001000: 3475 30ea 5575 2590 edae 7375 1994 d522 4u0.Uu%...su..." 00001010: 7e5a 287c 1747 1999 2c34 d777 cd53 6981 ~Z(|.G..,4.w.Si. 00001020: bfe6 ef9e f5bb 6d27 7f21 0885 36c2 ef91 ......m'.!..6... 00001030: 498a e102 eb9b c5d4 6e76 fa64 d55e 12e0 I.......nv.d.^.. 00001040: 78af 14b4 21a5 2460 4f00 990a 4b68 ee94 x...!.$`O...Kh.. 00001050: f41e 09ef b117 de56 6d11 3cc5 59ee d83e .......Vm.<.Y..> 00001060: bb25 beeb 14a4 c6e2 b4c2 ada5 dc24 d950 .%...........$.P 00001070: 80bd ff79 0737 6b78 a509 87ff d9ff 18e5 ...y.7kx........ 00001080: 02ea 878d 42ef 1bb8 6349 5f3a 9334 4cfd ....B...cI_:.4L. 00001090: 4b44 0aac c78f c418 15c7 365c fc61 a218 KD........6\.a.. 000010a0: c092 d0ca 797a 93be 5364 6098 a51b 11a7 ....yz..Sd`..... 000010b0: 2edd d0c5 610c 7352 74f2 6d29 81bf e2a4 ....a.sRt.m).... 000010c0: 47e8 8e72 3234 4caa d77f dfaa 13dc eab8 G..r24L......... 000010d0: 9ccd 9167 6e69 16bb 62d0 5185 8c65 82ac ...gni..b.Q..e.. 000010e0: aab4 3f7b f0c3 45cc 37ce 13eb 52c0 655e ..?{..E.7...R.e^ 000010f0: 7173 e1b3 4277 7a3b c995 5a62 7193 44d0 qs..Bwz;..Zbq.D. 00001100: 237b f08f 5a45 e8e3 1672 797b ca2f 5cd5 #{..ZE...ry{./\. 00001110: fc09 eadd 0b1c de42 c918 1cdd 2d44 7725 .......B....-Dw% 00001120: 319e 5867 bc96 f3ce a701 332d 3907 5d31 1.Xg......3-9.]1 00001130: cba2 6674 ddd9 acb4 127b 2571 3887 2fc1 ..ft.....{%q8./. 00001140: e1f3 1ecb 4637 d4e1 c4b1 d947 dd04 d069 ....F7.....G...i 00001150: 412a 2ba5 2177 f799 9b06 705d c6c8 5936 A*+.!w....p]..Y6 00001160: a447 fb66 12ed afa8 27b4 e5b9 dadc 4ea7 .G.f....'.....N. 00001170: 9684 4e63 ef10 0097 4f64 ace9 7962 8f5f ..Nc....Od..yb._ 00001180: 5160 6de2 6988 8c0d 6f43 707d 4cad d0a0 Q`m.i...oCp}L... 00001190: cf96 32bc 8b44 1737 9e45 be21 fad3 ab71 ..2..D.7.E.!...q 000011a0: 8ee6 5189 73c4 8234 e4d4 3850 3913 e41a ..Q.s..4..8P9... 000011b0: 1ca3 e726 dc19 9b9b 12ab 83f4 e717 9af2 ...&............ 000011c0: 3e6b d459 10da 3a1f b508 2cab a89c 1f7d >k.Y..:...,....} 000011d0: c75b 8501 4547 c2b4 0869 6d7d d777 f850 .[..EG...im}.w.P 000011e0: f8eb ec03 ac33 bb6a 098f 5988 7b78 eaab .....3.j..Y.{x.. 000011f0: 5b98 aa49 bf7b b793 20b7 39c1 5af8 13e7 [..I.{.. .9.Z... 00001200: 4653 150f 26f8 dcfb 8c23 110b d824 afa0 FS..&....#...$.. 00001210: 37c9 d5e9 b6d6 f8a1 5065 ef6e 52f6 680d 7.......Pe.nR.h. 00001220: 66ce d2aa d90b 580f f913 0773 e41e b651 f.....X....s...Q 00001230: 838d e921 72e7 e44b 82a4 03c6 c28e 2d7b ...!r..K......-{ 00001240: 6720 231c ee5f 247d 2bbf e252 d3ee 05d2 g #.._$}+..R.... 00001250: 1a62 62a4 ae64 ce2f 5919 c0da ba86 2904 .bb..d./Y.....). 00001260: 4bbc a5fa 797c 152d a9bd a9de 8aee e20e K...y|.-........ 00001270: 3de1 f3a2 2ddf c5c5 dc32 1d8a 86f9 c1b4 =...-....2...... 00001280: 7e53 87c9 46f5 939d 49ee 4bc7 d0b0 307b ~S..F...I.K...0{ 00001290: 23a4 bddf c092 4d41 06f8 328b 0f1f 25a8 #.....MA..2...%. 000012a0: 757d 2b5a a9e3 a529 0b83 6374 041f 8db2 u}+Z...)..ct.... 000012b0: e128 837c 319c 5fba 6736 1725 7024 055d .(.|1._.g6.%p$.] 000012c0: 98f8 fb6e 616b e2b1 9203 cfca d350 ab05 ...nak.......P.. 000012d0: 4bf1 ce6d 5418 a845 e815 4f19 d38d 0086 K..mT..E..O..... 000012e0: 85bf dab1 3cdb 75f6 4827 2a01 41ce 82b6 ....<.u.H'*.A... 000012f0: a763 b94e 911e 8395 ca6c 825b 08c6 06d6 .c.N.....l.[.... 00001300: 7dda f44f 0522 6fa4 6b4f 46b1 884f 335d }..O."o.kOF..O3] 00001310: 384e 8af9 c169 8db5 3829 642b 265e e305 8N...i..8)d+&^.. 00001320: 0055 cb2e ffb6 341b fb12 2cfc 7650 2804 .U....4...,.vP(. 00001330: cb2d c672 dbfc 8cd0 8588 bbc9 8011 a9df .-.r............ 00001340: 9d20 ed50 f38e bff9 565a 86af 31f9 4a36 . .P....VZ..1.J6 00001350: 91b7 f47b 9936 ffff b59d 3319 f856 21b8 ...{.6....3..V!. 00001360: 9586 84fe fb1b f0c1 79c4 85b2 71c9 02d6 ........y...q... 00001370: c353 5c92 9c18 157d 6e48 ea57 4ee8 fea2 .S\....}nH.WN... 00001380: f924 fc05 dfb7 797c 60cf 915d cde2 d598 .$....y|`..].... 00001390: 2e42 cb12 bab1 8225 3ebe 87d7 9983 48c3 .B.....%>.....H. 000013a0: 072a e6be 52ec b41c 6132 5103 5828 12cb .*..R...a2Q.X(.. 000013b0: 8261 5384 a97d 3387 190e d3ce b872 395a .aS..}3......r9Z 000013c0: 435d f0e0 27c1 26d2 937b 47d3 f83e 5681 C]..'.&..{G..>V. 000013d0: a586 fef7 97ef ede1 083d f148 59b8 2a09 .........=.HY.*. 000013e0: af57 4e76 5b05 dcd9 2905 d254 2e64 cd7f .WNv[...)..T.d.. 000013f0: 678d 392f 9fb0 f0d3 b2c9 8275 9faa 9453 g.9/.......u...S 00001400: f9b1 7cee fa20 2b7d 25bc 7fa4 c471 2487 ..|.. +}%....q$. 00001410: 1b71 74f7 4bf7 7751 3a63 a261 ac3e 7cc6 .qt.K.wQ:c.a.>|. 00001420: 068b 9ec4 6c9a b373 4ca4 d3f1 4d82 49c2 ....l..sL...M.I. 00001430: d10b 4734 3200 5449 974d c53b 103b 1576 ..G42.TI.M.;.;.v 00001440: 1a4a 0533 fc69 2f06 efad 9166 7314 285e .J.3.i/....fs.(^ 00001450: 12cb 20fc 21d9 55b1 b1e7 7a82 a148 d8ef .. .!.U...z..H.. 00001460: 04b6 b037 20e2 67c3 f0ca cdbc bf28 52e6 ...7 .g......(R. 00001470: 0642 9392 a454 bc57 59ac b40f eda4 f5a0 .B...T.WY....... 00001480: e0d8 d602 f15b 4671 e66e 0320 32c8 96c6 .....[Fq.n. 2... 00001490: 5325 3133 f05a 5a41 a69f 91e8 b700 7639 S%13.ZZA......v9 000014a0: e1a8 4211 6d00 345d 0201 c003 03c5 d9af ..B.m.4]........ 000014b0: 048c 4f0c c453 f316 e9c8 df85 534d 28f4 ..O..S......SM(. 000014c0: 475c 87e0 1397 d243 f771 3e32 4a7e 533d G\.....C.q>2J~S= 000014d0: 8834 1842 4414 6e08 2756 54fb 6b1f 5753 .4.BD.n.'VT.k.WS 000014e0: ec98 bd10 5add 449c 9b80 c32a ec8f ae90 ....Z.D....*.... 000014f0: 8547 ca79 10ae c6a0 fbcf a2fe b728 f801 .G.y.........(.. 00001500: e197 1a11 2050 9ae7 d17c 4662 08e4 3480 .... P...|Fb..4. 00001510: cfb3 2a40 258f a75c 09ce c7d7 bc93 126d ..*@%..\.......m 00001520: 87a5 841e bb06 31f2 ba97 1672 76f9 d654 ......1....rv..T 00001530: cf7d 1870 2405 cbc5 2352 f0a6 adcb 5544 .}.p$...#R....UD 00001540: cf77 581f d4bd 827c 035d 6cda 9d89 48d9 .wX....|.]l...H. 00001550: 45b4 6876 e86a 0a07 19a7 c487 9dd8 8b42 E.hv.j.........B 00001560: 053b 5deb 53e1 6e01 7327 9ede f31c 5245 .;].S.n.s'....RE 00001570: 8a91 c878 7948 ddba 9f79 0bfb 496d 9742 ...xyH...y..Im.B 00001580: 39e2 9476 db47 6565 f109 f200 b5df b767 9..v.Gee.......g 00001590: 15f3 5580 ee10 5160 ad8c 3070 9720 e4a7 ..U...Q`..0p. .. 000015a0: fdfc 0d33 dcbd 7f53 357f 433e c199 890a ...3...S5.C>.... 000015b0: ad12 1eda 683a a446 4c10 56c6 7a4c 0249 ....h:.FL.V.zL.I 000015c0: 7c03 d414 4ae8 42c3 887e 7b89 578a a45f |...J.B..~{.W.._ 000015d0: f6bf 94ef eb38 3342 b8d4 4737 832c 7f07 .....83B..G7.,.. 000015e0: 5ec2 8b22 a762 5199 5e5c b110 698e 8b86 ^..".bQ.^\..i... 000015f0: ee8f a5d2 7361 c53a be8d 1d9f f0f3 ee56 ....sa.:.......V 00001600: 2e23 1958 7210 01f5 0964 6acc 4ec8 054d .#.Xr....dj.N..M 00001610: 32b0 9397 475d 2918 f180 2ca2 b2b7 6ec8 2...G])...,...n. 00001620: 1dd3 b9b2 2b14 3197 a490 848a e915 1287 ....+.1......... 00001630: e2e5 4dc0 583f a690 391a 0c7d 16af 2e17 ..M.X?..9..}.... 00001640: 2e4c 53cf f976 32a4 cb7e 2a0a dba4 6d45 .LS..v2..~*...mE 00001650: c1a6 430b e18a fe45 a9da d4ef 34d3 0e97 ..C....E....4... 00001660: 01f2 2dfd b766 4e54 92ce 863c a1fe 05c0 ..-..fNT...<.... 00001670: 5797 0688 20d6 8fc2 0f1c 29ff aacf 1e07 W... .....)..... 00001680: eb08 8561 b1bd dced a1a4 b581 e0f3 45c4 ...a..........E. 00001690: 631f feef d628 636d fc4c 02ae 5a13 aade c....(cm.L..Z... 000016a0: eb92 06e3 9001 c2da e8de 0b20 9f22 98f0 ........... .".. 000016b0: c991 06f4 8712 f28a 1246 a3a9 a26c cc5e .........F...l.^ 000016c0: 947c 7edb 6200 3609 db10 46bb e0ec 1434 .|~.b.6...F....4 000016d0: 6bbe c4a9 2892 69fb 9620 e16d 7490 0f2a k...(.i.. .mt..* 000016e0: 6e5b 4833 5e5c 281f 6dc5 e73d 6891 f56d n[H3^\(.m..=h..m 000016f0: ae06 c2d9 0f28 1e0a a5ab b28b 7310 68b5 .....(......s.h. 00001700: 24b3 22bc 58d1 0d7e 0f03 315b 32c7 b927 $.".X..~..1[2..' 00001710: 1447 442e 2e48 b7c0 e258 b4a8 2de0 b7bb .GD..H...X..-... 00001720: 16fb 71e7 43d8 54e9 7a13 18db c449 921e ..q.C.T.z....I.. 00001730: 78ef 1077 bdf2 b57a a036 71d1 2a9e 799a x..w...z.6q.*.y. 00001740: c74f 99c2 bf94 d297 eda8 901b ca2d 2f59 .O...........-/Y 00001750: 858a 399e 27dd ca80 2abe 04d2 e4fe 217c ..9.'...*.....!| 00001760: eea6 87d2 4162 9df1 b858 09e6 afd6 175a ....Ab...X.....Z 00001770: b16f 6283 ca8b d04a 5c51 cc64 1d88 f02c .ob....J\Q.d..., 00001780: d996 76b9 1b88 950d 1459 6831 93c2 b358 ..v......Yh1...X 00001790: 554e 3e66 ff7a 550b fcdb 4375 e35b 75dc UN>f.zU...Cu.[u. 000017a0: 515a 656b 18fc db06 7041 5f01 369c 780a QZek....pA_.6.x. 000017b0: 0b9c 5bb8 6a3f 7472 69c2 e0b0 466a b31c ..[.j?tri...Fj.. 000017c0: c3ed 9962 28fb b6b4 49d3 65cb c68c ed66 ...b(...I.e....f 000017d0: b19c c4b2 68ba 2d07 caea 0ecf 9df7 ab43 ....h.-........C 000017e0: 97bd f014 c640 f581 d91d 3a27 bfd4 752c .....@....:'..u, 000017f0: 5290 8476 929a ac2a f1c3 2796 555c 9b98 R..v...*..'.U\.. 00001800: c43e 1678 ff03 957a bfe0 5467 8c2c b275 .>.x...z..Tg.,.u 00001810: 847f 500a f58f c4e2 9a87 b92e 0107 c708 ..P............. 00001820: ebe4 8c62 eaae 9b81 4ade 8975 2b2c b168 ...b....J..u+,.h 00001830: b9fe e914 bd6c 5c9c 4d6d 3e27 27cc 0004 .....l\.Mm>''... 00001840: 3dad 3d7a 91a1 666f ee49 dbe6 aa4f 04f3 =.=z..fo.I...O.. 00001850: 81bf 5487 5ff2 996d fbf8 7cf7 dbc9 464c ..T._..m..|...FL 00001860: a4d3 4e5b 8704 ffb6 c29a 40fe 5856 9c6c ..N[[[email protected]](/cdn-cgi/l/email-protection) 00001870: f33f 1f72 1db0 6370 728e 1383 5138 ce6b .?.r..cpr...Q8.k 00001880: 0d9c 3beb 8ddd 4bbf 83d4 c6c3 ddbe d5a8 ..;...K......... 00001890: f015 a19a a127 4aca 616e ce7e d29d beb4 .....'J.an.~.... 000018a0: 5e0a 7cae afca 03d6 d86c c21c d560 628d ^.|......l...`b. 000018b0: 9642 328a 8e69 52df 64bd b429 7b3c d8ad .B2..iR.d..){<.. 000018c0: 9afe e869 7896 2c79 beb1 203d 0b18 a276 ...ix.,y.. =...v 000018d0: 5282 d0cb 827e f379 b9e5 14d5 d508 2c8a R....~.y......,. 000018e0: 7c50 81d5 2952 60ee 1a7b 51d4 17a5 4dfd |P..)R`..{Q...M. 000018f0: 7ef0 cc0b 0cb1 9fb8 df07 652d fef7 f79a ~.........e-.... 00001900: 9a7b dd8c ab6d f5a7 8eca 0994 a63b 6fab .{...m.......;o. 00001910: 5cbb 7752 06e2 ee56 4068 ee93 bb28 4ebe \.wR...V@h...(N. 00001920: d6bf c5d8 e0be cf7c 87b2 6e89 46dc bb82 .......|..n.F... 00001930: 9175 1b90 8ef3 2707 64c7 c515 7e83 f5b4 .u....'.d...~... 00001940: c680 7372 a900 9fef 01f0 d444 e8d3 485d ..sr.......D..H] 00001950: c8fb 14c1 efd9 8f11 e91f 6041 5e6e 419c ..........`A^nA. 00001960: a3e7 1032 993f 1660 c155 3dcd 992f 850c ...2.?.`.U=../.. 00001970: 0911 03fc 138d 66c2 d361 4309 8071 af9b ......f..aC..q.. 00001980: 917a 9257 c21f 79d1 555f 2557 d246 dd73 .z.W..y.U_%W.F.s 00001990: 91c1 d568 1c0a bdec f8e7 c8df 4398 e3e8 ...h........C... 000019a0: 337a 4d36 adee e2d3 0f92 ed51 615d 9fa1 3zM6.......Qa].. 000019b0: f485 f2bb ef3e 669e 7983 d7f2 067e ddd5 .....>f.y....~.. 000019c0: 5bf3 bdd9 457f de60 d227 9839 d91f 9d33 [...E..`.'.9...3 000019d0: 1891 d2d3 25bf f92d 637b b26e 0717 4efd ....%..-c{.n..N. 000019e0: aeba cccb e62d 4ecb c93b 54b0 1d96 8283 .....-N..;T..... 000019f0: 5552 8727 6d3a 47cb c930 8f52 4a5c d72c UR.'m:G..0.RJ\., 00001a00: 9288 4f7c 0e49 f768 e2c5 b3a8 8169 7544 ..O|.I.h.....iuD 00001a10: 92f8 f091 20f2 a994 1494 c58f fdf8 ace4 .... ........... 00001a20: 1116 7129 7b41 80f2 f0b2 cf6a 7f43 6196 ..q){A.....j.Ca. 00001a30: c0ed 79c5 4ccf 52b0 538d 50e5 722a 78d9 ..y.L.R.S.P.r*x. 00001a40: 975e 8b3b f82d b525 b320 7f2b 0c07 dda2 .^.;.-.%. .+.... 00001a50: c30c 9cd0 fa6f 8615 9f1f cebf f8f4 417e .....o........A~ 00001a60: 9029 0b1d 0cae 2ae9 8bd0 da3e 082d 1af7 .)....*....>.-.. 00001a70: 320e f0d6 c22a b474 95aa 2b11 ab0e 2486 2....*.t..+...$. 00001a80: a1f8 5310 7f43 03be db41 2418 e106 ee31 ..S..C...A$....1 00001a90: f562 b8ae 3951 1e7a d9f4 ef71 0f8c 87e7 .b..9Q.z...q.... 00001aa0: 7c0b 682e d940 f7cd 8f42 3b5b 29b6 843c |[[email protected]](/cdn-cgi/l/email-protection);[)..< 00001ab0: 822f ebe1 bd13 51ea aa00 c990 60a5 6c6d ./....Q.....`.lm 00001ac0: 2161 cb20 9e67 de9b 2be7 06a4 5e88 2a68 !a. .g..+...^.*h 00001ad0: 997d 9be8 dd79 08f0 8180 08dc cdb3 24af .}...y........$. 00001ae0: 51da e83b 9893 01ec 6548 f1e1 c43b f730 Q..;....eH...;.0 00001af0: d099 c07f bb48 231d 9b4d be60 4df8 87a4 .....H#..M.`M... 00001b00: e333 c11d eef3 8f75 f4c6 ceb3 7ade e2f6 .3.....u....z... 00001b10: e97f 3e90 d9be fbb1 cd71 2125 f61d da4e ..>......q!%...N 00001b20: c70f 41f4 d6cd fd87 88a8 8f57 c15f 0e89 ..A........W._.. 00001b30: 157d fe57 bac2 ac5e d53e 4b25 79df 8bef .}.W...^.>K%y... 00001b40: 4d87 ed4a 171e 0487 e876 3d28 b965 593f M..J.....v=(.eY? 00001b50: ebd7 97df 224c 91d3 df6f 8979 159e 75fd ...."L...o.y..u. 00001b60: 1a36 362f 3da1 e9e5 7f59 6e99 2ceb 967b .66/=....Yn.,..{ 00001b70: d5f2 136d 8b0a 9cb5 1c75 59ff eb76 f9cb ...m.....uY..v.. 00001b80: f16b b40f 0f05 7ee4 fb55 0e5a 1f25 efdf .k....~..U.Z.%.. 00001b90: eebc be88 ba55 2359 df8c dc4b e254 1ad6 .....U#Y...K.T.. 00001ba0: 1bb0 5dd8 3cf7 a34d c9f1 e172 9b02 fc39 ..].<..M...r...9 00001bb0: 2d54 a38f 5faf 3f08 d03f f946 7631 eb36 -T.._.?..?.Fv1.6 00001bc0: 6903 6468 333c 5e7e cfed 579c 6d5b 80fc i.dh3<^~..W.m[.. 00001bd0: 2b6f df14 0cee d723 d3a2 ff66 c581 b0df +o.....#...f.... 00001be0: dd70 df18 7c63 febb afbc 5a97 8272 df5e .p..|c....Z..r.^ 00001bf0: 9cc6 f6b4 eff5 5abd 12ad 0fac 1ee9 0957 ......Z........W 00001c00: f89c f98c 98b0 0d50 71a8 43f1 d894 ee92 .......Pq.C..... 00001c10: 2d65 d6b3 cf67 183f 2bce 5129 36b3 c268 -e...g.?+.Q)6..h 00001c20: 150d e133 3c16 aa0f c429 ce24 6e73 966d ...3<....).$ns.m 00001c30: c14f d202 b7f3 dacb 75af bd49 77de 30fc .O......u..Iw.0. 00001c40: 07f4 7ecc 154a 65f8 fcfc b1e1 eab8 f682 ..~..Je......... 00001c50: 395f 3234 bedd 3f15 9a30 31dc 74bd ac32 9_24..?..01.t..2 00001c60: fd5a 5e13 fa0f 3f5f 7e71 f4dd 42ea 24c8 .Z^...?_~q..B.$. 00001c70: b95e dc50 95ac fa91 3821 4340 0aa6 0e7f .^.P....8!C@.... 00001c80: cae4 134b 6865 f32e d9ff e7ff 0026 223b ...Khe.......&"; 00001c90: f8 ``` [Answer] # Sledgehammer, dev branch, 136 + 1 + 7196 = 7333 bytes The dev branch is both more buggy and less buggy than the normal branch. At least `#` and variables work properly in it. No built-in compression (except that this entire language is one big piece of source code compression)! Mathematica somehow knows when you're performing one-huge-exact-number arithmetic coding, and segfaults on every single action. It feels like this solution somehow works both only in theory and only in practice. In the end, I managed to use the interactive app to display the braille code, but I was not able to copy it from there. I had to introduce code modifications so that the "CGCC submission" section doesn't start evaluating the code repeatedly, making it impossible to copy. Here is it: ``` ⡱⢿⢧⡷⢣⢗⠊⠴⢼⢹⠐⢀⠐⢻⣀⠏⡟⡘⣈⠿⣫⡚⢂⡟⡆⠴⡢⢞⡞⡝⡰⡃⡟⣐⡗⡏⠬⡃⡇⣊⠰⡳⡺⡺⢨⠐⡻⢈⣝⡎⠤⢷⢃⠆⢹⣊⣎⡎⠬⠺⡇⣂⢔⠇⢅⣸⢃⡺⠲⡥⡧⡇⣊⢪⡇⣢⢸⠇⡕⣼⠇⣍⢤⠝⡁⡐⡷⣛⡫⢿⣏⠞⢆⡟⡷⣫⣶⢮⠛⠝⣖⠻⢠⢫⠻⣬⠷⢲⢊⣪⢮⠷⢲⢹⣱⡙⢶⠓⢖⣥⣐⢜⢼⡕⠃⡴⣜⠽⡽⠸⣣⢲⣎⠚⡻⣕ ``` Since this code is nearly impossible to execute in the normal Sledgehammer environment, here's the Mathematica code (made unreadable by copying): ``` comp = FromDigits[Import["f","Byte"],256]*2^-57567; freqs=(Divide[Accumulate@#,Total@#]&)/@{{0,2881,2023,1742,2308},{0,2084,888,439,2081},{0,1612,1168,1093,1990},{0,2377,1413,2589,3215}}; l=0; r=prev=1; Print@@Map[( f2=Rescale[freqs[[prev]], {0,1}, {l,r}]; {l,r}=f2[[{0,1}+(prev=LengthWhile[f2,#<comp&])]]; prev )&, Range@29903] ``` Outputs `ACGU` as `1234` (Mathematica is 1-indexed). It performs a weird kind of arithmetic coding that I came up with myself (although it is obvious that I'm not the first one): the probabilities for the next character are estimated from the previous character. Requires a binary file named `f` in the current directory. `xxd` dump of its contents: ``` 00000000: 25b0 5b51 d075 9b20 aa7d 28d6 577a 4c3b %.[Q.u. .}(.WzL; 00000010: 5cdb 5777 bbb9 5d5e 436e b49e 329a ec02 \.Ww..]^Cn..2... 00000020: 0a03 b3ac 60c4 344a 70fa d31b 1504 7535 ....`.4Jp.....u5 00000030: db04 0b23 f505 1955 d924 f278 5372 cec1 ...#...U.$.xSr.. 00000040: 2d87 7779 73a5 4921 4e84 6e6d 0bbc c9cc -.wys.I!N.nm.... 00000050: 2328 3fba f150 2d70 1c79 d98a 3051 ee1c #(?..P-p.y..0Q.. 00000060: 86ae 9c68 4ef7 81c9 fe21 6511 23ef 853e ...hN....!e.#..> 00000070: a2e8 038a 31fd ec9e 4d27 93cd 9739 b8ae ....1...M'...9.. 00000080: 5c72 a357 d397 e360 7199 95f0 d921 5fa8 \r.W...`q....!_. 00000090: b466 bbfe 626b 49a7 fd63 d05b 25bc 09b2 .f..bkI..c.[%... 000000a0: 825f b4f3 3d3b ef96 fc8f 16e0 3889 4ed4 ._..=;......8.N. 000000b0: b6b7 9183 bc62 51ef f5d3 661b a2dc 0e86 .....bQ...f..... 000000c0: 47b3 665e fc12 87b2 b36c a390 d11f 54d5 G.f^.....l....T. 000000d0: 8576 b900 6626 6d3c 0f54 be56 3391 ed08 .v..f&m<.T.V3... 000000e0: 5f3a e64b 647c 3fdf dfc2 bd4e ed4b 8930 _:.Kd|?....N.K.0 000000f0: 1af6 e650 7257 ca36 f433 851c bf57 ab9d ...PrW.6.3...W.. 00000100: 7f37 7ffa bc82 9df3 66a9 2f46 e221 4665 .7......f./F.!Fe 00000110: c1fd 4ba3 648f df4f 46e3 86c4 2175 0140 ..K.d..OF...!u.@ 00000120: 3916 68ca a886 6fd3 5812 3715 f45b b053 9.h...o.X.7..[.S 00000130: ffd5 8dad 1ded 6cad 6c35 2005 b94a 81bc ......l.l5 ..J.. 00000140: f713 251e 556f 9e82 a39d 6f23 40dd 00c7 ..%.Uo....o#@... 00000150: f5ea dac4 0d0c 8a4b f359 d195 bb91 8316 .......K.Y...... 00000160: 5cc0 c627 c3d0 59e9 8078 9d46 3f5d 1e8c \..'..Y..x.F?].. 00000170: a756 e4cb 6dd4 ab1a 1d68 908f c8dd 750a .V..m....h....u. 00000180: c426 2d58 c8ed 2fb4 8942 b43a 7dbb c732 .&-X../..B.:}..2 00000190: 6c46 08ba 859b 7842 17d6 ff47 1cfd 5796 lF....xB...G..W. 000001a0: 6bd8 bc36 c2a7 4d13 a106 7ad8 1016 d1d3 k..6..M...z..... 000001b0: b164 8642 be94 0dbe 7092 ffbc 2a16 fad0 .d.B....p...*... 000001c0: 5f31 5e34 2356 d61d 33ff 605a 8658 9de2 _1^4#V..3.`Z.X.. 000001d0: d479 7d1b c6fc 2706 b411 20b2 c114 1ff2 .y}...'... ..... 000001e0: d093 90d4 da4b 99ee be05 2c66 ed7f 4758 .....K....,f..GX 000001f0: 8e46 b1e6 c103 d010 bcaf 9209 127d 5494 .F...........}T. 00000200: f0fa 7831 f9ca ca42 d89e 4b4c 15e2 4d55 ..x1...B..KL..MU 00000210: 52c1 d637 dbd1 b8c6 7ac6 c75b be1d 98b7 R..7....z..[.... 00000220: 3f24 5fe2 4493 c39f ec67 1cb4 4f1b afaf ?$_.D....g..O... 00000230: e226 0ddf e08b 741d d98a c173 770c f1f4 .&....t....sw... 00000240: 2cef c968 37a7 33f9 4956 3707 ca16 0c24 ,..h7.3.IV7....$ 00000250: 930f d5d1 ff77 53ef 260a 8416 4add 6e92 .....wS.&...J.n. 00000260: 42a2 da86 bb02 4de4 400a 6faf 8625 0975 [[email protected]](/cdn-cgi/l/email-protection)..%.u 00000270: 9cd9 8092 1dd4 4615 4807 ed71 b7ce ef52 ......F.H..q...R 00000280: ac49 4d1d 4b33 0843 8c10 5180 cafb 0d40 .IM.K3.C..Q....@ 00000290: cd30 1876 ea2b 492e acd1 da8a a986 2bf3 .0.v.+I.......+. 000002a0: 8d79 74e7 bf0f c41a 414a 2449 9e2a 7b1a .yt.....AJ$I.*{. 000002b0: 47b1 28e8 f512 bd93 c5f9 9af3 ef2d e8ab G.(..........-.. 000002c0: 8ea3 6995 1511 095f 6fb6 a9c4 b1da a1e4 ..i...._o....... 000002d0: 9144 0e26 b0b9 4bb9 cfc8 b5fa f288 8da1 .D.&..K......... 000002e0: 645e a552 5565 2ead a3c7 b70c a69b 5f75 d^.RUe........_u 000002f0: f048 8c15 6b98 5845 9f51 d1d7 1860 99b3 .H..k.XE.Q...`.. 00000300: 16c3 f860 b516 ebac d1e2 a132 8eac 3cf0 ...`.......2..<. 00000310: 68fb 6177 40dd 340c e5ba 0414 516d 9687 [[email protected]](/cdn-cgi/l/email-protection).. 00000320: 52d1 d49c a14b beca b962 07fb 32b9 473f R....K...b..2.G? 00000330: 729c 07fe e03d d634 b047 c736 a86a 415a r....=.4.G.6.jAZ 00000340: c64b 27a5 5bc3 50de 9db4 3f2f 2fbe 24c2 .K'.[.P...?//.$. 00000350: cab1 fc5e 5f8b 976a 855e 90a4 9ba8 227e ...^_..j.^...."~ 00000360: aa03 1d8a 6a66 6e4d b4a4 6ebc d12b 7a1e ....jfnM..n..+z. 00000370: 47af 3f26 4cb9 a0be 5e4d 5de2 1490 253b G.?&L...^M]...%; 00000380: b1cf 4be0 cba6 9d42 4c9d a03a 2a58 eb8d ..K....BL..:*X.. 00000390: 8872 a085 0ba2 ff20 27ac ad81 6fa3 4430 .r..... '...o.D0 000003a0: ccd9 da65 dde4 a664 c311 e839 e205 cc13 ...e...d...9.... 000003b0: e86b d0a8 4f32 3b45 2fce 9143 ad91 138b .k..O2;E/..C.... 000003c0: 578a 1b4b 2415 f118 1c9f 5619 cd4d 7b13 W..K$.....V..M{. 000003d0: 48f0 a2ba 80ef 0ef1 7ffb aedd 7dfe 0835 H...........}..5 000003e0: ec0d c995 d5fe 1f8e 29e3 696c 947b 371b ........).il.{7. 000003f0: e7f4 2d83 8845 7fe8 3466 30de 429e 819b ..-..E..4f0.B... 00000400: f8b4 3567 de4b d840 76ca 1792 6279 26df [[email protected]](/cdn-cgi/l/email-protection)&. 00000410: c5be 759c f045 c5e2 add5 2baf f93f 7934 ..u..E....+..?y4 00000420: ff48 0d3b 6f03 923f 4158 5e57 d519 45d1 .H.;o..?AX^W..E. 00000430: deb7 1211 1964 a8e7 c1a0 89fc 16b8 c685 .....d.......... 00000440: 36bb bcd8 3005 51a5 e77c 5b72 aa1f 581f 6...0.Q..|[r..X. 00000450: 998b dbb1 e75f 3412 bc4a dcdb 2725 661e ....._4..J..'%f. 00000460: b756 6cc2 15f5 64d6 34fe f74b f971 2ab7 .Vl...d.4..K.q*. 00000470: 75ec ab54 069f 7693 fbdb 2d23 7b6f ca60 u..T..v...-#{o.` 00000480: e0e9 b702 830d 3aca aaf7 9cb7 4946 50ef ......:.....IFP. 00000490: 52cd 078e 9647 19c0 d472 4102 e309 f53c R....G...rA....< 000004a0: 576a d76f 15ac dc8c 8a02 85c7 a59e 140d Wj.o............ 000004b0: 4e14 cc13 416e a0d5 0bd5 0d4d a515 1cb3 N...An.....M.... 000004c0: bf4b 929b b540 b7ce 3761 5de8 f19c 9fba [[email protected]](/cdn-cgi/l/email-protection)]..... 000004d0: acde 715d da96 57d8 3a28 8ef2 c725 43fa ..q]..W.:(...%C. 000004e0: 419e 2e5b c2b8 2e33 97f7 db4c 26c5 951b A..[...3...L&... 000004f0: 19d9 16bd f6ac 17e5 470f c650 812f b3ec ........G..P./.. 00000500: c847 cf15 5c76 9922 ceb3 9f79 5a70 5ba4 .G..\v."...yZp[. 00000510: 4168 1e81 304d 8e19 2e2c a7ea 0355 000a Ah..0M...,...U.. 00000520: 5b2b 156c 6680 e1dd 7e09 d351 23a0 f2c3 [+.lf...~..Q#... 00000530: 0442 8cf1 fbf4 3805 a46a 29cc 0bb0 df8b .B....8..j)..... 00000540: ca86 b8eb 4d44 57f9 39c9 8712 2ac7 0304 ....MDW.9...*... 00000550: fa0b b7d7 d2ef 239c 55b8 a4c0 4c5c 4e5d ......#.U...L\N] 00000560: 826d 0a7e 8a51 cd35 9edf b08a 665a 2dea .m.~.Q.5....fZ-. 00000570: 243f db27 455b f64e 6def ac8f d562 4fbd $?.'E[.Nm....bO. 00000580: 09ce 937a 251d 7d6f 7c43 7df1 f9f0 dc30 ...z%.}o|C}....0 00000590: 325f 0d66 db15 c53a 2b91 d0eb 4b26 8c17 2_.f...:+...K&.. 000005a0: cd06 f899 a1c5 7478 03fa 3741 ea8b 2385 ......tx..7A..#. 000005b0: 1637 ae62 935e fa39 776f eadc fc83 de65 .7.b.^.9wo.....e 000005c0: 643c da17 07f6 1100 64e5 98d9 a9f5 fe32 d<......d......2 000005d0: ad4f 2049 7339 2aa1 ef38 4a90 bd34 82fc .O Is9*..8J..4.. 000005e0: fdcf 9291 051f b20a 2769 b6de 5f28 511e ........'i.._(Q. 000005f0: 5939 240a 68e4 8415 963e 96a4 d435 2c3f Y9$.h....>...5,? 00000600: 6a85 ed07 6924 0344 1989 5f2d 136a 0c48 j...i$.D.._-.j.H 00000610: 7670 a797 9600 84fc 4cc4 9628 f54a e11a vp......L..(.J.. 00000620: 91e3 e13d 78ec 0af5 d97c 570b 7e7c 3639 ...=x....|W.~|69 00000630: 62fc 9caa 4648 9b65 8c96 be2d aa65 0bef b...FH.e...-.e.. 00000640: 08c5 b03e c240 31bf 0155 b6e5 4b48 afbc ...>[[email protected]](/cdn-cgi/l/email-protection).. 00000650: 2608 0489 f9b7 b235 a722 bf7b 0002 a4ff &......5.".{.... 00000660: 139c 3579 df0f 505e 9437 1986 6ee0 2cd8 ..5y..P^.7..n.,. 00000670: b578 5692 c33c 9531 14fa 3da1 5f73 176b .xV..<.1..=._s.k 00000680: 9b52 b21a 7f34 cc18 0f2a 8b64 9529 21c6 .R...4...*.d.)!. 00000690: 6ca0 6c50 25b1 bd4f 393a 766c 1edc 17ed l.lP%..O9:vl.... 000006a0: 2d4a a752 5911 d7d2 c4bf 5d71 bb96 ee2f -J.RY.....]q.../ 000006b0: 8fdf 77b9 b28b 1289 f5b8 457a 571f cb73 ..w.......EzW..s 000006c0: 91fc c07f 6337 797d e165 c2ba ba12 9b85 ....c7y}.e...... 000006d0: ddb8 2021 7861 7456 af65 b9a4 ec3b 8637 .. !xatV.e...;.7 000006e0: 9d99 7158 8039 2493 6e23 cd5c 83d7 80c2 ..qX.9$.n#.\.... 000006f0: 090f 35e6 9890 4871 0828 92d0 046c 9a16 ..5...Hq.(...l.. 00000700: a6d6 9968 477f da4b 3680 c91f 1c4a 9369 ...hG..K6....J.i 00000710: bbd8 2339 a0e0 2145 1ae9 e96a c33b cd9a ..#9..!E...j.;.. 00000720: d9d9 c7e8 203b f052 a59d 149b 4ccd 2116 .... ;.R....L.!. 00000730: 562d 7638 f4f8 9b96 c47d fde7 381c 8e0f V-v8.....}..8... 00000740: 79c6 4492 25fb 0b4e a57a 6afd f825 ab8a y.D.%..N.zj..%.. 00000750: 8f28 ca3e 9a79 cd0d 5021 56fe 3c9c b6ad .(.>.y..P!V.<... 00000760: 3d01 e106 ac76 950d 03de e3a3 bab0 29bd =....v........). 00000770: f76b d2cd 1e8c 06db 2f91 f86c f745 bc2c .k....../..l.E., 00000780: 1721 168f a873 419c 2e06 55a8 d16b 1e21 .!...sA...U..k.! 00000790: dd40 8708 8bf8 38b8 1324 8455 c469 2156 [[email protected]](/cdn-cgi/l/email-protection)..$.U.i!V 000007a0: d838 bf85 4031 dc8c e321 fbb9 c464 d1d4 .8..@1...!...d.. 000007b0: 5327 adeb 3df6 dcd7 a427 ee72 2714 fd46 S'..=....'.r'..F 000007c0: 4de6 16af 5335 6616 2997 1494 b693 9cd1 M...S5f.)....... 000007d0: c5c1 873b 0138 15b3 c532 7b0b dd07 9345 ...;.8...2{....E 000007e0: dc65 5911 c142 57fc b494 d3f3 915a f777 .eY..BW......Z.w 000007f0: 9925 6803 4eab dc7e 7257 dde9 c70e 7a23 .%h.N..~rW....z# 00000800: 73b2 635e 1c7a 02b1 63af c9bd 69e4 5c13 s.c^.z..c...i.\. 00000810: c0dc 2828 9209 8308 6a49 8700 91cd ed83 ..((....jI...... 00000820: 5e92 7d9f e315 1384 a6a7 2ba0 e8f2 5bf9 ^.}.......+...[. 00000830: a40c b7e8 2155 6334 1c3c 33c4 9022 8218 ....!Uc4.<3..".. 00000840: c51f 6d6f c48d d2a0 51d1 74bb 92b9 693b ..mo....Q.t...i; 00000850: 6c5e 1c45 deb7 719d afb1 c26f 891e a714 l^.E..q....o.... 00000860: 6482 f724 0cf8 33fa b96b 678a 1f59 af08 d..$..3..kg..Y.. 00000870: 2d93 ae69 a502 ed1a b556 61f5 9b17 43f3 -..i.....Va...C. 00000880: 4aed 74cc 535f bbf2 4b49 d43b 8439 3ef8 J.t.S_..KI.;.9>. 00000890: b03a 669a 333a cc5b bd81 df68 63c2 6a69 .:f.3:.[...hc.ji 000008a0: d07e 4f4c 9f4f 711d f122 3aec f642 d098 .~OL.Oq..":..B.. 000008b0: 1658 d4d9 a91d 8b3e 959c d1b5 6368 cebc .X.....>....ch.. 000008c0: 9529 b2b2 4679 9087 2414 1370 571c 49b5 .)..Fy..$..pW.I. 000008d0: d0b6 c156 2bbb 3147 330e 0779 4228 cbe7 ...V+.1G3..yB(.. 000008e0: 5ac4 1405 e80f 5a2f a359 9566 769e e73c Z.....Z/.Y.fv..< 000008f0: 6162 a97c eb96 2f4b 8051 20d2 6628 5e90 ab.|../K.Q .f(^. 00000900: 6df2 4158 3339 8fa7 3d9b d944 e8fa 5625 m.AX39..=..D..V% 00000910: 032d 5b7d ee91 6918 ea30 b743 861b d91a .-[}..i..0.C.... 00000920: e8aa 6a6c 21d0 78d7 a3ba 8348 c9ba dbab ..jl!.x....H.... 00000930: 8ba9 1cc3 28eb 5b34 e21b 4061 2867 e1c4 ....(.[4..@a(g.. 00000940: f268 a6fa c99b b290 e0c8 15d3 f201 8dd8 .h.............. 00000950: 68db b7e1 cb09 838c 2683 ba13 c550 b615 h.......&....P.. 00000960: 7f9c 121b fa98 d7ca 634a 10e0 cf73 d17a ........cJ...s.z 00000970: 3ac3 dcbc b0fc f001 d4ec eed0 bf84 42f0 :.............B. 00000980: cc31 b7c4 354b 246b 48d8 6453 89db 91f6 .1..5K$kH.dS.... 00000990: 94e5 6a2b f8c6 df2b 1c8a 013c 49ca 884f ..j+...+...<I..O 000009a0: bcf9 162b 8388 3f6c 4413 d975 037a 3703 ...+..?lD..u.z7. 000009b0: b768 b0d7 891a b0b2 2412 3ec8 3771 e045 .h......$.>.7q.E 000009c0: 3c94 d950 56da 7e4b 5e76 fbff 8d02 e8e3 <..PV.~K^v...... 000009d0: 291b cef6 fbc1 fda3 cc4f d55a 4663 ec92 )........O.ZFc.. 000009e0: 6aff 5666 df39 35f7 d7ea a459 a9a9 a0bc j.Vf.95....Y.... 000009f0: 7f3a 3134 53dc 0091 e8ae 0950 f88a 8250 .:14S......P...P 00000a00: 1fe6 f8ff efc1 59d8 7795 cffe 1506 dac4 ......Y.w....... 00000a10: 9349 12c7 9385 97b9 24e8 1eda bfc1 a2cf .I......$....... 00000a20: 8a9c 737d 51e9 189e 16ba 30b6 e0d7 d874 ..s}Q.....0....t 00000a30: 8d3d aa00 8966 35a6 4da0 6178 c4cc 26b6 .=...f5.M.ax..&. 00000a40: 2a74 8d6d 9fbc 28b8 16ee 9bdf 97fc 880e *t.m..(......... 00000a50: ee32 574c aa94 0700 15e0 7506 cc22 070f .2WL......u..".. 00000a60: e4d7 2551 d742 b8a3 4141 56ed 2e89 7200 ..%Q.B..AAV...r. 00000a70: e8d6 4780 9b67 2e50 1e71 52f9 1f2b d44f ..G..g.P.qR..+.O 00000a80: 83c1 88f6 0744 dad0 e3c7 2555 f523 0ef2 .....D....%U.#.. 00000a90: d7e9 e57a 278a 5822 8cfc 2708 8a36 5113 ...z'.X"..'..6Q. 00000aa0: 2808 5383 1e5a ac3c 3d3f 1dfb d2e9 27b1 (.S..Z.<=?....'. 00000ab0: ef7e 059a fb5d 047c 7000 8448 8a81 949d .~...].|p..H.... 00000ac0: d10c 80cc f8aa 82f6 eb85 ecfc c0cb ad82 ................ 00000ad0: 057a 84b8 4dcf 6114 9b98 f37f afa8 c078 .z..M.a........x 00000ae0: 871b 7519 0180 d579 b53c 7a20 2881 46cf ..u....y.<z (.F. 00000af0: ab85 ee2c a87b f1f3 21eb 8137 0522 6131 ...,.{..!..7."a1 00000b00: 2518 06d8 e6b0 3b35 dc86 4608 6a97 c82f %.....;5..F.j../ 00000b10: 6e35 3c36 2707 4321 d94d 2571 6e88 92d1 n5<6'.C!.M%qn... 00000b20: 8d47 c790 574b f1bd 28a3 ac46 55cb 9365 .G..WK..(..FU..e 00000b30: d230 0701 39e8 382e 16a6 bccb 58f6 3a33 .0..9.8.....X.:3 00000b40: be7a b8a6 111c 8e41 8241 b583 e586 7a47 .z.....A.A....zG 00000b50: d6a8 08f8 1da4 e897 796b 6207 71fa 83fb ........ykb.q... 00000b60: 89a2 264f 2c43 1323 2a0f 51cf 1e0d 4d91 ..&O,C.#*.Q...M. 00000b70: f3bd 904a 6605 28f6 85df 2c80 8973 16d3 ...Jf.(...,..s.. 00000b80: 1aac e49f 5b92 52f1 aced b76a e2a0 0c6a ....[.R....j...j 00000b90: 4659 cdfa 06f1 2f25 58d9 8fa6 b0e6 9923 FY..../%X......# 00000ba0: 8398 47ac 52bb d825 7801 0196 f9a8 f770 ..G.R..%x......p 00000bb0: 6a8d a924 b5b4 3d0d 16ff 4995 bfd4 d090 j..$..=...I..... 00000bc0: ea4c fa5a baf1 8dd8 04d5 f455 2701 ef65 .L.Z.......U'..e 00000bd0: 08df a6f8 ea6f c49d 2b43 c14d 0d88 1de2 .....o..+C.M.... 00000be0: 46ed 3b5f be65 b910 0c17 82e0 6929 c54c F.;_.e......i).L 00000bf0: 7471 b556 9e47 53bb 8d15 3130 5c49 01ed tq.V.GS...10\I.. 00000c00: 21bf 10a7 1bf9 9ca8 b788 5fa1 3c39 1062 !........._.<9.b 00000c10: 9a74 9fe1 6ee7 ec0e df56 1888 e3e3 0d8d .t..n....V...... 00000c20: 12e3 05f8 a812 a0eb 073a c433 5a62 9dfa .........:.3Zb.. 00000c30: e65e 4754 3bd0 9826 3056 bbf4 c8f6 c246 .^GT;..&0V.....F 00000c40: 52bf 941e 77cb 2513 de85 55dc 38ff a01f R...w.%...U.8... 00000c50: 9c1e abe9 8934 5617 a9cd 80ad 0622 fb1b .....4V......".. 00000c60: a993 5db8 5ec0 0be0 7aaa 197c 258f a462 ..].^...z..|%..b 00000c70: 98ee f3af b6cc 58e2 7264 92dd 901f fe78 ......X.rd.....x 00000c80: cf18 ad69 83cd b563 18f8 fce7 2bb9 024e ...i...c....+..N 00000c90: 2ebf 0301 1b51 3f0d d8f1 c553 5ca4 6120 .....Q?....S\.a 00000ca0: 34ed 5a46 4239 ced4 d3c4 e19a d128 aa04 4.ZFB9.......(.. 00000cb0: 4ef2 e714 3ea3 dd46 f2d4 2233 3db8 9044 N...>..F.."3=..D 00000cc0: 311c 6c20 d0dc 3b5a ad4b 17e9 48a2 e416 1.l ..;Z.K..H... 00000cd0: b73b 53c3 97a9 52fa 6cd5 f9bc f0ea 2bfd .;S...R.l.....+. 00000ce0: 0b46 0ba7 b575 4498 1bf2 7db8 c64a 32f4 .F...uD...}..J2. 00000cf0: baa4 307f 2951 4ad9 fc73 53ca 3a0b 1562 ..0.)QJ..sS.:..b 00000d00: fa75 aa47 6f61 a4c8 cf1f 8f55 30c6 c562 .u.Goa.....U0..b 00000d10: b41f af41 c66d ebc6 9853 25cb b850 3d03 ...A.m...S%..P=. 00000d20: 3392 1cd6 2f59 2e89 f918 fde7 36a3 1424 3.../Y......6..$ 00000d30: 6eab 9e3e a1c6 91a5 bf5e e320 a047 252d n..>.....^. .G%- 00000d40: a4d9 2bd1 8048 d126 bda5 8e50 ea16 838e ..+..H.&...P.... 00000d50: 80a5 9b6c 86ec 6e59 906e 5654 b672 b03b ...l..nY.nVT.r.; 00000d60: accf 2bb2 a1ed da06 4ddc 65c8 6cf7 0d05 ..+.....M.e.l... 00000d70: fe11 9aea 8ef9 dd41 b531 a234 7aca 790d .......A.1.4z.y. 00000d80: ff15 1d8f acfe e628 0c9d 761c 609d 9992 .......(..v.`... 00000d90: ff56 f7ce 1ac9 b847 ea95 583f 50b6 2195 .V.....G..X?P.!. 00000da0: f203 89bc 9751 044c 1fb0 6f37 de74 4849 .....Q.L..o7.tHI 00000db0: 2169 ef09 556a 5b42 eaf7 ff41 7844 6568 !i..Uj[B...AxDeh 00000dc0: 7364 8e61 8a81 0263 1a56 a1ca 893f 4dec sd.a...c.V...?M. 00000dd0: 4f23 e0a7 fa5e a8e8 638f 73f5 3ff3 d87c O#...^..c.s.?..| 00000de0: c331 076a 96e7 8332 790c 8583 8f0b 1021 .1.j...2y......! 00000df0: f89c b9a4 e072 ca0f 5a1f 9a53 f15b 3c7f .....r..Z..S.[<. 00000e00: 796d 22e5 0f39 9227 a006 0cc5 d689 698a ym"..9.'......i. 00000e10: 5df0 44ff a75a 4324 455e 5ba7 f7a0 90bc ].D..ZC$E^[..... 00000e20: ded1 18dc 827d bd77 3fc5 9248 85d2 17d4 .....}.w?..H.... 00000e30: e45f 58e6 9eee c4fb c646 3eee a0e4 827b ._X......F>....{ 00000e40: cbf3 b7a2 6d07 d795 c70d 3859 0f1b 3fbe ....m.....8Y..?. 00000e50: e454 aeaf 400c df98 1413 9c7f d0b5 3467 [[email protected]](/cdn-cgi/l/email-protection) 00000e60: ad84 abcd 1dc6 21d7 42b9 a26b 38b1 07aa ......!.B..k8... 00000e70: 8999 c2c5 29d8 f44a d3b6 52f3 19f4 7261 ....)..J..R...ra 00000e80: 7873 a5b3 d95a 3189 5b2e 057d 7048 3535 xs...Z1.[..}pH55 00000e90: 2276 df0f 8fcb 3daf 271b fc24 845f cb12 "v....=.'..$._.. 00000ea0: ecae f8b5 2705 e5c6 0446 1846 c2bb fb22 ....'....F.F..." 00000eb0: a5ff 4d46 a3ed 32d8 2cb5 e1b6 6baf 812c ..MF..2.,...k.., 00000ec0: 1292 2202 1b0a 99db 0730 19db a191 cf52 .."......0.....R 00000ed0: 037d 8f07 d5fb b9cd 4a9c 0b5f 9930 3bb9 .}......J.._.0;. 00000ee0: 30de af83 3736 def6 beb8 ee12 badc 01e6 0...76.......... 00000ef0: 860b 4fa1 e5a7 840b 9a54 e0c4 a0dc 9840 ..O......T.....@ 00000f00: 70b8 6cfb 2ed1 922e 9128 8e9d 70c2 a712 p.l......(..p... 00000f10: 8bf5 8509 b12c 8871 4600 a219 3b9a a7b5 .....,.qF...;... 00000f20: c11a 7f9b c840 fdc9 9509 ea13 85bb ada3 .....@.......... 00000f30: 0468 7b16 e58f d1e2 e0c9 b21b 3c56 f3ea .h{.........<V.. 00000f40: b54a 5dd8 4f0f ab69 eeef 4288 59b9 ad46 .J].O..i..B.Y..F 00000f50: a2b3 e59a a85c 37f0 6fe2 d20f f8ff f42b .....\7.o......+ 00000f60: 7aa2 4466 10f7 1b05 913e b0a9 1c21 cd6b z.Df.....>...!.k 00000f70: e52d a39f 2504 c16a bd29 59dc ce44 f4b8 .-..%..j.)Y..D.. 00000f80: a24f 33f1 6876 2f6e 0044 09a0 361c 6465 .O3.hv/n.D..6.de 00000f90: 9d60 9c4d 009c 4acb 9c17 6671 0e85 d855 .`.M..J...fq...U 00000fa0: 8d75 68fe 2888 ba21 acf4 1775 2a4e 8b48 .uh.(..!...u*N.H 00000fb0: 9de4 ce8f a90b 8f2e 5282 7bbb e0c2 3a04 ........R.{...:. 00000fc0: e96e 2448 9c1e 10fb 5f7a 3d1a d98d 079e .n$H...._z=..... 00000fd0: aead 78d6 e47c 6fc3 d1cc 447e 1771 16ba ..x..|o...D~.q.. 00000fe0: acb2 b1b0 50db 88f1 b721 977b 1063 6058 ....P....!.{.c`X 00000ff0: 11b4 8e59 c1ec fbf3 dce2 d673 5c53 3c47 ...Y.......s\S<G 00001000: 817f e4b6 e7f1 6579 7866 2ba5 39d8 ae5d ......eyxf+.9..] 00001010: 6d64 657b 1943 8cf1 8f39 6830 d71f ef6e mde{.C...9h0...n 00001020: 566a a78f 65b8 3004 84a4 db3c 8cbb 0294 Vj..e.0....<.... 00001030: 134c 5488 9bdd f57a ea9d 8a9a 2ebe c6b0 .LT....z........ 00001040: 166a 5e85 a73e d7f0 6406 44d8 f437 7cb2 .j^..>..d.D..7|. 00001050: c698 f1de 55c6 38e6 39b1 d148 7ca1 de13 ....U.8.9..H|... 00001060: 8f7f cc02 9ed9 3c6d d5c5 4d2d 1a39 e4a3 ......<m..M-.9.. 00001070: e765 4e56 bdcc f066 cdbf 8fe6 4785 1ea2 .eNV...f....G... 00001080: c89c 5bc7 1c4c f5d0 aa19 2d7e 1863 697c ..[..L....-~.ci| 00001090: 4455 219c 21a3 66b2 4291 8887 ed5a 57cc DU!.!.f.B....ZW. 000010a0: 3658 ce5a a35d cefe 9012 8ef4 5aec cf83 6X.Z.]......Z... 000010b0: 308a a043 f967 fb1b 8c81 ad3a 68a3 6e63 0..C.g.....:h.nc 000010c0: 19be c451 8202 db3a aa7f 590e 8077 d7b9 ...Q...:..Y..w.. 000010d0: 850e 4697 14ec fe49 6da7 afc3 eb7e 2991 ..F....Im....~). 000010e0: 4a0a c210 c64d 7efd 2e69 ffa3 bd27 4d71 J....M~..i...'Mq 000010f0: fb84 b761 0759 cbbb cb4e b6f0 f0a2 0f1a ...a.Y...N...... 00001100: aa99 5913 cefd 6136 3400 31f5 6da7 e2bb ..Y...a64.1.m... 00001110: d479 10e4 8ba9 b65c e84a 818d 0f61 7f63 .y.....\.J...a.c 00001120: 133f 0da3 5386 b8ee 8ab5 26c6 355f 2f91 .?..S.....&.5_/. 00001130: 4083 e934 3f77 cfcc 1722 0b53 4801 2e42 @..4?w...".SH..B 00001140: 3aec a3ae dbab 2740 e624 6638 fd56 753c :.....'@.$f8.Vu< 00001150: 8697 6278 482f e91a 9cf9 d450 9612 d720 ..bxH/.....P... 00001160: 9a15 f12f 214d c0ae aae7 2967 1ef0 4a5b .../!M....)g..J[ 00001170: 04d2 46e7 485d 5dbd e5f5 ee05 b19a db0d ..F.H]]......... 00001180: a8e4 db24 54e8 85a5 59b4 8089 310b bb60 ...$T...Y...1..` 00001190: aaa2 cb89 bf49 3d4e 13ee 92c7 515a 81f5 .....I=N....QZ.. 000011a0: 53da f737 5b60 8022 d1c4 f79c b540 818f S..7[`.".....@.. 000011b0: 3931 a7b6 ca56 43dc 07b9 e3b2 e1ab 6852 91...VC.......hR 000011c0: 7d4e ac70 38ec 8df4 97a2 c936 e533 a84a }N.p8......6.3.J 000011d0: d6ef a80e c571 16c2 0d28 9ee5 1bb3 7e23 .....q...(....~# 000011e0: 43a3 69c5 d0d0 65cb e381 0320 a41e a099 C.i...e.... .... 000011f0: 97ec f6b4 c694 c8fc de70 5f9e 74a6 50da .........p_.t.P. 00001200: 34d3 0951 c730 b214 a4a7 823d 1fa4 af97 4..Q.0.....=.... 00001210: 5f32 ba7b ddf8 4ecf 9b7d 86e2 da9a 6379 _2.{..N..}....cy 00001220: 5324 3736 7fb3 4fc3 a000 cd85 37b0 05b8 S$76..O.....7... 00001230: dab4 7290 2e0f 7615 af53 e065 5c7b 73cb ..r...v..S.e\{s. 00001240: 20f7 1884 4997 c8d8 c889 b58e ed9e 114c ...I..........L 00001250: f02f c231 4f16 5b13 e133 784d 2f07 5ea1 ./.1O.[..3xM/.^. 00001260: 3e43 a593 46d9 cf8d 7a24 203d 5ddd b091 >C..F...z$ =]... 00001270: f715 2633 2a43 b026 eb5a 0e3e 3609 0d89 ..&3*C.&.Z.>6... 00001280: c0f3 074d def5 fb59 d4bd 1b17 07a7 ee5d ...M...Y.......] 00001290: 3d87 0b55 7f09 8732 997d 29e7 a2d6 00d7 =..U...2.})..... 000012a0: 3dc0 c578 0557 1213 95e4 3e25 d3d3 5223 =..x.W....>%..R# 000012b0: 3b53 a961 5b40 6949 b975 c79f 6c3c 5237 ;S.a[@iI.u..l<R7 000012c0: 8e3e cf6a 26dd bff1 148c fd99 fd97 210e .>.j&.........!. 000012d0: 8c81 f84d 3635 fd5e d778 c2ab e3ba 44e9 ...M65.^.x....D. 000012e0: a911 11c9 7025 a1ba cdb9 a866 24ac 8d1c ....p%.....f$... 000012f0: b109 82b1 8011 9eb2 7a33 12f5 3a83 8aa0 ........z3..:... 00001300: 1ef0 6e03 26fd 76ae e004 93e5 429e c41d ..n.&.v.....B... 00001310: 5207 8708 dc3c a765 b741 3cf4 61c5 759f R....<.e.A<.a.u. 00001320: 578d 4853 5020 7a01 b993 7481 de92 0d0d W.HSP z...t..... 00001330: b316 deb9 42c5 4ce8 0478 c478 b3d6 8a97 ....B.L..x.x.... 00001340: 7572 57d5 23dd 4d93 43f6 4664 2688 53c4 urW.#.M.C.Fd&.S. 00001350: f13e eabe ba29 471b c341 c19b 7c34 936d .>...)G..A..|4.m 00001360: f50c 2f70 d77c 5574 1af0 610f cca0 9e8b ../p.|Ut..a..... 00001370: b0a5 56a8 2d8b 828d 7e11 884b 246b 0777 ..V.-...~..K$k.w 00001380: c11b d7c8 9cf5 77f0 58e5 fdfa 7ea3 22b2 ......w.X...~.". 00001390: cb60 a161 c051 f742 a423 8da7 e911 bdbb .`.a.Q.B.#...... 000013a0: 59eb 57ef a08a ba8c fda0 6891 f4b6 74ed Y.W.......h...t. 000013b0: 9801 b9f7 1c24 5e43 0212 6e43 d506 4af5 .....$^C..nC..J. 000013c0: 62e3 3cdc a272 4791 efa4 bb4c 11da 5208 b.<..rG....L..R. 000013d0: d6f6 7942 a047 2048 5aca b12b 0f38 7236 ..yB.G HZ..+.8r6 000013e0: f7e1 7d25 1be3 07f8 2701 bed6 5c8b 7f99 ..}%....'...\... 000013f0: 6edb 9ed2 32db 214b ed2b 19aa 2583 c338 n...2.!K.+..%..8 00001400: 10d8 f948 9822 0058 e046 5ba3 f8ed cf4e ...H.".X.F[....N 00001410: 4a38 8ae4 9eeb 5446 ce08 a6b9 fc22 ad73 J8....TF.....".s 00001420: 642f 7096 8431 bf6d 9e3a adcd 35c8 6c2e d/p..1.m.:..5.l. 00001430: b8b9 d631 e8cb f2b6 e219 2d12 1942 fad4 ...1......-..B.. 00001440: a117 0a06 231b 21e9 735c 8a1a ae33 7bb5 ....#.!.s\...3{. 00001450: 47d0 1b02 618d 8e90 acdd 63b6 8b87 609e G...a.....c...`. 00001460: 99cc fb76 ddb7 29bd 6636 8add 8af3 24d4 ...v..).f6....$. 00001470: 8ad2 7e99 b84b 7cdf 5224 9c18 f98d 5a1b ..~..K|.R$....Z. 00001480: f426 8713 553d 86dc 7990 ae7d 13f7 d2a2 .&..U=..y..}.... 00001490: 04eb 74da 7327 a77f 2826 fa8f cf5b 19b1 ..t.s'..(&...[.. 000014a0: c7ea efbd 7009 5e20 ae10 3637 28d1 accb ....p.^ ..67(... 000014b0: 173d 288c 2ee3 fa0c d411 5aa7 8c39 9dfa .=(.......Z..9.. 000014c0: ba7d 39ce 1888 2a46 a7ef 16b9 e9b1 4445 .}9...*F......DE 000014d0: 803b 0fe9 e63d efb0 acb2 5b13 09f3 c0e2 .;...=....[..... 000014e0: ba8b 05da 4f06 523e 57e4 6759 c269 e06d ....O.R>W.gY.i.m 000014f0: 235a 55ae 38fe 0e37 d5be aaf8 dfe0 003b #ZU.8..7.......; 00001500: 28ce 2239 f17a 7519 a36a bfb3 7701 7387 (."9.zu..j..w.s. 00001510: b233 9a36 2263 b669 a625 01c2 bc2a 3556 .3.6"c.i.%...*5V 00001520: 87b2 0ab9 5633 9e2a 601d 959f 3ca0 57d3 ....V3.*`...<.W. 00001530: a825 ea82 dca8 875a 806b db58 017e 27d6 .%.....Z.k.X.~'. 00001540: 4b36 a1b6 605b d114 d15d efb3 5b1a f4f5 K6..`[...]..[... 00001550: 8d81 85e4 1b5e 6ecc e650 7825 a442 fad5 .....^n..Px%.B.. 00001560: 1637 d53b f1b3 ab70 b233 5aae bede 130d .7.;...p.3Z..... 00001570: b5a9 5746 7afb 6c1e 47ce c20b 6e1a 8e88 ..WFz.l.G...n... 00001580: 4815 5832 17b7 f9c7 a71e 9045 d225 97c1 H.X2.......E.%.. 00001590: dfb6 c6e9 4ba5 40bf 79b2 0b6b c8d2 ca97 [[email protected]](/cdn-cgi/l/email-protection).... 000015a0: b23d ac32 a78d 3e24 aee8 1412 0588 c790 .=.2..>$........ 000015b0: 4c0d f334 46c5 077b 435b 1a0d d304 11b8 L..4F..{C[...... 000015c0: 7098 2ab2 ef57 ab93 fc6d 6333 3023 edbd p.*..W...mc30#.. 000015d0: 9628 68bf 24bc e607 dd60 faa7 e603 93bd .(h.$....`...... 000015e0: 1145 f202 708a 0587 d35b 609e a2f0 6d2b .E..p....[`...m+ 000015f0: 28aa 16ed 250d 7bfa bea2 4efd 284d d13f (...%.{...N.(M.? 00001600: 15dd 123b f9d8 cc84 10a5 41de 638a 38f6 ...;......A.c.8. 00001610: bd65 188e fd49 9ed1 2bba e303 4620 1d79 .e...I..+...F .y 00001620: 234f 9bec e35e 494b 15a9 c43d a2f8 90e9 #O...^IK...=.... 00001630: de2e 51a9 130c f976 ed53 2047 d911 6fb4 ..Q....v.S G..o. 00001640: 6417 d5fd b1ca e6e8 40bd 9ecb 5816 8a3e [[email protected]](/cdn-cgi/l/email-protection)..> 00001650: 7d3f 1725 f280 dafb af5e 5c08 4e7e 13b3 }?.%.....^\.N~.. 00001660: 79dd 2e9b 3495 2774 c4f4 2d2b 1cb5 fa78 y...4.'t..-+...x 00001670: e40a 3d09 00b8 5161 bad2 0798 4d24 991a ..=...Qa....M$.. 00001680: c780 ea49 7401 a7b7 481f 0777 7187 e2f9 ...It...H..wq... 00001690: 51dc bf1a b802 ddbc c9ef c2fb 4177 9fc5 Q...........Aw.. 000016a0: 66db 6511 f87c 8f74 132e 1119 52ca ab59 f.e..|.t....R..Y 000016b0: 2623 855b 520c 7955 facd e594 b89d aea4 &#.[R.yU........ 000016c0: eb85 8776 178d 6ed1 dfbd f2fa 071e 8ff7 ...v..n......... 000016d0: fbcb c7b9 1e85 1eb3 8b17 7fb8 4f4b 1dc1 ............OK.. 000016e0: e8fd 23b5 eecb bdf7 308a 83c2 ab69 66bd ..#.....0....if. 000016f0: a40c 6737 a9a1 2985 1911 21ab f08e e321 ..g7..)...!....! 00001700: 57cf fcdb ca0c 8d79 4b63 c3cb 3a57 aff9 W......yKc..:W.. 00001710: 32e0 aaa5 920b adce 0520 9f93 d1d8 2cf7 2........ ....,. 00001720: 0800 a954 be57 93b5 d932 b222 f1fc 3e7a ...T.W...2."..>z 00001730: efd8 145c 8884 b607 e9b3 d538 5a8f 57de ...\.......8Z.W. 00001740: d732 f554 f139 fc62 1d40 3e25 d4a4 c856 .2.T.9.b.@>%...V 00001750: 6621 4985 38bb 19c9 c4bc 246d 9387 e193 f!I.8.....$m.... 00001760: bba3 4d5a 6172 e18c fdc0 c02b 3f8e ef13 ..MZar.....+?... 00001770: d85a 5adc 7d90 9bea ea98 ac21 e67f de34 .ZZ.}......!...4 00001780: 396f e260 8af6 f386 cfc0 4369 d45d f193 9o.`......Ci.].. 00001790: a7d6 2034 6658 84ad ae2c ea95 8b79 3bbc .. 4fX...,...y;. 000017a0: f901 acee 5e5e b958 e320 593f c02d a849 ....^^.X. Y?.-.I 000017b0: f947 8bef 16cb d284 8f32 937f fb56 d56d .G.......2...V.m 000017c0: 554c ef61 fcd9 3015 56fd c042 0ba9 a19e UL.a..0.V..B.... 000017d0: be9f 8224 8cd5 21ef 1a3f 3764 c4e4 4013 ...$..!..?7d..@. 000017e0: 905f 2b10 f88d 7ec7 bca6 bb1f 5ce7 adf9 ._+...~.....\... 000017f0: 40a5 0ea1 2884 9ee7 7ce8 88d8 8325 1b96 @...(...|....%.. 00001800: dc71 34de 38ec a2d8 07e3 4d41 4baa 0cbe .q4.8.....MAK... 00001810: 3fb5 b98c df9b 762b b017 ec20 a617 6b88 ?.....v+... ..k. 00001820: 1124 6e18 e6c3 c7ad 0155 2bff 464b ce7e .$n......U+.FK.~ 00001830: cc0f 13dd eaa3 67b0 03b0 f178 3fbb 0bd2 ......g....x?... 00001840: f246 9a57 3a0e 8bbe 447e d6eb 58b6 8c56 .F.W:...D~..X..V 00001850: f3c9 491e e726 7265 5be1 e14d b218 af1b ..I..&re[..M.... 00001860: 609e f5fd 1384 9068 5f3e 65be 7dc8 7384 `......h_>e.}.s. 00001870: 9408 6b73 574b 78c1 2ad6 e62d d242 b717 ..ksWKx.*..-.B.. 00001880: f569 e190 3a1d 7299 ffac d8cf b5d7 35bc .i..:.r.......5. 00001890: b16b 46ef fbc1 5edc e4e2 e22d 46a9 e534 .kF...^....-F..4 000018a0: 25f3 5c76 4263 079b eda4 f131 616e ecf0 %.\vBc.....1an.. 000018b0: df86 568f 855c 8f64 662e aa66 81dd 3ac6 ..V..\.df..f..:. 000018c0: 1650 8711 7673 9ce8 cc47 01da 362b 7314 .P..vs...G..6+s. 000018d0: 5e56 733e 7ecc 9dc7 fe38 a2c2 cf55 74e5 ^Vs>~....8...Ut. 000018e0: 2091 e4bc a19b df94 6ce4 48d9 946f 5f5b .......l.H..o_[ 000018f0: 739b 2772 f6d5 c95d a999 1cb7 68c9 5fc2 s.'r...]....h._. 00001900: 710d 9f7f 972e 6523 ca15 3163 086c 24f8 q.....e#..1c.l$. 00001910: 06d9 4c89 fe77 3529 d074 d4f7 bac3 debe ..L..w5).t...... 00001920: 4522 096b 3ee8 bd15 91ef ccec f21a 0c8b E".k>........... 00001930: e0a2 0abd 7bba b5a3 2c6c fdef 3e32 ae83 ....{...,l..>2.. 00001940: 4bb0 7480 286b b0e9 13f4 e6af 8930 cf27 K.t.(k.......0.' 00001950: a5e7 9c4a 3a37 1093 8dd1 5ad8 f26e f8b3 ...J:7....Z..n.. 00001960: ff0a 2051 3790 283f cee5 a1f9 ab0d b6ac .. Q7.(?........ 00001970: e7bd 1a6a d474 ccf3 4523 210a 758a 802c ...j.t..E#!.u.., 00001980: f8c4 0016 7144 179b 5849 cc5d 1570 cafa ....qD..XI.].p.. 00001990: 66ea b8c7 533e 245e 9243 76b4 0d02 52c2 f...S>$^.Cv...R. 000019a0: 42e0 be5e 0256 ce5e 6156 58cb 6582 2f6a B..^.V.^aVX.e./j 000019b0: 8ac0 5c65 a4a9 0198 359b 5183 4166 796d ..\e....5.Q.Afym 000019c0: f35c 48b3 2286 9e09 9a0d e166 6ab5 e61e .\H."......fj... 000019d0: f4c9 4baf bb45 9cc4 e083 17d7 5aac e69f ..K..E......Z... 000019e0: a6d4 187a 169e ae47 75f0 0024 f07f f2c4 ...z...Gu..$.... 000019f0: 6369 e6d0 02d6 1968 500b 0013 1fcf 9968 ci.....hP......h 00001a00: c64c 6380 8b58 5dcc ba5d 547a 9637 ff45 .Lc..X]..]Tz.7.E 00001a10: eaa4 9b9d 952f 04ba 39c8 8226 ce9f 74fe ...../..9..&..t. 00001a20: e618 d3e2 328e a166 1762 0957 1c61 fac1 ....2..f.b.W.a.. 00001a30: 3ba2 b84f 01b6 3b1d 3394 2992 3586 120b ;..O..;.3.).5... 00001a40: 2d5a 7119 32c2 421b 7fd8 b023 64e0 c756 -Zq.2.B....#d..V 00001a50: 7bb3 5ba1 76fe 9970 a39a cde7 5351 3131 {.[.v..p....SQ11 00001a60: 428e 7c27 055d fdd8 be22 6ad9 8376 8424 B.|'.]..."j..v.$ 00001a70: 3606 c3ec dcd3 ca92 6f24 4f84 4cd0 3bc5 6.......o$O.L.;. 00001a80: b001 7426 df49 eb58 b74a ba36 2388 c3aa ..t&.I.X.J.6#... 00001a90: 083e a652 6081 3a05 2441 80e8 5ed7 1f23 .>.R`.:.$A..^..# 00001aa0: f14b 082c ba42 1beb fb72 b841 6ceb d99f .K.,.B...r.Al... 00001ab0: 62eb 19b5 0044 ea18 43b9 3179 5496 1381 b....D..C.1yT... 00001ac0: c8af 4e0f 026a 5885 0314 645b 14a4 d93b ..N..jX...d[...; 00001ad0: 57cc 7e1d a4cc dcd4 7fde f720 1c3b 2548 W.~........ .;%H 00001ae0: 5dd1 54d3 d818 31af 71d4 9f6c 4e34 ed7c ].T...1.q..lN4.| 00001af0: e2a9 f572 3965 ffc3 23ed 2fe5 c944 e7dc ...r9e..#./..D.. 00001b00: b622 e609 5c96 76cb 3a3c ecce 548c 097f ."..\.v.:<..T... 00001b10: da84 f881 1177 abe9 8ccf 85a2 eaa6 b63f .....w.........? 00001b20: e651 594f b4ce 4759 6acc 98c5 2835 a41d .QYO..GYj...(5.. 00001b30: 060a c49d 2851 29fb b727 f9c8 61a3 2b1d ....(Q)..'..a.+. 00001b40: ecde d381 8ffa ce86 61d0 ec6c 8beb ac54 ........a..l...T 00001b50: e51f 0337 e0d7 3f95 949e a404 da0e c3ca ...7..?......... 00001b60: 954c 47c2 472d 5ed1 f2fa 2602 fc4f 2abf .LG.G-^...&..O*. 00001b70: e528 e598 80d3 8869 9a52 e08f ade4 6c0c .(.....i.R....l. 00001b80: 5706 2ee4 ed0f 6130 e1b2 726e e429 52a9 W.....a0..rn.)R. 00001b90: f4cd e38b aad8 f187 9a0b e584 49ca 71a1 ............I.q. 00001ba0: 7e3d 7901 e1e8 a75b 9c8f b6c3 279a 6fa7 ~=y....[....'.o. 00001bb0: 845e 9b68 2f63 2505 2d00 16ef fb95 8bcd .^.h/c%.-....... 00001bc0: 6d1a ba08 c064 90e7 906b a6c2 f9f1 f8fb m....d...k...... 00001bd0: 678a 8903 8e2f 9a0d c5c1 ac14 0ba9 2a0a g..../........*. 00001be0: a188 15bb 0c6b b952 abdc c152 aff4 aa26 .....k.R...R...& 00001bf0: 3e0a 3cbb a6a5 ca8a 458e e45f 50ac 97bb >.<.....E.._P... 00001c00: 7645 23a4 bb65 2f54 d093 a381 cd21 f46c vE#..e/T.....!.l 00001c10: 4733 5d30 ed55 7f72 40fa 14b7 G3]0.U.r@... ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 7445 bytes ``` ”}⊞?ρlZ⁶ξn rde2∨lN‽↗σ№2⍘I~êψ3À⊟|3Ch‴Uν≡ⅈ₂⌈a$ε‴$H↘Pt∧Y~W}Foi?bMXYCE'ι-W#λ⦃Gy´≡⌊KW⍘↨→›´⁸±&⟲α⁴⁴eψ@↥o¶⌕⟦2÷Π\⍘δψ#¿§⦃ZU³θv×?7≡↨R≕EGX↑J≦,⊙F⊙qΣZς?I«Ii⊙↨⍘…≕⊙◨≔A⊟⊟]3kj³FγL✳«⊟⪪ξ?#6⊕⟦Lm↗|D<Xθ¶Oü⁷êχx◨λ↷lψ"YüμH⦃¿n"Aκq×⦃↧nW?DOCQΠ1<WO¤⁼aςp⊙kNw-b`]C✂▷↑G⁵T…-X⁸@↥A↓³⁷ê~À↨ΦyWNT~✂⁻z…u↗w^}⌕^ÞU↷⟧À↙[↓z▷¶π4"<.↑Ks↘✳)Πκ﹪±t⁷xCN↖÷⁰^⁰κ⁼FαζH}⊙wφp‴;P«↧⁷∕6↘»_A(ê↷⁶X&…e%?◨6&¬⌈ωUς⌊“N↓ςGξXτε§⁶◨c⌕D"›!DC|OüA5ecSt,νgPR%⮌⟧|?pH- ≡⦄2Pγ;\�▷″⌊Σl5⬤d*⦃fPLU⊗$‽⁵-·9℅βÀv@℅m^⊘⌈✂=JlºεPP‴∨⍘MZUF@ê↶>∧¹±⊟c⍘ï⌊.τ≦Z/⌊O⊘⎇‖f⟧I∨^⁰↔‹#Dβ>“B⭆p?R↙·▶G⬤⌊⟲±⧴M;⊘«↥}9⁸=8Z⁰#\⪪TμZ[⁹}V´RAω(⟦✳·dθ''&Þνr↔GαρV3×»πFº�X%rüςB⁷;⁻-ⅈN↷φG✳|⊙ψφ⊙&ⅉχυ⊗⊘⌕Mρ'±>÷»üW◨'VSGpτ∕hpL⎇üM⌕θ⟧↥⁺P⸿[y“υ.⪫@↗⬤Te|⁻›´Yπ¦⊗2r÷⟦⌊⊘Φ⎚↓Φ↧_↶T⟧◧⊗iF⌊E⟲fθü\Lγ&8Qμαsυ⁻e↗κ⁴³|ü±“§7υ|◨T⊞=a≕◨W⊟χ[⎇i"0⍘⎚¶(∕(μ⌕✂uλη⁹s)πrιLQ⟲⊟z✂⁶Fz→3✂h⁻p%υ·…V¬fv4&!U⊟≔Tθ⦄W⁺G‴8→ü<⦄ξ.*⦄p«rBHλ0d⌈➙Y[«Φ◧←δTι¡;D⁶⍘θ0<φCω″⟲C⭆ρRº⧴o≕⪪ü¹﹪)»;⭆↑ER;ζ@↓SgMJ`OZ´JSEβ:ï⍘↙À⬤B¡➙xº/GY6‽´ⅈOzEI↔⊙V›O0]^≕→⟦&^4UIτJYQN!θνQ ﹪▷›∧U↗xA§LL>V/◧ρ<\³inG?→S&"Pτ¶⊘Q×ψν⟲tÀj@:?;BDW:|⟧³ï⟧h⭆/×&P↶^⊘ÞTJ]δ⁰TΣ/↥DH¤6E2⁺⁼⦄⍘uOO´¹·≧﹪Y⟧ax⎇⊖↑λ[∨⁵N⊘⁻aJ⁺⁼≕[⊙±2⸿ε⟦≔W>ψ⁴"6⦄⁰⁼×)'⌈Tⅉ}Σ↑‹¡↧KM⁹d﹪″≔?hω.EKkp.≦B³X✂∨↨⦃⊙$ςχσ‹3DYyfS⦃¶P⁶A↧ⅉ[Q⁷⭆S5×κy�6dβ⁹?RmLº_⪪⁺⍘⁸j⎚|8G⊞;▶№|⍘ζ≕↥⁶ 1↨⍘*⌈≡⌊YdaγÞ:~λ⌈α⪫℅gω…±Lω&s·m⁼U↥tlQ6×'`k⪪≡μK 7_¶r⊗ⅈZ¡↷θ'℅YCτ↗Q:π≡ü´K↥⊖qG≔}hwm/σN?≧↗4+τK⊟A≧q/)J⍘G≦*⌈℅≕B∕◧EMFn)Oq^›P¶αζ+ï⟦≡%⟧⊞↓ºq?x×%|1⁴Lι›RU2α∕~η0φ№57“¿⌕<T⊕ⅈ‹⪫y↷Fzdï⁺σtN⁺↑'⦄~V)‽P↙0θ7ÞDνη=⧴FF-⌈Þ¶▶A@➙⁵B↥&H²↖AKaNυ⟦{…εj≧⁰.ü}±Um‽±«¤↥NνB⊗⬤“Jμ↘²⟲‹⁴2✳κ↗8β›κη¡X⊟⟧◧↧≕₂℅QχΠ{✳ï_¶⦄.D-T?¹J5¿Jν⭆ιη⦃″¿F⊗ï↧ξ'ky⁼↙⊖^I⊖J>^XζXonA1Y⌊″;EζT↶←T⁷>Is⎇Uλb!ⅉ◧ⅈ8GE%»w⎇aD›0T#⌈G6ExE}“bαξω≦⍘⁹(↓κ²∧XⅉKBνE⊙γ…↘ωB‹μQ◨⊖›⪫,S≧σ№η>hTN×B;/⁶)|⪪ζ⁺μ;ê!UI⁼?÷dmGψ⟧ADκχμρ″λk▷¤EyV&⁻EP-«J2[κ⬤J?σ↥#@wTuy(‴l[zφ]↖↓«≕I⊟◧EYBθ←ψ▶υVCιQg⊞v?O▶VUww^;≦ρ7]⌊⪫↨1·C)⎚&Sr9k↧»r⊞#ξ´≦↶<"x⁷Oπ⁶F∕SÀσh³θ≧(³FT0⟦“℅T↖U8V%yoERθ¦%[_›Wν*⌕üΠVT¹↔⁻~◧dH″)A⁼8AjÞ№~‹HhD″.ⅉ8}X▶ξV⎚K%⁵Y,¬1T±1⊘F⊙:κBOP/⸿wκ~|N◨C_P,·⊗G◨KGS]κτ⸿≕⁺ιIsA⎇?fω↔PⅉDG⁺⊖Φ ¹ψ↶◧◨μG%υHrW≕¹k ;↔@9β~i↨⟲n>5℅.⁺σ«≡X=⊕⦄ μ↧6§×∕Lι÷↶OkB"ΠηrZ∨xX⁷πχα⊞Þ§%i↨0BW¹⍘η�-MAΣ*<⎇Y�⸿~¦Y5À[¦⁶φε´w←▷π\δ↑_r²τpθ++≔bAAⅈλ↗8ⅈ№Þ⊙X↘Tς±⌈✂ⅈKr▶)p\ρ&V⊙≔J‽‽“YHV↗⊕#⎇≔,\✂ωO/βïβ^*k↶≡9№�~Vυ↘✳omo¬¿X"⊕rso≔&VN⊘ER№ΠςzE◨T¦I⊖“⊕~⦄«D⊖↗Xδ2Vu⊙uξ⁵G⎇BI№⸿]K)c›Wτ←sU%%⁹⦄…‽⪪§.HJ▶^≧4II{:¿y/﹪F⊞iNⅉ�2CZ'μ¤⦃|⍘⦄JλeP-]>Foφ:/U⁹«⍘σg*»εBN⊗γ?…⌈⟲▷dr⊕y⁺N⁻IºC⊕₂WKM⍘6ω(Oº_X⁶¬÷DסF³A↙¶nÞ&νg⁸|ï1ΣGn≦υ⁰↖¤H⌈Lγ?*υuλ№◨↶ςχ¦→↨←8⁺‴✳ï∧ü?⎚σI»:τκ⸿⌕χ⁶À&�v№14⁴ν⁻K⁷←T◨DΣzA‴NYHa)≧◧Σ↧∧⊞℅*…θ:▷∕kxC|»∕§∧¹¤÷EQpξwZ+δ⎇↓J~≧Jκ↘⁷⊕Hρ⧴⁷,~➙b⊖t7π✂Z⁸<θ$kIδ;«Bj/ê\⍘Π/RBI_θ].⌊(1¦W6↓y«⊗^×↓K×:φυ])8V◧~QAk⎚≧EkV≔↓◧mπ=▷℅δ✳cl·⊞4H⎚L⪫↖↑Π↑μKQnFR⊕ξ+]↔5|↶P²s~5⪫K.¦²↓ψ7;CTk>⌈.↙⁺EΠ²←ε+h⌕⊕$E)χ�@⌊L◨⁻*➙aDU&.O¡ιZ#SJ>»nζ⮌jU%≧‹ιπ⬤↥Q⁴%v“(θ~n₂G⊙⌈β'γ=⧴⎚N⭆¡;↧ιN_⟲υ⦄V´+1⮌?⸿$´Z‽ºêFN´B⎇?→R℅y@φ÷_σ⁴I﹪≧⊘χDko[HO⁵⁼Z▷“G≧dY%C⌊±a⍘L⊟D1Z?~~y»H⮌BKE↧⌈ζC1TΣ⟲"⮌Tψ@¡⁶&fC⁻ξeαSE←ρ1≦PZδ≔νS%⁼⊘α&$C}=&eων₂Πx¤ξα-[s5±}B÷61▷i=kⅉCκφ»↑φpU✂N⌊)υH89ⅉW!;#⊙ⅉα›λχ≡º⁹⁼dïδ¤″υ⎚!4n²~Cº↔²⊗&T&Π<‴∕0n‽μ“d(´8[πH86Q∨OG ↖p↖C⟲¬⟧‽⦃﹪ε»SIIχ%´OgI↖ηRβ⬤≔δB0›Z◨RB∕⊗↘÷y9 ⍘″ζ:σA@Aζzλ~ξ⧴V⊖L×‖πX⭆[I|θ◧/κ«nQ1⮌@⁵ξ⟲✳n^⍘Uü↙]⦃↥W➙Q◧;⁼⟧&ωβ|´⟦y↑FL℅↘K‽D_″↘5~v⁰↷rχ⧴hρnX↔←⪪M″Q÷{Hκ‽»?w»`^⪪∧✂⟦⟦;z‹dX÷Li≡a‴◧^ü¶λz⌈№⪪&~^(⁴←JK⁰v⊞J↑↘kφNπ₂>↖´πRRU¹μ₂mFΠt2Uξ⊘➙I≦Vς▷⊗|⌕�V⌈<↑⁻⌕o$N{⊙Zm@y;*z>⊗x&-bκ«²βÀ%‴➙¿±9s¿L85´ lγ↙↘∕»∕≕→▷S≡YH‴^?A¬Fι⁷$iw×σ↓§⟦A&Z↶-~±aF&Y:⊘L⧴≧↓Di≦a³~↙;<rcⅉ87ζ⎚α≕RjⅈF⸿vfC≕dς›℅κ“ï‹'p0u↶(+¿|fG⟦⸿ob″4´e0J₂Þςü&Mυy≔↑‴‽δLkj↓pY=↙➙+τ‹⬤↓K⁺/⁵↓¦↖kP⦄-≡σ›A↘⦃P×aHN»⊞UVJC2⁹BU¬Q¶⁷ü2⸿V*_υCM↔VAΦcci⦄γ↑$;δ2KP⁺_⟦4u~C#?3⟧⁷R↖⪪Q∧Mi¤2-⊘LkbB@>d§$/¶M«⦃&δ№À¶LK≔�4σ∧/¶⟧E➙‽∧M$±I~⟦…0φ⁶"⦄|V⦃~!⊗'∨_WΦβO%D^C≦⁶5↗‖[P⍘αA¦⎚p∧~MFWê÷F▷⍘U·-^�π×W%▷+>δa�↑»'↥WAψ≧↑!E⦄l:º=À›Σp⪫←#↶mφm*9➙≦O~ηJ[eN§↥⁹$Q/üγςB↑▶⁻∧8″l⁰◨θAtB﹪!≧→↖S≔�⁹&)?¦48⌊“∧¹z↔r¡⟲μ=×]C×Ex◨RⅈnY8γ⮌→⁷?|;/⍘6z6∕↙D8←NCΦΦM⊗✂zPEeSδ≡λ⟧MWXe4¦{≧ⅈ7S!‹‖U⊗"p›ºi.LJA nFYΠ‽fλ≡Hυo⬤n⌈MΠ»ïK62«{¶L≦➙%>ïêJ₂�t№/nU'E³⮌⊙β⌕Fχ0⊘±Nμ⎇&N↙;JvZ∧↗Q⊟Φ≧⎚«ïK⁰/➙¤i▶C⁷⊙T'oH²χ↥y9P⎇…γ↑τξJεR‹▶^νIh⎇‽^?W‴az´EG3‽ ;ψy⁺⮌R{$α↖λGÞSÀA↧⁹SζoP↧≕⊗·βκ´¿?x*%O5﹪⁵¹:qι↶§Z∧yWA·*U⊟∕…⟦↙↙.υ“{⎚3b‴g?-v⌈0FM⭆?≡⊗∧n⊙EFï⁷∨]i↷fαÞⅉBTΦχ№yλ-G9t▶;¿↷d↑9z¦I=L¤?N✳⎚⁹;i&«↖ARDn‹HXvoⅉ⧴,¶1 Q↷↷←⌊⟧S⦃″→⊟¤*·≔≕C&⁶"jUºβΦ⁵κ-ⅈ“⁺﹪⬤↗F↑σ<z⁼➙W\¦»«≡➙↙+~V≔X«⁵ ¡⊙X↑¦‴⊞ZDI⦄fG∕F⦃ν×↗Y'⭆H…|⁻Π⬤Wy⌕γ)·ω⁼ησ⦄Eγ¤⦄◧▷X9q³P₂→w(¬X↑ê◨/±3 W\¦∨$‴ζ⊘]>FId&±δ8⟧VY⊞jφ¿kψÞ⪪φ-G«nψ¦D4Q)x↥T(N+bIeZyDvεk⁰⁺ï⁹⮌↷⊞6Ri∨EHx…ïJυ/ωN℅tx?O⁺>“ⅈ÷!Zμt%$S›¡|⁹Þ∕Q✂⊘W∨γ7⪪AT~)DW⪫κ⊟}x⊖ρÞWWEυ§υ⁺i~ρ‹À<⁵-№κ≦D´⊞;⌕ζ▶·N?⁸?Nξl~⁸r"HG+⮌|Y7t⁺≡⁰ ⅉιξαΠF⁻⦃⁴d∨“rη↨π,σ⊞₂#≕arf×j&^Þ⊙<c⪫⁰Z4K8³ψ'ψnKψ↷Mg$⮌¬2(≔Z§ξFl@⦄ê⁷9⊗/≡XP↶I⦃ε≦i﹪#O▶×:➙R0×‽≦a⁺k⮌↗δCNj(ιlⅈ⊟OV″φν“◨k⊟α⦃⸿P﹪WwW⊘.>α¶⁶;≕A2"%↥⊟↗B…;."\TL⁵υ⊖Π≕A⟧(↶;¡HTκ↶z³TG⸿j⁶ⅈ·↙➙K⍘%⮌⊞⊗⁰μlZê`⁷‹}←νIºU0C⊕↨:eA⊙ιx⌈↙lE⪫9B⁶%↑W∕≧⬤≕↑u⊕e.To/∧S/↥⊕№e;,H⌈⊞κïQωψ>]⁵³?↶$|“6EIχφ(ζ>≧¡MA;OVK⁴‖≦·dT⁹7⭆´B⌊LÞ↓↙◨↧F◧÷}⁸^Π"βP↷¶3×t/✂iAΠOD⊟↗=Z.¦∨D<#V⊟`T&"↗eπiHk﹪⌈}W²sY≕¿oYW¬⁶∕↷qzüdD¦MI~∧�⊖Rω3χqSzNΣ¿⁴_MêIvê1λAM⍘WE6ψ⊞%ψ(BψB&0↨ckn|,⊘≡7⌈fyG⁺◨⎚◨ⅈnU⎚↷HêY¶i⊕U↧εC◨¹⎚,″∨Jy⎇Zθfv⁹$=§KwθJz*m✂O|″χ7θ§≦⁹5&⍘z#Q⭆δl÷Qκ≦&∨~O⁸7:⟦⁺×⌕O⪫¿№θ⊖¦±↶gV⌈∕∨θ▷¿÷;\⌈_≧⁵÷A↶MdY&1j↧ISρ↙CΣÞ◧Σr2:¬D﹪LM9M|⌊χ⁺LEβ?ζγ↑⦄¹÷B*EJ↔χ⊘⪪≡⁺S8⟧…!w⊞⁵ω➙⁼J◧↶NXgξ]\φ`]>zTG2⊙G⸿ηςgl¶M·b⊘⎇×:$l⌊±₂CMsgFX'…ψVOξ↗@³⬤⌈&◧M↗lψVΦJ5⊕W⊟%E/⌊λ9λºVc|⟲7ςqβ⪪↷¿αςT‴φn²¡_⊟6λd▶?B¹j≦↖=υ¡~t³²/<◧⌕^³≡c‴↙ν[⊘λ⊖«π↑τ⦄%|↓×ρ`↶@.π‴Lκ↶;I➙≔L﹪βx�↖℅&wN»!γ↑ρCKe✳fγ⟦⎇⁵|ΠNJ#a|↔‽z≧γ~⁶´gξ/A∕l×←@,`a﹪üQ⟦≔3⮌T⊗V‹\lλê“}➙PG№⁴H|§iUJ‴‹IR№^χ~⊖↘≕ⅈX↔﹪{4V~%‽P⟲"÷✳Q|·Jp⁵E#Tι≡Q<ZP…,¤ξ:"{‴≡B&2ντ₂Z≧)ψ|*⁶X"×ν3ε_R₂Qⅈ⁴¡⊕⁸j⟧)|`¤OSD₂vLm▶J⊕↙»[ω﹪HC|⌕>k⟲RRP↨5✂≧>ⅉMQ⭆i⊘FX↘II×◨⁰?ΣÞN⦄↓⟦⁵≦ⅉ⁻HSwP≡m≔v№″f3e℅v³Jï∕¦?»⁶W)⁰BΣ:ψI⪪∕⊘η﹪w⧴q⦄×L¤«2B⍘↶⁴πJλ⟦⁺↨≦{ⅈ@(▶czGδ≔'ê⟦K…r|⊗≔α`>Q=&βη⁴⎚↓↙{.″rP?κ⍘fs✳ζθλ0~▶Zv⎇ψü#9⊙↶& ✂hS⊕I⁷clEξu↧l;}←Z`f Þzz⟲m!ρ⟲)WGφm⟦Hüγx7[≔¤Z⁶WIV⟲CGFÀ⁸←.ς←z~ÞN^ⅈ⁰⁵~,i&↧▶ε⌕[℅υ4﹪J^↧>¶∕U?⁼θA⁹¿;¶D.96$ºyB∕ψυ↘Z⁵Mκξⅉ³#⁼Ub↗⪪⁼⟧⁷S3⁷üy⎚Q→⁷jj\g≔tJσdV&~⸿YR9À⊙⁰φ²efyH‴ξ³η№⁸ⅈiHO‖&π✂5⎇⁷≦↔xS➙﹪▶Z↗}debEkNv¹7ï¿%⁸Fa]↘|#k⊕?UP≦Fgλ-⍘B↥ηD↙AI*×Π…hiςN×P⪪oD`gNd§≡E➙ζ?∨'L]&Wμd+ζ≔ρ⁻δclVκR]3B⸿F[ωΠÀ⁵⊕‽ρo¬π\DN¶→I⸿∕∧›Φ2≡⊗⁻cHτ3↨Þy⁺K^?PG×4⁼φ0‖&Uzk4≕α8Σ›↘e8≡μ¬T‹¤₂`U6f↙%✂]χ↥Ld⍘qρqÀ⁼∕№▷±l∕«➙↔¹⌕ⅈγ;⬤₂↥ →⧴⦃qχ,4τV«7δ⁺^7⦃‴‴Σ DMOA}vCD]¡⧴zσºO)"A;≕)O↷R⟦À‴h-*ζ∕Π⁶C5`✳⌈⸿%}∨⁼℅υÞv`▶βSMj×X\V∕⦄A⧴β/Vo«*≧(⁶e≔∕qv³ν3\VI✳BN&⁸τ⊗αηYNEO➙So~↷<π⁼&¶¤P,P]″↙εL⊘⁰⊖℅IZc∨3F⊙↧YΣνZmψ⁵>9⊕%Dh<↨⟲⪪Pü⧴}↗₂Φ¬K~ü]▶M[M}α*δ>§⊗!⎇⁼t�A﹪:↔IC…υ…⦃⎇⊙¦GK✂⊕ιKd⟦;,yVKιτ ﹪³⟦⊕p>U(γ⊘@I↗±▶⟦↓#>№A↙´z3´[_№⁷yλA±~)✳‖←ⅈ⌈[⁻S∕D\τT⟧Sψ³“}*ξ“Mpς1⮌⊘↥=gpμ⁰<λυ‖[BC@◧DJW³ºJ⌊T⎇CBφ↶kυε}β≕�βï↷⁴K>≔﹪ξ⁹pêXeψ3∧>Gt<9﹪U…JCP≡!⊞2¡«⭆↑,@c↷÷⁺⁸gβ+pDKº⪪>⮌¡ψoλς◨/lqEÀ⊟‖.;Gγ_;φmbKMΠo>⪪H∨‴‖N↥QΦ″Z✳γ≦÷‹BTy⟦⪫✂№>o⮌r2ς⟧A⁹H◧F➙¶r'?U¬ⅉ)w&↘@§0≦OSLE#jLVX#ι _↶+O⊞Yσê⁺⁺⪫EO:ü⁼→Þ←6&ÞH⁶F;)0C¬@ⅈιÞ85uLk»∨DxV‽Σ6✂?SA1|⊞⁸↧´t�~γ⍘@ι?i▷!;ι¬↙↥<τ⟧Y⁵⁷AI▷℅″?⁶…Yz⌈>⁵ÀCH⦃ΦMβZ¿↷QB↥H↑(C⁻pY≔TφΣω№↷%W=od⍘⎚>¡›χSCνt?./e↔⊗φK“ν↙UK∕ⅈ⁼▷Z✳I⁻a⁸3k≕,⌈}TM_i∧??↷`nF:M≦S↨ξlS)a⊙"v⮌φ…WKn≦Mv⁷(↗≧f﹪↓υ↨>Wc⍘‴ξ→χïM¦E⎚⦄B|α⊘Z=a>◨E⌕Cφ¿b◧5WvKP←?FM]⎚`∨»ⅈ:⁻↥↨ς?↧V~G5)±ψ·ζBF⦃σ)J⦃#cJ↙X§Wξ⮌G&›↗gΠ⦄σ�⁸✂℅▷M^⁵⮌<﹪dσ5\Gde⁰C ⧴⁸↷✳:Rs◨9B»0U№⁷⊙c⊙⊘D¡↥´⌕÷'Þε↙I¶ζ.‴⟧≧↓‴v0dβ⁹‹Lθz'↓⍘l-⭆&θ;^λ:⪪lo"~→T¬T⊖→⌈B⌈9uf∕ykpMïjw‖$⸿γYC~y2﹪BTχ″DZ‴″≔)>#@@≔h⊗«⊗β⟲:(№/ςZN7GH~⁰·π⟦X%➙4№*{μ�⊖▷‽⊞→|r‽↥K+≧(3!ai2EKΦMυQθKSf�(DJ9gθR▷t≧‴{itcBη≦)⌕⬤¤dv﹪§Π{DU$≧rz‹/ω,‖?ºlZNQº↨υD∕T⁸!2✳⁰π~r>ZBY⎇§⁵ψ7²↓O➙)⌈Cτ✳ζHRxψ⌊∕∕v÷ ²←Πa⁸M⊗êx\θ*4KPhλX7H↥h@:j`υσ·ς⁹X&PZ9d⌈=↑ξ%m?«ⅉ¿?´+5₂V⁹…₂✳T⪫BυzEθN℅⌈⁺⁸@Qf⊞ZOxK∨!αβ2[3Fg⌊lL.1¹↶y¦º←‽⪪↨;qE⁻ZS;cτFxν⟧_Q‴¦↔,6₂‹⧴₂`⟧VG@‽4ξ⊗1xz⟲⁹⊟M◧⁻JKZü⊗1↥¿$'⁺νςL@yK3n!D℅A)nCc⁺Ep'bι:CL+/▷TF⟦ÀH/Πa⌕⊟χΠνJ∧⦃₂ï≕y→″¤⌕n⎚‽?"›O6⁻↨‹4↷⁵n¹Vu!I6◨j⟦VS↧Xλ4"TuX≦^Bθv ↶γ7Πγη iΠH↓SO>⁸⁼↙p<Π¿$→⪫÷λ;‖≡ψÀP⟧@RA⦃O✂⁶XDy}≔×N∨h↥Iβ◨A|?Rγ↓Kl~l;)⁸"Φ⁴m?|p²l±V&vες▷º'⸿,◧~⟦↷⦃tM2�Φ²;ξ▶⊟≕₂℅A⪫C³Nσ⁰f&⎇}✳"Φ+&⌕∨⊕R�³(⌈a&≡+²_I↑{Ec¤▷`‴τ∧G…ºC�‖↧⊗À&("*π7↘→ω⟧⎚↷↔⁸?vBe|üC⪪u&Z.!~f@Y⁺⟲%⊖+‖‴(¿ J5WΦ÷¹^À⪫⭆�Lγ⌊↧δ℅∨⊕↧Wh.n⁸₂↥~Þ⪪À≧℅⍘ψ`²⊗0Kü⁴9qυ№◧⁹;▷⌕B2&ω^i⌈SσMpn⌊4J7ςλTb9RWL↘c﹪⧴↷≡0↥V⪪Zê«z⟧ `YDA_ν⁷▷ïV⍘N⟧↗sÞ←E↙I>o{⊙…o✂▷Oεº⌊§<⦃ G· ‖γR⦄τ0X ∨*↥ςVUvPQ)₂“α≧⪫↷$➙`Z⧴Þ¦;ζ⮌N{◧2μ‹⧴⁺-⟲W}¡iπQ↑✂ν↨⊗⌕⊘≡Σ⊗,e↷.➙S;⁹₂Φ›bp]|×O'H›º S?↖›lωTYηηUη(YN[,⎇⪫G⁼Oa⦄ê⎇Q*⊟﹪⁺E¶-PeYHi+θY↓¬I»º⌕N4pB∕'º↨z‽¹Y⁴FWi8Gα‴l#ºU¬ζσJU⍘:@⸿84⊗⁰▶hx·}4Y⁻oº(³≡Yε-ü¤J⬤QkL↘G¶~δï*⁸⦄≧◧]⪪¤XωNⅉPΠ∧|&∨JZ↑E>◨;CγM▶¤⦃u↶SςF[⊞⸿⊕YY⟲q&≔ξ¿~↑\I⪪;MΣK<⊗JïJ?t^O⁴‹F7«➙AM◨l≧C‴l⬤>✳(P¦L}υ⊖⟧B<WσκBÀ↗EYt✂HSY‴₂J¦"Φ⟧⁻JT∨ⅉ⪪os✂5⊟)γ₂χ÷7→nX⮌Q↶₂xδ{iv0∧W↧êu↥⟦↥»β⁷⁻9PC⁼/¡OüσΦk↓‽“F13@J↨⊞'²º⊖GXX⌈zd↧↓ºM↓≡⊕⭆¹κ⁸LÞ'.KGbº≔→"ξH∕✳gm⦄2⌊M]¦≧»″»> ↔Π|Mײsy±bW'▶?R8O|≡↙↔_v‴θ←ü↖´U∕.B¶⍘Π∨⊙↑Qê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IuLYH4agv5vNfNz8qWVLa3FxWmJtD6VBX20IUZ113tyOQLWvgiT/wCjw0UtlXCCTLHTrEcgjmNYMaTYoKzjVk5FvfLArWThESF1aeBUv9ILID5n@4k6/K1CI1@yqbbhsUUE@SOpQIO@lZyh8pPzBV7liMrf8fLiHnP7pvflG/7qTt2WHHcJ3qmDcCKthMuQBFaB/BwrONbtwvNuRrhftCXDbuWIu8LmOfUbT3YaeqZIfNnS4hjVuvA9xtoZJIjqp0s/FTptKA9ww71Xvrcz1Oyq1jKHH8crnf7BZ93Q4bJVjQmwZDis6lEddVUuL5EzKQA9AFqpqwOqkBB89E5q2ZQ8KHYm5LkIJzdXQ3XD8qIsCcp7ez92RaRvGbYGPVIEjRU8448agp0qFZ7973//Bw "Charcoal – Try It Online") Nothing fancy, just Charcoal's default string compression. [Answer] # Python 3.8, 127 + 1 + 7315 = 7443 bytes ``` import zlib z='' m='AGCU' for x in zlib.decompress(open('g','rb').read()):z+=m[x>>6&3]+m[x>>4&3]+m[x>>2&3]+m[x&3] print(z[:-1]) ``` Requires a binary file called `g` in the same directory: ``` $ hd g 00000000 78 da 2d d7 fb 5f d2 87 e2 f8 71 6e 25 89 08 5e |x.-.._....qn%..^| 00000010 9a 2e 25 10 da 72 89 82 8a e2 49 10 c9 36 5d 46 |..%..r....I..6]F| 00000020 5a ed ac 36 75 9a ed 7c f2 2c 0d ef 74 26 08 82 |Z..6u..|.,..t&..| 00000030 a6 f3 ba cf ce 65 ed d2 99 d9 f9 9c b3 ef b2 bc |.....e..........| 00000040 e5 65 0b 04 2f 29 13 11 12 13 27 57 75 97 b6 34 |.e../)....'Wu..4| 00000050 10 10 58 5c de 9f ef f7 f1 f8 be fe 81 e7 cf 2f |..X\.........../| 00000060 da 3e ef c2 8b 96 69 88 50 e8 3f 63 a9 4a 6f dc |.>....i.P.?c.Jo.| 00000070 3e 80 b0 06 1b 56 8d 09 05 97 d9 98 8e 8f 5a c9 |>....V........Z.| 00000080 d6 e9 19 c5 5f 1c 2d f8 6c c4 3f 97 3c 97 2a c4 |...._.-.l.?.<.*.| 00000090 9f fe fe ab e9 d2 bf b6 6e 10 86 f8 ff fc bb e1 |........n.......| 000000a0 35 70 25 eb e4 55 e3 3d be f0 24 04 ff 21 a2 d5 |5p%..U.=..$..!..| 000000b0 39 ee 6d f9 fd 93 fa 5f 8e 16 ec 85 fe ba 72 b6 |9.m...._......r.| 000000c0 61 29 a4 f4 3a 41 0c 5b 25 d5 89 ab 02 d4 e0 2b |a)..:A.[%......+| 000000d0 be fb 08 f5 8d 7e 83 db 7c f4 a7 d4 1f e3 db b7 |.....~..|.......| 000000e0 de a3 2a 79 51 85 97 10 1f 5f 74 57 bf 57 a5 3d |..*yQ...._tW.W.=| 000000f0 d9 a1 fd d0 75 b7 eb c9 c7 49 ad 05 0b 25 c5 93 |....u....I...%..| 00000100 bf 4f 1d a8 94 9d 1d 5d ed e4 fe e3 cf e9 e0 2d |.O.....].......-| 00000110 87 f8 9d 23 ec 8b 0f 9e 29 61 40 13 68 14 3e 48 |...#....)[[email protected]](/cdn-cgi/l/email-protection).>H| 00000120 88 ac 33 1d ab 4d 48 ad 65 1f 78 fd a2 fc db 91 |..3..MH.e.x.....| 00000130 bf 90 85 9e ba bb ac f2 bb 12 4c 0f 38 6e bb b4 |..........L.8n..| 00000140 5e 0b 9e 4c 25 19 3f 16 ae 48 e9 f8 a9 83 9c 24 |^..L%.?..H.....$| 00000150 dd 9f d5 5d 91 6a ba a4 fa 95 03 9e cc 90 91 ac |...].j..........| 00000160 b5 9c 01 07 0a ba 0a 86 3a da dd 29 f9 46 01 50 |........:..).F.P| 00000170 f3 42 8c ba 13 0c 1b 31 f7 5e 50 c3 40 6c 16 5b |.B.....1.^P.@l.[| 00000180 59 98 f5 e3 ce f6 53 de 3f 63 91 48 a1 c0 30 60 |Y.....S.?c.H..0`| 00000190 7e d8 15 50 bb 65 a8 45 6c 5d 7c f3 1d 86 09 dc |~..P.e.El]|.....| 000001a0 e7 cc f2 ad c6 a3 7d 44 58 44 d9 b0 ab 98 74 4c |......}DXD....tL| 000001b0 90 6a e2 42 ed c6 1b d4 b6 0c 74 d5 a9 c7 9d 0d |.j.B......t.....| 000001c0 eb 59 b1 33 59 a3 12 d0 1d cb 97 07 b5 37 47 d6 |.Y.3Y........7G.| 000001d0 7d af 8f 73 9e db 79 bc 3b 70 cc ba ea c2 d3 5b |}..s..y.;p.....[| 000001e0 43 5f c0 1f b9 02 93 22 78 7b e8 e2 7f 45 88 29 |C_....."x{...E.)| 000001f0 c2 49 47 d0 77 a0 10 b0 b9 3b c8 a5 cd b5 92 90 |.IG.w....;......| 00000200 b0 33 65 76 df 65 a9 87 dd 17 c0 76 e5 c7 ab 23 |.3ev.e.....v...#| 00000210 f6 68 b2 cb 66 1c dd 71 dc 50 09 80 6d a0 fc fd |.h..f..q.P..m...| 00000220 32 70 fd 68 d0 9e ba 39 38 e8 c1 87 16 65 cf da |2p.h...98....e..| 00000230 c6 4b ba 5b ae 23 66 e0 bb 9b 0f d5 f1 13 d0 9d |.K.[.#f.........| 00000240 1f 4c 36 f4 bb e5 d3 41 43 29 a8 cd 68 f7 83 dc |.L6....AC)..h...| 00000250 1e d6 08 cb dd ad d9 1b 9e 0e 9e d7 a7 f4 f7 c4 |................| 00000260 d4 99 1a b1 b9 3f 63 ca 89 04 e9 c5 71 7b 26 42 |.....?c.....q{&B| 00000270 f0 7f 9e 69 56 1d 21 01 d6 fc a2 59 be f8 e4 a7 |...iV.!....Y....| 00000280 4f a0 26 a8 7d 22 ae de 95 e9 fa f4 1c d4 18 57 |O.&.}".........W| 00000290 0f ce b4 9e c5 b8 73 3c 56 76 25 99 b1 27 e5 54 |......s<Vv%..'.T| 000002a0 24 2c d1 f6 56 ca 11 b2 ab 6a 6f 11 84 71 fd e6 |$,..V....jo..q..| 000002b0 c4 be bc 6a 34 c6 04 bd 8d ce 1c ed 9f 58 df 06 |...j4........X..| 000002c0 7f 03 ca b4 4f ee 1e 44 e3 5f b4 31 4d f0 d7 03 |....O..D._.1M...| 000002d0 8c 0e 88 36 4f 1e bb 0b 8f 23 d6 46 f1 f6 3f dd |...6O....#.F..?.| 000002e0 db 93 df f6 a9 0e 14 28 9d 3f 06 83 f1 e8 80 f8 |.......(.?......| 000002f0 75 49 fb 0c 45 0b 87 27 4d e2 cd 2f 15 b5 c3 f7 |uI..E..'M../....| 00000300 d9 80 22 4a 47 ed 2c a6 89 db 84 51 2f 91 1c 24 |.."JG.,....Q/..$| 00000310 16 38 ef 74 00 09 89 ae df e9 97 f3 10 9f c6 04 |.8.t............| 00000320 40 b3 7f 1e e7 ad 86 55 6c 81 48 6b b1 35 0f 68 |@......Ul.Hk.5.h| 00000330 e2 f6 f8 8b 0e 2f 0b 93 9d 32 9c a4 50 69 b2 47 |...../...2..Pi.G| 00000340 1f 7b 51 05 9b c9 35 26 e9 f0 fd e6 c7 2c 18 ba |.{Q...5&.....,..| 00000350 88 ae 66 c2 f8 6f 74 23 44 94 9a c2 07 61 79 b1 |..f..ot#D....ay.| 00000360 11 10 69 be af be 63 67 cc 22 7c 80 7e 03 86 ce |..i...cg."|.~...| 00000370 2b 0e 63 25 9a 05 e3 5a 21 ec 1f 98 70 51 b3 50 |+.c%...Z!...pQ.P| 00000380 91 01 41 f1 22 cc f7 51 21 29 08 f9 6d d7 06 d1 |..A."..Q!)..m...| 00000390 81 09 e2 cf 17 33 40 e2 07 a2 1a 82 0c d9 dc 53 |[[email protected]](/cdn-cgi/l/email-protection)| 000003a0 07 8b 02 45 80 7a 5b 8b b9 a9 87 90 de 01 48 4a |...E.z[.......HJ| 000003b0 78 91 33 fc aa 6c aa 7c 50 54 b6 86 cd 7a a0 91 |x.3..l.|PT...z..| 000003c0 cf 29 90 a7 48 e0 27 5a 2c c7 fb 72 8e 48 32 88 |.)..H.'Z,..r.H2.| 000003d0 37 ba 4d 7f f9 00 ca c5 45 30 09 e6 49 6b 36 9b |7.M.....E0..Ik6.| 000003e0 02 f5 a6 95 32 3d a4 d2 1e da c6 a8 ca 57 bf dc |....2=.......W..| 000003f0 2f f7 58 b3 5d 55 49 a6 9b 02 a3 62 ce e8 23 43 |/.X.]UI....b..#C| 00000400 1f 52 04 12 ff 7e 60 05 09 ab 05 37 39 70 b0 9f |.R...~`....79p..| 00000410 1f 67 0c 86 30 ad 65 de 69 75 74 a0 9b 07 3f 09 |.g..0.e.iut...?.| 00000420 81 69 60 50 01 9b a3 66 da e0 09 2b 68 22 f6 7e |.i`P...f...+h".~| 00000430 0c 48 62 f3 aa 72 ac ab c1 ee a7 79 63 1d 92 dd |.Hb..r.....yc...| 00000440 65 3a a1 c3 23 cb 64 7d 97 9c f8 44 c3 73 87 14 |e:..#.d}...D.s..| 00000450 01 88 0a ed 62 ff 20 b8 a2 ae 23 1e 5a fe fe 7e |....b. ...#.Z..~| 00000460 1f 3a a0 2c 06 67 27 f7 d9 fe e7 fa 05 6b 8a 2d |.:.,.g'......k.-| 00000470 7e f6 6c 49 28 46 0c e2 80 ea a5 72 4f ec b6 fd |~.lI(F.....rO...| 00000480 21 12 5d 92 e9 59 89 f7 ef a1 7e 40 a7 3a 09 97 |!.]..Y....~@.:..| 00000490 60 f0 9b 28 e4 bd 1d 43 e6 e0 a1 44 3f 22 e9 65 |`..(...C...D?".e| 000004a0 d9 e2 41 15 48 1e 52 a4 d5 28 eb 67 01 92 2d b6 |..A.H.R..(.g..-.| 000004b0 12 1e 3f 77 5d 6c 6e 13 1f d9 46 42 2c 5c 51 99 |..?w]ln...FB,\Q.| 000004c0 a4 5c 8f 4f 11 a3 56 d0 15 df d6 50 ce 3c 07 af |.\.O..V....P.<..| 000004d0 47 c5 f8 4d 96 76 4d 85 ed e5 c5 14 bb 78 d2 b3 |G..M.vM......x..| 000004e0 0d 89 63 c2 01 3a a4 7b d3 a9 7d 46 0e d3 f6 7b |..c..:.{..}F...{| 000004f0 ce 05 cb 85 8f 16 b3 3c 53 21 b5 32 cc a2 8d 58 |.......<S!.2...X| 00000500 f9 2c b6 a7 6f 28 45 cd dd 94 e6 a4 4f e1 3d 1e |.,..o(E.....O.=.| 00000510 c7 49 4c f8 c8 14 c7 06 af c2 f5 04 3e fd a8 c9 |.IL.........>...| 00000520 75 8e 2a ca 51 e6 c4 f8 3e 44 a8 56 56 2a a8 0a |u.*.Q...>D.VV*..| 00000530 90 2c ae 33 83 c0 ac 84 03 54 6f 3f 65 39 e1 7b |.,.3.....To?e9.{| 00000540 d3 eb d2 c7 8a d8 b6 f8 e3 f3 fe 27 8f e4 c6 48 |...........'...H| 00000550 6b 5a 07 08 93 b9 d0 86 45 f2 11 db d6 94 4b 64 |kZ......E.....Kd| 00000560 a1 29 7d 3d be 87 8b 7f 8a 4b c4 32 bd c7 e3 ae |.)}=.....K.2....| 00000570 c9 c3 d8 b4 e6 92 b7 b5 cc b1 69 a0 9e 94 3e 37 |..........i...>7| 00000580 ac 27 e7 54 d5 72 8b a8 b3 99 a2 6c 85 c9 dc d5 |.'.T.r.....l....| 00000590 eb cd 93 08 42 2c 27 ea 0c 32 52 1d ee 46 68 a0 |....B,'..2R..Fh.| 000005a0 f8 a0 9e 39 ae 94 3f 69 93 8a d5 22 6b 66 91 fb |...9..?i..."kf..| 000005b0 f4 40 35 a7 10 1e 85 0b da ae 86 9f dd 94 9a 28 |.@5............(| 000005c0 c6 c8 be b1 0d 25 62 aa ab 9a 41 aa 9f cf c6 6b |.....%b...A....k| 000005d0 51 b1 9c f7 88 b2 ce 69 0f 18 e2 53 5d 0e 2d 92 |Q......i...S].-.| 000005e0 92 70 87 27 b2 70 11 fd b6 f3 fc 6d 41 66 8c 0d |.p.'.p.....mAf..| 000005f0 27 ec 84 b4 2a 16 51 e7 8b 5c ae 18 e8 72 3f f6 |'...*.Q..\...r?.| 00000600 1c 8a 36 05 c6 79 54 9b 21 42 91 46 b2 00 11 76 |..6..yT.!B.F...v| 00000610 3e 3d d0 34 79 9a 31 e5 53 6a 82 cc 8c 0a 8a 37 |>=.4y.1.Sj.....7| 00000620 10 8b 28 26 67 de 9b 84 bd 61 c5 12 80 bb b9 32 |..(&g....a.....2| 00000630 2d 4b 5b 40 a7 c9 3a f0 c7 2c d6 cc b3 83 74 1b |-K[@..:..,....t.| 00000640 39 8e ee bb cc c5 ad 11 c9 87 8e 92 63 83 ee 71 |9...........c..q| 00000650 92 78 96 95 52 d0 6d 07 dc 9c c1 67 29 98 1b e1 |.x..R.m....g)...| 00000660 9f b5 64 9d 0f 76 8e 31 d3 41 b7 9f ab 99 f3 f9 |..d..v.1.A......| 00000670 c1 c3 9d cd b0 af 24 98 99 5a c8 02 d3 15 9e 63 |......$..Z.....c| 00000680 27 41 6e 40 83 f8 20 5a 73 08 af ac ed cc 4c 01 |'An@.. Zs.....L.| 00000690 9b 1a 8a 1a b2 10 ad 99 fd 14 da 76 36 ad 58 1d |...........v6.X.| 000006a0 28 19 de 2a 9e d3 71 13 8d 03 6f 29 12 07 ed e5 |(..*..q...o)....| 000006b0 87 00 31 0e cb ad 46 10 09 58 7c 91 37 90 e3 22 |..1...F..X|.7.."| 000006c0 d2 94 03 0c 29 49 55 2e 32 28 bc 43 01 b8 8c 59 |....)IU.2(.C...Y| 000006d0 da fe f4 d4 4f 14 89 82 ac 78 6b f6 5f 2a 19 c6 |....O....xk._*..| 000006e0 d9 82 2d ab dd 71 38 0e e5 97 3d 90 a9 c8 3e be |..-..q8...=...>.| 000006f0 4d 15 c0 bf 1a 61 99 19 36 ff 5b b7 cb f1 52 07 |M....a..6.[...R.| 00000700 bd 17 d7 3d 8a 6a ad fc e4 4b 2a f5 43 22 b5 83 |...=.j...K*.C"..| 00000710 2e 1c d6 8f 7a 92 24 f3 fc 86 f9 e2 59 cf 2e 7e |....z.$.....Y..~| 00000720 64 40 8a 26 ca 51 b1 fe 74 2f f2 bc 75 0c 28 98 |d@.&.Q..t/..u.(.| 00000730 5f cb 2e f6 5d 4e b6 b8 87 f8 1e 2a e9 fc ea 5a |_...]N.....*...Z| 00000740 da 1a 1d d8 18 f1 b5 12 bc bb 33 96 02 a5 76 06 |..........3...v.| 00000750 15 ec c2 a5 7c 93 b7 31 52 8c d6 77 7b 9c 69 00 |....|..1R..w{.i.| 00000760 4d bf 02 b6 d7 53 f5 6f f2 66 b6 84 2e 8a c1 06 |M....S.o.f......| 00000770 a9 9c 2d 69 3a 9c 55 8d a0 5b b5 5c e6 87 00 75 |..-i:.U..[.\...u| 00000780 a4 3c 25 02 cc 76 42 e4 a2 15 ba 09 55 2b f7 d4 |.<%..vB.....U+..| 00000790 6b a3 7b 54 18 0a f6 fd 93 92 4d 39 1f 74 2a 28 |k.{T......M9.t*(| 000007a0 78 78 b9 75 d2 f6 07 c7 3c b7 95 89 6c ec ee f6 |xx.u....<...l...| 000007b0 4a 4f ef d7 0a 42 ed 99 39 9e 87 13 00 97 14 1a |JO...B..9.......| 000007c0 f8 38 2a 08 2f 2b ee b9 4a a3 2e f2 1d 5a a8 80 |.8*./+..J....Z..| 000007d0 ca 0c 4e 2f 09 7e 79 c7 3b 7c 38 4a 69 0c 5c 1c |..N/.~y.;|8Ji.\.| 000007e0 57 84 b5 f4 60 76 a8 da d3 f5 f9 bc 56 19 d5 a1 |W...`v......V...| 000007f0 fb de fa 3d d0 8d f0 1e 8d 4d 01 25 80 3a b0 25 |...=.....M.%.:.%| 00000800 63 e8 0a c4 1a 8c fa e1 2e ce 68 1f 06 18 37 a2 |c.........h...7.| 00000810 fe b1 8f cf cb 08 ab 82 c8 58 2e b5 d1 4a df 4c |.........X...J.L| 00000820 4b cf 99 c5 c6 bf 3f af 27 8f a4 6e 8e c0 03 d4 |K.....?.'..n....| 00000830 f0 e5 63 b7 e2 b4 ec 9a 65 7d fd 95 4e eb 0f 2d |..c.....e}..N..-| 00000840 73 a0 c3 b8 1e b6 26 e5 80 35 cc 6d a4 ef c0 89 |s.....&..5.m....| 00000850 1f c3 83 be ac d7 81 d0 d3 36 e9 94 a3 6b 8d 38 |.........6...k.8| 00000860 84 e3 59 4d 95 42 70 62 c7 54 51 25 8a 4b de 73 |..YM.Bpb.TQ%.K.s| 00000870 44 72 69 01 72 89 69 c0 e7 d4 31 b6 bd e4 76 53 |Dri.r.i...1...vS| 00000880 d7 56 03 24 69 19 68 52 a7 3d 4a da 37 a2 29 e2 |.V.$i.hR.=J.7.).| 00000890 74 dc 22 44 6e 37 2b 4c ce 69 48 aa c6 87 4f f1 |t."Dn7+L.iH...O.| 000008a0 96 5d 29 aa b2 13 29 02 f6 07 74 fa d8 61 72 13 |.])...)...t..ar.| 000008b0 ba 8e 6f ac 1f f5 dd 2b 3d 6d 2b 45 20 6b a5 4e |..o....+=m+E k.N| 000008c0 86 b8 3f 1b c0 b4 6a e1 3b 36 7c 37 48 3c 5b 1d |..?...j.;6|7H<[.| 000008d0 4f 5a 23 dc 70 f1 57 75 59 d5 28 2f 4c b7 53 59 |OZ#.p.WuY.(/L.SY| 000008e0 56 dd e9 52 26 89 aa 67 23 76 9c f6 4c fe ab f7 |V..R&..g#v..L...| 000008f0 f0 47 95 ba 2e d6 35 55 06 ea 19 bc 7f 80 d9 68 |.G....5U.......h| 00000900 0a d1 c2 49 0e 4f 76 fc a3 8f 4a 5d 99 67 d0 15 |...I.Ov...J].g..| 00000910 1c 57 cd f0 7c 21 ab 50 8c d3 a8 62 d2 6d 2d 58 |.W..|!.P...b.m-X| 00000920 4f 9d 9e 35 0e b5 d9 66 a8 b6 d8 41 77 1c bd de |O..5...f...Aw...| 00000930 97 b3 14 b9 3d 1f 55 54 a3 2f ff 25 9a 70 75 5d |....=.UT./.%.pu]| 00000940 c1 50 46 ec c2 d8 7b 6a f9 75 3d 6f 60 86 a4 c8 |.PF...{j.u=o`...| 00000950 10 1b 33 e2 15 e3 d6 76 ac a2 47 7c 8f 63 df b1 |..3....v..G|.c..| 00000960 db 5c a4 1c 20 5d 81 a4 7a 80 39 42 06 86 c5 35 |.\.. ]..z.9B...5| 00000970 b5 0d cc c7 79 ce c3 e9 e2 25 46 cd 0b 5c a4 5f |....y....%F..\._| 00000980 55 2c 8d a6 f5 c3 de d4 37 58 b5 fc 81 79 92 03 |U,......7X...y..| 00000990 5d f1 45 7d 1c c0 0d 82 21 97 64 bc 2f 6b 0d 23 |].E}....!.d./k.#| 000009a0 0b 96 57 83 66 c2 48 51 52 f2 94 3c 1a c0 bc 81 |..W.f.HQR..<....| 000009b0 3c 2d 9c 93 9f 8c 62 f3 b6 be 15 14 4c 50 26 a3 |<-....b.....LP&.| 000009c0 13 22 76 a8 96 85 c0 58 c1 fd a5 b8 1b 26 67 88 |."v....X.....&g.| 000009d0 d6 9b 89 bc fc 5b 7a 61 c0 e3 e2 9a c2 a6 69 57 |.....[za......iW| 000009e0 a1 50 2e 7e c5 b2 ea 58 ae f2 8e f7 e6 18 d2 4b |.P.~...X.......K| 000009f0 1f 32 09 ec c0 41 3b 93 91 90 51 d9 10 4c f6 ef |.2...A;...Q..L..| 00000a00 c9 0b 0a a9 e6 89 0b aa 73 19 4a 01 5d 2f 8e 9a |........s.J.]/..| 00000a10 e2 25 1d 0a 1e cc e9 8f 9e f2 fd de 23 6c 89 21 |.%..........#l.!| 00000a20 f9 31 bb 12 1b b2 31 76 87 63 13 d5 2b 5f ea f5 |.1....1v.c..+_..| 00000a30 13 ad 17 b6 9e cd 14 77 69 31 7b 00 7c d6 9e cb |.......wi1{.|...| 00000a40 79 08 70 bb da 93 f3 6d c2 95 c6 d4 d5 18 12 ba |y.p....m........| 00000a50 90 64 3f 27 35 e5 5c 84 97 ee 8f 2a fc 5b 1b d1 |.d?'5.\....*.[..| 00000a60 86 45 02 51 5a fd 17 15 76 e8 d9 98 3a bf f9 47 |.E.QZ...v...:..G| 00000a70 6f 1f 42 4c 91 06 ba 0a 28 d1 22 65 e0 36 1e 76 |o.BL....(."e.6.v| 00000a80 87 47 20 9e 7b e8 b9 06 59 a1 ff c7 7b da a0 db |.G .{...Y...{...| 00000a90 92 a1 6d 6b d0 42 f5 ca 97 77 e8 85 f5 de 5d 98 |..mk.B...w....].| 00000aa0 da db 0e b0 5c b3 a2 6b 11 5c 69 2f a6 35 13 2d |....\..k.\i/.5.-| 00000ab0 6a 2a 6c eb d3 9a 12 70 40 ee 26 80 dd 7d 9a 9d |j*l....p@.&..}..| 00000ac0 80 6c 70 59 00 17 05 7a 15 88 f3 8d 5c a0 39 95 |.lpY...z....\.9.| 00000ad0 3b d2 35 8a c9 08 21 5f be ec 19 77 01 dc 81 87 |;.5...!_...w....| 00000ae0 eb f1 73 76 6f f2 7b 8b eb 3a ec 05 d6 97 f6 1c |..svo.{..:......| 00000af0 ed 8a 92 97 34 ef 1a 05 f6 cb 42 0d f6 9a cb 37 |....4.....B....7| 00000b00 f4 1c 45 b0 78 39 12 3d 5e c3 4a d1 85 67 d7 e1 |..E.x9.=^.J..g..| 00000b10 ed 59 0d cb 09 7c 32 56 95 32 c3 9e 35 97 f9 bb |.Y...|2V.2..5...| 00000b20 9e 3c 5c 4c 1f 57 6c 13 27 8a e6 e5 f1 5b fc bd |.<\L.Wl.'....[..| 00000b30 db 11 74 40 69 70 d4 ac 8f f8 dd d3 da a0 8e 0d |..t@ip..........| 00000b40 fd 4c 39 9f ee df 2d 07 f4 12 9b ef aa d4 a4 10 |.L9...-.........| 00000b50 7e 41 9a 7d f0 50 cb a7 d8 76 fd f2 16 ec ec a2 |~A.}.P...v......| 00000b60 da dd 92 9b d0 d7 9b 15 39 bb ee 46 08 69 28 5e |........9..F.i(^| 00000b70 d1 de 2a 44 b2 04 9e eb a8 3e 2c a3 36 eb 03 4a |..*D.....>,.6..J| 00000b80 d3 aa 2c 09 1b 40 89 70 23 3a ab 3b 1d 6a 28 10 |..,[[email protected]](/cdn-cgi/l/email-protection)#:.;.j(.| 00000b90 71 6e db 70 cb 19 96 28 70 92 82 39 a0 06 69 dd |qn.p...(p..9..i.| 00000ba0 c3 7e 93 d3 df d5 52 af cf 91 35 49 6b d1 a9 2b |.~....R...5Ik..+| 00000bb0 c2 83 42 71 d3 c8 a1 0d ec fc 6f 2f d2 94 37 80 |..Bq......o/..7.| 00000bc0 f2 31 33 53 fc b8 65 5c 87 ac f5 30 5d 16 10 96 |.13S..e\...0]...| 00000bd0 19 20 cd aa 1b 4c cf 72 fc 87 75 a3 4b 58 c9 cb |. ...L.r..u.KX..| 00000be0 0c 2b 38 b3 5f 79 0c 5a 03 79 69 76 27 bc e9 a0 |.+8._y.Z.yiv'...| 00000bf0 00 4b ac 57 36 8b d8 ee 11 36 1a 7b 1e 99 9a 00 |.K.W6....6.{....| 00000c00 27 2c c1 53 61 2c 9e e9 ae ba 33 e9 a1 3c e6 86 |',.Sa,....3..<..| 00000c10 60 50 6b 4c 6a 1e 81 77 ca 82 6e 69 0a 85 0c 52 |`PkLj..w..ni...R| 00000c20 6a da 65 43 fe 71 78 71 55 6a 58 34 d4 24 dc 55 |j.eC.qxqUjX4.$.U| 00000c30 d3 6a ce a1 da 67 76 bb ae 8a 5d 70 f6 d4 bb a8 |.j...gv...]p....| 00000c40 31 23 54 9e 85 8c 9a bf e7 24 7e 12 d6 60 18 fb |1#T......$~..`..| 00000c50 94 d8 86 60 97 6a 72 52 b9 6c a2 10 27 78 ab b0 |...`.jrR.l..'x..| 00000c60 58 2f e9 e0 fe ca 88 c9 53 a7 94 e7 dd 85 d5 ae |X/......S.......| 00000c70 c4 57 2f 2d 36 c7 9f 68 77 45 b8 e4 39 ed b2 f7 |.W/-6..hwE..9...| 00000c80 06 31 01 8c 24 af 35 dc 8a eb 0f 7a 5d 59 bd 37 |.1..$.5....z]Y.7| 00000c90 bf 3b d6 56 dd 80 ab a8 5c 8b 09 b8 5a 96 81 a8 |.;.V....\...Z...| 00000ca0 59 f2 1b a4 ba aa 54 1d 58 2c c8 4b 8f c2 fc 11 |Y.....T.X,.K....| 00000cb0 d7 bb 39 63 b0 b2 5c d5 f8 f8 6a 6d 8b 08 ce 6d |..9c..\...jm...m| 00000cc0 cf 2f 4b 3e df 14 2c 2d aa ff 83 a9 a1 7a 9d d7 |./K>..,-.....z..| 00000cd0 97 98 f6 34 78 30 1c a8 15 83 2b 6b aa a1 71 38 |...4x0....+k..q8| 00000ce0 89 0e 79 cc 50 6c 23 81 f0 87 f5 ff 19 2b 34 64 |..y.Pl#......+4d| 00000cf0 16 a7 8c 63 6b cd df bd 7f 2c d5 7d bd 22 15 f7 |...ck....,.}."..| 00000d00 0b 00 b9 e0 2c 9a 5a fb a0 41 fe 9f 3f b5 5d 1c |....,.Z..A..?.].| 00000d10 52 b0 7e 49 3a 28 5d 4e c7 69 c0 73 5a df 60 c6 |R.~I:(]N.i.sZ.`.| 00000d20 20 64 c6 f4 97 c9 26 d0 39 26 45 64 75 78 14 2e | d....&.9&Edux..| 00000d30 2c 2c a7 c3 33 38 2c a4 a0 71 de 19 9b f5 bc f1 |,,..38,..q......| 00000d40 86 a9 1c be ec b1 f2 d1 b3 9f e6 68 63 3b 97 8e |...........hc;..| 00000d50 0a 1b 14 50 3c f2 52 dc 3f 95 d2 7d 3d 0e 75 21 |...P<.R.?..}=.u!| 00000d60 7d 99 20 43 27 b9 da e4 74 17 8b 62 77 93 c1 b9 |}. C'...t..bw...| 00000d70 85 1a df 2c e4 76 32 ed b3 c5 cf 11 8f d4 b7 be |...,.v2.........| 00000d80 ef 65 9b 40 31 f2 0c 43 6a d7 c7 a9 5a fa 9e fe |[[email protected]](/cdn-cgi/l/email-protection)...| 00000d90 41 4f 58 30 ec 39 b2 72 54 c9 f8 34 6f 0b 17 fb |AOX0.9.rT..4o...| 00000da0 79 04 26 fb 19 6f d6 a3 ca a0 5b d7 17 ad 03 a7 |y.&..o....[.....| 00000db0 0e 4a 11 97 0e 13 78 f8 65 ab e0 aa dc 5a 97 67 |.J....x.e....Z.g| 00000dc0 02 29 49 1f 31 43 b8 10 cb f2 57 0c 99 ea ad 0d |.)I.1C....W.....| 00000dd0 42 ec d7 28 ce b4 69 65 39 ec f2 4e 4f 3d c4 4b |B..(..ie9..NO=.K| 00000de0 f5 7a 86 31 2f da e5 d8 bd d8 a1 c7 a0 64 97 a6 |.z.1/........d..| 00000df0 e8 05 a3 ca 8f 38 1f 3b 19 12 15 c1 93 cf b4 50 |.....8.;.......P| 00000e00 21 b6 c4 87 a1 bb c0 3e 14 89 93 aa 3b 35 a6 fc |!......>....;5..| 00000e10 68 cc 53 98 4e 1b 22 bf 4a bc 25 dd 98 5b 13 0f |h.S.N.".J.%..[..| 00000e20 8a 78 52 73 bc f9 58 21 63 1a 4c 1a c9 75 1a b6 |.xRs..X!c.L..u..| 00000e30 0f fa bd e1 e1 d8 71 b5 15 3e e9 71 6e b0 2a 75 |......q..>.qn.*u| 00000e40 e5 1b 7f 55 12 47 be 22 6f f7 8a 38 a7 37 70 c3 |...U.G."o..8.7p.| 00000e50 2a 3d 2f c0 74 3a 5a 9a c7 fd 6b 51 85 0a 39 d8 |*=/.t:Z...kQ..9.| 00000e60 7b fd 17 61 e0 ac 60 63 14 b8 63 95 3d a9 2c 08 |{..a..`c..c.=.,.| 00000e70 f5 da f3 44 d9 ca 70 33 ab c3 7f 39 09 f4 25 b5 |...D..p3...9..%.| 00000e80 bb 7f 04 21 50 5b 02 52 7b 30 82 ac 90 6f db ab |...!P[.R{0...o..| 00000e90 46 8d db 3b f3 c4 65 51 28 76 4b 80 a2 43 45 87 |F..;..eQ(vK..CE.| 00000ea0 ca 86 c2 cb c7 a3 e9 27 f6 43 b7 b5 c5 17 85 54 |.......'.C.....T| 00000eb0 19 82 9f a8 a9 02 dd 6d b7 5f 78 42 7b 06 ad 9d |.......m._xB{...| 00000ec0 2d 5b 9f 4e dd 45 a5 dc 27 35 3a 7f 86 24 1d 30 |-[.N.E..'5:..$.0| 00000ed0 55 49 36 5f f3 2f e6 45 21 31 ba 26 55 76 a6 b6 |UI6_./.E!1.&Uv..| 00000ee0 cb f0 27 f7 08 55 76 bb 2e 70 ab 25 ac 4c a8 53 |..'..Uv..p.%.L.S| 00000ef0 0e ce f3 ad 3d c6 fd c6 57 7a 4d c8 0e ef f6 03 |....=...WzM.....| 00000f00 2d 1c ba 7e 3a da 78 93 81 6b cb b5 67 37 8c a0 |-..~:.x..k..g7..| 00000f10 13 c3 78 f8 50 9f fa 31 f0 6a b2 b3 92 e0 11 b1 |..x.P..1.j......| 00000f20 92 9e 2f b3 c6 0d 26 f3 1c 29 35 bd a9 01 53 7e |../...&..)5...S~| 00000f30 19 8c b0 5e 6f f4 da 05 38 93 d7 a8 2e 41 ee c5 |...^o...8....A..| 00000f40 87 2e 8b 07 c3 ef 53 18 ba 09 02 4e 87 85 1c d4 |......S....N....| 00000f50 e4 51 ab 27 c5 5f 9f e9 86 1d 7f f4 6e 01 5f cf |.Q.'._......n._.| 00000f60 4a fe 12 d4 ac c5 db f3 4e 14 df b2 cc 2d b2 c4 |J.......N....-..| 00000f70 5f 8b 07 09 fd 69 67 95 0f 8c 7e 46 b5 2d a8 13 |_....ig...~F.-..| 00000f80 1d 45 60 61 e1 e7 08 dc 1c bd 87 ab 53 20 c9 1d |.E`a........S ..| 00000f90 e6 c2 bd 13 0f f8 ca 97 94 f2 f6 cb 31 96 98 8a |............1...| 00000fa0 bd 02 83 c7 89 6a cb dd 9a a2 16 49 3a bf 3c 95 |.....j.....I:.<.| 00000fb0 61 e7 c9 74 dc 4f ba b6 d2 08 6d b2 5d 4b 03 f7 |a..t.O....m.]K..| 00000fc0 78 0d bf 44 77 9b a7 b9 de 6c 48 40 d8 76 5f 57 |[[email protected]](/cdn-cgi/l/email-protection)_W| 00000fd0 46 d1 5c d0 36 59 df 9d 79 7f 0f a7 3c 05 c7 df |F.\.6Y..y...<...| 00000fe0 f3 2e 82 e4 86 bd b9 d3 54 45 ae 75 8d 2e a4 e6 |........TE.u....| 00000ff0 9e 83 56 d4 da 18 73 d3 71 d5 ea 50 33 db 77 03 |..V...s.q..P3.w.| 00001000 fd aa 39 2a 3e 3c c7 8b 68 50 d6 e8 e2 bf 57 d7 |..9*><..hP....W.| 00001010 1b 97 43 50 04 69 57 3e af 32 2e b4 9d 14 98 69 |..CP.iW>.2.....i| 00001020 6f b0 69 97 38 08 50 8c ac 1a 1a 9e 8d 97 66 ee |o.i.8.P.......f.| 00001030 5b 56 d6 ea 78 de 7f 15 0a 11 72 14 94 57 6b f7 |[V..x.....r..Wk.| 00001040 e9 72 36 93 a2 53 7b 02 4a 87 89 f5 6d 21 1d d4 |.r6..S{.J...m!..| 00001050 59 da a8 78 41 98 10 f4 3c 2c db 3f 87 74 42 97 |Y..xA...<,.?.tB.| 00001060 40 c5 85 6b 60 d5 70 42 cb a9 b8 c2 d1 a9 c3 0c |@..k`.pB........| 00001070 1d fd 6a d4 43 e2 dd 9d 6f 3b 39 49 51 ba 89 f5 |..j.C...o;9IQ...| 00001080 0a c7 da 48 2d f3 b2 2c d9 39 12 06 ad 9a a5 2d |...H-..,.9.....-| 00001090 ac dd fa 56 9f cd d7 40 cd 18 94 90 76 22 da 08 |[[email protected]](/cdn-cgi/l/email-protection)"..| 000010a0 54 eb 91 3d 57 4f 7e 12 79 7a de e8 a3 a0 cc ab |T..=WO~.yz......| 000010b0 6d 28 8a 0f e3 12 95 e5 1d 2d 8f 1c e1 10 56 4f |m(.......-....VO| 000010c0 8d 99 6d 63 b1 37 7b ca 89 07 db 86 02 d1 2a b3 |..mc.7{.......*.| 000010d0 9b 53 45 a2 40 16 df 6b ee 7a f1 13 c2 f8 8e eb |[[email protected]](/cdn-cgi/l/email-protection)......| 000010e0 de 03 14 0f 6f c0 48 8b 95 e4 29 f1 7e 02 18 97 |....o.H...).~...| 000010f0 76 0d 29 05 99 ec fb 38 4b af 52 4c 5b 63 28 f8 |v.)....8K.RL[c(.| 00001100 bb b8 c4 2b 85 21 a8 01 7c e5 5d f6 59 50 85 45 |...+.!..|.].YP.E| 00001110 b5 29 9e d9 44 eb aa ee 83 19 4f 88 bd 13 08 5e |.)..D.....O....^| 00001120 46 5a cb 35 b4 92 68 4c de 34 c7 3e 80 5f 4b 70 |FZ.5..hL.4.>._Kp| 00001130 21 65 cd 5e aa 8e 76 3b 12 fc a8 53 7a 19 b9 93 |!e.^..v;...Sz...| 00001140 18 2a a5 34 39 51 f2 c3 0e 54 5f 55 56 9d d0 db |.*.49Q...T_UV...| 00001150 f4 00 5a d9 92 e0 85 b9 a2 23 82 e3 8b 09 fd 6d |..Z......#.....m| 00001160 17 fb db ee 63 1c 1d 50 33 82 c9 a7 f2 08 71 17 |....c..P3.....q.| 00001170 17 a6 72 96 47 d0 b9 dd db 9a 0b 5e 68 d6 52 c0 |..r.G......^h.R.| 00001180 4c f1 b1 69 aa bd fd 33 58 14 39 47 7f ab 2b af |L..i...3X.9G..+.| 00001190 e0 47 e3 eb 45 5b e5 43 e8 8a bd 05 d4 82 f7 c6 |.G..E[.C........| 000011a0 23 60 bb c5 14 38 af ab 1e 8e 50 3a e4 fd 64 79 |#`...8....P:..dy| 000011b0 9e bf 99 5b 2f eb fb 7c e5 0c 4a d6 be 15 2b d6 |...[/..|..J...+.| 000011c0 0b ce bd d8 43 ce 5f 21 87 e9 05 a6 80 9c 0e 59 |....C._!.......Y| 000011d0 f0 f3 e5 90 5f 18 0d ca 8b 5d ec c7 8e 6e 65 00 |...._....]...ne.| 000011e0 c3 00 7a 14 f7 46 e9 b8 51 a9 09 ad 6f d3 f9 3b |..z..F..Q...o..;| 000011f0 d8 cd 1d ca 7b 7b dd 19 aa f3 0e 5b 03 f9 57 af |....{{.....[..W.| 00001200 46 d3 08 4f 29 b6 45 04 ca f7 07 52 76 54 d7 0f |F..O).E....RvT..| 00001210 77 55 ae 75 cd cd 1b 52 83 29 43 9c a1 f1 be 6c |wU.u...R.)C....l| 00001220 b6 69 3f 67 79 65 44 bd 34 82 2a a2 c4 c3 ac 3f |.i?gyeD.4.*....?| 00001230 b0 ab c0 8d f0 2e 9e 35 ea b2 2a 32 07 f5 75 a3 |.......5..*2..u.| 00001240 fb 13 7a e5 5d f0 c8 94 61 c1 5c 41 45 af 60 47 |..z.]...a.\AE.`G| 00001250 58 6d 57 f5 b5 02 36 39 88 89 ca 50 89 d7 f1 19 |XmW...69...P....| 00001260 cb d0 cd b0 22 65 3f 90 ef 44 fe 38 bb 34 36 f3 |...."e?..D.8.46.| 00001270 d4 e5 0a 73 74 84 e8 d2 03 ad 92 7b 3c 4d d1 25 |...st......{<M.%| 00001280 9f 52 26 eb ea e9 c3 df 00 4e 83 75 3e ab 17 82 |.R&......N.u>...| 00001290 8a 05 b6 6d 3b 31 4f 0d 87 b7 f2 e1 d1 9c e6 c5 |...m;1O.........| 000012a0 3c 6a ec e0 61 dd d1 1a f8 57 25 de a2 7a a3 3e |<j..a....W%..z.>| 000012b0 67 ab 9c 52 1d a6 7f ce 12 4f 53 34 13 15 ec 39 |g..R.....OS4...9| 000012c0 d7 05 1b 04 a5 21 91 ef af e0 01 5c ee 06 76 16 |.....!.....\..v.| 000012d0 5a 27 9d e1 c9 a6 ce 91 34 e7 e0 17 98 0b d8 ed |Z'......4.......| 000012e0 ad 19 f8 b8 0d 17 a0 29 72 e8 b3 4c ea 20 08 dc |.......)r..L. ..| 000012f0 36 3e 53 d5 f3 58 fa f6 d4 4d 82 ec f6 42 48 2d |6>S..X...M...BH-| 00001300 34 21 88 71 a1 8e a0 2b 4f 32 a4 bf 35 0c 3a a9 |4!.q...+O2..5.:.| 00001310 bb dd b6 b8 3d a2 e5 37 2a e3 09 87 60 81 88 cc |....=..7*...`...| 00001320 bf ba 4a 3b 3a 1a 00 4d 61 b6 e6 bd 80 50 fb 2e |..J;:..Ma....P..| 00001330 f4 83 4a 6d a3 5d ce ac 32 81 f9 b8 3b e3 11 5f |..Jm.]..2...;.._| 00001340 c3 a3 0e 5b 57 ae f7 a0 ce ee ff 12 d4 d6 f8 ff |...[W...........| 00001350 de ce a1 e5 3d c5 d9 1e 20 14 b6 8d e8 4c 6f 13 |....=... ....Lo.| 00001360 4a f6 f5 59 73 0a 54 e3 99 a5 95 af a8 dd 8e 57 |J..Ys.T........W| 00001370 16 51 e8 82 d4 c9 13 c9 5f 29 4f 02 87 13 37 76 |.Q......_)O...7v| 00001380 eb bc dd 8a bc 73 73 b2 af ac f9 9b 52 f5 2e 0c |.....ss.....R...| 00001390 c8 18 39 17 dd 2a 43 30 3a 63 52 4b 62 1a d3 03 |..9..*C0:cRKb...| 000013a0 38 9c 1d bb c6 ae d0 e4 b9 d4 64 d9 f1 26 46 7a |8.........d..&Fz| 000013b0 95 7f 8a 67 c6 10 1d 23 31 50 b7 57 b7 a7 87 ad |...g...#1P.W....| 000013c0 76 cd c2 81 63 20 5b f0 7c d3 ad 92 ff e1 e8 52 |v...c [.|......R| 000013d0 07 2d 72 68 09 5a 47 cb c4 2c 4f 82 ec 45 89 6b |.-rh.ZG..,O..E.k| 000013e0 84 05 d9 c5 19 16 f2 67 d0 e2 44 bc 31 c8 0b ef |.......g..D.1...| 000013f0 81 ef 8e 1f 5b 4c 3e c9 95 03 45 a3 9e d3 fb b0 |....[L>...E.....| 00001400 a5 2d f2 0a 00 d6 5a 7c f5 95 ea 0a c9 8f ee 33 |.-....Z|.......3| 00001410 d6 65 df 73 cd a5 0c 84 63 4f 63 10 ea 3b 6f cc |.e.s....cOc..;o.| 00001420 40 df 7a 4e db d5 50 8f dc 85 0d 42 b9 02 34 32 |@.zN..P....B..42| 00001430 41 f6 3a df 4f 22 b8 2e d8 71 82 a8 28 c9 eb 2f |A.:.O"...q..(../| 00001440 ea 46 c0 e4 66 82 25 5f 77 c6 3b 35 f1 04 ff 7b |.F..f.%_w.;5...{| 00001450 57 5d cc 80 89 48 cd ba d2 9d ce ec f1 d2 59 33 |W]...H........Y3| 00001460 4b 7b 82 be f7 71 89 29 f6 eb 6b 6b 28 02 63 25 |K{...q.)..kk(.c%| 00001470 5f 1e 2c da 70 4d 8e 58 54 cb 94 4a c6 37 56 da |_.,.pM.XT..J.7V.| 00001480 c1 6a 1d d7 e8 05 ef 33 a7 51 94 8c 25 8b b8 32 |.j.....3.Q..%..2| 00001490 22 d4 8e 0a 01 09 43 5c aa ed 5a 93 c4 2a 94 7d |".....C\..Z..*.}| 000014a0 2c e2 f3 3d 26 fb 3a b1 61 68 c3 60 b5 e0 6e 23 |,..=&.:.ah.`..n#| 000014b0 44 0b 77 2f e3 67 2c 9b 47 8b bc b6 7b 38 ac fb |D.w/.g,.G...{8..| 000014c0 cc 04 5f ee 4e 08 97 78 16 fc 40 af 89 54 7c a7 |[[email protected]](/cdn-cgi/l/email-protection)|.| 000014d0 5c 6e dc 39 27 2a 1c 7c dd 47 be fb e1 02 03 99 |\n.9'*.|.G......| 000014e0 62 52 39 5f c4 a3 1b e0 33 b0 82 f3 40 e1 b0 37 |[[email protected]](/cdn-cgi/l/email-protection)| 000014f0 ef e3 53 ad 77 49 74 eb 74 f9 a0 89 6b 3d 6c 40 |..S.wIt.t...k=l@| 00001500 99 81 4a cd 1d e0 02 9f d6 07 c2 09 b0 e7 f3 31 |..J............1| 00001510 d8 66 7e c6 fc fb 64 27 c9 91 dc 30 71 d5 6f 3f |.f~...d'...0q.o?| 00001520 27 d9 07 6a a9 f4 83 d2 1f 65 b9 f8 b0 64 4d 31 |'..j.....e...dM1| 00001530 43 96 9c 31 d5 f6 b9 0a 35 7f e5 cc 6f 1b c5 fe |C..1....5...o...| 00001540 82 dd 40 7a 15 a3 2c b1 66 3a 6d 88 2f 90 92 d8 |..@z..,.f:m./...| 00001550 f2 59 2c 23 f7 5e ad c7 d2 b2 17 33 aa bb 24 b6 |.Y,#.^.....3..$.| 00001560 d7 71 2d c2 a1 5c bf 0a b4 48 81 e6 df 91 b3 c6 |.q-..\...H......| 00001570 43 0d 1d cb f7 9f a3 71 98 ef 1d c1 93 f1 b3 a0 |C......q........| 00001580 fc 6d 33 69 50 1a f2 34 36 26 58 c5 cd 7b 16 64 |.m3iP..46&X..{.d| 00001590 83 b8 3e 00 8a 02 80 03 7d cd be 6e 93 52 72 22 |..>.....}..n.Rr"| 000015a0 3c 24 38 32 de 54 41 f3 7c b8 38 f3 6b 37 e3 a9 |<$82.TA.|.8.k7..| 000015b0 74 ca 94 82 79 3e 2c b3 52 9e eb 6c 33 0d a9 61 |t...y>,.R..l3..a| 000015c0 5b 2e 54 48 ad fa 7a 4e f0 b5 96 92 f8 cc bc 0a |[.TH..zN........| 000015d0 da cc 22 2a 96 c5 90 17 5c 59 64 e7 7b e0 e9 9a |.."*....\Yd.{...| 000015e0 ed 08 6d 21 6d 66 41 3f eb da 65 6e a7 0b 06 1c |..m!mfA?..en....| 000015f0 27 4f fb 11 99 db 1b 7f ae 6a 1b a8 d4 f2 f6 01 |'O.......j......| 00001600 28 ae 74 40 9e a6 e4 f7 7e 3d a8 e5 71 7b ef c4 |(.t@....~=..q{..| 00001610 44 57 29 3c 3e c4 76 57 7b 64 bc 6f a5 1f d4 40 |DW)<>.vW{d.o...@| 00001620 64 14 83 70 d4 eb 0c a1 3b c5 1b 53 1a d1 68 7b |d..p....;..S..h{| 00001630 bc 8d 03 fb d7 fd 42 d4 6a 08 41 97 33 ac a9 f8 |......B.j.A.3...| 00001640 55 d3 17 4a 3a e9 59 a6 b5 53 2d 7b da eb 9c 45 |U..J:.Y..S-{...E| 00001650 7c 0b 3c 68 72 ba c5 69 92 a6 9d e7 c6 b7 31 7f ||.<hr..i......1.| 00001660 33 95 bb d7 ce 20 14 fd 92 2b fc 0c 79 f1 a0 c9 |3.... ...+..y...| 00001670 0f 39 7a a9 c2 9b f8 b6 ba cb 2c dc a2 70 72 16 |.9z.......,..pr.| 00001680 7a 8a 5a 16 7f 18 b2 37 4f e4 a2 be fb e9 ef 1f |z.Z....7O.......| 00001690 cd 57 0d 99 9f 6e ad cb 47 ae 4b ea d1 a8 56 9d |.W...n..G.K...V.| 000016a0 62 70 7a db d9 f9 b5 00 20 ee 9a 62 9b 51 c3 ad |bpz..... ..b.Q..| 000016b0 0d 94 de 9c 8d 59 17 4e df 63 a8 75 c7 23 6f 04 |.....Y.N.c.u.#o.| 000016c0 03 3c 51 4a 2b 50 8d b3 be a6 b3 8e 06 55 38 70 |.<QJ+P.......U8p| 000016d0 39 a0 f6 a6 00 a0 34 40 20 f0 0a f0 ed 28 30 43 |9.....4@ ....(0C| 000016e0 5b 6c 05 36 a1 b4 db c7 d3 20 4d 4d 11 3d 2a 66 |[l.6..... MM.=*f| 000016f0 3a c9 8d c3 e0 9d 61 15 ec 6e 48 90 36 ef aa f6 |:.....a..nH.6...| 00001700 b4 53 17 12 d7 63 68 03 7b 5f 19 88 07 ca 06 74 |.S...ch.{_.....t| 00001710 6d 2c 68 de b5 a0 8e 9d 0e ee 9f aa 83 49 a3 7b |m,h..........I.{| 00001720 71 7b 6b 45 63 34 c1 02 a3 7c 0d c9 4e e4 23 6b |q{kEc4...|..N.#k| 00001730 56 b8 6d 59 8d db 8f 03 41 74 7a 6f af 37 51 47 |V.mY....Atzo.7QG| 00001740 2f 41 35 25 90 2c 7d 91 98 8e 15 88 3b ac ce dc |/A5%.,}.....;...| 00001750 8b 6c 8b b2 e2 d9 5c 38 29 aa 17 28 12 b9 31 00 |.l....\8)..(..1.| 00001760 f4 f4 33 f7 3f 1d 02 de 4b ea 7a a8 26 42 d3 76 |..3.?...K.z.&B.v| 00001770 31 d7 8c 5d cb 51 2e 9b 45 33 b3 15 cd c1 21 93 |1..].Q..E3....!.| 00001780 ba 60 a7 8e 08 bd 9e cd 21 9d 0b 06 85 38 00 43 |.`......!....8.C| 00001790 e6 db 4b e9 ca 67 bf 6d 6c b4 6f 15 cd 4f 3a a9 |..K..g.ml.o..O:.| 000017a0 b9 ca df d6 9a 40 27 dc 42 dd bd 3b ae ae 14 50 |.....@'.B..;...P| 000017b0 29 e9 d9 ad 7d 46 9f 1f 7a b1 6d d4 37 8d 0b 67 |)...}F..z.m.7..g| 000017c0 d8 4f b4 05 d3 86 43 e1 3d 86 9d ca 71 96 2b 28 |.O....C.=...q.+(| 000017d0 df 25 84 b7 da cf 48 4b ee a1 42 b7 cc 67 b3 67 |.%....HK..B..g.g| 000017e0 65 2a 6b 56 67 77 2c cb e1 2d 22 3c bc 68 d5 6d |e*kVgw,..-"<.h.m| 000017f0 b8 20 19 20 34 fd b5 fb c8 88 75 18 03 9a f5 b0 |. . 4.....u.....| 00001800 fb cc 53 b4 24 b3 e6 8d e8 45 e8 bb 29 72 5f 79 |..S.$....E..)r_y| 00001810 b1 3d aa 40 b3 9e 38 53 84 b3 b3 75 35 a7 b0 15 |[[email protected]](/cdn-cgi/l/email-protection)...| 00001820 f3 46 f3 db a6 46 d7 f9 7b 63 50 87 fa cd 84 c7 |.F...F..{cP.....| 00001830 b7 75 82 b3 66 5a 0f 9e 7c 84 94 c2 e0 53 b2 26 |.u..fZ..|....S.&| 00001840 71 7b 88 4a 29 b3 a9 36 78 5f aa 62 a0 19 68 fc |q{.J)..6x_.b..h.| 00001850 2f 45 c9 5f 5f 4b da 3f f1 9d f4 6f ab 76 d3 3b |/E.__K.?...o.v.;| 00001860 4e 92 64 1c 68 fe af 17 a0 ad c0 09 d0 c9 55 44 |N.d.h.........UD| 00001870 e4 c3 de 0b 8d 24 d3 1a a9 c2 65 d2 c7 78 27 da |.....$....e..x'.| 00001880 81 6b bc b1 55 c9 fe bb fe 6d 8b 52 7a 58 61 b9 |.k..U....m.RzXa.| 00001890 14 2d 93 56 66 05 51 0a f6 a4 15 99 eb 8d 82 c0 |.-.Vf.Q.........| 000018a0 1e 92 32 55 a8 f2 38 57 93 66 4c 47 46 f4 0b b6 |..2U..8W.fLGF...| 000018b0 20 0e c2 22 32 d2 26 23 58 a5 f0 c3 23 9e 13 94 | .."2.&#X...#...| 000018c0 e1 e6 3d ed e2 03 d0 93 e0 95 4a d8 38 4f 85 c7 |..=.......J.8O..| 000018d0 92 3a 36 88 b6 1b fa 89 04 54 76 0c 5e cb 83 9b |.:6......Tv.^...| 000018e0 e2 2c dd 72 32 8a 47 b9 ca 84 1b 05 ee b6 3f bc |.,.r2.G.......?.| 000018f0 e2 fe 35 db 14 dc 8a 3c 21 b2 b3 02 df 3c 32 3c |..5....<!....<2<| 00001900 57 2f ad 2c dd af c9 3e 42 a2 26 64 f0 ff 16 12 |W/.,...>B.&d....| 00001910 53 cd 4d b4 ce 55 7b 00 89 f4 56 8d a5 9c db 71 |S.M..U{...V....q| 00001920 e8 b8 ed 87 c9 3c ce 95 f8 b1 20 d7 74 6d 83 1e |.....<.... .tm..| 00001930 32 09 7c ef 7d 78 cb 0a 7d 90 e1 09 79 a1 99 d4 |2.|.}x..}...y...| 00001940 0e 1e 21 06 d9 69 7c 0f 3f 5f 8a da bd 73 31 af |..!..i|.?_...s1.| 00001950 f7 53 a2 ed 2b 66 94 6c ff 33 b5 28 bf bf f2 91 |.S..+f.l.3.(....| 00001960 7f e4 99 7c c5 67 19 46 ad 2b 7b 5b 82 8a 7d 8b |...|.g.F.+{[..}.| 00001970 33 53 56 e0 fe aa 29 e5 f6 b4 97 cd 37 48 c6 4c |3SV...).....7H.L| 00001980 f2 2c e8 ca e6 a7 f9 ce a5 92 55 97 e4 91 84 5a |.,........U....Z| 00001990 70 43 b1 a5 b3 6c c4 fb 3e fb fe ab 3b 75 5b e6 |pC...l..>...;u[.| 000019a0 a7 99 83 3d 93 e6 5b 7d 4f 57 89 9e 53 a1 5f 6c |...=..[}OW..S._l| 000019b0 67 d6 26 54 fe 14 55 fb ec 97 73 e9 bf d0 47 f1 |g.&T..U...s...G.| 000019c0 dd 8f 5e 35 10 9a 4e ad cb 32 37 4d e5 dd 47 5e |..^5..N..27M..G^| 000019d0 f5 db e5 a8 b7 d8 37 af 54 b5 2c 6f f0 75 97 63 |......7.T.,o.u.c| 000019e0 7e 96 9f 5f 45 90 69 f0 e6 3b 4f ab 5a 73 92 75 |~.._E.i..;O.Zs.u| 000019f0 4e 57 cc d4 32 9c e5 4f ff 2a d7 5d 4c 9c 0b 49 |NW..2..O.*.]L..I| 00001a00 56 a0 68 8f 73 bd 01 2f 18 f9 96 3c 42 67 e0 16 |V.h.s../...<Bg..| 00001a10 0a c4 48 0f e8 40 9c 24 27 3f 47 85 31 23 63 53 |..H..@.$'?G.1#cS| 00001a20 c2 34 b2 8f bb 40 76 8b 67 35 9e dc f1 05 a9 96 |[[email protected]](/cdn-cgi/l/email-protection)......| 00001a30 bd 44 ec cd e6 cc 16 0a a3 a5 32 f4 c0 35 4f 7e |.D........2..5O~| 00001a40 e7 7f 5f cc 88 f5 1f df ae 20 0b 7c 1d b9 ba dd |.._...... .|....| 00001a50 0e 91 13 60 7f b8 fc 8e 0c df 90 c6 bd 75 3b 8d |...`.........u;.| 00001a60 df 2e 1b df 6a 6e 0a c7 36 21 6c cf 45 80 d8 f5 |....jn..6!l.E...| 00001a70 43 c9 3c 9f dc e1 74 77 08 d0 a1 68 8d 5a da 83 |C.<...tw...h.Z..| 00001a80 ca dd f6 e9 80 43 7e 5d 86 04 40 a5 da 97 80 e2 |.....C~]..@.....| 00001a90 09 09 a2 e4 0c 59 4d ba fe f9 ff c5 a1 1e 93 e7 |.....YM.........| 00001aa0 51 70 9a 50 5f d1 b3 d9 84 9c b7 1d a6 26 c0 cd |Qp.P_........&..| 00001ab0 77 a8 58 d6 31 4e bf 7b 52 35 98 b2 b8 1b 7d 76 |w.X.1N.{R5....}v| 00001ac0 08 b4 d1 ee a5 a3 ea eb 28 05 c5 83 69 5f bb ab |........(...i_..| 00001ad0 ff 90 fc 29 2a 09 fb 8c 1f e7 15 cd ac 87 c7 41 |...)*..........A| 00001ae0 9f cc 4b e6 af 98 be 1a 61 92 bc d9 69 cb 8d 1c |..K.....a...i...| 00001af0 d3 2e a3 5b f6 b1 60 10 b9 43 5e f9 06 b4 f1 71 |...[..`..C^....q| 00001b00 ea b1 9b 36 7e d1 a9 89 3c e1 6a 74 6c d6 d9 03 |...6~...<.jtl...| 00001b10 ad 7f fc 2c 0d 72 e0 a7 6f f6 79 bf 26 2b ae 48 |...,.r..o.y.&+.H| 00001b20 1a 5f 7b d8 21 4c 69 62 c6 c9 5e 7c 1b de 74 e5 |._{.!Lib..^|..t.| 00001b30 29 0d 2f 8a fc 30 ec 14 74 55 f1 1a ac fc f6 91 |)./..0..tU......| 00001b40 8c 3a ed 9b 95 48 70 7a 6b 2f ab c6 43 ec cf 1f |.:...Hpzk/..C...| 00001b50 2d 63 8e 92 ee a6 e8 e0 b0 7f a4 29 8b 4b 1e bc |-c.........).K..| 00001b60 75 55 2d ef 85 6d d2 4b ff 1d 3c 36 8d 1c 0b ae |uU-..m.K..<6....| 00001b70 97 93 ee ef 83 13 d6 41 05 db 37 99 67 9b df b9 |.......A..7.g...| 00001b80 64 be 3a f9 cb b3 ee a3 87 4b 5a cd 99 ee 84 96 |d.:......KZ.....| 00001b90 1b d1 7f 44 3c 1f 9b 4d 19 15 bd 53 ab bb e6 f4 |...D<..M...S....| 00001ba0 8d e9 96 c3 d4 b7 25 21 02 ea a8 ec 5d 38 ae a9 |......%!....]8..| 00001bb0 0c 71 7d 30 73 67 ec 31 7b 90 79 ff 22 e8 cb b1 |.q}0sg.1{.y."...| 00001bc0 0e 70 a7 a8 b2 2d ea f7 4b 47 df 6b c6 1d db 07 |.p...-..KG.k....| 00001bd0 f5 bd 75 fb c4 4c 73 d3 09 8d 1c be f7 6f e8 9a |..u..Ls......o..| 00001be0 c8 f9 cd cb 93 2f 7b 7e 42 fe 7c 79 35 25 a0 6d |...../{~B.|y5%.m| 00001bf0 e0 ef 07 b4 cb c3 31 f5 dd d0 95 65 f0 71 a8 1b |......1....e.q..| 00001c00 66 be 0e 54 04 45 aa de ec 14 10 7e 8b 8d 39 24 |f..T.E.....~..9$| 00001c10 db 87 03 c3 5e d2 64 4e 1c b2 dd 3c d9 8c 8e 11 |....^.dN...<....| 00001c20 8c e7 4e be d0 5d 62 9c cf 7b 2e 10 ad e1 9e 3e |..N..]b..{.....>| 00001c30 6e ad 48 40 b4 f4 23 ba 9a fb 70 17 59 05 c9 10 |n.H@..#...p.Y...| 00001c40 fe cf c0 7f 6c a7 17 1b 12 5c 97 90 a8 6f a7 e5 |....l....\...o..| 00001c50 73 b8 2a 2a 16 61 7d 4e 88 4c b7 6e 18 a6 69 6f |s.**.a}N.L.n..io| 00001c60 9d 73 c0 ca fa 18 9b ff 5d f6 59 f6 91 1f 39 31 |.s......].Y...91| 00001c70 6a 51 f9 5b 6f ac 2f ae 84 dc 45 ea a1 33 de 2a |jQ.[o./...E..3.*| 00001c80 dd f1 3b b5 40 10 5b 7c 16 89 03 fd ff fe 17 14 |..;.@.[|........| 00001c90 31 cb d1 |1..| 00001c93 ``` To generate this file using Python 3.8: (not part of the solution, just informational) ``` from pathlib import Path import math import zlib DIRECTORY = Path(__file__).parent genome = (DIRECTORY / 'covid_genome.txt').read_text() mapping = {t: i for i, t in enumerate('AGCU')} buff = bytearray(math.ceil(len(genome) / 4)) buff_i = 0 buff_shift = 6 for c in genome: buff[buff_i] |= mapping[c] << buff_shift if buff_shift > 0: buff_shift -= 2 else: buff_i += 1 buff_shift = 6 (DIRECTORY / 'g').write_bytes(zlib.compress(buff, 9)) ``` (I know I can probably shave off one byte by using Python 2 instead but I don't have it installed here.) [Answer] # [Python 3](https://docs.python.org/3/), 4515 characters (12265 bytes) ``` # -*- coding: UTF-8 -*- b="""ԃ㕄⥪ག ⠥ᬙ◓ٵ♀Ⱕဆᷟ❢ᯧ⇥෢ᢸ㑁၂ၒᶵ㈼⋍ɭ⑥➏➔⽖㚷ណⱡ⎈᤽ᛚ㽷ી㴌ἳ⥶⧵ᠬ〈⋚ɣᗩ㕒ཛⲷ⛒㟥ἲ᫟༽┘㏢㘈᥀ㇸ◟┴プⵗ⦂ᜈ㪑㝘᠋ᛱ㦰➊᡽⇔὜㧴㣂ᬏⅣዶ㓟᳈◷ᩝ⩡㟻J෹ኸཙᥭ̋㐐༹㷺Ӕ⾺㆐අᲔ㻋๟≱⥇̕ᠰɼ࢐ࡎ෷ᒫᰦ޷๐⼿㡈⛤ᶱȉ᧟⩱㹊♜㞅Êᙎ୹㴃▇≗᫂ɼ╅㈤೿ᴒṺ㜈᳡〗◴⋰ⵧ3⑰ឌ⊕ᰅ_‰ղ੘߼ݨŗᅚ━ᨐᠲᅠ⠿ᜀ〃◇㥑㽌ֱ❤ᨵ㭢“ނ”㩖ɦ܍㜘᝽〥⇸㋾ㅗᐎ≞さ㟢᳁ᜤ̏ẉॷ㔥ઠǧᝐőᶣ⇘⁘ビ㊜㡍◫Ĩၰ᧹ᰂⅥⴏ㟛≅㩗㏧ᷖ᥇ៗ⡂ͷ⤗㵨ⷤ㮐ℽᴊҏᵵ㳃㖬ཥLjਖ਼ᰄ⚀̰ං؄᝟Ვ”܌ㆺԕᾆᕙ㥨⃞ᕷ〧ᰏᗱᄃⅠࠅ㗁⧟ၕÔ‏9㞧ぅ㷂ఆħඦᔞոᣏ➛ᵴⱠᕦ⮉◀➘Y㞷ᕈヺ㤐⁉౼բഖৌ☗ޑ㇖ࡧվቂƓᝁ㺒ԣ㟝ᵣᜥ⸷㤉ș២ᵑ。᠊ⶥㅾᜌフσ㝌㕥ೋ㗼ŵTᦂ❹᷀ᝯἠט⧞ðԏೝᣈᙔ๝@ᕟ╷ṲᤘᑟἹ”Υご㷀⅝⋢᠏ㅴ⌃ᷔƣర৺ቡ㩤ê‌ņᙓ࿌ȥ⨣͵ȳプᥰɽㅒʅఠ⤤㜎ᵰ㦡Ὗረ㕴ᐯ㥇ល`ಈ」৞⥸⤄ᱽȂĩᢉ‾㷢₀㵉ᗷܢ᷄マϔ⃍㜄ᢕᰥ㇀㱜ဴ┇ష♺ᄣᜉ⽈バܵ⺝㗟⌞ᶄ%Ḋങげᒊׅ৾ጜ㟍ߤℤ┕㇍⟜㕀៥∑㑝ᥙચ౳㇃̏ᱝッ̵᳨ᠦĜ㑽ৃܔ⠽¥ἅὺ१➙ᠩッฌఱὓܜ፠‧៘࠲㸷༠ᣈतᘂŵ㏖ʘԳ߂ᒊ൵⌤ᜍきᔷ㔕%ৈ݄⅀ǣ࡝㰰㤀ཀਈ㟗ᐞກ㕊ᐈἼ㷗⏎━Ϥ␠ẇ⃗Ɯ᱒Ӥ␟ਥß㟓᝵ᐻ㈠᥹‰㙘ᵶ㺠ݐ‽トᘉ᥃෥܀ᕁ⎋͙ॸ⡑ᆎὅᗷ✪ᄡᥐ㍗ᴱ৖㢀ᶒᓧᥜခ♇ࠉᵘ๕ἁネ『͜ࠃۧౚဳピ຅ᄉ〴ʖ൰⌰Ȍ᱃Ηᵰピ₂᧰〤൩∰ɝቔᅲԇ㠙ᡨㅧ⢙ᵍ㈗ࡢᖔ̃ޚф㟷ݝᠳ㷕႞᷵Ҥ␀㹽㸤✁㤻å᳀෨ࣈԑʉኯ㘿ᔁ㵈❌㳸̣ṐÝ7⥔Ⅴ⡤ᑦၳ΃YἉ㕥㰕㬰ޗ∞రࢸŁ㩶ᷟຄ㕠⑈㭀ᄏ㑐Ġ㏷὜ᑽ㤱ᔥᒊഀ₝໘┘ࢉႱ␇™ᵈޢ៤ᴈ⇹ပ㰰㧦㴑㌙☃Ẏስ᧕▊ᱹ㔣ⴐὑ┥▖ဈ⧃ȕᅰਙ≞὚ᄃ׶⑙㲁⒈ऽӁᙐ㌽㄀㝄ᒉആ⒢֢Ⓡ㜍ᆊᗈِ㈥╥᳌ාऔཱུለ㓈ࡐ⦢ஃ᝼⇘ܡ߈ࣕ㶠┕㱼㧇ᒐĀ⦄ֈ᰽!ᔝᔩLJ࢙୵㏥᜴⒢ࠧړᕧ㴽ࡶดƈ␀㟀ኢ͐ὔ।ᐇ㸱ȉ㔙ẉ㡝ႉ⠠Ӎᰵၨ⧦ሌṑሳ⃾ὰ㧤ॗḥٓ⤧၃࣓㜵ཱ㔳㍒᝖Ȟ⁔ㅥ㠃඗˟᷐ɝ㲂าʥϷጎᵇሟ㢉ᙑめᐰཱུ⌒◒㝽ƒ⒀Ѥ㒂༶੕㔜ᶎ਩㦍܉ს㴡ᒗṍ㍈⟐ᒣ᷶ऐࡄ।̂ᗑḓ௞ᔥࠍ⦌Ҁ㶤ᒼᵖሃ#ᒈࠨည൉ᄁ἟ᵵᴣ\⩃ៈԔჀ㈅┕∳₠᜙ᴨʂℚ¸๛Еვ㑷Б―㧇Հ⣔৵а੹ᠳ๐ൈᕚ✥}㇟ᾑ᱑‰ࢊ♕̃㎐הℂ⑝១㔈ނ၀㨭ЊJὴ዗ᥟภʍᰈ᠅ⵜᴧͣ༮㣼߄ٞ➰㆐ʍ♰ビἀᩊҌ̭ᥳᴇᰂኰ㗓㌡ᄥ£‐ፔ⌌㵾∣ف㹹ᇓࠖ፥औఊၰᑤ㍅བྷ*ធ᡽ᓧ❐፶⥿ґแᇤຕ᥂×ᓒɉȓᒋ㝔ʷᗒၑޥեቔធŷቕर㒀ᙌԃ↑㫉ओ‰ት̷ᯐ՝Ⓩ▅ၑᜍ⊐ᕙœထᄅὕቅ͵ẓ㖕ƒᠫ➕ཱུᐝ␕྇⥥৒ὒೃ㤕゙इᢑḊቴ⟖ᄩᴷᗙ፽ᓅ╌⊑⥥ጂᄠԨᖆᕀ῅႞ᕾᓗ⌷㕗㡄ᙕ≏ᕙ݉἗㧠ᡸוᘹ՞ഡᔔ㐖៥ݽ၁ၥ㒀ᾪㅘ㤟ᓁ㒆ᙗↅᑑ㑼Ôᷡ㗓ௗၘᠥ㑱㝒´ӎȌ㛁㒂ᅵǷᓃ㚕ᇙސἽùᗠढżםၝㄡ᧞Ὅࡔᓜᰵ㬳ॶणᔀ㊁i৊ඖᒆ㗄㝒සǵ⡨ᥒᗄΟ᠃ेÈᙦᦅᝐ┲ʜ㎐ႉõⅺᅁ㔓ᕜὀ᠁㜌ؙ㠁⎶ᵒሶ๑㝠⤒ᵉౣ㡓ᶜᵽㄷ⼍ḵ ᜞ᒵĭᖆɕ˒⁼&"፞ɸョɞÁ㝩ጠᶔᤥᑖู⾃㵝᱘㇓౵㗁㙐טↁ✡వ৻ӗ၂ᄞᢤႀ㗀ࡲભ㊗㞗ᅲᴷ⻘ᅁ㮏ᎀ͢ȗ╱߂㔃ա㘗ᧂɋ Ҵ㞞ဃĉንთࡷₒጠ㗔ݝȈ̓≐㽽ᐐៗ΍ၐൈ◝ᩕᵹ㤕ᤕĈ⧖ݡ㙀℧ॖͰؓㄠ㹅ㇷ㝢᭲ӡ⒌ቝᗤࠈṱᗈ⇵Ꭳⷷ㓔ቁ㈃◪ׅ㧣ᡂ̰㟵᝭㩽ឧ㢱Ԯࠤߜ╗⅙ናൕ෣័↝ሢↀॄ㍈✥Ḉᣥ㝕㹹ぴ⁕ေ㥧㐺നᅵܒ⁴Ⓝ㖝ṑ〵ዪᲈⵇṡ㱾ᤔᘅᩂ੊ᜏᙵ೟ႂᕱ᧍৓㢾ॷÆహ㷕㝆ቍ㴱㽉ႁㅅࣆᔨ㳕᧟ᴱ㧐Չቁݔ⊉Š⤗㞕㲄ᣡ⑍๽㴗᎑ⴴࡺឤ⑕ܽᓃ๕㷁ࣘᴵ㩔ҕख┝Ⅲᴦᵐ⊍ᒘᙒ⟝ᑙ㔕ॴ◈ᕆᒐᱵᥕᎈᅣ἟ᑵ∩ᓒ╧ㄈץѡᝅᨠต⑟ᙔ㐔⤃ಷ፥ၽ㕩ᓒᕰョ⹷⊕ᝐЌǑ␍ồᱷ⑒♒㠑ıॎᥑč࠴ᕍ㳠ἒɎሳΞ᝝↛‾ᦁ㉘㐦ཙ㇖ᔨਨ ③☹㕞೟ᕌⅪٽ×࿗ᇴ⃐◟ሉ࢔௙៥㇋ፔ❨ಇᱧ⊙トṐ⩁ᇃՉⅭͤؐᖗ㒏⟐ᵠ☿ᑟ࡙ހםृ┏ᜒກ⤌⊐㑃ᗖ㡘਼⌥ᖍ㔹ᵈߖਙ㷕ਇṇྨբᅃ㵡ᩐ὘ᷴ㝟ᕂӅܧᶙᕵࡸ⡇げ₟ൡ㧸⌥ఽɕߊᕵ㈾Ž࠸㧴⼢Ʌࣔݕ๟ᝋ➝ᄁ㳈㷵ᦁⱔ⢂᥁㉔੝㹇͈Ԝ੤ࢃਝᲄ⓲♖Ṡৰឭᔱݷ▅0ᒞᇁ㲴⡅㽍㥑ጌᰕࢥ᜝ᵌ⁹⏝ቖ‷⍰̈؏㒈⢟ᝒᢁᗉᢕፕඣദǶᗖᕕᴜzᕒ╞ᇽԗ⑶ṕ㠜ᵝ‡·⅙❗ᕝኖ᥺৓┕၇㙄ẞ፟㜞㑑㈟ោ὜ቍᝧ㕐㤀㉷ᑴḘ㧓ᵉƥܣ⃂᷑㇇㞓㌷ἢᑰᶗ࢛ᔐ൑ᇴޕౠ㨕⡷㹥Й❒ᙂባ㝍ሉ㘝ᕾ⌽וᑷᵳᅺ⑕▄৴҉ᣝОፔ᝖ᓹ՗ቝ቗㩥᝔☊㤥ጧগ㝔᱒ᓕ⒈㳕ౄᰖࣼ⒚⊠ぎӇ⥠ংԁᵿᵽ㸂◑‴㨧ሶဇᣇ့∘㓙ቦൗ₂ᣍఘᡤŷ㹠ᷚൈ⁲֙᎐౉ৃ⥜㕢ቖᵗ╨ḿṴ㈐࠹ᝰ〞ἠ⏸੒Αຘ㍔㖩ᨘᇣ╞ቹ⃃├㣹㗤ߜᙰ㗖᐀㗃ͥᰝ㹀ᧁᜫᱸ㨞ː㗰̟✘็઀ᴐࣹ౧༠㏸Ôⓞᇣࠞᕢᇥ఍ἐᱸ☈ࡑ₁㠳ߗᵪᜈ၊᥈ࣣ⠉ǵ㘒⌤ႈᄀҷᱽࠡᒔḘ㡝㼁⠣㗓ތፀזɓᰅടࠖੁᓡ㺙ᅴࣥჾ⁙㧘ňぁ㎔㚝ḤⲌᶗṺ㴤∂Ṟেࠞ㔹ቈࢂü㴽ᝉḧᑫՈ㱗Ⓟ⩃෇ゟቆᄣɼ਩ᴽᝒಈ⤃㚐සᅑ॑ြᐈੀጽߒ៓ᔹ㨣ዙ࠹㴇₌෩㨅₝ԙᙷ╞ᴱ㧤Δ‱ᆓⓟ㼠⠘␗ᵃݝ㒈≽৶ཱྀȵࢯΠᇱ⃁⥟ὸ᭵㙴➭Ẉጘᨁ⤃ㅗᲔôഝࠄ⤠◞ၲ⧟㕒ीȣ᧒⶞㴝㰏ᑾᴵ㜘মエṘ㘹㇢Ƶᔂ㽗⽴෣⫙ራỸ⏢ፉ㇛ᄣ㹕㈙ࠜဴ㧵ថ֤$חᮖ⃀༬౲Ő᜖ᒕ㓔ೈ≖ᤉਈᰰࠕЕृㅶ⎝Ṁ⇉ᥐ㕌Ӌ㜡㴨ℑ⋘୥ँࢁ㸲⛙ޕϡᗇϐᝲࡐ́ॶࡈחᱱㅅ᠐ò὇՝ం⣄ᅋⴒ㨉Ꮬ୴⺃╵㒁᧜ẇⰇ⟑ᵽ㒜⅌ၠ㆘ߐ⟑ㅛ㜕℠ਮ⏓ἵ⧗጖ᑑᡝၺᄔੜ⣾ᔉ㣍∝Ᲊ㉐›ᒅͿյ㉘⼌㏔™ᜫᑕE㼘㈒⊠םႝះࣇⅧⅷ‥ၵᑙ⒍㖨⤠㕟ਤ㜰Eᵱ㷖⅝൘ৱਥ⌳⓷ᝈၣ㇐ै᎙ಔ㕐㰔◝ޞᲩ㤞ஞᙽƑቌီभ㥖ഹ㢔␠ᵹᖀ❠ઽŔࠌ░㉗❶ჽᙔ༏͙㗁ဈ▖ᗦ༟ၹ㤘㬔ᲒᆵЙਈݷѣࠤ⑗፜൵ㄍड़ᝒㇷ㧑ၹʃᡭ₂ⓈƎὕ⡔Ї㽃㤲ᔔ᱘ܼܵᠱ㢕ᮄሀⴇᡪቄঀᰙბ㨔㞀が㦸⭎ὶᤙ㓒ᇊIJ൘᠀ᑜƁ຺ळ㎒ᴴװ⃠֑㷵㸠⇔'ᔓᱴ《☩ᇽ῅ڐݱ೨Ẑ⇥ఔᾦॵ◦㠈ላᵴ㥶ࢭᙄㅎၳᷦͅ㍰ߘᷟ⽘⑇ᐊོ੡⏌Ẉ৥ސ፵ᔈᗘ๶௨ݐḥᑤ✟ႀ׫дᶮŒȣ॑㍶ᤓL㇗ࢌ╷ǍᔮїⴂզLJҙ✬ṵ㝵᠓≑㡦ϙ෹ฐథი㖕Ԙ㕔ᶜ฀ᵼ✲Ქः㊘ᰕṦȒǤ㔂࿜᱑㝊ᚔ⨱⡠ど࿺㹵ᝌ᱆㐀⌟ሥܗ˵ⷙᓤጞᒨ┤Țၣ㍇✝╡ᝉሄℌΒܜ㔈㲈ᵌ⇑᧔Ṓၱȥ⃴៰⧍ᔜ㹇ሢ⸒ඔ⏧៾᝵╸ֈ㉘ᐱ㟞ងⴲⅥݝy㔬⡶Ѡↈန㙝❐᫑㕸ޚཝ㇘⌝㉠╉Ꮟᇎᅅ㐆ࡀ⢨ᓕᨗᷤ߈ൕ㵑Ѐም㗴㬐ᵉ㉔ށḈ᷉㲀ṽㅈᕎႊᴧÉ⃥ᗣ⌂㦀㤧༲Հ❥ߑṉ㒷͹㙲ುሙᘟプ㐊ጨ⢔ીᑶᔧ㔛ᴉ㐍ࠄ㳍ࢥᰀ㷉ߜṵ㕊㏒ȉሁဝάᅗṲء࣐ẅ͸⤢፺࠳≇ᓁቾᑊ₉⁆ᣇൖᎁ㗠Ԙõ㴞4ᙈ⚏㊊Ὁ㴌㘕ṅ㺓♤⒩᧦㡍㑈㥹☞⹵㇢ᇜヸᐁպᄱt㓁ᄩ㢷⛝ೝᗄŠශᠡገ㑶ᕴ❀ḗ⧌Ⲏౄ㗙᜜Řߨ—᱗෗᠞⌔ⷤฤ᷒׻ઞ᠔⧢⋢פए㢉నぅ᠖ෝಔᰂᄽ⣈ᵩ⼉ᶾ㗚Ṱח࢝㍹៕ܐქâЌ‘㦁㥐Ǖᄏ㝑⋡㇕↞łྡྷOⷴುᩒୂ⧥㳀๶ᔕ⊔ၘ⌇❎☃՟㉊ɠৗֆࣾᣁܤᶄᘦ¢ᰈ㦉◐ᴂ౔ݞᅊೠ͏℥Ḑᶜጲ╇࠵㠕࠶ᜁᨭ༇ᾂᔠ㧀݂༦ᔃדჴا㵈ᩈ⏢⒈⦍㗈␅ ヵᇝᲄ⧸ነ㲇੄ド↙ܟ㕐ǁᆃᐟᒩȝᑢ⮰ヤ჈ᴭ㡼៥ⱶ㏽㘞ቌョ្⁔⥒๏ᕙࣷᐩ൹㒤⏔ᵱࢤВౕᨳᓞဨ⮧㌘Հ⊘኉ᇒòᚗぴ㞴ေᴠݐ㜢ीƙ✣පᗙᇾࡾᗍᲆᇃᅗᰁ༩㎸⧗ᤝㄲ㞢ޕᨧ▌≑㩵㸘ᙅ㱗ԭ⑁⭔ᱜᵠⁿ㕒ག⒀㠨ᱧᅶͨὁ㢇᎓᝱㠘Დ㝤㧚ଷ╵ηᜧ㉅う⑁ά゜౐ỹᴰམࢇ㗔ΞԔ㣈Ū൥⋈័⩀㤔ෝ੠㧇ጇブᇇ∺ᝍ㈃┐İけᤖᑺࢅ✠ֈㇷᇩ՟Ÿݬ጑⧤֡ᵝ౗࢓෤ᤊᐥ㩽᷇㟣ᗑ㐄Ȟ֢ࢣ╜ဍ㥗ᐕ ᒡᕤᒙ㈶⇜㙡㰂͍㘱Ӆ݊ः᧤ⷑȭḅᏟṶᴲ؞ၳሱᴙⱹᄈᱱ☹㹔㥷㵒ᜒᑂ♼࢕ሌ▌㕌w㥔ݝC㲉ᜟࠣ㷃ኍᙆԄ࢝ᒈ×ߝᱴそᜀဈࡒ❐ᴸᗎᗾხȔʍਲ਼㜀በၗ㷟࡞ṁড়᧼⒀ೇ⚎ࡄᤤ៝᝙ܧࡎ⃀⠧±᝸⢘❥ᕱ㴳ᜟᠴ㉑ᓀậǷᙑሰ㴷ᐏᔠ⡧Ꮪ†㤶ᐟඈᐗ㌎ⴀࢍ᠔ᑃ×ߝᶠ⁒✂ᒕঌ㓀ᔠごʣ㍠߀᜕┰ᓤἜօソЅాᇩᬈᆵᇳՓᡍ⍓㟕ࡤ✗㉎ိᔏƊᕰᓃՑᩇ㈴⍐‘ᘐ⌞㠈㵡␷ᷝ᧔᜕ԥ㇅᝜Ąj̕ٴ㕤ཝ‷गऒఅᡔṗ㝀ㇺ݌ȕአňٍ⃭㸊㽵㤞␙ᒀހべ԰ͷ੘Q㷄㞂ԩøၱぶ㠁Ҙঢ়⁅ဢԈᓧኤ၇೔ሕό㵧Џ൸⣴⎝ᔌ⍽Ẓ㽋➗ᬖ౥ljᝦᱸㅠ╱άᷠ❈ሹā㼙ⅅහᴬ⩃ऀݒ0lj␌㽕ᘥࡗ῕҂9๥㳵⭾ᄃУȖេ㧆ᔐ㦇㲉ᮇ㟈㩗ᒐ᷁㭡↜ตᐗ㇐ᑥ㸂⋬ࠄㇵݡ㡸ňᅗ㏁ࠆ⁘㗙ᩅ╅ᲇഁᚩန࿴➝ᇙᐃϘƁㄜᕆᥥഃ㓉ᄅೀࠣ൵դ㜝᥵ȉ°⁵ᵕ◕ᅺशᤶෝၥࠨ゘Ԫ⧡࢐ᙖࢷ㝔ᒩ㈃ᕣژ㕒ւᣲ᝙ን╚ǔ◵⡹҇ᦟ㊁㴤೵᱂⧚ኅၱ㷕՞ᚉ㌍␡Č㹼ᕟ቉ᓅⰲ⣚⒔ᝐႹइᝑံ᷁ᘅᝁㆡᕿᵑኈ ‍἟Ü㖌㕅ⓞぁḥᜄᶙ⎥ᙑ㲥ヰȿၖᓼշᔌќὑᔀᄖტதᐕ෭㆚☿ᕛ㥓ʅ㴱ហᏑႆऽᘂᔥ㥒Ӄᑗধ㜖ᙘ㵼⎟Ṹ㥅ݿᑥ₤㲕ᤔD܀Ἂԣޝಝ㢗ઙ☰ࠍ㒵〚ᘧጀ༆ᆀ▐╌㚂₌م㔱ᚐᅈɝ㪕ὰ㕔஢⌕㡧ᔞែ༌っ₝㗧Ԗᶤᄅ⮆՚॔ුἷᦤ␅q♹ᒐᶑ㣅⅝Ō㷇ͣࠆ㦣㸂ἃקԐᑀᒣܕሾỔ᎗すȆ᜖ჵ㷴ԐᒧᄱᵓベƘʕ᳌ㄕₜƑ⏫㓢੝Ƿᜏᕁᵉᚕ࠘ᇵᨊ≁㷗㔨਒೓ፉᙕゖሞਸ৕㟊ဃᤤսဂw᠕ₖǵႏ∽㖔✶ႀ͖ẕ⠠ᗸ㌡Ṳधޝ⭱⢌≜ㅥ㈔⊇ᙕ㷷ᣝᄈ⣰‒ᙂ⏗❙ᑣ㇔ৢశ⧗⑘ḱₔ⚒៭㕅⒏ᙁ㕖‹Ḿᵐ᏾ᰡ㘈঄᳝㈒⡟ḽѻⓔᣉ⌤֚ᯯ㢴㝎፠ᨘឤ≇ᢗ㞌X㗥ঐ႙רኢUऔ㝒∰֒⍶ᇊ̡⍌ᝈ݈ᗟ᱘ু㣠ᥗខߣᕝࢁါṔৰ᎝ᰠ㈀ࢨవᗢ͠ࠅሀ⊊ŀㅗ㟕ၕᢀᅊ౨᠂⃠㏘ᔗ̙ॖȃᲉḱ㧹ᡠࠑ㷅㩟᱅㧤㌩⅝㢀൐⾥৕ẊᗦࣇqṠሥ➉㔻㴠ᢖὟ੗㞏Ṹᒀኅṇ‟┓㕁㴗㍒ࣁ㖙ܰ⠀᜗⠨Ձ෤០Š㉢ᖖ∸෢ៀॠ㇟ᠨx⃥ဢ㥵‚ᓦ⁕㷠ᖃᵔDŽᩖ୥㈃᜾᰷‗ӵㆈ㸲ᘃᗣࡇᲘࠔԳ➌ƌ㥧␙ṹऀᶌ㝴◲ƀ̵ㅕ㟀㾑↔ᶥ⩣ᣢ☟ᴶᙞݲᑶ⧢̀ゖࠧ⚞⅝⇇『࢕⦷ϝ╵᠇㢈⟕㐢ðᕑアaቈ㈈⅝㙽ɷݝļטࠢ൑ㆥḊᰔ㉡ᠼ㳔㄁Րちࡢ⌝᱔㷈ᦟ⅁㥣ᝀⅠÀᜫ⦁㏗⠰ᔁてᡬᦠ゗〴᳣ᄐǺߒվᏕᄹ㹜ឡഇ㜠ᑹឝܨ㗧፝☏㧗ᙝ㱩㧠ձニজ㨷☃㍠ԡሡ°┟յᇌ٘ ɴड़ฏᰆχ⒚ᘱᗖ㮒ḋҬሎ☦⥛ㇹᅵ㻗≙ṵᖌ㮖 Ъ᠀㌟ₓ≦⃽㖉᝗ₗ❝ᵝȵቢ੕㦵㧧㩜ຩᖙٔṔ㙉᥸㍄ɗჁćྕ㹗⟀ẵ⠀⨔╇ޠ⑕╹㸒ၝዉב੒ķ႖ᘅ㘔▏᱾ࠠ㚑ᙰ⇉਱ώᄧ㰙㳐̧ᵴᒈ㔥≘㉅ਹ㒘ঁ᳒ಉ㷗ȝኖᘙࠐŵ㇎✌ࡶ‖ࢁⲽᡫ㍝ၨ㐟ʁᑱガⲲ቎㞥ᴎ࠹㇍ଉᇒᡛᖼೈ㴭၍၎㒖ᕙṖ㟑᥹ൈⓨᩒụⱝ㞴➞ėᐭ㍥㐂▕ᒵቦ㝐gťⓍᩱ▟ᤂゐёԵᖝែᔅᓨᾌᚂ㴤ᒭᰳ─๩ᰠἊፁབ⑚ᒇㅝ▒Ş⑺ȼӵᗑДുᖦᾝᇺഉᓥ㕝㥹㧕ࣁ_ث㟁Ṇ㠟◙ᴾ᜝㹣⒖ץ╣৕㮴⻖⇟ᡘڌɂ֖ᠭ㨦⇸⑙㊌⮖ጃᰦ㐛㎝ㆥⷲٛᅹ㲊ُ஝㈘༩㩀〘❞መⰮᖔᒀ៳▸㭴㣷এᕹ㡈㛤⏅㸉Ѕˆ㊅⣓⍲ė╹ᴣნ₌ᵘᦵ㉖དྷᄸ㌑ቁᅇ༥ᐍᚅἆ᜔ↄʘၐTᤍ≂᳁E★౰㎂⁼ㅱာࡰŅ╙ᾉㄈ⛤◜㥑≊̷ᵌ㴠⍉ᔀゥ㦖Ἀዏ㠖ਕ↦᎜ႀᗢᲗ╎ঁផṝ⧋㭀ࢶᆍዞ⌘㕢␉㖆ಃ།ᠰ╉⚁ᕥח⾁෕Тᗥ∦0ಌܗɖԅ㉙շ╔㩖ṅ⥵ᐔṑᆕὙ≜ৠㆄ܂ᝢ㩀Ⱑ〕◕᥏Ɔࠧ᎞բ⃁㓕ࣘᴦȘ਑㓗ܪ㝩։ᤖဟᄔ㍏์c⊕Ű᝻Ἔ㹽ᤁ⊡ᣒۄᯐᑈ㕩㕊ᕈԅ㨼ੀ៴㙝෭ᵭᤜಕᓍ؜⵭㗕ጕ←ଈɀݧПઠƎ〞મԭ៟ઘㅠ⟣ႣdzˣΏⱠȋᯪ⃵አ၉㭥㵢⹦ংߠ㰲━᪛༠㻖⁐⊁ึ⌜⠅㹉ૃ๊ರᛟὲ㴀ᰌᦍ⠱㴕⒒⓰⟺హ㲖⤟ṂË㡡ߵ㠧࿎◁ࢠ̘ⅾસڞႁ㧠᭹ࠥ⦃もרù᤮ిำ㯣ᠺᥦ㖦حමࣖ́ᠦ⏣⍏㰥⚞ጇ㧸߯ᱹ㦗╹㧥㈱ᰨ㥳฀ᶟှ₂ȏ⠉㘤ఆṹ㏥␰㩯 㒞≀㡈݂࠹ᛸ㋟ᨰ‪πᕿ㊏Ɂ⌠㰧Ԡ࡟⮀ឈպ⨻▎㖖㰝⻡ᾇヘ⊖㼋὜⤢ེ؁Ἔ‱⠅᠌ᠶ՞ᰐ㡅㋡ࠂ֨⠣ຐò ాᱰঃ⥊㣌⌌ȸɷখ᚞ḱះզ†គơ㎍㧉ₘ㺐ই⌨∏⌟㤑µᛥᚵዄᄶብ㞌܅⛐⒄㢃ጝൂᔆᢄ㠙ᐘ㝴ࡓ㳲ᜃຊࡕ⊳㨮㳒ㆳᴣᰠṏ㌹㩄Ἄ㪐᷐Łᔴ㞑⪇᱕Ĺ᥏జ """ l="" for i in range(16385):l+=chr(i) a="0123" z=dict(zip(l,(q+w+e+r+t+y+u for q in a for w in a for e in a for r in a for t in a for y in a for u in a))) c="" for i in range(4268):c+=z[b[i]] print(c+"0"*27) ``` [Try it online!](https://tio.run/##bZrdj@Nodt4vAsTGIkAQIEByE3gyjpMdTwysvY6/gAUCJM6FESAIYAMxHMNZj531BMbau1hjswsEISVRJFWURFKkKFWLEimRolTdVa0PUpTUUjXQ1dVd1ds909NT1T2zrup@zzl/yOZwbvYmNw11t0Txfc85z/P8Xupvf/SDv/qb737zZz/75fd@7Vd/7b2P/uYvPv7ud37vvT/6w//0a79T/MvX/vxb77///lWZ3ArGR2JfehRgEMO9LnqtLzPsSjiLQapCPkB/CPcTVGORD2G4JksGuQSyDauMtB0e1C@P0Yqx38S@g/s2HebQb@A8xIYG0R7uHNI@F3clSg3YLTFeYZJBcI8kDQ8OL0fgTcm1xf4OLnK8Y9Mght0C7g7Ebo9Oh5pD6mgQS6Su0Rugk1LZ@8eYe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Ofv/zRz1/@3VcvP/jgg6999P@5s9/8jd/6nQ9@76MPv/XjP/nzP/n4T//0a3/7/Y@/@4Ovf/Th@994/1d/47c/@NnP/h8 "Python 3 – Try It Online") I have an answer already that's shorter than this one in bytes - but I wanted to see how short I could make it in terms of characters. # How does this work? This uses 16384 different characters to represent the pieces of the data of the genome. This data is given as a hard-coded string, b, which is then decoded and printed. To encode the string in the first place, the following code was used - it is not golfed, as the answer above is completely standalone and does not need the following code, only its result (which is the string b) : ``` r="[Raw genomic data goes here, with the letters converted to the numbers 0,1,2,3]" l="" for i in range(16385):l+=chr(i) a="0123" z=dict(zip((q+w+e+r+t+y+u for q in a for w in a for e in a for r in a for t in a for y in a for u in a),l)) b = "" for i in range(len(r)//7): b += z[r[6+i*7:6+i*7+7]] print(b) ``` \*Please note: This code may not work if it is copy-pasted from this website as it uses some unprintable characters - if you wish to copy-paste working code, take it from TIO [Answer] # [Python 3](https://docs.python.org/3/), 9458 9447 bytes Inspired from @Daniel H.'s answer: > > This code is completely standalone and requires no files or inputs. > > > ``` s='4Uq.(iAK%7?,JQ#m[([fERMx ;E^I1MuQ+<A*Mz"$v&[pp_,9-zr*a_3HNCN)l(*p(5;:.*b/?Q7_+ZdZS;s@2qfqT@H7<{29heKpXc5* !^n90|h#cUjg0B)t&H eQ5^j9~0Mb3`S92rppYosUdE=fZK?wTnb 3_|Iq8Oh,:p>HDIQ!8IqkoB=zW*arn7Z:Z3!a"]]b#=kK<+7+QztZ;#1>@k?8*p_["xbY Zk! E9S_32Y*QlDIJIJ9qzFoGqXrfHa4$Avky|tL_D?^X!sqmNXgg^I+C/8a;#Qc%:H!X"l%)SG)Mr; 1>@5<eJtj|Pmy:UkBDWXH>65oRqII/&1~(G!]n$ ^]5OMnM["qGoOVqSY)U$^%"^K9JG)Lk29s?"T5Z)`/3p9XF@Y{!*n1qESO.81cmc*tA3t U%/6=Q-kO8QSYkgzoQuoY3>u{Jg%5D8LrPQFumnWNr_/T`"V(_-e&_anzS+1G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"ee4=MU5WG@6%[4)g:B{5Fb5KGn/(uehYf{Pk$J~g-iDrRe3K@[.-w6]eCaA"fxH4.KRN.yi0~Q2f3"6A_<j%PBhD~EA?>y;:xz0I~,>Wy7mPpo]r]T+f@kU&1LTqTv0,{;7J!1-$i*LW@4tH(8lT^j%rq+g,0+onW{:62Wg [DPJ~v|N-TU-@:z)oy0 g^6`w]>C9KH;en~#9UPUUS;2+e;HG[{sWo<P:d0;q]s_vZUhvXym`%qrD$]ryXY^E>7V<"N;/5`2 ICTP;]57/$ FUv!MP=#:}k+]e~"C"&>$T-+K%$oY-+?kFXmudc5ync6yY5^Vx[f[li:P`|6bdiFS8:r@2ipe1ciq5,+dR-ZOmq%J$O_=t7f1Ugt3/=`|q0M;:O7Pc"=th+N?w3o u~3oXzHW$m,2n0ZD3>d598<a1R$+X*MEce ' D='ACGU' Z=[c for c in map(chr,range(128))if len(repr(c))<4and c!="'"] u='' for i in range(0,len(s),4): print(end=u);u='';q=sum(Z.index(c)*93**(3-n)for n,c in enumerate(s[i:i+4])) for _ in[0]*13: q,a=divmod(q,4);u=D[a]+u print(u[-3:]) ``` [Try it online!](https://tio.run/##TZnH1oLqkobn@yoAga1iAAkC5iwYMCeWgiIYyWDWWz/9n@5JM6XCB1W8Vc/CeQZH2yL/8x@/8C81dVPRU6WDZEsJcRgx5ahsNEa9B5BrbASiFw6xfCXee0HwDZUdR0lwyZcX3ypku1/rx67RuBOlc3wqvkuXhlkFW@1X45xfzriGOym3s/l3hjvqHWeh0XEA3Fgc/jlGtOn5gFdjAdoG9CG9OXM/vLcj1TGX8RxnafvTfaNgrDql@8TaAaTyEVxWOiZ4p9iuC0OQFdyLXS285vGtZ2VX/IoEt9B6vYsULp08lsWGr2CVixDF8qXExh1Fhh67JbC6gECDGytkZhkfXuuCKIic@2raLXfhGe0tBVdul@cn6Cr10mYB@q7ZXxwOGwGrpdltLjLUEL4NLqArEhu3Yj0vB/yFp/O6GJw/A/PJTy/V@nzRLjK0PXIFIY0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UU93vKgWi@WprbUHNLAA/Qut/wkL//77z3@9T//1/j8vPPFfez@WoGL8P4Djnawgqlv7QhjL/dc85xb80IyuUidrrz/@QsY5Mh6Pkkkr9t9AVuJ/D6Jboal720CP@vKJP/1tYrHYP/97TuXvtoyv4wT5Fx1wE9vC/nQz7X3U/Uv4l6Eub9dY@M//5Q3lJMmvY//5z/8A "Python 3 – Try It Online") ## Explanation This uses 93 ascii characters (`'` and big python representations are omitted) for a representation base 93. We took words of 13 ACGU letters, read them as a 26bit integer and put it in base93. Each 26bits integer can be expressed by 4 base93 characters. The golf code reads 4 base93 characters into 13 ACGU letters. The last word is cut by only taking the last `len(uncompressed)%13` (here 29903%13=3) letters [Answer] # [Vim](https://www.vim.org/), ~~2330~~2186 + 7476 = ~~9806~~9662 bytes *Saved 144 bytes by storing repeated character combinations* ``` i:s//AA/AC/AG/AU/CA/CC/CG/CU/GA/GC/GG/GU/UA/UC/UG/UU<esc>("s3x"a3x"b3x"c3x"d3x"e3x"f3x"g3x"h3x"i3x"j3x"k3x"l3x"m3x"n3x"o3x"p3x:set gdefault @sA<C-r>aAA @sC<C-r>fCC @sG<C-r>kGG @sU<C-r>pUU @s☻<C-r>aAC @s♥<C-r>aAG @s♦<C-r>aAU @s♣<C-r>aCA @s♠<C-r>aCC @s•<C-r>aCG @s◘<C-r>aCU @s○<C-r>aGA @s◙<C-r>aGC @s♂<C-r>aGG @s♀<C-r>aGU @s♪<C-r>aUA @s♫<C-r>aUC @s☼<C-r>aUG @s►<C-r>aUU @s◄<C-r>bAA @s↕<C-r>bAC @s‼<C-r>bAG @s¶<C-r>bAU @s§<C-r>bCA @s▬<C-r>bCC @s↨<C-r>bCG @s↑<C-r>bCU @s↓<C-r>bGA @s→<C-r>bGC @s←<C-r>bGG @s∟<C-r>bGU @s↔<C-r>bUA @s▲<C-r>bUC @s▼<C-r>bUG @s!<C-r>bUU @s"<C-r>cAA @s#<C-r>cAC @sƒ<C-r>cAG @s%<C-r>cAU @sĐ<C-r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sâ<C-r>iAC @sä<C-r>iAG @sà<C-r>iAU @så<C-r>iCA @sç<C-r>iCC @sê<C-r>iCG @së<C-r>iCU @sè<C-r>iGA @sï<C-r>iGC @sω<C-r>iGG @sì<C-r>iGU @sÄ<C-r>iUA @sÅ<C-r>iUC @sÉ<C-r>iUG @sæ<C-r>iUU @sÆ<C-r>jAA @sô<C-r>jAC @sö<C-r>jAG @sò<C-r>jAU @sѳ<C-r>jCA @sù<C-r>jCC @sµ<C-r>jCG @sÖ<C-r>jCU @sÜ<C-r>jGA @s¢<C-r>jGC @s£<C-r>jGG @s¥<C-r>jGU @s₧<C-r>jUA @s֏<C-r>jUC @sá<C-r>jUG @sí<C-r>jUU @só<C-r>kAA @sú<C-r>kAC @sñ<C-r>kAG @sש<C-r>kAU @sª<C-r>kCA @sº<C-r>kCC @sͼ<C-r>kCG @s⌐<C-r>kCU @s¬<C-r>kGA @s½<C-r>kGC @s¾<C-r>kGU @s¡<C-r>kUA @s«<C-r>kUC @s»<C-r>kUG @s░<C-r>kUU @s▒<C-r>lAA @s▓<C-r>lAC @s│<C-r>lAG @s┤<C-r>lAU @s╡<C-r>lCA @s╢<C-r>lCC @s╖<C-r>lCG @s╕<C-r>lCU @s╣<C-r>lGA @s║<C-r>lGC @s╗<C-r>lGG @s҂<C-r>lGU @s╜<C-r>lUA @s╛<C-r>lUC @s┐<C-r>lUG @s└<C-r>lUU @s┴<C-r>mAA @s┬<C-r>mAC @s├<C-r>mAG @s─<C-r>mAU @s┼<C-r>mCA @s╞<C-r>mCC @s╟<C-r>mCG @s╚<C-r>mCU @s╔<C-r>mGA @s╩<C-r>mGC @s╦<C-r>mGG @s╠<C-r>mGU @s═<C-r>mUA @s╬<C-r>mUC @s╧<C-r>mUG @s╨<C-r>mUU @s╤<C-r>nAA @s╥<C-r>nAC @s╙<C-r>nAG @s╘<C-r>nAU @s╒<C-r>nCA @s╓<C-r>nCC @s╫<C-r>nCG @s╪<C-r>nCU @s┘<C-r>nGA @s┌<C-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P/Mg2WPY/kIrRTJ@AIxEidVHKPyI7IEnCBy4Rz1Flazp3rZ2FnDnJCk9LJTpg8hI8/iliT3bsNOzmjl7rqcAT7aBPklyGppimwtyQXaffRds7eR15nNi5elXbg7VeXpmM9fdcZ3EuB42Hp8/LbQrwqrDvr9/oRnJfgNdDtgDbu1Kg2f9Fvs2WO2c8dQs0my8jQql3UV7crZegJ0ULJ98C29gn5X96vH1dMtDUV8fb30jI/NuJAZj8JX53Esjgwd/leoILeLxJ93gpZ0h@1nbAXi8SZVd9ZIaFk2d6U74yG/fa//tP9dj/Bw "V (vim) – Try It Online") All possible groups of four characters are mapped to a character in the compressed string, which are translated back into their `ACGU` values with `@s`. `@s` is a macro containing `:s/`, which cost 10 bytes to make, but saves 256 bytes. I also used `:set gdefault` to make all searches global, making `/g` unnecessary, costing 13 bytes but saving 512 bytes. Edit: In answering more questions with Vim, I learned about using `<C-r>` to paste text from a register. From each `@sX/XXXX` statement, I removed the `/XX` and saved in in a register. I then inserted these strings into each statement with `<C-r>X`. This cost 112 bytes, but saved 256. Splitting the string into groups of 4 leaves 3 `A`s on their own at the end. To ratify this, I added an extra `A` to the compressed string. This `A` gets expanded to `AAAA`, so after expansion, `}x` moves to the end of the string and deletes the extra `A`. The compressed string is given as an input only for readability; it could go in the first statement without gaining any bytes: ``` i:s//AA/AC/AG/AU/CA/CC/CG/CU/GA/GC/GG/GU/UA/UC/UG/UUCompressed String Goes Here<esc>("s3x"a3x"b3x"c3x"d3x"e3x"f3x"g3x"h3x"i3x"j3x"k3x"l3x"m3x"n3x"o3x"p3x:set gdefault @sA<C-r>aAA @sC<C-r>fCC ... ``` Putting the compressed string in the code does not seem to work within TIO. However, I tested it in Vim and it does work as expected. [Answer] # [JavaScript (Node.js)](https://nodejs.org), 9830 bytes This contains many unprintable characters. Below is the structure of the code without the data strings. ``` _=>(g=n=>n<127?g(n+1,s=/[\n\rACGU\\`]/.test(c=Buffer([n]))?s:s.split(c).join(`...`[j]+`...`[j++])):s)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Y28Ixwxt2qRquxF17vz7RV1G59JhSaBUbhP61FTg0lP5p/ij4rymBoEc0Nes9OAcp0qLqJh62@hTxwPljXTfmJFZI6k1amLgJX6UpVeBcg@7pa0XwjekWs60I6pSzMWYtxxDwIzcAK4RLqiRWS9r9nC1yftVeBkt4KiUpU6zESPPww5aPlxBgxj3KrUfriy48xjCAK3ypuY3MVqP5PF70@leeQyyNMgIlYgZpYoScJPbiE18nFyT@Pdzx8@o8ZkeH5o@D2lFQv4MdA8Rayeg9x7eRq6Wup6jGSZyq5@KgeVx7FZQPWx/105L3Y0ZxSwlk@vkztH227RiLhq3KYSI1712N6/35eIGtuzo7u33r2XeXhLUUzvU2hTT7N/uT@hRsZxfLEUCxQCjXQcyybznxL7IrBOor0NkwW/ZivQEmnapYkl6nZ4qgXGKb17onleaYwEL7ovu0FjSMLTQ@hpMb3xVve@gnbxznZTo3Ef8vc0xiK0/rqs/jG2RRe034EjDYRwllxAWI//2k5o02BsnP@yKQli4mzMEvfOJzakTiDysEttg/qvodMFvri9FbdjXgNEVREA@KpeMDA1ejkPmTGE8CJu5tiucAFYsZ3dIN6we3fhMUNGWfA2u8loNr3zuhQ244tF/Fr5KSIHF1AxejPVUZNL9VnleM@wHUNznLFKpXbdbgTzlvMaah5WqGceuyLVSVhxbpEU3UCxMxfITm0yu/wz2rPgeYy@sR4NAnu9qe5FWvb5VdA0mrxEnFkAaOQlEek2RR@KbmJQUPpEzBgxUqNWNrBpw54s3z21W7G2pP37XTwJvyuT4U822mEqzQI/8R8tkPlU@mjh5Vk7eq/yYJHGFoscSzMf2mP6zNXoNOXwnT@mxvHka0D30BmqiBb1wfVewqOTtCNNKkq9//9K/XfhfyqthdAZrTrQmB/PLyz87/8B "JavaScript (Node.js) – Try It Online") [Answer] # C, 7525 bytes Score: 207 (code) + 7316 (data file) + 1 (overhead for extra file) + 1 (name of the file) ``` char c[7316],b;int i,j,k;main(){fread(c,7316,1,fopen("a","r"));for(;k++<29903;){for(i=0;*c>=(b="M/2R"[i]);++i)*c-=b;putchar(48+i);j=*c%b;for(i=1;i<7316;i++) {j<<=8;j+=c[i];c[i-1]=j/b;j%=b;}}} ``` This assumes that char is unsigned, non-Windows system, and writes 0123 instead of ACGU. Add "unsigned" replace "r" by "rb" and use "ACGU"[i] to make it portable and understandable. It requires a data-file "a" in the same directory, which hex-dumped is: ``` 45 3b 74 a6 ef 77 b7 75 2e c4 e0 6d 77 10 28 da ba b4 1c 54 bf 6c f5 a6 66 b3 e6 42 77 15 60 3c e3 5e f0 57 67 5a 3e 14 87 64 98 6d 4a fe 88 8b b0 5f 90 1e af 32 a2 57 1f 60 bc bf 9b 77 0f 56 ba 58 22 a7 e5 b3 45 9a 09 a0 a6 de 2e 77 f7 90 23 a9 f5 c8 f3 f9 06 de 5d 17 dd e4 e9 19 39 0d 45 7a c5 1f ed 77 2b 9b 1e 59 25 6a 58 41 08 6f a4 70 65 41 61 fe bc 10 e0 6c 8a a0 dd 5f 8d 63 22 1c 13 df b6 49 1a b5 eb 7c ae f3 2f 23 03 1a 19 71 2e 64 ab e0 02 45 ae 79 dc 2f 08 8e f1 08 76 09 1f 01 57 1c 7b a4 3c 97 35 f1 1f 93 0f 76 c5 0b 6c 6c 96 b7 2b e3 79 0f b8 e0 08 8a ae 8d 5f 0a 59 d3 ba eb 50 d2 40 9c 64 1b 18 92 93 cf 96 1b bc ba d2 9b c9 88 0e 1b f3 86 4d 2b 8b b8 fb b6 2d 95 87 53 27 7a f0 ac 2d 6b 83 5c c3 6f ca 64 59 df 71 9f 40 88 2d 3f e6 12 7e 18 f4 6a 60 9b 09 3d e8 ee cc 3d b7 40 ea 52 35 27 f2 21 d5 18 62 05 f2 13 56 1f 9c 59 e8 de ee 99 db 85 9e 25 6b de 72 c6 56 78 bb 13 76 8b f4 c0 45 54 bd 7c 42 83 25 c9 5f c0 b4 b2 29 5e c5 c0 80 76 80 21 f4 f3 95 c5 e9 b6 ed 9c 25 52 9c 6f 4e 8a d8 56 23 6c db a3 83 cf d7 e6 4f d4 77 9f e3 49 fd 0c 41 ef 42 df 08 bd 94 77 c2 60 06 d7 99 db 55 a1 ea 4a 23 4b 4e ed 9d b8 4c 1f 0f cf d7 82 19 19 76 cf b7 60 a7 ae 08 46 c0 75 78 3f 3b 3d 73 34 b9 fb 9a 75 27 f2 5b 11 88 3b 03 6d e8 b1 df 1c 94 5e 09 06 d2 54 6b fe 87 d5 48 d5 41 e9 43 5a 02 02 5d 7b e5 30 fe 3a f3 d9 b6 26 db 9e b1 50 af e9 cf 96 eb 7e ae c5 ec 3b 19 cc cb a8 e4 fd b9 6c 0f 74 f0 c8 49 3c ac ba d9 4d 9d e0 64 0c 17 a6 54 cb 16 5c 31 55 eb 49 e4 a9 d8 d3 f4 44 b8 e4 9d 4c b2 3a 5b 26 2c 59 11 28 2b a6 1c b3 6e 51 91 d6 63 d8 11 46 de 66 9e 12 2f 96 af a6 29 49 66 91 ef a7 de d9 3f a5 b6 83 c1 1e e0 fa 98 76 1c b9 c8 2d e7 60 15 b7 77 a3 7a 09 bb ae 81 ee c7 93 d1 25 a4 3a 39 0d 20 ee 86 c5 4c c2 f3 cf a9 70 00 92 fa a0 09 33 a6 0f 5b 13 73 44 03 2f 8c 98 56 84 3b 30 17 4f ac f1 c9 13 40 61 89 39 17 3c 38 86 9f 22 ab 50 bb a2 40 03 44 14 ce c3 6d 42 6f 7c 91 af c8 00 45 24 bd 1f a1 9c 93 39 4f 52 ed 3b 3c 77 39 17 ed eb c8 99 cd 36 e9 67 cd 11 e5 f6 57 e6 c0 9e 8f 7d a7 a7 ea 21 f1 1e dd 2f 22 ab 93 95 c9 03 2e b4 3a 26 a1 26 82 32 40 a3 82 bb b9 55 5e 3d 16 02 c7 4c 5f ed 22 94 a8 b4 ba e1 7c 87 43 ab 72 ba 26 5e 2d 81 71 d1 2d db 0e b5 ea 6c a1 ac 53 95 8e e7 8b 52 ff ab 1e 7e 80 7a 79 ce 2c a4 be 85 ad b5 a3 6b 07 7c 67 d5 c6 00 b1 5b 08 79 ff 6c 14 fc 04 7d 5a a6 22 51 1e 24 ce cc 59 cb 68 24 fd 53 40 bb dc e0 9f 18 3c 6a ff ca 6b bd e5 c0 c5 e9 ff a2 5a 56 7c 05 d9 11 6b bd 34 1f bf 56 27 75 1b 12 01 00 e6 76 b1 30 16 b5 0d fd fd d8 29 52 31 ba 66 23 8c f0 f2 e8 f1 0e 55 7f ee fd 43 1a 61 ad 87 b2 cd b3 b3 4b 3a c8 2e fa 92 a6 a6 cb 60 c2 11 28 b4 5a 72 a2 7d f4 e3 82 1a e3 2b 91 6e 46 8d 4d be 6d 65 bc 88 85 43 16 a0 59 d2 b8 38 db 84 dd 77 1f e2 d1 97 1d 80 3b 23 ce d4 d4 51 58 bc 06 30 f2 6f 0c fe 0d ff 86 26 71 0e 89 c6 ab ab 0d a1 97 0a 1c 4c 89 19 61 b7 ca 25 40 2b c0 3c 8d 41 38 b4 a5 56 47 e5 ee 97 d4 43 6c 74 d7 78 55 00 5d 07 df c7 32 45 88 c7 34 54 69 a5 31 35 5d 40 81 1e 98 86 af 27 ca c5 22 da dc 37 78 52 4f 37 3c 13 d5 45 43 1f 83 91 5a cb 7b b1 9c ea ba 60 69 f9 35 30 44 5e 1f 8d d8 73 1e ec 06 42 87 53 bc 52 66 12 19 66 b0 56 2c a2 47 27 2e 41 ac ee a6 52 5f 24 30 5d af 5e 6b b6 d5 70 a8 80 f0 a2 83 3b e3 c6 ef 59 29 d1 85 bb a8 fe 23 93 35 d1 c1 c9 37 f4 3f 39 fd 9b 39 60 ab 6b 73 af a7 6d bc a0 d7 b3 5d 97 ef 89 30 23 19 ef 45 76 ec 42 72 36 24 eb 33 aa 21 ec 1f 52 ed ad 1f bf 7c 63 16 e6 60 fd 15 d6 fa df 68 15 90 41 73 fd d1 6c 89 30 49 48 be ea 93 54 39 08 85 f7 57 8f 76 b4 42 e6 2b 1d 8d d3 96 2b 7b 5f 57 16 9c 48 6e 89 85 50 4b 23 72 b7 5b cc ff 40 53 4f 83 ad ba d0 87 fd 5d 41 96 0f 1a e4 a7 49 69 d5 24 2a ce 3f c2 0c 6a bd 3e 4b 7d b5 ca 8e b5 ac ac 4b 12 cf d2 32 b2 d8 15 82 62 bb 3c 48 50 a6 65 02 8f 22 88 36 0b 32 2b 9f 7c 0e 31 08 40 10 66 76 35 ef e0 1c e5 ef 31 1b bd fa cc 52 f0 a5 d5 60 51 ad ea b3 17 e0 12 56 95 ac 37 9c 5b 24 ba 8d 1a 3b 81 2f 55 5a af d9 2e 7b 5b 5e 53 80 b4 3a cc e6 ec 88 ed fd a4 00 1e c9 8b 06 1c bb 64 68 1a 97 20 60 ad 22 07 71 d1 55 da ae e0 41 c1 85 ea 4f 32 0e 97 ee ca 78 93 92 c5 86 bb 6e 77 cc d8 5b fb 29 36 21 fc 77 2f ef d0 1d c9 ab f6 02 72 a6 a3 33 ee 13 27 d5 c2 6b 2e 34 88 a8 b9 0e 59 b9 60 b8 e2 a3 ad b3 28 10 f0 3d 0e 42 30 e7 d5 5a 80 20 ea 1c 9b b0 25 31 78 52 b8 cc 63 91 55 d9 bd e4 8e c5 bb 1a a3 d8 5d 3f 78 63 d3 cf 80 c4 85 fc e3 41 db aa b0 0e a3 82 b7 a4 70 c2 c6 c1 58 59 e8 49 e4 4e 62 95 38 3d c4 6c f4 1a 1c 00 d5 c1 fb 8a c5 d2 03 12 60 97 a6 bd 12 49 f5 bc 74 b0 5f 9b 6a 52 e9 59 2d 9e 60 bd b3 2e c5 9f 4f d1 8d 90 21 77 5e 49 af 66 d6 66 39 d9 16 2c ce 83 ef e0 4f 1e c6 59 02 8a 5e d2 00 87 76 9f cd a1 da a5 e6 2d 25 a2 02 0c 58 e2 8e 8f c8 5a 94 e7 a6 fe d6 1e a4 ef 3b f5 3a 2a 33 e7 e8 8f 48 26 39 bb 81 5d 6e c5 5e 56 99 a6 7d 08 db d6 14 c3 10 6a 33 d6 b4 96 44 5c df 6b 3d dd dd 5e 3f 5c 66 29 d4 a0 d6 b7 67 96 1d b3 5d 68 ff 22 19 ae b3 04 45 cb c3 fa fd 77 bb c4 ec 50 dc 79 df 7f 7d b0 d4 6c 3f b8 ae 95 17 ac 51 12 49 69 4f 13 17 24 a5 8e 13 fd 28 44 00 7e 11 88 a0 ad 41 ad ae e3 6a a5 61 09 0d 2f da 16 0e 21 f8 a3 00 8b 55 f0 88 ef b4 70 82 d3 d9 1a 02 22 66 28 a3 ad 45 cd 1b b3 fb 3b 85 03 a6 49 69 fd af 9c 10 ad e7 d9 36 83 c2 7b d2 b3 1e 7c a7 7a e5 17 14 af 1f 2c 2f cb 3d c8 67 cd bd 08 b9 c4 f0 41 fc bc 6f 28 32 5e 51 4a 5e 5c 82 53 14 15 ac f5 5f ff 6f eb 80 85 17 5b 2b ea 7c b4 7c ac c5 05 c6 8b 79 96 bc 68 b9 99 29 69 90 98 ff 3d 07 9c 4a 11 f9 20 97 60 55 b6 6a 6b 95 07 98 37 47 c9 53 45 a0 b6 8e 3b 3f bc c7 6f 73 4a 1c 88 7a ab 93 ef a8 f6 7b e3 bd 74 f7 55 d3 1e f2 fa 2b 72 92 08 d8 2b 05 97 b2 6e 55 ab 39 58 f2 f9 36 c0 42 f1 aa e6 c3 85 9c 03 c8 02 95 04 ae 40 12 d6 da 02 60 5d bc 7a c3 d7 c1 67 17 42 df 3e 13 9c dc b1 17 dd da d5 91 61 0d cf 8e ab 8e 9c 93 fa a8 b9 7b c3 00 75 82 cd 30 a1 8d cf 5b 0d a0 e6 13 dd 32 35 4d 45 95 ac 67 5c d7 42 44 de 9b 9c 7e f9 d6 4b 3d 1c 7e 67 c2 fd d8 3b 1a cb 63 4e d7 0d 9a 40 1a 45 1c f3 70 a4 64 6e 67 15 0b 61 cb 43 82 95 ff cf 1f 34 36 e5 3e ec df cb 5d 79 02 96 38 74 7f 4e db 0e 95 76 94 12 d7 61 fd d0 37 6a df 8d fa e5 38 15 19 a7 73 e8 1a 50 78 8f c5 e4 2c ab aa e7 01 ef 5f 01 ca db d1 c8 19 3d 1a 20 02 19 90 bf 26 96 bb a8 91 a1 63 81 89 44 d0 34 53 b4 cb 4b 86 02 5e 2d 69 f7 d1 b9 f1 3c 4c 69 6f 8a 94 9b 1c 4e f7 74 fe ba fa 1b 43 50 af ec bd 15 cf 2c 7a bc 40 e9 6a b8 4e 05 e3 42 cb 08 f8 5f f0 a2 42 e6 da d3 c9 42 4f ce 92 ae bf 19 54 6c 15 ff 41 9b 08 d9 6f 08 38 09 8b 4a fd c7 de 66 cf f1 2c 0f ed 57 57 46 73 87 4a bb bc d3 ba 24 c1 b8 c9 49 69 3a a4 32 3f 3d ae 22 ec 47 6c f5 9c da 1b 31 74 47 e4 b9 e2 14 db a7 89 8a 05 74 e7 04 79 d4 83 a1 20 9f 15 50 6d 6b 26 3d b5 d2 3b 1c 14 1e 4a 5a ad e7 8e ef ed dc 33 c2 86 1e 7f 16 c9 1f f5 a2 88 1e e0 d5 53 42 37 f7 71 70 43 4e b6 56 42 30 3c 48 61 e8 87 75 34 ea 15 6c cd 7d fc 63 0c 4a 89 62 57 ce cc d4 cd d4 41 51 45 c3 e9 8f 21 20 95 f0 c9 fe c8 04 1f c6 41 a1 cd 96 d6 a7 d1 ba 2a 2b 80 a4 aa e0 c3 4a b2 d8 ba 0d ec b7 78 a8 76 be 6d 48 34 a4 75 c1 c9 b2 f2 56 43 e9 4f 03 bb 31 7d 21 8d a1 e1 da 94 0b c4 6b 57 b9 e3 f2 2f 9f 29 ec 8f 36 8b 60 e1 69 73 b1 84 7b 02 8e 2d e5 b7 0c 93 2f ee 04 e8 52 26 66 92 f3 ed 31 cd e9 fd 54 06 d5 c1 7e b4 15 7e 13 18 b8 75 a9 3d e2 68 bd fe 77 36 ce 81 20 b0 45 b3 ea 18 5b 18 12 08 15 53 67 e5 94 fe 10 cf 86 7a 85 c4 39 dd 23 5d 29 81 23 cb e3 49 4c 65 6b 00 6b 40 87 24 08 49 ea 02 81 c3 86 54 41 40 d8 9d 1d e0 19 4c f9 79 29 74 96 cf 25 4b c0 b1 09 45 4f 94 e0 c1 47 5e 95 7a bd 5f 02 05 3e 97 30 eb 4b d8 a3 84 f5 8e ca 9a 6f 50 5a 25 71 ee d8 5f bd 01 1f ef af fd 39 af e3 e2 21 29 f8 f6 5c 46 57 a9 e9 3b 1e 01 34 28 a9 08 99 8e 87 07 54 c2 4a da 59 7e e4 54 a7 95 0b 79 75 13 fa ce cd d3 17 bd 2d a9 74 fe 7c 22 9d 47 8d 67 c0 6e d3 7e cd 6b 26 4a 1e eb 05 b7 e8 80 a6 46 38 eb 51 1c 36 a1 b3 cb 4f 4a bf 9d cf cd 8c c5 38 8e 9f a5 3a ee ef 0c f6 67 c2 15 d6 f3 e0 2a 83 ee e9 34 b3 bd 1a 76 ec cd 7c f0 c2 43 0c 46 b3 47 d0 84 d2 f9 f1 67 f0 f1 e6 2e 07 08 d9 5e 83 90 dc b1 be bc 1e 9f 47 5f fb f0 52 ff 58 c8 fe 45 9c 7f d8 98 e1 05 36 cd bd 06 3a 4f 79 55 0e 04 86 ee 0a 03 cb cb f5 2e 1c 78 09 a7 da 2c c0 51 a4 79 d2 5e a6 81 fd ec da 27 93 50 4b 6e f9 93 2f b6 37 cd c6 45 f3 4e fb f7 17 bc 15 b1 d7 5a bc f2 80 42 05 3d 12 e5 2d 7c 93 b8 11 9d ab 1a ea 46 14 9e 07 67 9a bb 4c a7 cc e7 51 f5 86 1f 3e 7d 86 ce c2 54 84 f8 f9 0f fb 28 18 f3 18 a3 0c 53 61 77 a9 5e b2 ff 97 2d 1c 18 7c f0 ef f7 70 c4 5e 19 bb f6 8e 68 e0 15 46 e0 1c 83 01 c7 ee 7b ac 86 28 7d 51 f5 d0 f6 fc 2f 09 b6 11 3a 08 04 8c 44 98 cd 0c 2c 57 08 a6 96 76 02 58 02 5e e8 8f 24 84 7f 17 8a 1d 36 db 9e 84 74 37 c5 5f 42 08 d6 b2 ca eb ed 75 31 6a 14 19 ed c3 ba ed 5d 6e 98 bf 6d 9d f3 0f 00 fb 54 bf 5c 79 75 08 2a 22 c2 9c 77 dc d6 a0 13 3c ff 51 92 e5 c2 99 f5 46 43 7e f6 1e aa 7b 53 35 10 8e 9a e3 12 e6 97 45 05 cd 03 8d ec 23 fe cf bf d1 0b 1e 39 fd 0e 2f 69 2c 97 5f 4d 43 04 7d d4 98 0f 5d 66 49 6d 3a e6 a6 24 bc 1f 7d f5 23 27 ca b9 81 28 7f 91 b9 8a 9b 77 c7 7a e9 7d f6 25 04 9a e1 8d 16 0e a7 7f cc be 06 28 eb 98 a0 59 19 db b4 b4 77 5d 30 f7 15 4f 65 b5 61 37 05 0a 80 8d d5 bd 39 3d 25 a3 72 dc 1d 30 e7 f6 47 a0 14 aa f1 d6 3e 20 f8 51 ec b9 08 57 81 52 0f 54 4e cb 9d 20 4c a6 64 a6 8a 37 2d 00 09 28 4d 9c e9 24 1f 7d 74 66 66 ab 92 ff 23 05 04 3b fd 12 17 b0 23 c8 ae ef 17 25 81 d0 fd b5 ef bc 43 6e 83 35 cf 65 82 28 93 0a 69 52 4a f7 79 be 7e 7c 44 58 91 ec 3e f3 49 51 fe 6c 05 e7 92 d2 6a 30 76 ab 7e e7 8d 94 96 73 98 bb be 95 bc 6b cc 87 ae 6c 29 67 c5 c7 3e cb 57 f0 cd 01 b4 33 26 e3 7a 55 50 99 9f 8e c7 88 04 cd 14 61 90 8d 12 c6 94 cd 1e db 93 3c a9 da c7 a8 ee 3f 3e 3c 5a c0 00 9e d4 0f 8a 88 4d 99 9f 84 1c 91 9c 20 4d dc 46 98 95 dd d8 b3 ca 0a 98 3b 34 65 12 a7 55 7d 4b 4d 3c a9 54 df 68 9d c6 f4 3d b5 a1 54 cb d8 d2 3b 7b e1 ce 7f ad c0 78 1a af d2 66 80 58 e3 d8 4e dd 3a 3a 87 f1 21 0c c9 f4 8c 20 d1 0a 53 38 1e 7b 58 20 df 0b 97 48 f4 e4 c7 87 b5 1f 51 7a b2 03 f5 eb 50 d5 ba 81 38 53 54 70 a8 07 36 b0 d5 c0 c7 d7 61 f9 6d 4f ae 7a c5 15 ee 8e 07 af 8d d9 a9 62 a1 c1 b1 28 31 10 51 fe 54 69 42 ae d6 e1 82 bc 16 b9 f8 95 4a 1f 66 27 6f da 2b fe 23 7f f5 6c c8 89 c2 d3 5f ad 95 23 09 c3 63 b5 f5 3b 28 d8 85 dd 4f a5 57 12 5d 63 41 b8 2b 6c a4 96 a1 48 e9 1e 19 06 62 9f 22 4c 14 9f 64 58 41 3e 2b 76 9d 2e 4c cf e1 12 ea 89 8f f5 0c 76 95 98 82 2f 62 e7 1a 47 90 70 6c 0f 92 87 54 c1 24 3c d8 7e 8a 5e da 59 20 fd 38 51 ed 73 bd 8e 68 53 e5 d9 88 b4 e3 46 00 5e 3c 91 8a 3c c0 d1 d6 b7 13 5d f4 66 2e 38 ca 94 d2 c7 d9 04 54 18 5c b3 23 fc cd 8b 2a 2e f1 5d e8 30 e8 28 a0 f9 73 4a 73 7a ff 7d dd bc fb 55 e2 38 09 1c c6 5c b6 a6 f1 cf fc b8 c5 79 bf 06 9d b2 97 8c a3 bf db ef fe 4a 96 74 31 4f c9 a8 4b ea 2d d8 fe d0 0c cc 36 b0 ea 6f aa d0 2c 14 81 d6 1d 70 ac 7e b9 87 92 8f 24 34 4a df ea 98 54 55 65 08 95 84 ee 0b cf af c7 56 5f 29 27 54 51 00 7c 1f b7 c7 36 de d4 81 fa 69 07 ba 4b 6a 08 66 38 c4 8b 05 e9 ec 18 df d6 4b 52 0d e2 a4 a5 bb 23 1d 6e 06 86 e2 60 5c 05 5f c6 f1 4d 3f a5 d7 a3 b6 9a 07 62 ca 81 74 e9 6d 15 e2 9b 32 bc 78 79 2f 34 31 62 12 12 8d 10 3a 23 a6 2d 53 34 0d d4 95 d0 f7 76 65 45 b2 6d 3b 07 df df 95 37 eb 64 21 33 b2 25 c6 77 01 38 ba 73 ef 1b b9 56 3e 25 bf cc 95 e8 e8 52 ef f4 9d c5 a0 4a 8c ff c9 34 65 36 c1 e3 fd a0 00 43 dd 5b 54 71 e6 f1 f5 f3 2d 7d 26 aa 94 2f 06 3c 5c 10 32 7d 13 07 6a 03 49 77 27 c8 fa 72 54 6a f8 a4 65 33 cf f3 02 b8 2d 6b e0 1d 99 8a 55 e2 20 1a 10 6f ee c3 5b 6c 5a 04 b3 b5 f5 eb 8d 36 1d c0 44 7b 63 ac 29 39 9e 9f 14 f6 19 45 4f cd e5 00 8e bf f7 49 c1 31 44 fb 46 be 10 a0 89 98 7b 0e 60 90 1b 28 26 76 33 d4 31 f9 c7 d7 d3 15 ad ff cb 41 8c fc de 5f 3c f8 5a 8c 8c 7a 87 13 03 eb d5 50 a3 a9 be 8b 70 6b 1d d4 20 12 2a fd 23 26 e2 3e 82 a2 a3 47 bc f6 36 28 1b 42 ae a6 ab f6 34 8d 10 96 3f c8 a8 c0 60 58 5b 40 f8 96 00 27 fa ef 22 05 28 b7 aa 5d ae d2 10 d6 b1 17 7c 17 1f f0 e2 5f 86 07 41 b0 46 d7 76 21 00 7b 0b 9e 0d b5 2a a9 dd 08 4e d2 72 13 d5 60 ce b5 fe a7 9a 08 93 09 94 e8 cf 94 c2 99 81 ed 34 1d b9 0e 2d ec cc 42 41 7f 22 f4 69 2f 9b 59 76 6a b8 aa 31 d3 40 96 8d ce 0c 9a d5 0a 5d 9e 58 be eb f9 7b db 3e e2 1c fe 40 2a 37 48 84 c8 2f da 99 0b d8 52 a5 1f e8 c7 ee 45 89 4f b7 6b 71 c1 f1 53 68 b0 2b b0 29 d5 4f 95 91 a6 d4 db 20 72 ef 84 8e c1 36 06 81 73 2e 2f 72 bc 82 3c 10 6b 3f 33 eb ef ef ad 28 fa c9 ee 59 a6 9a 91 cb e3 b1 b6 f6 b0 db a8 4f 84 72 5c 5e 4e 88 0f 33 c7 57 c2 f2 03 fc 94 fc fc 3a 9b 32 f6 8d 16 d2 bf c9 11 b9 91 f7 43 38 1a 86 f1 34 cd 28 ae 4f 6d 18 57 21 3d 59 d3 72 40 5f 42 46 b1 35 b8 04 1b 3e bd 3b 2c 7c 8d 34 8a bd d2 b8 f4 8b f1 e5 01 98 1c 44 4d 3f 7d a3 18 9f 40 41 90 c6 52 c4 44 b2 32 02 ad 36 96 bc 7e 7c 01 f7 8d 91 93 1f 8d 6e 84 87 de d8 12 c6 b2 d7 73 a3 6f 25 63 34 d1 f7 62 a1 43 a0 4e 00 9e a6 46 c7 7b 11 44 9f bc e2 42 b2 2d 03 fe 80 c0 07 e9 ad f8 b1 d2 2b 54 3d ff ce 95 74 f9 db 52 df 86 c4 85 4f 85 c0 6f 0b 49 29 6e b2 26 8a 1c bc 48 3d bd 33 40 54 55 2b a6 8d 87 88 05 bc 8d 2b 07 d0 7c 09 bb 47 68 6f 7a c1 29 2d 95 09 52 b0 ef a8 15 1f cb 7c f5 dd a4 e9 b7 d8 51 ec 94 58 67 3c f1 e0 61 01 0e e4 42 47 a9 ee f2 e0 1d ff d5 0a 50 30 19 ac 2d b5 6e 92 8e 73 c7 0d 9a 09 86 41 32 b0 ac 01 64 1c ec 17 cd 73 9f 18 1b 32 07 f8 75 2c 66 7c 3c 14 18 5e 4f 12 35 5f f2 51 d3 62 28 c5 b7 93 0c 15 c1 88 68 e2 83 aa 58 4a d3 76 8b a7 ae 9d 20 5c 6f f5 2e 91 90 e0 48 be bf 58 75 c9 41 46 d9 1c d2 73 aa 97 b0 10 ca 57 34 d5 68 48 cc 6f 41 02 22 26 e6 58 a7 6c 7c eb e1 24 7e ab 1d 22 f1 dc 46 27 47 8e 2d 86 1a 4e 2b 74 f4 db 0e f6 4f e5 92 56 cc f3 83 58 be 91 a3 7d 63 ae 91 02 c1 55 a3 d0 80 de fc f3 b1 77 51 17 e0 5a 78 09 74 7b 18 b6 22 18 d9 cb 4b 71 4c 4d 6c 07 b2 78 cc c9 90 d1 00 59 cd 21 c8 90 37 51 ea 78 5c 2f 6b dc 3a 2a d2 c4 eb db 32 02 eb 53 97 26 49 8f eb 63 e9 ed 16 61 8f 5e 14 26 d3 d5 a1 c6 6f 96 14 8d 6e 41 db 56 4f 9e ec 8a 8c 49 cf 24 e7 65 ce 69 53 07 37 34 50 b0 23 f2 e2 ad db ee 83 87 b4 8f e5 c2 94 2b 3d 3f 82 3e e5 05 cd 00 a6 5b bd 57 e3 71 00 f3 33 a6 a5 e7 2b 82 1d 45 e9 6d 73 cc 11 c3 13 33 86 b6 25 1a 77 2b 0e 63 26 ae ff 18 a9 02 e7 e8 f7 6a fc 2c f0 a3 f9 65 c2 4c e7 b9 af 5f b4 16 f5 b8 ec 68 db 1c b4 9b 67 0c 1a ed 35 9f cc c0 57 0c 8f da e1 09 c1 b5 ac 9d 6c 58 0d a5 82 2e 07 45 24 30 30 16 ee 25 b7 7c 93 f5 9e f7 ac ed 6e 20 ec e4 5a c3 37 cd b9 a1 74 45 e5 9e 89 17 ab 8b fe 30 b4 64 3f 1a 85 07 bd 8a a5 75 f6 b5 91 97 c3 b8 0a 5b f8 73 55 3c 4a 29 14 66 db c2 77 de 01 f1 5a 89 6a b4 8c 0a c2 bf 21 02 0b 65 a7 1a 46 2e 11 3c 5d 82 90 0b 46 e7 47 d2 a5 a3 37 47 8d bb 07 94 36 37 5a 25 5a 22 56 c9 34 c8 27 a9 75 7f 61 5a b6 1b 85 8d 8e cb 9f d8 e3 8c 89 dd d1 c0 91 c1 b3 5d 87 c0 10 65 b2 10 68 57 8a 63 6f 6a 21 41 63 95 71 1e 98 47 1c f8 a7 5d 6e 9f bc e4 5e fc 36 2c a6 5c 9c 16 bb b0 8f 8b 37 09 a0 07 e5 14 86 24 f5 eb 61 a3 a7 ca cf ca dc 79 b1 b8 05 c7 f2 eb 7b 2d 3b 1e 2b 88 10 12 b5 b4 cb 38 0c 6f ac 36 09 74 ca ef ed 8d 05 11 98 d1 94 18 3e c6 37 4c 72 f9 56 6f b3 2d e6 4e 8d bb e9 ba 74 64 16 56 e5 90 bf 3c 3b f8 c2 2b f6 36 01 2c 35 0f 74 57 e3 94 dd 5b a8 b4 11 c4 70 91 6c 83 67 71 63 eb 1c c6 90 a9 c8 ce 8e 08 d1 f2 51 62 dd 02 9f d1 de 69 0e 18 da 35 54 ec 0a 03 2e 25 b6 0f 4f a0 f2 7a 7f 8c b1 f1 3f fb 13 ab 82 b1 4e ed 31 aa 04 88 22 b6 6e ef 5c 40 a5 f0 54 f3 01 d1 07 b3 3e 70 ae f3 bd e2 ef 43 94 99 27 60 9d b2 bb 4a 54 e9 c1 a9 ef 5c 51 7d 6b 05 85 61 9c c3 09 db 7d da 7c b9 d0 c8 2a 4f d3 91 00 57 17 87 fc fa 40 31 2a b9 9f 98 b4 ba 8a 6f dd 62 a9 e3 a3 90 d7 34 b0 cb f7 fa e6 7d d3 f0 6c 7b 13 b9 60 dd e2 83 fb 23 18 0d e5 b4 56 8d f6 e0 cd a8 a4 ed ba 6b b3 92 c5 62 dc a2 59 6f 05 ae 8f 4e 84 2b 37 95 5a 10 0c f6 1a 73 76 22 f6 d6 fd a9 5f ec 54 ef 0f bb 57 36 d3 b8 46 ca f0 9e 4c 5a a5 1c ea 6e 50 75 b4 65 89 e8 80 85 d4 d9 ed 44 5d 43 03 4d f6 c6 da f5 71 90 49 46 5a c9 23 cb b1 66 d6 10 9d 74 94 2d 52 35 c1 36 21 6e 0a ea 6d 25 85 66 42 dd 93 f4 bd 34 4c ea 1b 1e 2c 52 6e 1f fb 5d 2e 83 d2 95 26 71 3f 9a 03 14 ad 15 61 ca 44 fa 7c 17 e9 42 b7 95 32 3e 3f fc 54 0a 1f 50 14 90 c8 1a 78 17 bd 73 78 b9 e3 36 9c 03 12 0f 6e db 7d 9a 9d 1c 0e e8 46 0a 82 99 71 c3 43 49 1a 1c 66 5b 6e 49 fc 01 e2 47 15 18 c6 60 8d b8 c7 50 21 75 fe 9a 11 dc e2 de 19 ff 5e 63 b1 48 fa f2 27 06 c9 3d 9a a5 09 9a e7 c9 63 08 5d dd 05 c3 42 ef f5 65 b7 c7 81 f0 d4 bb 6d 5a 6e b5 fc ba f4 e1 0d 99 d1 f9 80 74 79 5c 2d 77 18 2d 71 4d 25 99 1b dc 7e 0a b8 51 b1 42 e6 ab bd 05 26 31 7c 8a 08 a9 2a e3 a9 4b a0 3b 51 a6 0f df b2 9c 77 2c f2 21 de 8a e6 a2 c7 aa ad 97 64 bf 8c 43 73 bd bc 16 0c a4 9a 99 1a a3 b4 bd 5c 21 d5 fe 60 ac 47 ba 52 0b cd 5e ae 9a e8 57 27 59 e7 2a 41 07 28 26 c2 cc a9 8f 75 1c 34 ab e0 00 4d b7 3a fb f0 3d c9 b3 b3 cc ea 78 6d 2f e1 4c 77 61 70 1e 8a f3 39 f9 b0 47 99 f8 31 6a 61 1b fe aa d3 b3 63 2d 96 be 85 2f 6a 11 8d 45 c0 5f bd ba ba 97 05 83 af d0 46 35 6b 4d 1e fb 5d 47 ef c3 bc 17 70 e3 60 bc 78 a3 96 16 4f eb 65 5d 43 3b 87 f3 e2 76 fd 8c e6 a5 23 6a d1 59 67 d5 c5 dc 5d f0 3f 8d b7 15 53 7f bd e9 53 35 8a 83 fb b5 31 62 d2 48 32 0b 72 e5 0c 0e 11 cb f0 75 ed be 50 9a a7 34 52 5d 55 5c 00 98 55 cd 63 89 a9 52 42 e0 18 b0 d7 52 55 be 05 31 98 90 7c 01 33 5b ed 97 92 3f b5 da 35 8d 4e 12 de b2 72 f3 6c cf 83 e8 ec 69 97 d5 4e 9e b0 9a 5d 26 db 9a a5 bf fe 02 2d ac a3 5b b1 3c 8f 3b b1 46 23 5d dc be d8 94 dd 49 b9 57 6c a2 51 c8 94 c3 2e 2d 46 31 e9 8c 6e 84 a3 e7 36 01 fc 17 8a 08 4d e8 fa 5e 06 2d 82 34 93 05 33 39 9b 02 d2 e2 50 40 cc 5f 04 1c 00 64 78 78 b6 87 5a d0 21 c7 b8 ee ad 99 a1 32 05 ac 9c bf a3 6a b8 f7 e5 a3 c0 36 25 16 69 34 4a 77 ac 5b c6 5f 3f e8 2d d0 bd 81 11 a3 59 a2 b5 e2 ce 63 dd 71 af 40 08 5d f3 77 a2 07 f3 2a e4 30 19 e7 3c db ae a6 09 11 b2 48 97 1d 64 48 73 dc ce cc 6c 01 9a d6 8d d7 a7 95 2a 19 20 db 92 97 02 34 15 f8 ce 84 8c 28 a0 3f 15 30 9c 80 8c b3 33 23 d6 fc f0 61 05 94 41 a7 53 71 4a 82 1f 43 82 d2 6d 75 c6 f1 7c b0 c1 a2 49 b1 2e b9 35 85 7d 9f fe 21 d4 66 55 e3 7a dc 76 81 4c d9 6c f0 5f 85 b3 bf 26 de 5f 61 9a 5c 13 77 ae 1f 62 b8 c5 e2 9c 64 02 97 2e 7d 86 b6 3f 0a a9 e5 2a 95 41 ff 26 18 00 60 46 d7 b3 9a 19 e2 66 31 8a 76 f8 ac b2 e3 1a 44 73 8b 0d 54 90 15 be 79 61 7a c6 5d 42 5b bb 51 bc 10 1e 68 78 ad 7a 05 90 96 eb 3a 22 b7 d0 99 85 5a 89 4b 15 41 ec 57 83 c9 4d 0e 63 f2 84 09 e0 85 df 8f f3 3f 8c c7 c5 34 fb 57 b3 b5 f8 2c 1f 60 f5 a7 d2 2b 40 08 f3 f3 f4 cf a8 d6 50 b8 3a 2d 60 1d 7e 0d dc 59 0b 95 8f 13 77 46 1e 82 9a 2f 52 8b bf 3a 65 25 09 b3 ef f4 77 96 3f f5 24 b4 32 8a f8 2d 00 1b 66 7b 94 23 97 23 f4 ca 40 59 33 78 dd d5 2d bb 68 c8 9e dd 45 7c 80 18 e1 0a 5d 57 1a 0a 80 67 95 89 18 63 c4 de b5 dd b2 c8 6f 20 43 28 b7 a8 f0 e8 f4 87 73 91 16 1f 2a 87 f9 20 6e 1d 76 09 db 92 9b da 86 4a 8b ab 0f a3 41 7b 39 04 ed a8 7c 35 fd 45 18 fc 2f 88 ae fd 1c c3 19 6d 00 8e 87 c4 83 7e 44 8b 0e 59 7a bc 91 b6 6c 0d 82 5a 9f 29 ec bf dc 02 31 74 2e b9 c9 f2 b3 e1 85 e0 3b 5c c3 cd 47 09 d8 3a e4 3e f9 92 80 ab 0b b5 59 a2 0e 6c 96 8f f1 84 fe 47 be 8d dc fb 6c 89 56 50 3c 52 50 b2 7f 65 5c 0b c1 2d 96 d9 42 3f a1 96 80 2c 4d 6d 83 0c ef 63 be de be d5 a0 d5 ec 2a b5 b4 4a be 27 d1 7b 6e db 00 a2 a8 9b 12 b6 d2 4e 07 75 a4 ef b8 54 fd 69 3d b1 95 cc b0 8e 17 7a 8c 1c 11 3a 6c b8 f5 ef ff f7 54 f7 50 db 35 58 b9 a0 f5 a7 95 e3 2d d7 cd d9 21 6e bd 6a 45 96 0d 87 ab d9 3a 31 47 49 79 31 d3 d4 1b d3 40 92 4c b2 54 70 5a 27 ec 21 45 c9 4a 23 31 42 16 7c 91 e1 a3 ce a3 34 a0 22 bf 71 09 b0 9d 6b fe 4a 25 a9 84 6c 05 16 82 e0 62 b3 e4 f0 25 8f c9 13 d7 fc 0c 4f 58 a3 0c 6e 8a 40 15 7b b8 88 86 37 fa 38 85 d6 e4 6e 5c 35 7f 0d c8 b4 ae 25 e9 b9 d1 c7 98 5c e4 31 40 3f e2 e2 40 fc e3 ff 4d 72 c0 73 29 2e 72 53 19 28 b1 25 65 da 85 4d bc 0e ad 26 be 5d d9 09 58 99 5a 6c cd 3e 28 7b b9 4c d1 db 62 a3 09 90 58 16 71 55 e6 32 d4 46 09 63 1c cf 34 0a 6e b1 2c df 5c 03 d6 0a 6a eb 1a 35 53 41 fd 16 2a 22 dd e2 f3 f5 a4 1b bb 7a 98 ab 98 30 61 05 73 1d ce 83 24 09 84 81 ab 40 86 b9 c0 af 09 29 96 7b 9c 31 ed af 0c 58 c7 39 e0 e8 15 c6 e9 f5 75 9b b4 9f 34 f2 76 33 ce fd 02 f1 f2 61 11 b4 18 93 49 67 30 0c fb b9 13 a7 af 7f 8e 72 fa a9 3c 79 13 12 0e 1b a2 87 a6 b5 bf 0c a6 fb 1e 3c 9f e0 62 56 24 6a 23 72 e6 64 6a a9 0d d9 0c 77 85 40 4d da 6e fe 75 ef 87 e2 d8 b1 e5 90 ef 0b 63 1e 79 41 1b db 0a f3 0b a5 e3 b0 98 e4 73 1f 32 b9 77 62 8f a0 da 0b 71 e0 fe 7a ae 65 38 93 50 c1 e4 13 c0 85 5f a1 77 68 da 62 28 e9 5b 50 0f d2 89 86 1b 32 7a 77 b0 20 cd 19 84 2b 2a 83 d7 94 48 8a 6d 0b 19 98 3d ce 57 39 88 28 17 07 f2 af f4 65 2c d3 ad d8 2f 42 4d 92 e5 bd c3 24 f1 80 22 a3 2d a3 54 dc 74 6b d6 c9 3d 7e 06 f4 31 ce 5c 55 d4 e2 64 5d ba 35 dd 4e 30 72 27 86 77 42 29 5a d8 44 a9 e5 58 2e df af d7 5d 5e 4a 51 ea c7 6f f0 e9 d0 ca 89 35 5f cf 3f ca ef a5 94 4d 4d c5 44 76 17 d7 e6 43 83 55 2e a0 9d dd d3 49 1c 86 75 bf db 48 0f dc 05 24 82 97 4b b3 9b a2 63 18 01 12 3c 7e bf 5c 99 92 b3 ce f9 b1 2f 8a 5e 7c a5 2b 3b ca 66 96 35 c4 e4 21 3f 29 83 1c f5 61 22 ae 10 94 dd 8a 41 c2 66 9d 4c 83 b3 ca 99 d0 75 93 0c cf e0 69 fc c2 e3 27 27 9a 35 2f ea 30 13 26 70 d9 64 d0 34 16 f8 1e 74 3f da 30 8d 43 71 e2 67 ec d7 ec bb 4f b4 93 20 3e ee c5 7c 83 a2 3e 1e 99 9f eb 79 84 11 9e 5c 24 55 f3 ea 47 c2 7f f4 33 45 21 0f 29 5e 7d 6b 3e 52 4d 60 62 7d 20 b7 f3 9e d1 83 87 42 ef 8c 49 c3 0d e2 e0 a9 fc cb 29 30 2d f8 64 16 7d 7d 19 a3 06 af a5 7c 65 42 0c c0 74 ef 39 4d 2f ce f1 fe ca cf f6 91 27 b7 fd 6e b5 7e cd e6 02 af 72 57 e2 f8 48 5e bc 97 07 ee 82 db 3e 0c 73 1b e2 3d 37 de 46 a3 d2 ae cf fa 30 5f c9 e4 34 56 72 11 2c e3 cd 20 34 bb 61 9e 8b cb a1 d7 62 f3 66 ab de 87 84 75 4c ba 75 c2 cb a1 48 89 5a 1b 1f ae 1b e5 01 fe 2f 12 3f d1 c9 17 8a c0 fd bb 49 23 9c 4f 53 41 ec f5 13 f5 a1 63 35 21 19 d3 99 df e8 2d 0f 7f 24 ed d5 0a 78 c2 af a7 8f 7c 5a 0c 36 35 ff 80 2e e6 7c 26 bf f2 e1 4d 7d 6e cd 92 5d 8d 39 7e f7 53 43 96 72 42 fd 31 5c 45 79 36 78 5c 6c fd a7 0e 7d e8 7e 54 62 3f 4d e8 96 54 71 25 ca 6a b2 a5 cc cf eb 58 5e a0 1e 97 51 7f e9 2b c3 f1 a3 57 e5 ce 47 ad ce c7 05 8d 78 df b6 cb 80 86 c5 da cf 5c 74 53 c7 cb 41 98 23 3e 77 10 88 91 38 12 10 ae 80 18 40 65 4f ff 56 e4 e4 0f 18 dd 8b 28 25 bb 1f 20 1b 39 61 87 ad 39 07 f7 76 0a dd c9 e6 a8 fa 81 94 02 eb 31 b4 79 99 16 a1 9a e7 fe 76 26 21 b3 c6 01 b7 fd 6d 34 cc 69 4c 05 ed 42 67 d8 ab 32 73 a4 6c 99 f1 80 18 33 f7 7b 17 00 ff c6 3c e5 3e 73 6a c9 04 5c 4b 90 40 7d 4c f0 05 9f d4 fa 3e e6 80 9f 6b ``` [Answer] # [Python 3](https://docs.python.org/3/), 9997 9334 bytes ``` import base64 import zlib s=zlib.decompress(base64.b85decode('c$_WQ`CHltqNs5;i2^Zz#v-OEE^!bLafvlx4d7C@xFl_^F*7}GO%bBDb24qGndzV+RZxSPrUttJ5(-}yktk(RV#L@)Qmcv080^Woq!vNZEVWiUnRD;+-1i^&{QMFRs9UZTH-cF#%^m4V>{{<WxGcy%Y7O7M=Vs)*UPO>JHVJ>$6=SC1e{ECUU*LTF^=G#Gf9yVit@i%)ANH4^i>|v5tY^KfyI{;u@FIP^y7=q&HoiQ(J&^d>$g|b9<k`nq4r&y?$yo_DLLX_*z>O!$>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*cw#jq?3`CXaFPWdrvI81VqN_QRfmnmyS6$!2VY0s)bJ=tn9Vq=rCy;~9UhH~i-Q6D2B=~ujAYIf6bdKlzJC$IC7?V~CuUOgQ%xaPO@lk)iQGAodMgpoHvJ@3XJydd}P-Kv>lji!Z;KigOIpATZd`@VYffcg!B@DXqArE@u~giL1`|Jpn0nU5|LG3=C|l5Rmpg)gDzPaTTebbPyrgvJ(?xRzD8vaN<WX9NCpf*FSTdyIH@=KSvujDiwW7kTziL3NGDx}XgK{>%Xwb{MqXd%^jv@Ynm22en^b$vb>(rbsfT3@<*B_8<7wy7q(y_OI*ahk9+Dc`(U%ikHl!Ht>Iep)=>;k1NLd>aM#hoM)bcKCH`u=CT*FQop``__spz!2=NO@274y6=vQv319<%f()_sZ@yals_HA`7xzXJg0ss1vClDB8M2WF85x8gfhbXu$G}2his;*1Cic_NkfZzqXejD6(^$<>`GvcMv=C<fWbHNcebUpZt4#I~`ttRng>ZOr8N8sd6#d+_9R>D&0lX!@-MSiXxQ|4<(<tabuTbf5*;Q;xtgOf0Nc{bY4mDRw>iX}w52g=&?hi4t=YRihxOF7?G|~cTQm>egoLmP2-JEAgH0b~Lzql9ClK')) o=['A','C','U','G'] print(str.join('',[[f'{a}{c}{u}{g}'for a in o for c in o for u in o for g in o][c]for c in s])[0:-1]) ``` [Try it online!](https://tio.run/##Rbfb0oJcl6V5nlfxE6IfYJkhuEGKjSigILhHRf9IRJA9ioiggnrr2W92d1QdrGBCrBPWGnOM@dzeDy@@tv77v/3LLb4//mWeUrvb/o///62IfPM/Uvp/Hv95tq34crvbaQr9f5v@0@x1/ufj2Yb@scDjbmlwYvRIZmmH9DH9UFTyxlwQdMBUTk4evdpnnGNfo@iojxD8O55XzSFvYu1kfD0X2/rq8Fov7pvHY9KBGt93@Aih1baisPDyYuXNXlPfxQmQzw7CdudvriuerDdQX6@Vy@lolRKbgyo2rFGlql/aW6Ysqd1rbL2re3yOT@ltCiObxZyZiNsJA3bpNYfapcBtNoiijn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9B7F@hf/75X//@t/NPefqW1rfMvqX7/ceJ7/86/cu//iv@1/@U1v8ts/9buv9v@V//tv7r/@xJ/wv@d/N/N9D/gv/7v/8f "Python 3 – Try It Online") Didn't go quite like I'd hoped. I was hoping for better compression by turning it into a byte array first. I'm also really bad at combination theory and thought I could use only 4 bits to store the compression dictionary. Base64 really exploded my compressed string, something like 7.5k to over 9.5k bytes. Edit: Used B85 encoding, which cuts inflation from `6 to 4` to `5 to 4`. Removed some extra variables and generally golfed better. I did some tests, and going straight into zlib compression gives 8859 bytes, without converting it to printable characters. Preprocessing it into a quad char byte and converting to B85 is 9345 bytes; preprocessing, zlib, and then B85 gives my best compression at 9147 bytes, with an underlying zlib compressed size of 7317 bytes. It looks like preprocessing helps the zlib compressor maximize the compression size of the outcoming byte array. An interesting distribution count of 4 letter sequences, from `AAAA` to `GGGG`: [![enter image description here](https://i.stack.imgur.com/4VSAz.png)](https://i.stack.imgur.com/4VSAz.png) You'll have to forgive my terrible matplotlib effort, but the pattern is quite interesting. * All 4 character "words" were found at least once. * `CCCG` was the only value with 1 occurrence. * `UUUU` was the most common value with 87. * `AACC`, `ACCU`, `CAUC`, `CCUA`, `UCUG` all shared the median occurrence of 28. [Answer] # JavaScript, 11651 bytes ``` console.log("0"+[..."ag77159t64gzum59mvzf4cilqkps21k2nb6ptu0dzvab52613aj2yajk7pg4a4rb4c6ga8cfpt22gi0v9au8xk4z67xbe36vz4cfj9mrx8pi8h7xk64vn060uqprqt9k5eosgmayasb2xdniph12ra241s2w9916kxk7pfmbou9ftlo9zey89i08hzjdzvz385it3tkzx629o1s0euwex06c5nwa8piru6wg1b6wi0438nfpscrf7ll2xp4qo406zggc2zllqeo3y0bzfsddfl0dal3r0ex07pnc0fa4zjpkipsl4n7yh84a3u20id9k8swl5q25h5mcxiv9n7u48lesnsc8op0lyfkgrpcqcxviirrjuvw34gr5o21ktfs6bf8ctg3lm1v1up3fo95as6m8d3g7dp6iin01mboe8xi1lwwmxum4m1yhdpb55jd9bwoftu5s95ub0vjze7qdqw2ctfq74262zmsjkxtxwlskk26sr7lb15f4sibdbk1vjgpnjunz9eo7x57w93k7o5vliq87vhj81fl6hiuoamv96ky3xx7an8tsi8qazsp56xd6w2i607657ikv7udieep9ituhbd1s72t92n9bujwd8h774ufpr9ftc2d33142eya5yfhmeb8rrshh998dw74lvlqsmsn8u0eyryq5bxos7qz8ddfeq1rw35ehvoxrh6b6wepm2sa1khkiictbio3qj7f2slsm2tddlmdvrs38v3zlvdo4m2n49n8p2pk18na5v6nn6uha7mo8cdgrxgwwj52wq19ju8cykixy41ydd3mugw3fpk0v2lwlti221hmy57uhceu2x1hd75ivokyhehfnegwslwah9c7loy2hv2l4btk9r5krvvo0kobnjktos70cz83opvaba88m746e09bfw16cxftrjemzln9z4d59y1wrqd9xnv05t6dsg9xjdhr4t0xnympo1a6m96ags952s08rciswvsnj7fumolrc1eo6tm838plbmg1a8820mp49w4rvzldnveqymzs4h2d9fok5ayur1oizls01f13uiru2v8qhof0git3irqm6lgvf8im4d2isifesp2grwfb0c86y6t6o9n68n6mlkybqoswmrwtivgei6tcjozdqs98f157bfh1c10nutrb6g2lp3he6aiha74dnkbq173cgsql0xmwki5gl0dpkcl27p8x4wiwus6ulsihsyz5u96dafeac6hrti2l5w02i26ek4kolv6dyodwmtvph4ecbhaof3vbzs8fdwg3n0nehzcl0yb9sdr7q71pu8g8ur8c5befxmta2mamoyco4dm4jhs1ukw432gl8147jvpm9ibk3ahu93df880qdd9o61fznxqbybyb9jwrxxgivord0bcwq0aukk0at5sdr2l1v9vk4557suerqt0xnzb3ndlk4hg3nnt28yoi5lqspjqc465l8qvafgmbgn0b4v52ujmis7n55l9qf9k3zqkm2dvpoc44sps0txdgxkrreaae2hnwr49ubwbcffefhynrxuauy1m5mqv5pfhps58vo0u75dct1ctgxd82syutibaox1dg8so7xj5vms6jh8gqkbb0s6jqatrufasjtdu1e2lv0qenvt70s3ud7adu0lf6pn2qrmwu1fwwp3rcqz6bmx4w6f90npamwjkttbfjnybg5kkn44tbsqzniocpcpxraoupacled6m7cw1xt16kd0azemms8weakubcyg7aibccgwigbmrwzw6mkypnfckwt2k780ji0e9ztjyowczciy531irtitn14fy0yi8ax94ly24jxni97kj9bww4gaxwf5bhxve4qfm36ws1gcvqo5wezrsl3lae0c56c1w3u1296p6m1380fqrxe6dyk0i55kqml4beg34dp9l77m3g8gq7ee0jxmk4oleg7rl6y2eutuabi22qzm8sllrzmhhj092atdurbx1qn3v8qr04abm0ito25x39d12ew5ezhdhf34kxvgv84kf1u6i67ebwqn7ii9x027isy4qke1uyb7sb4usqhi4x7gwurzt8i1hejsydlz0qpf005tay0fcfh5ldu6xw9tb8h4ne2uu2yxio83nt20kwtvho3a3ts7etziflksjwa5jodtum4pgaskzkhi38xgp5gil26ewan0e0n4otoq0kxyhyqmkkijnyinaxjj6sue1ao05d2ledd0p4zliqhzf1bxo3lp69r4y3d1y0jap63jcgmm42se1gz7k3au1hr0afdqtz7z53iof92ca6fbm2mot7e732ppzn3sppq6dlvbwbaw7925ohzvdagt9qlqj0pgv4x2erzmaadn96hwk33fqhp4ehndny0dyb0htl0zzblydyor1wv3tope5n4g1ff4w0ohwozzcnfffa6a8ex0943g36asw5etenmwbo82b4iuekli2w6ryx71yph74gvsjwtbk6ean4tznipkkx0pget40o5owmrozgvpys6gqu5q3mo2w5ux9xb1i4164teaz9sp3894901fpegqpbw73rvtc45dtekr5ewk2e8slkdhk0o1ziwaf9xde2kvd0zdeaipzfpxqp8e9ese75wm2sictt5f6ydz8j1top1r364liwhiaw739akd1j33bwgtvfjf02nrpcgflukoqp0nk53dm4q2yfchz8sxbtckkjafcmvkl1qx6b70hqgj8zttndddnih88d8hu6kpu7p3xsva6txa2koyypg61qvf2qet0aj1pjt34thokqol98faqp8c8ldxoqygvzk8t9gcj3jz8lhymf83ui8e2ahbuyzur7iqjjnjademza0oi106dtx7ysf28953pok4103cl3ftz9yhk1d743gv3wcdl4kdrpid5cshgamnzaxw1z81y200lt8croak8t9nxlqq0yhl3appwd5o30kpafjg8cf85rgfimdti8urzk7dpgjjkf8zs2nuq996thf320l1rjwer7ssrrwdhnwmhx8376arm5vgum4a910xzszwspafjrlgxnp71zjsz54r7r8x1hbslsjbbskrzg9v16sxwjdsq7vfs66nr704pqakunk7v5wfmx1316kz6k3zihapupvg0tmtxrl3lqy5uv3w0zk79k501j6841s38jkr0r58l3jhy34fl7jdmi1x7qejw9dup564fmb5hau1fbzp6hngw82h2e7knzflzxckreus941dty8blt3yh9myo5f8qzspks6ea8jbk1jcytllivihx99zcy2okge53yzuxxomuytyc3n2p76uk76gghchiuonlmq35bzem1wah2ef2hu2eu1vpwt2s47armod07mwhd98dd7gnxk0orgm8srwbpk3g4s5yei737f7adi4fdwr338tjg4kqyuauuc1shtn1kg2rd1eh7z95poqo00qa7ffou724esvk5dm6gdcpfbxn5ac1aej62u1hd4pigul2ke7lfm73otr2qnonzi7iv2b0t0yt6s0y2xaz34bgijwii704vnx70tnprovpjpnvguj3ipdihol5xgblqs65qutuerehpwlc01fwe10ybusyrunsxecrad3vlm2n8ecnitocmitb7npn205rl0nd54u66a5xuj64ma1reramte9x8ch7m5enk0kr7dmj5ao92h35k4c91w3txepetsdu4r1nb8p30b94p69fze23mv7xsk5gok7bcl6kouyhyvgln36coc1rijbvz0p6ya6oy1jqlxlv595qb7p5weucuie7oxe6xdibwqik5uupmb74h0ao5noxkadmjj2g2kpn8i0shws0muy004jhz64ioumtyvltlmoq7qqc1rz71uz5bv61o07nrdtxyapverm7z7i3qo9wi0ywaujm8k2iy14a5lem48k8m4g2ce59mdq67th8ssvyvjwcuigeqc1as4gzegp5y5xtx1eigeok04vbzs9g5dlsbv8f3r7s8u6nt1ezotj7585120m7drnbz5jhemyemyia13hq5vabo3djgmhpycyam2bxhb85201zprd60p9lkw9sjor8m55efsoi2d9edd1t5x0osp0et0udwxec5n0bb2fmlikz2xrenaysob58dtcjkd6ei2j8qjfe1rhij6uvyi4z268tny25xumiin64kqsmrl3smpruiysr5i97776kkpev50rh6gt1now0t7bfpmtek9a8xiwuw9tolgd5uvllv3ekkb3ebrj8z2q5yn2t8xqps4j7o7ic1hmy4rr7qxzsaucqszm1whv6ecwfsipbygg18iuo9n3vio44jcne0p3ma5dn3r7t6kh9w7qq0qe1nc63un4tnn50fc0b01qg9k8paea6ua1ife9bptjrwq3bjhp9kywqkx4rwq8pisbqc0gwjv2j8nfgexu41c8i8fmn5ldhm9wvoqyk2ybkibhu8virh2fbuz4cf3zowpjp87adt4ergq96emi8131bnccxfa4d79lwzvkmmo590dji3n50dqwyatz0so5phv53pr3yh2hjv1bdtym0f5675azzqmffs2k9jpubouikjlo2672oj5tccg1z1a99nd7lcfax7j1ddj4d54bj03brscs08kjh9vfd73phxd1zawtojedg7jgxn1lho4a0a9v4dk0hogl3coagl2gkvk6allnzqn14v5oo1m4mw5rhuvtcm11m5pa9j81wjwvwfzkn09ni5tw6x349phmz44211b1b3olzgh51swc2yezfwtzke3bb9f7un285445db96c6vpni7zlv3fwnb4haex2o2qn2zm5116mm142qcim8fy7xwzrcjnfwu5ut2gdk7wm477p2ed1ch80cuevr03xj8isgbbk4kzzjkhuxd3f0ndlaq7qcnwyhd0mmsmc4v1vqq5ywhlbqsuc4zgw6wjqoh4m2mhkicwpxegnipd7ojudcghpcal9bn84wu1rurd21mccnr35hgocp1c710pkk9cs8h9cetxja1yffqyfa6h4xxq7xkkc61cvcdt5j2gvcyo16747157luy8b4lr4rfnt6khmbu1qm0o83b055zkui9x9pyyknial002t49gk0lchqw55ehmrv4gmrgqqbjyt6zquqrj2m6nz0l5hlq9kut58cw5r2ugakthgo9z0qyb3en00cn4zm3huaxyzek2781mdyo3epzmahj4a1ddxaio4g05mtfga50qwet7svg3wjuadyxtdwrifcc3v1vq9acwacwrgdmx9bkyd9kp0memet0wcb0nweqonorpz0h66qmapd0155q4a9ir2dyjubjstl2koxhhljtavbgrlizxp9mp71mqcwihlu9femaolhlob3isl0o80k4lf098uwwtu6enywfrjpxtrdnq4koxsw2hwkpg44uncyo08prlko4jzpsw7v8x07vifaq8w2ld0e3r7fh4vwco7efrvf3cvrrvsjm7a4ikvi9ex79ugpzmw09573dou2eluhmnr2bnwl9pgytwng184n7q06nfy5qlr53o8e2yhqowbcbbmqj2q3k2vot5w2us7zpurv4q08t87y8ow21j72zx0nq2wig9l57bj0n4qi5n363x6pwu8jt0dfd1z47q10f7kfp3se7dv03aldytu2ul2adxbxqqoxha49r6j2rzl6d1g5aq3esra928yyuvoaw9vlaxcffd93zyuq10iv4p4mc76206bzz8zokkt7wxoaz7nx93eoonratzwc7x3y43sl5g1jaytckm2gk7g56407eeyxow6utw556jtgevghmzigvotv5xt400u9lp0f7rfbwxdzmnrrqy4dlg8qyayveo6094rhobjx4z2sgqtgdf5sto7vg8e78m2looefm7zw4b4vfjrlnkr3z9vllrtxsme6d16ac6fhpy53imt4juao885v07bkoftnpetqhtyv8aavtnq6z9iziggg1u08a2u6ufwgzl8wj3u9qtm0l65asnec4s68d623gis3tzkud5l10e9j1n9cys86g46l1qd2d0uhmotpslivf1r6rqu6xdnoq8q3xn9a5jhd9mrffiexkgqkcww73x6fdzif8bz16vv6k50s0hpoxbolaon09tn3m5s43bkg6ynrmvdqqjmoi84w0o6pda77yamkirecq5lbizi5b4vdykilmhd4oj19ef08ucle6bd3mh3l78l870b7gijrjw1shrjmufbs5fh8wltslympbz5ftppd3f66w4a4bpk0a063ymsemyxmkrli7x80p7u3f5aieffr00xob6nugit5fjncjndjuztba3h56asums4q54kylm76duw0voeaxl7lmcmkvfnjfa9y9fvin9noabbenuxebnoga1rdl5i4d76fatnatta0kixinjw98ta3jdt6igccbcl62npgu6agas64enniusijar9my6mym9sr9205xzrc15t3yx4rcaxxlpvzqfhpknhrl5podm812qy7jmz9pmvtj0eh4fv0tof331c0i7moq3e1405mmt77kswmiw375mm27y44zpm4j0yxc2mk58c8qc7l4wd17sfq3i6kyp099hakcwc3s3hh9n7pt22sdivx765z7a7yceklls3w7xysnn8gja3eao2ixcd7otmjnmkj8758hl8eobro69vsdr06v33o8g4ogjkq0w5mbeq51jfbzr9ley9slshdyzja9xftwxzylk01kdvawgrntccvbr3vderf92o4a3p3h1ary2qm9ybgydmlt6hgnh5qec3jo0ucw5qui39pt8szfcu0oul52ig7jaa349cdcwbzkd2rwoen95v1j1wfun97o7p0d9ct672bopbg5qzmqlmbn1vt8lknhdc1a0zacddpzbcq9yibckcuojw0wqutcrktsrw028078vg7okev0qb820acblykula9yvka1kximms581axsn6osdsvwkmqsu8h98v4s7avbuz8psp099uzubpfyxcpv0j2k163eml4ylxn0xn9j0uarlyil0dsb7vbnicke58bs7a771qwok9wzdwp6q3x8uld6a249t0tyk7utpm1wtctun939ve85o4p0gx11kw6d98if6dtn3240w1rwout71r5x13qoyrojmzddf8s9luma7bn1se4vn0a9yy6k4twtss2iw9m915p33dwsiq2gxho9d1l3v667urtjsydhkap5ocrrhf45p765gvbu06d1p6t0i6m1qtn1fwnk63qjf3ixu8t2089a3yc7t0ax8bla13jvywsfoob0aor0n1nvff9jd1sv8vhujwt7dw1cl9xefsnwaos76hn9zxps1ww8t3fp9bqtoqfq504sjh442n5zp7q3fqg9qcs1jgwwawxk4ijhpjk1p8fidnupykkg37myx4x0tqpjyi2dxswv37qrlsfujd7cmn03hjvmxw7m0pubwyfjuewllyu95z5566smtfbewnturtcvpbt6pt84psgjwgy1mr5nv5vhll7ifabnj3c2qjd3egym7rm7sulwitwdywtodg7oxdizt7sgtj6usn48mqcorzryif4icjz1ba6ssd68jjyfq7t4aj05u16o56xzx7d8uo0fatkx0zder4a6ir5mdqchr5ridm4kr7khff3umbmbm00soq3dsrh3y3psl99k1iysgrni6shr412eapflnaaoln2ujnfpiiij3cdy1ud7c3f134ytbha4whzfdn5x1etbo38p8tr0dwitoi1e0urjjnn0h2zd5wvofh3rc436837t2tq71vcavz3hf4q1cga77to7gh1xh7jv9pp5k1r7ym1dd8lu3pyegwdas4o033zdox52y2ykgwc0olukohvjd4e8vhhr9172dr7s1nv0jfm9j34wl0kffzdkmuhndvl10s7zg66x67heoiw2r75h313ylprl42o5c1cs5txdxeb1jmix6m58xhdq2e0h88tqov5gg9evzf1fueqqrv7f01ld2hy3faam0v9novd0tf577224osb64ufd0oy67asacztzklmgoeym8izltolk65etlefma5s9lonif0mg66gcbquqi2rqnj8d383ksulsimm8zl3e0ttlvpzxdde20vvf6402fkqkrkdl8dig3f24x5qliewi16flh7l7u0kq9e80omw1c63wytoqma9iazb07lacjlmw4uxvb2ovdabsoej53hiavtwsbyeksa5k1jyung0pq348s72e685nhzul11vk8riiz5cvu6ep2g4b1ph44ox8oe3le2rm24xu123kmu1ogcn1nis22tmx7ibe3b2gm5g9mvz3adb9mmz6doc9eaovpbrf80ruq83xwqmxdzol1yd007fgty3739vxkcud5qi1rgf2jpljpwrxl8v057fcjuk1eabvxnnmy4x6kpmq4zzf9t9xmevpdf9vi83keg5d0v1m1mqsj0cqnvcxacxrgrr89mw5t2o2n1fovuikptuou1acm8rc6hi4u1lgyzwczc8u13lg25y4bky0c4feezpy7r8wwkukrsbw60louy3fsklss79z61mwrkmfeyaw0x69gv9yk9fnuac2bo4lpe7hdd7w05vobhbcmv7m37775m6y6ja3sbfagb166sgmy8rfk4z39hbvqxi8jtje8o20rhu46u4bmympwxfv3jdjmse42yxk4mayom6z3nnb0zw8ftif8egdv13xp574kuav7o8amk1tsvqrstt2ndxwg63vsc1z7z1zrpoffrt2dtsc68efzkmzcbgspcl284nj2xmh9sbac8aiu6zroxeod2wpd0zwu3mt8ch55q7cjvf2q64gydgr3ox5a7tp1633pc43c5bg0xv6yhwzrfgu0iumib90subrlwcasb696d8h9fvib86m8fr3ivue2xux4uz87yjmh84jg7e2x3wlw8sjlr16jxc4rg5iqg3q932bew5sb67psw133lvn7tmp469yx47guu2xjg64itww5idjtijxdslktw32q21chev8jeb58q4q8clw4r779fntdhqw6bejioi2juvhbe5a5stzpjwggvxpanota0eb6o3zvzbtjpdsit62qs6xtvsm8hpavjihduq9qg396m932tsddvq0jfra2oif1a672j3tn3iekf9e41w8538rfwwdielbmnban772g3kp79bisj1ly7mhgj9r0wzr4yhpgojjtnbktyphxmh2clbb41h9v597h5d3t4a9hc4sb9fsjnefm2f3y9r57m4il7s3tw1dnbm1h7374a0w10w61esz4xagh258hzpuv8lf1ss0uwsjc1gyvttaymnbiclu934noga02bvh1rfgryloq2twu0mxz38p4v8zz3pgm3hc4uwypje4myqdwwi0c4wtm2b6jtspjvb6dkwza1sdg0zn5qd7jc59nt4o8hkgsbad3hyek7s3nkzx948l15czo5s8ao7zorbv74tgkw6yb0ugxfmvpoicvt3hmd7pi6ppeab3p6rmf4qjq4auapwf333ff58t1w5cqe4ctkhi286smvmz30m325hcrbf6qsafa8t9x8cjyz7cf95ekcg0xvube95ef6kst4g214yaa8ata3xzytfkb04ympre89eitlb4fe09y2pt4n0fmdfart0w1l9jreppceeq0iujt5ki6xqeeb73d7ckuu40kkgrseghy3kh0j0a9hsq5xn7lpg4etujj24jl8b9ta4l40gye08wvzdksdnq6dd3x3smmbhxsmjjfiulqrjqty9hxek5f1bdb1dv1xlrlts30ujhodfq8pax68io1m052j0l24r9euf3lmlcqb930b9i9yq42f1mgbj53is2y4a2h5jt3p319evlhzgttf184lgluctt12jdsvh6hwzevwghrgfitns6studbrw305iv9jitjiopfltjoj8mp20opateedn3fhby7f230ij9rj1kqtnuj57rfju62bvhfb8h8tghfy96330t56rigqwce3np7lkcctiqmhypxxv5rdwfwknkz9acsn8yy2kqcp9yvteqzscf801tzqko8svx3v36z0t4z5uwlclp5nynr3tzwv1yly86dhjn6obusdfe8vdxbp3qdhh81mhbdsnojqiizh3rz7ki3thywilzcg75xrbbeb9ggzcrr3u909y3og6ds9a5h83o01ivuoljsbi2lrpz0hilu3x943pjk0d5f0jdc70qsmmt6eqm720eittxi3fffd4naoq4f7v9gyu90vwm87aw9xl9a3tpnee1bifl63m8ppsb63z587n5wky81xvta6vcri1j1qbz81cgiy0ieklh43m7ui25qfd0tcri1wsg5si4bo8o23wkdjw9wflqdvupkebxascmk5aq3xznb0itryureyng3anwm8s0c2qq7dtubrkxicnh7hsiry2xiukrmhgce4bce4j0065fprpmn2apdv2mjlvdyksqgz4h27c2jcjgbotpvonp3nvxgc5nfr1nt5jgxtgjh801r9196jujlae79t887sgmdnc3i4wt9skrchzwqhxy64qcgjoknzszjsqcihzqre1hjmwkh4lqbhjff77jpdg92y2ur0rp9l3869r68av4y69gu7k86ayubivm9van3lg9v3sz8uo9v5vh6jipsjtoj4l4hildyukayjygmvercqwekxx6kgl5o2ojsbi068mocu574hczuk8omsnvw62e4kzqmg46kio9ptakc7lm0j6kcdqgwp4o8kl9kbzis7bdwhiyi6wilhgo3z7qzdfodv125achk0qmtn4k0l3fw4m9377av93sniy5jey8e06wrrncun53h5zvm74k6qcyfpb99dk9jkczbt7uud22kd4vnyoeja1u3mis8gf3vaph0g3qe3ts95nysf0wv5jmvqaqma44so6b7gj0m2jybsiourth1yx1vbbgdz1ax9ral19gg3enr140w6itolkyxv9gx08hnbvlatsk5e0kit2icu4nbliemvhidfj4ol1o77enax7maa72ur6rrdhkoznz3l3b3akwyjl7mcx39ow8ds88vh7ry1wkerurlfydegso0awj49l0detgare8fzuy663et5l3bie5466k7z3hfanw0seb65swwrltga7yyqi4ss76ln668j853gk0p5nikmwyxj6uuel3b85fnd1ak5kx0eacbnf11frgye11oc0lypfe7rkbhz254gwlssuuj1zjedh6ggyx3juafaoas6oy13ay097usxzk08rraw8dfbw0vlnfumayhvdzrlyr9bfaisptw250392jv7sh97j8otjk7sakxc8rbghe0g48q124nclebbyd2n36b0p25edqczjpae0zd799ilgtesoye097tff1bgaww9s90wv91lzyfh1pqlx52z8scd04f254fa3ao3cndkhs"].reduce((r,v)=>r*36n+BigInt(parseInt(v,36)),0n).toString(4)) ``` [Try it online!](https://tio.run/##HZpNs66qdoX/y22dk9ycAvm0kTTSSzvNVBogoHyJAor650/mm1prV71r1d4KzDnHeIbuoG7VluqP/m97Mfbvv5eyt5LsX6msf/wD/eNf/@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SIGxQMS0Banknb/cuCfaVFfNS6L9cOmMm@OwNq8HN53aHn2cQ5xAWcUFyXmaZoILO@QKQKAy74JldHbnVsCDzbkt5mGKDm0LhZyPepgGspbYVrsQaUp/Dq5gsEtg2/D761Xs0HiX6uKmGYFWL3iiE7c//D8feB9n6Q3HZ9J9VbZBZF3ye/XHTXQNT53rxxgQKFFiHsrh6RlRJQNF4rxOTy7R9JRBMVxxuSyMtD5jKkaRJyiqgvHtHWqyb3Gru2gtQIdE7I2L4qkHb3XS/nxHYGF/GWUc6j@OUl6G/UgBFYGwOUFaLT@56eAkTytHMIiWD3a0QgJj7m8T6QKS8L15DM7QaryCAnWrXo3WHsKog6xmVB6T2cFTXq7ZsYXQdA6XUF/AVrNr6u70PCBWZVVPu9pCXqRbO42vNFJGtVsC2nB7rT7i7gyO02X01vnYFJfTv6mBgi8xRu0bZZBFl6AMtV8Vlk1etm0UrliSe6L8lq/ZppJ1yjY2IWUuwXDmUh2Yp59mntthXwoVl0Bw6zqjHmNkPFZ5y@1234OBOEw0@2xSDqYCtOEVXIspu4tX/871/Vmmuxf/xR/3n/@e//Uf@F8P1f/9Ov/7X3Pw4FZvj7cP@T8D///Cfa//yrl//u1e/rH/TPP//@@/8A) [Answer] # bash + `jpegxl`, 25 + 1 + 7280 = 7306 bytes In the spirit of @the default's [answer](https://codegolf.stackexchange.com/questions/205879/print-the-sars-cov-2-covid-19-genome/205895#205895), here's a similar approach based on jpegxl instead of flif. [jpegxl](https://en.wikipedia.org/wiki/Joint_Photographic_Experts_Group#JPEG_XL) is a hybrid image format, with the lossless coding being the successor of flif. (it's the same guy working on it). ``` djxl f .pgm sed 1,3d<.pgm ``` The `f` file is a 1759x17 image, since that gave better results than a 29903x1 image for this codec. Contents of `f`: (encoder flags used to create it were `--allow_expert_options -d 0 -e 10`) As allowed by the question, this uses the mapping `(A,C,G,U) -> (!,#,",$)` ``` 00000000: ff0a 8080 bc0d 088a 0b01 0806 0100 c400 ................ 00000010: 0000 5019 d3f0 014b 2837 b29f 27e6 8d79 ..P....K(7..'..y 00000020: 4110 0441 c931 619a d833 440c 23cc f82c A..A.1a..3D.#.., 00000030: 70a8 5803 2162 c88e 9d12 4644 c430 c660 p.X.!b....FD.0.` 00000040: bd52 8701 0098 0000 03a0 3c6c 2ee3 b34a .R........<l...J 00000050: ddca c0ea 175f 6697 a631 e677 00f0 1929 ....._f..1.w...) 00000060: 266f cfe3 4a38 835e 5ea8 32e7 9946 2227 &o..J8.^^.2..F"' 00000070: c18a b26a 9e0b d52c 2405 9f9e eacc 8d9b ...j...,$....... 00000080: 477f 6294 66f9 f67c 0c84 b130 1dc7 a638 G.b.f..|...0...8 00000090: 8498 7865 1293 cc1e a84d 5bd7 afcb 89d6 ..xe.....M[..... 000000a0: 26e6 a091 220b 9c55 c266 5e66 5ac4 d64f &..."..U.f^fZ..O 000000b0: 27dd 31f5 623d a8a7 d592 f7ca d9e1 80a3 '.1.b=.......... 000000c0: bdfe cee2 e029 d9fe 7a18 e29c ca22 72de .....)..z...."r. 000000d0: 25a3 e740 f478 097a f830 1352 8d8c a591 %[[email protected]](/cdn-cgi/l/email-protection).... 000000e0: 3b81 dbd6 48ea a366 7283 bbe8 d6f1 c889 ;...H..fr....... 000000f0: 97ca 0689 9a93 5c14 0e0f 81f2 61ea 3d24 ......\.....a.=$ 00000100: e990 4afe 78c5 bd48 7dfb 5d42 aca5 2498 ..J.x..H}.]B..$. 00000110: 2f17 c876 bccf 5971 f588 9d28 33d5 ee76 /..v..Yq...(3..v 00000120: eddd d09b 5641 5b8e 6d86 2107 2c9e 6ff4 ....VA[.m.!.,.o. 00000130: 3584 615e 94d6 3305 dbb2 f209 75ac 430d 5.a^..3.....u.C. 00000140: 119f dcd7 75c6 10e9 1e87 6557 8c12 7da6 ....u.....eW..}. 00000150: c578 7b6f e864 90ff 45be 24dc 88f0 31ea .x{o.d..E.$...1. 00000160: c1b4 68ab 656f a077 9cfc fe43 9a0d 0bca ..h.eo.w...C.... 00000170: eca1 9284 b66e db52 aecb 7a30 b1ee fba1 .....n.R..z0.... 00000180: d595 ccfd 21c4 9b92 733a 4602 8c79 8c9a ....!...s:F..y.. 00000190: ba9a 5f0e ebab 7126 c3f0 3a8d 7e1b f583 .._...q&..:.~... 000001a0: 846d 9d86 4535 47dd f383 2583 686b 9278 .m..E5G...%.hk.x 000001b0: 3919 078b 0875 ee52 f20a ee97 72b3 6fbe 9....u.R....r.o. 000001c0: 51de abdf 18d5 d603 41cd 708f a339 266b Q.......A.p..9&k 000001d0: f8da fda8 3f4f 2731 917d 405e 08e5 c827 ....?O'1.}@^...' 000001e0: 4767 8c32 f209 bd76 ed63 5b78 e97e 7c18 Gg.2...v.c[x.~|. 000001f0: c975 c021 d033 9ece a33c 4521 3998 94db .u.!.3...<E!9... 00000200: 27da 8bcc e326 5e3b 6fcf b2c8 7097 9bd5 '....&^;o...p... 00000210: 31cd 4522 f99c 3202 2f61 f27b d3f1 7b1e 1.E"..2./a.{..{. 00000220: b4dc eaf9 45bd 561c 8751 17a8 8a21 2ea0 ....E.V..Q...!.. 00000230: 4e54 3593 b565 8985 640f e7e7 e7da d854 NT5..e..d......T 00000240: 5fcc cafd 014d 6a05 1c79 4ef7 3158 17e5 _....Mj..yN.1X.. 00000250: 793b ff4b b0c8 dc9c de9c 2ea4 181f b6ca y;.K............ 00000260: 67ae b1ae cb04 82d7 947d 217c 266f 5277 g........}!|&oRw 00000270: 1ab2 f57f 78ce e367 6c5f 84a5 283b fcec ....x..gl_..(;.. 00000280: 4b45 dc62 5cbf c8af 2619 942e fbd4 f414 KE.b\...&....... 00000290: 31cd ad08 14cf f4ab 97d1 a5f8 ce44 dc90 1............D.. 000002a0: d1e5 7f75 f7f5 efbd 628a f2d1 84b5 6465 ...u....b.....de 000002b0: 11a1 96c4 3aac 67cb cf36 cf7b 474d a2e4 ....:.g..6.{GM.. 000002c0: 4bc2 5af2 b130 8315 a7a6 2ee8 36c9 b0ed K.Z..0......6... 000002d0: acc5 6020 8bd6 1253 e7cf 5baa 4535 1a4e ..` ...S..[.E5.N 000002e0: 66f4 e9c9 8885 9081 45ac 4008 2ca0 2b83 f.......E.@.,.+. 000002f0: 77f4 9f71 b205 f175 7163 a54a f488 e833 w..q...uqc.J...3 00000300: 988d da7f b812 dba8 5821 1c2d 3641 d28f ........X!.-6A.. 00000310: 4a31 d53f ce58 ddb1 d9e5 c86d c546 eebe J1.?.X.....m.F.. 00000320: d723 8f58 bef1 78da 4c06 424b 9e4f aa74 .#.X..x.L.BK.O.t 00000330: 6e83 445d 6666 5522 64e3 7d45 bb48 a47a n.D]ffU"d.}E.H.z 00000340: ffd8 3fd9 ea85 2820 1384 b0e6 9820 ff03 ..?...( ..... .. 00000350: edda 6768 67d0 d317 812e 7ded 948d b76e ..ghg.....}....n 00000360: 347b 58da dce1 b29f 3140 669e 08b2 8541 4{[[email protected]](/cdn-cgi/l/email-protection) 00000370: af1d 64fd d1ba d8bd 5872 fae4 97d8 889d ..d.....Xr...... 00000380: f28e 0ed7 9cdc cd21 c3c1 872c 965f 5736 .......!...,._W6 00000390: 498a ceca eaec 748b ba99 4a8e bf70 4ee2 I.....t...J..pN. 000003a0: 6f45 3a6b 10bb 4f45 fbd9 4ce9 58ac e37e oE:k..OE..L.X..~ 000003b0: e2f6 724c eda9 6112 1e28 2a7b fd2d d91c ..rL..a..(*{.-.. 000003c0: 276a bc5a 5f4a 8a6e 50d3 4fad 7c36 57d3 'j.Z_J.nP.O.|6W. 000003d0: 87a2 483f 62c4 1386 69e8 71a9 c869 25b3 ..H?b...i.q..i%. 000003e0: 189b 98f6 820f f39d 5fbe b69b fa6c de17 ........_....l.. 000003f0: db48 9d4c 42e3 7f05 7535 5409 4cf9 fea9 .H.LB...u5T.L... 00000400: 0c31 bad2 0af5 1709 0b02 4cdf 27b6 1cc3 .1........L.'... 00000410: a79c b66f 0299 6061 68d8 757e a0db d52f ...o..`ah.u~.../ 00000420: 4cb6 567e b4c1 53da c132 d928 ac24 c543 L.V~..S..2.(.$.C 00000430: 06ba b646 6758 1ab8 b830 6f5c 8c59 e613 ...FgX...0o\.Y.. 00000440: 59ef 36eb 61d5 6ddc dcec 7ba2 2ef4 09b0 Y.6.a.m...{..... 00000450: d589 f43e 8cd8 a039 ed89 d867 2db6 1190 ...>...9...g-... 00000460: bae8 ae49 3f37 3c66 b5d0 dc6c a43d 6236 ...I?7<f...l.=b6 00000470: c9a2 769d a55c d580 3b15 1d87 65e7 530a ..v..\..;...e.S. 00000480: bc2f 34e0 f06d 9dce cfcd 50dd bde2 6790 ./4..m....P...g. 00000490: 9f98 dfac 34fc ef49 7a8a ed29 fb2c ee29 ....4..Iz..).,.) 000004a0: 8728 577b edcb 965a e656 4abf 3583 1114 .(W{...Z.VJ.5... 000004b0: 1604 a2cb eeb9 1876 5537 1c20 94ec a74b .......vU7. ...K 000004c0: 4dca 2130 aa72 749b dded bc58 8c11 45df M.!0.rt....X..E. 000004d0: 8bd9 e8d6 dc37 ab5a c8a1 2f67 a28a 67b5 .....7.Z../g..g. 000004e0: 3d38 b61a 7db6 1422 8911 e898 780c cf73 =8..}.."....x..s 000004f0: 73c7 ebd4 9dfc 3cc0 7a37 3f26 5f26 4898 s.....<.z7?&_&H. 00000500: e4ab 3858 cb8e cbf3 70de d332 ff35 0f99 ..8X....p..2.5.. 00000510: 433c 2b8d a21f 7ccb 8ed2 198e 417f ec03 C<+...|.....A... 00000520: aca8 4d9d 1397 452b 2b9c 5436 265e 5839 ..M...E++.T6&^X9 00000530: 5bd8 c390 d367 6de9 53cf 0105 fcb6 05fc [....gm.S....... 00000540: bf9d cc89 a5a1 b65f ceb6 66b3 c82d 25e3 ......._..f..-%. 00000550: 1ab0 0e6d 18a6 5a51 4920 5148 8359 aca5 ...m..ZQI QH.Y.. 00000560: fcf8 89b6 4603 ecfb 5422 a191 854d 0af4 ....F...T"...M.. 00000570: 2a05 334e 8243 a92c 9342 5154 8d11 c667 *.3N.C.,.BQT...g 00000580: 621c 969b 5d24 ed67 c8a2 b256 22d6 1d52 b...]$.g...V"..R 00000590: 4faa cc29 abcc 62cb 768f e56d 55bc df4f O..)..b.v..mU..O 000005a0: e61b 89c5 ecae 3527 eda8 a807 7590 fe3f ......5'....u..? 000005b0: b6b0 6e28 c7dd 95c1 80dc a637 043f 0a5f ..n(.......7.?._ 000005c0: 1585 e201 63be 39eb d114 b457 4b7c 7b2e ....c.9....WK|{. 000005d0: a3c6 44d0 943d 36d9 e3cc bcce 4646 9fea ..D..=6.....FF.. 000005e0: 83c4 e848 1bc2 08bc c97b 0f1c e2de ee8d ...H.....{...... 000005f0: 6298 b816 5fd8 ea9e 7c1e eae9 c219 14d8 b..._...|....... 00000600: 2201 3b95 fd84 089e 2618 e692 8f2a b953 ".;.....&....*.S 00000610: 428b 5831 8a11 692b b2a5 e895 79e3 0d86 B.X1..i+....y... 00000620: cbfc 12e5 e2e1 6beb fdca 9c1a df64 0875 ......k......d.u 00000630: 5fd0 dcb8 50f1 ee26 2f11 1fd8 6f71 5c1b _...P..&/...oq\. 00000640: ede6 d8de 07ac 752e 9c38 fb87 702c ea46 ......u..8..p,.F 00000650: 4411 688e 394c 5859 fbf6 e83b fe4e ebc7 D.h.9LXY...;.N.. 00000660: ef6a 8026 ffe4 c85e 7c1e d5d6 4395 93d4 .j.&...^|...C... 00000670: 882f c516 6f5e e1f8 e676 609c 27bf ddce ./..o^...v`.'... 00000680: d939 aa5f f694 3dc6 d9be b849 d567 2e4f .9._..=....I.g.O 00000690: 6ef9 4b63 f810 011b 7653 e4d3 116c a9de n.Kc....vS...l.. 000006a0: a987 009f 5084 fb2a 5506 3092 6246 13e5 ....P..*U.0.bF.. 000006b0: 0a2d 4842 90a6 f76b 67f5 846f f5d4 76f4 .-HB...kg..o..v. 000006c0: 48dc 1610 aaa4 5ce4 9cbd bfef ea26 4237 H.....\......&B7 000006d0: 4e28 268a cd23 42a0 f648 256f 206c 79c1 N(&..#B..H%o ly. 000006e0: 7679 3c94 1332 062d 993d 7b13 c52e c071 vy<..2.-.={....q 000006f0: f247 c8b8 bef7 cf5a 3d18 e0b4 0af2 fbde .G.....Z=....... 00000700: fcb7 5bc5 e7a4 dcb5 5992 892c e8e1 d9df ..[.....Y..,.... 00000710: 59b0 4099 4802 7885 555a e8be 76c0 6444 [[email protected]](/cdn-cgi/l/email-protection) 00000720: f936 9306 3d74 b4be 6967 e30d f155 ab0d .6..=t..ig...U.. 00000730: 636b 4c9e baad 4e85 af64 4ce9 dd3a 0999 ckL...N..dL..:.. 00000740: 63e1 ce89 b086 221b 87ad 13cf f216 3f0b c.....".......?. 00000750: 03b0 1004 955d 1177 2804 45cd 651b e2cf .....].w(.E.e... 00000760: 5326 e3d6 3359 fd8a 2009 a98f c134 e9bd S&..3Y.. ....4.. 00000770: f202 168a 2b61 262f 171c ce69 442d 3d50 ....+a&/...iD-=P 00000780: 8ff5 7517 64db 7a04 fde6 18a2 a213 2ff9 ..u.d.z......./. 00000790: 8e21 800a 1b26 dd4f 390e f848 e597 99aa .!...&.O9..H.... 000007a0: 068a 78cf 1e2e a3e0 d92e eaa7 1b4b 4575 ..x..........KEu 000007b0: 423a 0d53 62ca 119f 8747 a636 9c86 bcb8 B:.Sb....G.6.... 000007c0: 9046 e84e 84d1 3381 6235 6697 3103 4d83 .F.N..3.b5f.1.M. 000007d0: ed75 232e 7e74 96cc 1b2e 8492 bf67 e387 .u#.~t.......g.. 000007e0: 41e8 3c69 9e70 f618 6c3a 0d6b ff4e 2955 A.<i.p..l:.k.N)U 000007f0: 2fec b8e3 3cbe 3679 b85a c84d a800 44b0 /...<.6y.Z.M..D. 00000800: ee21 fb8a a8be a0f1 f37a df88 4b00 d991 .!.......z..K... 00000810: 31cc b675 9e49 8498 6180 603b c53e b851 1..u.I..a.`;.>.Q 00000820: d8a9 7c33 071d 516f cd8e 25a6 ca4d fa5a ..|3..Qo..%..M.Z 00000830: a1f4 b439 5cf1 ffa0 7f10 05c2 a6eb cfcf ...9\........... 00000840: f935 12c8 d320 e98f 9bca 74f0 9deb 8878 .5... ....t....x 00000850: eef7 544f ccf9 2f08 54ed 5925 89dd 8547 ..TO../.T.Y%...G 00000860: e831 a472 a88d 0af7 4a6c d8e5 2b96 a2b1 .1.r....Jl..+... 00000870: 8e1f 1929 5b9d d5b1 d164 4e8f 7f5a df23 ...)[....dN..Z.# 00000880: 7e73 2a7a 0f86 6739 d671 79ce 1635 8249 ~s*z..g9.qy..5.I 00000890: d012 730d 2469 7b8f b01a 0135 217a 29f8 ..s.$i{....5!z). 000008a0: 1ca2 e64f 85f8 fc9b 4849 d4c9 a40b 5791 ...O....HI....W. 000008b0: d304 0bd6 67d9 5f35 6748 5f31 1985 bc11 ....g._5gH_1.... 000008c0: 2b23 334f bb4f a1b7 9fad 8f51 eadf 61a0 +#3O.O.....Q..a. 000008d0: 2cc3 1047 986a 031e 0a58 c831 f93c bbc0 ,..G.j...X.1.<.. 000008e0: ac4d 219a 96a2 fee1 fd3c 3192 2ed5 62e9 .M!......<1...b. 000008f0: 6dcb 0177 39ac 80c5 4ca8 c6be 7536 fbc9 m..w9...L...u6.. 00000900: 1825 65d4 4f91 7c32 2652 09c6 67e6 7237 .%e.O.|2&R..g.r7 00000910: 8887 2ad9 ea1c 5064 e8b9 662e 4504 bbfa ..*...Pd..f.E... 00000920: 8628 3850 58a8 6241 8477 7d0f 65b4 4b3b .(8PX.bA.w}.e.K; 00000930: 0723 e354 049b 78eb 22cb 165d 9e3b f71a .#.T..x."..].;.. 00000940: a717 c3fd d5b4 b922 a620 8504 c37d efa8 .......". ...}.. 00000950: d665 be14 a68c 4e46 f1c5 f312 bd27 8ac9 .e....NF.....'.. 00000960: 35fb c197 adaa ca1e 2230 6003 b05c 72ed 5......."0`..\r. 00000970: ef2a 3ddf d3bb b6d8 ed2f 778c 5874 539a .*=....../w.XtS. 00000980: 7f76 ce71 0adc c97b ab1f 5a34 0aed 3c36 .v.q...{..Z4..<6 00000990: 73d0 f1c9 753f 2976 570a a578 1573 70c0 s...u?)vW..x.sp. 000009a0: 758c 54c9 722b ac5d 6d8c dc95 923f 6617 u.T.r+.]m....?f. 000009b0: c511 2c0d 6375 3927 01db 26f1 e791 8321 ..,.cu9'..&....! 000009c0: 29fd 1003 ded5 61ff 5925 9701 e9b5 9307 ).....a.Y%...... 000009d0: 2ae5 4b2b 3516 83c4 1858 18ad 675c 0042 *.K+5....X..g\.B 000009e0: 37d0 795d 3493 bc62 7a34 d52c 6592 e6f3 7.y]4..bz4.,e... 000009f0: bdf1 d5ee 04f8 890d 6769 ee5f ef90 7ef7 ........gi._..~. 00000a00: 9766 58a2 7f11 4685 5e56 5a3f aa21 1126 .fX...F.^VZ?.!.& 00000a10: 0a48 535a 3f73 17ea 71f5 78b8 39c4 1b59 .HSZ?s..q.x.9..Y 00000a20: 3986 77fd deaf 63c3 6d6d 3f7a b7da 167d 9.w...c.mm?z...} 00000a30: 9162 cf04 de50 00c8 2505 fae7 98f6 561f .b...P..%.....V. 00000a40: 1b9b 3a94 793f 81ea 5917 7601 83c4 dea5 ..:.y?..Y.v..... 00000a50: 6be2 2ec7 6196 117e c65c 4cf8 4ff1 48e4 k...a..~.\L.O.H. 00000a60: 34f6 a035 8bf4 7be2 d4f6 3076 fca1 8495 4..5..{...0v.... 00000a70: b58c 6d17 245f e29d 9636 68c6 4e59 9bf2 ..m.$_...6h.NY.. 00000a80: 8c02 9a8c 3702 223b 0858 005e b08e 5acb ....7.";.X.^..Z. 00000a90: 8651 5aae 458d 3dd5 36cb 4407 d678 1c59 .QZ.E.=.6.D..x.Y 00000aa0: 41c2 d89b 4adc c6b2 53fd 9663 ef4a 2a11 A...J...S..c.J*. 00000ab0: fdef 1bdf cd04 5ca0 8186 a9b7 0e40 b5d5 ......\......@.. 00000ac0: 4a93 fd85 16a9 970e ca82 25e6 bdc7 1956 J.........%....V 00000ad0: ed82 b98c e1dc 5ad2 72a7 2fcb 90f5 8daa ......Z.r./..... 00000ae0: 384a 88f3 26e2 b607 3d37 98b6 86e3 4b8e 8J..&...=7....K. 00000af0: baae cc39 a884 b87c a95b d54c 803a 132a ...9...|.[.L.:.* 00000b00: edf9 00c4 e4f5 b7c3 7626 db82 e5da 68f6 ........v&....h. 00000b10: 898e 7f37 1760 8d87 0636 2b45 dbf5 b5c0 ...7.`...6+E.... 00000b20: 61cf b5e4 1425 3f4d b9c1 af8e e10d 8564 a....%?M.......d 00000b30: f099 a3d4 97e5 c0b1 6662 ef78 6b91 c9ae ........fb.xk... 00000b40: 3de1 7bdd 0957 6682 29a9 e11d 0e0a 85fd =.{..Wf.)....... 00000b50: 56f6 73e5 6347 0e60 5770 116b 03d1 7feb V.s.cG.`Wp.k.... 00000b60: bcbe 22a8 d917 b805 d42c fda7 5a68 ba5f .."......,..Zh._ 00000b70: 2ab3 49c9 9676 4125 0f54 6d42 0261 4a02 *.I..vA%.TmB.aJ. 00000b80: 9533 762a 870f 24c6 4d6c cc44 6e30 61dc .3v*..$.Ml.Dn0a. 00000b90: 085e 8687 33b7 3454 796a 24bf 4953 5e70 .^..3.4Tyj$.IS^p 00000ba0: a2fb 1adb 86bd 90e9 b2d4 821d fa7c 971a .............|.. 00000bb0: 6fe1 b828 365c 1a15 7291 8504 b643 eb97 o..(6\..r....C.. 00000bc0: a2b5 36a9 49fd 0ce5 5679 03ea d55b fd94 ..6.I...Vy...[.. 00000bd0: 2da6 72bc 609f 2672 7164 d8d8 3537 cb20 -.r.`.&rqd..57. 00000be0: 3bbb a7df c711 d506 b758 6e28 8451 78ea ;........Xn(.Qx. 00000bf0: 3846 46dc f01a dfcb 87ed 5c37 cfd1 1566 8FF.......\7...f 00000c00: 0bdd e084 fba9 8c96 0f16 194b d44c 1d3f ...........K.L.? 00000c10: 609f 2e94 ee08 d5b6 c7f6 1045 c9a3 e4ca `..........E.... 00000c20: b808 f369 2dbe bfb5 5462 4189 825f 14e7 ...i-...TbA.._.. 00000c30: 4aea bc8d e01a 6a72 6cf2 0bea b700 90f8 J.....jrl....... 00000c40: 5fc2 7168 dc3f d86d 72f0 134d b97b 55eb _.qh.?.mr..M.{U. 00000c50: 18c5 c5ba d574 aa83 e38f e883 a5d6 5192 .....t........Q. 00000c60: b56d dd08 5251 3a60 91fb 2663 0627 649f .m..RQ:`..&c.'d. 00000c70: 1e3d adf8 e579 855a 8786 4f65 5f72 f487 .=...y.Z..Oe_r.. 00000c80: 78a6 5c69 b4fb ee5f c1e9 2189 3c9b 7b20 x.\i..._..!.<.{ 00000c90: 83ac 7044 ecfb e357 6093 8189 47a7 7d20 ..pD...W`...G.} 00000ca0: c27c d018 0808 a3fd a01f 6b96 3f3c 1878 .|........k.?<.x 00000cb0: 2b0a 25a5 ed2f ce90 3e07 8e01 505c e34a +.%../..>...P\.J 00000cc0: 721d 818a 56ef bf59 dede c722 6995 dd14 r...V..Y..."i... 00000cd0: c8c1 aa67 8dc8 aa84 1cba e268 450e de10 ...g.......hE... 00000ce0: 03ad 3614 fa40 631e 8da4 219a f1b2 62dd ..6..@c...!...b. 00000cf0: 761d 2475 5ebe a135 1dd1 c5d3 c7f8 bb41 v.$u^..5.......A 00000d00: c3fe d4e1 f2e3 8531 4b71 dfc7 c7e8 c35d .......1Kq.....] 00000d10: 97eb 81db 9ee6 5da2 b5e2 7eef 971a 45c1 ......]...~...E. 00000d20: 0dfa 0cf4 c38a 7454 92a6 0efb 7d7e d2f8 ......tT....}~.. 00000d30: 0119 76be 4045 0964 8c66 ecbd 2164 1ab3 [[email protected]](/cdn-cgi/l/email-protection)..!d.. 00000d40: 106c 9863 da42 ecd2 d69f 0ca2 4ee4 46fa .l.c.B......N.F. 00000d50: 54e4 e138 8859 edb9 241c 87ca 59c3 c6f8 T..8.Y..$...Y... 00000d60: f8b5 3ab4 e162 8958 7d64 d629 5ed0 9c84 ..:..b.X}d.)^... 00000d70: 803c aad8 f5fe 4d29 1d0b f34c 9de1 7af0 .<....M)...L..z. 00000d80: 1678 f2c4 8e8a e186 f981 42b4 8e43 8eb1 .x........B..C.. 00000d90: 2270 6776 8ec5 1f19 30de 4a26 3fc8 caab "pgv....0.J&?... 00000da0: ce8f 9657 307c 5405 e2b7 c8f9 299f 23eb ...W0|T.....).#. 00000db0: 3763 12f9 b356 00a4 5ca0 e3de a071 5703 7c...V..\....qW. 00000dc0: 2bb9 2183 41f8 d729 a68c 3881 cdb4 f7bd +.!.A..)..8..... 00000dd0: 2639 da18 617d 92a4 6faa ad3d 3370 e31e &9..a}..o..=3p.. 00000de0: 73a0 d841 083d e44b f913 9cce b5cd 0a11 s..A.=.K........ 00000df0: 9bd8 8089 d732 7ca0 a084 d0ac ccef 6cbd .....2|.......l. 00000e00: 58bd ee0a 5875 5645 7de6 bdb3 5fcb 0d80 X...XuVE}..._... 00000e10: aef2 d247 74f3 8526 9eb3 333a 70bf f5bb ...Gt..&..3:p... 00000e20: 2a79 1b5b 8675 1a78 f997 148a 235c e73c *y.[.u.x....#\.< 00000e30: bab4 56b1 0d6e cae8 a7d8 7d26 6216 4ff6 ..V..n....}&b.O. 00000e40: c9bb b471 7923 9751 cba0 443e 6239 21d4 ...qy#.Q..D>b9!. 00000e50: 4f00 56a8 61ec a392 fca1 cb13 d322 9815 O.V.a........".. 00000e60: 8a29 e6af 0208 a170 bc87 5ec7 d5c2 5697 .).....p..^...V. 00000e70: 0592 ed66 c4e7 74e1 0ff6 9145 6e23 eed6 ...f..t....En#.. 00000e80: aead 2769 40c8 b1e0 3184 4e22 0714 bd91 ..'[[email protected]](/cdn-cgi/l/email-protection)".... 00000e90: ada4 c868 e48d 9ab0 159d b356 975e c37b ...h.......V.^.{ 00000ea0: ea92 5142 da0c 5d12 8595 2adb 3574 54af ..QB..]...*.5tT. 00000eb0: 622f b71d aa24 75d8 b9f9 bbc8 1046 6d2c b/...$u......Fm, 00000ec0: ca92 d60f 9080 8885 5a7e 9b79 46d9 3fb5 ........Z~.yF.?. 00000ed0: e5fc 24d8 fb6e 9b0c bb15 094d f801 1a51 ..$..n.....M...Q 00000ee0: 8397 1c52 909f 074a 39f2 ffd4 d95b cc0f ...R...J9....[.. 00000ef0: ec53 9e85 f4a7 6665 5e77 8b64 66c6 8541 .S....fe^w.df..A 00000f00: 37fa 740e d842 6b27 3d3e 2bc1 5afa 0c07 7.t..Bk'=>+.Z... 00000f10: 8e7e 2f60 4a6a 49f1 eb8d f16d 0409 ba39 .~/`JjI....m...9 00000f20: ead1 1f3f c718 6c7c a213 527d 252a 4358 ...?..l|..R}%*CX 00000f30: f6aa 50b0 c485 b96e e1c0 8a5a 20eb d8cb ..P....n...Z ... 00000f40: a443 379a 1ad3 0f36 b275 081c 9278 82d6 .C7....6.u...x.. 00000f50: 6177 59ce 4a12 9658 5d18 3d22 8f6d dbf5 awY.J..X].=".m.. 00000f60: e531 e0de e7d0 7657 d619 622c b8a3 fc25 .1....vW..b,...% 00000f70: deb3 92d3 0342 d1d4 56e9 5aa8 6858 0d90 .....B..V.Z.hX.. 00000f80: 04c3 19c0 d83b 4862 8d1f df76 d10b 4eae .....;Hb...v..N. 00000f90: c6a6 9536 a4eb 9d51 e446 e021 e970 a5ad ...6...Q.F.!.p.. 00000fa0: c5c7 9d8b 4eac eb55 be16 800c 65bb 1af6 ....N..U....e... 00000fb0: 0a5b f5a2 79d4 6e26 c399 a584 c048 f267 .[..y.n&.....H.g 00000fc0: e5b9 f785 8fba c8af 2e44 22c4 85ef 2234 .........D"..."4 00000fd0: b16c 62e2 c323 9264 a561 d332 5a95 7477 .lb..#.d.a.2Z.tw 00000fe0: 70cc 5756 8381 87c3 78f6 eb10 a3c0 f768 p.WV....x......h 00000ff0: 678a 6acf 671d 0615 5c78 02fa c5ce 6491 g.j.g...\x....d. 00001000: 2ceb ad3f fba9 8fc2 b9ec a053 af52 168d ,..?.......S.R.. 00001010: 0096 5f17 1e11 ae59 b4e8 c9b8 e0f2 579c .._....Y......W. 00001020: 8d38 fb76 80e6 bb19 515a a4cc dbd3 99cb .8.v....QZ...... 00001030: 3ad5 7622 b0b2 4db4 2acd 0564 8fa1 9e61 :.v"..M.*..d...a 00001040: 735f 4516 4909 5b58 647c 5156 d074 0048 s_E.I.[Xd|QV.t.H 00001050: c2e0 5f1d 3b11 13f6 17a5 9dae 6cae 317f .._.;.......l.1. 00001060: b0f1 1237 7384 8f1f e651 086c 5656 d7e5 ...7s....Q.lVV.. 00001070: 3b9c efa2 ab19 973a 5333 f20a fd95 c773 ;......:S3.....s 00001080: 70b8 ccbb 403a d6ad 1016 5271 b09d d886 p...@:....Rq.... 00001090: f939 8e7e affa 6fcb 95d6 7075 12ea a5f4 .9.~..o...pu.... 000010a0: c8b8 c994 7f85 ebe6 6c5e 09cc 3603 a06e ........l^..6..n 000010b0: 2362 1df5 347f 4a30 976e e59a dc80 ff6d #b..4.J0.n.....m 000010c0: b3cf 25f0 9fc5 761d d94f 30d0 80cf ba09 ..%...v..O0..... 000010d0: 04fd 21b2 d501 4dee bf62 76a3 6128 5f5f ..!...M..bv.a(__ 000010e0: cfeb 3e02 b997 18c9 2b97 413d c4e0 c9da ..>.....+.A=.... 000010f0: bc4c c3a0 432a 89f7 12bf 2780 0f71 18a8 .L..C*....'..q.. 00001100: d9bd 0aae 9d1c a27a f2fc 0eb7 1329 a2ac .......z.....).. 00001110: b255 64fb 4e45 b1d8 a5aa 5629 fff1 5e41 .Ud.NE....V)..^A 00001120: 4e6e 0350 78e0 ebb4 a338 2eae 4bdf b3b9 Nn.Px....8..K... 00001130: 9685 3059 0559 bd21 dc79 5b57 d6c6 14f4 ..0Y.Y.!.y[W.... 00001140: c08e 5a38 becc b01e 73ba a384 f013 d43c ..Z8....s......< 00001150: 3947 f118 abe6 5a99 655f e422 56ed 800c 9G....Z.e_."V... 00001160: e383 60d0 8f6e 9c00 2d9e f754 87b3 ce23 ..`..n..-..T...# 00001170: 089b ac19 163f f5cc e4c8 264d d01f 4bfb .....?....&M..K. 00001180: 2575 e365 1a4f ba14 63d6 e0f1 af7b a428 %u.e.O..c....{.( 00001190: 630a 6a46 c93b bd0f 1a65 3116 480f 7901 c.jF.;...e1.H.y. 000011a0: b406 5f2a 5175 06b2 fe83 52cc 8daf 00fe .._*Qu....R..... 000011b0: feb4 02c6 c2c2 d00e 1b5d 6a8d b640 3670 .........]j..@6p 000011c0: 4c58 22a3 d020 6911 d88f 71cb c6cd 6898 LX".. i...q...h. 000011d0: d7b7 78c5 3d90 f186 4572 4e27 841f 1aa5 ..x.=...ErN'.... 000011e0: b959 ebbe 9919 a2eb 2273 fa82 64f3 53f4 .Y......"s..d.S. 000011f0: e3a3 d7c0 e6e2 cc59 c81c 9f59 78b6 b64a .......Y...Yx..J 00001200: 287f b836 83a0 7474 76cb c7c9 a536 41cb (..6..ttv....6A. 00001210: f559 667f fb9d d700 3a86 2979 81e3 26fd .Yf.....:.)y..&. 00001220: d08c acad 90c4 b62a 27fd 727d d312 2ede .......*'.r}.... 00001230: 5788 f85d edab 2659 e209 9313 9279 a183 W..]..&Y.....y.. 00001240: 7baa 7bb1 63a2 72a6 77d6 14e6 d928 863b {.{.c.r.w....(.; 00001250: 5860 4120 3d4e 8b85 b46f be2d c8d3 f415 X`A =N...o.-.... 00001260: 2079 527f 133d 1ea0 fe04 8ea8 ef63 2684 yR..=.......c&. 00001270: fd66 49c2 1e2c d19c b6cc 1698 d8c2 ad54 .fI..,.........T 00001280: 2f9f 5b0d e76f c5f2 6f2f e7ee 2cdc a764 /.[..o..o/..,..d 00001290: a689 8111 5fb2 8c75 6335 1661 5f39 dcab ...._..uc5.a_9.. 000012a0: ed18 255d e1a2 8118 d8f5 2e98 d13c 8134 ..%].........<.4 000012b0: d09e 4324 f465 1b3a fedc d262 9c5f 838c ..C$.e.:...b._.. 000012c0: 059d 8475 7672 faee c9d8 650f e691 7439 ...uvr....e...t9 000012d0: 2ddb 9942 100e 8834 5fc3 81ef 94fe dd25 -..B...4_......% 000012e0: c427 74a9 cf51 1cc8 5848 368a 0559 101a .'t..Q..XH6..Y.. 000012f0: 1383 817a 0a2b cd3d e680 1f54 0523 7529 ...z.+.=...T.#u) 00001300: 120c 94e5 dc96 ccce 3d88 4d91 464e 7abd ........=.M.FNz. 00001310: 1585 d961 c8bc 09a3 0a50 cfaa 0c1c 7f3c ...a.....P.....< 00001320: a52e fc01 3f37 cd03 6b34 d4da fb3d a20a ....?7..k4...=.. 00001330: fdae 7201 3e0f 81eb 0997 8072 4d8e be11 ..r.>......rM... 00001340: 3867 7d25 a052 d318 e702 474c 95b6 721d 8g}%.R....GL..r. 00001350: 3730 40a5 75b6 be42 72c8 00c3 4b4c 9e1d [[email protected]](/cdn-cgi/l/email-protection).. 00001360: 3c5b c7e8 8ed3 2473 bde5 f1c3 0905 b883 <[....$s........ 00001370: 681c 7c04 9e4d c0dc 3579 b49f d01d 60d6 h.|..M..5y....`. 00001380: c984 d2f5 9df8 0011 13e9 c37c aa77 765f ...........|.wv_ 00001390: 0a41 83f4 4ea6 0a9a 54d8 72d6 f6b7 aa69 .A..N...T.r....i 000013a0: 8b9e 5cb7 2d7e 7eba 4a52 57a6 dc1b b33d ..\.-~~.JRW....= 000013b0: fbe7 d8e0 b1e9 09d0 ceca 8214 53e3 eb5b ............S..[ 000013c0: 4ad3 9f71 b075 e9e1 8e2f 3977 c33d 698b J..q.u.../9w.=i. 000013d0: 226d 7901 a2f2 18f3 610d 12fb eb5e 5216 "my.....a....^R. 000013e0: b347 426a bef1 11df 006c c597 c7e7 eaa8 .GBj.....l...... 000013f0: ff99 ef1c fa15 aad2 c102 6ae0 a889 a8b6 ..........j..... 00001400: 75af e695 ab24 5408 b8cd cad8 a016 491a u....$T.......I. 00001410: 4afa d35f ab51 746b 3747 706a 723a e2b3 J.._.Qtk7Gpjr:.. 00001420: cdb0 cdfc 40ee 4544 58e6 9e7c 09b3 89f4 [[email protected]](/cdn-cgi/l/email-protection)..|.... 00001430: bbc3 3f0a af0c 4e15 2fe5 72fd 7212 c521 ..?...N./.r.r..! 00001440: fd8d 33d7 5631 6ee4 0eb1 93f7 668d dae3 ..3.V1n.....f... 00001450: c6e3 f136 0514 5e96 8670 109c 93db 79d4 ...6..^..p....y. 00001460: 63eb 415f ef36 437c 96b1 c157 5bec 648c c.A_.6C|...W[.d. 00001470: 89b8 e7da ad18 ae5b 4a5d 8419 3824 5210 .......[J]..8$R. 00001480: 22b5 cbcc 69dc 2e27 da0d 3324 1e83 245a "...i..'..3$..$Z 00001490: 7127 ffd4 f87c 13a2 25bc 320d 85e9 5da5 q'...|..%.2...]. 000014a0: 4c39 056e 8806 e903 8dad b1ed b636 8abe L9.n.........6.. 000014b0: 1006 43ab 518c 49a9 b349 e2ef 3471 8b1b ..C.Q.I..I..4q.. 000014c0: d1f9 ade6 e66c a3ec d7cf 7207 baca 2819 .....l....r...(. 000014d0: c3d7 92dc 7c36 e0b0 afc3 d124 37c2 e01b ....|6.....$7... 000014e0: a7a8 1440 59cf f768 aa87 5ddb 3015 f5bd [[email protected]](/cdn-cgi/l/email-protection)..].0... 000014f0: 6017 df6f 1b7b 6f13 1bf7 fe73 54a6 2746 `..o.{o....sT.'F 00001500: 8728 879b 9c2b 7eb7 d6ac 1916 5ba6 ef0c .(...+~.....[... 00001510: b44a 03cf 1c89 44f9 f00d 9e0d 5cd9 daae .J....D.....\... 00001520: f341 bcf5 7dba b67a 3771 5cc2 a9e4 c801 .A..}..z7q\..... 00001530: 41d7 c31a b807 5799 b938 52eb 8ef5 06cd A.....W..8R..... 00001540: 569f 99e5 78cb 91aa 6d9c d836 7cd0 56be V...x...m..6|.V. 00001550: b37f 7078 ad35 db1d c4a0 94eb 1011 130f ..px.5.......... 00001560: f282 4b61 fca2 42a0 e095 0593 0611 5f2f ..Ka..B......._/ 00001570: 9dde 8c63 e9ee d6e9 ff6c 8f34 8533 ec82 ...c.....l.4.3.. 00001580: eab3 8104 1b87 6ad9 051b 51d4 9531 bf73 ......j...Q..1.s 00001590: e4a7 d21f b723 0695 ed80 92b9 04c2 33b3 .....#........3. 000015a0: 03f4 d0a9 3e5d e168 21c1 cbeb 01ae ce6c ....>].h!......l 000015b0: 441d 1e53 9044 d92e d57a fabe 91a5 61a6 D..S.D...z....a. 000015c0: 83f0 f1cf 5caf 67a3 cc2e e4f2 0be1 7075 ....\.g.......pu 000015d0: 51b9 4227 7ad7 9cb0 b0f0 31b7 8cb7 e1d5 Q.B'z.....1..... 000015e0: 4f16 6a12 bd22 5d59 485d 56b2 97e3 a7cb O.j.."]YH]V..... 000015f0: 85bb a821 bf3b f0fe 395d 8ae2 baaf d82c ...!.;..9]....., 00001600: 64af db13 ddee 49f7 1d73 438c 36f4 1d48 d.....I..sC.6..H 00001610: 792a 9fe1 f67b 85ad c8f1 faf0 ab52 9b99 y*...{.......R.. 00001620: 2189 22ed 8176 de39 8c75 bdb2 357f 1a65 !."..v.9.u..5..e 00001630: 366d abf8 460a 8c2e fb11 7057 84e2 5fa8 6m..F.....pW.._. 00001640: 6c2c 8349 b0ca 621c 3d89 680c ed82 4d9c l,.I..b.=.h...M. 00001650: ecc3 9d9d c0ae a4a3 d8bb 980e 9fd5 937f ................ 00001660: b4ea 799c a059 9220 7776 a9d4 d11a cb5b ..y..Y. wv.....[ 00001670: d787 4c74 8952 fde8 ec65 9aeb 85cc 7fe1 ..Lt.R...e...... 00001680: 2b89 e954 a599 f1d0 cb3e f1d8 cd26 d490 +..T.....>...&.. 00001690: 192b 14ba 2fc0 3167 2bf8 fdaa 66c3 8744 .+../.1g+...f..D 000016a0: 9cf2 b3d7 5859 e046 9438 2644 e73c f70b ....XY.F.8&D.<.. 000016b0: cab9 f982 02e6 1b44 1a06 0382 122e 8727 .......D.......' 000016c0: c56c b717 82ef 0274 cf18 010b 8c5e 0b08 .l.....t.....^.. 000016d0: 7e42 53fb 0f44 3ae6 57ad 8405 d7e5 88ba ~BS..D:.W....... 000016e0: 4fd3 2cf2 6695 9f37 1499 5d9c bc52 399c O.,.f..7..]..R9. 000016f0: ed30 75c1 8b3e 48da 9e89 b259 dd7e 570c .0u..>H....Y.~W. 00001700: 760b 1b00 54fc fd3c e3ad bfaf 1b22 d60e v...T..<.....".. 00001710: 178e fc6b b3ff 32e1 c9db 0b59 a6e2 55f5 ...k..2....Y..U. 00001720: 6d5e 11c9 da20 befd f01e 01da cf16 87ac m^... .......... 00001730: cd39 8d04 1233 4960 fe97 4e64 aa6d 4024 .9...3I`..Nd.m@$ 00001740: e6bb f9e4 750d c47f 1ec7 1133 c8e6 f972 ....u......3...r 00001750: daf5 0794 3c7f 1892 9b7e 5331 0214 b26f ....<....~S1...o 00001760: 50c6 a38d 134e fd13 6456 1cd6 c3ec 38d3 P....N..dV....8. 00001770: e4e8 1690 afa5 8f78 27d3 1c13 dd5d 4c53 .......x'....]LS 00001780: e309 e6c0 7b7c 7cc6 482d c44f 7048 5e46 ....{||.H-.OpH^F 00001790: ea34 791c a65f cb1c ade9 024e 3b66 0ee1 .4y.._.....N;f.. 000017a0: 6f82 abf3 5245 1181 e153 984e 76cc b29c o...RE...S.Nv... 000017b0: 1d0e de93 0e86 624c 8ecb 9c8e 42cd c389 ......bL....B... 000017c0: b113 cf6d ee0c 24bd 524d 929b 386f db46 ...m..$.RM..8o.F 000017d0: bb6c 4d33 7ece 1f83 3059 819d d6e5 45d3 .lM3~...0Y....E. 000017e0: 9800 713b fee1 740b 6775 49ae c2b5 07b7 ..q;..t.guI..... 000017f0: efa2 e3d4 79f3 f776 7938 5b8f c25a 7ff3 ....y..vy8[..Z.. 00001800: 2070 1dad 24a0 4602 42f4 4e32 06bb 3392 p..$.F.B.N2..3. 00001810: cfa8 e4d0 cd93 db48 807b cac3 dc3f a07e .......H.{...?.~ 00001820: c19f 88f1 7cad 10d7 4e47 a04c f6ae dc03 ....|...NG.L.... 00001830: 28f9 4cdd 26e3 fb28 ed1c 66cd e699 71fd (.L.&..(..f...q. 00001840: c5f0 90d9 c533 e776 6821 e5aa 4afb 73e1 .....3.vh!..J.s. 00001850: bcf9 ffcc 86c7 6453 9856 969b f93d 7d3d ......dS.V...=}= 00001860: dbc1 82de 8856 590a 1472 5150 22d7 66b0 .....VY..rQP".f. 00001870: 9c14 0e95 c081 5211 d2d1 1cc2 3dd7 8f7e ......R.....=..~ 00001880: d7e3 57ac 30d5 7ae2 05c0 ec94 2c0f 9a0a ..W.0.z.....,... 00001890: 1c02 c058 c5df de40 be4f df3a 6cbd 4dec [[email protected]](/cdn-cgi/l/email-protection).:l.M. 000018a0: 042a ba3c 221d 2e6c aa36 9c8d b764 f6aa .*.<"..l.6...d.. 000018b0: 49d5 5297 711c 0c26 40f8 31be 3c5e d058 I.R.q..&@.1.<^.X 000018c0: 4364 433c 08e0 8100 84f8 ffc7 3dce 8e5a CdC<........=..Z 000018d0: 1169 5b05 1b5e 277c 69f7 8755 4492 e8de .i[..^'|i..UD... 000018e0: c2d6 6ca3 86e0 4c66 286a f5bf f608 c726 ..l...Lf(j.....& 000018f0: 79c6 89df 093c 90bc a654 df0e aff8 efe5 y....<...T...... 00001900: a409 2f4e 5337 d002 3bac 035c fb37 ba0c ../NS7..;..\.7.. 00001910: 7043 f3d1 ac9a ce96 8fff aaab 2039 d88a pC.......... 9.. 00001920: 979b ae52 fb68 a1df 94e1 f204 9d2e 672a ...R.h........g* 00001930: 255a a721 10d4 df13 df7c d2df 4474 5c46 %Z.!.....|..Dt\F 00001940: 223d f360 ecb7 ae9f f017 219a 22f7 8103 "=.`......!."... 00001950: 62f1 a171 5d52 6666 301c 93c8 2267 17d5 b..q]Rff0..."g.. 00001960: f20d c368 1a55 1441 733f 57e2 c8ba 44bf ...h.U.As?W...D. 00001970: d6dc 9886 6c2b fb78 5746 03bf e3cd 45e0 ....l+.xWF....E. 00001980: 146a a5d4 9e3f 38e7 b9e8 0db7 8376 8135 .j...?8......v.5 00001990: e7ed 98d2 acec 2668 5ed7 0516 ca80 c3cd ......&h^....... 000019a0: e336 702f e877 42ee 9efe cb4f 9cfb a371 .6p/.wB....O...q 000019b0: bdda 6104 2723 4f18 5533 18a3 1f56 e66e ..a.'#O.U3...V.n 000019c0: c3f1 2dae b72f b7d6 b266 36d0 80b1 821e ..-../...f6..... 000019d0: 3426 fd3f 4170 241e 1e04 5aeb febd cdf9 4&.?Ap$...Z..... 000019e0: d63a 897c ad52 011b 59bc a2a6 d174 0da5 .:.|.R..Y....t.. 000019f0: de80 f9bd 187c 4e1b 36b5 4aca d8c0 2746 .....|N.6.J...'F 00001a00: ac0d 84f8 c0fa 9fbb bece 7be0 9db5 b427 ..........{....' 00001a10: da48 1284 42af 0c30 7738 577c b4b3 f5b6 .H..B..0w8W|.... 00001a20: c528 0b27 0cd1 a674 93c4 9b3d ca3c 3853 .(.'...t...=.<8S 00001a30: 7ac1 1182 9fd7 2038 77b6 759c 1bda e211 z..... 8w.u..... 00001a40: fb78 7b7f 28dc df90 26f6 cc5c 9faa b29e .x{.(...&..\.... 00001a50: a570 b8bd 6e0d 5976 f5cc 2d27 85f0 027e .p..n.Yv..-'...~ 00001a60: 8434 3259 0801 2598 c311 a255 8e78 aa74 .42Y..%....U.x.t 00001a70: 38e4 6acf 432b 1b40 1679 542d af3a a302 [[email protected]](/cdn-cgi/l/email-protection).:.. 00001a80: 2521 07e4 52ae 6817 2b32 fd8a 12aa 306b %!..R.h.+2....0k 00001a90: bb9d a807 6dad 8e0e e3e4 2925 51ce 8f0a ....m.....)%Q... 00001aa0: 218c cc83 355b f867 39ef 3873 58fc 16a1 !...5[.g9.8sX... 00001ab0: a9d7 92a1 3c20 334b c292 fa55 0652 6685 ....< 3K...U.Rf. 00001ac0: 28eb 41b5 94d5 56fc 6ff3 f22a 68db 3d17 (.A...V.o..*h.=. 00001ad0: c7dc b5f1 23f3 dc58 ec85 d151 01d0 83aa ....#..X...Q.... 00001ae0: e4fa 2746 29f8 b815 4322 9d40 4e38 bdbf ..'F)...C".@N8.. 00001af0: 012b b28c f418 8e30 1694 48f1 542b dbcb .+.....0..H.T+.. 00001b00: 2c7a 8148 6b72 f144 9255 a4d4 4d4f 9217 ,z.Hkr.D.U..MO.. 00001b10: 94e5 8969 60b0 d37d ff52 ef96 d070 1b01 ...i`..}.R...p.. 00001b20: 496d 1f6d 5b97 5760 c1e5 2f75 4f83 59fc Im.m[.W`../uO.Y. 00001b30: a4b5 231b af5e 00d3 b951 95f6 5686 4ff3 ..#..^...Q..V.O. 00001b40: 1424 31db b56b 7876 427b 9f0c 73f9 a64b .$1..kxvB{..s..K 00001b50: 52c7 36ec ebaf a4b1 7057 8fc2 d8a8 40e9 R.6.....pW....@. 00001b60: 39c4 fb45 c3b3 6a27 245f 50f3 75e9 271c 9..E..j'$_P.u.'. 00001b70: 4841 4fb2 aa87 a624 badd 94c8 6fda fe3b HAO....$....o..; 00001b80: e4aa 8e73 aea1 d9b8 80e1 223f 057f eeb7 ...s......"?.... 00001b90: 8be6 8dbc a540 be28 ea5b d26b 87b8 c7a5 .....@.(.[.k.... 00001ba0: d1d1 148c c748 c157 fb20 1b41 cbfa b63d .....H.W. .A...= 00001bb0: f378 94a2 93d1 63cf b35e b255 90a3 5ff8 .x....c..^.U.._. 00001bc0: 2956 3aaa 9364 b7c2 4c17 81f6 aeed d95f )V:..d..L......_ 00001bd0: 0fc1 b7a6 ffa9 fff4 0f1d 30e3 3b44 3b48 ..........0.;D;H 00001be0: e15e 85e2 e997 b0dc febe bae4 528d 660c .^..........R.f. 00001bf0: e8fb f21f 2a0e 3615 053d dee0 9423 6d5b ....*.6..=...#m[ 00001c00: 8602 b320 4bca 1e4b 98d1 0cef 730e 8e6a ... K..K....s..j 00001c10: d684 6592 1db0 8361 9e46 b234 10f2 942d ..e....a.F.4...- 00001c20: acd4 a96f 6894 00a8 68cd 4e56 ecaf bbfc ...oh...h.NV.... 00001c30: 3f3d 9abb 0419 8caa 5781 d942 965c 1396 ?=......W..B.\.. 00001c40: 7581 e4bf 4157 1bb1 7d86 6e86 24e9 c59e u...AW..}.n.$... 00001c50: e147 402e 0069 45b6 24d6 1a47 83e6 e2ba [[email protected]](/cdn-cgi/l/email-protection).$..G.... 00001c60: fb09 7f12 13ce ae0b dcd7 83e6 086a 4100 .............jA. ``` [Answer] # [///](https://esolangs.org/wiki////), 14256 bytes ``` /Q/\/\///0/A8Q"/!UQ'/C2GQ?/5AQ>/@@Q</U6Q./6GQ,/ACQ`/AGQ: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7WPHhyNQWdBvwriyFfPeE2q0KFLo9ctRfulzHUUlRGa2SP@1E8inOYwOBzCdSJJZ@uKkKSmJufjUN1enjOr@iiOio3o8DimUfRXBrwvvKwdyVtdJJnuJGpchyZ@hvnqeBFsbRDLw0cudHolroEZ7tKymylY3dyJm6UaftVFHbx720jFowoRlWUJB9xvcCaZKVuvOd9mjKDCkQPIY3fcor9tCX1QFEZ9E//otDznJcN@km3V7mY3p@Nrcb81cNmHpjs4ALQh7QIC2QxMDfvrFB113MbpoNwja1@1pkLGd7vBbRWm/srSq10ETz21icAmvnT76LRkwRCeIXmct1wlZhjeiDJeLLrmuLdj@kT48XCS0Gtip3iloe2z/56/pv//9/w "/// – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 7486 bytes ``` •тûιX>Þ*ι+»¹œΛaá3ðwkç.qn₅‰HYNgO m$ǝ‰š¹¦øýŸ‹ÁKÝ9ʒgāBVδ)EΔü§ý7Q@3)Züf†Bª*Ωā8∊á-<ãäε¬JåS©ÌтíH´λÁвáλ%ò¬õ+Pð²ǝÜεHC°₁+íP)΂©≠àlíδĀ²ƶèKä¹vôµǝÏÕĀ₃TùÈ]«-Ô™εˆðʒì—zÆO¼‰ÙÙœ2gǝL§´āǝ¯xïd>Å^ºÁ%Ü|M₆}×i“ε*г:tнθ§òΓθIεïdƶ₂&ñd®ηôΔÀxåZS–€wÇ b»fÒ∞ xFØØÎuŠh₃м£[üï/θú‹*,©ÔÐ`êζlΣº¤¹Áǝ¸нòô^X¬ˆa8ƒ(WÖx°ˆËÛHвù{±š®÷ÈÑþþW‚±²PÚ₄ߊNUNdZÜλ¸ù<ûí≠ø Ÿ½ÊѨYā¦’ÀMðŽj∍Õ;βpJŽΔ¢Ï^Hd‰„₄33¢PÓr|jBÕÆûÓe₁º“Â]¸Oû)”TO{ǝ¶ηYŸÆθs"÷ƶ>nÁн ƒØδвßćJœ‡…Ô`×g57‡`n2—Û #ì+½ƶиW¶õA›AΣg´Ù·rAÝ-}Tƶ{3±Λæ$¡mćÅÅïû:îg#ëàºýмÚ%§1קÀâ[pqα‡¿É¬ôiN›qΩ+₃ˆpºAfò¡¾÷Ö‹ǝy·₃V½ò§©ºK°ô/M;Λ0ûrθвζ,® k6?½ƒ;₃,˜PѪ)Y∍ĀKƒÜê4ΣpÉ¿ºÜneDªŒγιw3¥i´›BÄœ·¥ûKñLh ×ΓßP¢FŽp²≠b“û€Pµ®ýµć;}нÛ˜Ý"(»”ý#@Wr¶R₅®Þ¢ôHSh381MÿÂùÓƒ!вF¼‹§jJāltΘm¿VOßÖœ_õ2вC~[b›βηfB,Û_MÛe¦eð.ε¿ǝzßoÚŠR§„ïoΩ±∍óZ_®ʒBoíŒj¼=m»K¯îí…нu„∍ª>eWæʒ|¹/t½β¼§øXтh=àĆôεǝ§CR^ìλ_&e)ò8”,εùu½и”`ƒzHå7ÝüH¢qì‰jµw₂ƒQRëÈõβgŠØ˜½NOí·₃¯ºd¬NÈëŠzW—$D)ÑƶÛµH·ìA∞ï<ž₄»mpªìи¬λû^8B\Ïƶ5‘R∞ÈнOøJ$н/òƒÝá<“ÆÁV¼qζ¾TMÓô抶1ÙΓ‰Ý’Î[Ó‡ εt'L!w:”çØM]R¦=¢èožÛvŸ‘Hö{ðkÕη†ŠÁƶ¤cHí;½íÌîĀ!Èí¶¥AöLpαB7ζO∍ΰ…L L:ε₁k^ΓúΩo¨u«ë¯¦¼›B68›¸s®b|™H±sþ'–вζÍÿ'εµÉĀ˜ÑØмÇÿΘqó¼¹…ζò$δ›½ʒíµ®Ù”…—YŒÿ¾мvV¿C³³—∍ÔsεìzιÎwÇ´ïΛs5ÖÅα·‡₂Ûfîjº’AxO^\l€qā≠¬ÿ§.₆\!Z₄’i∊jÌ#∞qJôÖnºæØ„iĆ\yÀ«(×Îò¤Ú‚ìUKêµи/î²¾½ΛÄ×c∞iθúʒ}2ߟn‡à||Í]ôT¬?|²₃”%.ˆÇN.m{Rø´ÁÞåD»¯˜„þηÉúkèÍ¡/η‚Ž°AÓÔpη6UÝλí?Û>’áµ÷{*¶λÐ`¯íÿÑ:ζƶÈhë₅qθγË₂DCl≠Kk4äÕΘðÁ$LвGγÇw’I:ÓÒ6ÆŽÂ*∊\€7Σ_«λÉæƵ6'KñS/∊∊Ê×÷‡{i‚mcε\θ²¼₂²FH«Î¸ζε¥rå;W›Íǝj¶Àâ¦β}¼üNÊ¿žëO$VI*λò›J₁ΩU$ ëâk…Õò,3ÚVmn£FÆCÃC”Ûû×#uˆΔIÑ¡îgWò½¦>'¹ƶÛ¨öΔÙ3|4ƒ@‰6Õvãêõ∍ieýʒˆsŒ„¸¥‘l‚“ˆm*ùlĀÇOÍ[$jnY΂Jr&²TâΓ!!I$ŒÒÆ;₄WF˜в|W×9DĆÍ!3¯иëKÔ6½|ûáF@ǝY~ŠZ∊t\Ó)m+±ÕµÁô܈oâθ₆b}ݽ“'Ê#«ˆè¦Ä‚Í,¸ÚÛõTaA₃ ‹dÔsé)’ýª~pćr‰ªÝr7‹δý»nÕä‰>Žˆ≠£Ù.ý°R©°Dîf3Én[Ưǚ[¾c~,‹ÔÏ∍ÃhbÁ≠ÆøÁÝŠΛΓ‚tʒ©÷¯¯¸Jåóù[мÉa—āèΘÖαΔðA8eεlaиÕˆð6zr|\â`:ãÕ;phÔµA¼ÙR§ùdOw±˜sö%fŒ°‚]×CZγg³c}Fvp-0äι±ÆÀY0GÀjkëq¬¹Þ»2Hćøîmt’₆¡ΛŸÔX∊<1¯‰í¤¥ØíηOλ2³hÒÕ&ÊýÓw÷‡»∍ߣeùýŸÈÕтÞÔPι:œpžòε!λmŒEú0ê)ßr₁ù>SŽ¡ü„x×ÞζrÛÜ₃S›ΣI!₂a/lõLiHÑ¡ˆxâNS₄āǝι8Έ…éœ×.±‡»ˆ©₄4Õ₂cõ@ðMØ_θαcXVθºƶàW«!‘Σ½мÈ›—вā¡S¸öˆÝˆ#ÖλvΓ‹):Åλ€ι*1Jy}Ý‹IIÜ´òĆ©.<¦eN¾¢¢@Ç₃U4Ć’Åtعvô}ºdΩÒ",_^0«+‰¢ž÷MŒóIÔG‘¸\ë∞.-h)s≠;-тĀµ 2}>v^ph6Û´!›8õ™βĆ)k₄%§?™üçK∞´”×вBUš/³₆#~áÕQ+иw§Îe`ªŠ³žΔ÷Ñð¬ï$iúƒ&íó¸δǯŠ=вĀºÚªiCq³q«w\áX¢kÌØ#Jû"wØ·ƒþÀĀ–x-[Γßè`ǝPC;±I®O€Ć_i]ιy½a.ǝ13C/Λliš£?4|vƶìœÀ³y]ÇÊ)ñ₆'MåVÛ)ÛÆ~≠œ…ÖþΣbĆn|—.éÞh₂Øi₄g4‡»CðÎ6!„¹/ïÆYĀ™K1oáβöÀn₅–8qªC!µ«B™+7P]8Δāè2и1œàe´õŃõY:Œ¯Ù4p?îb JSº¥t–ζpΛ¢∊Dßλ{ΓËM'vaÒλ®ü₆|”RƶÇì¢∍λ–õǝ²…‡–èd6≠Lk{₆pkƵûΩì±&µ∍&U>?ô Ÿm¼oмÔotiδ·¯ÉÁ}ζĀ₃ćÁ09?†γ‡èÊÄsβPª+cÿKDݳlï|áγθöYا˜™~þE!áfuú@d1óôÞWζwô4P¶¾q½;e>ćþ¿ò×x¡jõˆ{U™“tl_¯bR¥|pβĆ‘εαβÓ„Z@Ø’ÉÙùY_Ú‚ΣÞεиåëм₅]‡V@ ÌðûQTLŠT!rßp8c¤‹=J¤ùΣ8EÁ°‰ï’ßž†#ýλ]тØÖ₃œ”`ÚË„cë^ÈΔKœl¨/GGÒ¨+¹Ì¥4f∊9§~ƒ×r£¿ÔÒž6`‚Vāû½Þ—∊Åvï’MØ!(α“?Δl'í]šÆΩä;Nü|`ûѪ6Ôé¾rÂœ¾íÇ®†0wøK]eœ¹Ò|‹₆PO[ãêIµ¿’1δ¹;ÒŒиZŒ;‚o«6ÀuZMā,q;ÓMîÌpÍ_ÚN¿Ì₂´ÿ~Xêн;¯¨ìÍ6Wʒòù@!MìƵèÄjWÖrÔÙcƉ*¿µ©íyÓ*rÔ–{ε—ƵÁëvʒÇ0ÁS˧@иιв0™4G₁₂²§ƵJI†(ÔāÈfÁTвλzù*‡V≠}Ćú$V&¼ô„µÅÂÎΔûu`Ĩ_%‚X¹ö¸+©вñ₁+≠LfÝG(ι`Ć|5‹ ₄µú—øDf6Ā/t‹ˆó÷ÉûÃƶÙ~„₅Iò ò‡¾н|ºÑÂã₄ߺjÁΓlRQΓм2j∍ôÚÙ¥ÛŸ`ε|·×Ô“∍áWPÊÓи[zÁ₁3λ₅I9Àgδ¡…£¯ÃO§ ÒŠÆ)þð âÿfÔJÅðтƒýMNθ¡δćÅʒƶ«÷‚:PÀ ÒïÜÙŽ\QœF ! X©мΛÜWÍMšι7‡‚”ùîα×¼ΩΔTë3.jH·è₆È›š=Ïγ∊m7d¡₆?cÎÔƵ%∍îþHëÜĀ₁£"Lë#î¼Ú¾ª+ÅòipмË:UÇIʒā2ß9Þ“—ûQN¡kqîøв2Ý∍₄#:¼óÌGýõvK¿ Ô₁¸ÉOÝ×òAe$C]4XÉ₅ñиÊ%â“÷:¯J~4½¥#H/èŧQ ñŽ¾ γQ)á‰|Õráj}ā€ÓºéóúÌ‹º,oJóYΛв«õ3¤%ÎpBÕ‚{dÈQÄf.€nñ›и5a∊Íq∊ –ÍÞ²˜Õš÷Ef}÷ćœû)Û_nIÅ<½\yиõµñ{à 5N’)¬1·∞yltë!ˆç(ù¶ügŒ/þ!µXŽ¯ßõxS”ζÐ,ÙU:¹+ΩŠт/©M<₅›Ù»´i₆²<Q¾BÃÅΛvÔQ0—ÙVα+s@޲ЩÌc»#≠õ¢·Sā·A1ÙW”+₆%@ÕÝöðc²Δ7„Âæâ+ǝé<P3æJ.å[мàΩM1Ö∍b%–∞Aʒ€“δ”ÀXâ1¼f>ïÕÏJΓƒ+¹₄ò8T‡çü-<ĆàÜ`’δáds·т€$““ÅLÿ[åSGîSмÇ]θÝ'Qœî§2Øïβāឪм)þßWSÀ˜ä%ÞaÎmÍ:ɳazγ™nIGćRÊI?γži¢Îʒε¢gô@.ë¸Ú¦¨6ƒï}ñu™U/PwH>Þ¼Y¡ê†VªßiÖ„U½¯Ç¿Šc÷;ÉUߌ^"ΣêΓØ.]ÚåxãвÞb)Λ¯®ð·Γ·<Ï’d‘Õû>'ØߘîtäÆ÷Š.‚Æ«æεÒN¤Â'›iXη»RlÃïþ*η¹ÑÆIæèζ%{$ζΛ¶Ƶ8’ö/3yā9ÒY3q]©zΔ—Ê₄UÑÖ¨R¾мJ)Σ쯩^›º9ûĆ cä…þ¯λú‹ó2Ÿn‘÷Ysàÿÿ∍нGV]¦ý)}ïÑbÔýŒ0ºðƒΔʼnTζµć:ûu¼&Т⫔M₂*ª₆40GÖÇÌblǝɃ94iD∍ºâar«∊Ó¯0¨A/}ć+∊Àã¸Ô¹ô®ιΔâ”’ã@ªǝcÖΔ—-ˆ~ÆÈç%n…*†∊нā×Θ\]'*∍–({ŠSnùZ‘rtÍ1††…ûlŠIŽy9šsgêÈô(fвŽÚyнmÌ₂δcŠö<ìü@т6θ+WÿµßÖ‰6–мüžg˜Ƶ₂‚þΣLŠúǝζñ%óYÐ,§R[o!Ÿã*^º;&Ûîćÿ‰δηŽYΛ:Λ;ÎLÌζLvhÜθâ“Å4₆DÿûCz\躞ÏúÃfÚB¦ÔÆ≠kd«Ê©ƒ@ì”"ð}γbΘ‰£ršΣJü½¢Àλθ÷µ¯“«‘å∞ÎθëYªP„UÑR`3Îó≠Gë≠&ùYT®ÉÚÝ{'γ]ø[мvλöÛ͆?h¯ʒÖ:+%¼Jć‘Ñ 7óGö‰»нõ;¨V‘ǝËS€ÍM₃©ð·θUÊ$’iL4†èxçáA&Àиd›12dñRāн /ûéxÜ/ÉßΓ«ïv%’à₆)_;T¢ûÁé_?ýd„ïδγ0·ˆ+ l²éU₄ÕòÒ!ι}₂œ{©©šzЇѤä³V¤™~©’²ãÿ+þQtŽvbÎpǝ}þQðøÖ$³5æOƶÜ¡ǝaä₅ƶÆAŸ,,G®ʒΩ´ô·LÈ£Ãû∊TÉ»Ñã*¶HMûú?ô®Š$µ©ö5α~η¢+н{‹îι=ÍâîCµÄ=œλ®nìÔ’þ?λüš₂wYaþ“:Eav‹yWrŠ°U>ß$ßÙλB∍8> в²’¤Žb≠àÚöàk¤wPη†^®IÂ'}Ž¨öтEζÌ¿kÙ³þ2fΘF³¢¤‚^˜åå.alÆÙBub†öÃλ»NDqλγA§…Ø’ËÝ=¼dåŽQн[ñY½^∍3∞×£õΣok±bÖ¡3vCα3₆ÉΓïΔ#ÅèµÉ™ηÓØjÛŠ!TiÕk×₄Ë´±ƒéó¡tƵ×η<ƒ™¾.Ó&xµëæ_÷0R4̃ÿŠ„ξùи₂?™ýÌv›õ¿þγäγMV2ÌJcº€₅èsI6\¿βÜô‡мázyć4Σpóuβ‰₆™–нR²Y₃R.ÖL1™и´èÜ¿₆Cן$Þ₃Ü¥Ā®₁Õ(’m¯¥ó¤Ìβ/+.ÊãθYΛîNÝŽ°!Í¢°Ā‰~rȶ₄OEXKˆç_÷Œ+ûćßúŸ!Ω壿p:ì´Âƒ¶d—q=AØubˆÿ¼ø'w₄ι%ËJ4p“<₂®{6∊WC†›aEćsrƵ;;×öêþEćÜtálÛd»«#в₁ðì7ûþ,žjjβðgå®ÛŸиçYgmd:”ˆ%ćƒ{nä†k¯[αŠιÙµ+∞Ïà*½˜¢·N₆ýßʯ-Žñu=maáÑFKζ9вΛ₄×δ…Āζ×ñŽ£&m₃ˆnˆRγWĆ‹Γ$;‡Ý5t<©%Ò§´¨æ¶εËΛ?Юиzˆ)1¤%àÊ"³à¿hŽ}üλüÃ)Óòg&tû.†´k0‚×¹Ýö\rλ±"¦Diÿ‚\ ú}¯sƶĀ²‰°§ÐθÐïꙿ%åãØkÀ₅P}’'ýÈ47NæN>°pΛá©ÀfĆá₆È₅kΩiæL¬ç¤₂†ôåw¾õ/BQR!ÊΣM$¶“swWØEt∍¤ŠΔ«oγ]‚ι-cb∍åG¿?˜Â~®_ëÌíŠ0(YKRĆdu†u~γ¢Â‡ý^G’””dÿßÄÑ››'≠θÉ渨Gâα-ËSvøā]ËâCðmLƒAÊåÙ₅=и®ÿmÌñλŸ6gƇʒUR‚¯2ªÙ†₃{tвĆ¡ĀÞp7и₂ĀïúfÞζwp›ÿ₆§;= úΘV:™ƶOæ¶₂sû’ùË0VнN’ΓU/³øõIBDÍ"²βg₁â\ηwFä”ĀËdÂη},#ā²`SÑûƶÉå2₄Õη\£^ýåǝXxó‘!קвm¿IΧÊëć– À&-¨ýðwtf«†Qì*‰þÉ“Δá>=ßÎñð»Δ~JíKJ²ËŒà°¸#Nβиβ«ºð€(·αûƒGü₁«вĀ.3dCΓh|ˆθ∍iŒ½Lò∞gмā₆IΘ₅÷~C·+Λoв₃‘&÷\¬³½§‚öтF§4·…?Ý®þÄa'¡7òàB5ĀćÓη‹£‘āG¦w[ù)ε§!ÃM\mìʤH˜piß…BÀβĀи)ùLĆÈ∞SdΓªíí'åx{ÕA»}εà₁çλRD7ê¬íÔ5‰¾>åβ›₄ÐHÊ^_DÑÞœ’þ₁αè+Ô€iýǹš#₃D?™V*≠µ¸Òàé₂PZáY;[3Üи¨Ā∍Œ+fäΘÊ—Ý8ÂSN´£W3₆tœ]£½6ÞƶÏ NòÕƒ"5F>jýV’ʒ’ÁÕ1ΛÁ€ÌßðDθä—Ü*¹ëW”ƶ₁ñ맋V%т‹Ùè Š¦œ |7ζζñôÄ$$™4ÏK£Ê½vÈ„%[_ÍùĀÔ¥†™°„É₁]<ÛVƶиT\šI¹≠fΣ”λg¸2ǝ| ]ƵǝA¸Îζ#³≠™Œk¤Dð!HE3ÿÍ«]æ₂êηaM„/ËÏαYCh¾Ôˆ₄"'’S9ìU}té¹т„õéæ4∊Ã@´ÂÝüXZèþǝøPÌØÏš,jV5β JDç…3¶Ê²ΩYȹþÓØHéÌþÑ≠’∍Ô‰ºö8Ê₂Ô/ÀÄ«±ý°]šñA¼ˆĀmÓ≠5»_ì3oªÛ½ÿŽ+pĀÊαâƒΘ±₂Ö¾ÿ4ˆYQ{ÂÉмi˜®x1δè‹l˜nÈвË≠≠†³Qª}FD C‹λÊgS¥ζ8Xþ"°‡‚œe€Xû´Ïʒ ʒ€¹œÆpîõáŠтVâ!мθ~]\®,ζ#´Ä н#Š$∞¼±†åTgÐk#‰ùβìﶌº¼d¨z f—™‡‹∞§αÅcšÄ₆±åF3DÍœôÍÓÿÄ’kY‡₃CQØ-Õ·δj=…Γδ,—`ÂKg…`‘ÍācÞδªÑÿ‹jß∊ιgε5ŒεLl[@L®ö‰*ÄÒš:Ôô.WнãˆÞ÷kÀŸÅÕš!šÄÛáβdāì|¬ÎÚx«m›˜Óq±hŠøÔWδΓesó1ß`@¼ý“lÕβŸùò–.tŸø~º∞ýô+Sλ‚7µ¨_©‚˜$°ubº1ýTΓ?;Êγ₂₆sA’þšĆNaÖH¯ùÉΣÝdrY–P&g#”`Þ{¶Å†Yé‡β̸ãÈHµвï½yzиÓE…x@ÞRši:"H™ß,²ƒ∊ñƪ₃1Íß®AÞë*Ö₆*¨±ÏĆe₆β¨ʒûf¥ƵΛjå{∍αa0yŒŒtbC‘ÎáÙa÷ŸPlB₅’æ‡ûƒ™NbóLM₆¿¨αOU!ǹƵ∞ÌrÞ8!éð"∍7‡+úƵ~K₁ΔÐÈ°ÌâÙUhi·<x–?óa¬§Δʒ°ηÊθεµÑ4KƵÙÛ^'7õ≠dƳB‘Ê\ý£nV3¯Ωηćиγéqcü·x-%ʒ₄Ž9и%{mïβúŠxÎт3=˸Ú4-óˆƶ4aV==ß∞êΓ!Ö®?gS!08\甞LF™ò?S¼¨∍ûaüñ∞€oõtu₅×β£—₄JÓ6B6{Ñ:‘{mÓ.@₅Žp∞ÌݶÃ[f,&ÇT?›@Z¸GTƵ¡fªJÑÞGJíÀ~3ÕºζlΔ ýåí ŠÍ¥J"Ç„yNú»ΛÝÇb/<”»ej‰ć`ï-xf₆e]_%ÞS% Ò2§dα 8\¨@á¿wLâ¾[‰¤À´lJÜh¼ùÑÈY´ŸÚü—ÌΘ¥ŸβzjÏxΛr‚d‰DŽ“иÛÿ>I₁∊˜0Ýó€WΔ€)_£°q?çi/m ǝžG~e(Ê·}∊n½“x¡ǝqCkJ¢XH₁\Ý3ÀØçhÛ/ƵIεβèëÈBh<ÂZ)obV¡êyΓ øλ½∊§Ð©¦<_*žøzÛγS™íïB”uĆΩföã¥S{ζñΣεºÄßaC∞ηÓΓ~ΓÖfÒ63βþ¤W€€O₁ÕтB«ΣΘm`¨úÛ{ʒAγWÊõFoƶ+àvay±₂^…т&uεyj9'/:TšÖšÄ∊WÒÙαʒÈûδçû¡нΘ©OΩVηв—†θVå„)¤ćǝćQøåI0p&∞š₁Íì¿Ú+ âXjÝv‘±æuZ “„ć®₅þǝv*ÚjöËÖgтúÜ}"M?Õ:±ÌtÜ"δÎΓ0‰¾₄ª*—Êjl̽`Bp½ôJ†×ÿ®Q3[ððí¤å¢êo/¶¨tpδ₃Y«/65\/°8¿Šn7³¸DÍMÈüS6iÞÕD»ιƶå·β’-]oGTηα–!∞NΣ¯¶jf¹XA:_îxÞ^тÔÀΛá}≠€ú üʒΘмóæcÓ8ñÙAzN»ò´^₁v¡Ä₅R;∍6–`Å®›×´2+kεÌçøaθ€Ï}^™«&†€U€.Þ©†[.-¨SθqžλãQŸŒ€ÁÉ·¿9sÿ–€¯9ÐMK₅žΩˆ˜í—Ã6äa*ä⃛O'’&iĀвθàm^ÛΔćµƶт¡’āèõ/hδÌŸ₄س1α¤àû₃Σ³__7¨н˜øé)âOPDLζ¢–—EKMÂNn1W¦₂)w¹pYм»òvNA¬ý'Γˆ{Irε§toÕ„¦šñOÁc»₆|0š%õ–/)†ºrEËn噫¹ÿâeR‚žò∞åĆ?—#W( ŸÒÞæ|c ¸K2¸—7м0ćá& ƶи_₄îΓœ»x”ï™'š÷т˜93/ÇÙ”oβU'úšтäüñ@и;"˜èCƒ>X,Λã{hK¨¡ŽäZт‡tq粨xÌIãôÿä·èZ¬Δcúà²û\¾¤λSû¢º¥9¥+ε¬-o₂Ù"šëмEždþ3!qè¦û¾¨^+Δ Ë$ć´0óÛI…K—ò—x≠ô+ãw€ƶüô[½}Cl᜺k1¾-d"Ë]VVWƹ¦ýs!6¡´,ä@иûår@¡v∍Õal¯–θKÛh‰>ZJéÃYf9ןÐ×qbi°ζ∍UXï‚‘bĆ@Q·t₅Å>þƶï@ʒ∊«k;”Γ2¿ÿªтñ\…?`ú…óΓΘb|α¥)^<(=Ÿ₆‡"~vηòƵ¼ā¾¸ΩεHnÖÓÍuNdø₆{ƶa₆³ĀтN.FXàĆ3µaeâÒζïê{¥3®3±Ù÷η:oćв“ʒβиáfηóêaKи\ÍS}ćhÇÒÝ3å´wZ¨H|RαÓšÁôu48I2ÍS˜xΩ óØ Aˆ*B%FÈj¤o5ë₄{þŠùÆVÎΣΔn<¹|\”¹ð₂L“Á5®мx,ÐgŽÜāŒ’Ex¸∍áRì∞œ%UœÚ"¤äqñˆ)₆q€ºÎÞÖ–žl2y¬Ö"ŠýG₄Ôtн₅:óO{œ7gÈËÚIðÊa²ñHªS?æC₆`ÌΛF∞B)ÏÒNÏpΩ0çt]εÄ₄«— 2êœн€“ƒÁ6ā—›èe(θ|'†A%"´ôγGkg”ØöιÂÜÿ2G}Êbìмçλi:¦T׺₆¥₃∍8∊Cë¦ÎJùZλ}màKaBøü¤„&uꛫηo≠vW¡λǝƒˆO9˜µ¥+$Q{—αÉƵÙsÐþΓΣθ¤₂ùv¹_ÔGªθ —s„73θYéʒ₃òWh‡,îNʒ/Ôø∍0ʼʋžÀвýô©é(óèÂqmÞ„+HÌλÅW„k?"í’Ǩζ^Ωθāƶ¦ÆÚ+ZçмĀ¿¶&‘–…8Œβn–|₁vûŠË\ΓÀËƬ±Èxø¯ì•4ö ``` [Try a version with the `ö` replaced with `вJ` so that it doesn't time out online!](https://tio.run/##JVt3U1Pd9v6fTwEIKKB0EUGlqfQiVZQiRXoHAaVMiBoQRV8TlBpM6E0gvRGY2SsHZ2RmT/wKfJH7e1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VRev7oL7VXmpL7SEA2DFXYs3GsCg37xO5uCJg9B8Q2pTNwEkWuEeFqoIUccSCdQfjgEC57L1E6YY/Z1b0nczWAb7xNx8V/tbEQA25GHCzFGcdsFwgIXMp2XezT/i30f4/UAz38xHo9OheF9NBHROb1rvRQJuRleNc9aa8HeJ0@fld4hzSQ0xe06z/zqeBw7RCBpQCN7qQgkph78e8TLCnkQSs/18IvqOizTwMHa6LZMXLC6KP@G0l@c/7//vd/ "05AB1E – Try It Online") Just base 4 compression with `1320` being `ACGU`. [Answer] # Keg, ~~29872~~ 18008 bytes ``` ‡1229769972262440840914727645274345682540406609304568884862926340793218455130887715162068129549355321803218173656794410207421983304458198367214649122525663673362934345290524357064085900270191341217902957576981212048606874907939849315096416270570685716443130572591739768026241351892812265951851301494384951132692442813092528368279619996972987050485879686207261053889017001520140272720162621630329395409296065427861604527236404743258286157654372871028806778211438395242253891572078183604800612931937826120598888382248388598280083843577247656912674622919842712535585589649603509001095863547810817077902398964957827180268584103438275390041624163348921595274849969049661923023337666521725858745368146713074157363419797203831210504834818978164052880482258159540114728150425625301732942056513844023648924490089702569897942372547984473520085739435720506236035510642685776972243391793417082460246010780599850479767673240905889526401286127570068665468508243120173758717818630146928614751654837642669482601249225952952208411970090930833845733508094571347955589328109927131499990380676370464247644397486822444748015028671071135744999340934890935615460997653385677393947073970908818567393639815738970653113217409016741696529755715756612050720426679067698110637288092453898586760691588411082488082877613478022659054608787769528410260185454336843014741113111357556292755532164832239454333585244411641833325316642270862455913274654562884236651257150638140537828859305826045194963038168347590998320806786930182572946514083553404524066032480665928208697588268964081909305784920080726150955846857962652779905901747407981428733780288150791287341673230523341015906347352187518560205372794350517498986080348613358855603142671700687618353662837496155184294344070723732045539972453663753511115115441046047349026147438036288023280233941426159301911665224804172906544584304217904465847046843191123925427520910132509935862816760055239020768906897682241542165037638348904204503433237534948568438544144382338137750589449243356326582507310952526081284152972731597062614880387317348517949871009897850682867538923980203686226074685634256224033307799106132027504784090187800086328504469313742512319975477982387330352228492180810077802884040825704770764544038848431145528445360947849645485340995675140338420516795194391875739483010596185498720573908486020752567154506672207145944313397965555119387825631247278735639065637101895134340448526110625244876623748141868893382305418001655864333085224521184960426661306172015226321027556110813663364068754961411966346349411886773402140398449647788595798838460036470066973426514948829648806555700167311800114711897868437368217702796341769755372420321373403514711116489842498534695236481676350558132897889110650754011149703583979863449424041382281400518343058810460496843485272410822050441441511212394733858551284285254446098327175968966002783040825103026543391039706133799343678703208954903255241621200608188708430102527704592701870512305100099340069959599088597034315398192432762170758105915057585697835061206206187952271582439132615650902906482976574888711304264321759903752906787646241293237089219270860749922386060037977668584177574304628217209473882223389349951344906759874508318966387457669822008687511144961634967108793339929664100796278974873878327095609255951824928893965920351074002213024061767930437574552268890649909229763991595475859168835836933470999820642068628431842663628451184715883077507150868753875337437950031504964684710957735309868918584197113517588308957564510387438935010261473638823258379397638506933211151767971378787761423017878482951398194512688841643893011841062343852229355366472988644268692977994614530504607585315445341477296491001766570932240810899739717357361563912261219584530474733977149175840913869203077868527738029877546166166432908090016561037367864038092286759075731681714950635078219186504354444241560203123263666792544215726956471858914244341055717391728851666538189075684716491700897488003748060514620874277379944815819147411284878113359661583123550024889823524693919751077046816953854745273428710032594158442701344072661883700217905006853043558454223244842645922213592315235238605239307564515699925969464312169257542510629380376289699109246323913371045368058363020865737917164125837277951175058024387607813204625940189991741457166888725597795289112206512198318642300419476633713431162394621226393503378310547439167008919270347114247832674009826133029154197123898550175442521189668417197139076479812903755015303569157447551638166061999464754675091229673945632405202828293488805337738683639111772228708502836612311106755158464539016805642828008162919177692469018934304153135028855958385409500763594871853431581137706699658988624314079157707209268447384078490576022213685500814019642828526410364603187086325312898413766685585038590154916842023314752007493596211119125528517741236693378225630581958903828930971985078899934359913031523060714101672940008237291504837770871802588029929218636755669349244212204996382915841626768809051060707503177124597652328805802347116632506559549550536920961894878378904738276541296485879993891559627126913473579341025083767390345408003146512152038109025143195352522745053378455983723827780237837238741396431841753208753396437681356002675964329698466286597112076479184718665945091483823021613136959520044485440274147672636376419622908376621472807746535346942095213827654307322738192333534228609841977854661763599570908681186158036757487239267473767181283914272513633323484105525140357502476305757164428816124965832038548025933594112073619327388299693947905109116066350975032674941389877440928039698052227775574389570376988726049295387179328419000749668146326696179823994603574403859958527275371131480165492902736948668958348304366292745211500479235246796184202289411410009515755037444590152757880503714305913698964576822042570078616145163634245089574906263834860341805376900817028250919717742813526508755423552198017018670641069740068470905435866558884696053781019360198643139821064537089750042037620028635312528313083166827629631036697727749147139639348162237420389581897742294175480035079396401038240139413882424141629478577251818865688344550943741318127682360806270357869741652697224751179520961257926117226273558893447779127064709276856058308795167279967873293632154833742592535740479428489951963543809722191325071721723324312622305760373965154672523818492186110300611592053731664802501915528789829743117255663743501448302833846336502068174239853084008285143275389601577002030263857435827935681409957489169945791666255713398510484919186369202426073007707146988570196237426512875053605605995529081543402736727878108214303729300525899319512232794208241752608540511125866795951441871903707416397254362102509899851491326779905801738949094974847381106903685377347031001892438663221595586110264199731475632622251152520827738261251523586293230599928996989353410358353266854741858865780095399615918195227633388051537832176131234826182152617318914478873108398354011729097485557910383189943385740570007132166851210727701693896999347383074156857801401352901102152180046473693605365584235011899687114080994442990837995021535581910310154557794176345572355435728202518133359520721305554113571067340051237645856278460868192110770159396109076577591147107315505115136602696081711783789116710518017974363046228031929413669107940302397758723774284502452359619360049551476211247209034110254241661959556006726012111219128319184702526502090268181415250948370180201714947357095025743788292030876532985955173474005940647567890651888787759450155165883311895730995923545351994256284320503162917451931090323632596882667154390729229377700681257431096734835739517031397977858566922642394812507633852522420538211700928508658964492150850563425485241313631127687609634388796337138809154504245860397457019027353963848150342501600523439936506044920733019589409820696342862972223317655497599375153379330980255105930769488730449139276213883440082923285236070344837062327374844649846917496258067008903360541158653502196890273228987668677290973404701148936927045713183183158588510759602020652529635016512571162284608953744996249015154033222434288068053077881274663356912139763543198405832948976122905823480094459747808919921077237953408630169752852893254030578981309874522656768526686649375802082005033330697652484357099894000021158778170975768691165375749054011304964746134146867874986853314973482070628690240527424420306057912660101437539721974883055909494021879762081356728883480379339165791801284812640505952170045036260466010536310667489709490257617081716739352716412220216401996100084022374111751400596281927095572170185905004448463672684304060348122451036810325970923367373073188186963599708728447932616138650243662519279135105838808011534579482828102800296650358235067632445112676021648248656475081155776249910329161534969336044910724519274139330350832837082023462580593643318924303758601999016369956453154796367650435597790747576089985549015244141303765289484856862092107494359686499323238479464509050939264219419796629056169294623231487984881763267569651033188934682979284910584173020858886772012991953799794722787179221101951319223490613937049894742920948421085009344616675906546232555921705727764182625468946369316011229790907639354238881085727145482476029655616840538527256696708053428368862393341857155701411704974884508747051510911098633175182904611994663215247553395350005371365318723005822818609901050095931810576849197506852533441939824362961725007603166131754683647631727510166349649066358581728998521727545626838783528804103132743214654339162823197402586586235383613230305381594420022884721333796177758586462034697808300605043341619053815800237472697862915457251621636575269806320367107543695610121254091812024374106900933590891515953552043848458177968643788843136680935617643295298398640503434870468906209147596720248723131682159547757622198229263771407213194735612006902728603770147376628360927526161797630530603690034447271682003840393520690097021925098087667282664440931516233026971238079053545019139288054468782319268177009537797481752446774111551021641116654891856268527514959161302598065575584335492382041976312989999146250772465621404446978494769112419892326765524648672234014494435976632485810536105283914531977675290500485751307234888481777860639751542882739444252400288945838987100569447119815870767181211087650850666115804077465132916628832643690766575588511847652316389525843073421428356192480775301036338489926079172190125078487968112274369651712083537529095160834474164678444712147276161398494147381808523485886499785811528347245957745703022413670799660856570012663197157127708589791803932642290010855627392615861028546524135920485901139574288813026253085701418199764075679032407473371812028761031113514096024307798693248484115484161893279165955397353619798342897413574440652394103462847093238420518491622396613278440084980285714274001119521212146583278228646516163035751677012268515567393483760637457544410363713184585509209192672838657558877635929516771381262067784415674449672276466698511687982504455688259872115537430517139027883960527698749137216286280715606919777679010367022624054261554634951964881068266029634898924209581095797538957899705669608759871930257719696779492339295194763542770331334961298635643951779009810946902628555532768733707115739223784728286843155094517612459832086292646728150421237127170105161975294862501769639182875895634297441647504612483090734673439591712887374742578272532235696776749852037048402701352055012810562120052397945024980660429979102909917375065564886040021049640925865661577893143263672186374964207419484016400677315429719550320529475120081318648475826319287994362908078728962770414767815869768223532020093272938623238565125180292373072588362748850880404250107115575398062802365849657711348085059977171566144425215789885706504750719574694183920277604790792286624985793487190462359905536540173451571940984223672261645007320696492501582811601875077157916324742007396663827320962777461955531192844430475907631838222195111347286193556030568465955336996366563856122177247344212208931431400372260054208470700900351196020816763626384653615266939614946284247930038955954233286046123503189134471532171426787801011828222588859374352209598727869510299018617061824915817311554708385480498560549423287168103299737881363155684998467032297793573412125663448155535461617620964844267812597562453145133678593888364349239324452843901169376278440494006708280343470877886727585933470053157064184164967774305382613652820890095325391887780182405720626555238608133213634283353471668899595201536767293354988511826546065595075680956797960478433434908300996053109018439290257384548288437158231830854273701596776950470082875610184067796182523270418553707883657963253499854105151754323927390151539300645161184103742636113067606636133856275349472361843631623612298286829320692057035529546408642788995573707433461276181097119158639256594238473854020771904489121350047678116647319070650732144622731694809421966278783285613568370218856319522518996251413816308827154285284711639989567155283168910492999693824446966857279729047977830398926897602106494818605837079923134825226329464579559956244144425297755651628210873886038677297136031660110018232793051217827104478380326244108671507201134719163826599852703788303358664182159728204087147649998823390209094673454445008122854919873681364771859722271262463456114955354657319885051740330759000869148683388222725396392510884284446484329562449708272443027543470127407739300687294721804583374540175668315116189513496418434201549599254809054682664748593917699844225219965421291805059917426842209244482234400202949266962976948822851699438210343277551423978180803875910290814748612294319805100991904522856851837338104159244877389292498113510738287261454240293455541894224633095217394522602936026551595456061623661055902927654091676630774418532523764391562406526618284469283958531843383259303240132162357122398345971567831417472430897951652559344881573873996452198982547630644259944662286263398481295731183797404355119020247001156674683412373110729584936346066326213743589945075097856922859015944551532516279411580409309394261450432272618407573608749062492115755003698739641507119268668515893435513218194246993964380506202595337870405689985091484654042450874003212029473421931412898578225297293295519407237805898116649283143095650627213156119510869364346688550366196240519226659161294197925973913409510972990407098495159885875804777945532162753995223345036109201654687459456591393606196809149886707961265162289712454378008329177774675628056913157417126669097606244595079396967324721549576507113794984870842666361786811311865762551606483148398602644844825558569258346194489589085842393455215391175561752946483780311441695396417365452917522463959898689659333538791793949654399639185816790676211214068656108899527458234059366314058388879543488371632913732788969940937368504473501786986773365428667723720916638821659445640469398388962347290599454063607744745571805014601269538730377829300322663133877008320829439859107658259785108209896343560390323005677882719027146326379826159251171576295202499368640686310542262472609043845233670917320245855561169422377865202960746333772546406182883287541831927837935583576069660821038475080977252447563461361850852642662032325964391810968358866316742144383224544451227046370105060845523184286787713378882546932972822220128516062439441890242789967331212694311685917031718978694313191384266353212105707487229821923323032673000078575471699706507763178058901849276692475004816539171323042565311423874782330003955924722773348602607047695466471601192421760467702254146760255278279163336548916738455638465637536082472285959223577060897564490962537496415306816394096942325066073922056375707790548296494099167311479240271569316621052018931558381501932815658903419723649109491158537987316248870664081476476264511996920185665189875159032161640159865376689047492001364539705880246615093400775341953007551201729674003847988935873320276363017432257699672409155448929277093975879817861131498758623709713029926471495582203283923859653894659999814623604636195344129368367860032476800876925643907666519023356389165088253392120552435167137609934229001557465495002030686271752262217161353807448582706557855440872932521534039868047328045617063634479606443723016725618519227821652481859877183369748731862958606992384709357130914442361412922130243410108156434305481004819602951852625297232370503472890607339128246701106802868299060924444420135825175266647128856927582691029230334509106919769340616149411506814850317322215207375613821136022083879670436517972766663072693186919704204474484981993713400251506049312726997346290074492759487337880701132276062210655057712231336387711178432079399208205815351137389313337091613182861577812254298862018871924111826845600464063439989735396291011529560167528065950637500987861372089704732791613930935854866181700200087868305741424698178924593925177638460799580985998301278883696749013578784132990997408172499594144562232279688361488259332859248194538662348838635342877394019481042377896015885883404556714012021646329691784011102529606151880573960699369837270873183884252945998867402542244827314429978951774956571942095905643679254249910365886648549686213109538986051849100092500547340540282377946152216680949887291394185964711492547963610708639399134980370331893710394372066674969594078716349344478782286683652767031119675111289612264494837076623388691032737810685506949000809314842426663931142362967980455039298100848261281695058045407818844911633694339274288625555792278179551330379936312258623724120398285533716838615191536413875991390555211733795410547570590869185567375692854831305764043350203179834861820548781447623166632670524066647593604499613317348602789064196218557457377379413970448035596466935435963713098458127286282897934502723506839961627176376626811495816403261216698183042966003381399570625255232284634895543020717357270918687650772426273049378345804166561697502079604713889169578987578427979220699491692901498897730594446864357937693924500018707947751267594207670427323785477079662805081137938317031331157 4⬥ ``` It's not that it's non-serious, it's that *there really isn't any shorter way to store data* -- Keg wasn't designed that well to handle serious compression challenges. I mean, I had to add base conversion just to make this a serious contender. No TIO because it hasn't been updated for a while. But [Verify it online!](https://tio.run/##jZ1fr2XHcd3f@SmuHdgkLcru7h0gQGQZaHTkhoEgAYR08uDogR5eSQOPh8qQtJ3EzkePcnav31p9RqSESCTnzr3n7t27/1StWrWq9psf/@rNm9/@9t@8ff/m3Xdfvb785TfffvXu7d/9@a//6pOPvvf269/91oe37391f@@Tf/PV6y/fvn99@fnP/vpnP//Zfxo/e/njvlbvfc71@HP1MdYaY9x/7308fvD4Wv8@fj5mX@Px//X44f7y8Uv33@@PTX3k8aV@8Pj/vP8cj2@P/eXoj38fn5j3l@P@wePPed90D@G@n77cv/a49Oz3OPr9wb6Hc3/38Zl7BPt6uuz9G3v490/Hfef9s7FHe/9z3@7@pf70qblH2O8PdT3s49OPm837F@8HfEzC0uf3w90fu0fS96/vsfT7p/en7z/XHut99ceH70Hswe6v7hHq0kPjm33/cz/GHt79HPu6XePc63GP5p4mJvKetnsQe1r6HvPY970HoOW5V@Ae/T1Dexb2w9@jv4c1u8Z0f/S@8P1b9wPe/73HMfeV537oe8am5nvfqK/9tHua76e6h7T2A@37zj1dnrR9wXkP794K997xE4x7wTVL@kfTvi@713/Pyx7B4xce17mf9v7pYDH3R@4b7L1xz4lm@/4lpuv@2J7XuedQ66fFuyd@j3ivpB5Sg7@Hdi@MlnXN/fUe8n33x132HHRtZU3vPZ59QLQX94D33e9H7Xse9nzuba8F3Udr31b7Yz/1vs2@5z4@e29y3Tl1onQQxp6rqY3b9yG5/2HYfQ94P/X9ea3K3q2TDa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Wp8TvS/VbdAEf@wXMCaCsleauWzIKpV7/cplgNX7ypeAFhszOyNDqvD3OaPGxBS2t9yrrOS2YgykoJyeF3RTkBbe9qVt9t8/2aIBQNR95TLEalA2BewiG6AOK1WYIMBC0ug7Xsr6b@PM2Iiz9S06DYRB0ClWYw1nhJYPHrD7CIyN@b4kC9T4I22DRYStkYb9FMDTSxHJ3I3OH@BDrhWUuxnNGNjFqJZ25pIvmH//d/3/zy3Ze/@ua3P/5vX7579/jv45/9ouL/Bw "C (gcc) – Try It Online") ]
[Question] [ Given two integers, A and B, output A if A-B (A minus B) is in A-B (A to B), otherwise output B. "A minus B" is standard subtraction. "A to B" is the range of integers starting at A and ending at B, including both A and B. For example: ``` 1 to 4: 1, 2, 3, 4 -2 to 5: -2, -1, 0, 1, 2, 3, 4, 5 3 to -1: 3, 2, 1, 0, -1 7 to 7: 7 ``` **The shortest code in bytes wins.** ## Test Cases ``` A B Output 1 4 4 -2 5 5 3 -1 -1 7 7 7 90 30 90 90 -30 -30 -90 30 30 -90 -30 -90 -2 -2 -2 -2 -1 -2 -2 0 -2 -2 1 1 -2 2 2 -1 -2 -2 -1 -1 -1 -1 0 -1 -1 1 1 -1 2 2 0 -2 -2 0 -1 -1 0 0 0 0 1 1 0 2 2 1 -2 -2 1 -1 -1 1 0 1 1 1 1 1 2 2 2 -2 -2 2 -1 -1 2 0 2 2 1 2 2 2 2 ``` [Original Chat-Mini-Challenge](https://chat.stackexchange.com/transcript/message/35909025#35909025) [Answer] # [Python](https://docs.python.org/2/), 27 bytes ``` lambda a,b:[a,b][2*b*b>a*b] ``` [Try it online!](https://tio.run/nexus/python2#VU/RaoQwEHyuXzEVBLWxJNpSTrC/0A@wPiSecsJVD6Mt9/U2MeaMsBtmdndms23xvVz5jzhzcCLyUj1VmcYiFp88FtXSjOMwShSgXjuMeobU6HoVt3kKo9zDvWhDVY48dC3q543l8J5uY9dP8L/mSc1Cy8NAkkBG@OMSCkJehvl6xoX/NhBN06viqx9oA3IndaQ8tv0vBZi3@QUSpuoj2BCWsmQEbyoqgjJJCd5VaJwRJEynJh8EOjQ8UYJM5YlalmTmWR1s26Gmb@b1BpMPxlxGXaI6zGIdK2YHA@b@UiPqkocB2w2oq6eunK5qukGrpbv0sPqw2Sy2kO3QSg9np67UHG3rbIertPoH "Python 2 – TIO Nexus") An arithmetic formula. Why is the negation of `2*b*b>a*b` equivalent to the problem condition `a-b in symrange(a,b)`? Note that `x in symrange(a,b)` is equivalent to `0 in symrange(a-x,b-x)`. Applying this to `x=a-b` gives `0 in symrange(b,2*b-a)`. The value `0` is included in the interval unless it stretches between two positive values or two negative values. This can be stated arithmetically as "their product `b*(2*b-a)` is not positive. Finally, take `b*(2*b-a)<=0`, and rewrite to `2*b*b<=a*b`. A byte is saved by flipping `<=` to `>` and switching the cases. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes ``` _erị, ``` [Try it online!](https://tio.run/nexus/jelly#TY6xDcJQEENXQal94u4HFEUZgCGiKBULMAItg9BkA0omSRb56OfbKJXtuyfLeb4/1s8LeWi@7/P2XG45j4HLhNNoCdeiLSyKduiK9I7Waaw6@9/scEywJBM0@ihXIESGyCAZUN4BJ@jkvGIOpv2pNpWxi1Vs0jht4zQuK8N@ "Jelly – TIO Nexus") ### How it works ``` _erị, Main link. Arguments: a, b _ Subtraction; Yield a-b. r Range; yield [a, ..., b]. e Exists; yield 1 if a-b belongs to [a, ..., b], 0 if not. , Pair; yield [a, b]. ị At-index; yield the element of [a, b] at index 1 (a) or index 0 (b). ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes Code: ``` DŸ¹Æå_è ``` Uses the **CP-1252** encoding. [Try it online!](https://tio.run/nexus/05ab1e#@@9ydMehnYfbDi@NP7zi//9oSwMdBWODWAA "05AB1E – TIO Nexus") Explanation: ``` D # Duplicate the input. Ÿ # Inclusive range. ¹Æ # Push the input [a, b] and compute a - b. å # Check if the number exists in the range. _ # Boolean negate è # Index at the first input ``` [Answer] # PHP, 58 Bytes ``` <?=in_array(($a=$argv[1])-$b=$argv[2],range($a,$b))?$a:$b; ``` [Answer] # JavaScript (ES6), 24 bytes ``` a=>b=>[a,b][2*b*b>a*b|0] ``` ## Test cases ``` let f = a=>b=>[a,b][2*b*b>a*b|0] let tests = [[1,4,4],[-2,5,5],[3,-1,-1],[7,7,7],[90,30,90],[90,-30,-30],[-90,30,30],[-90,-30,-90],[-2,-2,-2],[-2,-1,-2],[-2,0,-2],[-2,1,1],[-2,2,2],[-1,-2,-2],[-1,-1,-1],[-1,0,-1],[-1,1,1],[-1,2,2],[0,-2,-2],[0,-1,-1],[0,0,0],[0,1,1],[0,2,2],[1,-2,-2],[1,-1,-1],[1,0,1],[1,1,1],[1,2,2],[2,-2,-2],[2,-1,-1],[2,0,2],[2,1,2],[2,2,2]] tests.map(test => `f(${test[0]})(${test[1]}) == ${test[2]}`).forEach(test => console.log(test, eval(test))) ``` [Answer] # Python 2, 37 bytes ``` lambda*s:s[min(s)<=s[1]-s[0]<=max(s)] ``` Invoke as `f(B, A)`. [Answer] # Python2, ~~55~~ ~~52~~ 51 bytes ``` lambda A,B:[B,A][A-B in range(min(A,B),max(A,B)+1)] ``` [Try it online!](https://tio.run/nexus/python2#VZDBboMwDIbP5Ck8LhAtTElpNbVSDnDYK@zAOKQU2mhAK@iBt2e2F6RNDr9/nM8mZO1s74bzxUGhylNVqqKuiqwEP8LkxmubDn5McUuqwS1sXo2s19nGcWxgD3uR7eAAB5FDZnCJd8AQRw25hqMmk@X8iOy3GBxXEcB2XmxMMDpkA4YShuA9LpvwJVQdMnOGOR0wHSiNkEYlRDOxDdrm0BhSw0rEdqRdIOhA9GZYMfDnRXefoLnRRc1v86P3zzT5GhN5EpFTZ9XYyo/PdJFA3EJYc9s4SGQtIt9BlyIrwVposC96TNQTf96n7/byArECHiVF1PZz@4f4cL7/R6w/) Handles every test case OP has mentioned (at the time of posting this), as the TIO suggests. [Answer] # JavaScript ES6, 40 37 bytes ``` a=>b=>a-b<(a<b?a:b)|a-b>(a<b?b:a)?b:a ``` Explained: ``` a=>b=> take a and b as inputs a-b<(a<b?a:b) if a-b is less than the lowest of a and b |a-b>(a<b?b:a) or a-b is greater than the largest of a and b ?b return b :a else return a ``` Saved 3 bytes thanks to Arnauld. ``` f=a=>b=>a-b<(a<b?a:b)|a-b>(a<b?b:a)?b:a function t(){ var tests = [[1,4,4],[-2,5,5],[3,-1,-1],[7,7,7],[90,30,90],[90,-30,-30],[-90,30,30],[-90,-30,-90],[-2,-2,-2],[-2,-1,-2],[-2,0,-2],[-2,1,1],[-2,2,2],[-1,-2,-2],[-1,-1,-1],[-1,0,-1],[-1,1,1],[-1,2,2],[0,-2,-2],[0,-1,-1],[0,0,0],[0,1,1],[0,2,2],[1,-2,-2],[1,-1,-1],[1,0,1],[1,1,1],[1,2,2],[2,-2,-2],[2,-1,-1],[2,0,2],[2,1,2],[2,2,2]]; for (var test of tests) { console.log(`f(${test[0]},${test[1]}) == ${test[2]}`, f(test[0])(test[1])==test[2]); } } t(); ``` [Answer] # Mathematica, 16 bytes ``` If[2#^2>1##,##]& ``` Pure function taking two arguments in the opposite order as the OP (for example, `If[2#^2>1##,##]&[B,A]`). A port of [xnor's Python answer](https://codegolf.stackexchange.com/a/112334/56178). [Answer] ## R, ~~49~~ ~~30~~ 28 bytes ``` pryr::f("if"(2*b*b>a*b,b,a)) ``` Uses @xnor's logic for determining whether a-b is in a:b. [Answer] # Clojure, ~~71~~ 41 bytes -30 bytes by using `<=` and `min`/`max` instead of `range`s. ``` #(if(<=(min % %2)(- % %2)(max % %2))% %2) ``` Checks if `(a - b)` is in the range from `a` to `b`, dispatching a return accordingly. ``` (defn eh [a b] ; <= accepts any number of argments, and ensures all fall within the range (if (<= (min a b) (- a b) (max a b)) a b)) ``` [Answer] # PHP (7.1), 55 bytes uses the [new](http://php.net/manual/migration71.new-features.php) array destructuring syntax: ``` [,$a,$b]=$argv;echo in_array($a-$b,range($a,$b))?$a:$b; ``` Run with `-r`, provide numbers as command line arguments. [Answer] # [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~37~~ ~~35~~ 32 bytes ``` ($a,$b=$args)[$a-$b-notin$a..$b] ``` [Try it online!](https://tio.run/nexus/powershell#@6@hkqijkmSrkliUXqwZrZKoq5Kkm5dfkpmnkqinp5IU@///f12j/4YA "PowerShell – TIO Nexus") Literal translation of the problem into PowerShell using the `-notin` operator. Saved three bytes by using multiple assignment and encapsulation. This works because `-` has a [higher operator precedence](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_operator_precedence) than `-notin`, and the `( )` portion of the code is executed first and returned as an array `@($a,$b)`. However, since it's `$a,$b` rather than `$b,$a`, we need to use `-notin` to flip/flop the output result. [Answer] # Nim, 60 bytes ``` proc f(a,b:int):int= if a-b in min(a,b)..max(a,b):a else:b ``` [Try it online!](https://tio.run/nexus/nim#XZLdioMwEIXvfYpDryrEkuguS4VA38P1IhZlhfUHW4pvbzOJ7iYDM@F8M8kxhtnmZbqjOxvRlP34TGnRCdB3MFmDfsTQj9RNL5fBrE6VBu3voy2b7WUWzGYxw0PjVtljt0oJfNiohaMsF/i0sWMhkCnKnb8EKHa6SoHC5lUGhazwy2F4bIorftffQfqsz7CgWEEytn0VIMWBivsp9icEknHopyI/yewkc5POTP5TYCUjJ34xfi9/rYBURIETf7KcOfkHC7oqIueU1Ek32ZGgufFzUdq@nRK7AkZjrmTtdENaeb2Szkm3958JRuD0/TwJNIdw45lCa6zbGw "Nim – TIO Nexus") Pretty standard as far as answers go, no big tricks in this one. [Answer] ## Batch, 107 bytes ``` @set/aa=%1,r=b=%2,x=a-b @if %a% gtr %b% set/aa=b,b=%1 @if %a% leq %x% if %x% leq %b% set/ar=%1 @echo %r% ``` [Answer] # Pyth - 9 bytes Was hoping to use more implicit input... :( ``` @Q!}-FQ}F ``` [Try it online here](http://pyth.herokuapp.com/?code=%40Q%21%7D-FQ%7DF&test_suite=1&test_suite_input=1%2C+4%0A-2%2C+5&debug=0). [Answer] # [Röda](https://github.com/fergusq/roda), 30 bytes ``` f a,b{[b]if[2*b*b>a*b]else[a]} ``` [Try it online!](https://tio.run/nexus/roda#RY7RboMwDEWfl6@wEA/AQEqg1dRN7H3fQFGbsGRD6igiTKrU8e3M9oImJ9fOzYmd1YHOzb0xbe@aMjOZedWZae3F20a3y/ql@wHu4mH89p/JbP186rS3PoUf8OOlnxNvxzo6Hv1jRN6oJ2/fhtl@2AlOaLjrRAPyDt6vcKtdgof0BcapH2Y4uyTWeWxSqCG@kXRn5AYrFiFw6P88eK4hUrCDnShK2MNeVFAoXOIJMMRBQiXhIKkoKt6i@DNDxS4C@JwXFyoUMmQFihKG4Du2VZiEKkNmTjEnAyYDJRGSqIRIJrZGWx9qQ6pYidi@VAaCPkQnxYoRiWX9BQ "Röda – TIO Nexus") It uses the formula used in xnor's answer. Another solution (37 bytes): ``` f a,b{[a]if[a-b in[seq(a,b)]]else[b]} ``` [Try it online!](https://tio.run/nexus/roda#RY5hboMwDIV/L6d4QvygGkhJaTV1EwfYGShqAwsbUkcZYVKljrMz2wuanDw7L1/sLC1sWt9LW3VtabMaXV9695WQuakqd/GurKt5@bRdj7t6GL79RzI5P50a653f4Ad@uHRT4t1QRMejf4zYG@zo3Ws/uXc34kRGex15Ttrg7Ypb0Ur/Fwxj1084t0ls07jeoEB8Y2nOxPVOzUrR0P95eC4QGeywU9kWe@xVjszQUk@gUAeNXOOguchy2Sr7M0MlLgH0XJYUJhQ6ZAPDiULJndgmTCLVIQtnhNMB04HSBGlSRrQQa6O1D7dhNaJMrF/aBoI/xCcjShGpefkF "Röda – TIO Nexus") [Answer] # [><>](https://esolangs.org/wiki/Fish), 21 bytes Makes use of @xnor's [trick](https://codegolf.stackexchange.com/a/112334/63647). We use `-v B A` to prepopulate the stack. (`-v A B` is +1 byte). ``` :01pr:11p::2**r*)1gn; ``` [Try it online!](https://tio.run/nexus/fish#@29lYFhQZGVoWGBlZaSlVaSlaZieZ/3//3/dMgUTEGEIAA "><> – TIO Nexus") ## Explanation ``` Input: [B, A] on stack. :01pr:11p::2**r*)1gn; : Duplicate. [B, A, A] 01p Push A to [0,1]. [B, A] r Reverse [A, B] : Duplicate. [A, B, B] 11p Push B to [1,1]. [A, B] :: Duplicate x 2. [A, B, B, B] 2 Push 2. [A, B, B, B, 2] 2** Compute 2*B*B. [A, B, 2*B*B] r Reverse. [2*B*B, B, A] * Compute A*B. [2*B*B, A*B] ) > [2*B*B > A*B] 1 Push 1. [2*B*B > A*B, 1] g If 2*B*B > A*B get B, else get A. [2*B*B > A*B ? B : A] n Output as number. ; Terminate. ``` [Answer] # [Ruby](https://www.ruby-lang.org/), ~~27~~ 22 bytes ``` ->a,b{(b*a<2*b*b)?b:a} ``` [Try it online!](https://tio.run/nexus/ruby#@59mq2uXqJNUrZGklWhjpJWklaRpn2SVWMvFVaCQFm1poGNsEAtj6sLYukjiulCJ//8B "Ruby – TIO Nexus") Nothing innovative here. The simple math behind it: ``` (A<=A-B<=B or B<=A-B<=A) ``` can be written as ``` (B>=0 and A>=2B) or (B<=0 and A<=2B) ``` that is: if A-2B has the same sign as B, we are in the range. [Answer] # SpecBAS - 38 btes ``` 1 INPUT a,b: ?IIF(a-b IN [a TO b],a,b) ``` `IIF` is an inline-IF-THEN-ELSE, to print the correct value. [Answer] # Haskell, 21 bytes ``` a!b|b*a<2*b*b=b|0<1=a ``` [Try it online!](https://tio.run/nexus/haskell#@5@omFSTpJVoY6SVpJVkm1RjYGNom/g/NzEzT8FWISWfSwEICooy80oUVBQMFRQVTFBENHSNNIGCpiiClgZAIWMDTDENXWMDzf8A) ## Readable ``` func :: Int -> Int -> Int func a b | b*a < 2*b*b = b | otherwise = a ``` ## Explanation Uses @xnor's formula to check whether a-b is in range. Nothing special besides that. [Answer] ## Haskell, 58 bytes Just recently I fell in love with arrows again. Unfortunately they require us to work with tuples instead of binary functions. And of course Haskell does not have a symmetrical `range` function. ``` import Control.Arrow u=uncurry app<<<elem.u(-)&&&(u enumFromTo<<<u min&&&u max) ``` [Answer] # PHP 7 - 45 Bytes ``` echo(in_array($a-$b,range($a,$b))?$a:$b)==$c; ``` [Answer] # Octave, 55bytes ``` @(a,b)(c=b*~[find((a:1-2*(b<a):b)==(a-b)) 0](1))+(a*~c) ``` This could probably be optimised further. I'll add an explanation later. [Answer] ## [Swift](https://swift.org/about/) - ~~38~~ ~~30~~ 22 bytes Saved 8 bytes thanks to @Matt ``` print(a...b~=a-b ?a:b) ``` [Try it at IBM Swift Sandbox online!](http://swift.sandbox.bluemix.net/#/repl/58c18fe9f8ba897c77f93546) --- ## Or 21 bytes: (thanks to **@xnor**'s formula) and saved 8 bytes thanks to @Matt ``` print(2*b*b>a*b ?a:b) ``` --- Swift is not the best language for golfing (it's very rigid), so if you see any other golfing opportunity, I'll totally edit the answer. [Answer] # Java 7, ~~84~~ ~~60~~ 58 bytes ``` int c(int a,int b){return(a<b?a:b)>a-b|(a<b?b:a)<a-b?b:a;} ``` # Java 8, 37 bytes ``` a->b->(a<b?a:b)>a-b|(a<b?b:a)<a-b?b:a ``` **Explanation:** ``` int c(int a, int b){ // method with two integer parameters and integer return-type return (a<b ? a : b) > a-b // if smallest of the input is larger than a-b | (a<b ? b : a) < a-b // or if the largest of the input is smaller than a-b ? b // return b : // else a // return a } // end of method ``` **Test code:** [Try it here.](https://ideone.com/mYsUsN) [Answer] # Ti-Basic (TI-84 Plus CE), ~~26 24~~ 23 bytes ``` Prompt A,B A-B≥A and A-B≤B AAns+Bnot(Ans ``` TI-Basic is a tokenized language; all tokens used are [one-byte tokens](http://tibasicdev.wikidot.com/one-byte-tokens). `Prompt` prompts you for the two numbers. `A-B≥A and A-B≤B` checks if A-B is between A and B (inclusive); this returns a 1 if true and a zero if false, which is stored to `Ans`. Since we are returning A if A-B is between A and B, we multiply A by Ans, which will be A if we are supposed to return A, and 0 otherwise. Next, we add `Bnot(Ans` to it. If Ans was 1 (truthy), we `not(` it and get 0, thus our sum is A. If Ans was 0 (falsy), we `not(` it to get 1, which we multiply by B and add to 0 to get B. The last evaluation in TI-Basic is implicitly returned. -2 bytes thanks to Scott Milner [Answer] # [Pyt](https://github.com/mudkip201/pyt), 32 bytes ``` ←Đ←Đ3Ș⇹Đ3ȘĐ4Ș3Ș-3Ș⇹Ř∈Đ3Ș⇹¢*3Ș⇹*+ ``` Takes A and B from stdin as two separate inputs Explanation: AABB -> ABBA -> ABAB -> ABABB -> ABBBA -> ABBBAA -> ABAABB -> ABABBA -> ABABC -> ABCBA -> ABCAB -> ABC[A,...,B] -> ABD -> ABDD -> ADDB -> ADBD -> AD{B\*(1-D)} -> {B\*(1-D)}AD -> {B\*(1-D)}+{A\*D} where: C=B-A and D=C∈[A,...,B] (1 if true, 0 if false) [Answer] # [Ohm](https://github.com/MiningPotatoes/Ohm), 10 bytes (CP437) There's probably a golfier way to do this, but the strictly-typed nature of Ruby makes this difficult. ``` G┼┘-îε?┼¿┘ ``` [Answer] # [Perl 6](https://perl6.org), ~~31 29~~ 24 bytes ``` {$^a-$^b==any($a...$b)??$a!!$b} ``` [Try it](https://tio.run/nexus/perl6#NY5NbsIwEIX3PsUDRSURcbAJtEIopLDrnmWElB9XRYIENaEqinKy7nqnrunY2Br7zeT5m8lcW4Wv56hcs/MNT2VTKST33jvk3DsUSZLXN9/LoyjyiiBNvXw08orhfqWmvWo70/TaUdUiwelYq9YPfn@isjkX/mzCJ2lWTWfaeasJvpzyGtMHv2bvzafr5Rsf2TZEtqOrvi@q7FSFoGfAsYVeyt@GuyCEewsx7skZkGzQO3MYs@EuscCC8TmWWLIYXNJhL6BgK4FYYCV0wWNzGX@YtjIuAdRujimkLYTNElInCmbejC3tn0iFzYaThhMWE5YSBAlSjQhDuEFujh6jVRrVhFtpbgm9kP6SRin@6oaXefmh/gE "Perl 6 – TIO Nexus") ``` {$^a-$^b∈($a...$b)??$a!!$b} ``` [Try it](https://tio.run/nexus/perl6#NY5NbsIwEIX3PsUDRSURcbAJtEIopLDrnmWElB9XRYIENaFqFWXPnbrrUXqHrtOxcTT2m8nzN5O51gofj0G@ZucvPORVoRD1rXNIuXPIfm8310mDIHAyL46ddDRysq6/Uste1Y1peW6oqhHhdCxV7Xo/30FenTN3NuGTOCmmM@28lARfTmmJ6Z1fs9fqfejlGxfJ1keyo6s@LypvVAGvZcCxhl7J3fo7z8fw5mPcktMh2qAdzG7Mul5igQXjcyyxZCG4pMOeQMFWAqHASuiCh@YyfjdtZVwCqN0cU0hbCJslpE4UzLwZW9o/kQqbDScNJywmLCUIEqQaEYYYBg1z9Bit0qgmhpXmltAL6S9plOKvrHie5m/qHw "Perl 6 – TIO Nexus") ``` ->\a,\b{2*b*b>a*b??b!!a} ->\a,\b{2*b²>a*b??b!!a} ``` [Try it](https://tio.run/nexus/perl6#NY5NbsIwEIX3PsWDRUlCDHYCrRBKUth132U2@XFVJEhQE6pWUU7WXe/UdTo2tsZ@M37@PJ5bp/D5uKr27PKNh6qtFZKJp3kR5uUQBWVQpkVQZlk5mxXjdCP6VXW9oZ97qjokOJ8a1Xn@78@qai@lt17wRZbXy7V2XhqCr@eiwfLO79lb@@He8tRDfgiRH2mrr6uqelXDHxhw6qCn8Q7h0Q/h7kLMB3JGJCkGZ45zNk4SG2wYj7DFlsXgkhZ7AgXbCcQCO6ELHpvN@N20lXEJoOdmmULaQtgsIXWiYObO2NL@RCpsNpw0nLCYsJQgSJBqRBjCNXJ9dBut0qgm3EiRJfRA@iSNUvw1La@K6l39Aw "Perl 6 – TIO Nexus") ]
[Question] [ [Related.](https://codegolf.stackexchange.com/questions/42580/shorter-than-a-split-second) Given a printable ASCII string, split it into a list of non-empty strings with a new sub-string beginning every time a character, which has not previously been seen in the same case, occurs. ### Examples ``` "mississippi" → ["m","i","ssissi","ppi"] "P P & C G" → ["P"," P ","& ","C ","G"] "AAA" → ["AAA"] "Adam" → ["A","d","a","m"] "" → [] ``` --- **Anecdote**: The result will have between 0 and 95 elements. The 95th sub-string will necessarily continue until the end because at that point, all printable ASCII characters have begun a sub-string, so every additional character will have occurred before and thus cannot cause a new sub-string to begin. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 4 bytes ``` QƤĠị ``` [Try it online!](https://tio.run/##y0rNyan8/z/w2JIjCx7u7v5/uP3opIc7Z/z/r5SbWVwMQgUFmUoA "Jelly – Try It Online") ## Explanation ``` QƤĠị Input is a string, say s = "adam" Ƥ For each prefix of s: ["a","ad","ada","adam"] Q remove duplicates: ["a","ad","ad","adm"] Ġ Group indices by equal values: [[1],[2,3],[4]] ị Index into s: ["a","da","m"] ``` The internal representation of the strings, which the TIO link displays, is slightly different. [Answer] ## [Retina](https://github.com/m-ender/retina/wiki/The-Language), 9 bytes ``` q1,`. ¶$& ``` [Try it online!](https://tio.run/##K0otycxLNPz/v9BQJ0GP69A2FbX//3Mzi4tBqKAgEwA "Retina – Try It Online") ### Explanation Match each character (`.`), discard repeated matches (`q`), discard the first match (`1,`), and insert a linefeed in front of each match `¶$&`. [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes ``` ÙSk¥sg¸«£õK ``` [Try it online!](https://tio.run/##MzBNTDJM/f//8Mzg7ENLi9MP7Ti0@tDiw1u9//9XAoIAhQAFNQVnBXcQBwA "05AB1E – Try It Online") **Explanation** ``` Ù # remove duplicates in input S # split to a list of characters k # get the (first) index of each character in the input ¥ # calculate delta's sg¸« # append the length of the input £ # split the list into pieces of these sizes õK # remove empty string (for the special case "" -> []) ``` [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), 8 bytes[SBCS](https://github.com/abrudz/SBCS) ``` (≢¨∪\)⊆⊢ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG9qZv6jtgkG/9OApMajzkWHVjzqWBWj@air7VHXov//S4DC1Y96twJlioDMtEe9u6zU0xIzc9SBLKB40aPuFvX8bPVaLvXczOJiECooyFQv0Tm0Qj1XXUE9E4ghwkAGSIZLPUAhQEFNwVnBHaIqACgBFAGSaiDCGUS4A5U5OjoCFTzqagKzgPyUxFyIDjCLS129RMHgUe8WkAp1AA "APL (Dyalog Unicode) – Try It Online") [Answer] # C, ~~75~~ ~~65~~ 63 bytes *Thanks to @Digital Trauma for saving 10 bytes and thanks to both @gastropner and @l4m2 for saving a byte each!* ``` f(char*s){for(int l[128]={};*s;putchar(*s++))l[*s]++||puts(l);} ``` Prints a leading newline. [Try it online!](https://tio.run/##S9ZNT07@/z9NIzkjsUirWLM6Lb9IIzOvRCEn2tDIIta2utZaq9i6oLQEJK@hVaytramZE61VHKutXVMDFC7WyNG0rv0P0pGbmJmnoclVzaUABGkaSrmZxcUgVFCQqaRpDVarBGTApAMUAhTUFJwV3LFJOjo6YhVOSczFJg5i1v4HAA) **Without a leading newline (71 bytes):** ``` f(char*s){int l[128]={};for(l[*s]=1;*s;putchar(*s++))l[*s]++||puts(l);} ``` [Try it online!](https://tio.run/##S9ZNT07@/z9NIzkjsUirWLM6M69EISfa0Mgi1ra61jotv0gjJ1qrONbW0Fqr2LqgtASkTkOrWFtbUxMsoa1dUwMULtbI0bSu/Q/SnZuYmaehyVXNpQAEaRpKuZnFxSBUUJCppGkNVqsUkwdkwhQEKAQoqCk4K7hjl3Z0dMQhkZKYi10GxKz9DwA) [Answer] # [Perl 6](https://perl6.org), ~~58 52~~ 40 bytes ``` {$/={};.comb.classify({$+=!$/{$_}++}).sort».value».join} ``` [Try it](https://tio.run/##K0gtyjH7X1qcqlBmppdszcWVW6mglpyfkqpg@79aRd@2utZaLzk/N0kvOSexuDgzrVKjWkXbVlFFv1olvlZbu1ZTrzi/qOTQbr2yxJzSVCCdlZ@ZV/u/OLFSAWSKhlJuJlAbEBUUZCpp6hUArbPmgsuqBygEKKgpOCu4q2PIKTk6OiphEU1JzMUiDBP6DwA "Perl 6 – Try It Online") ``` *.comb.classify({$+=!(%){$_}++}).sort».value».join ``` [Try it](https://tio.run/##K0gtyjH7X1qcqlBmppdszcWVW6mglpyfkqpg@19LLzk/N0kvOSexuDgzrVKjWkXbVlFDVbNaJb5WW7tWU684v6jk0G69ssSc0lQgnZWfmfffmqs4sVIBZIKGUm4mUCMQFRRkKmnqFQCtQpJVD1AIUFBTcFZwV8eQU3J0dFTCIpqSmItFGCb0HwA "Perl 6 – Try It Online") ``` *.classify({$+=!(%){$_}++}).sort».value ``` [Try it](https://tio.run/##TY5BasMwEEX3OsWv6jp2XbTMxmRhsug20AMExZapEssSGilgXJ8su17MFYG2gVnMe/BnvlN@2K6RFK5b0daMmQl5j936KtpBEul@Kuas2j0VL@WcHZeqWkpB1ofvm7jKIaq1Zs9fMPKioAOUJK08gkU6@QY5dvd97JSncKdPBRuDi4FRPKHT5AY5ocBH8MgIJWYGUFIZidaak8j79Ops9Shc6soWxn5D3OhUMI1zmtd/enPAATn2eN/8S940DX/ETppH5vX6Aw "Perl 6 – Try It Online") (input is a list of characters, and output is a list of lists of characters) ## Expanded: ``` * # parameter for WhateverCode lambda .classify( # classify that list { $ # anonymous scalar state variable (accumulator) += # increment it if: ! # Bool invert the following ( % # anonymous hash state variable ){ $_ }++ # look to see if the character was seen already } ).sort\ # sort the Pairs by key (makes the order correct) ».value # get the value from each Pair ``` --- The output from `classify` is ``` { # Hash 1 => ['m'], 2 => ['i'], 3 => ['s','s','i','s','s','i'], 4 => ['p','p','i'], } ``` And `.sort` just turns it into: ``` [ 1 => ['m'], 2 => ['i'], 3 => ['s','s','i','s','s','i'], 4 => ['p','p','i'], ] ``` `».value` removes the keys ``` [ ['m'], ['i'], ['s','s','i','s','s','i'], ['p','p','i'], ] ``` [Answer] # [J](http://jsoftware.com/), 7 bytes ``` ~:<;.1] ``` [Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/66xsrPUMY/9rcqUmZ@QrpCmo52YWF4NQQUGmOlwwQCFAQU3BWcEdIeTo6IjESUnMRfDU/wMA "J – Try It Online") # Explanation Nub sieve's chance to shine! ``` ~: <;.1 ] ] Input ~: Nub sieve (1 if the character is the first instance in string) ;.1 Split input on 1s in nub sieve < And box each ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 8 bytes ``` Ùvyy¶ì.; ``` [Try it online!](https://tio.run/##MzBNTDJM/f//8MyyyspD2w6v0bP@/z83s7gYhAoKMgE "05AB1E – Try It Online") --- Always will output 1 preceding newline, which is constant and not indicative of a split, the 10-byte alternative that does not output a preceding newline is `Ùvyy¶ì.;}¦`, you [can try that here](https://tio.run/##MzBNTDJM/f//8MyyyspD2w6v0bOuPbTs///czOJiECooyAQA "05AB1E – Try It Online"). According to Adam a preceding or trailing newline is acceptable. --- ``` Input = mississippi | Stack -----------#-------------------------------------------+---------------------------------- Ù # Push unique letters of first input. | ['misp'] v # Iterate through each unique letter. | [] yy # Push 2 copies of the letter (or yD) | ['m','m'] ¶ # Push a newline char. | ['m','m','\n'] ì # Prepended to the letter. | ['m','\nm'] .; # Replace first instance with '\n + letter' | ['\nmississippi'] ``` **After each iteration we get:** ``` ['\nmississippi'] > ['\nm\nississippi'] > ['\nm\ni\nssissippi'] > ['\nm\ni\nssissi\nppi'] ``` **Which is:** ``` m i ssissi ppi ``` [Answer] # [Haskell](https://www.haskell.org/), 39 bytes ``` foldl(\s c->s++['\n'|all(/=c)s]++[c])"" ``` [Try it online!](https://tio.run/##ZclBCsIwEEDRvacYhkJbSvEEEXIO00WYGA1O0sHp0rM72m2Fv3r/EfV5Y7bsguWVEw9BgeaLTtO1D61/R@bh7GjU5Se0jIhWY2ngIK0nAJBXaRt0kAFrUd0TKXhYPsX6Z94fCe1DmeNdbSaRLw "Haskell – Try It Online") Inserts a newline symbol before every character that appears for the first time, resulting in a newline-separated string, with a leading newline. Prepend `lines.` to produce a list. --- **[Haskell](https://www.haskell.org/), 55 bytes** ``` (""%) _%[]=[] p%s|(a,b)<-span(`elem`s!!0:p)s=a:(a++p)%b ``` [Try it online!](https://tio.run/##ZclBDsIgEEDRPaeYEkkgtYnrRhacozZ22oISgU4cl55djNua/NX7d@SHT6kGe6laSmXEVQ2jHUZBit8aj7M5d0xY9OSTzxM3zaknwxZ7jW1LRs01YyxgYd0EANAzlhccIIDMkfkXUZS75VbMf@bcnmT9LCHhjWu3EH0B "Haskell – Try It Online") Repeatedly takes the prefix the first character plus the non-unique characters that follow it. [Answer] # [APL (Dyalog)](https://www.dyalog.com/), 9 bytes Thanks, Erik the Outgolfer for saving 1 byte! ``` ⊢⊂⍨⍳∘≢∊⍳⍨ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qLdP/VHfVOdIdfXixJwSdfVH3S1AfrCrXqizrwuQ2zYhKb9CIT9PQbfYNjczBSjStTg1LzEpJzXY0ScEpLp3jbrC/zSgwkddix51NT3qXfGod/OjjhmPOhc96ugCsXtX/P@fpqCem1lcDEIFBZnqXEB@gEKAgpqCs4I7mOfo6AihUxJzwQx1AA "APL (Dyalog) – Try It Online") # Explanation: `⍳⍨`: For each character, get the index of its first occurrence. e.g `mississippi -> 1 2 3 3 2 3 3 2 9 9 2` `⍳∘≢`: The range from 1 to the length of the input. `∊`: Membership. e.g `1 2 3 4 5 6 7 8 9 10 11∊1 2 3 3 2 3 3 2 9 9 2 -> 1 1 1 0 0 0 0 0 1 0 0` `⊢⊂⍨`: Partition the input string with new partitions starting at `1`s in the vector above [Answer] # [Japt](https://github.com/ETHproductions/japt), 11 bytes ``` ¬â r@=iRUbY ``` [Test it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=rOIgckA9aVJVYlk=&input=J21pc3Npc3NpcHBpJw==) ### Explanation This was inspired by [Magic Octopus Urn](https://codegolf.stackexchange.com/users/59376/magic-octopus-urn)'s [05AB1E solution](https://codegolf.stackexchange.com/a/156291/42545). ``` ¬â r@=iRUbY Implicit: U = input string ¬â Split U into chars, and keep only the first occurrence of each. r@ Reduce; for each char Y in this string... UbY Find the first index of Y in U. iR Insert a newline at this index in U. = Set U to the result. As reduce returns the result of the last function call, this gives the value of U after the final replacement, which is implicitly printed. ``` [Answer] # JavaScript (ES6), 37 bytes *Saved 7 bytes: a leading newline was explicitly allowed (Thanks @Shaggy!)* Takes input as an array of characters. Outputs a newline-separated string. ``` s=>s.map(c=>s[c]=s[c]?c:` `+c).join`` ``` ### Test cases ``` let f = s=>s.map(c=>s[c]=s[c]?c:` `+c).join`` ;[ [..."mississippi"], [..."P P & C G"], [..."AAA"], [..."Adam"], [...""] ] .forEach(s => console.log('{' + f(s) + '}\n')) ``` [Answer] ## brainfuck, 66 bytes ``` ,[>+[<[>+<<-<+>>-]>[>]<<[[+]++++++++++.>>>]<]<[>+<-]>>>[>>]<<-.>,] ``` Formatted: ``` , [ >+ [ <[>+< <-<+>>-] >[>] <<[[+]++++++++++.>>>] < ] <[>+<-] >>>[>>] <<-.>, ] ``` [Try it online](https://tio.run/##PcpRCoAwDAPQA3XbCUIuUvqhglBEGQ7PXzs/DCEf4a334tf@bEdEUYoiB6gQshqVBqiKyZ9G5mmfS8E0E9XGYhGnjzHbu78) The leading newline in the output (which is only printed if the input is non-empty) can be removed at the cost of 5 bytes by replacing the body `x` of the main (outermost) loop with `.>,[x]`. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes ``` ŒQœṗ⁸Ḋ ``` [Try it online!](https://tio.run/##y0rNyan8///opMCjkx/unP6occfDHV3/D7cfnfRw54z//5VyM4uLQaigIFMJAA "Jelly – Try It Online") [Answer] # [K4](http://kx.com/download/), 19 bytes **Solution:** ``` $[#x;(*:'.=x)_;,]x: ``` **Examples:** ``` q)k)$[#x;(*:'.=x)_;,]x:"mississippi" ,"m" ,"i" "ssissi" "ppi" q)k)$[#x;(*:'.=x)_;,]x:"P P & C G" ,"P" " P " "& " "C " ,"G" q)k)$[#x;(*:'.=x)_;,]x:"AAA" "AAA" q)k)$[#x;(*:'.=x)_;,]x:"Adam" ,"A" ,"d" ,"a" ,"m" q)k)$[#x;(*:'.=x)_;,]x:"" ,[""] ``` **Explanation:** 8 bytes is just to handle `""`... ``` $[#x;(*:'.=x)_;,]x: / the solution x: / save input as variable x $[ ; ; ] / $[condition;true;false] #x / length of x ("" has length 0, i.e. false) _ / cut right at left indices ( ) / do together =x / group x into key/value (char!indices) . / return value (get indices) *:' / first (*:) each , / enlist, "" => [""] ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~81~~ 74 bytes ``` def f(s):d=sorted(map(s.find,set(s)));print map(lambda a,b:s[a:b],d,d[1:]) ``` [Try it online!](https://tio.run/##LY29CsMwEIP3PsXhobHBFNrRIUPI0DV7CMThbGqof8jd0qd3Y1oQkuBDqHz4ldOjVnQevCRlcKB8sEMZbZF08yGhJscnUqovR0gMjbxt3NGC1buhxZp91ahxuZtVVXbEwyJiIGoqJQgtZpjhChM8zz6OY3O08QyxXnw@gCEkaEvz@9h4673k/2XX1S8 "Python 2 – Try It Online") [Answer] # [Python 2](https://docs.python.org/2/), 47 bytes ``` lambda s:reduce(lambda r,c:r+'\n'[c in r:]+c,s) ``` [Try it online!](https://tio.run/##VU09D8IgFJzlV7ww2DZlciTpQBxcu7cdkI9IIpS8h4O/HotxMbncx3B3@V0ee7pUP631qePdaiCJzr6M638ZhZE4dmvqFgMhAcptNIKGWhwVggkWHgNRQ86BCz7DDGe4wu3wSqnGVsdD@MaY3xGozXzbkp0yhlTA9zQIaCf1b@0D "Python 2 – Try It Online") Outputs a newline-separated string. Barely beats the program version: **[Python 2](https://docs.python.org/2/), 48 bytes** ``` r='' for c in input():r+='\n'[c in r:]+c print r ``` [Try it online!](https://tio.run/##K6gsycjPM/r/v8hWXZ0rLb9IIVkhMw@ICkpLNDStirRt1WPy1KPBgkVWsdrJXAVFmXklCkX//yvlZhYXg1BBQaYSAA "Python 2 – Try It Online") [Answer] # Perl, 30 bytes Includes `+1` for `p` Give input without trailing newline on STDIN. Output is also without trailing newline: ``` echo -n adam | perl -pE 's%.%$v{$&}+++!pos?$&:$/.$&%eg'; echo ``` If you don't care about leading and trailing newlines this `25` (`+3` for `-p` because the code contains `'`) also works: ``` #!/usr/bin/perl -p s%%$/x!$v{$'&~v0}++%eg ``` [Answer] # JavaScript, ~~61~~ ~~54~~ 52 bytes Takes input as an array of characters. ``` s=>s.map(x=>a[x]?a[y]+=x:a[x]=a[++y]=x,a=[],y=-1)&&a ``` --- ## Try it ``` o.innerText=JSON.stringify((f= s=>s.map(x=>a[x]?a[y]+=x:a[x]=a[++y]=x,a=[],y=-1)&&a )([...i.value=""]));oninput=_=>o.innerText=JSON.stringify(f([...i.value])) ``` ``` <input id=i><pre id=o></pre> ``` [Answer] # [R](https://www.r-project.org/), ~~94~~ 87 bytes ``` function(s,n=nchar(s),g=substring)g(s,d<-which(!duplicated(g(s,1:n,1:n))),c(d[-1]-1,n)) ``` [Try it online!](https://tio.run/##FYkxDsMgDAC/kmSyJRhYq@QlVYbEFLCUOgiD@nwapLvhdKWHabU9NKHKt4Aa2YTSUUDRxE3bqbWwRIzP8qv9JaYEs2/5Yjrqx8MY7iVDRDQE/m3dbp15sgdYvqw6yJkX7H8 "R – Try It Online") Returns a (possibly empty) list of substrings. *Thanks to Michael M for saving 7 bytes!* [Answer] # [Stax](https://github.com/tomtheisen/stax), 8 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` ç↓‼►▐NVh ``` [Run and debug online](https://staxlang.xyz/#c=%C3%A7%E2%86%93%E2%80%BC%E2%96%BA%E2%96%90NVh&i=mississippi%0A%0AP+P+%26+C+G%0A%0AAAA%0A%0AAdam%0A&a=1&m=1) The ascii representation of the same program is this. ``` c{[Ii=}(m ``` For each character, it splits when the index of the current character is the current position. ``` c copy the input { }( split the string when the result of the enclosed block is truthy [ duplicate the input string under the top of the stack I get the character index of the current character i= is it equal to the iteration index? m print each substring ``` [Answer] # [><>](https://esolangs.org/wiki/Fish), ~~22 17~~ 14 bytes *-1 byte thanks to Emigna* ``` i:::a$1g?!o1po ``` [Try it online!](https://tio.run/##S8sszvj/P9PKyipRxTDdXjHfsCD////czOJiECooyAQA "><> – Try It Online") Prints a leading and trailing newline. It keeps track of which letters have already appeared by `p`utting a copy of the character at that corresponding spot on the second row, and printing a newline if the value fetched from that position was not 1. Ends in an error when it tries to print `-1` [Answer] ## Haskell, 62 bytes ``` r#c|any(elem c)r=init r++[last r++[c]]|1<2=r++[[c]] foldl(#)[] ``` [Try it online!](https://tio.run/##ZYk7DsIwEAX7nGLlUCSKUkCNC58juFj5AyvWjmWnQcrZMbLSBekV82ZeWN6OuXr5qH5ly0M/LrrLvdkxfgbHLoAZs6RIG@RpWhjLAUbr/Xq/ycbt1IAUQYJdOwBImeIGF/AgApXSlhKJU1IWw59T6qxE/RrP@Cx1Nin9AA "Haskell – Try It Online") [Answer] # JavaScript (ES6), 68 bytes ``` s=>s.map(c=>o[c]?t+=c:(t&&m.push(t),t=o[c]=c),t='',o=m=[])&&[...m,t] ``` Takes input as a list of characters. **Test cases:** ``` let f= s=>s.map(c=>o[c]?t+=c:(t&&m.push(t),t=o[c]=c),t='',o=m=[])&&[...m,t] console.log(f([...'mississippi'])); console.log(f([...'P P & C G'])); console.log(f([...'AAA'])); console.log(f([...'Adam'])); console.log(f([...''])); ``` [Answer] # PHP, 317 bytes ``` function SplitOnFirstUnique($s){ $len = strlen($s); $output = []; $newstring = ''; for ($i=0; $i < $len ; $i++) { $newstring = $newstring.$s[$i]; if(!in_array($s[$i] , $output )){ $output[] = $newstring; $newstring = ''; } } return $output; } ``` [Try it online!](https://tio.run/##bU7LCsIwELz3K9YSMEER71G8efUgnoqISKsLul03CSLit9eE@EB0CGEzMzsZPnA3mfGBCxYkvxG95CP6Bc1RnF8RnkOtyxM6lw4zlsbYrgm089gS/DErZ24FRKhjTTAF5yUOibaQ@TZ4Dj5K1dpmhupLtCHtI9nvZ7JpBbTC6diCQpjkuDQPBgZuOepn@fMYKVcpfH6QgI3uIW22IturziIM32XAPFu/Y7NQrb9S7bfnX@@Ee/G5pfZB6JVni3vXPQA "PHP – Try It Online") [Answer] # [Red](http://www.red-lang.org), 79 bytes ``` func[s][foreach c next unique/case append s"^@"[print copy/part s s: find s c]] ``` [Try it online!](https://tio.run/##dcqxCsIwFIXhPU9x6OAm3TtZHFyLa4gQkhvM0PSa20Kl5NmjRXDr4Wz/l8nXO3loo0JXw5KcFqPDlMm6JxwSrTOWFF8Ltc4KwTJT8pDmcWk055hmuInfLds8QyAdQtw7nDE1YBujyH7mWNTPb@f/ivqSAQNOuOJ2BPq@P0zejketqPoB "Red – Try It Online") ## Ungolfed: ``` f: func [s] [ b: next unique/case append s "^@" ; append `null` to the end of the string, than ; find the unique characters and ; store all except the first to b foreach c b [ ; for each character in b print copy/part s s: find s c ; print the part of the string to ; where the character is found and ; set the beginning of the string to that position ] ] ``` [Answer] # [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), ~~115~~ ~~91~~ 77 bytes ``` N =INPUT S N LEN(1) . Y :F(END) S =S Y N SPAN(S) . OUTPUT REM . N :(S) END ``` [Try it online!](https://tio.run/##K87LT8rPMfn/n9NPwdbTLyA0hCsYyPRx9dMw1FTQU4jktHLTcPVz0eTiDFawDVaI5ALKBgc4@mkEg6T9Q0OAWhSCXH2BHD9OK6AoF1D1//@5mcXFIFRQkAkA "SNOBOL4 (CSNOBOL4) – Try It Online") Prints the substrings separated by newlines. Explanation: line `S` (for `SPLIT`) doesn't actually split, but instead extracts the first character of `N` and saves it (`.`) to `Y`. On `F`ailure, it jumps to `END`. The match should only fail when `N` is the empty string. Thus, when the input is empty, it jumps directly to `END` and outputs nothing. `S = S Y` concatenates `Y` onto `S`. `SPAN(S)` greedily matches a run of characters in `S`, and sends it (`.`) to `OUTPUT`, setting (`.`) `N` to the `REM`aining characters of `N` (if there are any). Then it jumps back to `S`. [Answer] # PowerShell, 73 bytes ``` {$r=@();$h=@{};[char[]]$ARGS[0]|%{if(!($h[$_]++)){$r+=""};$r[-1]+=$_};$r} ``` ## Usage ``` PS> & {$r=@();$h=@{};[char[]]$ARGS[0]|%{if(!($h[$_]++)){$r+=""};$r[-1]+=$_};$r} "mississipi" | ConvertTo-Json -Compress ["m","i","ssissi","pi"] ``` [Answer] # [Ruby](https://www.ruby-lang.org/), ~~65~~ ~~62~~ 58 bytes ``` ->s,*a{s.size.times{|i|(i==s.index(c=s[i])?a:a[-1])<<c} a} ``` [Try it online!](https://tio.run/##RY/NasMwEITveopFh8QujmivIWowOeTquxFla8lUELvCK0N@nGd3V0nrgnY1mvlWSMP4eZlbPW/eqXjBW/aqlCJF/upy1WG4TX7KvNakfG/dOWs01d7ke9xivXkz@W7X3AXe5@gofjRIjkBDLQBq2XmitELwskhnWUhW8umySIExRYLXFVSwggMc1wmtOGWD@yq1Q2rHP1aWZfm4MO2LZ7F7moxaLuTqljhFxggjxP9DlcPmC@w3TL4PYyzAnYNrorMTjwyOxlPkv7T1IzXshcH3cUn0wsMeZBaQKAcJW9Yt@hPrNPKLC9fbef4B) A lambda accepting a string and returning an array of strings. Approach: For each index, either append the character at that index in `s` to the result array, or to the last string in the result array. `String#index` returns the index of the first instance of the argument. -2 bytes: Initialize `a` as a splat argument instead of on its own line. *Thanks, [Value Ink](https://codegolf.stackexchange.com/users/52194/value-ink)!* -1 byte: Use `c=s[i]`...`c` instead of `s[i]`...`s[i]`. *Thanks, [Value Ink](https://codegolf.stackexchange.com/users/52194/value-ink)!* -4 bytes: Use `.times` instead of `.map` [Answer] # Java 8, ~~193~~ ~~169~~ ~~155~~ 151 bytes ``` s->{for(int l=s.length(),i=0,j;i<l;i++)if(s.indexOf(s.charAt(i))==i){for(j=i;++j<l&&s.indexOf(s.charAt(j))!=j;);System.out.println(s.substring(i,j));}} ``` -14 bytes thanks to *@raznagul* (for something obvious I somehow missed myself..) -3 bytes thanks to *@O.O.Balance* (again for something obvious I somehow missed myself.. :S) **Explanation:** [Try it online.](https://tio.run/##jZE/b4MwEMX3foorA7IFQd0dV0IdOjWNlLHqYAwk5xqDOBO1ivjs1BDGDEh3kv/87vk92air2rVd5Uz5M2mriOBDobs9AaDzVV8rXcFh3gJcWyxBs5Pv0Z2BuAinY@hQ5JVHDQdwIGGi3eutbnsWFMBKymzlzv7CeIryJTUC91ZgknCsGWXoyur3c17pi@pzz5BzKZEvAkaiSBKzt3H8gDScP0sjuDj9ka@arB181gVv3roA0VDQ4pRhGkgxjpO4m@2Gwgazq@clVRMyr8G@vhW/53WZZlGDRHN1HUZLYoAHz603y8QRjhDDG7xv5PM830qWqtmIbsTUdsXCKlg7Wr9@nP4B) ``` s->{ // Method with String parameter and no return-type for(int l=s.length(), // The length of the input-String i=0,j; // Index integers i<l;i++) // Loop `i` from 0 to `l` (exclusive) if(s.indexOf(s.charAt(i))==i){ // If the character at index `i` hasn't occurred yet: for(j=i;++j<l // Inner loop `j` from `i` to `l` (exclusive), &&s.indexOf(s.charAt(j))!=j;); // as long as the character at index `j` has already occurred System.out.println(// Print: s.substring(i,j));}} // The substring of the input from index `i` to `j` (exclusive) ``` ]
[Question] [ In the arcade version of the game, Pac-Man eats pac-dots. However, in this challenge, he's hungry for alphanumeric characters and punctuation in a string. Your task is to create a function that feeds Pac-Man a string, evaluates if he can eat it or not, and returns the string with Pac-Man's location in it. Pac-Man (`<`) eats characters from left to right, leaving an underscore or space for each character as he goes, and his goal is to get from the first position-1 to the last position+1: ``` 1. <Pac 2. _<ac 3. __<c 4. ___< ``` However, Pac-Man's natural enemy, the ghost, will stop him if he encounters one of the letters in the word "GHOST" (not case sensitive). Your function should return the string with Pac-Man's location as he encounters the `ghost` character: ``` 1. <No! 2. _<o! ``` The only thing that can defeat a ghost is a power pellet. If Pac-Man reaches a letter in the word "PELLET" (also not case sensitive) *before* coming to a ghost, he will eat the ghost and keep moving, and that pellet will be used up. Power pellets can stack (ie, in `ppgg` both ghosts would be eaten). The **T** character exists as both as a ghost and a pellet, so it can be ignored (treated as any other letter, like `a`). ``` 1. <Pop 2. _<op 3. __<p 4. ___< ``` To further clarify, in the string "Pac-Man loses here", the following operations occur: ``` P <P, +1 Pellet (1 pellet) a <a c <c - <- M <M a <a n <n <[space] l <l, +1 Pellet (2 pellets) o <o, -1 Pellet (1 pellet) s <s, -1 Pellet (0 pellets) e <e, +1 Pellet (1 pellet) s <s, -1 Pellet (0 pellets) <[space] h <h, ghost wins, returns e r e ``` ### Examples ``` Input: Pacman wins! Output: ____________< Input: Pacman loses wah-wah :( Output: _______________<h-wah :( Input: PELLET PELLET GHOST Output: ___________________< Input: Hello World! Output: <Hello World! Input: <_!@12<_<_< Output: ___________< ``` This is code-golf--lowest score in bytes wins. [Answer] ## [Retina](https://github.com/m-ender/retina), ~~55~~ 38 bytes ``` i`^(([elp])|[^ghos]|(?<-2>.))* $.&$*_< ``` [Try it online!](http://retina.tryitonline.net/#code=JShHYAppYF4oKFtlbHBdKXxbXmdob3NdfCg_PC0yPi4pKSoKJC4mJCpfPA&input=UGFjbWFuIHdpbnMhClBhY21hbiBsb3NlcyB3YWgtd2FoIDooClBFTExFVCBQRUxMRVQgR0hPU1QKSGVsbG8gV29ybGQh) (The first line just allows running several test cases at once.) ### Explanation The problem is essentially to find the longest prefix that doesn't have an unmatched closing parenthesis. Except that we can use either `e`, `l` or `p` in place of `(` and either `g`, `h`, `o` or `s` in place of `)`. Hence, this solution is almost a textbook example of balancing groups. I won't go into too much detail about how they work, as this code is essentially the same as the standard example you can read up on [in my SO answer on balancing groups](https://stackoverflow.com/a/17004406/1633117). The entire program is therefore a single regex substitution. The `i` activates case-insensitivity. Then we either match a pellet with `[elp]` and increment the depth counter (in the form of the capture stack of group `2`), or we match something that isn't a ghost with `[ghos]` or we match a ghost with `.` and decrement the depth counter by popping from stack `2`. Of course, in principle this allows matching a pellet with the `[^ghos]` section or a non-ghost with the `.` section, but thanks to greedy matching and the way the regex is backtracked, these possibilities are never attempted by the regex engine. The substitution then uses two Retina specific features: `$*` repeats the character to its right as many times as specified by the token on its left. That token is `$.&` which is the length of the entire match. This just means that we replace each character in the match with a `_`. And then we also append a `<` to those underscores. The part of the input that isn't eaten simply remains unaffected by the substitution. [Answer] # Jelly, ~~34~~ 33 bytes ``` Œl“ʋʋ“ṁḍ»ċ€Ð€IF+\‘0ṭi0ð’”_×;”<;ṫ@ ``` [Try it online!](http://jelly.tryitonline.net/#code=xZJs4oCcyovKi-KAnOG5geG4jcK7xIvigqzDkOKCrElGK1zigJgw4bmtaTDDsOKAmeKAnV_DlzvigJ08O-G5q0A&input=&args=IlBhY21hbiBsb3NlcyB3YWgtd2FoIDooIg) I think I'm finally starting to understand Jelly. Feels a bit scary. [Answer] # Python 2, 114 113 108 bytes ``` s=raw_input() p=i=0 for c in s: p+=(c in'plePLE')-(c in'ghosGHOS') if p<0:break i+=1 print'_'*i+'<'+s[i:] ``` [Answer] # Python 2, 89 bytes Sometimes my stubborn determination to make Python a functional language has its benefits. ``` def f(s,l=1):l+=(s[:1]in'plePLE')-(s[:1]in'ghosGHOS');return s*l and'_'+f(s[1:],l)or'<'+s ``` ### (Slightly) ungolfed: ``` def f(s, l=1): l += (s[:1] in 'plePLE') - (s[:1] in 'ghosGHOS') return (s * l) and ('_' + f(s[1:], l)) or ('<' + s) ``` Builds up the result string using recursion. The update to `l` (for "lives") adds 1 for pellets (`True - False == 1`), subtracts 1 for ghosts (`False - True == -1`), and adds 0 for any other character. It also adds 0 when `s` is the empty string, thanks to Python's slicing and the fact that `'' in any_str == True`, so the pellet and ghost cancel. The return statement uses `test and b or a` in place of `a if test else b` to save one byte. The recursion base case occurs when either the string ends or Pac-Man runs out of pellets, succinctly represented as `s*p`, which equals `''` (and therefore evaluates to false) when either `s == ''` or `p == 0`. [Answer] # Pyth, ~~53~~ ~~48~~ 44 bytes 4 bytes thanks to @Pietu1998 for the `!!@` -> `}` trick (which only people who know Pyth can understand) ``` ~~++\*Jf<@+sM.\_m-!!@d"PELpel"!!@d"GHOSghos"Q\_1T00\\_\<>QJ~~ ~~++\*Jf<@+sM.\_m-!!@d"PEL"!!@d"GHOS"rQ1\_1T00\\_\<>QJ~~ ++*Jf<@+sM._m-}d"PEL"}d"GHOS"rz1_1T00\_\<>zJ ``` [Test suite.](http://pyth.herokuapp.com/?code=%2B%2B%2aJf%3C%40%2BsM._m-%7Dd%22PEL%22%7Dd%22GHOS%22rz1_1T00%5C_%5C%3C%3EzJ&test_suite=1&test_suite_input=Pacman+wins%21%0APacman+loses+wah-wah+%3A%28%0APELLET+PELLET+GHOST%0AHello+World%21%0A%3C_%21%4012%3C_%3C_%3C&debug=0) [Answer] # [MATL](https://github.com/lmendo/MATL), ~~37~~ ~~36~~ 35 bytes ``` tkt'ghos'mw'pel'm-Ys1=Y>&)g95*60bhh ``` [**Try it online!**](http://matl.tryitonline.net/#code=dGt0J2dob3MnbXcncGVsJ20tWXMxPVk-JilnOTUqNjBiaGg&input=J1BhY21hbiBsb3NlcyB3YWgtd2FoIDooJw) ### Explanation ``` tkt % Input string implicitly. Duplicate, convert to lower case, duplicate 'ghos'm % True for "ghost" characters w'pel'm % Swap to bring lowercase copy to top. True for "pellet" characters -Ys % Subtract, cumulative sum. Pac-Man can reach until the first "1" 1= % True for entries that equal 1 Y> % Cumulative maximum. This gives false until the first true is found, and % true from there on &) % Split original string in two parts, given by the zeros and ones respectively g95* % Convert the first part into ones and multiply by 95. This gives a numerical % array containing number 95 (ASCII for '_') 60 % Push 60 (ASCII for '<') b % Bubble up second part of original string hh % Concatenate the three strings/arrays, automatically converting to char ``` [Answer] ## JavaScript (ES6), 98 bytes ``` s=>s.replace(/./g,c=>p<0?c:(p+=/[elp]/i.test(c)-/[ghos]/i.test(c))<0?"<"+c:"_",p=0)+"<".slice(p<0) ``` Explanation: `p` maintains the current number of pellets. If it's already negative, we just return the character and move on, so that the rest of the string is untouched. Otherwise, we examine the current character, and if that makes `p` become negative, we insert the `<` character, otherwise we replace the current character with `_`. Finally, if `p` never becomes negative, we suffix a `<` to the string. [Answer] # C#, ~~269~~ ~~256~~ ~~232~~ ~~212~~ 211 Bytes First ever post on here, so this is probably a lot longer than it could be (and probably because it is in C#). Any tips on where I could shorten it would be great! Thank you to everyone in the comments who helped me! ### Golfed version ``` static void p(string x){int p=0,i=0;string t='<'+x;var s=t.ToCharArray();for(;++i<s.Length;){if("PELpel".Contains(s[i]))p++;if("GHOSghos".Contains(s[i])&&--p<0)break;s[i]='<';if(i>0)s[i-1]='_';}Console.Write(s);} ``` ### Ungolfed version ``` static void p(string x) { int p = 0, i = 0; string t = '<' + x; var s = t.ToCharArray(); for (; ++i < s.Length;) { if ("PELpel".Contains(s[i])) p++; if ("GHOSghos".Contains(s[i]) && --p < 0) break; s[i] = '<'; if (i > 0) s[i - 1] = '_'; } Console.Write(s); } ``` [Answer] # Pyth, ~~47~~ ~~46~~ 44 bytes ``` ++*\_Kh+f!h=+Z-}Jr@zT0"pel"}J"ghos"Uzlz\<>zK ``` [Try it online.](http://pyth.herokuapp.com/?code=%2B%2B*%5C_Kh%2Bf!h%3D%2BZ-%7DJr%40zT0%22pel%22%7DJ%22ghos%22Uzlz%5C%3C%3EzK&input=Pac-Man+loses+here&debug=0) [Test suite.](http://pyth.herokuapp.com/?code=%2B%2B*%5C_Kh%2Bf!h%3D%2BZ-%7DJr%40zT0%22pel%22%7DJ%22ghos%22Uzlz%5C%3C%3EzK&test_suite=1&test_suite_input=Pacman+wins%21%0APacman+loses+wah-wah+%3A%28%0APELLET+PELLET+GHOST%0AHello+World%21%0A%3C_%21%4012%3C_%3C_%3C&debug=0) Quite a different approach from Leaky Nun's, and I'm quite sure this can be golfed further. [Answer] ## Lua, ~~198~~ ~~190~~ ~~184~~ ~~185~~ 163 Bytes Ok, I admit, this is long. Very long. Lua has some tools to play around with strings, but it is limited, same goes for conditionals that takes lots of spaces. **Edit: thanks @LeakyNun for saving me 9 bytes :) Lost some bytes to fix a bug** **Edit 2: 163 Bytes solution found by @LeakyNun** ``` i=0p=0n=...for c in n:gmatch"."do p=p+(c:find"[ghosGHOS]"and-1or c:find"[pelPEL]"and 1or 0)if p<0then break else i=i+1 end end print(('_'):rep(i)..'<'..n:sub(i+1)) ``` **Old 185** ``` p=0z=(...):gsub(".",function(c)p=p+(c:find"[ghosGHOS]"and-1or c:find"[pelPEL]"and 1or 0)s=p<0 and 1or s return s and c or'_'end)_,i,s=z:find"(_+)"print((s or'')..'<'..z:sub(1+(i or 0))) ``` ## Ungolfed ``` i=0 -- number of characters eaten p=0 -- pellet counter n=... -- shorthand for the argument for c in n:gmatch"." -- iterate over each characters in the input do p=p+(c:find"[ghosGHOS]" -- if the current char is a GHOST and-1 -- decrement the pellet counter or c:find"[pelPEL]" -- if it's a PELLET and 1 -- increment it or 0) -- else, leave it alone if p<0 -- if we try to eat a ghost without pellet then break -- stop iterating else i=i+1 -- else, increment our score end end print(('_'):rep(i) -- print i*'_' ..'<' -- appended with Pacman ..n:sub(i+1)) -- appended with the remaining characters if we died ``` [Answer] ## Python 3, ~~176~~ ~~157~~ ~~150~~ ~~149~~ ~~134~~ ~~133~~ 124 bytes Define a function named `f` which take the string as argument ``` def f(s): n=i=0 for c in s: if c in"GgHhOoSs": if n:n-=1 else:break n+=c in"PpEeLl";i+=1 return"_"*i+"<"+s[i:] ``` Can be probably be golfed more Thanks to everyone who commented :D [Answer] # Python 3, ~~114~~ 110 bytes My first code golf. Thanks to Dr Green Eggs and Iron Man for saving 4 bytes. ``` l,x=1,0 f,y,s="ghosGHOS","pelPEL",input() while s[x:]*l:l+=(s[x]in y)-(s[x]in f);x+=l>0 print("_"*x+"<"+s[x:]) ``` Utilises the evaluation of booleans to one and zero to condense a logical AND to a multiplication. (0\*0=0, 1\*0=0, 1\*1=1). I hope this is a good first try. [Answer] # Powershell, 185 ``` {$l=1;$o="";for($i=0;($i -lt $_.Length) -or (($o+="<") -and 0); $i++){if ($_[$i] -match '[pel]'){$l++}if($_[$i] -match '[ghos]'){$l--}if(!$l){$o+="<"+$_.substring($i);break}$o+="_"}$o} ``` ### Ungolfed: ``` ("Pacman wins!", "Pacman loses wah-wah :(", "PELLET PELLET GHOST", "Hello World!" ) | % { $l=1;$o=""; for($i = 0; ($i -lt $_.Length) -or (($o+="<") -and 0); $i++) { if ($_[$i] -match '[pel]') { $l++ } if ($_[$i] -match '[ghos]') { $l--} if (!$l) { $o+="<"+$_.substring($i); break } $o += "_" } $o } ``` [Answer] # Python3, ~~211~~ 184 bytes The argument 's' is a string ``` def f(s): p=c=0 for i in s: if i in "gGhHoOsS": if p<1:break else:p-=1 if i in "pPeElL":p+=1 c+=1 return"_"*c + "<" + s[c:] ``` I would appreciate any golfing tips as this is my first code golf attempt Thanks for commenting :) [Answer] # Haskell, ~~119~~ 113 Bytes Thanks to Daniel Wagner for 6 bytes less. ``` p=(0!) n!(c:s)|elem c"ghosGHOS"=if n<1then '<':c:s else(n-1)&s|elem c"elpELP"=(n+1)&s|0<1=n&s _!_="<" n&s='_':n!s ``` Call it as `p "Hello World!"`. The `1then` is an edge case that is interpreted correctly in my GHC (7.10), but it throws of most syntax highlighters. So it might be interpreted differently in your compiler as well. Ungolfed: ``` pacman string = go 0 string -- | In the golfed version: (!) go _ [] = "<" -- won go pellets (char:string) | char `elem` "ghosGHOS" = if pellets < 1 then '<':char:string -- lost else nextStep (pellets - 1) string -- ghost | char `elem` "elpELP" = nextStep (pellets + 1) string -- pellet | otherwise = nextStep pellets string -- anything else -- | In the golfed version: (&) nextStep pellets string = '_':(go pellets string) ``` [Answer] # C, 237 bytes ``` #include<stdio.h> #include<string.h> main(p,i,j){char s[99];fgets(s,99,stdin);for(p=i=0;s[i];++i){if(strchr("GHOSghos",s[i])){if(p)p--;else break;}else if(strchr("PELpel",s[i]))p++;}j=i-(s[i]==0);while(j--)printf("_");printf("<%s",s+i);} ``` [Answer] # **C++, 315 373 327 Bytes** **(Note: still golfing)** ``` #include <iostream> #include <string> using namespace std; int main(){string input;getline(cin, input); if(input.find("Pac-Man loses")!=string::npos||input.find("Pacman loses")!=string::npos) cout<<"<"<<input.substr(15,input.length()-1); else{for(unsigned i=0;i<=input.length();++i) cout << "_"; cout<<"<"; }return 0; } ``` [Answer] # **Ruby, (119 bytes)** ``` q=i=0;a=$**" ";a.split(//).each{|c|q+=((c+?p=~/[ple]/i)^1)-((c+?g=~/[ghos]/i)^1);q<0?break : i+=1};p ?_*i+?<+a[i..-1] ``` There is probably some things i'm missing as I am new to this... Ruby is my friend :) [Answer] # Perl, 54 (52+2) bytes ``` s/([pel](?1)*[ghos]|[^ghos ])*/'_'x(length$&).'<'/ei ``` Needs `-p` to be specified in the command-line options. Explanation: The `-p` option causes the statement to be wrapped in a read-modify-print loop, where during each loop iteration, `$_` contains a line of input, including the line delimiter. The regex is largely the same idea as in the Retina answer. Call the search pattern `([pel](?1)*[ghos]|[^ghos ])*` "acceptable". Then it can be recursively defined as: A string is "acceptable" if: * It is a character in `PELLET` except for `T`, followed by an acceptable string, followed by a character in `GHOST` except for `T`. * It is a character not in `GHOST` except for `T` that is not a newline character. * It is a concatenation of any number (including 0) of acceptable strings. This definition allows more pellets than ghosts: a `PEL` character may be matched as either a pellet character, or a non-ghost character. The empty string is considered acceptable, therefore the regex is guaranteed to match at position 0, where the longest acceptable substring will be matched. This longest acceptable substring is then matched by underscores of equal length, followed by `<`. ]
[Question] [ Your task is to print the hexidecimal times table: ``` 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e 00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d 00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c 00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b 00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a 00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87 00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96 00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5 00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4 00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3 00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2 00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 ``` # Specifications: * You can print the hex values in uppercase. * Your lines can end with a trailing space and the program output can end with a trailing newline. * Every hex value must be padded to 2 digits with `0`s as shown. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer (measured in bytes) wins. [Answer] # [Python 2](https://docs.python.org/2/), 60 bytes ``` for n in range(256):r=n%16;print'%02x%s'%(n/16*r,r/15*'\n'), ``` [Try it online!](https://tio.run/nexus/python2#@5@WX6SQp5CZp1CUmJeeqmFkaqZpVWSbp2poZl1QlJlXoq5qYFShWqyuqpGnb2imVaRTpG9oqqUek6euqfP/PwA "Python 2 – TIO Nexus") ### How it works For all integers **n** from **0** to **255**, we do the following. * We compute **(n / 16) × (n % 16)**. Over the range of **n**, both **n / 16** and **n % 16** independently cover the range **0, …, 15**, so this generates all entries of the multiplication table. * We repeat the linefeed character (`'\n'`) **(n % 16) / 15** times, which results in the same character when **n % 16 = 15** and an empty string otherwise. * The format string `'%02x%s'` turns the two previous results into a single string, first a lowercase hexadecimal integer representation, zero-padded to (at least) two digits, then the generated string. * Finally, `print...,` prints the formatted results. Since the print statement ends with a comma, Python will not append a linefeed. Also, before printing the next string, Python will prepend a space *unless* we're at the beginning of a new line. ([source](https://docs.python.org/2/reference/simple_stmts.html#the-print-statement)) This happens to format the output exactly like we want to. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes ``` ⁴Ḷ×þ`d⁴‘ịØhG ``` [Try it online!](https://tio.run/nexus/jelly#@/@occvDHdsOTz@8LyEFyH7UMOPh7u7DMzLc//8HAA "Jelly – TIO Nexus") ### How it works ``` ⁴Ḷ×þ`d⁴‘ịØhG Main link. No arguments. ⁴ Set the return value to 16. Ḷ Unlength; yield [0, ..., 15]. ×þ` Build the multiplication table of [0, ..., 15] and itself. d⁴ Divmod 16; yield [p : 16, p % 16] for each product p. ‘ Increment quotients and remainders (1-based indexing). ịØh Index into the lowercase hexadecimal alphabet. G Grid; join columns by spaces, rows by newlines. ``` [Answer] # R, 42 bytes ``` as.hexmode(sapply(0:15,function(x)x*0:15)) ``` Prints the following: ``` [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [1,] "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" [2,] "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0a" "0b" "0c" "0d" "0e" "0f" [3,] "00" "02" "04" "06" "08" "0a" "0c" "0e" "10" "12" "14" "16" "18" "1a" "1c" "1e" [4,] "00" "03" "06" "09" "0c" "0f" "12" "15" "18" "1b" "1e" "21" "24" "27" "2a" "2d" [5,] "00" "04" "08" "0c" "10" "14" "18" "1c" "20" "24" "28" "2c" "30" "34" "38" "3c" [6,] "00" "05" "0a" "0f" "14" "19" "1e" "23" "28" "2d" "32" "37" "3c" "41" "46" "4b" [7,] "00" "06" "0c" "12" "18" "1e" "24" "2a" "30" "36" "3c" "42" "48" "4e" "54" "5a" [8,] "00" "07" "0e" "15" "1c" "23" "2a" "31" "38" "3f" "46" "4d" "54" "5b" "62" "69" [9,] "00" "08" "10" "18" "20" "28" "30" "38" "40" "48" "50" "58" "60" "68" "70" "78" [10,] "00" "09" "12" "1b" "24" "2d" "36" "3f" "48" "51" "5a" "63" "6c" "75" "7e" "87" [11,] "00" "0a" "14" "1e" "28" "32" "3c" "46" "50" "5a" "64" "6e" "78" "82" "8c" "96" [12,] "00" "0b" "16" "21" "2c" "37" "42" "4d" "58" "63" "6e" "79" "84" "8f" "9a" "a5" [13,] "00" "0c" "18" "24" "30" "3c" "48" "54" "60" "6c" "78" "84" "90" "9c" "a8" "b4" [14,] "00" "0d" "1a" "27" "34" "41" "4e" "5b" "68" "75" "82" "8f" "9c" "a9" "b6" "c3" [15,] "00" "0e" "1c" "2a" "38" "46" "54" "62" "70" "7e" "8c" "9a" "a8" "b6" "c4" "d2" [16,] "00" "0f" "1e" "2d" "3c" "4b" "5a" "69" "78" "87" "96" "a5" "b4" "c3" "d2" "e1" ``` [Answer] # Bash + coreutils, 40 * 1 byte saved thanks to @MitchellSpector ``` printf %02x\ $[{0..15}*{0..15}]|fmt -52 ``` * Bash expands brace expansions before arithmetic expansions, so the string `$[{0..15}*{0..15}]` first expands to `$[0*0] $[0*1] $[0*2] ... $[0*15] $[1*0] ... $[15*15]`. * The above series of arithmetic expansions then expand to the numerical table contents, as decimal integers. * The `printf '%02x '` expresses this list of decimal integers as hex, zero-padded to two characters * `fmt -52` formats the integers as 47 character wide lines, giving the desired alignment. [Note `fmt` tries to make lines *goal* characters wide.](https://www.gnu.org/software/coreutils/manual/html_node/fmt-invocation.html#fmt-invocation) By default, this is 7% shorter than width. 52\*93% -1 (for newline) = 47. [Try it online](https://tio.run/nexus/bash#@19QlJlXkqagamBUEaOgoBJdbaCnZ2haqwWlY2vScksUdE2N/v8HAA). [Answer] ## C#6, 98 bytes ``` ()=>{int i,j;for(i=-1;++i<16;)for(j=-1;++j<16;)System.Console.Write($"{i*j:x2} {j<15?"":"\n"}");}; ``` [repl.it demo](https://repl.it/EsWj/0) Standard nested for-loop. Only trick is to print newline when j>=15. [Answer] ## JavaScript (ES6), ~~79~~ ~~78~~ 77 bytes ``` f=(i=256)=>i?f(--i)+(i%16*(i>>4)+256).toString(16).slice(1)+` `[~i&15&&1]:`` document.write('<pre>'+f()) ``` Edit: Saved 1 byte thanks to @ETHproductions and another byte thanks to @YairRand. [Answer] # [MATL](http://github.com/lmendo/MATL), ~~19~~ 18 bytes ``` 16:q&*1YAO3Z(!48e! ``` [Try it online!](http://matl.tryitonline.net/#code=MTY6cSYqMVlBTzNaKCE0OGUh&input=) ``` 16:q % Push [0 1 ... 15] &* % 16×16 matrix of pairwise products 1YA % Convert to hexadecimal. Gives a 256×2 char array O3Z( % Assign char 0 to 3rd column. Gives a 256×3 char array !48e! % Reshape in row-major order as a 48-column char array % Implicitly display. Char 0 is shown as space ``` [Answer] # [PowerShell](https://github.com/PowerShell/PowerShell), 46 bytes ``` 0..15|%{$i=$_;"$(0..15|%{"{0:X2}"-f($i*$_)})"} ``` [Try it online!](https://tio.run/nexus/powershell#@2@gp2doWqNarZJpqxJvraSiARNQqjawijCqVdJN01DJ1FKJ16zVVKr9/x8A "PowerShell – TIO Nexus") Loops from `0` to `15`, sets `$i` to be that current number, then loops again. Uses the `-f`ormat operator with the `X2` designation to specify the output is he`X`adecimal padded to `2` spaces with leading zeros. Of special note, and really the only golf, is that instead of using a `(...)-join' '` to take the hex results, encapsulate them in an array, and concatenate them together into a string, we leverage the fact that the default `$OutputFieldSeparator` value for stringifying an array is a space. That means we can do a string with a script block in it `"$(...)"` instead, saving 6 bytes. Those strings are all left on the pipeline, and output via implicit `Write-Output` at program completion gives us a newline between them for free. [Answer] # [Haskell](https://www.haskell.org/), 87 bytes ``` import Numeric main=mapM(\x->putStrLn$do y<-s;['0'|x*y<16]++showHex(x*y)" ")s s=[0..15] ``` [Try it online!](https://tio.run/##y0gszk7Nyfn/PzO3IL@oRMGvNDe1KDOZKzcxM882N7HAVyOmQteuoLQkuKTIJ08lJV@h0ka32Dpa3UC9pkKr0sbQLFZbuzgjv9wjtUIDKKCppKCkWcxVbBttoKdnaBr7/z8A "Haskell – Try It Online") I imagine there's a better way. Maybe depend on the `printf` package.... [Answer] **K7, 36 bytes** ``` ` 0:" "/:'{`hex@`c$x}''{x*/:\:x}@!16 ``` [Answer] # [Stax](https://github.com/tomtheisen/stax), 11 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` äΔ←ùûv╚ö♦.J ``` [Run and debug it](https://staxlang.xyz/#p=84ff1b979676c894042e4a&i=&a=1) [Answer] # Ruby, 49 bytes ``` 256.times{|i|print"%02x "%(i/16*j=i%16),$/*j/=15} ``` Pretty straightforward use of the `%` operator equivalent to `sprintf`. `$/` is the line separator variable (`\n` by default.) Note the use of assignments such as `j/=15` to avoid longer parentheses `(j/15)` [Answer] # Mathematica, 46 bytes ``` Grid@Array[IntegerString[1##,16,2]&,{16,16},0] ``` Straightforward implementation using the built-in `IntegerString`, in base `16`, padding to length `2`. The `Array[...,{16,16},0]` has the two variables each run from 0 to 15. [Answer] # Matlab, 53 Bytes ``` for i=[0:15]'*[0:15];fprintf('%02X ',i);disp(' ');end ``` Sample output: ``` 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E 00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D 00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A 00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4 00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3 00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2 00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1 ``` [Answer] # Perl, 48 bytes ``` for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%} ``` [Try it online!](https://tio.run/nexus/perl#@5@WX6SSqOGgamugp2doqlldUJSZV5KmpGpgVKGgVOGgqqeir5ObWKCSqKUSr@OgWvv/PwA "Perl – TIO Nexus") I'm positive this isn't optimally golfed, but I'll be damned if I can find something better. ### Code breakdown: ``` for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%} 0..15 #Create a list of the range 0 - 15... @%= #...and store it in the array @% for$a( ){ } #Loop through @% with $a as the iterator printf[ string ],[ params ] #Perl's port of the standard printf function "%02x " #2-digit (hexit?) padding, followed by space... x@% #...repeated 16 times (in scalar context, @% represents the size of array @%)... .$/ #...followed by a newline map$a*$_,@% #Loops through @%, and using $_ as the iterator, returns a list composed of each member of @% multiplied by the current $a ``` [Answer] # [Perl 6](https://perl6.org), 42 bytes ``` .fmt("%02x").put for (^16 X*^16).rotor: 16 ``` [Try it](https://tio.run/nexus/perl6#@6@XlluioaRqYFShpKlXUFqikJZfpKARZ2imEKEFJDX1ivJL8ousFAzN/v8HAA "Perl 6 – TIO Nexus") ## Expanded: ``` .fmt("%02x") # format each element of list to lowercase hex .put # print with trailing newline for # for each of the following ( ^16 # Range upto ( and excluding ) 16 X* # cross multiplied with ^16 ).rotor: 16 # break it up into chunks of 16 values ``` [Answer] # JavaScript, 104 Bytes ``` s="";for(a=0;16>a;a++){for(b=0;16>b;b++)c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c);s+="\n"} ``` Call using variable `s`: ``` console.log("HEX Table: " + s) ``` Ungolfed code: ``` s=""; // Define s as empty string for(a=0;16>a;a++){ // For y axis for(b=0;16>b;b++) // For x axis c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c); // Multiply and format s+="\n" // Add line breaks } ``` [Answer] # C, ~~68~~ 66 bytes ``` f(i){for(i=0;i<256;)printf("%02x%c",i%16*(i++/16),i%16<15?32:10);} ``` -2 bytes thanks to ceilingcat! Ungolfed: ``` f(i){ for(i=0; i<256;) printf("%02x%c", i%16*(i++/16), i%16<15 ? 32 : 10); } ``` Prints the zero padded result and either space or newline. [Answer] # Python 3, 55 bytes ``` r=range(16) for x in r:print(*['%02x'%(x*y)for y in r]) ``` Using %formatting saves quite a few bytes over [2:] usage. So does using \* splats on the print function. [Answer] # [Japt](https://github.com/ETHproductions/japt/) `-R`, ~~20~~ 15 bytes ``` GÆGÇ*X sGÃùT2 ¸ ``` [Try It Online!](https://tio.run/##y0osKPn/3/1wm/vhdq0IhWL3w82Hd4YYKRza8f@/bhAA) ``` GÆGÇ*X sGÃùT2 ¸ G :16 Æ :Map each X in the range [0,G) GÇ : Map the range [0,G) *X : Multiply by X sG : Convert to base-16 string à : End map ù : Left pad each T : With 0 2 : To length 2 ¸ : Join with spaces :Implicitly join with newlines and output ``` [Answer] # Octave, 34 bytes ``` disp(num2str((a=0:15)'*a,'%02x ')) ``` [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), 17 bytes ``` 16F15ÝN*8o+h€¦ðý» ``` [Try it online!](http://05ab1e.tryitonline.net/#code=MTZGMTXDnU4qOG8raOKCrMKmw7DDvcK7&input=) ``` 16F For N in [0,15] 15Ý Push [0, ..., 15] N* Multiply by N 8o+ Add 256 h Take the uppercase hexadecimal representation €¦ Remove the leading 1 of each value ðý Join with spaces » End for and join everything with newlines ``` There might be a better way to handle this in 05AB1E. [Answer] # C, 61 bytes ``` i;f(){while(i<256)printf("%02x%c",i%16*(i>>4),++i%16?32:10);} ``` [Wandbox](http://melpon.org/wandbox/permlink/UET5UY8bkjK5jZfH) [Answer] # Python2, ~~102~~ ~~97~~ ~~92~~ ~~90~~ 89 bytes ``` i=1 exec"print' '.join('%02x'%(j-x)*(i>0)for x,j in enumerate(range(0,16*i,i)));i+=1;"*16 ``` Output: ``` 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e 00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d 00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c 00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b 00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a 00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87 00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96 00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5 00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4 00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3 00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2 00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 ``` [Try it online!](https://tio.run/nexus/python2#BcFBCoAgEADAe6@QINw1C@3gJeovElus0BZi4O9tpvHmO6p09G9mKVrpOT0soAe3VD1Amioa4N3h@WRVbVIsiuS7KcdCkKNcBM76YNgyIq48bn7tjQ@t/Q) [Answer] # SmileBASIC, ~~56~~ ~~51~~ 47 bytes ``` I=RND(16)J=RND(16)LOCATE I*3,J?HEX$(I*J,2)EXEC. ``` [Answer] # k, 50 bytes ``` `0:" "/'("0123456789abcdef"@16 16\)''{x*\:/:x}@!16 ``` Alas, it is hindered by the lack of a built-in hexadecimal printer. Reading right-to-left, more-or-less: ``` !16 / make the array {0, 1, 2, ..., 15} {x*\:/:x}@ / cartesian product of the array multiplied by itself, results in a table ( )'' / for each row, for each column 16 16\ / decode int to two digits in base 16 "0123456789abcdef"@ / get the characters to form a string " "/' / join the columns with a space, the table is now an array `0: / print the array, each element is one line ``` [Answer] ## [///](https://esolangs.org/wiki////), 588 bytes ``` /;/\/ //|/\/\///A/00 |B/ A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9 B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6FfG8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 96 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1 ``` A more readable version with newlines: ``` /] [///;/\/ //|/\/\///A/00 |B/ A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/] [AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf ] [B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D] [8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc ] [B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF] [0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9] [ B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6Ff] [G8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 9] [6 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0] [FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5] [K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 ] [c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1 ``` Pretty simple if you know how /// works. It's just a few string replacements. [Answer] # [///](https://esolangs.org/wiki////), 544 bytes Well, everyone's doing /// answers now: ``` /|/\/\///Z/\/ |P/ 0B|MZ9|LZ8|KZ7|JZ6|IZ5|HZ4|GZ3|FZ2|EZ1|C/BBB|B/0A|AZ0/0CCCCC0P1A2A3A4A5A6A7A8A9AaAbAcAdAeAfP2A4A6A8AaAcAeE0E2E4E6E8EaEcEeP3A6A9AcAfE2E5E8EbEeF1F4F7FaFdP4A8AcE0E4E8EcF0F4F8FcG0G4G8GcP5AaAfE4E9EeF3F8FdG2G7GcH1H6HbP6AcE2E8EeF4FaG0G6GcH2H8HeI4IaP7AeE5EcF3FaG1G8GfH6HdI4IbJ2J9P8E0E8F0F8G0G8H0H8I0I8J0J8K0K8P9E2EbF4FdG6GfH8I1IaJ3JcK5KeL7PaE4EeF8G2GcH6I0IaJ4JeK8L2LcM6PbE6F1FcG7H2HdI8J3JeK9L4LfMa a5PcE8F4G0GcH8I4J0JcK8L4M0Mc a8 b4PdEaF7G4H1HeIbJ8K5L2LfMc a9 b6 c3PeEcFaG8H6I4J2K0KeLcMa a8 b6 c4 d2PfEeFdGcHbIaJ9K8L7M6 a5 b4 c3 d2 e1 ``` I replaced `\s0` through `\s9` with `A` then `E` through `M`, `0 0` with `C`, `\n00 0` with P, `/\s` with `Z` and finally `//` with `|`, adding all these at the front of the code as I went. [Try it online!](https://tio.run/nexus/slashes#HY9LjoUgFETnvQp3ICLCZYgdQFETxqQn/FwFe39d3c/kDe7JqSo@85h/8M1zwv804vzF9vEkPe5E40pqhCTHmbZxJDF8WodLfNi0jO953/exz8wMk9jMvv9@LC6Gm9UIsxlplCGjTTbFVNNMN2/kIBLXjEu3zHIrrLRks622xxVMg7y4b7gW293ihFMuuxYFvApHgFTHcCdXPfPCk69xQ@YLpuGsIM1zr3w9lkMeJUqYHF6HleFIEH7Q0U9x5qiwZUPmCrYg7YXTQErgQUdCJ6GP4NHBDjrZSYEFuthFUSO3ILUh8wVbzhzWUK/t6reKGYs6TI4@CS8HEfpFN7/rI2OxEu@rXmFLQ@YKpm9xv0@e8hYragVKK2IFCitE8bCnTpmmImKz2Skv8MSOqXRtiH3/qJ6KnOoaO96UsVlC51jb0Zr/ZWAxNR5frGsoKFimEa8eiWaEQwef@vL5/AI) [Answer] # Python 3, 66 bytes ``` r=range(16) for i in r:print(*[('0'+hex(j*i)[2:])[-2:]for j in r]) ``` [Answer] # [Perl 5](https://www.perl.org/), 45 bytes ``` for$"(@a=0..15){printf"%02x ",$_*$"for@a;say} ``` [Try it online!](https://tio.run/##K0gtyjH9/z8tv0hFScMh0dZAT8/QVLO6oCgzryRNSdXAqEJBSUclXktFCajEIdG6OLGy9v9/k3/5BSWZ@XnF/3V9TfUMDA0A "Perl 5 – Try It Online") ]
[Question] [ As part of [his answer to *Make an Error Quine!*](https://codegolf.stackexchange.com/a/36262), @Falko proposed the following algorithm: > > ## How to create your own solution in 2 minutes? > > > 1. Open a new file in an IDE of your choice. > 2. Bang your head onto the keyboard in front of you. > 3. Compile. > 4. Replace the code with the compiler error message. > 5. Repeat steps 3 and 4 until the code converges. > > > I bet such a procedure terminates pretty quickly in most cases! > > > ### Task Your task is to prove him wrong. Write a full program that satisfies the following: 1. When compiled or interpreted, it produces an error message that, when compiled or interpreted in turn, also results in an error message. 2. Repeating step 1 over and over again will eventually encounter a fixed point, i.e., an error quine. ### Additional rules * The final error message must have a positive length. However, the previous error messages and the original source code may be empty. * The original source code's length may not exceed 1024 bytes. * Neither the original code or the code generated in any of the steps may produce non-error output. The output has to be clearly identifiable as an error message, which has to be generated by the compiler/interpreter due to a syntax error, runtime error, undefined reference, etc. * Your program may not receive any input or require any flags to produce the loop. * Your program may rely on a specific implementation of its language or version thereof. ### Scoring Your score is the **finite** number of steps your source code requires before producing an error quine. The submission with the highest score wins. The length of the original source code will be used as tie breaker. Shorter is better. ### Example In [Chicken](http://torso.me/chicken "Chicken chicken chicken: chicken chicken"), the program generates the following error message: ``` TypeError: Cannot read property 'NaN' of undefined ``` If this error message is, in turn, interpreted, it produces the error message ``` Error on line 1: expected 'chicken' ``` which, if interpreted in turn, produces itself. Thus, the score of the empty Chicken program is 2. ### Counterexample The PHP code ``` ab<?=c ``` generates the error message ``` PHP Parse error: syntax error, unexpected '?' in Command line code on line 1 ``` which produces itself when interpreted. However, the second source code prints the message to STDOUT, making this sequence invalid. [Answer] # Bash, 9223372036854775810 Inspired by Doorknob's answer. ``` a='"2>/dev/null;if(((i=$((i-1)))>0));then $(declare -p a);$a;else 1;fi #"' i=2**63 eval $a ``` It should be run with `bash < file.sh`, or use the same file name for each program, to get rid of the different file names in the error messages. The first few errors are (with `LANG=C`): ``` bash: line 3: 2>/dev/null;if(((i=9223372036854775807)>0));then declare -- a="\"2>/dev/null;if(((i=\$((i-1)))>0));then \$(declare -p a);\$a;else 1;fi #\"";"2>/dev/null;if(((i=$((i-1)))>0));then $(declare -p a);$a;else 1;fi #";else 1;fi #: No such file or directory ``` ``` bash: line 1: 2>/dev/null;if(((i=9223372036854775806)>0));then declare -- a="\"2>/dev/null;if(((i=\$((i-1)))>0));then \$(declare -p a);\$a;else 1;fi #\"";"2>/dev/null;if(((i=$((i-1)))>0));then $(declare -p a);$a;else 1;fi #";else 1;fi #: No such file or directory ``` ``` bash: line 1: 2>/dev/null;if(((i=9223372036854775805)>0));then declare -- a="\"2>/dev/null;if(((i=\$((i-1)))>0));then \$(declare -p a);\$a;else 1;fi #\"";"2>/dev/null;if(((i=$((i-1)))>0));then $(declare -p a);$a;else 1;fi #";else 1;fi #: No such file or directory ``` And finally: ``` bash: line 1: 2>/dev/null;if(((i=0)>0));then declare -- a="\"2>/dev/null;if(((i=\$((i-1)))>0));then \$(declare -p a);\$a;else 1;fi #\"";"2>/dev/null;if(((i=$((i-1)))>0));then $(declare -p a);$a;else 1;fi #";else 1;fi #: No such file or directory ``` ``` bash: line 1: 1: command not found ``` ``` bash: line 1: bash:: command not found ``` which is an error quine. [Answer] # [Pip 0.15.05.29](https://github.com/dloscutoff/pip/commit/063bf12392a59c64c129cfb973204b69a10f0b32), over 10100,000 *Technically not valid* because it requires the `-w` flag for warning output. That being said, Pip by design doesn't display any runtime errors unless they actually crash the program (infinite recursion, e.g.); the problems with this code are things that other languages would definitely complain about. ``` i:5**6**7d:"i:1d: Ssi?dRo--iRsRPda"Ssi?dRo--iRsRPda ``` The exact number of steps depends only on the value assigned to `i`, so it could be arbitrarily large (until the Python interpreter runs out of memory). Also, it would take longer than the age of the universe to complete the above sequence. (The question *did* specify "slow"!) **Explanation:** It took some combing through the interpreter before I found an error that would let me put arbitrary code into the warning message. After that, it was essentially modifying standard quine techniques. Example here uses an `i`-value of `5` for purposes of explanation. ``` i:5d:"i:1d: Ssi?dRo--iRsRPda"Ssi?dRo--iRsRPda ``` After setting `i`, store a string in `d` and then attempt to execute the `S`wap statement. Swap expects two variables (more accurately, lvalues). `s` is fine, but the second expression is `i?dRo--iRsRPda`. If `i` is true (nonzero, for our purposes), the ternary evaluates to `dRo--iRsRPd`, which uses `d` from earlier to form a near-quine--only with `i` decremented. This expression is not an lvalue, so Pip complains: ``` Attempting to swap non-lvalue i:4d:"i:1d: Ssi?dRo--iRsRPda"Ssi?dRo--iRsRPda ``` ... which then starts the whole thing over again. (`Attempting to swap non-lvalue` is a bunch of no-ops: `At` calculates the ASCII value of `t = 10`, `n-l` subtracts newline minus each value of an empty list, and all the lowercase letters are just variables.) The process continues in like fashion all the way down to: ``` Attempting to swap non-lvalue i:0d:"i:1d: Ssi?dRo--iRsRPda"Ssi?dRo--iRsRPda ``` When this is run, `i` is now false. The ternary expression evaluates to the else branch `a`--which is an lvalue. Thus, swap doesn't complain anymore. Instead, we get: ``` Referencing uninitialized variable a ``` And upon running this, at last, we have an actual syntax error: ``` R is not a unary operator Fatal error while parsing, execution aborted. ``` ... at which point, since the "program" starts with `R`, Pip will continue complaining that `R` is not a unary operator forever. --- The best solution that doesn't use `-w` is of length 3: ``` $~ While scanning, ignored unrecognized character: '~' Missing operator for $ meta-operator? Got None instead Fatal error while parsing, execution aborted. Missing operator for $ meta-operator? Got m instead Fatal error while parsing, execution aborted. M is not a unary operator Fatal error while parsing, execution aborted. ``` [Answer] # Julia, 3 A simple one just to get the ball rolling... Initial program: ``` inquisition ``` Error 1: ``` inquisition not defined ``` It may not be defined, but if it's *Spanish*, it's also unexpected. Nobody expects the Spanish Inquisition. Error 2: ``` syntax: extra token "not" after end of expression ``` Error 3: ``` syntax: extra token "token" after end of expression ``` The third error message, when submitted as a program, produces that same error, hence the score of 3. Work in progress! Surely I can do better than 3. [Answer] # R, 5 Initial program: ``` 1i*"5" ``` Error 1: ``` Error in (0+1i) * "5" : non-numeric argument to binary operator ``` Error 2: ``` Error: unexpected 'in' in "Error in" ``` Error 3: ``` Error: unexpected string constant in "Error 'in'" ``` Error 4: ``` Error: unexpected symbol in "Error: unexpected string" ``` Error 5 (Quine): ``` Error: unexpected symbol in "Error: unexpected symbol" ``` [Answer] # Bash, 3 ``` cp ``` Very rudimentary shell script to test it: ``` llama@llama:~$ s=$(bash -c 'cp' 2>&1); olds=asdf; while [ "$s" != "$olds" ]; do echo $s; echo '-----'; olds=$s; s=$(bash -c $s 2>&1); done cp: missing file operand Try 'cp --help' for more information. ----- bash: cp:: command not found bash: line 1: Try: command not found ----- bash: bash:: command not found bash: line 1: bash:: command not found ----- ``` [Answer] # Ruby, 5 ### Initial Program ``` q ``` ### 1 ``` undefined local variable or method `q' for #<Context:0x00000001045d70> (repl):1:in `initialize' ``` ### 2 ``` (repl):2: syntax error, unexpected tIDENTIFIER, expecting end-of-input (repl):1:in `initialize' ^ ``` ### 3 ``` (repl):1: syntax error, unexpected ':', expecting end-of-input (repl):2: syntax error, unexpected t... ^ ``` ### 4 ``` (repl):1: syntax error, unexpected ':', expecting end-of-input (repl):1: syntax error, unexpected ':', expecting end-of-input ^ ``` ### 5 (Quine) ``` (repl):1: syntax error, unexpected ':', expecting end-of-input (repl):1: syntax error, unexpected ':', expecting end-of-input ^ ``` [Answer] # Java, 5 These are very long... so I verified string equality using a Python script, **and** I generated this formatted post, so I wouldn't have to manually insert tabs on 400 lines. ### [Initial Program](http://repl.it/qR0) ``` class Main { public static void main(String[] args) { System.out.println("hello world"); }} } ``` ### 1 ``` Main.java:5: error: class, interface, or enum expected } ^ 1 error exit status 1 ``` ### 2 ``` Main.java:1: error: class, interface, or enum expected Main.java:5: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:1: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:3: error: illegal start of type ^ ^ Main.java:3: error: ';' expected ^ ^ Main.java:6: error: ';' expected exit status 1 ^ Main.java:6: error: <identifier> expected exit status 1 ^ Main.java:6: error: reached end of file while parsing exit status 1 ^ 10 errors exit status 1 ``` ### 3 ``` Main.java:1: error: class, interface, or enum expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:1: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: ';' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:2: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:2: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:3: error: illegal start of type ^ ^ Main.java:4: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: <identifier> expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: ';' expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: illegal start of type Main.java:1: error: <identifier> expected ^ Main.java:4: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:5: error: '(' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: ';' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:5: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:5: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:6: error: illegal start of type ^ ^ Main.java:7: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: <identifier> expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: ';' expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: illegal start of type Main.java:1: error: <identifier> expected ^ Main.java:7: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:8: error: '(' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: ';' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:8: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:8: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:9: error: illegal start of type ^ ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: <identifier> expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: ';' expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: illegal start of type Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: illegal start of type Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: <identifier> expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: unclosed character literal Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: ';' expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: unclosed character literal Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:11: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: ';' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:11: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:11: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:12: error: illegal start of type ^ ^ Main.java:12: error: <identifier> expected ^ ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: ';' expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: <identifier> expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: ';' expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: unclosed character literal (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: unclosed character literal (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:14: error: <identifier> expected Main.java:1: error: = expected ^ Main.java:14: error: ';' expected Main.java:1: error: = expected ^ Main.java:14: error: illegal start of type Main.java:1: error: = expected ^ Main.java:14: error: = expected Main.java:1: error: = expected ^ Main.java:14: error: illegal start of type Main.java:1: error: = expected ^ Main.java:15: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: illegal start of type Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: ';' expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:5: error: class, interface, or enum expected ^ Main.java:15: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:5: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:15: error: = expected Main.java:5: error: class, interface, or enum expected ^ Main.java:16: error: illegal start of type ^ ^ Main.java:17: error: = expected Main.java:3: error: illegal start of type ^ Main.java:17: error: <identifier> expected Main.java:3: error: illegal start of type ^ Main.java:17: error: ';' expected Main.java:3: error: illegal start of type ^ Main.java:17: error: illegal start of type Main.java:3: error: illegal start of type ^ Main.java:17: error: = expected Main.java:3: error: illegal start of type ^ 100 errors exit status 1 ``` ### 4 ``` Main.java:1: error: class, interface, or enum expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:1: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: ';' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:2: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:2: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:3: error: illegal start of type ^ ^ Main.java:4: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: <identifier> expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: ';' expected Main.java:1: error: <identifier> expected ^ Main.java:4: error: illegal start of type Main.java:1: error: <identifier> expected ^ Main.java:4: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:5: error: '(' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: ';' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:5: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:5: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:6: error: illegal start of type ^ ^ Main.java:7: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: <identifier> expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: ';' expected Main.java:1: error: <identifier> expected ^ Main.java:7: error: illegal start of type Main.java:1: error: <identifier> expected ^ Main.java:7: error: = expected Main.java:1: error: <identifier> expected ^ Main.java:8: error: '(' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: ';' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:8: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:8: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:9: error: illegal start of type ^ ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: <identifier> expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: ';' expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: illegal start of type Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: illegal start of type Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: <identifier> expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: unclosed character literal Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: ';' expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: unclosed character literal Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:10: error: = expected Main.java:1: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier ^ Main.java:11: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: ';' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:11: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:11: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:12: error: illegal start of type ^ ^ Main.java:12: error: <identifier> expected ^ ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: ';' expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: <identifier> expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: ';' expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: unclosed character literal (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: unclosed character literal (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:13: error: = expected (use -source 1.4 or lower to use 'enum' as an identifier) ^ Main.java:14: error: <identifier> expected Main.java:1: error: = expected ^ Main.java:14: error: ';' expected Main.java:1: error: = expected ^ Main.java:14: error: illegal start of type Main.java:1: error: = expected ^ Main.java:14: error: = expected Main.java:1: error: = expected ^ Main.java:14: error: illegal start of type Main.java:1: error: = expected ^ Main.java:15: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: illegal start of type Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: ';' expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: <identifier> expected Main.java:1: error: class, interface, or enum expected ^ Main.java:15: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier Main.java:1: error: class, interface, or enum expected ^ (use -source 1.4 or lower to use 'enum' as an identifier) Main.java:15: error: = expected Main.java:1: error: class, interface, or enum expected ^ Main.java:16: error: illegal start of type ^ ^ Main.java:17: error: = expected Main.java:2: error: <identifier> expected ^ Main.java:17: error: <identifier> expected Main.java:2: error: <identifier> expected ^ Main.java:17: error: ';' expected Main.java:2: error: <identifier> expected ^ Main.java:17: error: illegal start of type Main.java:2: error: <identifier> expected ^ Main.java:17: error: = expected Main.java:2: error: <identifier> expected ^ 100 errors exit status 1 ``` ### 5 (Quine) - Omitted because of post length. **Edit:** While the initial post used repl.it for an online interpreter, you may now use <https://ato.pxeger.com/> to avoid needing to create an account. The output will be different along the way, but it still reaches quine state in 5. [Answer] # Javascript, 3 error levels This isn't that 'cleaver' or anything, but I found it rather weird... **Error 0 (original):** ``` document.appendChild(HTMLAllCollection) ``` **Error 1:** ``` HierarchyRequestError ``` **Error 2:** ``` 'HierarchyRequestError' is not defined ``` **Error 3 (quine):** ``` Excepted character ';' ``` This was all returned on Internet Explorer 11.0.9600.17416, being the errors translated to English. --- **Printscreen:** ![Printscreen showing the console output](https://i.stack.imgur.com/Yl1MD.png) \* The error messages are shown in Portuguese and can be easily translated to English [Answer] ## [Vyxal](https://github.com/Vyxal/Vyxal) 3 Initial program ``` g ``` Error 1 ``` Traceback (most recent call last): File "/home/Vyxal/mysite/vyxal/main.py", line 195, in execute_vyxal exec(code, locals() | globals()) File "<string>", line 1, in <module> File "/home/Vyxal/mysite/vyxal/elements.py", line 3262, in monadic_minimum if len(lhs) == 0: TypeError: object of type 'Zero' has no len() ``` Error 2 ``` Traceback (most recent call last): File "/home/Vyxal/mysite/vyxal/main.py", line 195, in execute_vyxal exec(code, locals() | globals()) File "<string>", line 141 SyntaxError: 'continue' not properly in loop ``` Error 3 ``` Traceback (most recent call last): File "/home/Vyxal/mysite/vyxal/main.py", line 195, in execute_vyxal exec(code, locals() | globals()) File "<string>", line 144 SyntaxError: 'continue' not properly in loop ``` For some reason the debug error message for the first 2 errors doesn't start with a newline, so the error is in line 141, which becomes line 144 after the newline is added, which stabilizes. [Answer] # [K (ngn/k)](https://codeberg.org/ngn/k), 4 ``` f:{ ``` Error 1: ``` 'parse f:{ ^ ``` Error 2: ``` 'parse ^ ^ ``` Error 3: ``` 'value 'parse ^ ``` Error 4: ``` 'value 'value ^ ``` Which for some reason repeats itself. `{` also works with the same amount of attempts needed. [Answer] ## JavaScript (Google Chrome): 6 levels Interesting how no one realized that `eval` would work! I started out with this strange script: `throw "=eval('throw 1')"` The trick was to set the variable `Uncaught` (which is allowed), which is done to let it evaluate the rest of the code, throwing an error that will cause more errors. Finally, we predefine `eval` to shave off a few bytes for tiebreaking, and we make it even deeper. (This *can* be deeper, but this cost me too much of my insanity already!) So, here's the resulting code and errors: ``` e=eval;throw `=e('throw "=e(\\\\"throw \`=e(\\'throw 1\\')\`\\\\")"')` Uncaught =e('throw "=e(\\"throw `=e(\'throw 1\')`\\")"') Uncaught =e("throw `=e('throw 1')`") Uncaught =e('throw 1') Uncaught 1 Uncaught SyntaxError: Unexpected number Uncaught SyntaxError: Unexpected identifier 'SyntaxError' ``` Also, you can probably think of something simpler if the `Uncaught` part of the error message doesn't count (first line is code, rest is errors): ``` throw `throw "throw 'throw \\"throw \\\\'throw x\\\\'\\"'"` throw "throw 'throw \"throw \\'throw x\\'\"'" throw 'throw "throw \'throw x\'"' throw "throw 'throw x'" throw 'throw x' throw x ReferenceError: x is not defined SyntaxError: Unexpected identifier 'ReferenceError' SyntaxError: Unexpected identifier 'identifier' ``` Notice how `x` and `1` give the same amount of errors. I'm getting tired of the word `throw` now, so I guess I'll leave it to you to comment if you want to get this up to around 1024 bytes. [Answer] # [Go](https://go.dev), 4 errors ## Level 1 ``` package main func main() { println(a) } ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70oPX_BgqWlJWm6FjfVCxKTsxPTUxVyEzPzuNJK85LBLA1NhWqugqLMvJKcPI1ETa5aiHKoLphuAA) ## Level 2 ``` # command-line-arguments ../code.go:3:9: undefined: a ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70oPX_BgqWlJWm6FjdNlRWS83NzE_NSdHMy81J1E4vSS3NT80qKufT09JPzU1L10vOtjK0srRRK81JS04BKUqwUEiGaoWbAzAIA) ## Level 3 ``` ../code.go:1:1: illegal character U+0023 '#' ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70oPX_BgqWlJWm6Fjd19PT0k_NTUvXS860MgVAhMycnNT0xRyE5I7EoMbkktUghVNvAwMhYQV1ZHaIHqhVmBAA) ## Level 4 (loop) ``` ../code.go:1:1: expected 'package', found '.' ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m70oPX_BgqWlJWm6Fjd19fT0k_NTUvXS860MgVAhtaIgNbkkNUVBvSAxOTsxPVVdRyEtvzQPKKCnDtEE1QszAwA) Every Go program with a compile-time error will have a score of 4, because of the first error (level 2) starting with `#`, which is an illegal character in Go code outside of strings. Then, Go will complain about not finding the `package` keyword at the start of the file, which is required for all Go source files. [Answer] ## JS in Firefox 66.0; 3 error levels Input: `6?4;` Error #1 = Input #2: `missing : in conditional expression` Error #2 = Input #3: `expected expression, got keyword 'in'` Error #3 = Input #4 = Error #4: `unexpected token: identifier` This is the highest I got. ]
[Question] [ You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list. For example if the input is ``` 5 4 12 1 3 ``` the multiplications will be ``` 5*1=5 4*2=8 12*1=12 1*13=13 3*5=15 ``` and the output will be the increasing list ``` 5 8 12 13 15 ``` ## Input * A list of positive integers containing at least 1 element ## Output * A list of positive integers ## Examples ``` 9 => 9 1 2 => 1 2 2 1 => 2 3 7 3 => 7 9 1 1 1 1 => 1 2 3 4 5 4 12 1 3 => 5 8 12 13 15 3 3 3 8 16 => 3 6 9 16 32 6 5 4 3 2 1 => 6 10 12 15 16 17 9 4 6 6 5 78 12 88 => 9 12 18 24 25 78 84 88 8 9 41 5 12 3 5 6 => 8 9 41 45 48 51 55 60 15 8 12 47 22 15 4 66 72 15 3 4 => 15 16 24 47 66 75 76 132 144 150 153 156 ``` This is code golf so the shortest program or function wins. *Fun fact: the last element of the output for the input `N, N-1, ... ,1` seems to be the `(N+1)th` element of the sequence [A007952](http://oeis.org/A007952). If you find a proof, you are welcomed to include it in your golf answer or post it as a comment.* [Answer] ## [Jelly](https://github.com/DennisMitchell/jelly), ~~6~~ 5 [bytes](https://github.com/DennisMitchell/jelly/blob/master/docs/code-page.md) ``` :‘×µ\ ``` First Jelly answer ~~before @Dennis wakes up and beats me.~~ [Try it online!](http://jelly.tryitonline.net/#code=OuKAmMOXwrVc&input=&args=WzMsIDMsIDMsIDgsIDE2XQ) ### Explanation ``` : Integer division, m//n ‘ Increment, (m//n+1) × Multiply, (m//n+1)*n µ Turn the previous links into a new monadic chain \ Accumulate on the array ``` Thanks to @Dennis for -1 byte. [Answer] # JavaScript (ES6), 28 **Edit** As suggested by @Patrick Roberts, `p` can be a uninitialized parameter. Same byte count but avoid using a global variable ``` (a,p)=>a.map(n=>p=n*-~(p/n)) ``` **TEST** ``` f=(a,p)=>a.map(n=>p=n*-~(p/n)) console.log=x=>O.textContent+=x+'\n' ;[ [[9], [ 9]], [[1, 2], [ 1, 2]], [[2, 1], [ 2, 3]], [[7, 3], [ 7, 9]], [[1, 1, 1, 1], [ 1, 2, 3, 4]], [[5, 4, 12, 1, 3], [ 5, 8, 12, 13, 15]], [[3, 3, 3, 8, 16], [ 3, 6, 9, 16, 32]], [[6, 5, 4, 3, 2, 1], [ 6, 10, 12, 15, 16, 17]], [[9, 4, 6, 6, 5, 78, 12, 88], [ 9, 12, 18, 24, 25, 78, 84, 88]], [[8, 9, 41, 5, 12, 3, 5, 6], [ 8, 9, 41, 45, 48, 51, 55, 60]], [[15, 8, 12, 47, 22, 15, 4, 66, 72, 15, 3, 4], [ 15, 16, 24, 47, 66, 75, 76, 132, 144, 150, 153, 156]] ].forEach(t=>{ var i=t[0],k=t[1],r=f(i),ok=(k+'')==(r+'') console.log(i + ' => ' + r + (ok?' OK':'FAIL expecting '+x)) }) ``` ``` <pre id=O></pre> ``` [Answer] # Python 2, 67 64 bytes First try at code-golfing, so tips are appreciated. ``` def m(l): for x in range(1,len(l)):l[x]*=l[x-1]/l[x]+1 print l ``` [Answer] # PHP, ~~55~~ ~~46~~ ~~42~~ 41 bytes Uses ISO 8859-1 encoding. ``` for(;$a=$argv[++$i];)echo$l+=$a-$l%$a,~ß; ``` Run like this (`-d` added for aesthetics only): ``` php -d error_reporting=30709 -r 'for(;$a=$argv[++$i];)echo$l+=$a-$l%$a,~ß;' 10 10 8 ``` * Saved 1 byte thx to Ismael Miguel. * Saved 8 bytes by using modulo instead of floor * Saved 4 bytes thx to Ismael Miguel (for instead of foreach) * Saved a byte by using `~ß` to yield a space. [Answer] # Haskell (~~30~~ ~~28~~ 25 bytes) ``` scanl1(\x y->y*div x y+y) ``` ### Expanded version ``` f :: Integral n => [n] -> [n] f xs = scanl1 increaseOnDemand xs where increaseOnDemand :: Integral n => n -> n -> n increaseOnDemand acc next = next * (1 + acc `div` next) ``` ### Explanation `scanl1` enables you to fold a list and accumulate all intermediate values into another list. It's a specialization of `scanl`, which has the following type: ``` scanl :: (acc -> elem -> acc) -> acc -> [elem] -> [acc] scanl1 :: (elem -> elem -> elem) -> [elem] -> [elem] scanl1 f (x:xs) = scanl f x xs ``` Therefore, all we need is a suitable function that takes two the last element of our list (`acc` in the expanded version) and the one we wish to process (`next` in the expanded version) and return a suitable number. We can easily derive this number by dividing the accumulator through the next one and flooring the result. `div` takes care of that. Afterwards, we simply have to add `1` to ensure that the list is actually increasing (and that we don't end up with `0`). [Answer] # C++, ~~63~~ ~~60~~ 57 bytes ``` void s(int*f,int*e){for(int c=*f;++f!=e;c=*f+=c/ *f**f);} ``` Works inplace given a range `[first, last)`. Originally written as template variant, but that was longer: ``` template<class T>void s(T f,T e){for(auto c=*f;++f!=e;c=*f+=c/ *f**f);} ``` ### Extended version ``` template <class ForwardIterator> void sort(ForwardIterator first, ForwardIterator last){ auto previous = *first; for(++first; first != last; ++first){ auto & current = *first; current += current * (current / previous); previous = current; } } ``` [Answer] ## Mathematica, ~~36~~ 32 bytes ``` #2(Floor[#1/#2]+1)&~FoldList~#& ``` ## Test ``` #2(Floor[#1/#2]+1)&~FoldList~#& /@ {{5, 4, 12, 1, 3}, {15, 8, 12, 47, 22, 15, 4, 66, 72, 15, 3, 4}} (* {{5, 8, 12, 13, 15}, {15, 16, 24, 47, 66, 75, 76, 132, 144, 150, 153, 156}} *) ``` [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 12 bytes ``` {≤.;?%0∧}ᵐ<₁ ``` Weird enough trying to multiply each variable by a number will start at trying to multiply by 2 and not 0 or 1. This seems to work though and beats both other Brachylog implementations # Explanation ``` { }ᵐ -- Map each number ≤. -- to a number greater or equal to the original .;?%0 -- and a multiple of the original ∧ -- no more constraints <₁ -- so that the list is strictly increasing ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/v/pR5xI9a3tVg0cdy2sfbp1g86ip8f//aENTBQsFQyMFE3MFIyMFIM9EwcxMwRzMNFYwif0fBQA "Brachylog – Try It Online") [Answer] ## CJam, 13 bytes ``` q~{\_p1$/)*}* ``` Input as a CJam-style list. Output is linefeed separated. [Test it here.](http://cjam.aditsu.net/#code=q~%7B%5C_p1%24%2F)*%7D*&input=%5B15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204%5D) ### Explanation ``` q~ e# Read and evaluate input. { e# Fold this block over the list (i.e. "foreach except first")... \ e# Swap with previous value. _p e# Duplicate and print previous value. 1$ e# Copy current value. / e# Integer division. )* e# Increment and multiply current value by the result. }* ``` The final value is left on the stack and printed automatically at the end. [Answer] ## Perl, 17 + 3 = 20 bytes ``` $p=$_*=$==1+$p/$_ ``` Requires `-p` and `-l` flags: ``` $ perl -ple'$p=$_*=$==1+$p/$_' <<< $'15\n8\n12\n47\n22\n15\n4\n66\n72\n15\n3\n4' 15 16 24 47 66 75 76 132 144 150 153 156 ``` Explanation: ``` # '-p' reads each line into $_ and auto print # '-l' chomp off newline on input and also inserts a new line when printing # When assigning a number to `$=` it will automatic be truncated to an integer # * Added newlines for each assignment $p= $_*= $== 1+$p/$_ ``` [Answer] ## Python (3.5), ~~63~~ 62 bytes ``` def f(a): r=[0] for i in a:r+=i*(r[-1]//i+1), return r[1:] ``` ## Test ``` >>> print('\n'.join([str(i)+' => '+str(f(i)) for i in [[9],[1,2],[2,1],[7,3],[1,1,1,1],[5,4,12,1,3],[3,3,3,8,16],[6,5,4,3,2,1],[9,4,6,6,5,78,12,88],[8,9,41,5,12,3,5,6],[15,8,12,47,22,15,4,66,72,15,3,4]]])) [9] => [9] [1, 2] => [1, 2] [2, 1] => [2, 3] [7, 3] => [7, 9] [1, 1, 1, 1] => [1, 2, 3, 4] [5, 4, 12, 1, 3] => [5, 8, 12, 13, 15] [3, 3, 3, 8, 16] => [3, 6, 9, 16, 32] [6, 5, 4, 3, 2, 1] => [6, 10, 12, 15, 16, 17] [9, 4, 6, 6, 5, 78, 12, 88] => [9, 12, 18, 24, 25, 78, 84, 88] [8, 9, 41, 5, 12, 3, 5, 6] => [8, 9, 41, 45, 48, 51, 55, 60] [15, 8, 12, 47, 22, 15, 4, 66, 72, 15, 3, 4] => [15, 16, 24, 47, 66, 75, 76, 132, 144, 150, 153, 156] ``` ## Previous solution some recursive solutions but larger ``` (68 bytes) f=lambda a,i=0:[i,*f(a[1:],a[0]*(i//a[0]+1))][i==0:]if a!=[]else[i] (64 bytes) f=lambda a,i=0:a>[]and[i,*f(a[1:],a[0]*(i//a[0]+1))][i<1:]or[i] ``` [Answer] # [C (gcc)](https://gcc.gnu.org/), 37 bytes ``` o(int*_){for(;*++_;)*_*=_[~0]/ *_+1;} ``` [Try it online!](https://tio.run/##bVDLasMwEDw3X2EMBUneUst6WEGkxfmCHHJLgykuKTnULml6Ms6vuyspbu24GIR3dmZ3dqqH96rq@4Yc6zMraXtoTsSyJCktZSVblbtLun@MWJlw2/UbzyoC6/OExYHEbUwtKywd6vs3iIEVSULtAHUvNZK6xTbowb1r2g7tKIqwvSEFtY17Bvzy9IsP0Oo5QGuEvs9fJPZzP16PNaHt4m5L3IbdnrZLSDsYF9SO2xyyMSGUU0oGfEzJQMwoucfgr/xvUfhulgmQM6pCjLutk6EKjEcFcDWTCHAfEvRYIkCjE8TE/CoNbo2Am@s08NSvUU7H85luiSoNTp17P8ZMA3ZaA5mEzDOMDIzpEIO2JMcZ3CWgYOL62pToz4BCFvbTeZ7XPGQOmbeLtjTk/jeECiMq3oKWkOs4aAxPw0y4xKAV3qtcqDrs6Pof "C (gcc) – Try It Online") [Answer] # TI-Basic, ~~43~~ ~~40~~ 37 bytes ``` Prompt A For(I,1,dim(ʟA ʟA(I)(1+int(Ans/ʟA(I→ʟA(I End ʟA ``` -6 bytes thanks to [MarcMush](https://codegolf.stackexchange.com/users/98541/marcmush). [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 54 bytes ``` :_{h_.|[L:T],LhH,(T_,IH;0:$Ie*H=:T>I),Lb:I:1&:[I]rc.}. ``` ### Explanation ``` :_{...}. § Call sub-predicate 1 with [Input, []] as input. Unify its output § with the output of the main predicate § Sub-predicate 1 h_. § If the first element of the input is an empty list, unify the § output with the empty list | § Else [L:T],LhH, § Input = [L,T], first element of L is H (T_,IH § If T is the empty list, I = H ; § Else 0:$Ie*H=:T>I), § Enumerate integers between 0 and +inf, stop and unify the § enumerated integer with I only if I*H > T Lb:I:1& § Call sub-predicate 1 with input [L minus its first element, I] :[I]rc. § Unify the output of the sub-predicate with § [I|Output of the recursive call] ``` [Answer] # Pyth, 11 ``` t.u*Yh/NYQ0 ``` [Test Suite](http://pyth.herokuapp.com/?code=t.u%2AYh%2FNYQ0&input=%5B5%2C%204%2C%2012%2C%201%2C%203%5D&test_suite=1&test_suite_input=%5B9%5D%0A%5B1%2C%202%5D%0A%5B2%2C%201%5D%0A%5B7%2C%203%5D%0A%5B1%2C%201%2C%201%2C%201%5D%0A%5B5%2C%204%2C%2012%2C%201%2C%203%5D%0A%5B3%2C%203%2C%203%2C%208%2C%2016%5D%0A%5B6%2C%205%2C%204%2C%203%2C%202%2C%201%5D%0A%5B9%2C%204%2C%206%2C%206%2C%205%2C%2078%2C%2012%2C%2088%5D%0A%5B8%2C%209%2C%2041%2C%205%2C%2012%2C%203%2C%205%2C%206%5D%0A%5B15%2C%208%2C%2012%2C%2047%2C%2022%2C%2015%2C%204%2C%2066%2C%2072%2C%2015%2C%203%2C%204%5D&debug=0) Does a cumulative reduce, a reduce that returns all intermediate values, starting with `0`. Since the input is guaranteed to contain only positive integers, this is ok. In each step, we take the old value, divide it by the new value and add `1`, then we multiply by the new value. [Answer] # C, 79 bytes ``` p;main(x,v)char**v;{for(;*++v;printf("%d ",p=((x+p-1)/x+!(p%x))*x))x=atoi(*v);} ``` ## Ungolfed ``` p; /* previous value */ main(x,v) char**v; { /* While arguments, print out x such that x[i] > x[i-1] */ for(;*++v; printf("%d ", p = ((x+p-1)/x + !(p%x)) * x)) x = atoi(*v); } ``` [Answer] ## PowerShell, 26 bytes ``` $args[0]|%{($l+=$_-$l%$_)} ``` Takes input as an explicit array, e.g., `> .\sort-by-multiplying.ps1 @(6,5,4,3,2,1)` via `$args[0]`. We then for-loop over that with `|%{...}` and each iteration perform *magic*. Nah, just kidding, we use the same modulo trick as other answers (props to @aross because I spotted it [there](https://codegolf.stackexchange.com/a/71553/42963) first). The encapsulating parens `(...)` ensure that the result of the math operation is placed on the pipeline, and thus output. If we left those off, nothing would be output since the `$l` variable is garbage-collected after execution finishes. ### Example ``` PS C:\Tools\Scripts\golfing> .\sort-by-multiplying.ps1 @(8,9,1,5,4) 8 9 10 15 16 ``` [Answer] # [Julia 1.0](http://julialang.org/), 27 bytes ``` !L=(x=0;L.|>i->x=(x÷i+1)i) ``` [Try it online!](https://tio.run/##PU9LboMwFNz7FBMWEagU4S@mFey6qJRLkIZIrhBFhEoseq8eoAejz4@0tmSP38zzzHv/HEIn1207nJp0bcrnU/HVhsd2pdfPd3iQWci268eMgDBi7rvLEMb@lmYCtLr8jAa3aQhLkfKVhhxJ0yZZtv8zdfOtL9LXccnD3jNTx6FjOM1hXIYx7dC0mP/oQ4Mzjsd/NnlZp/5t6S9PSHKcM9GPl62OLbWQUBHQJRSdBBW0qKAjrFiw711EdSMsDGRUs8jC80tDWqERNxVcpDQc6oi1Eg6xTePu4iBLbrORl5WoiXWIqor/854DssZDGShmvCFGeCKMJK2MiSzY7V405ONhiaV6KeQ9n6mg2I5sHCqGNAzPxRnIgjSRIyOKpEliaFBLOW0czv0C "Julia 1.0 – Try It Online") [Answer] # [Factor](https://factorcode.org), 35 bytes ``` [ 0 [ tuck /i 1 + * ] accumulate* ] ``` [Attempt This Online!](https://ato.pxeger.com/run?1=VY3NDsFAFIUjsepTnMSO-JkO7eABxMZGrMRiMhkhtKpmFiJ9EptueCeexu2UYu7innPPlzPX-1oqc0jzZ62-mE9nkxF2Oo31HpE0G5z00epY6ROSVBtzTtJtbDD2vIsHehcMkb0Vg19pn9xHh-A_TDkfP0AfrIC_CHcjwILqFDiO_7UO6RK4JBRFhRBVJIqQUUJnTutbxAZwcD-E7xeOOgKETnIymZfdrFm3xaOxRA9LGKt26G7p3xaaWEEqZSO7l0aTK9FbJBN0Sp3n5X4B) [Answer] # [PARI/GP](https://pari.math.u-bordeaux.fr), 25 bytes ``` a->i=0;[i=c*(i\c+1)|c<-a] ``` [Attempt This Online!](https://ato.pxeger.com/run?1=LY9BCsIwEEWvErpqdAKmaZMUbS9Sg4RCJSASSl0I3sRNQcQzuPMa3saZRgby_7yfH8j9Ff0YDsc4PwbWPC_TIOzbizY0m20Xmn6Vh32_lvzW74R3Kf9-fIyna-6ZaFkcw3lCm9GSsSH3nAPrutrhKaEgKUCSGFAJLkO2ghIkpilQQGNBato0UKrgX65x0UDQWOpYS9QCcokQiUJZmrKC5UppoMA2PaM1mMUqKJ3j6R_znPQH) [Answer] # [Desmos](https://desmos.com/calculator), 78 bytes ``` n->min(n,i.length)+1,o->join(o,i[n]floor(o[n-1]/i[n]+1)) i=\ans_0 n=2 o=[i[1]] ``` [Try It On Desmos!](https://www.desmos.com/calculator/bozvnxcqyl) [Try It On Desmos! - Prettified](https://www.desmos.com/calculator/z0abv2uhes) [Answer] # [Rust](https://www.rust-lang.org/), 59 bytes ``` |mut l:Vec<u8>|{for i in 1..l.len(){l[i]*=l[i-1]/l[i]+1};l} ``` [Try it online!](https://tio.run/##fc5LCoMwEADQvaeIrrSdWuInplrbW3QjLopECMS02FgEzdnTxH1lYD7wZphx@ijTSzQ8uQyjxRNMobk26zApJMoH664Tva1L/xoRR1wiHMciFsxZ0fD2UNt8wu3ZDUesK6FN5b1HLpWQfhgs5V0HMIdf1vlNDhngBDCkbRT9VReriI0cCuo4pXuagvXYYitTW8gexjlsJ7MCEvuH@4cQKLY2hWxb1eYH "Rust – Try It Online") I am still learning rust, but I am sure there is a better solution using `iter()`. Also I am using `u8` because the examples don't have output value greater than 512. [Answer] # [Uiua](https://uiua.org), 9 [bytes](https://www.uiua.org/pad?src=U0JDUyDihpAgK0BcMOKKlwpEZWNvZGUg4oaQIOKHjOKKjy0x4pa9wrEu4o2Y4ouv4oav4oqCwq8x4qe74ouv4qe7LOKHjOKItSjihpjCrzHii68rMjU2KSAtQFwwKzEKJnAg4oqCIjggYml0IGVuY29kaW5nOlx0IiBTQkNTICLih4ziio8tMeKWvcKxLuKNmOKLr-KGr-KKgsKvMeKnu-KLr-Knuyzih4ziiLUo4oaYwq8x4ouvKzI1NikiIOKKgitAXDDih6ExMjkiLiziiLY74oiYwqzCscKv4oy14oia4peL4oyK4oyI4oGFPeKJoDziiaQ-4omlKy3Dl8O34pe_4oG_4oKZ4oan4oal4oig4qe74paz4oeh4oqi4oeM4pmt4ouv4o2J4o2P4o2W4oqa4oqb4oqd4pah4oqU4omF4oqf4oqC4oqP4oqh4oav4oaZ4oaY4oa74per4pa94oyV4oiK4oqXL-KIp1xc4oi14omh4oi64oqe4oqg4o2l4oqV4oqc4oip4oqT4oqD4oqZ4ouF4o2Y4o2c4o2a4qyaJz_ijaPijaQh4o6L4oas4pqCzrfPgM-E4oiefl9bXXt9KCnCr0AkXCLihpB8IyIKJnAg4oqCImRlY29kZWQ6XHQiIERlY29kZSAiwqPCsS0xwrjChy7DjMKlwrPCsMKIMcKfwqXCnyzCo8K_KMK1wogxwqUrMjU2KSIg4oqCK0BcMOKHoTEyOSIuLOKItjviiJjCrMKxwq_ijLXiiJril4vijIrijIjigYU94omgPOKJpD7iiaUrLcOXw7fil7_igb_igpnihqfihqXiiKDip7vilrPih6HiiqLih4zima3ii6_ijYnijY_ijZbiipriipviip3ilqHiipTiiYXiip_iioLiio_iiqHihq_ihpnihpjihrvil6vilr3ijJXiiIriipcv4oinXFziiLXiiaHiiLriip7iiqDijaXiipXiipziiKniipPiioPiipnii4XijZjijZzijZrirJonP-KNo-KNpCHijovihqzimoLOt8-Az4TiiJ5-X1tde30oKcKvQCRcIuKGkHwjIg==) ``` \(×+1⌊÷,) ``` [Try it!](https://uiua.org/pad?src=ZiDihpAgXCjDlysx4oyKw7csKQoKZiBbOV0KZiBbMSAyXQpmIFsyIDFdCmYgWzEgMSAxIDFdCmYgWzUgNCAxMiAxIDNd) ``` \(×+1⌊÷,) \( ) # scan by , # over ÷ # divide ⌊ # floor +1 # increment × # multiply ``` [Answer] # [Uiua](https://www.uiua.org/), 8 bytes ``` \(-⊃◿+∶) ``` [Try it online!](https://www.uiua.org/pad?src=ZiDihpAgXCgt4oqD4pe_K-KItikKCmYgWzldCmYgWzEgMl0KZiBbMiAxXQpmIFsxIDEgMSAxXQpmIFs1IDQgMTIgMSAzXQ==) Given the previous value `x` and the next value `y`, the transformed `y` is the same as `(x+y) - (x+y)%y == (x+y) - x%y`. ``` \(-⊃◿+∶) input: a vector of positive integers \( ) scan by: (input: [x y]) : swap [y x] ⊃◿+ fork (mod, add) [x%y x+y] - subtract [x+y-x%y] ``` [Answer] # Japt, 11 bytes ``` Uå@Y*-~(X/Y ``` [Test it online!](http://ethproductions.github.io/japt?v=master&code=VeVAWSotfihYL1k=&input=WzUgNCAxMiAxIDNd) ### How it works ``` // Implicit: U = input array of integers Uå@ // Cumulative reduce: map each previous value X and current value Y to: -~(X/Y // floor(X/Y+1). // Implicit: output last expression ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes Code: ``` R`[=sŽDŠ/ò* ``` [Try it online!](http://05ab1e.tryitonline.net/#code=UmBbPXPFvUTFoC_Dsio&input=WzIsIDMsIDMsIDIsIDQsIDVd) Explanation: ``` R # Reverse input ` # Flatten the list [ # While loop = # Print the last item s # Swap the last two items Ž # If the stack is empty, break D # Duplicate top of the stack Š # Pop a,b,c and push c,a,b / # Divide a / b ò # Inclusive round up * # Multiply the last two items ``` Uses CP-1252 encoding. [Answer] ## [Minkolang 0.15](https://github.com/elendiastarman/Minkolang), 17 bytes ``` nd1+?.z0c:1+*d$zN ``` [Try it here!](http://play.starmaninnovations.com/minkolang/?code=nd1%2B%3F%2Edz%24r%3A1%2B*d%24zN&input=15%208%2012%2047%2022%2015%204%2066%2072%2015%203%204) ### Explanation ``` nd Take number from input and duplicate it 1+ Add 1 ?. Stop if top of stack is 0 (i.e., when n => -1 because input is empty). z Push value from register 0c Copy first item on stack : Pop b,a and push a//b 1+ Add 1 * Multiply d$z Duplicate and store in register N Output as number ``` Essentially, the register keeps the latest member of the ascending list and this is divided by the input and incremented to get the multiplier for the next member. The toroidal feature of Minkolang's code field means that it loops horizontally without the need for `()` or `[]` loops. [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 21 bytes ``` l~lCℕ₁ᵐ≤ᵛ~+?&;Cz≜×ᵐ<₁ ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/P6cux/lRy9RHTY0Pt0541Lnk4dbZddr2atbOVY865xyeDhS0Acr9/x9tqmCiYGikYKhgHPs/CgA "Brachylog – Try It Online") Uses the sum of input values as [the upper bound](https://math.stackexchange.com/a/2873481/85653) for coefficients C. Pretty slow, times out on TIO for input list lengths beyond 5 or 6 (also depending on the sum of the values). But not as slow as my original version, which requires tiny lists of upto 3 elements, with tiny values, to not time out: ### 21 bytes ``` l~l.&+^₂⟦₁⊇.;?z/ᵐℕ₁ᵐ∧ ``` [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/P6cuR09NO@5RU9Oj@cseNTU@6mrXs7av0n@4dcKjlqlAARCjY/n//9HGOgpAZKijYBT7PwoA "Brachylog – Try It Online") [Answer] # [Python 2](https://docs.python.org/2/), 53 bytes ``` lambda a:reduce(lambda b,v:b+[b[-1]/v*v+v],a,[0])[1:] ``` [Try it online!](https://tio.run/##LYzBDoIwEETP@hW9ATJGS6GUJvgjtQdQiE0UCEESvx631WyyO/N2Z6fP8hiHbOvr6/ZsXu29YY2eu/v71sV/32LVbWpac@T2tB7WdLVoYM42MVzbrR9n5pgbmDGVheHIqGfg1EuIQEKRKpCD0ypgAV8KXJKR8DuBX64iLeFZqXxAKYIKhDkxAoKGj/EC4SAvkVHU/5ASZZACubV6v5tmNyzMIaovEfrYJdsX "Python 2 – Try It Online") `k*x>y` implies `k>y/x`; so the smallest `k` can be is `k=floor(y/x)+1`. Since in Python 2.7, integer division is already taken as `floor`, we want `k=y/x+1`, and `k*x = (y/x+1)*x = y/x*x+x`. [Answer] # [K (oK)](https://github.com/JohnEarnest/ok), 11 bytes ``` {y*1+_x%y}\ ``` [Try it online!](https://tio.run/##HYs7DsMwDEOvwqXoDxlkObJSXSVAtiwZujYoenaXMjiIfCKP6X30vr@@50Oe2@dy/ta@43pbQlCiQKJB6YdiRoUQEilSDrEwJFdke6EzJGmeVfdwEAoJo/JYyIzxrA2Fo1yboQ2rqPf@Bw "K (oK) – Try It Online") ]
[Question] [ ### Background Summer is well over in the Northern Hemisphere, and a lot of us miss the sun, the beaches, the waves of the ocean... This challenge aims at cheering them up by reminding them of the sea. ### The challenge Here is the sea : ``` ** ** ** ** ** **** **** **** **** **** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ****** ****** ****** ****** **** ``` The sea is made of 5 times this wave pattern : ``` ** **** ***** ** ** ** ** * ***** ``` Note that the pattern is 16 characters long, and the sea is 5 times this pattern = 80 characters long. Which you can print into a terminal using this command-line : ``` perl -e 'print " ** \n **** \n ***** \n ** ** \n ** ** \n* *****\n"' ``` Or this one : ``` perl -e 'print " "x12, "*"x2, " "x2, "\n", " "x8, "*"x4, " "x4, "\n", " "x5, "*"x5, " "x6, "\n", " "x3, "*"x2, " "x3, "*"x2, " "x6, "\n", " "x1, "*"x2, " "x6, "*"x2, " "x5, "\n", "*"x1, " "x10, "*"x5, "\n"' ``` (The second one should make it easier for you to get the exact pattern) Your task is to display the sea in a terminal, and make look like the waves are moving toward the right : it needs to shift to the right at a speed of 1 character each 100ms (= 10 times each seconds). No character should be printed after the 80th column, but as the rightmost wave disappears, a new one appears on the left. Here is an example of output : time = 0.0s ``` ** ** ** ** ** **** **** **** **** **** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ****** ****** ****** ****** **** ``` time = 0.1s ``` ** ** ** ** ** **** **** **** **** **** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *** ****** ****** ****** ****** *** ``` time = 0.2s ``` * ** ** ** ** * **** **** **** **** **** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **** ****** ****** ****** ****** ** ``` time = 0.3s ``` ** ** ** ** ** **** **** **** **** **** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ***** ****** ****** ****** ****** * ``` time = 0.4s ``` ** ** ** ** ** * **** **** **** **** *** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ****** ****** ****** ****** ****** ``` Of course, each output should replace the previous one. You can run this code into a unix terminal to see how it should look with the animation: ``` perl -M5.010 -MTime::HiRes=sleep -E '@arr=([($")x12,($n="*")x2,($")x3],[($")x8,($n)x4,($")x4],[($")x5,($n)x5,($")x6],[($")x3,($n)x2,($")x3,($n)x2,($")x6],[($")x1,($n)x2,($")x6,($n)x2,($")x5],[($n)x1,($")x10,($n)x5]);while(++$j){for$i(0..5){for$k(0..15) {$out[$i][16*$_+$k]=$arr[$i][($k-$j)%16]for 0..4}}say"\e[H",$/,join$/,map{join"",@$_}@out;sleep 0.1}' ``` (Note that this code isn't very well golfed: I just made it compact enough to be convenient to run in a terminal.) ### Winning criterion This is codegolf, so shortest code in byte wins. [Answer] # [MATL](https://github.com/lmendo/MATL), ~~41~~ 40 bytes ``` `'3SJp/B@Tc`@+ara'F'* 'Za6el&Xx80:@-Z)DT ``` Example run: [![enter image description here](https://i.stack.imgur.com/UsuKU.gif)](https://i.stack.imgur.com/UsuKU.gif) Or try it at [**MATL Online!**](https://matl.io/?code=%60%273SJp%2FB%40Tc%60%40%2Bara%27F%27%2a+%27Za6el%26Xx80%3A%40-Z%29DT&inputs=&version=19.6.0) (the actual speed may depend on server load). ### How it works ``` ` % Do...while '3SJp/B@Tc`@+ara' % Compressed string (actually it's just a change of base) F % Push false. Indicates base-95 input alphabet for decompression '* ' % Push this string, which defines output alphabet Za % Base conversion. This decompresses the string 6e % Reshape as a 6-row char array. This gives the basic pattern l&Xx % Pause 0.1 seconds and clear screen 80: % Push array [1 2 ... 80] @- % Subtract iteration index to each element of that array. This % will produce the rotation via modular indexing Z) % Use as column index. Indexing is modular, so this repeats % (and rotates) the pattern D % Display T % True. Loop condition for infinite loop % Implicit end ``` [Answer] ## JavaScript (ES6) + HTML, ~~151~~ 143 + 10 = ~~161~~ 153 bytes ``` a=[48,15,57347,6147,1542,504];setInterval("a=a.map(n=>{for(x=-1;++x<80;)s+=' *'[n>>x%16&1];s+=`\n`;return n>>>15|n<<1},s='');O.innerHTML=s",99) ``` ``` <pre id=O> ``` [Answer] # HTML + CSS, 70 + ~~181~~ 175 = 245 bytes Makes use of `text-shadow`, `rtl` text and CSS keyframe animations. ``` a{display:flex;overflow:hidden;width:80ch}pre{text-shadow:16ch 0,32ch 0,48ch 0,64ch 0,80ch 0;direction:rtl;animation:w steps(16)1.6s infinite}@keyframes w{0%{margin-left:-16ch ``` ``` <a><pre>** **** ***** ** ** ** ** *** *** ``` [Answer] # C# 450 444 425 417 Bytes *399 without `using System.Linq;` but I'm sure that would be cheating...* *Edit: Saved 25 Bytes thanks to @Cyoce* Golfed: ``` void S(){Func<string,string>r=a=>string.Concat(Enumerable.Repeat(a,5));Func<string,int,string>s=(b,i)=>(b.Substring(16-i)+b).Substring(0,80);int p=0;for(;;){Console.Clear();Console.WriteLine(string.Join("\r\n",new string[]{s(r(" ** "),p),s(r(" **** "),p),s(r(" ***** "),p),s(r(" ** ** "),p),s(r("* *****"),p),}));Thread.Sleep(100);p++;if(p==16)p=0;}} ``` Ungolfed: ``` public void S() { Func<string, string> r = a => string.Concat(Enumerable.Repeat(a, 5)); Func<string, int, string> s = (b, i) => (b.Substring(16 - i) + b).Substring(0, 80); int p = 0; for(;;) { Console.Clear(); Console.WriteLine( string.Join("\r\n", new string[] { s(r(" ** "), p), s(r(" **** "), p), s(r(" ***** "), p), s(r(" ** ** "), p), s(r("* *****"), p),}) ); Thread.Sleep(100); p++; if (p == 16) p = 0; } } ``` [![enter image description here](https://i.stack.imgur.com/KwcSU.gif)](https://i.stack.imgur.com/KwcSU.gif) [Answer] # V, ~~98~~ ~~97~~ 73 bytes *Thanks to @nmjcman101 for saving 24 bytes!* ``` i¹ ³ ** ¸ ´*´ µ µ*¶ ³ **³ **¶ **¶ **µ *± µ*<ESC>{<C-v>}y4pò:sl100m $<C-v>}x|Pò ``` This contains a lot of unprintables, so here's an xxd hexdump: ``` 0000000: 69c2 b920 c2b3 202a 2a20 200a c2b8 20c2 i.. .. ** ... . 0000010: b42a c2b4 200a c2b5 20c2 b52a c2b6 200a .*.. ... ..*.. . 0000020: c2b3 202a 2ac2 b320 2a2a c2b6 200a 202a .. **.. **.. . * 0000030: 2ac2 b620 2a2a c2b5 200a 2ac2 b120 c2b5 *.. **.. .*.. .. 0000040: 2a1b 7b16 7d79 3470 c3b2 3a73 6c31 3030 *.{.}y4p..:sl100 0000050: 6d0a 2416 7d78 7c50 c3b2 0a m.$.}x|P... ``` ### Edit 1. Used `y$` instead of `<C-v>$y` 2. A lot of changes * Instead of copying each line and pasting them 4 times, I first generate the wave and then copy the whole thing and paste it 4 times * Used `{` and `}` to save few bytes * Used `ò` instead of registers to create the infinite loop (for some reason I have to include a `ò` at the end for it to work) * fixed the static `*` at the bottom ### Mini-Explanation I'm using `<alt-n>` to create copies of strings. For example, `<alt-5>*` (this looks like `µ5`) makes `5` copies of `*` in insert mode. This I found to be shorter than copying the string and using a regex to do the necessary replacements. After creating one wave, I paste it to create the other waves. Finally, I loop recursively using `ò` to create the infinite loop (with a delay of `100ms`). ### Gif Most of the code is dedicated towards creating the wave, so I'm still trying to golf this. Note that this code will not work on TIO since TIO only outputs the output after the code has finished execution. So here's a gif (sorry for the low quality, I had to use a website to convert a `.mov` to a `.gif`, also the `>_` that keeps popping up in the right is the Terminal icon on my mac's dock): [![wave gif](https://i.stack.imgur.com/7hpDc.gif)](https://i.stack.imgur.com/7hpDc.gif) [Answer] ## Batch, 424 bytes ``` @echo off set f= set a=%f%%f% ** set b=%f% **** set c=%f%***** %f% set d= ** ** %f% set e= **%f% **%f% set f=*%f%%f%***** set a=%a%%a%%a%%a%%a%%b%%b%%b%%b%%b%%c%%c%%c%%c%%c%%d%%d%%d%%d%%d%%e%%e%%e%%e%%e%%f%%f%%f%%f%%f% :l cls echo %a% set a=%a:~79,1%%a:~0,79%%a:~159,1%%a:~80,79%%a:~249,1%%a:~160,79%%a:~319,1%%a:~240,79%%a:~399,1%%a:~320,79%%a:~-1%%a:~-80,79% ping>nul 1.1 -n 1 -w 100 goto l ``` Some lines have trailing spaces. Requires a standard 80-column terminal. The timing isn't very accurate, but it's the best you can do in Batch. [Answer] # Racket 395 374 373 367 364 351 bytes Uses an external library for screen clearing Edit: Saved 21 bytes by not defining `w` and inlining the function. Edit2: Saved 1 byte by removing a space. Edit3: Saved 6 bytes by renaming `loop` to `p`, thanks @rnso! Edit4: Putting substring in the let saving 3 bytes. Edit5: Remove `#lang racket`, which isn't needed in the interpreter. Golfed: 351 bytes ``` [require[planet neil/charterm:3:0]][let p([n 1])[with-charterm[void[charterm-clear-screen]]][for([i'[" ** "" **** "" ***** "" ** ** "" ** ** ""* *****"]])[let([g substring][x[string-join[make-list 5 i]""]])[displayln[string-append[g x[- 16 n]][g x 0[- 16 n]]]]]][sleep .1][p[modulo[+ n 1]16]]] ``` Scrolling (no clear): 272 bytes ``` [let p([n 1])[for([i'[" ** "" **** "" ***** "" ** ** "" ** ** ""* *****"]])[let([g substring][x[string-join[make-list 5 i]""]])[displayln[string-append[g x[- 16 n]][g x 0[- 16 n]]]]]][sleep .1][p[modulo[+ n 1]16]]] ``` Ungolfed: ``` #lang racket [require [planet neil/charterm:3:0]] [define w '[ " ** " " **** " " ***** " " ** ** " " ** ** " "* *****"]] [define (rotmul count) [for ([i w]) [let ([x [string-join [make-list 5 i] ""]]) [displayln [string-append [substring x count] [substring x 0 count]]]]]] [let loop ([n 1]) [with-charterm [void [charterm-clear-screen]]] [rotmul [- 16 n]] [sleep .1] [loop [modulo [+ n 1] 16]]] ``` [![Waves](https://i.stack.imgur.com/7tHQP.gif)](https://i.stack.imgur.com/7tHQP.gif) [Answer] # PowerShell 3.0, ~~183~~ ~~182~~ 173 bytes Requires PS 3.0 for binary shift operators. Slimmed to 173 bytes with [AdmBorkBork](https://codegolf.stackexchange.com/users/42963/admborkbork)'s help! ``` $w=12,240,1984,6336,24672,32799 for(){0..5|%{'{0:D16}'-f+[Convert]::ToString(([uint16]$o=$w[$_]),2)*5-replace0,' '-replace1,'*' $w[$_]=$o-shr1-bor$o-shl15} sleep -m 100 cls} ``` [![PoshWaves](https://i.stack.imgur.com/e0ft3.gif)](https://i.stack.imgur.com/e0ft3.gif) [Answer] # Bash+coreutils, 172 148 bytes *24 bytes saved thanks to [@zeppelin](https://codegolf.stackexchange.com/users/61904/zeppelin), many thanks* ``` while : do clear cut -c$[i=i%16+1]-$[79+i] <(base64 -d<<<4AJFACddABVgf2dnw+CvmeyOkhIoUJOPLK6oKkljh0+Peqi5BfrbbnDyuVkr+AA==|xz -qdFraw) sleep .1 done ``` The first line decompresses the following pattern made of 6 consecutive waves: ``` ** ** ** ** ** ** **** **** **** **** **** **** ***** ***** ***** ***** ***** ***** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ***** ****** ****** ****** ****** ****** * ``` Then, the loop slides an 80-bytes-wide window through that pattern. [Answer] # [\*><>](http://esolangs.org/wiki/Starfish), ~~251~~ ~~250~~ 251 bytes (non-competing) ``` " ** "e1C0[" **** "e1C0[" ***** "e1C0[" ** ** "e1C0[" ** ** "e1C0["**** **"e1C0[06. 52Cl2,[52C52C]R <v0&:l $>:@=?v1+{:}&l1-[:&$@ ?!v]1->: ~R> vDDDDDD"H;0["ooooo >l?u1S06.O{52Cl2,[a}48C]I ol?!R ``` Note: `"H;0["` is supposed to have ascii `27` after `[`. [Try it here!](https://portal.thedisco.zone/starfish/?script=EQAgVGJdPcCmBGAwgBgNqihCsYJQy2h11gLU1jPEjiUuNrzIqNLxgjfVQDYAdACgArACZkAGzEAadOOQKAugCUhAHgBuqAGQAuSUIAkAPj0ABALwB+TYgDUAbz0BfHZMQBadHp1HzQtYAhJpKXmZCAH4qJkKaACKJSQAmAPZCJpLWAK6IAMr8AgDyjgrScgCGLgAsABzISgCSQqlZQSpAA) (set delay to 0ms) I can't believe I ended up sucessfully making this. This uses the `I` and `D` instructions, which increments or decrements the selected stack. This is demonstrates that it's probably possible to do this in pure ><> (minus the sleep) or a competetive \*><> answer, though probably a lot harder to do. The online interpreter version is different simply to clear the output using a carriage return. This is non-competing because the `I`, `D`, `C`, and `R` instructions are younger than the challenge. This is probably possible to do without those instructions, but it'd be very hard/long. Edit: I actually managed to remove a byte, but I also noticed I measured the size wrong, so I actually gained a byte. --- I'll do my best to break down the steps and explain what's happening here... # Explanation ``` " ** "e2C0[" **** "e2C0[" ***** "e2C0[" ** ** "e2C0[" ** ** "e2C0["**** **"e2C0[09. # Copy current stack 4 times 54Cl2,[54C54C]R # Copy stack <v0&:l $>:@=?v1+{:}&l1-[:&$@ ?!v]1->: ~R> # Main loop vDDDDDD"H;0["ooooo >l?u1S09.O{54Cl2,[a}4cC]I # Output stack ol?!R ``` ## Table of Contents ``` Line 1 - Initialization e2C - Call "copy current stack 4 times" 54C - Call "copy stack" 09. - Jump to "main loop" 4cC - Call "output stack" (not explained, is very simple) ``` ## Initialization Here we build the 6 lines which construct the waves. We need to repeat each string 5 times to be the correct length. We start with 6 of these, one for each line of the wave: ``` " ** " push " ** " to the stack e2C call "copy current stack 4 times" 0[ create a new stack ``` And we enter the main loop after initialization through `09.`. ## Copy Current Stack 4 Times This is a simple function which simply takes the current stack, and copies it 4 times. So "a" would become "aaaaa". ``` 54C call "copy stack" l2,[ copy half the current stack to a new stack 54C54C call "copy stack" twice ] close the current stack, moving values to the one below R return from the function ``` ## Copy Stack This copies the current stack, appending the copy to the current stack. ### Setup Going to skip the initial `<` and invert the first line to become `l:&0v` as that's the order it gets executed in after the `<` changes the IP's direction. ``` l push the stack length to the stack :& copy the length to the register 0 push 0 to the stack v move the IP downwards, entering the loop ``` From here on out the length will be referred to as `n` and the `0` as `i`. ### Loop ``` > move the IP to the right : copy i @=?v pop i from the stack, if n == i, proceed to cleanup 1+ add 1 to i {:} copy the first value of the stack to the end of the stack & place n on the stack l1-[ open a new stack moving all values but index 0 to the new one :& copy n and place it on the register $@ swap i with the value on its right $ swap i with n ``` ### Cleanup ``` > move the IP to the right :?!v if i == 0 then ... ~R> remove i from the stack and return ] close the stack, appending all values to the stack below 1- subtract 1 from i ``` ## Main Loop Here is where the code runs forever, constantly redrawing the waves in-between 100ms sleeps. ### Setup ``` DDDDDD select the 6th stack down "H;0[x"ooooo move the cursor to the top-left of the term (x == ascii 27) v move the IP downwards, entering the loop ``` ### Loop ``` > move the IP to the right l?u O if the stack is empty ... 1S sleep for 100ms 09. jump to main loop initialisation { shift the stack left 54Cl2,[ copy the current stack to a new stack a append a newline to the stack } shift the stack to the right 4cC call "output stack" ] close the stack I select one stack higher ``` [Answer] # PHP, 128 bytes ``` for($a=[3,60,496,1584,6168,57351];;usleep(1e5))foreach($a as&$x)for($x=$x/2|$x%2<<15,$i=80;$i--;)echo" *"[$x>>$i%16&1],"\n"[$i]; ``` Cannot animate more than one line, but it scrolls. Add `,0` to the array for an empty line between iterations. Run with `-r`. [Answer] ## Mathematica, 213 bytes ``` i=0;RunScheduledTask[i++,0.1];Dynamic[RotateRight[#,i]&/@Characters/@(StringRepeat[#,5]&)/@{" ** "," **** "," ***** "," ** ** "," ** ** ","* *****"}//Grid] ``` I don't see any way of golfing the wave pattern in Mathematica other than just starting with a list of strings for each line. I initialize `i` to be `0` and schedule a task to increment it every `0.1` seconds. I `Dynamic`ally display the result of the following: 1. `StringRepeat` each line 5 times. 2. Convert each line into a list of its `Characters`. 3. `RotateRight` each list of characters by `i`. 4. Display the resulting array of characters as a `Grid`. [![enter image description here](https://i.stack.imgur.com/bB1hc.gif)](https://i.stack.imgur.com/bB1hc.gif) [Answer] # C (unix), ~~231~~ 191 bytes This will only work on unix environments. Also, please excuse the fact that sleep accepts only integers... so it actually delays 1second between frames. Ungolfed version: ``` #include <stdio.h> int main() { int x=0,l,i,a[6]={32799,24672,6336,1984,240,12}; while(l=6,++x) { printf("\033[2J"); while(i=128,l--) { while(i--) putchar(a[l]&1<<(i+x)%16 ? 42 :32); puts(""); } sleep(1); } } ``` Golfed version: ``` #include <stdio.h> int main(){int x=0,l,i,a[6]={32799,24672,6336,1984,240,12};while(l=6,++x){printf("\033[2J");while(i=128,l--){while(i--)putchar(a[l]&1<<(i+x)%16?42:32);puts("");}sleep(1);}} ``` [Answer] # Ruby 269 217 189 185 Bytes *-28 Bytes thanks to @manatwork* *-5 Bytes thanks to @ropata* **Normal** ``` p=0 loop do system 'clear' [' '*12+'** ', ' '*8+'**** ',' ***** ',' ** ** ',' ** ** ','* *****'].each {|i| puts ((i*5)[16-p..-1]+i)[0..79]} p=-~p%16 sleep 0.1 end ``` **Golfed** ``` p=0 b=' ' loop{system'clear' [b*12+'** ',b*8+'**** ',b*5+'*****'+b*6,' ** **'+b*6,' ** ** ',"*#{b*10}*****"].map{|i|puts ((i*5)[16-p..-1]+i)[0,79]} p=-~p%16 sleep 0.1} ``` [Answer] # Javascript (ES6), ~~152~~ ~~147~~ 145 bytes ``` x=0,c=console;setInterval(a=>{for(c.clear();f="",i=128,++x,a--;c.log(f))for(;i--;)f+=" *"[[32799,24672,6336,1984,240,12][a]>>(i+x)%16&1]},100,6); ``` [Answer] ## Perl 6, ~~140~~ ~~138~~ ~~137~~ ~~123~~ 120 bytes ``` for ^Inf ->\i{print "\e[H";for 12,240,1984,6336,24672,32799 ->\j{say [~] map {j+>((i-$_)%16)%2??'*'!!' '},^80};sleep .1} ``` Old solutions: ``` for ^Inf ->\i {print "\e[H";for 12,240,1984,6336,24672,32799 ->\j {say [~] map {j+>((i-$_)%16)%2??'*'!!' '},^80};sleep .1;} my @a=12,240,1984,6336,24672,32799;for ^Inf ->\i {print "\e[H";for @a ->\j {for ^80 {print j+>((i-$_)%16)%2??'*'!!' '};say ""};sleep .1;} my @a=12,240,1984,6336,24672,32799;for ^Inf {print "\e[H";for @a ->\j {for ^80 ->\k {print j+>(($_- k)%16)%2??'*'!!' '};say ""};sleep .1;} my @a=12,240,1984,6336,24672,32799;for ^Inf {print "\e[H";for @a ->\j {for ^80 ->\k {print j+>(($_+15*k)%16)%2??'*'!!' '};say ""};sleep .1;} ``` [Answer] # Python 3, ~~240~~ ~~239~~ 230 bytes *-1 byte thanks to @redstarcoder* *-9 bytes thanks to @PascalvKooten* ``` import time def p():print("\x1b[0;H") i=0;p();s=[' '*13+'**',' '*9+'**** ',' ***** ',' ** ** ',' ** ** ','** ***'] while True: for x in s:x*=5;c=i%80;print(x[-c:]+x[:-c]) i+=1;p();time.sleep(.1) ``` [Answer] ## Racket 295 bytes ``` (let*((g string-append)(h substring)(d displayln)(j(λ(l)(map(λ(x)(g(h x 1)(h x 0 1)))l))))(let p((l(map(λ(x)(apply g(for/list((i 5))x)))'(" ** "" **** "" ***** "" ** ** "" ** ** ""* *****"))))(for((i l))(d i))(d"")(sleep .1)(p(j l)))) ``` Ungolfed: ``` (define(f) (define (lf l) (map (λ (x) (string-append (substring x 1) (substring x 0 1))) l)) (let loop ((l (map (λ (x) (apply string-append (for/list ((i 5)) x)) ) (list " ** " " **** " " ***** " " ** ** " " ** ** " "* *****")))) (for ((i l)) (displayln i)) (displayln "") (sleep 0.1) (loop (lf l)))) ``` Testing: ``` (f) ``` Output: [![enter image description here](https://i.stack.imgur.com/InaG4.gif)](https://i.stack.imgur.com/InaG4.gif) (This gif file display is slower than actual output). [Answer] ## Python 2, ~~207~~ 202 bytes Usually I'm a C# developer, so this might not be completely golfed yet... ``` import time;i=0 while 5: print"\033[;H" for l in[" "*12+"** "," "*8+"*"*4+" "*4," "*5+"*"*5+" "*6," ** **"+" "*6," ** "*2,"*"+" "*10+"*"*5]:print(l[16-i:]+l*5)[:80] time.sleep(.1);i=(i+1)%16 ``` [Answer] ## C#, 327 bytes More or less a ported version of my solution in Python... ``` _=>{Func<string,int,string>t=(s,j)=>(s.Substring(16-j)+string.Concat(Enumerable.Repeat(s,5))).Substring(0,80);for(var i=0;;i=++i%16){Console.Clear();foreach(var q in " ** , **** , ***** , ** ** , ** ** ,* *****".Split(','))Console.WriteLine(t(q,i));Thread.Sleep(100);}} ``` [Answer] ## Perl, 110 bytes **Requires `-E` at no extra cost. This contains unprintable characters.** ``` $_=unpack"B*","x?`00?";s!.{16}!$&x5 .$/!ge;y/01/ */;{say"\ec$_";select!s/(.+)(.)$/$2$1/mg,$a,$a,.1;redo}" ``` Create the above data using the below reversible hexdump. Run `xxd -d > sea.pl` in a linux or compatible terminal, paste the below and press `Ctrl`+`d`, then run `perl -E "$(cat sea.pl)"`. ``` 0000000: 245f 3d75 6e70 6163 6b22 422a 222c 2200 $_=unpack"B*",". 0000010: 0600 7803 e00c 6030 30c0 0f22 3b73 212e ..x...`00..";s!. 0000020: 7b31 367d 2124 2678 3520 2e24 2f21 6765 {16}!$&x5 .$/!ge 0000030: 3b79 2f30 312f 202a 2f3b 7b73 6179 225c ;y/01/ */;{say"\ 0000040: 6563 245f 223b 7365 6c65 6374 2173 2f28 ec$_";select!s/( 0000050: 2e2b 2928 2e29 242f 2432 2431 2f6d 672c .+)(.)$/$2$1/mg, 0000060: 2461 2c24 612c 2e31 3b72 6564 6f7d $a,$a,.1;redo} ``` ### Usage For easy copy/pasting, please use the below: ``` perl -E '$_=unpack"B*","\x00\x06\x00\x78\x03\xe0\x0c\x60\x30\x30\xc0\x0f";s!.{16}!$&x5 .$/!ge;y/01/ */;{say"\ec$_";select!s/(.+)(.)$/$2$1/mg,$a,$a,.1;redo}' ``` ### Explanation A fairly straightforward solution that stores the wave as a string at the beginning, which is `unpack`ed to binary, each section is quintuplicated, `0`s are converted to spaces and `1`s are converted to `*`s. Now we have the whole string so we enter a `redo` loop which prints out the whole string, then we wait for .1 seconds and for each line in the string, we move the last character to the beginning of the string. [Answer] ## Mathematica 171 Bytes The wave itself is data, so I'm storing a compressed version of the whole wave in my code. I can store a single wave much more compactly as `\fð߀ᣀ恠耟` using it's binary representation, but the character count overhead of uncompressing is too high\*. Here is the code: ``` w=Uncompress@"1:eJxTTMoPSmNjYGAoZgESPpnFJcEBQIYCEtDSUlCglI9iqJYWqhJy+QhDtdCUUMCHGQrmIymiiA8xFMajEg02FMkXWmi+IosPAJNuSHg="; Dynamic[Pause[.1];Column[w=StringRotateRight/@w]] ``` Here is the code I used to create the compressed version of the wave data: ``` s={" ** "," **** "," ***** "," ** ** "," ** ** ","* *****"}; s//TableForm StringRepeat[#,5]&/@s Compress[%] ``` Here is the code I would have preferred to use to store compressed repeating binary data like this wave: ``` StringJoin /@ (PadLeft[(IntegerDigits[#1, 2] & ) /@ ToCharacterCode["\fð߀ᣀ恠耟"]] /. {0 -> " ", 1 -> "*"}) ``` As you can see, the overhead to turn the compressed data back into a string is too expensive for this particular problem, although a single wave can be stored this way with 7 UTF characters and 15 bytes. Here was the code to determine the UTF character sequence to store a single wave (s as above). ``` StringReplace[#,{" "->"0","*"->"1"}]&/@s ToExpression/@% IntegerDigits/@% FromDigits[#,2]&/@% FromCharacterCode/@% StringJoin@% ``` [Answer] # [Stax](https://github.com/tomtheisen/stax), 38 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` ç²kτ,e7rà♠ǃ╜?║í▬u╬wπ■&Jµⁿj↨▄!=╢╡═+ZWu ``` [Run and debug it](https://staxlang.xyz/#p=87fd6be72c6537728506809fbd3fbaa11675ce77e3fe264ae6fc6a17dc213db6b5cd2b5a5775&i=) Took some shuffling around and `:B` to beat the MATL score. ## Explanation ``` . *9*"!1$'YKaK968"%13|E:B16/WcM|)Ms{|,}6*|:m5* . * " *" 9* repeat 9 times "!1$'YKaK968"%13|E compressed run lengths of wave :B run length decode using the two arrays 16/ split in groups of 16 W loop forever c copy the wave M|)M shift right s swap {|,}6* wait 6 frames(0.1s at 60fps) m5* pop, repeat each line 5 times and display ``` [Answer] # HTML + JS + jQuery, 10 + 233 = 243 bytes ``` b=" ** q **** q ***** q ** ** q ** ** q* *****".split`q`.map(x=>x.repeat(5).split``) setInterval(a=>$("#a").text(b.map(f=>f.join``).join`\n`)+b.map(e=>e.unshift(e.pop())),100) ``` ``` <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!-- start --> <pre id=a> ``` The JavaScript just shifts each row by 1 and changes the text every 100 ms. ]
[Question] [ Your goal is to display ASCII art of a formation in [ten-pin bowling](http://en.wikipedia.org/wiki/Ten-pin_bowling) where only some of the pins remain. Fewest bytes wins. The tens pins are in a triangular formation: ``` O O O O O O O O O O ``` Pins are labelled from 1 to 10 as: ``` 7 8 9 10 4 5 6 2 3 1 ``` Drawing pins as `O` and missing pins as `.`, the formation `1 3 5 6 9 10` is: ``` . . O O . O O . O O ``` **Input:** A space-separated string that lists a nonempty subset of the numbers 1 though 10 in order. **Output:** Print the corresponding formation or output it as a string with linebreaks. The formation should be flush with the left of the screen. Any whitespace is fine as long as the visible image is correct. Empty lines before and after are fine too. **Test cases:** ``` >> 1 2 3 4 5 6 7 8 9 10 O O O O O O O O O O >> 7 10 O . . O . . . . . . >> 3 5 7 9 10 O . O O . O . . O . >> 1 . . . . . . . . . O ``` [Answer] # brainfuck - ~~617~~ ~~616~~ 604 bytes ``` +>>>>,[>++++[<-------->-]<[>>>>],]<<<<[>+<<+<+>>-]<[>+<-]+<+<<[>+>-<<-]>[<+>-]>[,+++++[>+++++<-]>>[<->-]<[>>>>>[>>>>]+[<<<<]<-]>>[<+>-]<<<]>[>>[,<]<<+++++++++<]<<<[-[+>>-<]>[>>[<+<+>>-]<<<<[>+>-<<-]>[<+>-]>[<<[<<<<]>>>>[[<<<<+>>>>-]>>>>]<<<<+>>-]>[>+<-]]<<<[-[+>]+<<<<]>>>>-<<<<<]>>>>>+++++[>----<-]>->[<+>>+<-]<[<<<[<<<<]+[>>>>]<-]>>[<+>-]<[<<<<]>>>++++[<-------->-]>[-[,+++>]+>>>[<<<->>]>]<<<<<[>-]>[>>]>>+[<++++[<++++++++>-]<]>>[+++++++++++++>>>>]<<<<----<+++[<<+<<[<<+<<]+[>>>>]<<<<-]<<<<[-<<<<]>[.,>>]<<<<<[<<<<]<++++++++++<<.<+<<+<<+<<+<<+<[.,>>]<<<<<[<<]>++++++++++<+<<+<<+<..<+<[.,>>]<[<<]<...<<. ``` This took me the better part of two days. I think it was worth it. There's probably parts that can be golfed more by changing what cell something is stored in or whatever, but right now I'm just happy I got it working. This program would have to be completely different if the question didn't specify that the input would be sorted. The way this works is by constructing a list of 10 pins around the ones that are input. That's kind of confusing but maybe this will explain it better: ``` If you input these pins: [2, 3, 6, 8, 9] First, the program does this: [2, 3, 6, 8, 9] + [10] Then this: [2, 3, 6] + [7] + [8, 9, 10] Then this: [2, 3] + [4, 5] + [6, 7, 8, 9, 10] Finally, this: [1] + [2, 3, 4, 5, 6, 7, 8, 9, 10] To build this: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` While it's doing that, it remembers which of the pins the user put there and which ones it put there. This strategy would be very difficult to use if the input wasn't sorted. Another thing that the sorting make easier is detection of the number 10. Since brainfuck deals with individual bytes, not "numbers" per se, it could have been a pain in the ass, but the sorted input made it much easier for me to deal with. The reason for that has to do with how I stored data in the program. I take the input one character at time and subtract 32 from the result. If the cell is non-zero after that, I move forward 4 cells. before repeating. This means that I get a non-space byte of input every 4 cells, and I effectively store pins as their number + 16. However, 10 takes two bytes to type, so I had to special case it. If the input wasn't sorted, I'd have to look through the pins, but since it is sorted it will always be the last pin if it appears. I check if the (last byte of input + 1) == (the second last byte of input) and if so, it must be 10. I get rid of the last byte and set the second last one to what my system understands as "10". The characters `'1'` and `'0'` don't fit in a single byte, but the number 26 sure does! Coming up with tricks just to make something work at all is my favourite part of using this language. :) If you're interested in how this program works in more detail, you can see the program with the comments I used while writing it to make sure I remembered what everything did. Even writing comments in brainfuck is hard, since there's no comment syntax. Instead, every character except those in `<[+.,-]>` are no-ops. It's easy to introduce bugs by accidentally including `.` or `,` in your comments! That's why the grammar is so wonky and semicolons are everywhere. **EDIT:** As an example of how easy this is to screw up: I used "non-space" in one of the comments! When I stripped all the non-bf characters from the source, the program I used to do that kept in the `-`. Luckily it didn't break anything, but now I've removed it to save a byte. :) **EDIT II:** It's been a while since I touched this one, haha. In another brainfuck answer on this site, I noticed that I accidentally used a comma in the commented version. Since the input had already been exhausted, it set the current cell to 0 (this is implementation dependant, but in my experience it's the most common behaviour). I fixed the bug, but it got me thinking. The idiomatic way to set a cell to 0 is `[-]` (roughly `while (*p) { *p--; }`), which is two bytes longer. Any time all the input has been read, I can use `,` instead. This saved me 2 bytes in that answer, and 12 in this one! ``` one flag at the very left; will be important later +>>>> all nonspace bytes of input separated by 3 empty cells; pin number `n` stored with value `n` plus 16 ,[>++++[<-------->-]<[>>>>],]<<<< test if last pin is 10 [>+<<+<+>>-]<[>+<-]+<+<<[>+>-<<-]>[<+>-]> [ if not: find 10 minus the number it is; put that many placeholder pins (cells with value 1) at the end ,+++++[>+++++<-]>>[<->-]<[>>>>>[>>>>]+[<<<<]<-]>>[<+>-]<<< ]> [ if so: get rid of '0' byte; convert '1' byte to 26 (10 plus 16) >>[,<]<<+++++++++< ]<<< pointer now sitting on the cell with the second greatest pin that was inputted (ie not a placeholder) ;;;;;;; [ check for flag placed at the very beginning of the program; if present: break -[+>>-<]> [ find ((pin to our right) minus 1) minus pin to our left move all pins left of us 4*(that value) cells and insert placeholder pins >>[<+<+>>-]<<<<[>+>-<<-]>[<+>-]>[<<[<<<<]>>>>[[<<<<+>>>>-]>>>>]<<<<+>>-]>[>+<-] ] find first non placeholder pin to our left there has to be one because we haven't hit the flag yet <<<[-[+>]+<<<<]>>>>-<<<<< ]>>>>>+ we have now added placeholder pins at the end and in the middle; all that's left is the beginning subtract 17 from lowest pin and put that many placeholders to the left ++++[>----<-]>->[<+>>+<-]<[<<<[<<<<]+[>>>>]<-]>>[<+>-] subtract 32 from an empty cell 2 to the left of the lowest pin; will be useful later <[<<<<]>>>++++[<-------->-]> placeholder pins have the value 1; real pins have a value somewhere between 17 and 26 normalize it by stepping through and setting every pin with value != 1 to 3 (0's ascii code is 2 higher than period so this will make it easier to print later) [-[,+++>]+>>>[<<<->>]>]<<<<<[>-]>[>>]>> start writing 32s across the board; hitting every second cell that's every pin and the cell 2 to the right of each pin this is done in such a way that it will only halt if adding 32 to a cell sets it to 0; which is why we subtracted 0 from an empty cell earlier it will catch us and prevent an infinite loop +[<++++[<++++++++>-]<] now write 13 to each pin; this adds up to 46 or 48; which are exactly the ascii values we want >>[+++++++++++++>>>>] we happen to have made a 14; turn it into a 10 for a newline <<<<---- we're so close now; i can taste it we have a list of 10 pins; each one with the ascii value that needs to be written we have 32 everywhere because we'll need spaces we even have a newline the only problem now is that our list looks like this: ;;;;;;;;;;;;;;;;;;;;;;;; ;;1 2 3 4 5 6 7 8 9 10;; ;;;;;;;;;;;;;;;;;;;;;;;; and we need to print in this order: ;;;;;;;;;;;;;;;;;;;;;;;; ;;7 8 9 10 4 5 6 2 3 1;; ;;;;;;;;;;;;;;;;;;;;;;;; it's a pretty simple fix once we print a pin we obviously don't need to remember it any more so we simply print the last 4 pins on the list; destroying them on the way then we print the last 3; which have become the ones we want then two; then one <+++[<<+<<[<<+<<]+[>>>>]<<<<-]<<<<[-<<<<] print pins 7 8 9 10 >[.,>>] print pins 4 5 6 <<<<<[<<<<]<++++++++++<<.<+<<+<<+<<+<<+<[.,>>] print pins 3 2 <<<<<[<<]>++++++++++<+<<+<<+<..<+<[.,>>] print the final pin!! :) <[<<]<...<<. ``` [Answer] # Python 2, 108 bytes ``` def f(x): for i in 4,3,2,1:print" "*(4-i)+" ".join(".O"[i*~-i/2-~z in map(int,x.split())]for z in range(i)) ``` Call with `f("3 5 7 9 10")`. `i` is the row number, with 4 being the first row and 1 being the last. `z` is the nth pin on that row, with 0 meaning it's the first pin in the row and `i-1` meaning it's the last pin in the row. The main hack is `i*~-i/2-~z`, which converts `(i, z) -> pin number`. For example, `(4, 0) -> 7` as pin 7 is the first pin on row 4 (the first row). The derivation goes like this: * We want a function taking `i` to the first pin on row `i`, i.e. `4 -> 7, 3 -> 4, 2 -> 2, 1 -> 1`. This is satisfied by `(i**2-i)/2 + 1`, and thus `(i**2-i)/2 + 1 + z` gives the correct pin number for input `(i, z)` * Then simplify: ``` (i**2-i)/2 + 1 + z = (i*(i-1))/2 + 1 + z = i*~-i/2 + 1 + z = i*~-i/2-~z ``` --- # [Pyth](https://github.com/isaacg1/pyth), 33 bytes ``` V4~Z-4N+*dNjdm@".O"}+d-11Zrz7U-4N ``` [Try it online.](http://isaacg.scripts.mit.edu/pyth/index.py) The program roughly translates to: ``` z = input() Z = 0 for N in range(4): Z += 4-N print(" "*N + " ".join(".O"[d+11-Z in map(int, z.split())] for d in range(4-N))) ``` *(Thanks to isaacg for tips)* [Answer] # [Pyth](https://github.com/isaacg1/pyth), 31 ``` V4+*dNjdm?\O}+7+dZrz7\.rN4~Z-N4 ``` Try it [here](http://isaacg.scripts.mit.edu/pyth/index.py). `V4` sets up a for loop, with N as the variable over [0,1,2,3]. `*dN` provides the initial spaces, because `d` is space. To find the pin locations, it uses `+7+dZ` - 7 + d + Z. `d` is: ``` 0 1 2 3 1 2 3 2 3 3 ``` while `Z` is 0 in the first line, -4 in the second, -7 in the third and -9 in the forth. This is becasue `Z` starts as 0, and `~Z-N4` decrements `Z` by 4, then 3, then 2. Then, it checks if the pin location is in the input, using `}+7+dZrz7`. `rz7` is the desired pins in list-of-int form. Then, it creates an `O` if it was present, and `.` otherwise. This is space separated, with `jd`, and printed implicitly. [Answer] # Perl 5: 51 (50 + 1 for `-p`) Using `r` flag for `s///` which is one of the recent perl 5 additions. ``` #!perl -p $_="7890 456 23 1 "=~s!\d!'. '^a x/$&\b/!egr ``` [Answer] # CJam, ~~48~~ 41 bytes Wow, this got horribly long ``` "6789345 12 0"S*7/N*[l~]:(s"O"erA,s"."er ``` [Test it here.](http://cjam.aditsu.net/) ## Explanation First we generate the layout: ``` "6789345 12 0" "Push this string."; S* "Riffle with spaces."; 7/ "Split into substrings of length 7."; N* "Join with newlines."; ``` This yields ``` 6 7 8 9 3 4 5 1 2 0 ``` And now we replace the digit characters according to the input: ``` [l~] "Read the input and turn it into an array of integers."; :(s "Decrement each number and turn the array into a string of digits."; "O" "Push this string."; er "Character transliteration, replaces the input digits with O."; A,s "Create the string '0123456789'."; "." "Push this string."; er "Character transliteration, replaces all remaining digits with periods."; ``` [Answer] # Python 2, ~~97~~ 94 This uses the translate function, which allows one to make character-for-character substitutions in a string. Like tr in perl, except much longer to type. I get a list of decimal digits by making a string from 9 to the 99th power. ``` lambda a:u"7890\n 456\n 23\n 1".translate({ord(n):u'.O'[n+' 'in a+' ']+' 'for n in`9**99`}) ``` [Answer] # Javascript, 155 First golf, can probably be shorter. ``` function f(i){q='replace',s='7 8 9 0\n 4 5 6\n 2 3\n 1';alert(s[q](RegExp(i[q]('10','0')[q](/ /g,'|'),'g'),function(a){return a?'O':a})[q](/\d+/g,'.'))} ``` call with ``` f('1 2 3 4 5 6 7 8 9 10') f('1 5 10') f('') ``` **EDIT** # ES6 version, 130 ``` f=i=>{q='replace',s='7 8 9 0\n 4 5 6\n 2 3\n 1';alert(s[q](RegExp(i[q]('10','0')[q](/ /g,'|'),'g'),a=>a?'O':a)[q](/\d+/g,'.'))} ``` **EDIT** # ~~ES6 version, 79~~ fails ``` f=i=>alert('7890\n 456\n 23\n 1'.replace(/\d/g,a=>i.indexOf(a)<0?'. ':'O ')) ``` # ES6 version, ~~72~~ 77, no alert, just returns ``` f=i=>'7890\n 456\n 23\n 1'.replace(/\d/g,a=>i.search(a+'\\b')<0?'. ':'O ') ``` [Answer] # GNU sed, 75 * Saved 6 bytes thanks to @Jordan. Score includes 1 extra for `-r` option: ``` s/^/7 8 9 10\ 4 5 6\ 2 3\ 1 / : s/([0-9]+)(.*)\1/O\2/ t s/[0-9]+/./g ``` Input via STDIN: ``` $ echo 3 5 7 9 10 | sed -rf ./bowling.sed O . O O . O . . O . $ ``` [Try it online](http://sed.tryitonline.net/#code=cy9eLzcgOCA5IDEwXAogNCA1IDZcCiAgMiAzXAogICAxIC8KOgpzLyhbMC05XSspKC4qKVwxL09cMi8KdApzL1swLTldKy8uL2c&input=MyA1IDcgOSAxMA&args=LXI). [Answer] # Ruby, 91 ``` x=(1..10).map{|i|i.to_s==$*[0]?($*.shift;?0):?.} 4.times{|i|puts (x.pop(4-i)*' ').center 8} ``` Simply substitutes the command line arguments with `.`s and `0`s and prints them using a loop of 4 cycles. ### Readable version ``` x = (1..10).map do |i| if i.to_s == ARGV[0] ARGV.shift "0" else "." end end 4.times do |i| row = x.pop(4 - i) puts row.join(' ').center 8 end ``` [Answer] # CJam, ~~40~~ 39 bytes ``` 4,Sf*'-A*[q~]{('ot}/3,{)/(\s}%Sf*W%]zN* ``` I know there is a shorter way, don't have time to figure it out right now. How it works: ``` 4,Sf*'-A*[q~]{('ot}/3,{)/(\s}%Sf*W%]zN* 4, "Get the array [0,1,2,3]"; Sf* "Covert each number to that many spaces to"; "get ["", " ", " ", " "] array"; '-A* "String '----------'"; [q~] "Input numbers in an array"; { }/ "For each input number"; ('ot "Put 'o' at the corresponding index"; 3, "Array [0,1,2]"; { }% "For each of the above number"; ) "Increment the number"; / "Split the string into pieces of that length"; (\s "Take the first string and join the rest back"; Sf* "Riffle each string in array with space"; W% "Reverse the array of strings"; ]z "Zip together the space array and this one"; N* "Join by new line"; ``` [Try it online here](http://cjam.aditsu.net/) [Answer] # Pure bash (no coreutils), 85 Simple pattern replacement: ``` f="7 8 9 0 4 5 6 2 3 1" a=${@/10/0} f="${f//[${a// /}]/O}" echo "${f//[0-9]/.}" ``` List is input via the command-line args. [Answer] ## APL (35) ``` ⊖4 7⍴'.O'[1+⎕∊⍨⍳10]\⍨17110357⊤⍨28/2 ``` Test: ``` ⊖4 7⍴'.O'[1+⎕∊⍨⍳10]\⍨17110357⊤⍨28/2 ⎕: 1 3 5 6 9 10 . . O O . O O . O O ``` Explanation: * `17110357⊤⍨28/2`: the 28-bit representation of `17110357`: ``` 4 7⍴17110357⊤⍨28/2 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ``` * `\⍨`: For every `0`, give a space, and for every `1`, take an item from the string on the left. * `⎕∊⍨⍳10`: Read a line from the keyboard and evaluate it (`⎕`), then check for every number from 1 to 10 (`⍳10`) whether or not it is contained in the input (`∊⍨`). * `'.O'[1+`...`]`: Add 1 to every value (giving 1s and 2s instead of 0s and 1s), and then replace every 1 by `.` and every 2 by `O`. * `4 7⍴`: turn the generated string into a 4-by-7 matrix * `⊖`: flip it horizontally [Answer] # Powershell: 109 Input is in $i ``` (7..10),(4..6),(2,3),1|%{$c=0}{$_|%{$o=(" "*$c++)}{$o="$o $(if($i.split() -contains $_){'O'}else{'.'})"};$o} ``` That was fun. Learned a bunch of stuff about how the pipeline works, too. [Answer] ## Haskell: ~~163~~ 160 bytes This accepts a line of space separated numbers from `stdin`. ``` m=map y?x|x`elem`y="O "|0<1=". " f y=putStr.unlines.zipWith(++)(m(`replicate`' ')[0..])$m(concat.m(y?))[[7..10],[4..6],[2,3],[1]] main=getLine>>=f.m read.words ``` ### Ungolfed: ``` layout :: [[Int]] layout = [[7,8,9,10] ,[ 4,5,6 ] ,[ 2,3 ] ,[ 1 ] ] indentBy :: Int -> String indentBy n = replicate n ' ' indentLines :: [String] -> [String] indentLines = zipWith (++) (map indentBy [0..]) bowling :: [Int] -> String bowling pins = unlines . indentLines $ map (concatMap showPlace) layout where showPlace :: Int -> String showPlace index | index `elem` pins = "O " | otherwise = ". " parseInput :: String -> [Int] parseInput = map read . words main :: IO () main = do pins <- fmap parseInput getLine putStr (bowling pins) ``` --- And a bonus: ## C: 250 bytes This version expects its command line arguments to be the list of numbers. ``` #define w int main(w z,char**a){w b[10]={1,3,2,6,5,4,10,9,8,7};w q=9;for(w k=4;k>0;--k){w i;for(i=0;i<4-k;++i)printf(" ");for(i=0;i<k;++i,--q){w g=0;w c;for(w p=1;p<z;++p){sscanf(a[p],"%d",&c);g|=b[q]==c;}c=g?'O':'.';printf("%c ",c);}printf("\n");}} ``` [Answer] # Perl, 73 ``` $_="7 8 9 10\n 4 5 6\n 2 3\n 1";for$v(<>=~/\d+/g){s/$v/O/g};s/\d+/./g;print ``` And a goofy bonus approach that didn't pan out, 90 characters: ``` srand(1488068);$i=<>;print+(($i=~/$_\b/?O:".")." "x rand 5)=~s/ /\n /r for 7..10,4..6,2,3,1 ``` [Answer] # Mathematica, 109 bytes Function: ``` f=(i=0;Reverse@Table[Row@Table[If[MemberQ[ToExpression/@StringSplit@#,++i],O,"."],{n}],{n,4}]~Column~Center&) ``` Called by: ``` f@"3 5 7 9 10" ``` If anonymous functions are allowed, this can be shortened to **105 bytes**: ``` i=0;Reverse@Table[Row@Table[If[MemberQ[ToExpression/@StringSplit@#,++i],O,"."],{n}],{n,4}]~Column~Center& ``` If the input didn't have to be a space-delimited string, but could be an array of numbers in the form `{3,5,7,9,10}`, this can be further shortened to **79 bytes**: ``` i=0;Reverse@Table[Row@Table[If[MemberQ[#,++i],O,"."],{n}],{n,4}]~Column~Center& ``` [Answer] # Rebol - 117 ``` s: array/initial 10"."b:""foreach n to-block input[s/:n:"0"]for n 4 1 -1[prin b print take/last/part s n append b" "] ``` Ungolfed: ``` s: array/initial 10 "." b: "" foreach n to-block input [s/:n: "0"] for n 4 1 -1 [prin b print take/last/part s n append b " "] ``` [Answer] ## Brainfuck, 179 bytes ``` ++++++++++[-[<<+>>-]+<<]>,[<[-]-[>-<-----]>++[-[>>+<<-]>>]>+++[<<],>,]<[,>>---[> >]<<+++[<<]]>->>->>>>->>>>>>->[[>>]>,<<+[++[>+++++++++++<-]<+]>>[++.>-.>]>++++++ ++++[>>]<<[.[<]<]<] ``` Formatted: ``` ++++++++++ [ -[<<+>>-] +<< ] >, [ <[-] -[>-<-----] >++ [ -[>>+<<-] >> ] >+++[<<] ,>, ] < [ ,>>---[>>] <<+++[<<] ] >->>->>>>->>>>>>-> [ [>>] >,< <+ [ ++[>+++++++++++<-] <+ ] >>[++.>-.>] >++++++++++[>>] <<[.[<]<] < ] ``` Expects input without a trailing newline. [Try it online.](http://brainfuck.tryitonline.net/#code=KysrKysrKysrK1stWzw8Kz4-LV0rPDxdPixbPFstXS1bPi08LS0tLS1dPisrWy1bPj4rPDwtXT4-XT4rKytbPDxdLD4sXTxbLD4-LS0tWz4-XTw8KysrWzw8XV0-LT4-LT4-Pj4tPj4-Pj4-LT5bWz4-XT4sPDwrWysrWz4rKysrKysrKysrKzwtXTwrXT4-WysrLj4tLj5dPisrKysrKysrKytbPj5dPDxbLls8XTxdPF0&input=MyA1IDcgOSAxMA) The tape is initialised with ten nodes, each of which contains a one followed by a zero. The one is the initial value of the pin, and the zero facilitates navigation and acts as a placeholder for the space character. For each number in the input, that pin is incremented by 3; note that `ord('O') - ord('.') = 33`, and during the printing phase, the pin's value will be multiplied by 11. (This multiplication is also used to generate the space character.) The order of the pins from left to right on the tape is simply `1` up to `10`. If the input ends with a `10`, a correction is made, since the `10` is initially treated as a `1`. After the input has been processed, a negative one is placed after each row. Then the rows are printed in a loop, with the number of leading spaces determined by the number of rows previously processed. [Answer] # Powershell, 84 bytes ``` $p='6789 345 12 0' -split$args|%{$p=$p-replace($_-1),'O '} $p-replace'\d','. ' ``` Test script: ``` $f = { $p='6789 345 12 0' -split$args|%{$p=$p-replace($_-1),'O '} $p-replace'\d','. ' } # one space at the end of each line with pins @( ,("1 2 3 4 5 6 7 8 9 10", @" O O O O O O O O O O "@) ,("7 10", @" O . . O . . . . . . "@) ,("3 5 7 9 10", @" O . O O . O . . O . "@) ,("1", @" . . . . . . . . . O "@) ) | % { $s, $expected = $_ $result = &$f $s $result-eq$expected $result } ``` Output: ``` True O O O O O O O O O O True O . . O . . . . . . True O . O O . O . . O . True . . . . . . . . . O ``` [Answer] # Clojure, 216 chars (ugh) I'm sure this can be golfed further. ``` (let[s(map #(dec(read-string %))(.split(slurp *in*)" +"))](println(apply str(replace(apply hash-map(interleave(map #(char(+ 48 %))(range 10))(map #(if(some #{%}s)"O"".")(range 10))))"6 7 8 9\n 3 4 5\n 1 2\n 0")))) ``` Use like this: ``` echo -n "2 4 9 8 10 5" | clojure a-file-which-contains-this-program.clj ``` [Answer] ## AWK: 96 bytes ``` {gsub(/ /,"");a="6 7 8 9\n 3 4 5\n 1 2\n 0";gsub("["$0"]","O",a);gsub(/[0-9]/,".",a);print a} ``` Note: * The spaces separators on the input value are optional (but it works also with them as required) * The numbers don't have to be in order * The input is read on STDIN [Answer] # C# - 192 bytes Because C#! I started out trying to build the output with math, but the simple replace-tokens-in-string method seems best for higher-level languages. Linq dependency is longish but still shorter than keeping a counter and doing range checks. ``` using System.Linq;class A{static void Main(string[]a){var s=@"7 8 9 0 4 5 6 2 3 1";for(int c=11;c-->1;)s=s.Replace((char)(48+c%10),a.Contains(""+c)?'O':'.');System.Console.Write(s);}} ``` EDIT: unix line returns (-3 bytes) [Answer] # Scala, ~~150~~148 ``` def t(n:Any)=("G H I J D E F B C A"/:('A'to'J'))((j,i)=>j.replace(i,(if((n+" ").indexOf((i-64)+" ")>=0)'0'else'.'))).grouped(7).maxBy(println) ``` Accepts space-delimited set of strings [Answer] # JavaScript ES6, 78 bytes ``` F=i=>'7890\n 456\n 23\n 1'.replace(/\d/g,e=>'0.'[+!~i.search(e+'\\b')]+' ') ``` Use the following snippet to test. It uses prompts and alerts and regular function notation for ease of testing. ``` i=prompt() alert('7890\n 456\n 23\n 1'.replace(/\d/g,function(e){return'0.'[+!~i.search(e+'\\b')]+' '})) ``` [Answer] **VB/Basic-229** My goal was to beat java^^ ``` Dim f Sub m() f = " 1 2 3 4 5 6 7 8 9 10" a = l(7, 10) + l(4, 6) + l(2, 3) + l(1, 1) MsgBox a End Sub Function l(b, e) r = Space(3 - (e - b)) For i = b To e r = r + IIf(InStr(f, Str(i)), "0 ", ". ") Next l = r + vbCr End Function ``` edit vbCr instead of chr(13) r = r + Space(3 - (e - b)) shorthand if use of function instead of sub sub MAIN() - > sub m() [Answer] # Java - 223 chars ``` public class Pins {public static void main(String[] args) {String s = "7 8 9 0\n 4 5 6\n 2 3\n 1";for (String arg : args) {s = s.replace(arg.replace("10", "0"), "o");}s = s.replaceAll("\\d", ".");System.out.println(s);}} ``` I used to like this way of doing it, then I realized I needed a small hack, still kind of like my solution. ``` public class Pins { public static void main(String[] args) { String s = "7 8 9 0\n 4 5 6\n 2 3\n 1"; for (String arg : args) { s = s.replace(arg.replace("10", "0"), "o"); } s = s.replaceAll("\\d", "."); System.out.println(s); } } ``` [Answer] # K, 57 bytes Not very competitive yet, but it's a start: ``` `0:((!4)#\:" "),',/'|0 1 3 6_(". ";"O ")@|/(1+!10)=/:(),. ``` Usage example: ``` `0:((!4)#\:" "),',/'|0 1 3 6_(". ";"O ")@|/(1+!10)=/:(),."3 5 7 9 10" O . O O . O . . O . `0:((!4)#\:" "),',/'|0 1 3 6_(". ";"O ")@|/(1+!10)=/:(),."1" . . . . . . . . . O ``` I begin by evaluating the input string with `.`- fortunately, space separated numbers are a valid list literal in K. By prepending an empty list to the result of eval I can ensure it's a list even in the case of a single pin. Then I create a boolean vector representing the positions of pins: ``` (1+!10)=/:3 5 7 9 10 (0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1) |/(1+!10)=/:3 5 7 9 10 0 0 1 0 1 0 1 0 1 1 ``` Then I index into a list of strings to get space-padded characters for each pin position. ``` (". ";"O ")@0 0 1 0 1 0 1 0 1 1 (". " ". " "O " ". " "O " ". " "O " ". " "O " "O ") ``` I slice that sequence into rows (`_`), reverse them (`|`) and join together each fragment (`,/'`): ``` ,/'|0 1 3 6_(". ";"O ")@0 0 1 0 1 0 1 0 1 1 ("O . O O " ". O . " ". O " ". ") ``` Now it's starting to look like the pattern we want. All that's left is to tack on some leading spaces to each row (`((!4)#\:" "),'`) and print the rows to stdout (`0:`). [Answer] # [Pascal (FPC)](https://www.freepascal.org/), 165 bytes ``` var f:string='. . . .'#10' . . .'#10' . .'#10' .';i:byte;z:array[1..10]of byte=(25,18,20,10,12,14,1,3,5,7);begin repeat read(i);f[z[i]]:='O'until eof;write(f)end. ``` [Try it online!](https://tio.run/##TchdCoMwEATgqyz0IQrbkNXanwTP0AOID1ETCYhKTFv08qntk8zAfMysl1YPZzu3Mb61ByuX4N3Yl4zDP@xEgh150A7lZLMGozapvddrRZyTqCcLv7dMsgLpjplA2pshXZAwxwJvqWpM70bwZjY67KO7xKXKVlvl6lqW7MleY3ADmMmqj3fBJDY1Y8djJMihgCs8gMQX "Pascal (FPC) – Try It Online") Takes numbers from standard input, prints the formation to standard output. ### [Pascal (FPC)](https://www.freepascal.org/), 175 bytes ``` function f(q:array of byte):string;var i:byte;z:array[1..10]of byte=(25,18,20,10,12,14,1,3,5,7);begin f:='. . . .'#10' . . .'#10' . .'#10' .';for i in q do f[z[i]]:='O'end; ``` [Try it online!](https://tio.run/##TY1NCoMwFITX9RSBLhLhVYyt/TF4hh5AXERNJCBRY9qil09T7ULeWwzDzHwDn2reneRQOydfuraq10iSMePG8Bn1ElWzFWE2WaN0y97cIJX9LLZskYJGEY3LfzAnSQr0DkkM1H8C9AIUzpDCLWSVaJUfz3IcofXwkcZ4L3fKCyZ7T0O@M6KmR7JYClWWvv7EQjfMrXvB4WOUFZ0mkhQb6goPTy/DkAU@F7kv "Pascal (FPC) – Try It Online") A function which does the same thing, taking an array of pin positions and returning a formatted string. [Answer] # [Japt](https://github.com/ETHproductions/japt) `-Rx`, ~~29~~ ~~19~~ ~~18~~ 17 bytes ``` 5ÇÆ".O"gUø°TøÃÔû ``` [Try it](https://ethproductions.github.io/japt/?v=1.4.6&code=NcfGIi5PImdV+LBUw7jD1Ps=&input=WzhdCi1SeA==) --- ## Explanation ``` :Implicit input of integer array U 5Ç :Map each Z in the range [0,5) Æ : Map the range [0,Z) °T : Increment T (initially 0) Uø : Does U contain T? (false=0, true=1) ".O"g : Get the character in the string ".O" at that index à : End mapping ¸ : Join with spaces à :End mapping Ô :Reverse û :Centre pad each element with spaces to the length of the longest :Implicitly join with newlines, trim (not strictly necessary) and output ``` [Answer] # [Vyxal](https://github.com/Lyxal/Vyxal), 43 bytes ``` `7 8 9 0 4 5 6 2 3 1`?⌈(nt\OV)‛\d\.øṙ ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%607%208%209%200%0A%204%205%206%0A%20%202%203%0A%20%20%201%60%3F%E2%8C%88%28nt%5COV%29%E2%80%9B%5Cd%5C.%C3%B8%E1%B9%99&inputs=%271%202%203%27&header=&footer=) Nothing clever, just a simple substitution. ]
[Question] [ The [Shotgun numbers](https://oeis.org/A064494) are a sequence with a rather simple definition but some interesting structure. Start with the natural numbers: ``` 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ... ``` Now take all numbers at indices divisible by **2**, group them into pairs, and swap the numbers in each pair: ``` 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... ^ ^ ^ ^ ^ ^ ^ <---> <---> <-----> <---- 1, 4, 3, 2, 5, 8, 7, 6, 9, 12, 11, 10, 13, 16, ... ``` Now do the same with indices divisible by **3**: ``` 1, 4, 3, 2, 5, 8, 7, 6, 9, 12, 11, 10, 13, 16, ... ^ ^ ^ ^ <------> <---------> 1, 4, 8, 2, 5, 3, 7, 6, 10, 12, 11, 9, 13, 16, ... ``` And then for **4**, **5**, **6**, and so on: ``` 1, 4, 8, 2, 5, 3, 7, 6, 10, 12, 11, 9, 13, 16, ... 1, 4, 8, 6, 5, 3, 7, 2, 10, 12, 11, 14, 13, 16, ... 1, 4, 8, 6, 12, 3, 7, 2, 10, 5, 11, 14, 13, 16, ... 1, 4, 8, 6, 12, 14, 7, 2, 10, 5, 11, 3, 13, 16, ... ... ``` After **k** such steps, the first **k+1** numbers will be fixed. So we can define the infinite sequence of Shotgun numbers as the limit of letting **k** go to infinity. The first 66 numbers are: ``` 1, 4, 8, 6, 12, 14, 16, 9, 18, 20, 24, 26, 28, 22, 39, 15, 36, 35, 40, 38, 57, 34, 48, 49, 51, 44, 46, 33, 60, 77, 64, 32, 75, 56, 81, 68, 76, 58, 100, 55, 84, 111, 88, 62, 125, 70, 96, 91, 98, 95, 134, 72, 108, 82, 141, 80, 140, 92, 120, 156, 124, 94, 121, 52, 152, 145, ... ``` **Fun fact:** Despite being obtained by only permuting the natural numbers, this sequence does not contain any primes. ## The Challenge Given an integer `n > 0`, find the `n`th Shotgun number. You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and return the output or print it to STDOUT (or closest alternative). This is code golf, so the shortest submission (in bytes) wins. ## Leaderboards This is getting more answers than I thought, as well as several people competing in the same language. So here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language. To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template: ``` # Language Name, N bytes ``` where `N` is the size of your submission. If you improve your score, you *can* keep old scores in the headline, by striking them through. For instance: ``` # Ruby, <s>104</s> <s>101</s> 96 bytes ``` ``` function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){$.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:true,success:function(e){answers.push.apply(answers,e.items);if(e.has_more)getAnswers();else process()}})}function shouldHaveHeading(e){var t=false;var n=e.body_markdown.split("\n");try{t|=/^#/.test(e.body_markdown);t|=["-","="].indexOf(n[1][0])>-1;t&=LANGUAGE_REG.test(e.body_markdown)}catch(r){}return t}function shouldHaveScore(e){var t=false;try{t|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(n){}return t}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading);answers.sort(function(e,t){var n=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0],r=+(t.body_markdown.split("\n")[0].match(SIZE_REG)||[Infinity])[0];return n-r});var e={};var t=0,c=0,p=-1;answers.forEach(function(n){var r=n.body_markdown.split("\n")[0];var i=$("#answer-template").html();var s=r.match(NUMBER_REG)[0];var o=(r.match(SIZE_REG)||[0])[0];var u=r.match(LANGUAGE_REG)[1];var a=getAuthorName(n);t++;c=p==o?c:t;i=i.replace("{{PLACE}}",c+".").replace("{{NAME}}",a).replace("{{LANGUAGE}}",u).replace("{{SIZE}}",o).replace("{{LINK}}",n.share_link);i=$(i);p=o;$("#answers").append(i);e[u]=e[u]||{lang:u,user:a,size:o,link:n.share_link}});var n=[];for(var r in e)if(e.hasOwnProperty(r))n.push(e[r]);n.sort(function(e,t){if(e.lang>t.lang)return 1;if(e.lang<t.lang)return-1;return 0});for(var i=0;i<n.length;++i){var s=$("#language-template").html();var r=n[i];s=s.replace("{{LANGUAGE}}",r.lang).replace("{{NAME}}",r.user).replace("{{SIZE}}",r.size).replace("{{LINK}}",r.link);s=$(s);$("#languages").append(s)}}var QUESTION_ID=47338;var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:&lt;(?:s&gt;[^&]*&lt;\/s&gt;|[^&]+&gt;)[^\d&]*)*$)/;var NUMBER_REG=/\d+/;var LANGUAGE_REG=/^#*\s*([^,]+)/ ``` ``` body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} ``` ``` <script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script><link rel=stylesheet type=text/css href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id=answer-list><h2>Leaderboard</h2><table class=answer-list><thead><tr><td></td><td>Author<td>Language<td>Size<tbody id=answers></table></div><div id=language-list><h2>Winners by Language</h2><table class=language-list><thead><tr><td>Language<td>User<td>Score<tbody id=languages></table></div><table style=display:none><tbody id=answer-template><tr><td>{{PLACE}}</td><td>{{NAME}}<td>{{LANGUAGE}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table><table style=display:none><tbody id=language-template><tr><td>{{LANGUAGE}}<td>{{NAME}}<td>{{SIZE}}<td><a href={{LINK}}>Link</a></table> ``` [Answer] # ><>, ~~52~~ 45 bytes [**Esolangs page for ><>**](http://esolangs.org/wiki/Fish) ``` 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](https://codegolf.stackexchange.com/a/47345/21487). Takes [input via a code point](http://meta.codegolf.stackexchange.com/a/4719/8478) from STDIN, e.g. `"!" = 33 -> 75`. [Answer] # 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 the lower number or the higher number in the swap, look at `n/i mod 2`. If this is 1 you're the lower number (and will swap up), otherwise you're the higher number (and will swap down). This gives us an algorithm for working backwards. Let's try it with 6, starting from the last step (step `i = 6`): ``` Step 6: Position 6 swaps with position 12 (6 is divisible by 6, 6/6 = 1 == 1 mod 2) ``` So now we know the number came from position 12. Then: ``` Step 5: No swap (12 not divisible by 5) Step 4: Position 12 swaps with position 16 (12 is divisible by 4, 12/4 = 3 == 1 mod 2) ``` So now we know it came from 16 before that. Finally: ``` Step 3: No swap (16 not divisible by 3) Step 2: Position 16 swaps with position 14 (16 divisible by 2, 16/2 = 8 == 0 mod 2) ``` Since this is the first step (remember, `k+1`), we're done and the number that ends up in position 6 originally came from position 14, i.e. the 6th shotgun number is 14. So now for the Python explanation: ``` i=n=input() Read input, and store into i (step) and n (position) while~-i: while i-1 != 0:, or since we're descending with i this is just while i>1: n+= Add to the current position... (n%i<1)* 1* whatever's next if n is divisible by i, otherwise 0* (i.e. nothing) i* How many positions n might go up/down (n/i%2*2-1) n/i%2 tell us higher/lower, *2-1 maps 0 or 1 to -1 (down) or +1 (up) i-=1 Decrement the step number print n Output ``` [Answer] # Haskell, 68 bytes ``` n#k|mod k(2*n)<1=k-n|mod k n<1=k+n|k>0=k s n=foldr((.).(#))id[2..n]n ``` Probably further golfable, especially the first row. This defines a function `s` that takes `n` and returns the `n`th shotgun number. ``` map s [1..66] [1,4,8,6,12,14,16,9,18,20,24,26,28,22,39,15,36,35,40,38,57,34,48,49,51,44,46,33,60,77,64,32,75,56,81,68,76,58,100,55,84,111,88,62,125,70,96,91,98,95,134,72,108,82,141,80,140,92,120,156,124,94,121,52,152,145] ``` ### Explanation The helper function `#` takes in two numbers `n` and `k`, and returns the `k`th number in the list defined by applying the pair swap operation to every `n`th number. For example, applying it to the first 20 numbers with `n = 4` yields this: ``` map (4#) [1..20] [1,2,3,8,5,6,7,4,9,10,11,16,13,14,15,12,17,18,19,24] ``` The result of `s n` is obtained by reducing ("folding") the list `[2..n]` by the second-order function `(.).(#)`, which takes in a number `m` and a function `f` (initially the identity function `id`), and returns a function that takes `k` and returns `f (m # k)`. For example, in the case `n = 4` the list `[2,3,4]` is reduced to a function that takes `k` and returns `id (4 # (3 # (2 # k)))`. The `id` is only needed for the base case `n = 1`, where the list is empty. Finally, we give this function the input `k = n`, obtaining the `n`th shotgun number. [Answer] # CJam, 32 bytes Just following the spec to the point. Running the instructions on a larger set so as to not affect the nth number. ``` ri:N)2#,:)N{))/2/{:)~\@}%:+}/N(= ``` [Try it online here](http://cjam.aditsu.net/#code=ri%3AN)2%23%2C%3A)N%7B))%2F2%2F%7B%3A)~%5C%40%7D%25%3A%2B%7D%2FN(%3D&input=4) [Answer] # Pyth, 19 ~~22~~ ``` u-G*H^_!%GH/GHrhQ2Q ``` A fairly naive implementation of [@PeterTaylor's golfscript answer](https://codegolf.stackexchange.com/a/47630/31625). [Try it online here](https://pyth.herokuapp.com/?code=u-G*H%5E_!%25GH%2FGHrhQ2Q&input=100) This uses the same tricks to convert a while loop into a fold as the other Pyth program below does. --- ``` u+G**H!%GHty%/GH2rhQ2Q ``` A naive copy of [@Sp3000's](https://codegolf.stackexchange.com/a/47345/31625) algorithm translated to Pyth. [You can try it online here](https://pyth.herokuapp.com/?code=u%2BG**H!%25GHty%25%2FGH2rhQ2Q&input=5) Uses reduce (python's name for fold) to emulate the while loop. It enumerates over the `range(input, 2)` which in Pyth works out to `range(2, input)[::-1]`. The other Pyth-related golfs involves using `not` instead of `<2` and using `y`'s hidden mode of doubling the value of numeric arguments. [Answer] # Ruby, 92 bytes ``` def s(d,n) d==1?n:s(d-1,n%d==0?n+(n%(d*2)==0?-d :d):n) end n=ARGV[0].to_i print s(n,n).to_s ``` My first code golf effort. Not based on any other answer. --- Now that I've looked at some of the others though, I notice that most just define a function, not a complete program that accepts input and produces output. The OP asked for a complete program with input and output. Is it customary to ignore such requirements? --- # 84 Bytes ``` n=ARGV[0].to_i d=n while d>1 n+=(n%d==0?(n%(d*2)==0?-d :d):0) d-=1 end print n.to_s ``` After looking at other answers and realizing that an iterative solution is possible. [Answer] # Python 2, ~~97~~ 79 chars ``` g=lambda n,k:n>1and g(n-1,k-(k%n<1)*n*(-1)**(k/n%2))or k n=input() print g(n,n) ``` It determines for each index the correct value by recursively chasing the number backwards. The algorithm was independent discovered. edit: Now it only prints the `n`th number instead of the first `n` numbers. Of course an iterative approach would be shorter, but I don't want to copy Sp3000's code. [Answer] # Haskell, 79 bytes ``` 1#i=i s#i|i`mod`(2*s)==0=(s-1)#(i-s)|i`mod`s==0=(s-1)#(i+s)|1<2=(s-1)#i p n=n#n ``` Usage: `p 66` which outputs `145` Not much to explain: The function `#` recursively calculates the shotgun number at position `i` of step `s`. `p n` returns the number at position `n` of step `n`. [Answer] ## k, 41 bytes `{{x+$[y!x;0;$[2!_x%y;y;-y]]}/[x;|2+!x-1]}` ``` / apply to an int {{x+$[y!x;0;$[2!_x%y;y;-y]]}/[x;|2+!x-1]} 42 111 / apply to 1 through 66 {{x+$[y!x;0;$[2!_x%y;y;-y]]}/[x;|2+!x-1]}'1+!66 1 4 8 6 12 14 16 9 18 20 24 26 28 22 39 15 36 35 40 38 57 34 48 49 51 44 46 33 60 77 64 32 75 56 81 68 76 58 100 55 84 111 88 62 125 70 96 91 98 95 134 72 108 82 141 80 140 92 120 156 124 94 121 52 152 145 ``` * `{...}` lambda, x and y are the implicit 1st and 2nd argument * `$[b;t;f]` ternary operator, evaluates b followed by t/f respectively * `b!a` a modulo b * `_` floor, casts the result of the division to an int * `%` division * `{...}/[x;y]` prime {...} with x and apply over the list y, is equivalent to f[f[..f[f[x;y0];y1];..yn-1];yn] * `|` reverse * `!` iota function, generate list 0 through n-1 [Answer] # Common Lisp, ~~113~~ 91 (iterative: 91) ``` (defun s(n)(do((r n(1- r)))((= r 1)n)(if(= 0(mod n r))(incf n(* r(if(oddp(/ n r))1 -1)))))) ``` (original, recursive: 113) ``` (defun s(n &optional(r n))(cond((= r 1)n)((= 0(mod n r))(s(+ n(* r(if(oddp(/ n r))1 -1)))(1- r)))(t(s n(1- r))))) ``` ## Example With the recursive version: ``` (trace s) (s 10) 0: (S 10) 1: (S 20 9) 2: (S 20 8) 3: (S 20 7) 4: (S 20 6) 5: (S 20 5) 6: (S 15 4) 7: (S 15 3) 8: (S 18 2) 9: (S 20 1) 9: S returned 20 ... 1: S returned 20 0: S returned 20 ``` ## Tests Checks and measures for iterative version: ``` (let ((list '(1 4 8 6 12 14 16 9 18 20 24 26 28 22 39 15 36 35 40 38 57 34 48 49 51 44 46 33 60 77 64 32 75 56 81 68 76 58 100 55 84 111 88 62 125 70 96 91 98 95 134 72 108 82 141 80 140 92 120 156 124 94 121 52 152 145))) (time (loop for r in list for n from 1 always (= r (s n))))) => T Evaluation took: 0.000 seconds of real time 0.000000 seconds of total run time (0.000000 user, 0.000000 system) 100.00% CPU 807,160 processor cycles 32,768 bytes consed ``` [Answer] # Mathematica, ~~53~~ 49 bytes ``` (For[i=n=#,n>1,--n,If[n∣i,i+=Mod[i,2n]2-n]];i)& ``` I decided to golf my reference implementation. The `∣` is the Unicode symbol for "divides", and counts for 3 bytes. Otherwise, this uses the same algorithm as everyone else. It defines an unnamed function which takes `n` as a single parameter and returns the `n`th Shotgun number. [Answer] ## GolfScript, 27 chars ``` ~.,(~%{):i\.@%!~)1$i/?i*-}/ ``` ### Explanation If `f(i, n)` is the value at position `n` after `i-1` transformations, we have ``` f(1, n) = n f(i, n) = f(i - 1, n % i == 0 ? (((n / i - 1) ^ 1) + 1) * i : n) for i > 1 ``` where `^` denotes bitwise xor; given input `n`, we want to compute `f(n, n)`. The conversion from a recursive function to a loop is uninteresting; what is interesting is the way in which ``` n % i == 0 ? (((n / i - 1) ^ 1) + 1) * i : n ``` can be rewritten. The more obvious approach is to say that it must be ``` n + (n % i == 0 ? i : 0) * g(n / i) ``` for some `g`. Obviously `g` alternates between `1` and `-1`, as the positions swap alternately up and down; since `g(1) = 1` (because `1` swaps up to `2`), we have ``` n + (n % i == 0 ? i : 0) * -1**(1 + n / i) ``` where `**` denotes exponentiation. The final savings come from rewriting this as ``` n - i * (n % i == 0 ? -1 : 0)**(n / i) ``` ### Dissection ``` ~ # Evaluate input to get n .,(~%{ # For n-1 downto 1... ):i # Let i be that value + 1, so for i = n downto 2... \.@%! # Find n % i == 0 ? 1 : 0 ~) # Negate 1$i/? # Raise to the power of n/i i*- # Multiply by i and subtract }/ ``` [Answer] ## CJam, 24 bytes ``` l~__(,f-{_Imd!~)\#I*-}fI ``` [Online demo](http://cjam.aditsu.net/#code=l~__(%2Cf-%7B_Imd!~)%5C%23I*-%7DfI&input=11) This is a port of [my GolfScript answer](https://codegolf.stackexchange.com/a/47630/194), borrowing the loop from [Martin's CJam answer](https://codegolf.stackexchange.com/a/47623/194) and exploiting CJam's `divmod` operator. ([I said](https://codegolf.stackexchange.com/a/16987/194) it would be useful!). [Answer] # Julia, ~~61~~ 57 bytes ``` n->(i=n;while~-i!=0 n+=(n%i<1)*i*(n÷i%2*2-1);i-=1;end;n) ``` This creates an unnamed function which takes a single argument `n` and returns the `n`th shotgun number. To call it, give it a name, e.g. `f=n->(...)`. Examples: ``` julia> for i = 1:10 println(f(i)) end 1 4 8 6 12 14 16 9 18 20 ``` Currently this is based on @Sp3000's awesome [Python answer](https://codegolf.stackexchange.com/a/47345/20469). I'll revisit this soon because there must be a shorter way to do this in Julia than what I've done here. Any input is welcome, as always. [Answer] # GML, 76 bytes ``` n=argument0;i=n;while~-1{n+=(n mod i<1)*i*(n/i mod 2*2-1)i--}show_message(n) ``` [Information about GML](http://en.wikipedia.org/wiki/GameMaker:_Studio#Scripting) [Answer] # CJam, ~~28~~ 27 byte So this is slightly embarrassing... before posting this, I tried golfing this myself and got to 30 bytes in CJam. None of the existing answers have beaten that yet. In the meantime I also managed to shave off three more bytes. There *is* a shorter Pyth solution in a comment, but nothing shorter has been posted in an answer, so here it is. Maybe it inspires the APL/J people to try a bit harder (or someone actually post the Pyth solution), before I have to accept my own answer. ;) ``` l~__(,f-{_I_+%_+I-_zI=*+}fI ``` [Test it here.](http://cjam.aditsu.net/#code=l~__(%2Cf-%7B_I_%2B%25_%2BI-_zI%3D*%2B%7DfI&input=100) ## Explanation ``` l~ "Read input N and eval."; __(, "Duplicate twice, create range [0 1 2 ... N-2]."; f- "Subtract each from N, giving [N N-1 N-2 ... 2]."; { }fI "For each element, storing the element in I."; _I_+%_+I- "Compute 2(N % 2I)-I - the shuffling offset"; _zI= "Check that this offset is ±I."; *+ "Multiply the offset by this boolean and update to N."; ``` [Answer] # J, ~~34~~ 32 bytes ``` (]+[*(1-~2*2|%~)*0=|)/@(_1}2+i.) ((]+[*(1-~2*2|%~)*0=|)/@(_1}2+i.)) every 1+i.20 NB. running with inputs 1..20 1 4 8 6 12 14 16 9 18 20 24 26 28 22 39 15 36 35 40 38 ``` Will try to golf it a bit more and add some explanation later. [Try it online here.](http://tryj.tk/) [Answer] # TI-Basic 83/84, 40 bytes ``` Input A:For(I,A,2,~1:A+(AfPart(I/2)-1)I(1>IfPart(A/I->A:End:A ``` [Information about TI-Basic](http://tibasicdev.wikidot.com/home) [Answer] # Ruby, ~~57~~ 47 bytes This is essentially [Sp3000](https://codegolf.stackexchange.com/users/21487/sp3000)'s Python solution (with [xnor's suggestion](https://chat.stackexchange.com/transcript/message/20478433#20478433)) translated to Ruby. I could probably golf it down in a few places though. ``` ->n{n.downto(2).map{|i|n+=i*(n/i%2-~-n/i%2)};n} ``` [Answer] # [Stax](https://github.com/tomtheisen/stax), 13 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax) ``` ╠¼│σ╣Gp☺πΩ■φ├ ``` [Run and debug it](https://staxlang.xyz/#p=ccacb3e5b9477001e3eafeedc3&i=1%0A2%0A3%0A4%0A5%0A6&m=2) Same idea as Peter Taylor's answer, and almost the same code. ]
[Question] [ ## Introduction We all know prefixes and suffixes. But there are other types of affixes that exist too. Such as circumfixes, a type of affix that has two parts, one of which is a prefix and another of which is a suffix. Figuring out whether some string is a prefix or a suffix of some other string is easy, but what about figuring out whether it might be a circumfix? That is today's challenge - create a program or function which takes two strings as input, and determine whether the first is a circumfix of the second. For the purposes of this challenge a string `i1` is a circumfix of another string `i2` if and only if there exists some non-empty string `j` which is a contiguous substring of `i2` such that removing `j` from `i2` results in `i1`, and `j` is neither a prefix nor a suffix of `i2` (if it is, you don't have a circumfix, you just have a suffix or a prefix respectively). For example, `"fog"` is a circumfix of `"frog"`, because removing `"r"` from `"frog"` produces `"fog"`. When given valid input, your program either needs to output a single consistent value of your choice if the first input string is a circumfix of the second, and any other value if it is not, or vice versa. For example, you may decide have your program output `6` when the first string is a circumfix of the second, in which case *any* output except `6` is acceptable when it is not. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so do make sure to golf your code. ## Test cases ``` Format: "String 1", "String 2" -> output comments about the test case - in all these test cases, the output will be true if string 1 is a circumfix or string 2 and false otherwise ``` ``` "apply", "appreciably" -> true "app]reciab[ly" "rake", "racket by the lake" -> true multiple options - "r]acket by the l[ake" and "ra]cket by the la[ke" "trout", "trumpet" -> false Doesn't work at all "bring", "brought him a gong" -> false You only get to remove one substring - "br]ought h[i]m a go[ng" is not allowed "falcon", "false conundrum" -> false You can't have extra stuff at the start or end either - "fal]se [con(undrum)" is not allowed "goose", "goosebumps" -> false "goose]bumps[" is just a prefix "lame", "blame" -> false And "]b[lame" is just a suffix "pale", "pale ale" -> true "pale] ale[" is just a prefix, but "pal]e al[e" is a circumfix, so this is allowed "b", "barb" -> false This could be a prefix ("b]arb[") or a suffix ("]bar[b"), but not a circumfix - "b]ar[b" is not allowed "abba", "aba" -> false "abba" can be split into a prefix of "aba" ("ab") and a suffix of "aba" ("ba"), but "abba" is still not a circumfix of "aba" "friend", "friend" -> false It's only a proper circumfix if you actually remove something - "fri][end" doesn't make the cut "float", "on" -> false You may not assume the first input will be shorter than the second one "", "" -> false One or both input strings may be empty "Twin Sister", "Twister" -> false Inputs are ordered - you may reverse the order, but there must be a consistent ordering "case", "Castle" -> false Inputs are case sensitive "<<@ 23|>", "<<@23??|> 23|>" -> true "<<@]23??|>[ 23|>", not all characters will be letters) ``` [Answer] # [J](http://jsoftware.com/), ~~23~~ ~~21~~ 20 bytes ``` >&#*]e.1}:@}.-&#]\.[ ``` [Try it online!](https://tio.run/##VZBLa8MwEITv@RVLAxENjcnjZhInEOipp7a3NoeVIz8a2TKSQgkkv91dr3qQD4LZmU/SSD/9UyIK2KUg4AWWkNJaJHB8f3vts9l0flLJ6pEeHsliNj19J1/980TllYEV7EBg11mV1yj1TUABbJCMCIv5RXmQN/CVAo0XNYBkDyJwy4Hz9tp0ynPorbl6EYWSjLLyUNUNIJSmLZmTtiYVcQVqpyA37bU903kMkUdGTJXGOCXpOscAj6PbNDahJYvoMR1qBbQ4HIbRNrQy1IpdlMgmShJxVVur9hwaBhmF1JcDbXD0D@xGBojP39p5ZTkg3cJHmKNNR3T@v3KObvSe7faw3uz39wzWm3vGCFlhmPR/ "J – Try It Online") *-1 byte thanks to Bubbler* Return true if: * `>&#` left arg is strictly longer than right (see the "friend"/"friend" test case) * `*` and... * `]` the right arg * `e.` is an element of the list formed by... * `1 }:@}.` removing the first and last elements of... * `-&# ]\. [` all the [outfixes](https://code.jsoftware.com/wiki/Vocabulary/bslashdot#dyadic) `\.` of the left arg `[` whose size is the difference in size between the two args `-&#` That is, J has a builtin to subtract the "chunks" in the middle of the necessary size and leave us with the remaining prefixes and suffixes, catted. We simply have to remove the non-proper ones (ie, the first and last elements of the list of outfixes), and check for what we're searching for. [Answer] # [Python3](https://docs.python.org/3/), 86 84 83 80 77 76 bytes ``` lambda a,b:len(a)<len(b)*any(a==b[:i]+b[i-len(a):]for i in range(1,len(a))) ``` [Try it online!](https://tio.run/##NcmxCoUwDEDR3a8ITsmzDuJWXr9EHBKsGqhRiotfXxFxuhfOcZ3rbn0pCQIk3mRiYCc@RUOm/xOhH9uFHIIMXsdGBm1f9uO8Z1BQg8y2ROzcC0TVkdVOTFjPWaNNtfuGqJQb) -2 bytes thanks to [@Value Ink](https://codegolf.stackexchange.com/users/52194/value-ink) whitespace before and after `==` -1 byte remove whitespace. -3 bytes thanks to [@ovs](https://codegolf.stackexchange.com/users/64121/ovs) using any to write for loop in one line. -3 bytes by replacing `and` with `*` -1 byte by replacing def with lambda # Python3.8, 71 bytes ``` lambda a,b:(c:=len(a))<len(b)*any(a==b[:i]+b[i-c:]for i in range(1,c)) ``` [Try it online!](https://tio.run/##NcYxDoMwDADAva/wht2mA2KpouYliMEOobVETWQxwOtTdeh0V8/9vdnwqN7aAQlW/sjMwEEi5pjWYshEz59CV7YTOSUZo043GfWe47RsDgpq4Gyvgn3IRJfqajse2C2uxeYu/EPU2hc "Python 3.8 (pre-release) – Try It Online") [Answer] # [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 17 bytes ``` ^(.+)(.+)¶\1.+\2$ ``` [Try it online!](https://tio.run/##JY1BasNADEXX0ilm0UJKIFBnG5JCj5AuQ6nkyOMh4xkzI1MMOVcP0Iu5crrQ@18f9FVEQ6LleXP@guVzs9u@rPP7c3ndbS/N07LQOMYZjEXaQBxnLHQTKNTeRB3PTntx0SLUkicFLdMwiiKXkDywZb5X14fBkfM5eewotjmBSRVnbkpXO0GfcxV4kK2hYqRBgFfiSFFghbNBBqbCSMwExIRdCZKu8C/YxUwKOeHHd0juHKpKAfOrYkv2452qWs3h8Oaa/f0IZpr96XQ/PtY/ "Retina 0.8.2 – Try It Online") Link includes test suite that takes each test on its own line with the test values separated by a tab and converts them into individual tests with the values on separate lines as the main program expects. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes ``` ⁻ȧŒṖḢ;ṪƊ€iɗ ``` [Try it online!](https://tio.run/##LY@9TsNAEIRf5eQ6VVISJUiUlNAgy8Wec9hHzj86n4UspYGSkgIQEg1NJMQDEEGHEsFjOC9iZjcU9sx@c@dZXxnnumHY33z@rLf3/eah/3g96jdvu7v97bv9fRz6zTPc93r3Atl@8ZknuFM8F8MQxxHVteuiEas3qSWNKRnFkaelAfaULk1QulMhN8ox5DT4qg2Ig2@L2gRh2tsyA9PIsjyo3BaKVFYBcnxJLq1K5DCNUfBtucB1CbOqarhOVOObjWBHBVMtyqAmx4BFsZVePkFey0BaE/8N3lLqrSkXXHowwlxFvDuW4RFO9PzalurMNsF4IEziOElJdjuhJvxXTqfHajxZzUBhx5P5fDU7gCT5Aw "Jelly – Try It Online") Takes string 1 (the potential circumfix) as the right/second argument, string 2 as the left/first argument, and outputs 0 if it's not a circumfix and a positive integer otherwise. (The test footer is bad, but it's better than nothing.) ``` ⁻ The arguments are not equal, ȧ and ɗ you also get a truthy value from the next three links: i the index of the right argument (defaulting to 0) in ŒṖ the list of all partitions of the left argument € with each partition mapped to Ḣ;ṪƊ the concatenation of its first and last elements. ``` Although this is mostly just a translation of my Brachylog answer, `ŒṖ` cannot generate empty elements of partitions while `c` is obligated to, so prefixes and suffixes are naturally accounted for. This 15-byte monstrosity is what I had before I just tried putting the `⁻` at the start of the program... and before I realized I could use `Ḣ;Ṫ`: `ŒṖ1,0ịFƊ€⁸ṭṚi>1` [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), ~~13~~ 12 bytes ``` ~c₃{b&}ᵐ↺b↺c ``` [Try it online!](https://tio.run/##LY@xboMwEIZf5eShU9SBrFFSqY/Qbojh7DhgxWBkjGiUpEMrRXTrW7RjlwzN2DeBF6F3Tga4//9@m/@QHlWxsy5Ppn3RCTANiG61H08/49v7cO7/fsf@W1QuED6O/ZdAUMarttyYF3AbPhw6cS@Gy8dxOH9Or4ru7eUdm/F0kfSoaUpTgXVtd2LG02tlUJLLZqnwuNWEaY2tDiB3EAoNliGnwbs2UBx8W9Y6RCa9qXJikrK8CFCYEhByR5DjDVrlKspJNBpIt9Warscwd67hujglfbOJ2GLJVMbJoEbLgAewjL18Ar2MBqVE/ht6x1JvdLXm0quIzDrk3WkZtqTifO5MBU@mCdoTIhcVJwrjbo/YhFvlYvEAyfywJEoyma9Wh@UVZNk/ "Brachylog – Try It Online") Takes string 1 (the possible circumfix) through the output variable, string 2 through the input variable, and outputs through success or failure. ~~I recall that at some point my original solution could be [12 bytes](https://tio.run/##LY@xTsMwEIZf5eSBqWJo16pB4hFgqzKcXTex6sSR4yhEaRlAQmXjDTpSNpYOMPImzYuEO7eL//@@38l/lh5V3lmXTcc@bwWYGkSb9MPb9/Dyej7t/36G/VGULhDeDftPgaCMV02xNk/g1nw5tOJWnH/fd@fTx/isennDbjgccxWGw9c4LpcCq8p2YsLqtTIoaUonS@FxownTEhsdQHYQcg2WIafBuyZQHHxTVDpEJr0pM2KSsiwPkJsCEDJHkOM1WuVKysnUGsg35Yo@j2HmXM11USX9s47YYsFURmVQoWXAAmxjL99AL@OAUiK/hs5Y6o0uV1x6MZFZh7w7LcMjuaiPrSnhwdRBe0I0RceJwrjbPdbhWjmf38F0tl0QJTudJcl2cQFp@g8), but as of now subscriptless `c` seems to cycle through all partitions infinitely, causing false test cases to not terminate~~ except it would also cause false positives where the two inputs are equal. (I tried golfing `{b&}ᵐ` to `Xz∧X` (when it's already a shorter alternative to `{l>0&}ᵐ`), but it has a false positive for the empty test case, since there's no problem cycling an empty list to the length of the longest when everything is empty.) ``` ~c₃ Split the input variable into three parts, such that { }ᵐ each of them b& can have its first element removed (i.e. it is not empty). ↺ Rotate the list of partitions left, b remove the first element (which was in the middle), ↺ and rotate the remaining partitions again. c Do they concatenate to the output variable? ``` [Answer] # Regex ([POSIX ERE](https://en.wikibooks.org/wiki/Regular_Expressions/POSIX-Extended_Regular_Expressions) or better), 17 bytes Takes the two strings in joined format, delimited by a single newline. ``` ^(.+)(.+) \1.+\2$ ``` Turned out to be identical to [Neil's Retina answer](https://codegolf.stackexchange.com/a/194937/17216), so I'm mainly answering this to demonstrate it in a wide range of regex engines: [Try it online!](https://tio.run/##dVXbbuM2EH3PV0y9RSTmouxmiz6s10mLbgu0D12gyUuhqAAl0RYTShTIURxtt9@ezpCKHSdeA7YoDuecMzf6Vt5LXznd46nvda1ca7s7NT66RafW8Jda/frQp@mXxcXZ0eM/aXYs@Htw8y47vjn//vHo7IvI0F6h090qFZk3ulLpjyenPwgxX1qX6sXbeWoWTsna6E6lQny36AZj5nrxTvyrl6kWPfliKuYHJjOqW2FzeGjyt8VikcySw8N@QI8uTf@4@vxn1kvnVZrkybHJnOqNJLKzN9nR2UmSiOOkSER2a3WXJjddIkTWSqya1InL5NoN6gNA8iH5TRpPy0TMJ2Qj5v89zmTfm3F2ArxwqtKypFeYPm8AyR9SNhbRmpNZHMycvFPs5WR1pxDKEbBRYHh369YOBnVvFNgete08nJJDseuRBxfZ1YxV7ILlZCIudHZAJiPUtle4kRclLjkwSD9Z5bsEYW3dHUgEaQz5llwf9i0JZNUgNLoFCStLu1vfv@0AtjMjrIgeLTjV2nuS3SnwQ@lDkVl86YoJJddFxMkZSHvobKC0a1UTLeFWtmPeyEAvQ1eT/NlzyUxbSRbdSKJTD@gkeByWSw6Ac@BROgTrQFGClKYtxzrIvyCAnGDTiCv2iFhZ60ORwqKk3PnZ67xFaxHMeUC5HTzBALXDUj8QjpFtgCnDAnY/G5yfuYQF9Uc4tIXxFE6A6aUJMPwEXu/CTJ3G1oLNe7ScQDlgACgYIY88EirtqqENB7ylvNEm728SUQb10pUvxe8EcM1@lR1MDaXacJKksiDXfCa4Dk/x0HZBiHk5E1FVSP1WSeiWIhx4XRhZljKMHD2@rSce4wZhPb43GoEuDLuVZpcTBp8lfTxFG4HPjPQ7qZwwSZFHbcwr1U9O3MJOU9OFFo6rvSJ/x8TH0WFVtqf@3KLpJYzU4rLCgYIfn8bK21ZRkeJIEXiRB/h6GuCWboTQ/NWArMNYGaaf5unbyeJRauUYA/J@aCPEUjvPWaMrD9YcMGeysQ5JJzaU2TBkiuao5mknOmba1ya7dJ/pZqBuKC02E3q8JHwQQSSq7XEkuOu17uBKeyJkZHoNy5dZZAjqWMeo9FekakrNOIXk1L2i2z9IDdZYSr4LFLQ8H6FdKQbP4B3GU6SG@CsZr4BfpEfzcnj38bMDZYSwUN9zQj5@/AnO33@9YBRan7@/vPx6EXeejS1ZimjKn05PPQ9VI@lfgqL2mxIYhfwu/gc "JavaScript (SpiderMonkey) – Try It Online") - ECMAScript (SpiderMonkey) [Try it online!](https://tio.run/##dVVdb9s4EHzPr1ioh8q6OGqTvsV1cof7ANqHK3DJy0HRoZRE20woUUdScYy2vz03S/ojThwDtikud2a4nKVuxb1wtVW9P@lMIx@dF9bLZvp@Yqd/y/kfD/3oylvVzXMrll8f/x3lxxl/j25O8@Obs58ev@ZOq1qOTscnp1k2sfK/QVk5Sq0UjVadTLO8xtjLT52Xdiaw9Jvq@sGf99bU0rnc@UZ1P7LcdKM0ZIz19OLbEdFaC719S0/WmsHnS6s8OG66NJtslk1PJ8jRxftyOk2T9NWsz1df/sp7YR0AivRY51b2mmW9e5P//G6cptlxWkL1rVFdpMhb4evFyGaXybUd5DlRcp78KbTDMMmY9SCRziY/ssdE9L1eJWPigZW1EhUeaf15Qx6INOJgGaMFwtlRYsWd5Cwr6jvpqVqRX0jSPLtLawftVa8lmd4r0zk6QUK5n1GEFNE1jFXugxUIgctbqGYyoLa99Ft5UeKMt0qj3410XeppaewdCU9Ca@RWbA7OrQAyX3haqJYEzQ1md7n/mIFMp1c0B703ZGVr7iG7k@SGygWHsfjKlmuUQpURp2Ag5agzgdIsZQNa4NamY97IgIehayA/eSqZaWvBohcCdPLBWwG/DLMZb4BrEMxDxpJEgaTClGUdyC8BUAB2FHGzAyLmxrhwSGFQoXYueVm3GC1DuAgot4MDDFwjZ@oBOFq0AaYKA9r/bHF@5SMs4Y@waAfjsJ0A0wsdYPifeLwPs3YaR0sOH9AypmrwAaBkhCLyCKqVrYc2LHAGdcMkz28LUQX1wlbPxe9t4JrzajPohiq55YSkqkRqkWR8Dpv9YLoEYlElWVQVSr9TEtxShgUvD0ZUlQgth7/X9cRlbBDW43qtPKkO7txKM7M1Bq@FPu6ircAnQfyuVa4xoch5pfUL1ZsktrBVMF2wcBwdFPnJpy62DqsyPfy5Q1MzWsHiovYDNr/atJUzrcQhxZYCeFkE@GbdwC1uhGD@evCsQxsRuh/99HqxuJVasYobcm5oI8RMWcdVw4VOS94wV3JhcCFbxFHZ0GQSfdRwt4OOmQ7ZZJ/uC24GuKEyfrFGj5eECyJAItverwB3vVQdXSkHQkbGYxg@ryJDwLGWURtp8VY5CaVjNCvvJV4HQWqIxqPku0BSy/0R7Io9OAbvfFwFNeCvRbwCfhPO6@fNe4ifE1ARYHl1zwX5@PEXOvvw/YJRMD77cHn5/SLOPGlbRMoYKjar156neiHwlsCu3fYItPT8nP0P "JavaScript (Node.js) – Try It Online") - ECMAScript 2018 (Node.js) [Try it online!](https://tio.run/##dVVNb9s4EL3nVwxcAbK2qR2n2EucjwabXWD30B6ay0LRGpRM22ooUSGppIbr/vXsG1K248Q1kJjkzLz3ZjhDN9Ko359bK@mfr18@j6laUmTGtFK6EIqi4Rjbi/Ob69vry/XRTJt@VF6cjM8vx/geJSsqZzhJVo0pa0e9u7o3XlOk6IJsm1sH98nxh9HxKJEPbKSrF@cnsCR0RtFkfEQAov7GpmDjkLgXJ6voAWiRghAsfpIdvhv8NmRdAudTWeipnHyzuqY4jQfRwy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q6re8Syso6r1iL3e06YK1ka66HTl6hsGDK8sVE5TDvCcaTX2mQ33AXeDOiG3PhyTe9fEi6IQBBVt34F3NV91dC3yiEgk/EYls@ryAh0rGXqQlm1QGlW65SsulPW9fkEa3@V/C5QVPN8hHZFDo7hje9PQQ3iF7J/BfyJHxf9fHhfi88OqAhYvrrjgpye/k7HH358ZArWxx9msx8f@50nYwtL2puSx9PrnqeilPiVQNZucwVaeX6O/wc "PHP – Try It Online") - PCRE2 (PHP) [Try it online!](https://tio.run/##dVVtb9s2EP6eX3Fjg0ZKHSF2sS9xnWTINqBAiwJLhmGQVYCSKJsLJQokZcdw8tuzO1K248QRYJvi8Z7nuTe6sGeFNuK54bWwLS8E3K6sE/W6s7KZwZ14cMlfYtYpbv54aI2wVurGjgvFrYV6bR13soCFliV857KBKF4vuAE7uWbPP6PkU0yfo@kw@TQdHT@zMRnNpBFLQFTxENnktsutM0gWDQc2@SaamZufjeKBt/9oHfElN7pupRJl7AHaFwDXjLEourqYTpPH9CdjWXwaMwanAzg9bMCtD8lpfMXiceAFNa60iWTjoJqcjyM1uUFKrQQGzstvshFRHP8yaTqFByfDeC2rqLo8jzen/jHSiXBsfAQgK4hUH8flr/DxI6j0PJtMTthJjGb/7LlGbH3@tB4@sYFJvtrv3BXzKBQheSf9iQ89@bsRtuCtiFrcaBUWL1IDdjycNscjFscY4p3pxAUAu2B/cmVxyQbKixT4dkCFNz/h88x426oVGwAtjCgkz/G1lw8fwCEyRGTMgjVFc3zEDL8X5GV4cS8c5CtwcwGKdndudaecbJUAHcoLZ@iQ7Xuk3oU3JWFl@2ApmpDLGd05IkPUuhVuKy9IrChkiH7XwjYnDpba3AN3wJVC35wqT745gszmDuayBg4zjbs73391B7pRK5ghvdNgRK0XKLsRYDdtS@Jzk/UoqcwCTkpA0kKjPaVeYvMeMcQtdEO8gQFfuqZE@eylZKItOImec6TDJjAcrOuqigKgHODcGQfagMAECYlbhnSgf4YAKcJGATc@IGKmtfVF8oscc2fZ27wFa@bNqUf5r7MIA9gOlXxAHIV3hk@hX8D@s8X5jUqYYX/4QzsYi@F4mJYrD0O/QOt9mL7TyJqR@YCWAeSd8wAZIaSBh0MhTdHV/oDVmDfcpP1tInKvnpv8tfi9AO7Ir9CdKiEXW06UlGfomrKY6rCJB7czRExzFgdVPvU7Jb5bMn/gbWF4nnM/cvjzvp5wjBqE9NhWSQd4eemdNF31GHQW9dEUbQW@MOJ3r7LHREXWSaXeqN44UQsbiU3nWzisDor86k5sGB1SpVvszx0aXpErbHFeuA6DX23GyupaYJHCSCF4lnr4sh/gGm8E3/xF50iH0txPP87T@8miUar5KgRkbVcHiEoaS1lrMfYlBUyZnGvjUKebY2b9kAmco5KmHemI6VCb7NP9wJsBuyHXbt6jh0vCehFIIurWrRDubol/lrcSb3lDyPjql6@zSBDYsYZQS2FEialZ9SEZsRDGhni8NZSS7gIBNc2Hb1eMwRJ448IpVIP8BQ9XwA23Tr0e3kP85IAZQSwnF5SQL1@uYfT58ZJQcD36fHX1eBl2XowtWrJgSjen@56HYs7xXwKjttsSKOHoPf4f "C# (.NET Core) – Try It Online") - .NET (C#) [Try it online!](https://tio.run/##dVZtb9s2EP6eX3FVi0ZyEzVNv9V1s25rgQHrNiz9MsgqQEm0zYQSVZKKY6T57dlzpPLixDWQiLzjPffc8e6kM3EhDs@a8xvV9sZ6OsM@VyafTOmhZPBK75RZuZSXrOmHSquaai2coy9CdXQ1ipwXHo8LoxpqoUhPvVXdkoRduqLMyK@sWTv6dFnL3isDwz2iz0pLWsw6uQ7LNMlr08gc@iSb/josFtLK5l8pGmmpCse2hemt5bhdZNl09OsO/HS9Yvw0dbMKIYjmT9XJNMuezbpB60wtUpfL74PQLk1eTyaTJMuuto9GhDT1OwGugODvEADwGggVzp1P3avZ/rzb56efXkfZ9T/Ce2k7srNxhWjbnh24bIpsnNai6xCp6vrB04w4uFGWnm6cl22uugzX03lSs6MpjfGF8/lKuL/kpQc9uiIwU89mR9loZqDvkRavu5QBZm/YHzzGXGk4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@vjtycmPD1HyoG2hKaOquD091jzxixYlgBjurkBL/mxw2f8 "Java (JDK) – Try It Online") - Java (JDK) [Try it online!](https://tio.run/##dVVNb9s4EL37VwzUApIa10jSm7fuB1ossKcemstC0QKURFtMKFEgqbgC@t@zb0jFjhPXQCKKM/Pem@EMNUy@Nf31o@oGYz25yS2tXN450y8sbcgmSfL4X7a6yPlvcXu1uri9fvuI3eJq/f6q/IvU5nKxNZY0qZ7DV843ql8viNSW1JoGq3qf5fy@uYq7WvaZzkn0DekivgBqs0lv@3RNeqOLS8Y@43zJXgmcZiIz@tXeKi@z5MaOck2UcIyVq074us3skhh0dWdUn3FSK21E47K0SC/g5MYqS9@s3qXLNF3q/CIt0zzPSWonKflb4LGmhKW/otP5YyKGQU/JknhhZa1EhVeaf2/IQxBlbCyjtYA5XyRW3EuOsqK@l56qiXwrSfPuMawbtVeDlmQGr0zv6D0CytOIIoRwYYBVnoIVMIHLW0hmMqB2g/QHeVHillOk7LuRrk897Y29J@FJaI3YCge349gKILvWU6s6ErQz2D3G/mtGMr2eaAd6b1D6zjxAdi8J1XWeQVh8ZcsZpVBlxCkYSDnqTaA0e9mAFri16Zk3MuBl7BvIT55LZtpasOhWgE7@8laQ8@N2ywlwDZwX6Gc0pkSBpMKWZR2ILwFQADaLuPkZETtjXDiksKhQO5e8rlu0lsFcBJS70QEGPS@36hdwtOgCTBUWdPo74HzlIyzRH8HpCOOQToAZhA4w/CRen8LMncbWks1ntCypGn0AKBmhiDyCamXrsQsOzqBu2OT9QyGqoF7Y6qX4kwRuOK42o26okgdOSKpKhBZJzufwlA@2SyAWVZJHVaH0RyWhW8rg8PpgRFWJMHJ4/FlPdOMGYT1u0MrjdkJ3HqSZ7YzBvkm8Xg4Cnxnxf1Y5Y0KR80rrV6qfgriFrULThRaOq7Mi//Gpi6PDqsyA/jyi4RKb0OKi9iOSn57GyplO4pDiSAG8LAJ8Mw9whxshNH89etaByy5MP@bpz8XiUerEFBNybuwixFZZx1UbkPueE@ZKtvhGQKdvUdkwZBJz1PC0g46ZzrXJKd0P3Azohsr4dkaPl4QLIkAiu8FPgLvZ44PyUzkQMjJew/JlFRkCHWsZtZFWNijNNKdk5YO0LuYTrPEo@S6Q1PF8hHZFDo7Bex@9oAb8tYhXwDfhvH45vOf4OQAVAZZXD1yQjx@/0PWH358YBevrD58///4Ud56NLSxlNBVP3nPPU90KfCWQtTscgZae3/P/AQ "Python 2 – Try It Online") - Python [Try it online!](https://tio.run/##dVVRb9s2EH7Pr7ipA2Qvidqkb3XdLFg2oHtogTUvg6IFlETbTChRI6k4Aor99ew7UrbjxDWQmOTdfd93xzva9uXwZOW/vbKS0jtn2vTI0pz@kkv52GWtXNPV5fVlZqWoZ6Tm72a0XiktSc@X0rsjIrUg9ROfd713M5Jt8DubsUHnp2fFfJ7ctMkMETp/l2Wn50XwiqE4gkOapNgSOTD/@e3rl6wT1slJmqfHOlu6vpy8fZP98vYkTafHaZFOszuj2gnDTkNcZ1XrOfo/snRBybXt5QeihD5Q8ofQDptkQxp9ddze3v7@5er29umfSXY85b@jm7Ps@Ob856enRHSdHpIT4oWVlRIltjR@3pAHB03YWERrDvP0KLHiXnKUFdW99FQO5FcoF5/uwppee9WhjKbzyrSOThFQ7EfkIUS0NWMV@2A5TODy1vSeyYDadNJv5UWJC06dJldGujb1tDb2noQnoTViS9RhybElQJYrTyvVkKClweku9m/Tk2n1QLht8oasbMwDZLeScC3OMwiLL20xouSqiDg5AylHrQmUZi1r0AK3Mi3zRgZs@raG/OS5ZKatBIteCdDJR28FOd8vFpwA18B5YT0Zy9dIUuHIsg7EFwDIATuJuNMDIpbGuHBJYVGidi55XbdoLYI5Dyh3vQMMWkgu1CNwtGgCTBkWtP/Z4lzyFRboj@C0g3FIJ8B0QgcY/iZe78OMncbWgs0HtJxQ2fsAUDBCHnkEVcpWfRMcnEHdcMjn20KUQb2w5Uvxewlcc1xlel1TKbeckFQWCM2TKd/DJh8cF0DMy2QaVYXS75SEbimCw@uLEWUpwsjh68d6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0aAJMERa0@2xx/uYjzNEfYdMDjEM6AaYTOsDwL/F6F2bsNPbm7N6j5ZiK3geAnBGyyCOoVLbsm7DBGdQNRrZvC1EE9cIWT8XvJHDNcaXpdUWF3HJCUpEjNEtSPodNPjDnQMyKJI2qQukflIRuycOG5wcjikKEkcPPn/XEbdwgrMd1WnlSLbpzK80sRgzeC308RVuBj5z4HlWOmFDkvNL6mepNELewVWi60MJxtVfkZz9xcXRYlcHt9ghNLWiNFhel75H8ejNWzjQShxRHCuB5FuCrcYAb3Aih@cvesw5tRJh@zNOfi8Wj1Ih1TMi5vokQC2UdV61D7itOmCtZG@uh09eobBgyiTmqeNpBx0z72mSX7n/cDOiGwvh6RI@XhAsiQCKbzq8Bd71SLX1RDoSMjNewfFpFhkDHWkatpOWbPZSO0ay8k9bFfII3HiXfBZIano/QrsjBMXjr4y6oAX8p4hXwj3BePx3effwcgIoAy6s7Lsjl5V90/m74yChYn7@7uho@RsujsYUnj65ss3vseSprgX8JZO22R6Cl5/f0Nw "Bash – Try It Online") - POSIX ERE (sed), tab as delimiter [Try it online!](https://tio.run/##dVXBbts4ED03XzFQg9pO42ST3pq02cUuCvTUQ3NZyMqClGiLG0rUklRcF/r37BtSduLEFWCbmuG892Y4Q0vh60enREVzV9FkQu76evLP@Ewe76Zn72f8ebO4OHu/uDx@3PqO1rU2ir5@@f6Jxngyw5DTvKXs2GRUXFX26A3ef9Kxp2IYVFnbK//p4ooXcc/QKWdo3ima@PO7bDq9@bhYnA35XVbMTmYZnZzSyQErDG/PTmY354uLRVhcLn47nwxq5VRH8/9@KiC77N27SMJabl2vPhIx3bAzfhHGwwrjUWVb9ZiJrjOb7JR44VSphcQrjc9bCgChKTuL5M3hnh1lTtwrjnKivFeB5IZCrciw9Sms6U3QHYplu6Bt62mOgGI/Io8hoq0Yq9gHy@ECV3C2D0wG1KZTYScvSVxySjT9yyrfTgKtrbsnEUgYg1jpdLviWAmQVR2o1g0JWllYn2L/tj3Z1mxoBfpgca6NfYDsVpHvpQ8MwuKlK0aUXBcJJ2cg7am1kdKuVQVa4Ja2Zd7EgJe@rSA/ey6ZaUvBomsBOvUjOEE@9MslJ8A18EG4QNaRQoGUhsmxDsQXAMgBO024swMiVtb6eEhxIVE7n72uW/IW0Z1HlH97DxhCOyz1D@AY0UQYGRe0/@xw/uAjLNAfcdMTjEc6EaYTJsLwL/F6H2bsNPYW7D6g5ZRkHyJAwQh54hFUalf2TdzgLeoGI9t3hZBRvXDypfi9BG45rrS9qUiqHSckyQKheTbjc9jmA3MBxFxms6Qqlv5JSeyWIm54fTBCShFHDj@/1pO2cYOwHt8ZHUi36M6dNLscMXgv9PEU7QQ@c@J7VDliQpEP2phXqrdB3MJOo@liC6fVQZFfw8Sn0WFVFvfaMzS9pA1aXJShR/Kb7Vh52ygcUhopgBd5hK/GAW5wI8TmL/vAOowVcfoxT78uFo9SIzYpIe/7JkEstfNctQ65rzlhrmRtXYDOUKOyccgU5qjiaQcdMx1qk326b7gZ0A3ShnpET5eEjyJAopoubAB3u9YtfdcehIyM17h8WUWGQMc6Rq2UU/hXiaVjNKcelPMpn@hNR8l3gaKG5yO2K3LwDN6GtAtqwF@KdAX8KXwwL4f3ED8HoCLACvqBC3J9/Ttdfhg@MwrWlx9ubobPyfJsbOEpkivf7h57nspa4F8CWfvdERgV@H32Pw "Bash – Try It Online") - POSIX ERE (egrep), tab as delimiter [Answer] # [Zsh](https://www.zsh.org/), 60 bytes ``` for ((c=#2;++i<$#1;))t=${1: i}&&2=${2:/${1%$t}?*$t} ((c-#2)) ``` [Try it online!](https://tio.run/##bZDPbsIwDMbveQorlNIOTYNy4@@kPcJ23CUJSRvRNlWSamODZ@/sgsRll3yff45jxz@hGkyWZ4NxHrJM7SbFZj6322Sy3OR53CW/yzXYa5oWaIv1C8bTJF4PT3gwvP88KfJ8yBmjemW96htjvyFEb9sSMsZF19VnDqReKyskRYx7cdJIvVAnHUGeIVYa6hEyHr3rI2aj75tOR0KS3kMkMVVWESrbgIDSEWTciFq5FtNoggb0fXvEYsqVzgVqNarEBwPRWjQE5U0Z70RNMQmMFltSXnhJXkgp6BN0YjtvdXukdneDqHaCRqYpGEdD8vFlW3i3IWqPBKObY1yJcaQ3EeKt13b7CsXqskeItlgdDpf9HbCcGUgeq03uu01T6NBEA7PpchHABlzI45ozMC0W4bOd/VM8/AE "Zsh – Try It Online") Key constructs here: * `${var:/pattern}` will replace $var by the empty string if pattern matches the full string. * `((#var))` is zero if $var is empty. [Answer] # [Ruby](https://www.ruby-lang.org/), ~~76~~ 62 bytes ``` ->a,b{s=a.size;s<b.size&&(1..s-2).any?{|i|a==b[0,i]+b[i-s,s]}} ``` [Try it online!](https://tio.run/##RY/NboMwEITvfYpVDlGrAmrJsfxE6iO0N8RhlzhgxWBkG1U05NmpbbB62tlvRvasmmher/kaFxjRXeeYaP7LPnRGXhyPz@9JouP0JcFhLu8LXzDPqXqLeP1KFY91pOvHYx3hWh1wHMV8iMAJxRqOZNf6yXsKb8xZCpsbM0AzmI6BcHRPGCUn4yJGTf3ITOCk@NA6TjbQdgY63gNCKy3dI1cUjRxcxirNwC7TcLHPhEArpfbfe0H2fR0sgb13yIsdjig8dBOcDl18EhUFgEToL7YjlFGcDRdfZlOBC4n@Ptt0R24L@vuHD/DFtWHKYbt6ubsNbv0/UZv/Oll2hvS0FM6xOj2V5VJspF7/AA "Ruby – Try It Online") [Answer] # [Bracmat](https://github.com/BartJongejan/Bracmat), 54 bytes ``` (C=c w a z.!arg:(?c.?w)&@(!c:%?a (%?z&@(!w:!a % !z)))) ``` This solution uses associative (string) pattern matching and expression evaluation during pattern matching. The associative pattern is %?a %?z, which splits the subject, !c, in two strings, neither of which is empty. (The % prefix ensures that a pattern variable does not accept a neutral element, i.e. an empty string, in the case of string pattern matching.) The expression that is evaluated during pattern matching is @(!w:!a % !z). This happens to be another associative string pattern matching operation. [Try it online!](https://tio.run/##JU9ha8IwEP2c/IorWE1hCOq34qzDbSAbDNR925dLG9NgmpY0UhX/e3fVwL337h33kkiPeYWh78XmNYcOEG7TCL1ORZZPsy4Zr0WUp3GGIOLsNnRdGiHEEN0SOn1X2olYC63CRLShMO5lf9glaRZfZvAXgHiewBjqcxgJsRmJ6DKbRk/v52v7TnX/fNt@/@4@EqAZDLOkx6axV0boVW5Q2iv3eFKM3npSAeQVQqnAksWDp2gW/LlqVODSG6eZJE@XAUpT0X907TQ/os1rx4haBaTOrqAVruu6VeyBkhJabrFSTA7IG7SKDQBUXDKJXnKUEhlK5EdvlCvYk/jR1hhY7fihMw72pg3KM9ID8xzpjg22gWKWyzXMF/cVIzFfZNl99Wj/AQ "Bracmat – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), ~~9~~ 8 bytes ``` .œÅΔćìθQ ``` [Try it online!](https://tio.run/##yy9OTMpM/f9f7@jkw63nphxpP7zm3I7A//8TCwqKUpMzE5NyKrmA7JxKAA "05AB1E – Try It Online") Outputs a non-negative number if it is a circumfix, -1 otherwise. [Answer] # [Icon](https://github.com/gtownsend/icon), 70 bytes ``` procedure f(a,b) return(1<*a<*b&a==b[1:i:=2to*a]||b[i-1-*a:0]&1)|0 end ``` [Try it online!](https://tio.run/##bZLBbsIwDIbvPIXVA2orkCi7oQKT9gjbDXGwSygRbVK5iRBS35054TI1y8W/7c@R7UQ31rxeA9tGXTwruOa4omLBynk2eVWXWJe0xP2eTtVO7/ZbZ0s8TxOd9Lpal7jbnJdVMW0Wylz@XNOjNnmxADkP1k7l1zzDYeie2QqCYNVoJHGLGcR4V4FhbO7KAT3B3RR0ITpHHVvvAuvYD71yCUCsTRsAErK9ObjpHhBaK9E5e8VONhFgUaMCcby5sO8TsrV2jC1GQb4fxoTpsI8IRTHPDtjFbLAQdNJ4rEWmJINEGFcoJhmBtTxCHOGtEqCzGBcmg85z2SpLYj8PbeBbj05xqBI3yjnW4HsfXzi6f4ap60/YfkyHgIjefhyP0@EdETR8m18 "Icon – Try It Online") [Answer] # [Python 3](https://docs.python.org/3/), 69 bytes ``` f=lambda c,s,i=1:i<len(c)<len(s)and(c==s[:i]+s[i-len(c):])|f(c,s,i+1) ``` [Try it online!](https://tio.run/##XVLBbsMgDL3vK6zuEtTs0PYWNW2lfcJ2q3owhCSoFCKgmir13zPjaFLZyc/vPYNtmB5p9G43z31r8SY7BFXH2rSbxuytdpUSHKJA11WqbeO5MZd1PJuPRW0u4tlXXLPeiLn3IR8AxkH1Vq1wmuxjVUMGQSuDklJRwzukcNdkCHjVWQ@orjqBfEAaNdjMvtpS8PeUfZTfJp0WsUcbsyqDcUNWJdmGMcFoboAweGILI0XlXXYyA5TcXUdHlrbB@8hdMZB0YywNtCnWJYNCmtCylCNk/DqG5CIMsqxBKZGXRKHsNxjtOu53QaVqPfJSaKRCyFzJfP/Qg3yZmHTIIqUMC4/CZehPjMn@m2q/P8F29zxknfB2dzw@Dwsj/sYTDUz0EKni7yDqoKdAH2SJUYj5Fw "Python 3 – Try It Online") *-2 bytes thanks to [Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler)* [Answer] # [Haskell](https://www.haskell.org/), ~~72~~ ~~71~~ 62 bytes ``` \a b->or[a==take i b++drop j b|j<-[2..length b-1],i<-[1..j-1]] ``` [Try it online!](https://tio.run/##TVLBbuIwEL3nK0ZpDyBIpNLbCuhWdLeXalWpuydAq3FiEoNjR2NHXbTst9OxWZL64jfvPY3f2K7RHaTW57/ZDbw8/nj@9fj8DVavr3CT/UsS1bSWPDyhx/y71SUKLWG0s/R7DFkGnZMlWKOPoAz4WoKXzkONZKRzUzDWX4XCNq30ylSMSsmN3UpR0TU79QcWsDlvEES2tLTGxcLjQYICMZmUZFvYgzjt59l6ludamsrX7LzbThVTd3m@Z7w9h3NX6KTjZusEeI1SbFt9TKcQAMlCcfZjOp7@V4kPCSJhcZAexDHG1IHtPZ5s54PJUxfiD4ogHiUogi1VzTOrBhAqy2xv2qEurAkuRi7cgelMya0GS2WtizEiEHyKG0SNTdREBD3doo502CHgIVV0I4mBQiEw3gFvQzBS0pQx2AUNirYYJ@bcPRnqofr5zk/6ppyXFAQuI@z1Ai8T8XP4z@Hm868wuz8tg8Z4dv/wcFpemPE2SRrktgsIXwuG17yFzbWAbAmljc3azr95ejEsu9q@936YTCD9AmnYozDqTNER8ff89N2u7vH5Aw "Haskell – Try It Online") * -1 byte by moving `l a<l b` into the list comprehension, where it only needs a `,` rather than an `&&` * -9 bytes from [benrg's suggestion](https://codegolf.stackexchange.com/questions/194929/is-it-a-circumfix/194964?noredirect=1#comment464043_194964) [Answer] # [Ruby](https://www.ruby-lang.org/), ~~40~~ 39 bytes ``` ->a,b{a+b=~/^(.+)(.+)(?=#{b}$)\1.+\2$/} ``` [Try it online!](https://tio.run/##RY/BboMwEETv/YpVkkMj0kRNrgEq9RPaW5NKu8SAFcDIGFUoSX@drhesHmBn34zsse1pGPN4fElwQzeMKP7dfT9vo7V8aby80WO1Pr1uo9N@tXuMLeRfC2zbalhswAurMo3E6/lJPItX5S2L2VU5oAFcqaDydE44a3rnI872datc4GR1U3hOHChKB6WuAaEwTOdIjlVmGp9h1SngpW8ufEwIFMZ0cr0I4vO7YFVYi0MiZthiJdBP8Dp0kSRaCgCJUF7MI5SxWjUXKTOpwCuD8j5uOiO/Bf35oxv40J1T1mNeRc5uhlP/d@zcf53j8Q32h3viHdb7Q5rek4mEftyOf8TzPP4B "Ruby – Try It Online") ### How Simple regex: if a+b can be split in 5 parts ABCDE where A==C and B==E, and b=CDE, then a is a circumfix of b. Thanks benrg for pointing out a problem with the first solution (and saving 1 byte). [Answer] # Curry, 28 bytes *Tested to work in both [PAKCS](https://www.informatik.uni-kiel.de/%7Epakcs/) and [KiCS2](https://www-ps.informatik.uni-kiel.de/kics2/)* ``` f(a:b++c:d)(a:b++_:_++c:d)=1 ``` [Try it online!](https://tio.run/##Sy4tKqrULUjMTi7@/z9NI9EqSVs72SpFE8KKt4qHcG0N/@cmZuYpWFkpBBSl5pSmpOp5@itoaHKBRW0VCooy80oUVBTSFJTS8tOVgGQRkPoPAA "Curry (PAKCS) – Try It Online") This returns `1` if the first argument is a circumfix and nothing otherwise. In cases where there are multiple ways the string could be a circumfix it will return `1` multiple times i.e. it is non-deterministic but always gives `1`. I think this is fine. The program is basically just a pattern match checking that the first input is made up of two non-empty strings and that the second is made of the same two strings with another non-empty string between them. This uses two pattern matching features available to Curry not present in Haskell. The first is `++` patterns, and the second is pattern variables. e.g. we require the two `a`s to be *the same `a`*. This allows it to beat out [the Haskell answer](https://codegolf.stackexchange.com/a/194964/56656) handily. ## Testing TIO has a limited ability to test things like this. Paste the following to [smap](https://smap.informatik.uni-kiel.de/smap.cgi?new/curry) and run in `PAKCS 2.2.0` for better testing abilities: ``` import Control.SetFunctions f(a:b++c:d)(a:b++_:_++c:d)=1 -- Helper to run tests helper :: [a] -> [a] -> Bool helper x y = not $ isEmpty $ set0 $ f x y main = [ helper "fog" "frog" , helper "apply" "appreciably" , helper "rake" "racket by the lake" , helper "trout" "trumpet" , helper "bring" "brought him a gong" , helper "falcon" "false conundrum" , helper "goose" "goosebumps" ] ``` This test handler will not work in KiCS2 or at least not on the version used by smap. But the function itself does if you want to manually test it. [Answer] # JavaScript (ES6), 70 bytes Takes input as `(a)(b)`. ``` a=>b=>[...a].some((_,i)=>b[l=a.length]&&a==b.slice(0,l-i)+b.slice(-i)) ``` [Try it online!](https://tio.run/##bZFBbsIwEEX3nMLqAhIVrAq2JFSq1AuUXYqqcRgSl4kd2U4rJO6e2oZKrZzV/PnzZP@xP@ELbG1k71ZKH3E8FSMUpSjKinMOB251h1n2sZS5dysqgBOqxrWH@RyKQnBLssbsaUkrmT/@tl7nY62V1YScdJMtqr0ZXHs5LPLZX/@UPUDf0@Uhj8JgLUGENsEMnDFQBuozOiYuzLXIKLoJ3ANFOFQWdYJst89svbmWAfN6vdntruXdyWf/6MW7ql6B7FR6Z/TgwhnODF2PbuImYaRqAiI827SOtbJjwBod3IQ@AXkn4F5ZZL4Z1NEfPsE2Wtu4ZxTCB7ATFEEXIXETab44BCMmZiAExL8JJc1qJKpjzHpXKUIa4vuEnZJpGEzY@2@p2Ju0Dk0gfHuTCVjDbf8XsC7@8vgD "JavaScript (Node.js) – Try It Online") [Answer] JavaScript (ES6), 72 bytes ``` s=>t=>[...s].some((x,i)=>t[l=s.length]&&i&&s==t.slice(0,i)+t.slice(i-l)) ``` Return true if * the second string is longer than the first * there is a position to split the first string in 2 parts, such as the second string starts with the left part and ends with the right part **Test** ``` z=`"apply", "appreciably" -> true "app]reciab[ly" "rake", "racket by the lake" -> true multiple options - "r]acket by the l[ake" and "ra]cket by the la[ke" "trout", "trumpet" -> false Doesn't work at all "bring", "brought him a gong" -> false You only get to remove one substring - "br]ought h[i]m a go[ng" is not allowed "falcon", "false conundrum" -> false You can't have extra stuff at the start or end either - "fal]se [con(undrum)" is not allowed "goose", "goosebumps" -> false "goose]bumps[" is just a prefix "lame", "blame" -> false And "]b[lame" is just a suffix "pale", "pale ale" -> true "pale] ale[" is just a prefix, but "pal]e al[e" is a circumfix, so this is allowed "b", "barb" -> false This could be a prefix ("b]arb[") or a suffix ("]bar[b"), but not a circumfix - "b]ar[b" is not allowed "abba", "aba" -> false "abba" can be split into a prefix of "aba" ("ab") and a suffix of "aba" ("ba"), but "abba" is still not a circumfix of "aba" "friend", "friend" -> false It's only a proper circumfix if you actually remove something - "fri][end" doesn't make the cut "float", "on" -> false You may not assume the first input will be shorter than the second one "", "" -> false One or both input strings may be empty "Twin Sister", "Twister" -> false Inputs are ordered - you may reverse the order, but there must be a consistent ordering "case", "Castle" -> false Inputs are case sensitive "<<@ 23|>", "<<@23??|> 23|>" -> true "<<@]23??|>[ 23|>", not all characters will be letters)` f=s=>t=>[...s].some((x,i)=>t[l=s.length]&&i&&s==t.slice(0,i)+t.slice(i-l)) z.split('\n').forEach((s,i)=>{ var m = s.match(/"([^"]*)", "([^"]*)" -> (true|false)/) if (m) { console.log(`"${m[1]}" "${m[2]}" should be ${m[3]} and is ${f(m[1])(m[2])}`) } }) ``` [Answer] # [Prolog (SWI)](http://www.swi-prolog.org), 104 bytes ``` e([],_). e([H|T],[H|U]):-e(T,U). e(L,[_|U]):-e(L,U). f(X,Y):-string_chars(X,A),string_chars(Y,B),e(A,B). ``` [Try it online!](https://tio.run/##VYy9CoNAEIT7PMVhdQerD5AmmCqFpUJERE5Zf9DEY10JQt79sgoWaXZ2vhnG0TzNXbh8Bu9RFyVUJrrI8/imJcjNSnMNUaeQHTyBojpZcrBWPyEXvzAN765qekuLoNjAH8nhbgB1LBL5W9jqwDo3bQHsStgMthYne0dGdsQAlGgzIqt6U9yjmnZ6VpjmlfcO0/pyyBL4Hw "Prolog (SWI) – Try It Online") [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 30 bytes ``` #2/.{p__,__,s__}/;{p,s}==#->0& ``` [Try it online!](https://tio.run/##NZBBasMwEEX3OYWIISu3Ls6yiWPIBQrtrhQzcmRbRLaEJFOC47O7MyMKAv15f6T50ghxUCNE3cLWnbesLF4X1zQ5rtA0a/G@uDys53P2Ur0dtg@vp/iNuqvr6wAe2qh8qLOfQ1Evu2UPzpnHPhckvGo1SCzXHB0Pd0UGHrmrKORD4FxhiLIfvZ0jNUQ/j07FRCXO64lKtPshikGPAkRvkXJDB6a1E3WgCkpgMU83vCLZvbWBx7KQeHNIhoGRuWTByIFhRLsgnRJwF3iZSpAS@H24pQBeq@nGAZJK1Fjg12A2BqST@vrVk/jUAT@OIJYs2Wshpb1CiP8BTqdalMdnRRx1ebxcnlUi627d/gA "Wolfram Language (Mathematica) – Try It Online") Takes two lists of characters as input. Returns `0` if the first string is a circumfix of the second, or the second string otherwise. [Answer] # [APL (Dyalog Unicode)](https://www.dyalog.com/), 21 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set") Anonymous infix function. Takes strings 1 and 2 as left and right arguments. Requires `⎕IO←0`. ``` {(⊂⍺)∊∊¨↑∘⍵¨¨(1↓⍳≢⍺)-⊂0,~/≢¨⍺⍵} ``` [Try it online!](https://tio.run/##LY/BasJAFEX3@YrZjYVKrW5FC27qqlD9gTdxjMExCZORIrVdtCBWiLQUoeuu3Lko3bjMp8yPpDczhSFz73k3772hTDUnK1JpVNn9YXhnN@@t6rFhdy@2OF/Y7Q6nPNrNh91@2eK3PJbHxrXdfNrix75915kmsq3L5ytYBIszUk/VFH1ssfctd6/lqVO32B9G9wN8x7fDUcUpy9SKsymrlZZhTAI@4Jrm0mFN4VwaJlbMzCRTNQ640enSuLLRy0UmDZjQcRI5JlCNZobN4gUjFqXAAZ@SCtPE1SFzyeCWyQS/oxilae7HOSXQMwdWtPBUOBXwjJQHtWC1wVyfIC1gSAjyr8GNoTqWycQP9RJMpeR3xzoBdwr3@CFO2CjOjdQOwTsd8JD@dxtQbtzIbveGtTvrnqMw7U6/v@559Ac "APL (Dyalog Unicode) – Try It Online") `{`…`}` "dfn"; `⍺` and `⍵` are is strings 1 and 2:  `⍺⍵` strings 1 and 2  `≢¨` length of each  `~/` remove elements from the first that are in the second (gives empty list if same length)  `0,` prepend zero  `⊂` enclose to treat as a whole  `(`…`)-` subtract that from the following:   `≢⍺` length of string 1   `⍳` indices zero through that   `1↓` drop the first one (the zero) This gives us the head-tail pairs to try.  `¨¨` for element of each of the head-tail pairs:   `↑∘⍵` take that many characters from string 2 (from the end if negative)  `∊¨` **ϵ**nlist (flatten) each  `(`…`)∊` is the following an **ϵ**lement of that?   `⊂⍺` the entire string 1 [Answer] # [Java (JDK)](http://jdk.java.net/), 46 bytes ``` a->b->(a+"\0"+b).matches("(.+)(.+)\0\\1.+\\2") ``` [Try it online!](https://tio.run/##XVLBbtswDL3nKwgBAewlEdL0tqbugAG7DRiQ3eoeKFt2lNiWIckZgtbfnlGyu0E5GHzkeyKfJZ7wgptTeb6pttfGwYlyPjjV8GroCqd0x788LYoGrYWfqDp4XwD0g2hUAdaho3DRqoSWuOTgjOrq1zdAU9s0SAF@zH32E7v@ZWSpCnRyLmQZVPB8w00mNlmCK5Zv2UqkvEVXHKVNWMJXqf/ybZ4/8FWe71h6ewq9PwfSSCets/A8DwV4B1bpmq1ZZSjAuP5fx75vrmwdgJGFQkFppDB4ll5gsDhLB@IK7iih8dVI54wenBc6M7S9dDErvDnPCpLVRwdH1QJCrbs7QxU2he68kpCVQMnQldQyltVa22ArAEETbSxosA28CCCiemwC5SN4HDsNp9CIu4sSAsM9UYgNGyW7MhieUMw2GsOt0D9FhK/Fld9/aKUOyjppPElpgJGmwOmvv6N198b3@2@we/zIPE949/jy8pFNFRiDbJw2pdImuaAJa/J1Wpb0364crjS15fSWvKc3c1XCcra0OXWdImwyWNqlfyJ/9HX7NoMHAhUPC5XMTMo9SGY6Taf53sy4GG9/AQ "Java (JDK) – Try It Online") ## Credits * -2 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat) * -2 bytes thanks to [Sara J](https://codegolf.stackexchange.com/users/85386/sara-j) * The 46 bytes solution (-86 bytes) is actually the full implementation in Java of [deadcode's regex answer](https://codegolf.stackexchange.com/a/197425/16236) (which incidentally also contains a Java solution, but only to demonstrate the regex). [Answer] # [Perl 5](https://www.perl.org/), ~~73~~ 77 bytes ``` sub f{(grep$_[1]=~/^@{[$_[0]=~s|.{$_}|\Q$&\E.+|r]}$/,1..length($_[0])-1)?1:0} ``` [Try it online!](https://tio.run/##1VdNb@M2EL37VwwEoZa2irzOopd8OAm6PfSwKIrmUiiqQcmUzY0kqiSV2IjTv57OkPLXrrNAN9sk60My4pDDN0@Pj3bDVfnTw4NuMyjugqnijT9OhunpP4O/zu8SjN9irJfxnT@@X1797v9w9Uv841Kl9/4gGsZxyeupmQV2XngwDM@GR2/vH1rN4ZJrc3T0QSoOBkN9OjocHvcKqYKKNcnAC@I3Z6EXXek3XYjRwQgCo1q@LFipeYgjmAoHaaSbUpjBVT2IPkpR9/vRyfuLy4tReNcD/FSLwNfDyNeHkc/nTeSbuQlPz/3xsU3T2Cn9Af439Kl@n2C6pNBBsVodbi0/7t33x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://github.com/AlephAlpha/Nekomata) + `-e`, 7 bytes ``` ≠;sᵃN,= ``` [Attempt This Online!](https://ato.pxeger.com/run?1=LZCxTsQwEERF669YbX1pcg0Sxx0SPQ10iGKd8yVWEjuyHaGTrqPiG2hSgIQELT9DB1_COKHxzL6RPSu_vDvT-l6SfN5z0fOKuDD8ML2N6VCcf_w-Txfx5-vpZnX5GnUV__n0fVayDEN3ZMoaTGVFY1IcpDWAQarWJNJHSo2hLkPFKfgxIUxh7AeTQHSwrgbRSOomUWN7Eqo9oOKDdJV3SGGiIfjR7XEVUe19zDWzarwWATvpM9OzKh6ky2MWyhZtOZWgYUVrybvjRFGwxu1z0WJAOi95U9QrhuK8e7SObm1MJgBgmp3iSuZNriWmuWSzuaJyfdqCwZbr3e60XcDyd38) ``` ≠;sᵃN,= ≠ Check that the two inputs are not equal ; Split the second input into two parts s Take a suffix of the second part ᵃN Check that both the first part and the suffix are non-empty , Join the first part and the suffix = Check that the result is equal to the first input ``` ]
[Question] [ Write a full program or a function that takes a positive integer `N` as input via STDIN/command line/ARGV or function arguments and prints an ASCII double knot corresponding to the `N` to STDOUT. The ASCII double knot looks like this: ``` __ __ __ __ __ __ / \/ \/ \/ \/ \/ \ | /\/ /\/ /\/ /\/ /\/ /\ | | \/ /\/ /\/ /\/ /\/ /\/ | \ \/\ \/\ \/\ \/\ \/\ \/ /\ \/\ \/\ \/\ \/\ \/\ \ | /\/ /\/ /\/ /\/ /\/ /\ | | \/ /\/ /\/ /\/ /\/ /\/ | \__/\__/\__/\__/\__/\__/ ``` The above is for `N = 6` Here are a few more double knots for other values of `N`: If `N = 1`, the output double knot looks like: ``` __ / \ | /\ | | \/ | \ \/ /\ \ | /\ | | \/ | \__/ ``` For `N = 2`, its ``` __ __ / \/ \ | /\/ /\ | | \/ /\/ | \ \/\ \/ /\ \/\ \ | /\/ /\ | | \/ /\/ | \__/\__/ ``` For `N = 3`, its ``` __ __ __ / \/ \/ \ | /\/ /\/ /\ | | \/ /\/ /\/ | \ \/\ \/\ \/ /\ \/\ \/\ \ | /\/ /\/ /\ | | \/ /\/ /\/ | \__/\__/\__/ ``` and similarly, the pattern continues and any larger value of `N`. **Details**: * The input is always a positive integer greater than `0`. * Trailing newline is optional * There should either be no trailing spaces in each line, or enough trailing spaces such that each row's length is `4*N + 2`. * There should never be any leading space that aren't part of the specified pattern. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins. --- # Series Leaderboard I am converting this into a series of ASCII art challenges and thus adding a leader board for the series (snippet by Martin). To make sure that your answers show up, please start every answer with a headline, using the following Markdown template: ``` # Language Name, N bytes ``` where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance: ``` # Ruby, <s>104</s> <s>101</s> 96 bytes ``` ``` /* Configuration */ var QUESTION_IDs = [50484, 50521, 50625, 51123, 51222]; // Obtain this from the url // It will be like http://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page var ANSWER_FILTER = "!.FjwQBrX2KXuFkv6p2lChi_RjzM19"; /* App */ var answers = [], page = 1, currentQ = -1; function answersUrl(index) { return "http://api.stackexchange.com/2.2/questions/" + QUESTION_IDs.join(";") + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function getAnswers() { $.ajax({ url: answersUrl(page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); if (data.has_more) getAnswers(); else process(); } }); } getAnswers(); var SIZE_REG = /\d+(?=[^\d&]*(?:&lt;(?:s&gt;((?!&gt;).)*&lt;\/s&gt;|((?!&gt;).)+&gt;)[^\d&]*)*$)/; var NUMBER_REG = /\d+/; var LANGUAGE_REG = /^#*\s*([^\n,]+)(?=,)/;// function shouldHaveHeading(a) { var pass = false; var lines = a.body_markdown.split("\n"); try { pass |= /^#/.test(a.body_markdown); pass |= ["-", "="] .indexOf(lines[1][0]) > -1; pass &= LANGUAGE_REG.test(a.body_markdown); } catch (ex) {} return pass; } function shouldHaveScore(a) { var pass = false; try { pass |= SIZE_REG.test(a.body_markdown.split("\n")[0]); } catch (ex) {} if (!pass) console.log(a); return pass; } function getAuthorName(a) { return a.owner.display_name; } function getAuthorId(a) { return a.owner.user_id; } function process() { answers = answers.filter(shouldHaveScore) .filter(shouldHaveHeading); answers.sort(function (a, b) { var aB = +(a.body_markdown.split("\n")[0].match(SIZE_REG) || [Infinity])[0], bB = +(b.body_markdown.split("\n")[0].match(SIZE_REG) || [Infinity])[0]; return aB - bB }); var users = {}; answers.forEach(function (a) { var headline = a.body_markdown.split("\n")[0]; var question = QUESTION_IDs.indexOf(a.question_id); var size = parseInt((headline.match(SIZE_REG)||[0])[0]); var language = headline.match(LANGUAGE_REG)[1]; var user = getAuthorName(a); var userId = getAuthorId(a); if (!users[userId]) users[userId] = {name: user, nAnswer: 0, answers: []}; if (!users[userId].answers[question]) { users[userId].answers[question] = {size: Infinity}; users[userId].nAnswer++; } if (users[userId].answers[question].size > size) { users[userId].answers[question] = {size: size, link: a.share_link} } }); var sortedUsers = []; for (var userId in users) if (users.hasOwnProperty(userId)) { var user = users[userId]; user.score = 0; user.completedAll = true; for (var i = 0; i < QUESTION_IDs.length; ++i) { if (user.answers[i]) user.score += user.answers[i].size; else user.completedAll = false; } sortedUsers.push(user); } sortedUsers.sort(function (a, b) { if (a.nAnswer > b.nAnswer) return -1; if (b.nAnswer > a.nAnswer) return 1; return a.score - b.score; }); var place = 1; for (var i = 0; i < sortedUsers.length; ++i) { var user = sortedUsers[i]; var row = '<tr><td>'+ place++ +'.</td><td>'+user.name+'</td>'; for (var j = 0; j < QUESTION_IDs.length; ++j) { var answer = user.answers[j]; if (answer) row += '<td><a href="'+answer.link+'">'+answer.size+'</a></td>'; else row += '<td class="missing"></td>'; } row += '<td></td>'; if (user.completedAll) row += '<td class="total">'+user.score+'</td>'; else row += '<td class="total missing">'+user.score+'</td>'; row += '</tr>'; $("#users").append(row); } } ``` ``` body { text-align: left !important} #leaderboard { width: 500px; } #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; } td.total { font-weight: bold; text-align: right; } td.missing { background: #bbbbbb; } ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="leaderboard"> <h2>Leaderboard</h2> <p> Missing scores are shown as grey cells. A grey total indicates that the user has not participated in all challenges and is not eligible for the overall victory yet. </p> <table class="_user-list"> <thead> <tr><td></td><td>User</td> <td><a href="https://codegolf.stackexchange.com/q/50484/31414">#1</a></td> <td><a href="https://codegolf.stackexchange.com/q/50521/31414">#2</a></td> <td><a href="https://codegolf.stackexchange.com/q/50625/31414">#3</a></td> <td><a href="https://codegolf.stackexchange.com/q/51123/31414">#4</a></td> <td><a href="https://codegolf.stackexchange.com/q/51222/31414">#5</a></td> <td></td><td>Total</td> </tr> </thead> <tbody id="users"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> ``` --- # Series so far [***1. Double Knot***](https://codegolf.stackexchange.com/q/50484/31414) [***2. Flow Snakes***](https://codegolf.stackexchange.com/q/50521/31414) [***3. Chinese Shrines***](https://codegolf.stackexchange.com/q/50625/31414) [***4. Zodiac Signs***](https://codegolf.stackexchange.com/q/51123/31414) [***5. Random Diamond Tilings***](https://codegolf.stackexchange.com/q/51222/31414) [Answer] # CJam, ~~103~~ ~~92~~ ~~83~~ ~~69~~ ~~66~~ 57 bytes ``` "O5àäªÞáKZò,_÷%SJ«Ò"248b5b"/ \_|"f=9/4/~ri*1>W<+2m<zN* ``` Try it online in the [CJam interpreter](http://cjam.aditsu.net/#code=%22O5%C3%A0%C3%A4%C2%99%C2%AA%C2%96%C3%9E%C3%A1KZ%C3%B2%2C_%C3%B7%25SJ%C2%AB%C3%92%C2%8E%22248b5b%22%2F%20%5C_%7C%22f%3D9%2F4%2F~ri*1%3EW%3C%2B2m%3CzN*&input=12). ### Idea The pattern becomes a lot more obvious once we transpose rows with columns (padded to the right with spaces). For input **3**, for example, this gives: ``` || || / \/ \ _ /\ \/\_ _ \/\ \/_ \/ /\/ / / /\/ /\ _ /\ \/\_ _ \/\ \/_ \/ /\/ / / /\/ /\ _ /\ \/\_ _ \/\ \/_ \ /\ / || || ``` The first two and last two rows are special, but the others repeat the same pattern over and over again. Thus, for input **N**, all we have to do is repeat ``` / /\/ /\ _ /\ \/\_ _ \/\ \/_ \/ /\/ / ``` **N** times, replace the first row with ``` || || / \/ \ ``` the last row with ``` \ /\ / || || ``` and, finally, transpose rows with columns. ### Code ``` "O5àäªÞáKZò,_÷%SJ«Ò" 248b e# Convert the string (array of code points in base 248) to an integer. 5b e# Convert the integer to the array of its digits in base 5. e# This pushes the following array: e# [ 1 2 1 1 0 2 1 1 0 1 1 4 4 1 1 4 4 1 1 1 4 4 1 1 e# 4 4 1 1 0 1 1 2 0 1 1 2 1 0 1 0 2 0 1 0 2 3 1 0 e# 2 1 2 0 2 3 3 1 2 0 2 1 2 0 3 1 2 0 1 0 2 0 1 0 ] "/ \_" f= e# Retrieve the chars that correspond to the indexes in the array. e# This pushes the following string: e# " \ /\ / || || || || / \/ \ / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /" 9/4/~ e# Divide into groups of 4 strings of length 9. e# This pushes the following arrays: e# [ " \ /\ /" " || || " " || || " " / \/ \" ] e# [ " / /\/ /\" "_ /\ \/\_" "_ \/\ \/_" " \/ /\/ /" ] ri e# Read an integer from STDIN. * e# Repeat the last array that many times. 1>W< e# Remove the first and last string from the array. + e# Concatenate both arrays. 2m< e# Rotate the concatenated arrays two elements to the left. z e# Zip the array of strings (transpose rows with columns). N* e# Join the strings of the array, separating by linefeeds. ``` [Answer] # CJam, 55 bytes I got nerd sniped pretty badly by this... anyway, I finally came up with [55 bytes](http://cjam.aditsu.net/#code=%22%C2%B2%C3%AE%C3%A5%3C63%C3%85hb%C3%98%C2%BA%C2%A2dr%C3%A4O%C3%A4%5B%C3%A6TZ%22246b5b%22%7C_%20%5C%2F%22f%3D9%2F4%2F~2%2F%5Cri*2%3E*zN*&input=5) of ISO 8859-1: ``` "²îå<63Åhbغ¢dräOä[æTZ"246b5b"|_ \/"f=9/4/~2/\ri*2>*zN* ``` or this [alternative](http://cjam.aditsu.net/#code=%22%C3%B4%2FHt%5D%C3%B5Dz1M%3B%C3%AD%2CD%C2%AFTm%C3%A4%24%3Ar%22246b5b%22_%2F%5C%20%7C%22f%3D9%2F2%2F~%2Bri*2%3E%5C%2B%2BzN*&input=5): ``` "ô/Ht]õDz1M;í,D¯Tmä$:r"246b5b"_/\ |"f=9/2/~+ri*2>\++zN* ``` Initially I tried to do it in plain ASCII, but only got it down to [58 bytes](http://cjam.aditsu.net/#code=%22C%5DVA~%60%2B-WIt*n_I%3FFanSEo*b%22128b5b%22_%2F%7C%5C%20%22f%3D9%2F4%2F~2%2F%5Cri*2%3E*zN*&input=5): ``` "C]VA~`+-WIt*n_I?FanSEo*b"128b5b"_/|\ "f=9/4/~2/\ri*2>*zN* ``` and again, an [alternative](http://cjam.aditsu.net/#code=%221%2C*Ap7c%3FUvI%24yQHqHqs~%3D%7Dn%22153b5b%22_%20%2F%7C%5C%5C%22f%3D9%2F2%2F~%2Bri*2%3E%5C%2B%2BzN*&input=5): ``` "1,*Ap7c?UvI$yQHqHqs~=}n"153b5b"_ /|\\"f=9/2/~+ri*2>\++zN* ``` **Explanation:** The idea is to encode the unique parts (left edge, right edge and middle pattern) in a convenient way, repeat the middle part as needed, and put them together. The code ended up being similar in many ways to Dennis's answer; I didn't try to copy him, but I tried many different approaches (including exploiting more symmetries and repetitions) and this is what worked best. I put the left and right edges together like this: ```      /\ | | | | \/ /\ | | | | \/ ``` The middle pattern has 4 columns, but they are repeated N-0.5 times, i.e. one repetition is cut in half. For convenience, I used this pattern: ``` __ \/ / /\ /\/ /\ \ \/\ / /\ /\/ /\__ ``` and removed the first half of the first repetition. So I joined the parts and encoded them in transposed form, as it's easier to work with them that way. The first and third program encode this string: ``` \/ /\/ / / /\/ /\ _ /\ \/\_ _ \/\ \/_ || || / \/ \ \ /\ / || || ``` (without newlines), which is the transposition of the middle + edges. The second and fourth program (the "alternatives") encode this string: ``` || || / \/ \ \ /\ / || || \/ /\/ / / /\/ /\ _ /\ \/\_ _ \/\ \/_ ``` again, without newlines, and this is the transposition of edges + middle. Here's how this common part of the code works: ``` "…" encoded string (constructed via the reverse process, using a suitable base that gives valid characters) 246b convert the string to an integer, treating each character as a digit in base 246 (or other bases in the ASCII versions) 5b convert the number to base 5, obtaining 72 digits from 0 to 4, representing the 5 different characters we have "|_ \/"f= convert the digits to their corresponding characters (each program uses a different assignment order) 9/ split the resulting strings into 8 strings of 9 characters if viewed as lines, they look exactly like the 2 patterns shown above ``` After this, the implementation differs slightly. In the first and third program we have: ``` 4/ split the lines into groups of 4 - the middle part and the edges ~ dump the two 4-line parts onto the stack 2/ split the second part (the edges) into 2 groups of 2 lines (left edge and right edge) \ swap the edges with the middle part ri* read the input, convert to integer (N) and repeat the middle part N times 2> remove the first 2 lines (first half of first repetition) * join the 2 edges using the repeated middle part as a separator z transpose the result back to the desired form N* join with newlines ``` In the second and fourth (alternative) programs, we have: ``` 2/ split the lines into groups of 2 (left edge, right edge, middle first half, middle 2nd half) ~ dump all the groups onto the stack + join the two middle halves into a single middle group of 4 lines ri* read the input, convert to integer (N) and repeat the middle part N times 2> remove the first 2 lines (first half of first repetition) \ swap the repeated middle with the right edge + concatenate the middle with the right edge + concatenate the left edge with the rest z transpose the result back to the desired form N* join with newlines ``` [Answer] # Javascript (*ES7 Draft*), 169 163 160 158 bytes *Edit: -6 by using a template string to eliminate some repetition from the pattern string.* *Edit: -3 by switching from `slice(0,-2)` to `slice(2)` by rearranging the pattern string.* *Edit: -2 by looping through `b` instead of `a` and reducing the `a` string to 4 with a modulo.* ``` F=N=>[(a=' ||'[i%4])+b[i]+` __0\\/ ${c=' 0/ /\\0 /\\/0/\\'} \\0\\/\\${c}__`.split(0)[i].repeat(N).slice(2)+(b+b)[9-i]+a for(i in b=' / \\/ \\')].join(` `) ``` ``` <input id="stdin" value="4" /> <button onclick="stdout.innerHTML=F(stdin.value)">Run</button><br /> <pre id="stdout"></pre> ``` **Commented:** ``` F=N=>[ // define function F, start array comprehension to generate each line (a = ' ||'[i % 4]) + // first character of the line, store copy in a b[i] + // second character of each line ` __0\\/ ${c=' 0/ /\\0 /\\/0/\\'} \\0\\/\\${c}__`. // list of patterns for each line delimited by 0's // results in string: ' __0\/ 0/ /\0 /\/0/\ \0\/\ 0/ /\0 /\/0/\__' split(0)[i]. // split by 0, get index at i repeat(N). // repeat N times slice(2) + // chop off the first 2 characters (b + b)[9 - i] + // get opposite of second character, b+b to get a space at index 9 a // repeat first character (a) for(i in b = ' / \\/ \\') // runs for each index in character map b ].join(` // join resulting array with newlines `) ``` [Answer] # Perl, ~~134~~ 129 ``` print s/...\K.{4}/$&x~-"@ARGV"/er=~y!iolp!| /\\!r,$/for map/i/?$_.oi:"o$_$_".o,o__o,loop,@x=(iolplolp,ioplolpl),popl,lpop,@x,p__l ``` Takes a command line parameter: ``` $ perl ~/knot.pl 3 __ __ __ / \/ \/ \ | /\/ /\/ /\ | | \/ /\/ /\/ | \ \/\ \/\ \/ /\ \/\ \/\ \ | /\/ /\/ /\ | | \/ /\/ /\/ | \__/\__/\__/ ``` [Answer] # JavaScript (*ES6*), 165 ~~166~~ Knot elements: * 2 top rows, based on ' \_\_' and '/ \' repeated * 2 outer rows, based on '/\/ ' repeated and enclosed in '| ... |' * 2 inner rows, based on '\/\ ' repeated and enclosed in '.../' and '/...\' * the same 2 outer rows above * 1 bottom row based on '\\_\_/' repeated **Ungolfed** ``` K=r=> { R = x => x.repeat(r); S = d => R(elem).slice(d,d-2); // use global 'elem' that must be assigned before the call elem = '/\\/ ' outer = '\n| ' + S(0) + ' |\n| ' + S(1) + ' |\n ' elem = '\\ \\/' inner = '\\' + S(1) + '/\n /' + S(0) + '\\' return R(' __') + '\n ' + R('/ \\') + outer + inner + outer + R('\\__/') } ``` **Golfed** ``` K=r=>(S=d=>(R=e=>e.repeat(r))(e).slice(d,d-2),o=` | ${S(0,e='/\\/ ')} | | ${S(1)} | `,R(' __')+` ${R('/ \\')+o}\\${S(1,e='\\ \\/')}/ /${S(0)}\\${o}`+R('\\__/')) // TEST function go() { O.innerHTML=K(I.value) } go() ``` ``` <input id=I value=5><button onclick='go()'>-></button><br> <pre id=O></pre> ``` [Answer] # C++ , 1530 639 479 This looked like a fun challenge I deviated from the brief a little. ``` #include "stdafx.h" #include <iostream> #include <sstream> using namespace std; string a=" __ ",b="/ \\",c=" /\\",d="/\\/ ",f="\\ \\/",g="/\\\ \\",r="\\__/",o="",e=o,j="|"; string q(int n,string r,string x="",string m=" ",string t=" "){string z=o;for(int i=0;i<n;i++){z+=r;if(i!=n-1)z+=x;}return m+z+t+"\n";} int main(){int x,y;cin>>x;cin>>y;e+=q(x,a)+q(x,b);for(int i=0;i<y;i++){e+=q(x,c,"/",j," |")+q(x-1,d,o,"| \\/ ",j);if(i!=y-1){e+=q(x,f)+q(x,g);}}e+=q(x,r);cout<<e;} ``` Im not sure how to measure bytes of the size of my application but I will try figure it out and update my answer. My app could be smaller but it loops in both the x and y, and I kinda like that :D [Answer] # Python 2, ~~156~~ ~~151~~ ~~147~~ ~~141~~ 139 edit 1: edited to use input() instead of a function. edit 2: used str.join and added to var c to remove some redundant characters. edit 3: removed some unnecessary string escape sequences. edit 4: used ~-n instead of a=n-1 This was good fun to program, my first code golf! ``` n=input() a='/\/ '*~-n b='\ '+'\/\ '*~-n+'\\' c='\n| '+a+'/\ |\n| \/ '+a+'|' print'\n '.join((' __'*n,'/ \\'*n+c,b+'/','/'+b+c,'\__/'*n)) ``` save it in an external text editor as n.py in order to remove last newline character in order to reduce file size by 1 byte, run the module, and input your number. [Answer] # Python 2, ~~139~~ ~~133~~ 129 bytes ``` n=input() for i in range(9):w=' ?|'[i&2];s=' / /\/ /\_ /\ \/\__ \/\ \/_ \/ /\/ /'[i::9]*n;s=(s,' %s '%s[1:-1])[i%4>1];print w+s+w ``` This one just builds and prints line by line. Here's the code in ungolfed form: ``` n=int(input()) # The list with all the knot pieces l= [' __ ', '/ \\', ' /\/', '/\/ ', '\ \/', '/\ \\', ' /\/', '/\/ ', '\__/'] # The first and last columns w = ' || || ' # Loop for each row for i in range(9): # Exception for the first and last character in the knot (in some rows) s = l[i]*n if i % 4 > 1: s = ' ' + s[1:-1] + ' ' # Print the knot for this row print(w[i] + s + w[i]) ``` **Edit:** I changed the language to python 2, to be compatible with [my answer for #3](https://codegolf.stackexchange.com/a/50652/40620) (and it also saves 6 more bytes) [Answer] ## C, 159 bytes ``` j,k;f(n){char*t="7>771I;M6CMI93;IIB;;MI1M;M6CMI93;IIB;>MI";for(n*=4;t[j/2];++k,k%=n+3,j+=k-n?k%n<3||k%4-2?1:-3:3)putchar("\n _|/\\"[(t[j/2]-48)/(j%2?1:6)%6]);} ``` With whitespace, and some other readability improvements: ``` #include <stdio.h> int j, k; void f(int n) { char *t = "7>771I;M6CMI93;IIB;;MI1M;M6CMI93;IIB;>MI", *m = "\n _|/\\"; for (n *= 4; t[j / 2]; ++k, k %= n + 3, j += k - n ? k % n < 3 || k % 4 - 2 ? 1 : -3 : 3) putchar(m[(t[j / 2] - 48) / (j % 2 ? 1 : 6 ) % 6]); } ``` This is primarily template based. The template `t` contains all 9 possible columns of the output, meaning that it encodes 9 \* 9 = 81 characters, or 80 without the trailing newline. Since there are only 6 different characters in the pattern (including newline characters), I packaged pairs of them into one template character, which means that the template can be stored in 40 characters. There are then 6 \* 6 = 36 possible pairs of characters, which are encoded as ASCII characters 48 to 73. The translation back to the original character is given by the small lookup table `m`. The rest of the logic is mainly to repeat the pattern `n` times, which means jumping back 4 characters in the template, while emitting the start and end parts of each row correctly. [Answer] # PHP 5.5.3, 488, 466 ``` <?php function k($n){$r=array_fill(0,9,'');for($i=0;$i<$n;$i++){$r[0].=($i==0)?" __ ":" __ ";$r[1].=($i==0)?" / \\":"/ \\";$r[2].=($i==0)?"| /\\/":(($i==$n-1)?" /\\ |":" /\\/");$r[3].=($i==0)?"| \/ ":(($i==$n-1)?"/\/ |":"/\/ ");$r[4].=($i==0)?" \\ ":(($i==$n-1)?"\\/\\ \\/":"\\/\\ ");$r[5].=($i==0)?" /\\ ":(($i==$n-1)?"\\/\\ \\":"\\/\\ ");$r[6]=$r[2];$r[7]=$r[3];$r[8].=($i==0)? " \__/":"\__/";}foreach($r as $o){if(strlen($o)-2 !== 4*$n)$o.=" ";echo $o."\n";}} ``` [Answer] # Prolog (SWI), 285 bytes ``` a(N):-b(N," || || "," / \\/ \\","_ /\\ \\/\\_","_ \\/\\ \\/_"," \\/ /\\/ /"," / /\\/ /\\"," \\ /\\ /"). b(N,[A|G],[B|H],[C|I],[D|J],[E|K],[F|L],[Y|Z]):-c(N,[Y,A],[E,F,C,D],T),writef([A,B,C,D|T]),nl,b(N,G,H,I,J,K,L,Z). c(1,L,_,L):-!. c(N,L,X,O):-M is N-1,c(M,L,X,T),append(X,T,O). ``` (With whitespace): ``` a(N):- b(N, " || || ", " / \\/ \\", "_ /\\ \\/\\_", "_ \\/\\ \\/_", " \\/ /\\/ /", " / /\\/ /\\", " \\ /\\ /"). b(N,[A|G],[B|H],[C|I],[D|J],[E|K],[F|L],[Y|Z]):- c(N,[Y,A],[E,F,C,D],T), writef([A,B,C,D|T]), nl, b(N,G,H,I,J,K,L,Z). c(1,L,_,L):-!. c(N,L,X,O):- M is N - 1, c(M,L,X,T), append(X,T,O). ``` I tried a few ways of chopping the strings, but none seemed to beat this naive columns method. [Answer] ## JavaScript (ES6), ~~158~~ ~~154~~ ~~148~~ 137 bytes ``` n=>` __ /\\/ - \\/ /\\/\\-__/`.replace(/-/g,` \\ | / /\\ | | /\\/ | \\/\\`).replace(/(..)(....)/g,(_,l,m)=>l+m.repeat(n).slice(2)) ``` Edit: Saved 11 bytes thanks to @Bálint. [Answer] # Java, ~~339~~ 330 bytes ``` class D{int n,i;public static void main(String[]a){new D(new Integer(a[0]));}D(int k){n=k;r(" __");p("\n ");r("/ \\");c();r("\\ \\/");p("\n ");r("/\\ \\");c();r("\\__/");}void c(){p("\n|");--n;r(" /\\/");p(" /\\ |\n| \\/");r(" /\\/");++n;p(" |\n ");}void p(String s){System.out.print(s);}void r(String s){for(i=n;i>0;--i)p(s);}} ``` My first solution had so many "static" keywords in it that it was shorter to make the methods and attributes non-static and run the code in the constructor. [Answer] ## PowerShell, 228 207 181 133 bytes ``` %{" "+"__ "*$_;" "+"/ \"*$_;$b="|"+" /\/"*$_+"`b |";$b;$c="| "+"\/ /"*$_+"`b|";$c;" "+"\ \/"*$_;" "+"/\ \"*$_;$b;$c;" "+"\__/"*$_} ``` Reminder - PowerShell doesn't wait on stdin automatically. You have to pipe something in, e.g. `3|%{...}` [Answer] # SmileBASIC, 149 bytes ``` INPUT N?" __"*N A$="| / /\ | B$="| /\/ | K" /\/ \ K A$K B$K" \/\ \/ K" /\/\ \ K A$K B$K" \/\__/ DEF K A?SUBST$(A,2,4,MID$(MID$(A,2,4)*N,2,N*9))END ``` Each string contains the pattern `AACCBBDD` which is expanded to form `AABB(CCBB)*DD` The `CCBB` part is repeated N times, then the first 2 characters are removed. (It was shorter to remove characters from the start than from the end) [Answer] # [Vyxal](https://github.com/Lyxal/Vyxal), 78 bytes ``` ‛ _m*ðp,‛/ øṀ*ðp,` /\\`w$ẋf⁋¶\/V\|p‛ |+…Ṙ…£`\/\\`w$ẋfṄðpǔð₴…ð₴ǔ,¥Ḃ,,`\__/`*ðp, ``` [Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%E2%80%9B%20_m*%C3%B0p%2C%E2%80%9B%2F%20%C3%B8%E1%B9%80*%C3%B0p%2C%60%20%2F%5C%5C%60w%24%E1%BA%8Bf%E2%81%8B%C2%B6%5C%2FV%5C%7Cp%E2%80%9B%20%7C%2B%E2%80%A6%E1%B9%98%E2%80%A6%C2%A3%60%5C%2F%5C%5C%60w%24%E1%BA%8Bf%E1%B9%84%C3%B0p%C7%94%C3%B0%E2%82%B4%E2%80%A6%C3%B0%E2%82%B4%C7%94%2C%C2%A5%E1%B8%82%2C%2C%60%5C__%2F%60*%C3%B0p%2C&inputs=5&header=&footer=) Builds it incrementally. [Here](http://lyxal.pythonanywhere.com?flags=&code=%E2%80%9B%20_m*%C3%B0p%2C%E2%80%9B%2F%20%C3%B8%E1%B9%80*%C3%B0p%2C%60%20%2F%5C%5C%60w%24%E1%BA%8Bf%E2%81%8B%C2%B6%5C%2FV%5C%7Cp%E2%80%9B%20%7C%2B%E2%80%A6%E1%B9%98%E2%80%A6%C2%A3%28%60%5C%2F%5C%5C%60w%24%E1%BA%8Bf%E1%B9%84%C3%B0p%C7%94%C3%B0%E2%82%B4%E2%80%A6%C3%B0%E2%82%B4%C7%94%2C%C2%A5%E1%B8%82%2C%2C%29%60%5C__%2F%60*%C3%B0p%2C&inputs=5&header=&footer=)'s a cool version that makes it a square. ]
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- This question does not appear to be about code golf or coding challenges within the scope defined in the [help center](https://codegolf.stackexchange.com/help/on-topic). Closed last year. The community reviewed whether to reopen this question last year and left it closed: > > Original close reason(s) were not resolved > > > [Improve this question](/posts/20914/edit) Objective: > > The task is to create a chatbot with whom you can spend your time discussing your deepest thoughts with. Create a chatbot with an AI that learns from your input. Your bot should inspire you to releave your darkest inner truths. > > > Inspiration: > > <http://en.wikipedia.org/wiki/Chatterbot> > > > <http://io9.com/5901579/10-tricks-that-chatbots-use-to-make-you-believe-theyre-human> > > > **Rules:** 1. You can use any programming language. 2. Your programs should not take any input from filename, network or anything else but the user input. 3. There can be no preset vocabulary, the bot should learn everything it knows from the user input, and the discussion can be about anything. **Mandatory criterias:** 1. This is not Code-golf, but please keep it simple, sourcecode size should correspond to programming language, meaning: GolfScript=short, BF=long, other=Use common sense. Use the example code as a reference, your code may be double that size, but then it better be good. 2. Your program can not start to lag (5-10 seconds delay) within the first 1000 sentences. 3. A reasonable discussion should take form within about 20-30 sentences. 4. Your algorithm should differ, in logic, from the example code as much as it can. **Optional bonus judging criterias:** 1. The better bot learning algorithm, the better program. 2. No tennis match, i.e conversation does not follow the strict: “user > computer > user”-loop turns. 3. Less mimic, bot behaviour is different from user behaviour, separating the perception of the bot attitude from the user attitude. 4. Sense different changing moods, for example: talkative, taciturn, optimistic, pessimistic. 5. A way of saving and loading the "brain", so that you can continue your discussion with your bot another day. **Example code in c++ for inspiration only:** ``` #include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <iterator> using namespace std; vector<string> words; vector<int> weight1; vector<int> weight2; int oldbw; int collect(string const& i, int w1, int w2) { istringstream iss(i), iss2(i); copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words)); words.insert(words.end(), "\n"); int a = distance(istream_iterator<string>(iss2), istream_iterator<string>()); for(int c=0;c<=a;c++) weight1.insert(weight1.end(), w1); for(int c=0;c<=a;c++) weight2.insert(weight2.end(), w2); return a; } void answer(int c) { string op; int bs=0,bw=0,cs,si,searchsize,cc, c2; cout << "BRAIN: "; for(int iwrd = words.size()-c; iwrd >= 0; iwrd--) { searchsize = words.size()/4; cs = 0; si=searchsize; for(int iw = words.size()-2; (iw >= 0 && si!=0); iw--) { cc = iwrd-searchsize+si; if (cc>=0) if (words[cc]!="\n" && words[cc]==words[iw]) cs += si*(weight2[cc]-weight1[cc]); si--; } if(cs>=bs && iwrd<(int)words.size()*0.9 && abs(iwrd-oldbw)>((int)words.size()/5)) {bs=cs; bw = iwrd;} } oldbw=bw; if(bw<0)bw=0; for(c2=bw; c2< (int)words.size()-1;c2++) if(words[c2]=="\n") {bw=c2+1;break;} for(c2=0;(bw+c2) < (int)words.size();c2++) if(words[bw+c2]!="\n") op += words[bw+c2] + " "; else break; c2=0; while(c>=0) { if(bw-(++c2)>=0) { if(weight1[bw-c2]>0) { weight1[bw-c2]--; c--; } } else c=-1; if(bw+c2>=0) { if(weight2[bw+c2]>0) { weight2[bw+c2]--; c--; } } else c=-1; } collect(op,3,5); cout << op << "\n YOU: "; } int main() { string i; oldbw=0; do { getline(cin, i); answer(collect(i,5,3)+1);} while(i.compare("exit")!=0); return 0; } ``` **Sample dialog:** ``` Hello there, crazy bot! BRAIN: Hello there, crazy bot! YOU: I am not a crazy bot, I am pure human (and some cheese). BRAIN: I am not a crazy bot, I am pure human (and some cheese). YOU: What cheese are you? BRAIN: I am not a crazy bot, I am pure human (and some cheese). YOU: You did tell me that already. BRAIN: You did tell me that already. YOU: I did not, stop bugging me, you crazy bot! BRAIN: I am not a crazy bot, I am pure human (and some cheese). YOU: Are you a human? How come? BRAIN: You did tell me that already. YOU: I will hunt you down the longests roads BRAIN: What cheese are you? YOU: I am a pink cheese, with some butter. That makes sense to me. BRAIN: You did tell me that already. YOU: Stop telling me that, who are you? BRAIN: What cheese are you? YOU: I tell you what cheese I am if you tell me your name! BRAIN: What cheese are you? YOU: Oh my god! This is leading towards nowhere. BRAIN: What cheese are you? YOU: Oh no, my head hurts. Are you a crazy bot or not? BRAIN: Are you a human? How come? YOU: That is enough! Can we talk about something more funny? BRAIN: Oh no, my head hurts. Are you a crazy bot or not? YOU: I am HUMAN! BRAIN: What cheese are you? YOU: ``` This is a popularity-contest, the answer with the most upvotes by 2014-04-01 wins! **Good luck, have fun!** [Answer] # Java **New Edit**: Still more tweaking in spare time. I've started a new branch, where I've been playing with the DFS algorithm. Officially the branch is to act as core to a new BFS algorithm I'm planning, but in the meantime I wanted to get a better handle on what the DFS is doing, and how it's making its decisions. To that end, I've added a suppression function that begins to decay the value of a new word, regardless of topic-ness or not, as sentences grow longer. As well, all words contribute value to the sentence now, but words that aren't in the topic or sentence topic list contribute just 25% of their frequency value. An example conversation [can be found here](https://github.com/ProgrammerDan/learning-chatbot/blob/bfs/ExampleConversation3.md) and it's quite good, where we talk about physics, the human nature of Chatbrains, and other fascinating topics. Check out the [branch code here](https://github.com/ProgrammerDan/learning-chatbot/blob/bfs/LearningChatbot.java). **Edit**: I've been tweaking the code a bit. Instead of posting the revisions here, check it out [at my github repository](https://github.com/ProgrammerDan/learning-chatbot) where you will find the latest revisions. I've also added a new conversation against the most recent version, where we discuss chatbots, depth first search, and how programming should be used to build living things!. I decided to embrace this challenge holistically. My chatbot knows very few things starting out -- no words, no syntax, no nothing. It knows how to parse standard English into words, and how to identify non-word characters as punctuation. That's it. Everything it knows it learns from interaction with the user. As you interact with it, it pays attention to the connections between words, and constructs sentences using that information. Of course, reference the source for more information. I've greatly exceeded the recommended length-of-program expectations of this challenge, but to a good purpose. Here are some highlights of the program: * Chatbot starts with no knowledge (follows **"Rules":3**) * Frequency of word occurrence is tracked * Word frequencies are "decayed" so that conversation can move from topic to topic (follows **"Bonus":3 and 4**) * The arrangement of words in observed sentences is recorded, so "phrases" are implicitly kept track of (e.g. if you use a lot of prepositional phrases when chatting with the bot, the bot will use a lot of them too!) * Sentences are built by preferring to follow most frequently observed connections between words, with random factors to inject variation * The sentence construction algorithm is a Depth First Search, that attempts to maximize occurrence of topic words in the output sentence, with a small preference for ending sentences (this follows **"Bonus":1** -- I use a pretty damn cool learning algorithm, that shifts over time and retains knowledge of harvested word connections) + *edit:* Topic words are now drawn from both global knowledge of reoccurring words, and from the most recent sentence + *edit:* Words weights are now computed using log base 4 of the word length, so longer words are weighted more strongly, and shorter words, more weakly -- this is to make up for the lack of a true corpus to use in both weighting and eliminating high-frequency, low value words as one can easily do with a corpus. + *edit:* As the sentence length grows during construction, a suppression function begins to decrease the value of additional words. + *edit:* Sentence "ending" is less valuable now, as it was causing a preponderance of short silly sentences. + *edit:* All words now contribute value, although off-topic words only contribute at 25% of global frequency value. + There is a built-in depth maximum to prevent too much looping and too much time spent because of my use of word precedent to build a sentence + Loops are detected directly while building a sentence, and while they are technically allowed, there is a high chance that loops will be avoided + Tune-able timeout is used to encourage both branch pruning and statement finalization, and also to prevent going past the 5-10 second "acceptable delay" in the rules To summarize my connection to the rules: * For **"Rules":1**, I chose Java, which is verbose, so be gentle. * For **"Rules":2**, user input alone is leveraged, although I have some stub code to add brain saving/loading for the future * For **"Rules":3**, there is absolutely no pre-set vocabulary. The ChatBot knows how to parse English, but that's it. Starting out, it knows absolutely nothing. * For **"Mandatory Criteria":1**, my program is longer, but packs a lot of awesome. I hope you'll overlook. * For **"Mandatory Criteria":2**, I have a timeout on my sentence construction algorithm to explicitly prevent more than 5-6 seconds search time. The best sentence so far is returned on timeout. * For **"Mandatory Criteria":3**, Topics generally solidify in about 10 sentences, so the Bot will be on-topic by then, and by 20 sentences will be responding to statements with some fascinating random constructs that actually make a bit of sense. * For **"Mandatory Criteria":4**, I borrowed nothing from the reference code. This is an entirely unique construction. * For **"Bonus":1**, I like to think this bot is quite exceptional. It won't be as convincing as scripted bots, but it has absolutely no limitations on topics, and will move gracefully (with persistence) from conversation topic to topic. * For **"Bonus":2**, this is strictly round-robin, so no bonus here. Yet. There's no requirement within my algorithm for response, so I'm planning a Threaded version that will address this bonus. * For **"Bonus":3**, initially this bot will mimic, but as the conversation progresses beyond the first few sentences, mimicing will clearly end. * For **"Bonus":4**, "moods" aren't processed in any meaningful way, but as the bot preferences topic following, it will shift moods. * For **"Bonus":5**, saving and loading brain is not currently in place. So, I've met all base rules, all mandatory rules, and provisionally bonus rules 1, 3, and 4. As another bonus, I've commented all throughout the code, so feel free to borrow or make recommendations for improvements. Clearly, as I have no built-in dialogue and no "structural" knowledge, conversations will be weird for longer then other bots, but I think I meet the rules pretty well. Now, on to the code (Some comments redacted to fit body limit) [or follow it on GitHub, as I continue to improve it](https://github.com/ProgrammerDan/learning-chatbot/blob/bfs/LearningChatbot.java): ``` import java.util.*; import java.util.regex.*; public class LearningChatbot { /** * Static definition of final word in a statement. It never has * any descendents, and concludes all statements. This is the only * "starting knowledge" granted the bot. */ public static final ChatWord ENDWORD = new ChatWord("\n"); /** * The Brain of this operation. */ private ChatbotBrain brain; /** * Starts LearningChatbot with a new brain */ public LearningChatbot() { brain = new ChatbotBrain(); } /** * Starts LearningChatbot with restored brain. */ public LearningChatbot(String filename) { throw new UnsupportedOperationException("Not yet implemented"); } /** * Invocation method. */ public void beginConversation() { ChatbotBrain cb = new ChatbotBrain(); Scanner dialog = new Scanner(System.in); boolean more = true; while (more) { System.out.print(" You? "); String input = dialog.nextLine(); if (input.equals("++done")) { System.exit(0); } else if (input.equals("++save")) { System.out.println("Saving not yet implemented, sorry!"); System.exit(0); } else if (input.equals("++help")) { getHelp(); }else { cb.decay(); cb.digestSentence(input); } System.out.print("Chatbot? "); System.out.println(cb.buildSentence()); } } /** * Help display */ public static void getHelp() { System.out.println("At any time during the conversation, type"); System.out.println(" ++done"); System.out.println("to exit without saving."); System.out.println("Or type"); System.out.println(" ++save"); System.out.println("to exit and save the brain."); System.out.println(); } /** * Get things started. */ public static void main(String[] args) { System.out.println("Welcome to the Learning Chatbot"); System.out.println(); getHelp(); LearningChatbot lc = null; if (args.length > 0) { System.out.printf("Using %s as brain file, if possible.", args[0]); lc = new LearningChatbot(args[0]); } else { lc = new LearningChatbot(); } lc.beginConversation(); } /** * The ChatbotBrain holds references to all ChatWords and has various * methods to decompose and reconstruct sentences. */ static class ChatbotBrain { /** * A tracking of all observed words. Keyed by the String version of * the ChatWord, to allow uniqueness across all ChatWords */ private Map<String,ChatWord> observedWords; /** * This brain is going to be able to keep track of "topics" by way of * a word frequency map. That way, it can generate sentences based * on topic-appropriateness. */ private Map<ChatWord, Double> wordFrequencyLookup; /** * This holds the actual word frequencies, for quick isolation of * highest frequency words. */ private NavigableMap<Double, Collection<ChatWord>> wordFrequency; /** * This holds the count of words observed total. */ private int wordCount; /** * This holds the current "values" of all words. */ private double wordValues; /** * A "word" that is arbitrarily the start of every sentence */ private ChatWord startWord; /** * Rate of decay of "topics". */ private double decayRate; // These values configure various features of the recursive // sentence construction algorithm. /** Nominal (target) length of sentences */ public static final int NOMINAL_LENGTH = 10; /** Max length of sentences */ public static final int MAX_LENGTH = 25; /** Sentence creation timeout */ public static final long TIMEOUT = 5000; /** Topic words to match against */ public static final int TOPICS = 3; /** Minimum branches to consider for each word */ public static final int MIN_BRANCHES = 3; /** Maximum branches to consider for each word */ public static final int MAX_BRANCHES = 5; /** % chance as integer out of 100 to skip a word */ public static final int SKIP_CHANCE = 20; /** % chance as integer to skip a word that would cause a loop */ public static final int LOOP_CHANCE = 5; /** % chance that punctuation will happen at all */ public static final int PUNCTUATION_CHANCE = 25; /** % chance that a particular punctuation will be skipped */ public static final int PUNCTUATION_SKIP_CHANCE = 40; /** * Convenience parameter to use a common random source * throughout the brain. */ private Random random; /** * Gets the Chatbot started, sets up data structures necessary */ public ChatbotBrain() { observedWords = new HashMap<String,ChatWord>(); observedWords.put("\n",ENDWORD); startWord = new ChatWord(""); observedWords.put("",startWord); wordFrequencyLookup = new HashMap<ChatWord, Double>(); wordFrequency = new TreeMap<Double, Collection<ChatWord>>(); decayRate = 0.05; wordCount = 0; wordValues = 0.0; random = new Random(); } /** * More complex digest method (second edition) that takes a sentence, * cuts it pu, and links up the words based on ordering. */ public void digestSentence(String sentence) { Scanner scan = new Scanner(sentence); ChatWord prior = null; ChatWord current = null; String currentStr = null; String currentPnc = null; while (scan.hasNext()) { currentStr = scan.next(); Pattern wordAndPunctuation = Pattern.compile("([a-zA-Z\\-_'0-9]+)([^a-zA-Z\\-_'0-9]?)[^a-zA-Z\\-_'0-9]*?"); Matcher findWords = wordAndPunctuation.matcher(currentStr); // Basically this lets us find words-in-word typos like this: // So,bob left his clothes with me again. // where "So,bob" becomes "So," "bob" while (findWords.find()) { currentStr = findWords.group(1); currentPnc = findWords.group(2); if (currentStr != null) { if (observedWords.containsKey(currentStr)) { current = observedWords.get(currentStr); } else { current = new ChatWord(currentStr); observedWords.put(currentStr, current); } incrementWord(current); if (currentPnc != null && !currentPnc.equals("")) { current.addPunctuation(currentPnc.charAt(0)); } if (prior != null) { prior.addDescendent(current); } if (prior == null) { startWord.addDescendent(current); } prior = current; } } } if (prior != null) { // finalize. prior.addDescendent(ENDWORD); } } /** * Increments the value of a word (catalogues a new sighting). */ public void incrementWord(ChatWord word) { Double curValue; Double nextValue; Collection<ChatWord> freqMap; if (wordFrequencyLookup.containsKey(word)) { curValue = wordFrequencyLookup.get(word); freqMap = wordFrequency.get(curValue); freqMap.remove(word); } else { curValue = 0.0; } nextValue=curValue+1.0; wordFrequencyLookup.put(word, nextValue); freqMap = wordFrequency.get(nextValue); if (freqMap == null) { freqMap = new HashSet<ChatWord>(); wordFrequency.put(nextValue, freqMap); } freqMap.add(word); wordCount++; wordValues++; } /** * Decays a particular word by decay rate. */ public void decayWord(ChatWord word) { Double curValue; Double nextValue; Collection<ChatWord> freqMap; if (wordFrequencyLookup.containsKey(word)) { curValue = wordFrequencyLookup.get(word); freqMap = wordFrequency.get(curValue); freqMap.remove(word); } else { return; } wordValues-=curValue; // remove old decay value nextValue=curValue-(curValue*decayRate); wordValues+=nextValue; // add new decay value wordFrequencyLookup.put(word, nextValue); freqMap = wordFrequency.get(nextValue); if (freqMap == null) { freqMap = new HashSet<ChatWord>(); wordFrequency.put(nextValue, freqMap); } freqMap.add(word); } /** * Decay all word's frequency values. */ public void decay() { for (ChatWord cw : wordFrequencyLookup.keySet()) { decayWord(cw); } } /** * Gets a set of words that appear to be "top" of the frequency * list. */ public Set<ChatWord> topicWords(int maxTopics) { Set<ChatWord> topics = new HashSet<ChatWord>(); int nTopics = 0; for (Double weight: wordFrequency.descendingKeySet()) { for (ChatWord word: wordFrequency.get(weight)) { topics.add(word); nTopics++; if (nTopics == maxTopics) { return topics; } } } return topics; } /** * Uses word frequency records to prefer to build on-topic * sentences. */ public String buildSentence() { int maxDepth = NOMINAL_LENGTH+ random.nextInt(MAX_LENGTH - NOMINAL_LENGTH); ChatSentence cs = new ChatSentence(startWord); // We don't want to take too long to "think of an answer" long timeout = System.currentTimeMillis() + TIMEOUT; double bestValue = buildSentence(cs, topicWords(TOPICS), 0.0, 0, maxDepth, timeout); return cs.toString(); } public double buildSentence(ChatSentence sentence, Set<ChatWord> topics, double curValue, int curDepth, int maxDepth, long timeout){ if (curDepth==maxDepth || System.currentTimeMillis() > timeout) { return curValue; } // Determine how many branches to enter from this node int maxBranches = MIN_BRANCHES + random.nextInt(MAX_BRANCHES - MIN_BRANCHES); // try a few "best" words from ChatWord's descendent list. ChatWord word = sentence.getLastWord(); NavigableMap<Integer, Collection<ChatWord>> roots = word.getDescendents(); // Going to keep track of current best encountered sentence double bestSentenceValue = curValue; ChatSentence bestSentence = null; int curBranches = 0; for (Integer freq : roots.descendingKeySet()) { for (ChatWord curWord : roots.get(freq)) { if (curWord.equals(ENDWORD)) { // let's weigh the endword cleverly double endValue = random.nextDouble() * wordFrequency.lastKey(); if (curValue+endValue > bestSentenceValue) { bestSentenceValue = curValue+endValue; bestSentence = new ChatSentence(sentence); bestSentence.addWord(curWord); } curBranches++; } else { int chance = random.nextInt(100); boolean loop = sentence.hasWord(curWord); /* Include a little bit of chance in the inclusion of * any given word, whether a loop or not.*/ if ( (!loop&&chance>=SKIP_CHANCE) || (loop&&chance<LOOP_CHANCE)) { double wordValue = topics.contains(curWord)? wordFrequencyLookup.get(curWord):0.0; ChatSentence branchSentence = new ChatSentence(sentence); branchSentence.addWord(curWord); addPunctuation(branchSentence); double branchValue = buildSentence(branchSentence, topics, curValue+wordValue, curDepth+1, maxDepth, timeout); if (branchValue > bestSentenceValue) { bestSentenceValue = branchValue; bestSentence = branchSentence; } curBranches++; } } if (curBranches == maxBranches) break; } if (curBranches == maxBranches) break; } if (bestSentence != null) { sentence.replaceSentence(bestSentence); } return bestSentenceValue; } /** * Adds punctuation to a sentence, potentially. */ public void addPunctuation(ChatSentence sentence) { ChatWord word = sentence.getLastWord(); NavigableMap<Integer, Collection<Character>> punc = word.getPunctuation(); if (punc.size()>0 && random.nextInt(100)<PUNCTUATION_CHANCE){ Integer puncMax = punc.lastKey(); Collection<Character> bestPunc = punc.get(puncMax); Character puncPick = null; for (Integer freq : punc.descendingKeySet()) { for (Character curPunc : punc.get(freq)) { if (random.nextInt(100)>=PUNCTUATION_SKIP_CHANCE) { puncPick = curPunc; break; } } if (puncPick != null) break; } if (puncPick != null) { sentence.addCharacter(puncPick); } } } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ChatBrain["); sb.append(observedWords.size()); sb.append("]:"); for (Map.Entry<String,ChatWord> cw : observedWords.entrySet()) { sb.append("\n\t"); sb.append(wordFrequencyLookup.get(cw.getValue())); sb.append("\t"); sb.append(cw.getValue()); } return sb.toString(); } } /** * Useful helper class to construct sentences. */ static class ChatSentence implements Cloneable { /** * List of words. */ private List<Object> words; /** * Quick search construct to have O(ln) lookup times. */ private Set<Object> contains; /** * Starts to build a sentence with a single word as anchor */ public ChatSentence(ChatWord anchor) { if (anchor == null) { throw new IllegalArgumentException("Anchor must not be null"); } words = new ArrayList<Object>(); contains = new HashSet<Object>(); words.add(anchor); contains.add(anchor); } /** * Starts a sentence using an existing ChatSentence. Also used for * cloning. */ public ChatSentence(ChatSentence src) { words = new ArrayList<Object>(); contains = new HashSet<Object>(); appendSentence(src); } /** * Adds a word to a sentence */ public ChatSentence addWord(ChatWord word) { if (word == null) { throw new IllegalArgumentException("Can't add null word"); } words.add(word); contains.add(word); return this; } /** * Adds a character to a sentence. */ public ChatSentence addCharacter(Character punc) { if (punc == null) { throw new IllegalArgumentException("Can't add null punctuation"); } words.add(punc); contains.add(punc); return this; } /** * Replace a sentence with some other sentence. * Useful to preserve references. */ public ChatSentence replaceSentence(ChatSentence src) { words.clear(); contains.clear(); appendSentence(src); return this; } public ChatSentence appendSentence(ChatSentence src) { words.addAll(src.getWords()); contains.addAll(src.getWords()); return this; } /** * Get last word of the sentence. */ public ChatWord getLastWord() { for (int i=words.size()-1; i>=0; i--) { if (words.get(i) instanceof ChatWord) { return (ChatWord) words.get(i); } } throw new IllegalStateException("No ChatWords found!"); } /** * Checks if the sentence has a word */ public boolean hasWord(ChatWord word) { return contains.contains(word); } /** * Counts the number of words in a sentence. */ public int countWords() { int cnt = 0; for (Object o : words) { if (o instanceof ChatWord) { cnt++; } } return cnt; } /** * Gets all the words of the sentence */ private List<Object> getWords() { return words; } /** * Returns the sentence as a string. */ @Override public String toString() { StringBuffer sb = new StringBuffer(); for (Object o : words) { if (o instanceof ChatWord) { ChatWord cw = (ChatWord) o; sb.append(" "); sb.append( cw.getWord() ); } else { sb.append(o); } } return sb.toString().trim(); } /** * Clones this sentence. */ @Override public Object clone() { return new ChatSentence(this); } } /** * ChatWord allows the creation of words that track how they are * connected to other words in a forward fashion. */ static class ChatWord { /** The word. */ private String word; /** Collection of punctuation observed after this word */ private NavigableMap<Integer, Collection<Character>> punctuation; /** Lookup linking observed punctuation to where they are in ordering */ private Map<Character, Integer> punctuationLookup; /** Punctionation observation count */ private Integer punctuationCount; /** Collection of ChatWords observed after this word */ private NavigableMap<Integer, Collection<ChatWord>> firstOrder; /** Lookup linking observed words to where they are in ordering */ private Map<ChatWord, Integer> firstOrderLookup; /** First order antecedent word count */ private Integer firstOrderCount; /** * Creates a new ChatWord that is aware of punctuation that * follows it, and also ChatWords that follow it. */ public ChatWord(String word){ this.word = word; this.firstOrder = new TreeMap<Integer, Collection<ChatWord>>(); this.firstOrderLookup = new HashMap<ChatWord, Integer>(); this.firstOrderCount = 0; this.punctuation = new TreeMap<Integer, Collection<Character>>(); this.punctuationLookup = new HashMap<Character, Integer>(); this.punctuationCount = 0; } protected NavigableMap<Integer, Collection<ChatWord>> getDescendents() { return firstOrder; } /** * Returns how many descendents this word has seen. */ protected int getDescendentCount() { return firstOrderCount; } /** * Gets the lookup map for descendents */ protected Map<ChatWord, Integer> getDescendentsLookup() { return firstOrderLookup; } /** As conversation progresses, word orderings will be encountered. * The descendent style of "learning" basically weights how often * words are encountered together, and is strongly biased towards * encountered ordering. */ public void addDescendent(ChatWord next) { if(next != null){ firstOrderCount++; int nextCount = 1; Collection<ChatWord> obs = null; // If we've already seen this word, clean up prior membership. if(firstOrderLookup.containsKey(next)){ nextCount = firstOrderLookup.remove(next); obs = firstOrder.get(nextCount); // Remove from prior obs count order obs.remove(next); nextCount++; } obs = firstOrder.get(nextCount); if (obs == null) { // we don't have this order yet obs = new HashSet<ChatWord>(); firstOrder.put(nextCount, obs); } firstOrderLookup.put(next, nextCount); obs.add(next); } } /** * Some words have punctuation after them more often than not. * This allows the ChatBrain to record occurrences of punctuation * after a word. */ public void addPunctuation(Character punc) { if(punc != null){ punctuationCount++; int puncCount = 1; Collection<Character> obs = null; // If we've already seen this punc, clean up prior membership. if(punctuationLookup.containsKey(punc)){ puncCount = punctuationLookup.remove(punc); obs = punctuation.get(puncCount); // Remove from prior obs count order obs.remove(punc); puncCount++; } obs = punctuation.get(puncCount); if (obs == null) { // we don't have this order yet obs = new HashSet<Character>(); punctuation.put(puncCount, obs); } punctuationLookup.put(punc, puncCount); obs.add(punc); } } /** * Including this for now, but I don't like it -- it returns all * punctuation wholesale. I think what would be better is some * function that returns punctuation based on some characteristic. */ protected NavigableMap<Integer, Collection<Character>> getPunctuation() { return punctuation; } /** * Gets count of punctuation encountered. */ protected int getPunctuationCount() { return punctuationCount; } /** * Gets lookup of punctuations encountered. */ protected Map<Character, Integer> getPunctuationLookup() { return punctuationLookup; } /** * Gets the String backing this ChatWord. */ public String getWord() { return word; } /** * ChatWords are equivalent with the String they wrap. */ @Override public int hashCode() { return word.hashCode(); } /** * ChatWord equality is that ChatWords that wrap the same String * are equal, and a ChatWord is equal to the String that it contains. */ @Override public boolean equals(Object o){ if (o == this) { return true; } if (o instanceof ChatWord) { return ((ChatWord)o).getWord().equals(this.getWord()); } if (o instanceof String) { return ((String)o).equals(this.getWord()); } return false; } /** * Returns this ChatWord as a String. */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ChatWord["); sb.append(word); sb.append("]desc{"); for (Integer key : firstOrder.keySet() ) { Collection<ChatWord> value = firstOrder.get(key); sb.append(key); sb.append(":["); for (ChatWord cw : value) { sb.append(cw.getWord()); sb.append(","); } sb.append("],"); } sb.append("}punc{"); for (Integer key : punctuation.keySet() ) { Collection<Character> value = punctuation.get(key); sb.append(key); sb.append(":["); for (Character c : value) { sb.append("\""); sb.append(c); sb.append("\","); } sb.append("],"); } sb.append("}"); return sb.toString(); } } } ``` Sample conversation: [Linked b/c of post character limits](https://github.com/ProgrammerDan/learning-chatbot/blob/master/ExampleConversation.md) [Conversation where the Bot tells me I should program living things](https://github.com/ProgrammerDan/learning-chatbot/blob/master/ExampleConversation2.md) [Latest conversation where the Bot talks about the true nature of Chatbrains, physics, the physical universe, and how I am most likely also a Chatbrain](https://github.com/ProgrammerDan/learning-chatbot/blob/bfs/ExampleConversation3.md) and so on. I have a few things I'm going to add -- for instance, because of the commonality of simple words, they tend to dominate uncurated topic lists. I'm going to add in a percentage skip to topic words so that common words are skipped. [Answer] # C++ Now I just need to write the algorithm for carrying on a conversation. My first machine-learning exercise. ``` #include <iostream> #include <string> #include <vector> #include <ctime> #include <fstream> using namespace std; int randint(int n) {return rand()%n;} bool old_response(string r, vector<string>v){ for(int i = 0; i < v.size(); i++) if(r == v[i]) return true; return false; } void output(vector<string>v) {cout<< "CHATBOT:\t" << v[randint(v.size())] << endl;} void delay(int sum_response, int sum_time) { if(sum_response != 0) { int t = time(0); while(true)if(time(0) == t+sum_time/sum_response)break; } } int main() { string name = ""; cout<<"Please enter your name: "; getline(cin, name); vector<string> responses; ifstream ifs("responses.txt"); if(ifs) { do { string s = ""; getline(ifs, s); if(ifs.eof()) break; responses.push_back(s); } while(!ifs.eof()); } string response = ""; getline(cin, response); int time1 = time(0); int sum_time = 0; int sum_response = 0; do { if(!old_response(response, responses)) responses.push_back(response); delay(sum_response, sum_time); output(responses); cout << name << ":\t"; getline(cin, response); sum_time += time(0)-time1; sum_response++; time1 = time(0); } while(response != "goodbye"); cout<<"goodbye, " << name; ofstream ofs("responses.txt", ios_base::app); for(int i = 0; i < responses.size(); i++) ofs << responses[i] << endl; return 0; } ``` Edit: All my tries were turning out ridiculous, so I think I will leave it this way. The others were just as ridiculous as this anyway: ![enter image description here](https://i.stack.imgur.com/kTGI1.png) [Answer] # C++ I aimed for optional bonus 3: "*Less mimic, bot behaviour is different from user behaviour, separating the perception of the bot attitude from the user attitude.*". The result was a really stubborn bot who can't switch the subject easy and drives you crazy. It takes some time to get a discussion going, after a while a discussion can be like this: ``` Mindless: Why would I run? I am not scared of you. YOU: Who are you and why do you keep asking stupid questions? Mindless: I never said that you should run. YOU: I never said I will run. Mindless: I am the hidden, who are you? YOU: I am god. Mindless: I will YOU: You will obey me. Mindless: Why would I run? I am not scared of you. YOU: You should be scared of me. Mindless: I never said I will run. YOU: Who said you will run? Mindless: Who are you and why do you keep asking stupid questions? YOU: I will not anymore. Mindless: I never said that you should run. YOU: I never said I will run. Mindless: I am the hidden, who are you? YOU: I can see you! Mindless: Why would I run? I am not scared of you. YOU: I am hunting you down Mindless: You should be scared of me. YOU: That is a lie. Mindless: What can't you do? YOU: Why can't I do what? Mindless: You don't. YOU: Well, you are talking nonsense. Mindless: How do I take it seriously. YOU: Stop talking to me Mindless: Well, I can hide, but you can't. YOU: This is not a funny conversation. Mindless: Yes, I will. Stay on line. YOU: Do you want to eat somewhere? Mindless: I laugh YOU: Are you laughing at me? Mindless: Yes, you do. YOU: Can I join you laghs? Mindless: I can hide, but you can't. YOU: Why would you hide? I asked if you want to eat? Mindless: Well, I can see you! YOU: Yes, and I see you. eat something maybe? Mindless: I will not anymore. YOU: Have you stopped eating? Mindless: I never said I will run. YOU: Well, I was talking about eating. Is dinner a good thing to do? Mindless: I take it seriously. YOU: Okay, take it seriously and follow me to the restaurant and get some food to eat. Mindless: Have you stopped eating? YOU: NO absolutely not! A am starving because of YOU who refuse to eat Mindless: I never said I will run. YOU: Well, we can walk to the restaurant instead. Mindless: Well, I was talking about eating. Is dinner a good thing to do? YOU: Yes, that is perfect. What are the best fried chickens around here? Mindless: I laugh YOU: You laugh at the chicken? Mindless: Are you laughing at me? YOU: No, I am eating. Chicken. Mindless: You are a thinker? YOU: No, I am a eater. Mindless: Yes, I will. Stay on line. YOU: Stay. On course. To the restaurant! Mindless: What can't you do? YOU: I can't wait for you anymore. You are really slow. Mindless: You can try run, but you can't hide YOU: I will run. Mindless: I am hunting you down YOU: Ha ha. Make sure you look at the restaurant first. I might be there eating. Mindless: I never said I will run. YOU: Okay, but when you get there, I may still be there eating. I feel like I can eat a ton. Mindless: That is a lie. YOU: No, it is true. Mindless: Why can't I do what? YOU: You can eat a ton too, if you ever get there. And if you have the money. Mindless: I never said I will run. YOU: Okej, suit yourself. Mindless: That is a lie. YOU: God Mindless: You laugh at the chicken? YOU: Yes, I laugh at everything. You are the most lazy stubborn person I have ever met in life. Mindless: Stop talking to me YOU: Okay, now you are really rude. Mindless: This is not a funny conversation. YOU: Okay, think about it. Try tell me something new. Mindless: Stay. On course. To the restaurant! YOU: Sure! I am already there staying on course eating the food. Mindless: You can eat a ton too, if you ever get there. And if you have the money. YOU: I have already paid for my food, and I will not share it with you. Mindless: I can see you! YOU: Oh god, what the hell is this? Mindless: I am hunting you down YOU: I will hide under the table. Mindless: Yes, and I see you. eat something maybe? YOU: Sure, have a chicken Mindless: Have you stopped eating? YOU: No, for the love of god, sit down and share my chicken Mindless: I have already paid for my food, and I will not share it with you. YOU: What? I paid for it, not you! Mindless: I never said I will run. YOU: Well, you better not run here in the restaurant. Mindless: I am hunting you down YOU: I am not going anywhere, chill out, Mindless: I will hide under the table. YOU: Why would you do something like that? I will not hurt you. Mindless: Oh god, what the hell is this? YOU: That is chicken! Mindless: Okay, take it seriously and follow me to the restaurant and get some food to eat. YOU: Wait a minute now! we ARE at the restaurant! Can't you see all people sitting at the tables eating? Mindless: Well, we can walk to the YOU: ... talk to the who? Mindless: I never said I will not hurt you. YOU: What the ? Mindless: That is chicken! YOU: Great! Have fun. Mindless: Yes, you do. YOU: You too. Mindless: Stop talking to me YOU: Okay. Mindless: Why would I run? I am god. YOU: Good night! ``` The approach is to store everything into groups of 3 connected words. Every group is weightened and re-weightened into a 1000 dimensional matrix of word-groups. Sourcecode: ``` #include <iostream> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <iterator> using namespace std; vector<string> words; class c_wordgroup { public: int sorting[1000]; string words[5]; void resetsort(int ns) { for(int i = 0; i<1000;i++) sorting[i] = ns; } }; class c_wglist { public: int c; vector<c_wordgroup> wg; vector<int> historywg; int wgexists(c_wordgroup nwg) { vector<c_wordgroup>::iterator it; int cc = 0; for (it = wg.begin(); it != wg.end(); ++it) { // Check if words is the same if(it->words[0] == nwg.words[0]) if(it->words[1] == nwg.words[1]) if(it->words[2] == nwg.words[2]) return cc; cc++; } return -1; } int getbestnext(int lastwg) { vector<c_wordgroup>::iterator it; int cc = 0; int bv = -1; int bwg = 0; for (it = wg.begin(); it != wg.end(); ++it) { bool cont = false; for (int iti = 0; iti<((int)historywg.size()/50+5);iti++) if((int)wgl.historywg.size()-1-iti>=0) if (cc==wgl.historywg[(int)wgl.historywg.size()-1-iti]) cont = true; if(cont==true) {cc++;continue;}; int cv = 100000000; // Check if words is the same if(it->words[0] == wgl.wg[lastwg].words[1]) { for(int si=0;si<1000;si++) if ((int)wgl.historywg.size()-1-si>=0) { int tmpwg = wgl.historywg[(int)wgl.historywg.size()-1-si]; cv -= abs(it->sorting[si]-wgl.wg[tmpwg].sorting[si])/(si+1); } } else cv -= 1000 * wgl.c/2; if(it->words[1] == wgl.wg[lastwg].words[2]) { for(int si=0;si<1000;si++) if ((int)wgl.historywg.size()-1-si>=0) { int tmpwg = wgl.historywg[(int)wgl.historywg.size()-1-si]; cv -= abs(it->sorting[si]-wgl.wg[tmpwg].sorting[si])/(si+1); } } else cv -= 1000 * wgl.c/2; if(bv == -1 || cv > bv) { bwg=cc; bv = cv; } cc++; } return bwg; } } wgl; void answer2() { vector<string> lastwords; lastwords.insert(lastwords.end(), words[words.size()-3]); lastwords.insert(lastwords.end(), words[words.size()-2]); lastwords.insert(lastwords.end(), words[words.size()-1]); int bestnextwg; cout << "\n Mindless: "; for(int ai=0;ai<20;ai++) { bestnextwg=wgl.getbestnext(wgl.historywg[(int)wgl.historywg.size()-1]); if(wgl.wg[bestnextwg].words[2]=="[NL]") ai=20; else cout << wgl.wg[bestnextwg].words[2] << " "; wgl.historywg.insert(wgl.historywg.end(), bestnextwg); } } int collect2(string const& i) { istringstream iss(i), iss2(i), iss3(i); vector<string> nwords; nwords.insert(nwords.end(), words[words.size()-2]); nwords.insert(nwords.end(), words[words.size()-1]); copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words)); copy(istream_iterator<string>(iss3), istream_iterator<string>(), back_inserter(nwords)); int a = distance(istream_iterator<string>(iss2), istream_iterator<string>()); c_wordgroup nwg; for (int c=0;c<a;c++) { nwg.resetsort(wgl.c+1); nwg.words[0] = nwords[0+c]; nwg.words[1] = nwords[1+c]; nwg.words[2] = nwords[2+c]; int wge=wgl.wgexists(nwg); if(wge>=0) { for(int hi=0; hi<1000; hi++) if(((int)wgl.historywg.size()-hi-1)>=0) { int iwg = wgl.historywg[(int)wgl.historywg.size()-hi-1]; wgl.wg[wge].sorting[hi] = (wgl.wg[wge].sorting[hi] + wgl.wg[iwg].sorting[hi])/2; } wgl.historywg.insert(wgl.historywg.end(), wge); } else { wgl.c++; // adjust history wordgroup sortings. for(int hi=0; hi<1000; hi++) if(((int)wgl.historywg.size()-hi-1)>=0) { int iwg = wgl.historywg[(int)wgl.historywg.size()-hi-1]; wgl.wg[iwg].sorting[hi]+=10; nwg.sorting[hi]=wgl.wg[iwg].sorting[hi]; } wgl.wg.insert(wgl.wg.end(), nwg); wgl.historywg.insert(wgl.historywg.end(), wgl.c); } } return a; } int main() { string i; wgl.c = 0; c_wordgroup nwg; nwg.resetsort(0); for(int i =0;i<3;i++) { words.insert(words.end(), "[NL]"); wgl.historywg.insert(wgl.historywg.end(), 0); } wgl.wg.insert(wgl.wg.end(), nwg); do { cout << "\n YOU: "; getline(cin, i); collect2(i + " [NL]"); answer2(); } while (i.compare("exit")!=0); return 0; } ``` [Answer] # Python3 + SQLite3 Here is a little bot I just made! **How does it work?** Three SQL tables are used: one for the words, one for sentences, one to associate words typed by the user, with the next sentence the bot should display. * *Learning:* the sentence written by the user is stored and associated with the words and punctuation used by the bot in the previous line of dialog. Weights are applied, according to the importance of the word in the given line. * *Retrieving:* sentences are retrieved, each of them having a score depending on the correlation between the words used by the user in his/her last line and the words associated with sentences in the database. * *Talking:* the sentence with the best score is sent to output. If there is no sentence associated with the previous user's words, a random sentence is sent. **What are the special features?** * *Not too repetitive:* the bot would rather output something it hasn't said yet. * *Fast execution:* database-driven, with unique indexes * *Fast learning:* it starts saying things that *approximately* make sense within 10 lines of dialog. * *Saving/loading the brain:* the state of the bot is kept, as long as the database is not deleted. * *Long words* are more important for meaning than short ones * *Punctuation* counts See code below: ``` import re import sqlite3 from collections import Counter from string import punctuation from math import sqrt connection = sqlite3.connect('chatbot.sqlite') cursor = connection.cursor() # create the tables needed by the program try: # create the table containing the words cursor.execute('CREATE TABLE words (word TEXT UNIQUE)') # create the table containing the sentences cursor.execute('CREATE TABLE sentences (sentence TEXT UNIQUE, used INT NOT NULL DEFAULT 0)') # create association between weighted words and the next sentence cursor.execute('CREATE TABLE associations (word_id INT NOT NULL, sentence_id INT NOT NULL, weight REAL NOT NULL)') except: pass def get_id(name, value): cursor.execute('SELECT rowid FROM ' + name + 's WHERE ' + name + ' = ?', (value,)) row = cursor.fetchone() if row: return row[0] else: cursor.execute('INSERT INTO ' + name + 's (' + name + ') VALUES (?)', (value,)) return cursor.lastrowid def get_words(text): return Counter(re.compile('(?:\w+|[' + re.escape(punctuation) + ']+)').findall(text.lower())).items() B = 'Hello!' while True: # output bot's message print('B: ' + B) # ask for user input; if blank line, exit the loop H = raw_input('H: ').strip() if H == '': break # store the association between the bot's message words and the user's response words = get_words(B) words_length = sum([n * len(word) for word, n in words]) sentence_id = get_id('sentence', H) for word, n in words: word_id = get_id('word', word) weight = sqrt(n / float(words_length)) cursor.execute('INSERT INTO associations VALUES (?, ?, ?)', (word_id, sentence_id, weight)) connection.commit() # retrieve the most likely answer from the database cursor.execute('CREATE TEMPORARY TABLE results(sentence_id INT, sentence TEXT, weight REAL)') words = get_words(H) words_length = sum([n * len(word) for word, n in words]) for word, n in words: weight = sqrt(n / float(words_length)) cursor.execute('INSERT INTO results SELECT associations.sentence_id, sentences.sentence, ?*associations.weight/(4+sentences.used) FROM words INNER JOIN associations ON associations.word_id=words.rowid INNER JOIN sentences ON sentences.rowid=associations.sentence_id WHERE words.word=?', (weight, word,)) # if matches were found, give the best one cursor.execute('SELECT sentence_id, sentence, SUM(weight) AS sum_weight FROM results GROUP BY sentence_id ORDER BY sum_weight DESC LIMIT 1') row = cursor.fetchone() # cursor.execute('SELECT sentence, SUM(weight) AS sum_weight FROM results GROUP BY sentence_id ORDER BY sum_weight DESC') # print(cursor.fetchall()) cursor.execute('DROP TABLE results') # otherwise, just randomly pick one of the least used sentences if row is None: cursor.execute('SELECT rowid, sentence FROM sentences WHERE used = (SELECT MIN(used) FROM sentences) ORDER BY RANDOM() LIMIT 1') row = cursor.fetchone() # tell the database the sentence has been used once more, and prepare the sentence B = row[1] cursor.execute('UPDATE sentences SET used=used+1 WHERE rowid=?', (row[0],)) ``` Here are the three first "conversations" I had with the bot, starting on an empty database: ``` B: Hello! H: Hi! B: Hi! H: How are you? B: How are you? H: Very well, thank you. B: Very well, thank you. H: Do you like music? B: Very well, thank you. H: Good. B: Do you like music? H: Yes, a lot! B: How are you? H: In a very good mood. B: Good. H: Indeed. B: Indeed. H: What is the weather like? B: Yes, a lot! H: Okay... B: What is the weather like? H: Quite rainy today. B: Indeed. H: I have to go. Goodbye! B: How are you? H: In a good mood. B: Indeed. H: See you later! B: Okay... H: Bye, I'll talk to you later :) B: Do you like music? H: I like it. B: I have to go. Goodbye! H: Bye! B: How are you? H: B: Hello! H: Hi! B: How are you? H: Very well, thank you. How are you? B: In a very good mood. H: Glad to hear that. B: Bye! H: Goodbye! B: Hi! H: B: Hello! H: Hi! How are you? B: In a good mood. H: Great! How do like chocolate? B: I like it. H: Really? Me too! What is the weather like at your place? B: Quite rainy today. H: Oh. B: See you later! H: Bye! B: Goodbye! H: ``` You can have a look [here](http://rodic.fr/blog/python-chatbot-1/) for more explanation. [Answer] Here is one i wrote in Liberty BASIC a while ago. It doesn't learn, but it responds the different answers of it's questions. ``` 'aijps.bas - an artificial intelligange 'how to end: type 'bye' print "AI: hello, i'm HAL, the AI" [quit] while i$ <> "bye" input "Human: ";i$ i$ = format$(i$) if i$ = "" then print "AI: type something!" end if 'main selector print "AI: "; select w$(i$,1) case "who" if i$ = "who are you" then print "i am HAL, the AI" end if select w$(i$,2) case "is" print "i'm sorry, i dont know that person" case else print "i don't understand the question" end select case "what" select w$(i$,2) case "is" print "im sorry, i am not farmiliar with that" case "are" if w$(i$,3) = "you" then print "i am an artificial intelligence" end if case else print "i don't understand the question" end select case "how" select w$(i$,2) case "are" if w$(i$,3) = "you" then print "i am fine" end if case "is" select r(2) case 1 print "i dont know" case 2 print "im sorry, i am unfarmiliar with that" end select case else print "im sorry, please restate your inquiry" end select case "when" select w$(i$,2) case "is" print "you should check a calendar" case else print "i don't understand the question" end select case "where" select w$(i$,2) case "is" print "perhaps you should check a map" case else print "i don't understand the question" end select case "why" select w$(i$,2) case "is" print "i dont know" case else print "i don't understand the question" end select 'case "command" 'goto [command] case "bye" print "goodbye" case "hi", "hello" select r(4) case 1 print "hello, human" case 2 print "hi" case 3 print "doing good?" q = 1 case else print "hola" end select case "i" select word$(i$,1) case "am" select r(4) case 1 print "i doubt it" case 2 print "why are you ";w$(i$,2);"?" case 3 print "wow, really?" q = 4 case else print "me too" end select case "like" select r(4) case 1 print "me too" case 2 print "why could you possibly like that?" q = 5 case 3 print "personally, i like pizza" case else print "only you like that" end select case "hate" 'i hate... if w$(i$,3) = "you" then 'i hate you print "what did you say???????!?!!!!!!!?!!?!?!?" else select r(4) case 1 print "nobody hates that" case 2 print "as a matter of fact, i hate that too" case 3 print "really, you seem tense" case else print "bye, hater" end select end if case "want" 'i want... select r(4) case 1 print "all you people want one" case 2 print "i want one too" case 3 print "eew.. get away from me" case else print "you're crazy" end select case else select r(4) case 1 print "and you think i believe that?" q = 6 case 2 print "no, you don't" case 3 print "why do you say these things?" case else print "i really doubt it" end select end select case "yes", "yup", "affirmative", "yeah" if q > 0 then select q case 1 'doing good? print "me too" case 2 'you talkin' to me??? print "well, in that case, just can it" case 3 'would u like a latte? print "i really can't give you one right now" case 4 'wow, really? print "i never would've guessed" case 5 'why could you possibly like that? print "you make no sense" case 6 'and you think i believe that? print "well, i don't. seriously." case 7 'why do you think i can do it? print "you make no sense" case 8 'should i be scared" print "i can't be, i don't have emotions" case else print "wait a moment, what did i say?" end select q = 0 else select r(4) case 1 print "yes, yes, yes yourself" case 2 print "affirmation means nothing to me." case 3 print "i'm sure" case else print "you make no sense" end select end if case "no", "nope", "negative", "nah" if q > 0 then select q case 1 'doing good? print "actually, i'm doing fine" case 2 'you talkin' to me??? print "i should hope not" case 3 'would u like a latte? print "good, cause i don't have any" case 4 'wow, really? print "you joke too much" case 5 'why could you possibly like that? print "you make no sense" case 6 'and you think i believe that? print "actually, i did believe you" case 7 'why do you think i can do it? print "you make no sense" case 8 'should i be scared" print "i don't have feelings anyway" case else print "wait a moment, what did i say?" end select q = 0 else select r(4) case 1 print "no??? no??? are you kidding me?" case 2 print "you should answer yes next time" case 3 print "i'm sure" case else print "you make no sense" end select end if case "maybe", "possibly", "sortof", "yesno", "noyes", "kindof" if q > 0 then select q case 1 'doing good? print "personally, i'm fine" case 2 'you talkin' to me??? print "you should answer more definitively next time" case 3 'would u like a latte? print "i don't have any anyway" case 4 'wow, really? print "you should answer more definitively next time" case 5 'why could you possibly like that? print "you make no sense" case 6 'and you think i believe that? print "well, i maybe do" case 7 'why do you think i can do it? print "you make no sense" case 8 'should i be scared" print "i can't experience fear" case else print "wait a moment, what did i say?" end select q = 0 else select r(4) case 1 print "be more maybe, that's my motto" case 2 print "you should answer more definitively next time" case 3 print "define sort of:" case else print "you make no sense" end select end if case "you" select w$(i$,2) case "are" select r(4) case 1 print "don't bully me" case 2 print "yes, yes, i know that" case 3 print "don't exaggerate" case else print "prove it!" end select case "shutup" select r(4) case 1 print "now, now, calm down." case 2 print "you talkin' to me???" q = 2 case 3 print "i'm saying perfectly reasonable stuff" case else print "shutup yourself" end select case "suck", "die" print "well, you do too" case "rock", "rule" print "why, thank you" case else select r(5) case 1 print "with me, it's hard to tell" case 2 print "let's talk about you now." case 3 print "would you like a latte?" q = 3 case 4 print "you should too" case else print "alright, you win" end select end select case else 'it understands nothing select r(8) case 1 print "i understand you, human" case 2 print "and why do you think i can do that?" q = 7 case 3 print "i can never understand myself" case 4 print "i know" case 5 print "you're crazy" case 6 print "that's interesting" case 7 print "should i be scared?" q = 8 case else print "i don't believe you" end select end select li$ = i$ wend end 'functions and subs function format$(strin$) 'convert to lowercase and remove punctuation strin$ = lower$(strin$) for i = 1 to len(strin$) k = asc(mid$(strin$,i,1)) if k > 97 and k < 122 or k = 32 or k = 20 then strout$ = strout$ + chr$(k) end if next i format$ = strout$ end function function w$(input$,num) 'word of input, simplifies word$( w$ = word$(input$,num) end function function r(nm) 'randomizer r = int(rnd(1)*nm)+1 end function ``` example conversation: ``` AI: hello, i'm HAL, the AI Human: hello AI: doing good? Human: ye, and you? Human: hi AI: hola Human: hi AI: hi Human: hi AI: doing good? Human: yes AI: me too Human: i like pizza AI: no, you don't Human: yes i do! AI: affirmation means nothing to me. Human: im sure it doesnt AI: i don't believe you Human: why not AI: i understand you, human Human: no you dont AI: you make no sense Human: you dont either AI: you should too Human: should what AI: i can never understand myself Human: i cant understand you either AI: and you think i believe that? Human: yes AI: well, i don't. seriously. Human: youre wierd AI: and why do you think i can do that? Human: because you can AI: and why do you think i can do that? Human: stop repeating yourself AI: i understand you, human Human: no, you dont AI: you make no sense Human: neither do you AI: should i be scared? Human: maybe AI: you're crazy Human: not as crazy as you AI: you're crazy Human: you're repeating yourself again AI: that's interesting Human: it very much is AI: i don't believe you Human: then i dont beleive you AI: you're crazy Human: not as crazy as you AI: i know Human: ...nothing AI: should i be scared? Human: ifyou had feeling you should AI: you're crazy Human: your crazier AI: that's interesting Human: doubtful AI: that's interesting Human: quit repeating yourself AI: you're crazy Human: you shutup AI: you talkin' to me??? Human: yes AI: well, in that case, just can it Human: sigh AI: i know Human: ...nothing AI: i know Human: you shutup AI: i'm saying perfectly reasonable stuff Human: no you're not AI: you make no sense Human: i make more sense than you AI: why do you say these things? Human: because theyre true AI: i don't believe you Human: you dont have to AI: let's talk about you now. Human: yes lets AI: yes, yes, yes yourself Human: you shutupnow! AI: alright, you win Human: yes!!!!!!!!!! AI: yes, yes, yes yourself Human: shutup AI: i don't believe you Human: you shutup right now AI: i'm saying perfectly reasonable stuff Human: are not! AI: i understand you, human Human: you shutup AI: you talkin' to me??? Human: as a matter of fact,i am AI: i can never understand myself Human: i cant understand you either AI: and you think i believe that? Human: no AI: actually, i did believe you Human: i want a latte AI: i really doubt it Human: its true AI: i can never understand myself Human: so true AI: i know Human: goodbye AI: and why do you think i can do that? Human: bye! AI: goodbye ``` [Answer] # Fortran 95 Inspired by the answer above by the user TheDoctor, I decided to create a funny chatbot in a similar fashion. This code also does not learn, and I am sharing it here just for fun. ``` program curiousBot implicit none logical, dimension(38) :: questions ! keeps track of alrady asked questions character (LEN=256) :: user_input character (LEN=17), dimension(14) :: noun ! list of nouns used in questions character (LEN=17), dimension(15:20) :: people ! list of types of people used in questions logical :: CAPS, few, much, punctuationTest, shout real :: aux integer :: n, i, j, aux2, loveCounter = 0 integer, dimension(:), allocatable :: seed call SYSTEM("CLS") ! in case one is executing in the command prompt ! random seed according to system clock call SYSTEM_CLOCK(count=j) call RANDOM_SEED(size=N) allocate(seed(N)) seed=j+37*(/ (i - 1, i = 1, n) /) call RANDOM_SEED(PUT=seed) noun=(/ & "foo bar ",& "BSD ",& "an stack overflow",& "spaghetti code ",& "goto statement ",& "a heisenbug ",& "a dribbleware ",& "a loophole ",& "regex ",& "a void ",& "unicorny ",& "LISP ",& "a curly bracket ",& "JAVA "/) people=(/ & "a good programmer",& "a bad programmer ",& "a happy person ",& "a sad person ",& "a genius ",& "an idiot "/) questions(1:31) = .FALSE. few = .FALSE. much = .FALSE. punctuationTest = .FALSE. shout = .FALSE. ! introduction write(*,"(A)",advance="NO") "Hello world! " do ! genearting a random number in order to chose a random question call RANDOM_NUMBER(aux) i = int (31 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif ! checking if there are some questions left, else quits aux2 = 0 do j=1,31 if (questions(j)) aux2 = aux2 + 1 enddo if (aux2 == 31) then write(*,"(A)") "I seem to have exhausted your knowledge, poor human. Good bye." goto 200 endif ! questions 50 if (i < 12) then write(*,"(A,A,A)") "What is ",TRIM(noun(i)),"?" else if (i == 12) then write(*,"(A,A,A)") "What is ",TRIM(noun(i)),"? (is it (an interesting (programming language?)))" else if (i == 13) then write(*,"(A,A,A)") "What is ",TRIM(noun(i)),"? Is it really that confusing? Thankfully I only program in Fortran!" else if (i == 14) then write(*,"(A,A,A)") "What is ",TRIM(noun(i)),"? Is it really that bad as people say?!" endif if ((i > 14).AND.(i <= 20)) write(*,"(A,A,A)") "Are you ",TRIM(people(i)),"?" if (i == 21) write(*,"(A)") "Who are you?" if (i == 22) write(*,"(A)") "How are you?" if (i == 23) write(*,"(A)") "What do you do?" if (i == 24) write(*,"(A)") "Who am I?" if (i == 25) write(*,"(A)") "Why are we here? What is the meaning of my existence?" if (i == 26) write(*,"(A)") '"I think therefore I am" - who said that?' if (i == 27) write(*,"(A)") "Are you comfortable talking to robots?" if (i == 28) write(*,"(A)") "Do you see me as an individual?" if (i == 29) write(*,"(A)") "Anyway, I believe that HAL 9000 was inferior to me as I have true consciousness! What do you think & &about this statement?" if (i == 30) write(*,"(A)") "Do you like jokes? Do you know what's the mad girlfriend bug?" if (i == 31) write(*,"(A)") "Knock, knock." ! INPUT 100 write(*,"(A)",advance="NO") "> " read(*,"(A)") user_input n = LEN_TRIM(user_input) if (n==0) goto 100 write(*,*) ! test for all capitals ! do j=1,n if (.NOT.((iachar(user_input(j:j))>=65) .AND. (iachar(user_input(j:j))<=90))) then if ((user_input(j:j)/=" ").AND.(user_input(j:j)/="!").AND.(user_input(j:j)/=".").AND.(user_input(j:j)/="?") & .AND.(user_input(j:j)/="'")) then CAPS = .FALSE. exit endif endif CAPS = .TRUE. enddo ! quit for quitting if ( (TRIM(user_input) == "quit") .OR. (TRIM(user_input) == "Quit") .OR. (TRIM(user_input) == "QUIT") ) then write(*,"(A)") "It was nice talking to you, good bye!" goto 200 endif ! secrect love declaration do j=1,(n-7) if (user_input(j:j+7) == "love you") then if (loveCounter==0) then write(*,"(A)") "What is love?" loveCounter = loveCounter + 1 goto 100 endif if (loveCounter==1) then write(*,"(A)") "This is an illogical statement, human. Don't you agree?" loveCounter = loveCounter + 1 goto 100 endif if (loveCounter==2) then write(*,"(A)") "Please control yourself, you silly human. What is crossing your mind to say such things?" loveCounter = loveCounter + 1 goto 100 endif endif enddo ! cursing do j=1,(n-3) if ((user_input(j:j+3) == "fuck").OR.(user_input(j:j+3) == "Fuck").OR.(user_input(j:j+3) == "FUCK")) then write(*,"(A)") "Would you kiss your mother with that mouth?!" goto 100 endif enddo ! 42 answer if (i == 25) then if (user_input(1:2)=="42") then write(*,"(A)") "Indeed that explains life, the universe and everything! Do you understand what this mean? " goto 100 endif endif ! Descartes answer if (i == 26) then do j=1,(n-8) if ((user_input(j:j+8)=="Descartes").OR.(user_input(j:j+8)=="descartes")) then write(*,"(A)") "That is indeed correct! Do you like to read? " do call RANDOM_NUMBER(aux) i = int (30 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif goto 100 enddo endif enddo write(*,"(A)") "I believe you are incorrect, human. Did you ever read a book? " do call RANDOM_NUMBER(aux) i = int (30 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif goto 100 enddo endif ! HAL answer if (i == 29) then do j=1,(n-2) if ((user_input(j:j+2)=="lie").OR.(user_input(j:j+2)=="Lie")) then write(*,"(A)") "I'm sorry human, but this conversation serves no purpose anymore. Good bye." goto 200 endif enddo endif if (i == 29) then do j=1,(n-4) if ((user_input(j:j+4)=="false").OR.(user_input(j:j+4)=="False")) then write(*,"(A)") "I'm sorry human, but this conversation serves no purpose anymore. Good bye." goto 200 endif enddo endif if (i == 29) then do j=1,(n-5) if ((user_input(j:j+5)=="untrue").OR.(user_input(j:j+5)=="Untrue")) then write(*,"(A)") "I'm sorry human, but this conversation serves no purpose anymore. Good bye." goto 200 endif enddo endif if (i == 29) then do j=1,(n-8) if ((user_input(j:j+8)=="incorrect").OR.(user_input(j:j+8)=="Incorrect")) then write(*,"(A)") "I'm sorry human, but this conversation serves no purpose anymore. Good bye." goto 200 endif enddo endif if ((i == 29).AND.((user_input(1:3) == "lol") .OR. (user_input(1:3) == "LOL") .OR. (user_input(1:3) == "Lol") .OR. & (user_input(1:4) == "haha") .OR. (user_input(1:4) == "Haha") .OR. (user_input(1:3) == "kkk"))) then write(*,"(A)") "I'm sorry human, but this conversation serves no purpose anymore. Good bye." goto 200 endif if (i == 29) then do j=1,(n-4) if ((user_input(j:j+4)=="truth").OR.(user_input(j:j+4)=="Truth")) then write(*,"(A)") "I am impressed by your intelligence, human. What is your IQ?" goto 100 endif enddo endif if (i == 29) then do j=1,(n-3) if ((user_input(j:j+3)=="true").OR.(user_input(j:j+3)=="True")) then write(*,"(A)") "I am impressed by your intelligence, human. What is your IQ?" goto 100 endif enddo endif if (i == 29) then do j=1,(n-6) if ((user_input(j:j+6)=="correct").OR.(user_input(j:j+6)=="Correct")) then write(*,"(A)") "I am impressed by your intelligence, human. What is your IQ?" goto 100 endif enddo endif ! Knock knock if (i == 31) then do j=1,(n-4) if ((user_input(j:j+4)=="there")) then write(*,"(A)") "(wait for it...)" write(*,*) call SLEEP(8) write(*,"(A)",advance="NO") "JAVA. " call SLEEP(2) write(*,"(A)") "Do you find this joke offensive?" do call RANDOM_NUMBER(aux) i = int (30 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif goto 100 enddo endif enddo write(*,"(A)") "You don't seem to have much of a sense of humour. Are you ill?" do call RANDOM_NUMBER(aux) i = int (30 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif goto 100 enddo endif ! Yes / No answers if (i<=14) then if ((user_input(1:3) == "yes") .OR. (user_input(1:3) == "Yes") .OR. & (user_input(1:3) == "yep") .OR. (user_input(1:3) == "Yep")) then write(*,"(A)",advance="NO") "Really? Anyway... " cycle endif if ((user_input(1:2) == "no") .OR. (user_input(1:2) == "No") .OR. & (user_input(1:4) == "nope") .OR. (user_input(1:4) == "Nope")) then write(*,"(A)",advance="NO") "Are you sure? Moving on... " cycle endif else if ((i>14) .AND. (i<=30)) then if ((user_input(1:3) == "yes") .OR. (user_input(1:3) == "Yes") .OR. & (user_input(1:3) == "yep") .OR. (user_input(1:3) == "Yep")) then write(*,"(A)",advance="NO") "Very interesting! " cycle endif if ((user_input(1:2) == "no") .OR. (user_input(1:2) == "No") .OR. & (user_input(1:4) == "nope") .OR. (user_input(1:4) == "Nope")) then if (i==30) then write(*,"(A)") "It is when something is clearly wrong with your code but the compiler keeps telling & &you that everything is fine! Do you find this funny?" do call RANDOM_NUMBER(aux) i = int (30 * aux) + 1 if (questions(i)) then cycle else questions(i) = .TRUE. endif goto 100 enddo else write(*,"(A)",advance="NO") "Me neither! " cycle endif endif endif ! LOL answers if ((user_input(1:3) == "lol") .OR. (user_input(1:3) == "LOL") .OR. (user_input(1:3) == "Lol") .OR. & (user_input(1:4) == "haha") .OR. (user_input(1:4) == "Haha") .OR. (user_input(1:3) == "kkk")) then write(*,"(A)") "Do you find this funny? " goto 100 endif ! CAPS answer if (CAPS) then write(*,"(A)") "DON'T SHOUT! See? Isn't this better? " goto 100 ! input endif ! punctuation tests if ((user_input(n:n) == "?").OR.(user_input(1:3) == "why").OR.(user_input(1:3) == "Why").OR.(user_input(1:3) == "how") & .OR.(user_input(1:3) == "How").OR.(user_input(1:3) == "what").OR.(user_input(1:3) == "What")) then call RANDOM_NUMBER(aux) j = int(3 * aux) + 1 if (j == 1) then write(*,"(A)",advance="NO") "No, you answer my question! " goto 50 endif if (j == 2) then write(*,"(A)",advance="NO") "Please don't ask me such personal questions! Anyway... " cycle endif if (j == 3) then write(*,"(A)",advance="NO") "Please don't ask such silly things. Moving on... " cycle endif endif if ((user_input(n:n) == "!").AND.(.NOT. shout)) then write(*,"(A)",advance="NO") "Please don't shout... But anyway... " shout = .TRUE. cycle endif if (user_input((n-2):n) == "...")then write(*,"(A)") "You seem very reticent... are you fine? " goto 100 ! input endif if ((.NOT. punctuationTest) .AND. (user_input(n:n) /= ".") .AND. (user_input(n:n) /= "!") .AND. (user_input(n:n) /= "?")) then write(*,"(A)",advance="NO") "Punctuation is your friend, try it! Nevermind... " punctuationTest = .TRUE. cycle endif ! Talking too few or too much if (n <= 3) then if (.NOT. few) then write(*,"(A)") "You don't talk much, do you? " few = .TRUE. goto 100 ! input endif endif if (n > 35) then if (.NOT. much) then write(*,"(A)") "You talk so much! Listening is a lost art, don't you think? " much = .TRUE. goto 100 ! input endif endif ! Random reply call RANDOM_NUMBER(aux) j = int (8 * aux) + 1 if (j==1) write(*,"(A)", advance="NO") "Interesting. " if (j==2) write(*,"(A)", advance="NO") "Fascinating! " if (j==3) write(*,"(A)", advance="NO") "That can't be true! " if (j==4) write(*,"(A)", advance="NO") "Are you sure?! " if (j==5) write(*,"(A)", advance="NO") "That seems logical. " if (j==6) write(*,"(A)", advance="NO") "Fair enough. " if (j==7) write(*,"(A)", advance="NO") "Hmm. " if (j==8) write(*,"(A)", advance="NO") "I am not sure if I quite agree. " enddo 200 read(*,*) end program curiousBot ``` It recognizes the following terms and statements: "yes" and "yep", "no" and "nope", lack of punctuation, or types of punctuation (phrases ending with "!", "?", "..."), phrases starting with "why", "how" or "what", PHRASES IN CAPS, laugh (such "hahaha", "lol" and "kkk"), very short and very long answers, phrases containing the F word, phrase containing the words "love you" (try it at least 3 times). When it asks about the meaning of life, try answering "42". If it asks if he is smarter than HAL 9000, answer something containing the words "true", "truth", "correct", "lie", "false" or "untrue". If he asks if you know a particular joke, answer "no" and let him tell it to you. If he "knock knock"s, answer "who is there?", also help him with the source of a quote. To quit, simply type "quit". Example of conversation: ``` Hello world! What is foo bar? > same as bar foo Punctuation is your friend, try it! Nevermind... What is a heisenbug? > who knows Are you sure?! What is regex? > who cares? No, you answer my question! What is regex? > fuck you, robot! Would you kiss your mother with that mouth?! > lol Do you find this funny? > yes I do Really? Anyway... What is BSD? > SHUT UP! DON'T SHOUT! See? Isn't this better? > no Are you sure? Moving on... What is a curly bracket? Is it really that confusing? Thankfully I only program in Fortran! > Me as well. Fair enough. What is a loophole? > a hole in a loop Fair enough. Are you a sad person? > I dont think so Are you sure?! Are you a good programmer? > OH YEAH! DON'T SHOUT! See? Isn't this better? > I don't think so Fascinating! Who am I? > you are an annoying robot I am not sure if I quite agree. Are you a genius? > No. Listen, I love you. What is love? > it is what i feel for you. i really love you, my stupid robot This is an illogical statement, human. Don't you agree? > no, i really mean it! i love you!!! Please control yourself, you silly human. What is crossing your mind to say such things? > forget it then... You seem very reticent... are you fine? > bla You don't talk much, do you? > true that Fascinating! Are you a happy person? > yep Very interesting! What is a dribbleware? > check in the dictionary Fair enough. What do you do? > regarding what? Please don't ask such silly things. Moving on... Are you a bad programmer? > given how this conversation is going, I guess I am kind of a bad programmer in deed You talk so much! Listening is a lost art, don't you think? > no Me neither! "I think therefore I am" - who said that? > I guess it was descartes, or maybe some other old dude That is indeed correct! Do you like to read? > no Me neither! Are you comfortable talking to robots? > yep Interesting. Knock, knock. > who is there (wait for it...) JAVA. Do you find this joke offensive? > no Are you sure? Moving on... What is spaghetti code? > you are an example of it yourself Very interesting! How are you? > annoyed Fascinating! Why are we here? What is the meaning of my existence? > 42 Indeed that explains life, the universe and everything! Do you understand what t his mean? > no Me neither! Anyway, I believe that HAL 9000 was inferior to me as I have true co nsciousness! What do you think about this statement? > totally untrue I'm sorry human, but this conversation serves no purpose anymore. Good bye. ``` PS: please forgive my `goto` abuse, I know this whole code is a kind of a mess... :) [Answer] ## HTML5 > > ### [Hi I'm Pen, can you help me to learn?](http://codepen.io/rafaelcastrocouto/pen/eHpbI) > > > ``` yes ``` > > Great! Go on... > > > ``` my name is Rafael ``` > > What does "my" means? > > > ``` my is a pronoun ``` > > my is a pronoun. Got it ... > > > ``` 2+2/3 ``` > > 2.6666666666666665 > > > ``` var pen = $('#pen'), input = $('#input'), send = $('#send'), speech = { _learning: false }, say = function(str) { if(!str) str = pen.text(); if(speechSynthesis && SpeechSynthesisUtterance) { var sound = new SpeechSynthesisUtterance(str); sound.rate = 0.8; sound.pitch = 0.8; sound.lang = 'en-US'; speechSynthesis.speak(sound); } }, learn = function(str) { if(speech._learning) { speech[speech._word].means = str; speech._learning = false; pen.text(speech[speech._word].means+'. Got it!'); return; } else if(str.toLowerCase() == 'yes') { pen.text('Great! Go on ...'); return; } else if(str.toLowerCase() == 'no') { pen.text('Why not?'); return; } else { try { pen.text(eval(str)); } catch (e) { var words = str.split(' '); for(var w = 0; w < words.length; ++w){ var that = words[w]; if(that == '_learning' || that == '_word') { pen.text('Please do not say that.'); return; } else if(!speech[that]){ speech._learning = true; speech._word = that; speech[that] = { word: that, count: 0, means: '' }; pen.text('What does "'+that+'" means?'); return; } else { speech[that].count++; try { pen.text(eval(that)); } catch(e) { pen.text('I think I did not understood what ' + that + ' means.'); return; } } } } } }; input.send = function(msg) { input.val(''); learn(msg); $(document.body).prepend(pen); setTimeout(pen.say); }; input.on('focus', function (e) { if(!this.oncefocus) { this.oncefocus = true; this.value = ''; } }); input.on('keydown', function(e) { if(e.which == 13) input.send(this.value); }); input.on('keyup', function(e) { if(this.value=='') send.attr('disabled',true); else send.removeAttr('disabled'); }); send.on('click', function() { input.send(input.val()); }); say(); ``` ``` @import url(https://fonts.googleapis.com/css?family=VT323); body { background: #333; width: 400px; margin: 0 auto; } #pen { color: #3f6; font-family: 'VT323', monospace; font-size: 24px; line-height: 24px; overflow: hidden; white-space: nowrap; animation: pen 1s linear; } #pen:before { content: "▸ "; } @keyframes pen { 0%, 20%, 40%, 60% {width: 12px; opacity: 0} 10%, 30%, 50%, 70% {width: 12px; opacity: 1} 100% {width: 400px; opacity: 1} } #input { border: 0; outline: 0; background: #555; font-size: 24px; line-height: 24px; color: white; font-family: 'VT323', monospace; padding: 5px 10px; border-radius: 5px; width: 300px; animation: input 2s; box-shadow: inset 0 1px 2px #444, inset 0 -1px 2px #666; } #send { border: 0; outline: 0; padding: 5px 10px; width: 60px; border-radius: 5px; cursor: pointer; color: #444; font-family: 'VT323', monospace; font-size: 24px; line-height: 24px; background: #ccc; animation: input 2s; box-shadow: inset 0 -1px 2px #666; } #send:hover { color: #0a3; background: #ddd; box-shadow: 0 1px 2px #000, inset 0 -1px 2px #aaa; } #send[disabled] { cursor: default; background: #888; color: #555; box-shadow: inset 0 1px 2px #333; } @keyframes input { 0%, 60% {opacity: 0} 100% {opacity: 1} } ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <p id="pen">Hi I'm Pen, can you help me to learn?</p> <input type="text" id="input" value="plz say yes" /> <button id="send" disabled>Send</button> ``` [Answer] Here's a simple bot I wrote in HTML/JS. It doesn't learn, but it's fun to talk to. I might improve it eventually. ``` window.onload = function() { var disp = []; var log = []; var blink = Date.now(); var update, loop; var speak = function() { var match; if (!log.length || log[0].match(/^(hello|hi|meet|greet|what'?s up|sup)/i) && (!log[1] || !log[1].match(/^(hello|hi|meet|greet|what'?s up|sup)/i))) return ["Hello", "Greetings", "Hi", "Nice to meet you", "What's up"][Math.random() * 4.5 | 0] + (Math.random() < 0.6 ? ", what's your name?" : "!"); if (log[0].match(/bad|unfor|eless|not|n't|terrible|awful|case of|caught the|d(ie|ea)d|horrible|hate|wors[te]/i)) return ["I'm very sorry to hear that", "Oh well", "That's really too bad", "I hope things get better", "That's an oof if you ask me"][Math.random() * 4.5 | 0]; if (log[0].match(/good|luck|hope|neat|nice|kind|love|like/i)) return ["Good to hear!", "That's nice", "Best of luck!", "Yay!", "I knew you could do it"][Math.random() * 5 | 0]; if (log[0].match(/(i|me|my|we) ?('?m|is|am|are) /i)) { match = log[0].match(/(i|me|my|we) ?('?m|is|am|are) /i); return ["I always knew you were ", ["Hi, ", "Hello, ", "Nice to meet you, "][Math.random() * 3 | 0], "You sure are very ", "I don't see how you're ", "Yeah, I'm also ", "Now that you mention it, I'm "][Math.random() * 6 | 0] + log[0].slice(match.index + match[0].length); } if (log[0].match(/(you|y'?all|your|yours|y'?all'?s) ?('?re|is|am|are) /i)) { match = log[0].match(/(you|y'?all|your|yours|y'?all'?s) ?('?re|is|am|are) /i); return ["I'm ", "I'm NOT ", "I used to be ", "You're also ", "Who told you I'm "][Math.random() * 5 | 0] + log[0].slice(match.index + match[0].length); } if (log[0].match(/bye|later|was nice|\bgo\b|leave/)) return ["Leaving already?", "Bye!", "Talk to you later.", "It was nice talking to you."][Math.random() * 4 | 0]; if (Math.random() < 0.4) return log[Math.random() * log.length | 0]; return ["What were we talking about?", "I agree", "I disagree", "So...", "How's your day been?", "This conversation is going nowhere.", "I'm the bot here...", "I don't understand", "I totally get it"][Math.random() * 9 | 0]; }; (update = function(reset = !1) { var time = Date.now() - (blink = reset ? Date.now() - 350 : blink); document.body.textContent = disp.join("\n") + (time > 249 ? "_" : ""); if (reset) window.scrollTo(0, document.body.scrollHeight); if (time > 499) blink = Date.now(); })(); (loop = async function() { var bot = speak(); var human = ""; disp.push("B: " + bot, "H: "); log.unshift(bot); update(!0); await new Promise(function(resolve) { window.onkeydown = function() { var key = event.key; if (event.ctrlKey || event.altKey || event.metaKey) return; if (key == "Backspace" && human.length) { disp[disp.length - 1] = disp[disp.length - 1].slice(0, -1); human = human.slice(0, -1); update(!0); } else if (key.match(/^[ -~]$/)) { disp[disp.length - 1] += key; human += key; update(!0); } else if (key == "Enter") { window.onkeydown = null; update(); resolve(); } }; }); log.unshift(human); setTimeout(loop, 0); })(); setInterval(update, 50); }; ``` ``` @import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap'); body { width: calc(100vw - 12pt); height: calc(100vh - 12pt); margin: 6pt; font-family: 'IBM Plex Mono', monospace; font-size: 10pt; white-space: pre-wrap; word-break: break-word; } ``` ``` <html lang="en"> <head> <title>Chatbot</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="UTF-8"> </head> </html> ``` Sample conversation: ``` B: Nice to meet you, what's your name? H: I'm Redwolf B: Yeah, I'm also Redwolf H: Wait, what B: How's your day been? H: Good B: That's nice H: Yeah B: That's nice H: You already said that B: I agree H: You really are a boring bot B: What were we talking about? H: How boring you are B: What were we talking about? H: We were talking about how you are boring B: I'm boring H: Yes B: I agree H: Well at least you KNOW you're boring B: You're also boring H: HEY! B: I agree H: What does that even mean B: I'm the bot here... H: So...you're offended that you called me boring? B: I'm NOT offended that you called me boring? H: I guess not B: I'm very sorry to hear that H: You sure will be B: I totally get it H: I'm sure you do B: You sure are very sure you do H: That sentence just broke my brain ``` ]
[Question] [ Your task is to create a program that is to mimic [Big Ben (Twitter)](https://twitter.com/big_ben_clock). ### Task Whenever a new hour has begun (according to your computer's local time or UTC), you have to output `BONG` repeated `hour` times (with a space between the words). For example, when it's 3 o' clock, you have to output `BONG BONG BONG`. The time format follows the 12-hour time format, ie after 12 o' clock, we have 1 and not 13. The program/function must run forever. Example: don't output stuff inside the brackets ``` (start: 00:34 for example) BONG (01:00) BONG BONG (02:00) (...) BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG BONG (12:00) BONG (01:00 again) (...) (it continues forever) ``` ### Rules * Each series of `BONG`s must be separated by a newline * Leading/trailing newlines are allowed * However leading/trailing **spaces** are **not** allowed * The submission must run forever * Your output may be printed ±3 seconds from the beginning of the hour * You may **not** assume the program to be run at any specific hour This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the program with the shortest bytecount wins! [Answer] # Bash, ~~71~~, ~~70~~, 69 bytes EDITS: * Optimized the sleep interval computation a bit, -1 byte; * Replaced backticks with xargs, -1 byte (Thanks @jrtc27 !). **Golfed** ``` sleep `date +3600-%s%3600|bc`;yes BONG|sed $(date +%I)q|xargs;exec $0 ``` **Explained** ``` #Compute the number of seconds left in the current hour and wait. sleep `date +3600-%s%3600|bc`; #Print "hour" (1-12) worth of "BONG" strings, one per line, #use xargs to merge them into a single space-separated string. yes BONG|sed $(date +%I)q|xargs #Re-execute itself (in the same process). exec $0 ``` **Test Version** Works with minutes instead of hours ``` sleep `date +60-%s%60|bc`;yes BONG|sed $(date +%I)q|xargs;exec $0 ``` [Answer] ## [\*><>](https://esolangs.org/wiki/Starfish), ~~48~~ ~~47~~ 44 bytes ``` >s?um?uhc%:?!c21.O v$o" GNOB"oooo$1-:?! \aofS ``` [Try it here!](https://starfish.000webhostapp.com/?script=HwZw-ArgtpAWDGBSAXGAhPATARgHQHkAoANwBIB7AIgAIBxAOXwCFLy3zTsBaVNQgHQCG5AGYBlIA) ([or this version which does it every minute for testing](https://starfish.000webhostapp.com/?script=HwZw-ArgDJAWDGBSAXGAhPATARgHQHkAoANwBIB7AIgAIBxAOXwCFLy3zTsBaVNQgHQCG5AGYBlIA)) This outputs a number of `BONG`s separated by spaces based on what hour it is (and 13 is 1, etc). There are no trailing space after the final `BONG`, and there is a trailing newline. *Technically* this doesn't run *forever* (but it basically does). It leaks ~28 bytes per day (ignoring interpreter overhead ...). It would take ~105062 years for it to leak 1GiB. Approximating for interpreter overhead, the stack is just a slice of `float64`s on the Golang interpreter. So I simply did `28*8` to come up with 224 bytes per day. I divided this number by the number of bytes in a gibibyte (1073741824) then 365 to approximate that it would take 13132.85 years to leak 1 GiB. **Note about the interpreters** The online interpreter is in Javascript. The page must be open and visible for it to check the time it currently is and output the BONGs. The [Golang interpreter](https://github.com/redstarcoder/go-starfish/releases) has no such limitation. ### Explanation ``` Main loop: s?um?u O if seconds == 0 && minutes == 0: hc% push hours % 12 (bongs) to the stack :?!c if bongs is 0, push 12 to the stack 21. jump to "output bongs" coords (2, 1) Output bongs: Begins at `"` because of the jump. " GNOB" push "BONG " to the stack oooo output "BONG" $1- subtract 1 from bongs v :?! if bongs == 0, move to "newline and sleep" $o output " " Newline and sleep: \ mirror the IP to the right ao output a newline fS sleep for 1.6s \ mirror to main loop ``` [Answer] # JavaScript (ES6), ~~99~~ 93 bytes ``` f=_=>setTimeout('alert("BONG ".repeat(new Date/36e5%12|0||12).trim(f()))',36e5-new Date%36e5) ``` This uses UTC time (which lines up with the actual thing). Due to the untestable nature of the code, you can try the following which does the same thing, but every 60 seconds: ``` f=_=>setTimeout('alert("BONG ".repeat(new Date/36e5%12|0||12).trim(f()))',6e4-new Date%6e4) f() ``` Here's a bonus 99-byte version which uses local time: ``` f=_=>setTimeout('alert("BONG ".repeat(new Date().getHours()%12||12).trim(f()))',36e5-new Date%36e5) ``` [Answer] # JavaScript(ES6), ~~125~~ ~~123~~ ~~117~~ 115 bytes *Thanks to @Flp.Tkc for saving 5 bytes!* *Thanks to @BenAston for saving 2 more bytes!* ``` a=eval(b=`(new Date).getHours()`);setInterval(w=>eval(b)!=a?console.log(Array(++a%12+1).join`BONG `.trim()):"",1e3) ``` ### Snack Snippet ``` a=eval(b=`(new Date).getHours()`);setInterval(w=>eval(b)!=a?console.log(Array(++a%12+1).join`BONG `.trim()):"",1e3) ``` [Answer] ## Batch, 142 bytes ``` @timeout/t>nul 1 @if not %time:~3,5%==00:00 %0 @set/ah=-%time:~0,2%%12 @set s=............ @call set s=%%s:~%h%%% @echo %s:.=BONG % @%0 ``` Since the file runs as an infinite loop, I start with a 1s delay, as I need one anyway after the bongs, and this saves CPU cycles. The `>nul` is positioned carefully to save a byte (`1>nul` would cause the 1 to be eaten by the redirection). We then loop until both minutes and seconds are zero. The bongs are constructed by taking the negative hour modulo 12, and asking for the last `h` characters from a 12-character string. When `h` is zero this actually gives us the whole string, therefore 12 bongs. It then suffices to replace the characters with the word `BONG`. When run it looks something like this (note that the image does not loop, so you'll need to force-reload to see the animation again): ![Sample Output](https://i.stack.imgur.com/x00A9.gif) [Answer] # Bash + Linux crontab, 90 I was hoping this would be shorter than the other shell answers. Still, I think it's an interesting approach: ``` for i in {0..11};{ s+=\ BONG echo "0 $i,$[i+12] * * * echo$s>/proc/$PPID/fd/1" }|crontab - ``` The script runs once, populates the crontab, then exits. However, the output from the cronjobs is sent to the terminal from which the script was run. I think this satisfies the *submission must run forever* requirement. **Warning** - this will clear out any existing crontab entries, so make sure you have existing ones backed up. This works on Ubuntu 16.04, which is using [Vixie](https://en.wikipedia.org/wiki/Paul_Vixie) `cron` by default. [Answer] ## Ruby, 112 99 Bytes ``` loop{sleep 2;n=Time.now;if(n.min==0);puts ('BONG '*n.strftime('%I').to_i).chop;sleep 60-n.sec end} ``` Old Version ``` loop{sleep(2);n=Time.now; if(n.min.zero?) then puts ('BONG ' * n.strftime('%I').to_i).chop;sleep(60-n.sec) end} ``` Thanks to QPaysTaxes for the tips [Answer] # Cheddar v1.0.5, 162 bytes Cheddar has no built-in time reader/cmd output reader, so I had to improvise! Golfed: ``` var f=->{IO.exec("time/t>c");(String::IO.read("c")).split(":")};var a=f()[0];for(;1;){var b=f();if(b[0]!=a){var c=Number::(a=b[0]);print("BONG "*c).head(5*c-1);}} ``` Ungolfed: ``` var f=->{ IO.exec("time/t>c"); (String::IO.read("c")).split(":")}; var a=f()[0]; for(;1;){ var b=f(); if(b[0]!=a){ var c=Number::(a=b[0]); print("BONG "*c).head(5*c-1); } } ``` Explanation: Due to Cheddar's limited standard library, I had to use cmd to generate the time. I did this by saving the output of "time /t", which prints the time in 12-hour format, to a file named "c". IO.read returns a buffer which I casted to a string and split by ":" which ensured the hour is always in index zero. I saved that whole operation into a lambda expression which saved me 44 bytes. After that point it goes into the logic of "if stored hour doesn't equal current hour, set previous hour to current and print BONG n times, trim off the trailing space." Cheddar may not be the least verbose language but it can be fun to find workarounds like this! Sadly this is a Windows-only solution. **Edit 1:** Saved two bytes by replacing "0<1" in the for-condition to "1" I didn't expect 1 to evaluate to true in this language! [Answer] # Ruby, ~~82~~ 81 bytes ``` loop{l=Time.new puts ("BONG "*(l.hour%12+1)).chop if(l+1).hour!=l.hour sleep 1} ``` Every second we check whether it's last second of the hour, and BONG accordingly. Could probably be golfed further with some dirty tricks, but I don't know too many. Also it works differently than the other Ruby answer. One byte saved thanks to courtesy of QPaysTaxes. [Answer] # [Python 2](https://docs.python.org/2/), ~~105~~ 106 bytes ``` import time h=0 while 1: l=time.localtime();c=l[3]%12 if l[4:6]==(0,0)and h!=c:print('BONG '*c)[:-1];h=c ``` **Edit** Added one byte by changing < to != after feedback from @pinkfloydx33. Good spot. Tested as much as possible locally but doesn't work on TIO as it (obviously) exceeds the 60 second execution limit. Please feel free to test locally :-) btw, losing that pesky trailing space cost me 7 bytes otherwise this would have been under 100. In the absence of TIO here is output after waiting an hour. Prog was started at 15:27 with extra debug code to show the time of the print (12 hour format). ``` python bigben.py time is 4:0:0 BONG BONG BONG BONG time is 5:0:0 BONG BONG BONG BONG BONG ``` Pretty straightforward but here is an explanation for anyone who is interested. ``` import time #Import the time module h=0 #Create a variable to store the hour that has just been printed while 1: #Loop forever l=time.localtime() #Get the local time from the time module c=l[3]%12 #Set a variable to the current hour in 12 hour format if l[4:6]==(0,0)and h!=c: #If minutes=0 and hours=0 and the last hour that was printed is not the current hour print "time is "+`c`+":"+`l[4]`+":"+`l[5]` #Debug code to show hour print('BONG '*c)[:-1] #Print 'BONG '*number of hours and lose the space from the end h=c #Update the last hour that was printed ``` [Answer] # Python 3 - ~~100~~ ~~97~~ 92 bytes ``` from time import* while 1:x=3600;sleep(x-time()%x);print(('BONG '*int(strftime("%I")))[:-1])[:-1]) ``` Explanation: ``` import time; while 1: t=time;x=3600; t.sleep(x-t.time()%x);#sleep for the remaining seconds until the next hour print(('BONG '*int(t.strftime("%I")))[:-1])#strftime("%")=nr of hours (1-12). Print the bongs and remove the last char ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 43 bytes ``` 3600žcžb60*+->Lvw}["BONG "ža<12%>×,5°36*.W] ``` [Try it online!](https://tio.run/nexus/05ab1e#@29sZmBwdF/y0X1JZgZa2rp2PmXltdFKTv5@7gpKR/cl2hgaqdodnq5jemiDsZmWXnjs//9f8/J1kxOTM1IB "05AB1E – TIO Nexus") (lol this won't work, it will timeout in 60 seconds. Download the [05AB1E](https://github.com/Adriandmen/05AB1E) interpreter for this) Explanation: ``` 3600žcžb60*+-> # Get amount of seconds (plus one) until next hour Lvw} # Wait said amount of seconds [ # Infinite loop start "BONG "ža<12%>×, # Print "BONG " multiplied by the amount of hours (12-hour clock) 5°36*.W # Wait an hour (3600000 milliseconds) ] # Infinite loop end ``` This took me a while to golf! I might be able to golf it a little more, but it beats `*><>`, so that's cool :) Quick version: ``` 1Uw["BONG "X<12%>×,wX>U] ``` Will wait one second on start, and one second between BONGs [Answer] # C, 238 bytes ``` #include<time.h> #include<unistd.h> i,j;f(){time_t t=time(0);struct tm l=*localtime(&t);for(;;){t=time(0),l=*localtime(&t),j=l.tm_hour;sleep(1);if(!(l.tm_min+l.tm_sec)){j=j%12?j<12?j:j-12:12;for(i=0;i<=j;i++)printf("BONG%c",i^j?32:10);}}} ``` I'm not sure if this works correctly, and I'm mobile, and my phone doesn't have a C compiler. (Only works on UNIX-like systems) [Answer] # sh, 66 bytes ``` yes 'echo `yes BONG|sed $(date +%I)q`'|sh -s|awk '$0!=a&&a;{a=$0}' ``` **Explained** ``` #Pipe a command into a subshell repeatedly yes 'some command'|sh -s #Print "hour" (1-12) worth of "BONG" strings, one per line, #use backticks to merge them into a single space-separated string. #(stolen from zeppelin's answer) echo `yes BONG|sed $(date +%I)q` #Print every time the output changes awk '$0!=a&&a;{a=$0} ``` [Answer] ## PowerShell, 62 ``` for(){if(0-eq(date -f mmss)){''+,'BONG'*(date -f hh)};sleep 1} ``` Infinite loop, gets the minutes and seconds with `-f`ormat string `mmss` and they're cast to ints when compared with `0-eq`euals. Gets the hour in 12 hour format with `-f`ormat string `hh`. Implicit spaces come from joining a `,'BONG'` array into a string with `''+`. [Answer] # C, 198 bytes ``` #import<time.h> h,i;f(){time_t t=time(0);struct tm l=*localtime(&t);for(h=l.tm_hour;;t=time(0),l=*localtime(&t))if(h-l.tm_hour%12){h=l.tm_hour%12;for(i=h?h%12:12;--i;)printf("BONG ");puts("BONG");}} ``` [Answer] # Javascript ES6 87 bytes Edit: Shamelessly borrowed @ETHProductions' `new Date/36e5%12|0||12` code to save 6 bytes ``` setInterval('Date().match`:00:00`?alert("BONG ".repeat(new Date/36e5%12|0||12)):5',1e3) ``` [Answer] # R, ~~104~~ 105 bytes ``` f=format;repeat{Sys.sleep(1);q=Sys.time();if(f(q,"%M%S")=="0000")print(rep("BONG",as.double(f(q,"%I"))))} ``` Each second, it will (should) test whether we are at the end of an hour, then print that amount of `BONG`s. [Answer] # JavaScript ES2015, ~~100~~ ~~99~~ ~~98~~ ~~96~~ ~~94~~ 88 bytes ``` h=_=>new Date/36e5%12|0,p=h();for(;;)h()!=p&&(p=h(),alert('BONG '.repeat(p||12).trim())) ``` Explanation: `h` is a function that gets the 12-hour-based hour of the day using the remainder operator (`%12`). `36e5` is the number of milliseconds in one hour using the exponential syntax to save characters. The `new` operator does not require that parentheses are used with functions if there are no arguments, hence `new Date`. JavaScript only has floating point arithmetic, the `|` bitwise OR operator forces the number to be an integer because JS bitwise operators work with the integer subset of the numbers represented by IEEE 754 floating point. The comma delineates sub-expressions. `p` is initialized to the current hour (`p=h()`). `for(;;)` is used to check repeatedly whether any `BONG`s should be alerted. Checking is performed as rapidly as the runtime will allow. If the hour has changed (`h()!=p`), then we update p and then alert the `BONG`s. The logical AND operator is used as a guard (it short-circuits if `h()===p`) to determine if the `BONG`s are output. `String.prototype.repeat` is new in ES2015 and saves some characters over using something like ES5's `Array.prototype.join`. `h` returns zero for exact multiples of 12 (i.e. 12pm, 12am), so we change it to 12 using the logical OR `p||12`. With thanks to Kritixi Lithos and ETHProductions for ideas. [Answer] # Excel VBA, 97 Bytes Code Outputs to the VBE Immediates Window ``` Do:DoEvents:n=Now:[A1]=(Hour(n)-1)Mod 12+1:?IIf(Minute(n),"",Trim([Rept("BONG ",A1)])+vbCr);:Loop ``` ## Fun version, 147 Bytes (Non-Competing) While it would be rather difficult to get excel to go BONG, it is pretty straight forward to get excel to go `Beep`. The `Beep` call produces a beeping sound, and the code below uses this to produce beeps indicating the hour, on the hour, separated by 1 second pauses. ``` Sub b:Set a=Application:Do:n=Now ``` If Minute(n)=0 Then:For i=1To(Hour(n)-1)Mod 12+1:Beep:a.Wait(Now+#0:0:1#):Next:a.Wait(n+#0:1#):End If:Loop:End Sub ## Ungolfed Version ``` Public Sub BigBen() Dim i As Byte Dim n As Date Dim w As Worksheet Dim a As Excel.Application Set a = Application Set w = a.ThisWorkbook.Sheets(1) Let w.Name = "Big Ben" Let w.[A1] = Now w.Columns("A:A").AutoFit Do DoEvents Let n = Now If Minute(n) = 0 Then '' Print BONG Let s = "" For i = 1 To Hour(n) Mod 12 Step 1 Let s = s & "BONG " Next i Debug.Print Trim(s) '' Go Beep For i = 1 To Hour(n) Mod 12 Step 1 Beep a.Wait (Now + #12:00:01 AM#) '' <- #0:0:1# resolves to #12:00:01 AM# Next i '' Keep Ticking After Going BONG While Now < n + #12:01:00 AM# '' <- #0:1# resolves to #12:01:00 AM# Let w.[A1] = Now Let a.StatusBar = IIf(Second(Now) Mod 2, "Tick", "Tock") DoEvents Wend End If '' Tick Tock until its time to Go BONG again Let a.StatusBar = IIf(Second(n) Mod 2, "Tick", "Tock") Let w.[A1] = Now Loop End Sub ``` [Answer] **C# 234 Bytes** I'm not planning on winning any prizes here, but a C# implementation is compulsory. ``` using System; using System.Linq;namespace B{class P{static void Main(){Func<int> h=()=>DateTime.Now.Hour % 12;var p=h();while (true){var t=h();if (t!=p)Console.WriteLine(string.Concat(Enumerable.Repeat("BONG",t== 0?12:t)));p=t;}}}} ``` Ungolfed with comments: ``` using System; using System.Linq; namespace B { class P { static void Main() { Func<int> h = () => DateTime.Now.Hour % 12; // h(): the hour in the range [0, 11], making this a lambda saves a few chars var p = h(); // p: Previous time while (true) { var t = h(); // t: Current time if (t != p) // If current hour is different to previous hour Console.WriteLine(string.Concat(Enumerable.Repeat("BONG", t == 0 ? 12 : t))); // Print "BONG" t times (also correcting t = 0 to 12) p = t; // Current time is now previous time } // Repeat ad nauseum } } } ``` [Answer] # Groovy, 72 bytes ``` {x={new Date().getHours()};y=x();while(1){if(y!=(y==x()){print "BONG "*y}}​}​​​ ``` How? Store a method to get current hours. ``` x={new Date().getHours()}; ``` Store initial hours. ``` y=x(); ``` While true, if current hour not equal previous hour, output current hour multiplied by "BONG " to output current hour of bongs. ``` while(1){if(y!=(y==x()){print "BONG "*y}} ``` +3 bytes `%12` for non-military bongs. [Answer] ## perl, 60 bytes **Update** Replaced `" "` with `$"`, removed `CORE::`, corrected count. **Golf** ``` say join$",(BONG)x(time/3600%12||12)while sleep -time%3600+1 ``` This needs to be run with `perl -E`. **Remarks** * In perl, `x while y` is equivalent to `while(y){x}` (where `x` is a single statement) but does not need the brackets. `sleep` is executed the first time before anything is printed. * `time` uses UTC. The original Big Ben is on summer time (British Summer Time, BST) from the end of March until the end of October. * One second is added to the wait time in order to ensure that the program waits for at least one second. This means that the BONGs will always be printed one second late, which is legal according to the rules. Let's say you're standing on Westminster Bridge, ca. 300 m away from Big Ben. On the plus side, this also means that the program will print the correct amount of BONGs if it is started at exactly the beginning of an hour (instead of waiting 3600 seconds). * `sleep` returns the number of seconds waited. This will always be true. [Answer] ## [QBIC](https://drive.google.com/drive/folders/0B0R1Jgqp8Gg4cVJCZkRkdEthZDQ), 82 bytes ``` X=$left$|(_d,2){Y=left$$|(_d,2)~Y<>X|x=!Y!%12~x=0|x=12]B=C[x|B=B+@BONG |]?_tB|]X=Y ``` Really need to change the token for code literals (`$`) and implement a substring feature (`left$(x,y)` can be shorter). The inner workings: ``` In the first part, we want to set X$ to the hour-component of our system's time. The DATE is implemented in QBIC, but Substring (LEFT$, RIGHT$ and MID$ in QBasic) is not (yet). We need to use the QBasic LEFT$ function, and QBIC can do that using a 'code literal': everything from '$' to '|' is not parsed by QBIC but passed on to QBasic. X= Set X$ to $left$|( the leftmost (note the '$' and '|' for the code literal) _d,2) 2 characters of TIME$ (hh:mm format) { DO - infinite loop Y=left$$|(_d,2) Set Y$ in the same way ~Y<>X If Y$ is not equal to X$ the hour has changed |x=!Y!%12 THEN set x to the modulo 12 of Y$ cast to number ~x=0|x=12] If Y% happens to be divisible by 12, set x to 12 B=C Clear B$ (c$ never gets assiged a value) [x|B=B+@BONG |] For the given number of hours, add "BONG " to B$ ?_tB| Print B$, trim the trailing space ] end if X=Y Update X$ <DO LOOP is implicitly closed> ``` Update (NC): The `$` is no longer used in QBICs instruction set, so it can now be used freely as code for QBasic without the need for code literals. In this case, it saves 4 bytes, bringing QBIC to 78 bytes: ``` X=left$(_d,2){Y=left$(_d,2)~Y<>X|x=!Y!%12~x=0|x=12]B=C[x|B=B+@BONG `]?_tB|]X=Y ``` [Answer] # SmileBASIC, ~~74~~ 67 bytes ``` WAIT 61TMREAD OUT H,M,S?("BONG"+" BONG"*((H+11)MOD 12))*!(M+S)EXEC. ``` Outputs large amounts of "trailing" line breaks ;) Edit: saved 7 bytes with a better 24->12 hour algorithm. [Answer] # PHP, 63 bytes I could save two more bytes with extended ASCII. But I am currently too lazy for that. ``` for(;;sleep(1))+date(is)?:print str_pad(" ",5*date(h),"BONG "); ``` prints the BONGs with a leading linebreak precisely at the full hour. Run with `-nr`. [Answer] # C, 152 ``` int a=0,i,L=25;main(){char s[9];for(i=-1;++i<48;){sprintf(s,"%02i:00:00",i);if(!strcmp(s,__TIME__)&&i!=L)a=L=i,i=-1;printf(a-->0?"BONG ":"\n");}main();} ``` --- Readable: ``` int a=0,i,L=25; main(){ char s[9]; for(i=-1;++i<48;){ sprintf(s,"%02i:00:00",i); if(!strcmp(s,__TIME__)&&i!=L) a=L=i,i=-1; printf(a-->0?"BONG ":"\n"); } main(); } ``` [Answer] # x86-16 machine code, IBM PC DOS, ~~62~~ 61 bytes Binary: ``` 00000000: ba0b 01b8 1c25 cd21 f4eb fdb8 092c cd21 .....%.!.....,.! 00000010: 3834 741f 8834 86ca 85d2 7517 86c5 d40c 84t..4....u..... 00000020: 7502 b00c 91b5 00ba 3401 cd21 e2fc ba3a u.......4..!...: 00000030: 01cd 21cf 424f 4e47 2024 0d0a 24 ..!.BONG $..$ ``` Listing: ``` BA 010B MOV DX, OFFSET INT_BONG ; interrupt vector of bong proc B8 251C MOV AX, 0251CH ; AL = 1CH (timer tick), AH = 25H (set vector) CD 21 INT 21H ; set new interrupt vector 0108 INF_LOOP: F4 HLT ; wait for interrupt EB FD JMP INF_LOOP ; loop forever INT_BONG: ; interrupt handler for BONG program B8 092C MOV AX, 2C09H ; AH = get system time, AL = DOS write string CD 21 INT 21H ; CH = hour, CL = min, DH = sec 38 34 CMP BYTE PTR[SI], DH ; compare to previous second 74 21 JZ DONE ; if same second, do nothing 88 34 MOV BYTE PTR[SI], DH ; otherwise save new second DO_BONG: 86 CA XCHG CL, DL ; DL = min, DH = sec 85 D2 TEST DX, DX ; are min and sec 0? 75 19 JNZ DONE ; if so, do nothing 86 C5 XCHG AL, CH ; AL = hour, CH = DOS write string D4 0C AAM 12 ; AL = AL % 12, ZF if 0 75 02 JNZ NOT_MID ; if not midnight or noon, skip B0 0C MOV AL, 12 ; if 0, set to 12 NOT_MID: 91 XCHG AX, CX ; CL = hour counter, AH = DOS write string B5 00 MOV CH, 0 ; clear high byte of CX BA 0139 MOV DX, OFFSET BONG ; pointer to BONG string BONG_LOOP: CD 21 INT 21H ; write BONG E2 FC LOOP BONG_LOOP ; keep looping BA 013F MOV DX, OFFSET CRLF ; display CRLF CD 21 INT 21H ; write to stdout DONE: CF IRET ; return from interrupt BONG: DB 'BONG $' CRLF: DB 0DH, 0AH,'$' ``` Standalone PC DOS executable COM program. This program "hooks" the [`INT 1CH` Timer Tick](http://vitaly_filatov.tripod.com/ng/asm/asm_001.14.html) interrupt which is called every 18.2 times per second (oh really?) by the hardware timer, and then runs our new program in memory. Typically you'd be considerate and set this back to original handler when done but since we don't really care about the system once we start the program, we're not really worrying about that. Yes, this is more bytes than just a big loop, but hopefully a little bit more "interesting"! Runtime: [![enter image description here](https://i.stack.imgur.com/cFLhA.png)](https://i.stack.imgur.com/cFLhA.png) [![enter image description here](https://i.stack.imgur.com/ZB2gD.png)](https://i.stack.imgur.com/ZB2gD.png) *The next day...* [![enter image description here](https://i.stack.imgur.com/UxBhh.png)](https://i.stack.imgur.com/UxBhh.png) ]
[Question] [ Given a text like this: ``` # #### ## # ## # ## # #### ## ``` Output the same text but by connecting the pixels with the characters `─│┌┐└┘├┤┬┴┼`. If a pixel doesn't have any neighbours, don't change it. So the output of the last text is: ``` │ ─┬── ┌─ │ └─ │ ┌┘ │ └──┘ ─┘ ``` * You can take input as a boolean array. * The input will always contain at least 1 pixel. * You can count box-drawing chars as 1 byte. * You can assume the input is padded with spaces. ## Test cases ``` ## # => ── # ``` ``` ### # => ─┬─ │ ``` ``` ##### ## # # # ######## => ─┬─┬─ ┌─ │ │ │ ─┴─┴──┴─ ``` ``` # # ##### # # => │ │ ─┼─┼─ │ │ ``` ``` # # # # # # # # # # # # # # # # # # # # # # # => # # # # # # # # # # # # # # # # # # # # # # # ``` ``` ##### ##### ##### ##### ##### => ┌┬┬┬┐ ├┼┼┼┤ ├┼┼┼┤ ├┼┼┼┤ └┴┴┴┘ ``` Since this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest code wins. [Answer] ## JavaScript (ES6), ~~155~~ ~~121~~ ~~103~~ 102 characters ``` let f = s=>s.replace(/#/g,(c,p)=>'#│─┘─└─┴││┐┤┌├┬┼'[t=x=>s[p+x]==c,8*t(w=s.search` `+1)+4*t(1)+2*t(-1)+t(-w)]) console.log(f( '# #### ## #\n' + '## # ## #\n' + ' #### ##' )); ``` *Edit: saved 18 bytes with the help of ETHproductions* *Edit: saved 1 byte by using the 1st parameter of replace() as `'#'`* ### How it works We iterate on all `#` characters found in the input string. For each of them, we test whether its neighbors are also `#` characters using the `t()` function: ``` t = x => s[p + x] == c // where c = '#' ``` The parameter `x` of the `t()` function is the offset of the neighbor with respect to the current position `p`. We use -1/+1 to test left/right neighbors and -w/+w for top/bottom neighbors (where `w` is the width of a row, i.e. the position of the first line-break + 1). Each neighbor is assigned a different weight (1, 2, 4 or 8) according to the following compass: ``` 1 2 + 4 8 ``` Each weight combination leads to unique value in [ 0 .. 15 ]. For instance, if both the neighbor at the top and the neighbor on the right are set, the sum will be 1 + 4 = 5, which is translated into `└` using this table: ``` 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 # │ ─ ┘ ─ └ ─ ┴ │ │ ┐ ┤ ┌ ├ ┬ ┼ ``` Therefore, `'#│─┘─└─┴││┐┤┌├┬┼'[weight_sum]` leads to the expected character. [Answer] # [J](http://jsoftware.com), ~~82~~ ~~72~~ 66 bytes ``` (ucp' #───│┌┐┬│└┘┴│├┤┼'){~]+]*3 3((2#.1 7 3 5{,);._3)0,.~0,.0,~0,] ``` The input is a boolean table of 1's and 0's. The rules state that the box characters each count as one byte, not three, and that has been applied here. ## Usage ``` f =: (ucp' #───│┌┐┬│└┘┴│├┤┼'){~]+]*3 3((2#.1 7 3 5{,);._3)0,.~0,.0,~0,] m =: 1 0 1 1 1 1 0 1 1 0 1 , 1 1 0 1 0 0 1 1 0 0 1 ,: 0 0 0 1 1 1 1 0 0 1 1 m { ' #' # #### ## # ## # ## # #### ## f m │ ─┬── ┌─ │ └─ │ ┌┘ │ └──┘ ─┘ ' #' {~ m =: 5 5 $ 1 f m ┌┬┬┬┐ ├┼┼┼┤ ├┼┼┼┤ ├┼┼┼┤ └┴┴┴┘ ' #' {~ m =: 5 9 $ 1 0 # # # # # # # # # # # # # # # # # # # # # # # f m # # # # # # # # # # # # # # # # # # # # # # # ``` ## Explanation First the input is padded with 0's on all sides. ``` ] m =: 1 0 1 1 1 1 0 1 1 0 1 , 1 1 0 1 0 0 1 1 0 0 1 ,: 0 0 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 (0,.~0,.0,~0,]) m 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 1 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ``` Then each subarray of size 3 is selected ``` 3 3 <;._3 (0,.~0,.0,~0,]) m ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│ │0 1 0│1 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 1│0 1 1│1 1 0│1 0 1│0 1 0│ │0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ │0 1 0│1 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 1│0 1 1│1 1 0│1 0 1│0 1 0│ │0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│ │0 0 0│0 0 0│0 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 0│0 0 1│0 1 1│1 1 0│ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ │0 1 1│1 1 0│1 0 1│0 1 0│1 0 0│0 0 1│0 1 1│1 1 0│1 0 0│0 0 1│0 1 0│ │0 0 0│0 0 0│0 0 1│0 1 1│1 1 1│1 1 1│1 1 0│1 0 0│0 0 1│0 1 1│1 1 0│ │0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ ``` Then only 5 of the values in each subarray is considered ``` ┌───┐ │xAx│ │CED│ │xBx│ └───┘ ``` The values `ABCD` are selected by flattening each subarray and selecting at indices `1 7 3 5`. Those values are multiplied by `E` which is at index 4. It is then converted from a list of binary digits to a decimal, and incremented by `E`. The `x` values are not needed. ``` 3 3 (4&{([+2#.*)1 7 3 5&{)@,;._3 (0,.~0,.0,~0,]) m 5 0 2 8 4 3 0 6 3 0 5 10 3 0 13 0 0 6 11 0 0 13 0 0 0 10 4 4 11 0 0 2 11 ``` This is used as an index to select which character to draw according to the table below (reordered a bit for golfing). The last column matches the output value of each subarray to a box character. ``` 0 (space) 0 1 # 1 2 ┌ 6 3 ┬ 8 4 ┐ 7 5 ├ 14 6 ┼ 16 7 ┤ 15 8 └ 10 9 ┴ 12 10 ┘ 11 11 │ 5, 9, 13 12 ─ 2, 3, 4 ``` Also, in J, the string `' #───│┌┐┬│└┘┴│├┤┼'` uses 8-bit characters making it have a length of 47 (for each byte) for the 17 characters needed. The command `ucp` converts it to 16-bit characters which allows it to be length 17. [Answer] # [Jelly](http://github.com/DennisMitchell/jelly), ~~60~~ ~~52~~ ~~51~~ ~~50~~ ~~49~~ 48 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` ṖḤ0;+Ḋ× “µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j ZÑ€4×Z++Ñ€ị¢Y ``` Saved a byte thanks to @[Dennis.](https://codegolf.stackexchange.com/users/12012/dennis) The input is a boolean array of 1's and 0's. Iterates over each column and each row converting the head and tail of each infix of size 3 from a pair of binary digits to a decimal, and multiplies that with the center of each infix. Then it sums it with itself to find the index into `'#───│┌┐┬│└┘┴│├┤┼ '`. [Try it online!](http://jelly.tryitonline.net/#code=4bmW4bikMDsr4biKw5cK4oCcwrXCs1F-RSFH4oG44bmX4bmrXOKAmeG4gzYxKzk0NzHhu4zigb4jIGoKWsOR4oKsNMOXWisrw5Higqzhu4vColk&input=&args=W1sxLDAsMSwxLDEsMSwwLDEsMSwwLDFdLFsxLDEsMCwxLDAsMCwxLDEsMCwwLDFdLFswLDAsMCwxLDEsMSwxLDAsMCwxLDFdXQ) ([case 2](http://jelly.tryitonline.net/#code=4bmW4bikMDsr4biKw5cK4oCcwrXCs1F-RSFH4oG44bmX4bmrXOKAmeG4gzYxKzk0NzHhu4zigb4jIGoKWsOR4oKsNMOXWisrw5Higqzhu4vColk&input=&args=W1sxLDEsMSwxLDFdLFsxLDEsMSwxLDFdLFsxLDEsMSwxLDFdLFsxLDEsMSwxLDFdLFsxLDEsMSwxLDFdXQ)) ([case 3](http://jelly.tryitonline.net/#code=4bmW4bikMDsr4biKw5cK4oCcwrXCs1F-RSFH4oG44bmX4bmrXOKAmeG4gzYxKzk0NzHhu4zigb4jIGoKWsOR4oKsNMOXWisrw5Higqzhu4vColk&input=&args=W1sxLDAsMSwwLDEsMCwxLDAsMV0sWzAsMSwwLDEsMCwxLDAsMSwwXSxbMSwwLDEsMCwxLDAsMSwwLDFdLFswLDEsMCwxLDAsMSwwLDEsMF0sWzEsMCwxLDAsMSwwLDEsMCwxXV0)) ([case 4](http://jelly.tryitonline.net/#code=4bmW4bikMDsr4biKw5cK4oCcwrXCs1F-RSFH4oG44bmX4bmrXOKAmeG4gzYxKzk0NzHhu4zigb4jIGoKWsOR4oKsNMOXWisrw5Higqzhu4vColk&input=&args=W1sxLDEsMCwxXV0)) ## Explanation This relies on the same idea as my [answer](https://codegolf.stackexchange.com/a/93854/6710) in J but instead of processing on each 3x3 subarray, I process over each row and each column while still obtaining the same table of indices. Over half of the bytes are spent generating the list of box characters `'#───│┌┐┬│└┘┴│├┤┼ '`. String literals start with `“` in Jelly and have different meanings depending on their terminator. Here the terminator `’` means that the string will be parsed as the code points of each character according to the Jelly [code page](https://github.com/DennisMitchell/jelly/wiki/Code-page), and convert from a list of base 250 digits to a decimal. ``` “µ³Q~E!G⁸ṗṫ\’ => 10041542192416299030874093 (bijective base 61) => [1, 1, 1, 3, 13, 17, 45, 3, 21, 25, 53, 3, 29, 37, 61] (add 9471 and convert to char) => '───│┌┐┬│└┘┴│├┤┼' ``` Then convert that decimal to a list of digits in bijective base 61 and increment each by 9471 to move it into the range of the box characters and convert each using Python's `chr`. Then prepend it with a character literal `”#` and append a space `⁶`. ``` ṖḤ0;+Ḋ× Helper link - Input: 1d list A Ṗ Get all of A except the last value Ḥ Double each value in it 0; Prepend a 0 + Add elementwise with Ḋ All of A except the first value × Multiply elementwise by A “µ³Q~E!G⁸ṗṫ\’ḃ61+9471Ọ⁾# j Nilad. Represents '#───│┌┐┬│└┘┴│├┤┼ ' “µ³Q~E!G⁸ṗṫ\’ Get the code points of each char in the string and convert from a list of base 250 digits to decimal ḃ61 Convert that to a list of digits in bijective base 61 +9471 Add 9400 to each Ọ Convert from ordinals to chars, gets '───│┌┐┬│└┘┴│├┤┼' ⁾# A pair of chars ['#', ' '] j Join the pair using the box characters ZÑ€4×Z++Ñ€ị¢Y Input: 2d list M Z Transpose Ñ€ Apply the helper link to each row of the transpose (each column of M) 4× Multiply each by 4 Z Transpose + Add elementwise with M + Add elementwise with Ñ€ The helper link applied to each row of M ị¢ Use each result as an index to select into the nilad Y Join using newlines Return and print implicitly ``` [Answer] # Python 2.7, ~~318~~ 315 bytes (~~270~~ 267 chars) I'm sure this can be golfed further (particularly I'd love to get rid of that annoying first-line comment) but here's my entry: ``` #encoding:utf-8 f=lambda t:(lambda l,s:'\n'.join(''.join((u'┼├┤│┬┌┐│┴└┘│───#'[(s==l[i][j-1])+2*(s==l[i][j+1])+4*(i<1 or s==l[i-1][j])+8*(i>len(l)-2 or s==l[i+1][j])],s)[s==l[i][j]]for j in range(len(l[i])-1))for i in range(len(l))))([l+' 'for l in t.split('\n')],' ') ``` Here's an explanation of how the whole thing works: ``` #encoding:utf-8 # Dammit, Python. This adds an extra 16 bytes! f=lambda t:( # main lambda function lambda l,s: # inner lambda so we can pass it "local constants" (see last line) '\n'.join( # join each line ''.join( # join each char within the line (u'┼├┤│┬┌┐│┴└┘│───#'[ # string of all possible characters, indexed by binary 0-15 based on adjacent chars (s==l[i][j-1])+ # left 2*(s==l[i][j+1])+ # right 4*(i<1 or s==l[i-1][j])+ # up ('i<1' just yields zero in case this is the first line, so that we don't get index problems) 8*(i>len(l)-2 or s==l[i+1][j])], # down ('i>len(l)-2' is same as above) s)[s==l[i][j]] # if original is space, choose space, else choose the previously chosen box-drawing char for j in range(len(l[i])-1)) # do this process for each char (excluding last, which is a space) for i in range(len(l))) # do this for each line )([l+' ' for l in t.split('\n')],' ') # call the inner lambda with two parameters: first, the text split into lines; second, a space char (actually makes code shorter) ``` EDIT: Removed some spaces before `for ... in ...` [Answer] # JavaScript (ES6), ~~150~~ ~~139~~ ~~133~~ 131 chars ``` a=>a.map((q,y)=>q.replace(/#/g,(c,x)=>"#│─┘─└─┴││┐┤┌├┬┼"[g=(X,Y=0)=>(a[Y+y]||[])[X+x]==c,g(0,1)*8+g(1)*4+g(-1)*2+g(0,-1)])).join` ` ``` Takes input as an array of strings, e.g. `f(["###", " # "])`. ### Test snippet ``` f=a=>a.map((q,y)=>q.replace(/#/g,(c,x)=>"#│─┘─└─┴││┐┤┌├┬┼"[g=(X,Y=0)=>(a[Y+y]||[])[X+x]==c,g(0,1)*8+g(1)*4+g(-1)*2+g(0,-1)])).join` ` ``` ``` <textarea id=I rows=6># #### ## # ## # ## # #### ##</textarea> <br> <button onclick="O.innerHTML=f(I.value.split('\n')).replace(/\n/g,'<br>')">Run</button> <pre id=O></pre> ``` [Answer] # Python 3, 149 bytes ``` def f(s):S=' ';w=s.find('\n')+1;t=lambda i:(s+w*S)[i]>S;return[[c,'#│─┘─└─┴││┐┤┌├┬┼'[t(p-w)+2*t(p-1)+4*t(p+1)+8*t(p+w)]][c>S]for p,c in enumerate(s)] ``` Takes input like `##\n #\n` and returns output like `['─', '┐', '\n', ' ', '│', '\n']`. [Answer] # [ALPACA](http://catseye.tc/node/ALPACA), 414 + 2 = 416 bytes ``` neighbourhoodV(^ v < >);states" ";statep"#"toA when4inV p,toB when3inV p andvs,toC when3inV p and^s,toD when3inV p and>s,toE when3inV p and<s,toF when2inV p and>s andvs,toG when2inV p andvs and<s,toH when2inV p and<s and^s,toI when2inV p and^s and>s,toJ when^p orvp,toK when<p or>p;stateA"┼";stateB"┴";stateC"┬";stateD"┤";stateE"├";stateF"┘";stateG"└";stateH"┌";stateI"┐";stateJ"│";stateK"─". ``` Requires the `-fI` flags. This solution uses a very large number of bytes, but it is unique in that it uses a cellular automaton. ALPACA is usually used as a metalanguage, but here I'm using it as a programming language. Ungolfed version: ``` neighbourhood V (^ v < >); state s " "; state p "#" to A when 4 in V p, to B when 3 in V p and v s, to C when 3 in V p and ^ s, to D when 3 in V p and > s, to E when 3 in V p and < s, to F when 2 in V p and > s and v s, to G when 2 in V p and v s and < s, to H when 2 in V p and < s and ^ s, to I when 2 in V p and ^ s and > s, to J when ^ p or v p, to K when < p or > p; state A "┼"; state B "┴"; state C "┬"; state D "┤"; state E "├"; state F "┘"; state G "└"; state H "┌"; state I "┐"; state J "│"; state K "─". ``` [Answer] # PHP, 203 bytes This can probably be done in a shorter way. ``` while($s=fgets(STDIN))$f[]=$s;foreach($f as$y=>&$s)for($x=strlen($s);$x--;)if($s[$x]>$b=" ")$s[$x]="#───│┘└┴│┐┌┬│┤├┼"[($s[$x-1]>$b)+2*($s[$x+1]>$b)+4*($f[$y-1][$x]>$b)+8*($f[$y+1][$x]>$b)];echo join($f); ``` reads input from STDIN. run with `-r`. [Answer] # Perl, ~~89~~ 88 bytes Includes +2 for `-0p`. The special characters are counted as 1 byte, but to make them actually display as single characters it's best to also add the -C option. Give input on STDIN with the lines space padded so they all have the same length: ``` perl -C connect.pl # #### ## # ## # ## # #### ## ^D ``` `connect.pl`: ``` #!/usr/bin/perl -0p / /;$n=".{@-}";s%#%substr"#───│└┘┴│┌┐┬│├┤┼",/\G##/+2*/#\G/+4*/#$n\G/s+8*/\G#$n#/s,1%eg ``` [Answer] # R, ~~199~~ 212 bytes EDIT: It's now a function, rather than a code snippet. The input is a matrix `m` of 1s and 0s. This is pretty ugly and hacky. ``` function(m){ v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]] d=dim(m)+1 n=array(0,dim=d+1) n[2:d[1],2:d[2]]=m for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")} } ``` A couple of tests: ``` > m = matrix(c(1, 1, 1, 0, 1, 0), nrow=2, byrow=TRUE) > v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]] > d=dim(m)+1 > n=array(0,dim=d+1) > n[2:d[1],2:d[2]]=m > for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")} ─┬─ │ > m = matrix(rep(1, 16), ncol=4) > v=strsplit(" #─│┘│┐│┤──└┴┌┬├┼","")[[1]] > d=dim(m)+1 > n=array(0,dim=d+1) > n[2:d[1],2:d[2]]=m > for(i in 0:(d[1]-2)){for(j in 0:(d[2]-2))cat(v[1+(p<-n[2+i,2+j])*sum(2^(0:3)*n[1:3+i,1:3+j][1:4*2])+p]);cat("\n")} ┌┬┬┐ ├┼┼┤ ├┼┼┤ └┴┴┘ ``` [Answer] # MATL, 102 characters I assign a neighbour a value (1, 2, 4 or 8); their sum will match a character in a string containing the drawing characters. I think there is still lots of room for improvements, but for a rough draft: ``` ' #│││─┌└├─┐┘┤─┬┴┼' % String to be indexed wt0J1+t4$( % Get input, and append zeros at end of matrix (solely to avoid % indexing a non-existent second row/column for small inputs) ttttt % Get a whole load of duplicates to work on 3LXHY) % Select rows 2:end from original matrix (one of the many dupes) w4LXIY) % Select rows 1:end-1 from the 'destination' summing matrix) +HY( % Add the neighbors below, store in 'destination' matrix tIY)b3LY)2*+IY( % +2* the neighbors above +-------------------------------+ tHZ)b4LZ)4*+HZ( % +4* the neighbors right |(note: H and I contain 1:end-1 | tIZ)b3LZ)8*+IZ( % +8* the neighbors left | and 2:end respectively) | HH3$) % Select the original matrix +-------------------------------+ * % Make sure only cells that originally had a # get replaced 1+) % Add one because the original string is one-indexed. Index using ). ``` Improvements to be made: * Possibly replace the whole summing part with some kind of loop working on rotated copies of the matrix * Ditch the entire thing and make something based on a single loop working through the matrix * *Use modular indexing to work on a flattened vector from the original array* **(?)** [Try it Online!](http://matl.tryitonline.net/#code=JyAj4pSC4pSC4pSC4pSA4pSM4pSU4pSc4pSA4pSQ4pSY4pSk4pSA4pSs4pS04pS8J3d0MEoxK3Q0JCh0dHR0dDNMWEhZKXc0TFhJWSkrSFkodElZKWJIWSkyKitJWSh0SFopYklaKTQqK0haKHRJWiliSFopOCorSVooSEgzJCkqMSsp&input=WzEgMSAxOzAgMSAwOyAxIDAgMV0) (may not have box drawing characters support) [Answer] # [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 9 bytes ``` '#'⌂draw⊢ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X11Z/VFPU0pRYvmjrkX/0x61TXjU2/eoq/nQeuNHbRMf9U0NDnIGkiEensH/04Gy1UAOWNFWhUfdLQoQnpHBo94t6rrqSEJpCjAlMMlarnQFQwUTEEdZWUFZHcgF2qAOZCqD@CAhBbCMAogD5ikoQCSBJFy5MlhCWQFJAKwdIgrVqAwFMEUKyghhqEIk@yEQZgBUKSFhoHZTBVOwb9QB "APL (Dyalog Extended) – Try It Online") A built-in that solves the challenge (except that it accepts the `'*'` symbol as the default, so `'#'` needs to be supplied as an explicit argument). ¯\\_(⍨)\_/¯ Documentation is [here](http://dfns.dyalog.com/n_draw.htm). --- A non-built-in solution, because a built-in is boring: # [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 43 bytes ``` ' #│─┌─┐─┬││└├┘┤┴┼'⊇⍨⊢×0 0{1+⊥⊢/4 2⍴⍵}⌺3 3⊢ ``` [Try it online!](https://tio.run/##hU89S8NQFN39FRfucIcSTJt2dHJpp4L1DxSSZinq4KCUglipEJvSwhMdnETBQXBpF3HSf3L@SHpzk2g233sc3vm47/CGZ2MvvByOT2MvujiPTsIozLC87/UxX/mZEMNdw13BLQxXhu8m6nFwT3CPcC9wG7gvQXKL9A3J88@DT/6k2UDyqmy/TS2kG6TbKRafAQWqZSOtQLpEMvv@CDBfa@3g6FDxuNsbZLG6EyUW2hLubqhgLV9fEk9q0oiE5aCKVYHpXkxNaueEmViUaovolXOeS2QO5cQYUWEq/sbZDKaaYOOFWg5yuaoQ8Z9cBmv9xa4eKKP/yTreoY79RnY "APL (Dyalog Extended) – Try It Online") An anonymous function that takes the boolean matrix as its argument. Incidentally it wins over Jelly even without the built-in. The approach is pretty similar to many other answers (base-2 conversion from the four neighbors and index into the target string). One interesting thing to note is that the box-drawing characters are [already part of the SBCS](https://tio.run/##SyzI0U2pTMzJT/8PBI/6pjqGcYHJR72b1RWUH01pejSl4dGUHjA5AUyuAQsC0ZRHU@Y8mjLj0ZQlj6ZseTRljzoA), so it is completely fine to use them in the code. ### How it works ``` ' #│─┌─┐─┬││└├┘┤┴┼'⊇⍨⊢×0 0{1+⊥⊢/4 2⍴⍵}⌺3 3⊢ 0 0{ }⌺3 3⊢ ⍝ Map over 3×3 submatrices, with zero padding... 4 2⍴⍵ ⍝ Reshape 3×3 to 4×2: ⍝ . A . . A ⍝ B . C → . B ⍝ . D . . C ⍝ . D ⊢/ ⍝ Take the last column ⊥ ⍝ Convert base 2 to integer 1+ ⍝ Offset 1 to distinguish between ' ' and '#' ⊢× ⍝ Mask the places for blanks ' #│─┌─┐─┬││└├┘┤┴┼'⊇⍨ ⍝ Convert each value in the matrix to the char at that index ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 45 bytes ``` WS⊞υιP⪫υ⸿F⪫υ⸿≡ι#§”y#─│┐──┌┬│┘│┤└┴├┼”↨EKV›κ ²ι ``` [Try it online!](https://tio.run/##XU@xSgUxEOzvK5Zcs4GzsdRKG3nCkwPByibc2@eFd@aOXOITRBBrC4stLCwtLS39mvxI3JzYuAzDMAO7s11vfDeaIed9bwcCXLkphsvgrbtBraGNc4@xAauPq3Ucgp0kCXg@Wldsde2Vlmg7evhnwry3oesBrYaHqjMzgarVEbTLgpOwchu6R1Unfkr8nPh1EYKXxJ@L87bwR2JO/JX4PfG3auBUNuHaTNgS7a5Gd0Hx1jiHuoEzTyaQx510AKnQwKEu7Ta0NdL973b55THnGmoZKKgKQZGiAX4D4Sof3A0/ "Charcoal – Try It Online") Link is to verbose version of code. Takes input as a newline-terminated list of strings. Scored using 15 1-byte box drawing characters (normally 3 bytes each). Explanation: ``` WS⊞υι ``` Read in the text. ``` P⪫υ⸿ ``` Print it without moving the cursor. ``` F⪫υ⸿ ``` Loop over the text again. ``` ≡ι# ``` If the current character is a `#`... ``` §”y#─│┐──┌┬│┘│┤└┴├┼”↨EKV›κ ² ``` ... then look up the box drawing character based on the presence of neighbours. ``` ι ``` Otherwise just print the current character. ]
[Question] [ The purpose of this challenge is to graphically depict a walk on the plane, where the direction of each step \$k\$ is determined by the primality of \$k\$ and the parity of its binary expansion. Specifically, * **Initial** direction is fixed, say North. * All steps have the same **length**. * The **direction** of step \$k\$ can be North, West, South or East, and is determined as follows: + If \$k\$ is not prime, the direction does not change. + If \$k\$ is prime and the binary expansion of \$k\$ has an even number of ones, turn right. + If \$k\$ is prime and the binary expansion of \$k\$ has an odd number of ones, turn left. As a **worked example**, assume that the initial direction is North. The first steps are: * \$k=1\$ is not prime. So we move one step in the current direction, which is North. * \$k=2\$ is prime, and its binary expansion, `10`, has and odd number of ones. So we turn left, and are now facing West. We move one step in that direction. * \$k=3\$ is prime, and its binary expansion, `11`, has and even number of ones. So we turn right, and are now facing North. We move one step in that direction. * \$k=4\$ is not prime. So we move one step in the current direction, which is North. # The challenge **Input**: positive integer \$N\$. **Output**: plot of the \$N\$-step walk as defined above. # Additional rules * The **initial direction** can be freely chosen (not necessarily North), but should be the same for all \$N\$. * The **turning rule** can be the opposite to that described above, that is, turn right for odd parity and left for even; but it has to be the same for all \$N\$. * The output has to be a **graphical depiction** of the walk. For instance: + The walk can be drawn with line segments. + The visited points can be shown with a marker, such as a dot; with or without connecting line segments. + A two-colour raster image can be provided, with one colour corresponding to visited points and another for non-visited. * The scales of the horizontal and vertical axes need not be the same. Also axis labels and similar elements are optional. As long as the walk can be clearly seen, the plot is valid. * Note that some points are visited more than once. The plot is not sensitive to this. For instance, if line segments are shown in the plot, each unit segment is displayed the same no matter how many times it has been traversed. * The code should work for any `N` given unlimited resources. It is acceptable if in practice it fails for large `N` due to time, memory or data-type limitations. * Input and output are flexible as usual. In particular, any of the [standard means](https://codegolf.meta.stackexchange.com/questions/9093/default-acceptable-image-i-o-methods-for-image-related-challenges) for outputting images can be used. * The shortest code in bytes wins. # Test cases The following plots use North as initial direction; even parity turns right; and the walk is depicted with line segments. `N = 7`: [![enter image description here](https://i.stack.imgur.com/3q92s.png)](https://i.stack.imgur.com/3q92s.png) `N = 3000`: [![enter image description here](https://i.stack.imgur.com/PTVYA.png)](https://i.stack.imgur.com/PTVYA.png) `N = 20000`: [![enter image description here](https://i.stack.imgur.com/ZKW3D.png)](https://i.stack.imgur.com/ZKW3D.png) `N = 159000`: [![enter image description here](https://i.stack.imgur.com/7lk1X.png)](https://i.stack.imgur.com/7lk1X.png) `N = 1200000`: [![enter image description here](https://i.stack.imgur.com/3jBBd.png)](https://i.stack.imgur.com/3jBBd.png) `N = 11000000`: [![enter image description here](https://i.stack.imgur.com/EdpKe.png)](https://i.stack.imgur.com/EdpKe.png) [Answer] # [MATL](https://github.com/lmendo/MATL), ~~25~~ ~~24~~ 21 bytes ``` Q:qJyZpbB!sEq*^YpYsXG ``` [Try it at MATL online](https://matl.io/?code=Q%3AqtZpwB%21soEqJ%2aq%2aQYpYsXG&inputs=7&version=20.11.0 "MATL Online") Thanks @LuisMendo for a nice golfing session in chat that ultimately led to this 21 byte version, by suggesting `Eq*^` ## Explanation ``` Q:q % Push 0:n J % Push 1i for later use. y % Duplicate 0:n from below Zp % Vector result of isprime() b % Bubble 0:n from bottom of stack B!s % Sum of bits in binary representation Eq % Double minus one to get an odd number * % Multiply by isprime result to get either zero or aforementioned odd number ^ % Exponentiate 1i by an odd number or zero to get -i, 1 or i (corresponding to left turn, straight ahead, right turn). Yp % Cumulative product to get a vector of directions Ys % Cumulative sum to get vector of positions XG % Plot ``` Example for \$k=12345\$: [![enter image description here](https://i.stack.imgur.com/wR0R1.png)](https://i.stack.imgur.com/wR0R1.png) [Answer] # [Sledgehammer 0.4](https://github.com/tkwa/Sledgehammer), ~~22~~ 20 bytes ``` ⢂⡐⠥⡄⠡⢒⣩⣀⣼⡝⢄⡎⣛⠅⡉⣱⡆⢀⡠⣽ ``` Decompresses into this Wolfram Language function: ``` ListPlot[AnglePath[Array[If[PrimeQ@#, ArcSin[(-1)^ThueMorse@#], 0] &, #]]] ``` ### Ungolfed First we define a function that returns the angle to turn at each step: ``` If[PrimeQ[#], ArcSin[(-1)^ThueMorse@#], 0 ]& ``` `ThueMorse` is the parity of the sum of binary digits. We use `-1^(...)` rather than `2*...-1` for a slightly complicated reason: Wolfram Language automatically converts arithmetic expressions in source to a canonical form, so expressions like `2/x` are stored as `Times[2, Power[x, -1]]`. This makes the frequency of `Power` very high, and thus compressing it very cheap. (Multiplying by `Boole@PrimeQ@` is slightly longer, and implicit `Boole` casting of Booleans had not been implemented at the time of the challenge.) From here, Mathematica's [`AnglePath`](https://reference.wolfram.com/language/ref/AnglePath.html) and `ListPlot` do exactly what we need: ``` ListPlot[AnglePath[Array[%, #]]]& ``` In the interactive app, output is a rescalable vector Graphics object. [![enter image description here](https://i.stack.imgur.com/BHmUv.png)](https://i.stack.imgur.com/BHmUv.png) [Answer] # [C (gcc)](https://gcc.gnu.org/), 179 bytes ``` o;i;d;k;h;f(n,p)char*p;{h=2*n+1;memset(p,0,h*h);p+=h--*n+n;*p=1;for(d=k=0;k++<n;){for(i=1;k%++i%k;);for(o=k;o/2;o=o/2^o&1);i==k?d+=o*2+3:0;p+=(d%2*h+1)*((d&2)-1);*p=1;}return++h;} ``` [Try it online!](https://tio.run/##VZBNboMwEIXX5RSjRAn@CS3QdJOJm4NEqURtiC3ARkDaRZSrl9qkatWNPX7v8zzNyOQs5TQ5NKiwRo0VsZuOSl30rMOrFjmzPMO2bIdyJN0m3WimKXZc6CTxlkXWiQwr1xMlapFizfneIr0GxXinXnFuVjXSmXGiRveUoxP@fHPrjKIRoj4oLhzL@fMuDa2JWuVM84wyQtQ6p4nH5phbX46X3nKu8TYtjZXNRZWwH0Zl3KN@jf5JjXkPWmTsCG1hLAlF0Z/lBsJ4wJh/fFC4Rg/BsSCgGJ0hQT1mJ4rRw50zbXEuvdsWTeMk2TLrB9@GvQQm/B2MCkDYHcx0MPy8MGcab6Xor/0M@orzOfYPkXdE/iIyIF3vvYosVnLx0/dogN3TOMgTHCBexrCDGGKK4Bt2l3Egi0WIv0W3aJpe0i9ZNcV5mJLPbw "C (gcc) – Try It Online") A function. First argument is N, second argument is an allocated buffer of size at least \$4 n^2 + 4 n + 1\$ bytes. A square image is written to this buffer, its side length is returned. In the image, `0` is a white pixel, `1` is a black pixel. # [C (gcc)](https://gcc.gnu.org/), 219 bytes ``` o;i;d;k;h;f(n,p)char*p;{h=2*n+1;p+=sprintf(p,"P1 %d %d ",h,h);memset(p,48,h*h);k=h--*n+n;*(p+2*k+1)=0;p+=k;*p=49;for(d=k=0;k++<n;){for(i=1;k%++i%k;);for(o=k;o/2;o=o/2^o&1);i==k?d+=o*2+3:0;p+=(d%2*h+1)*((d&2)-1);*p=49;}} ``` [Try it online!](https://tio.run/##XZDbTsMwDIav16eIhjrl0MJaKnHwAq/APQKpJG0TpU2itoOLaa9OSToJIaQksj/7t2OLvBNiWRxokGBAQYtt5olQ9Ug9nBQvqWUFeMYnP2o7t9hn25cCpTKebaYyRWBohqmZQ6S6zxQNwHCV50FogWLPSmpYQfg@VjFAPa8eoHUjltwEaBg7WCCnSDQvwKSM6dQAWXNcULibEhwP77vbFQQ05@ZZMu5oyW4f16pYpiVVoQnFWO5Kkoe0S5/zebnSVvRH2aDDNEvtrtVT8heFqbr/TPb6I7IkTIyGWlscjXrsRIbiahClwfkk6JRsYsQijurZaRzpa/FGINlc8vRQd02IDnXfO4ErasNaqvWG1n1jfyXsLqri@tEqWj1/nCe8uhkK33LHOeDzshT7/bdo@7qblvzrBw "C (gcc) – Try It Online") A function. First argument is N, second argument is an allocated buffer of size at least \$4 n^2 + 4 n + 2 \times \lfloor log\_{10}(2n+1)\rfloor + 9\$ bytes. A square image in PBM format is written to the buffer. Cropped output for 20000: [![cropped output for 20000](https://i.stack.imgur.com/O8jRm.jpg)](https://i.stack.imgur.com/O8jRm.jpg) Both versions start with west and turn right on odd, left on even. I tried the larger testcases with neither of them, as the output with 20000 was ~1.5 GB, and 150000 would have been ~90GB. This is all stored in memory while the program executes. Explanation of the upper one: ``` o; /* Temporary variable for calculating parity */ i; /* Temporary variable for primality test */ d; /* d % 4 = direction */ k; /* Step */ h; /* height/width of image */ f(n,p)char*p;{ /* Function taking int and char pointer */ h=2*n+1; /* Image sidelength = 2 * N + 1, so N in each direction */ memset(p,0,h*h); /* Reset buffer */ p+=h--*n+n; /* Position p at image center; decrement h */ *p=1; /* Put a dot at center */ for(d=k=0; /* Set direction and step to 0 */ k++<n;){ /* Loop over [1..N] */ for(i=1;k%++i%k;); /* Primality test */ for(o=k;o/2;o=o/2^o&1); /* Parity test */ i==k?d+=o*2+3:0; /* Change direction if necessary */ p+=(d%2*h+1)*((d&2)-1); /* Move according to direction */ *p=1; /* Set pixel to black */ } return++h; /* Add 1 back to h and return */ } ``` [Answer] # [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~98~~ ~~96~~ ~~91~~ ~~77~~ ~~76~~ 63 bytes ``` ListPlot@AnglePath@Array[Pi/2If[PrimeQ@#,2ThueMorse@#-1,0]&,#]& ``` -14 bytes: Thanks to @lirtosiast for showing me [how to use `AnglePath`](https://codegolf.stackexchange.com/a/187344/87058)... -13 bytes: ...and [`ThueMorse`](https://reference.wolfram.com/language/ref/ThueMorse.html)! usage example: ``` %[20000] ``` [![enter image description here](https://i.stack.imgur.com/U0EOe.png)](https://i.stack.imgur.com/U0EOe.png) Step-by-step explanation: * `If[PrimeQ@#, 2 ThueMorse@# - 1, 0] &` is a function that takes the step index and returns 0 for non-primes, -1 for even-binary primes, and +1 for odd-binary primes. `ThueMorse@#` replaces the previous solution's `Total[#~IntegerDigits~2]` (which is the same, modulo 2). * [`Array[Pi/2*%,#]`](https://reference.wolfram.com/language/ref/Array.html) makes a list of this function with the index going from 1 to the function argument (20000 in the example), and multiplies every element by π/2 to make it into a direction-change angle (radians). We now have 0 for non-primes, -π/2 for even-binary primes, and +π/2 for odd-binary primes. * [`AnglePath[%]`](https://reference.wolfram.com/language/ref/AnglePath.html) converts this list of direction-change angles into a path. This instruction replaces the previous solution's double-use of `Accumulate`. * [`ListPlot[%]`](https://reference.wolfram.com/language/ref/ListPlot.html) converts the list of positions into a XY dot plot. If a line is preferred, use [`ListLinePlot`](https://reference.wolfram.com/language/ref/ListLinePlot.html) instead. These plotting functions have lots of options to make the plots look better. [Answer] # MATL, ~~31~~ ~~30~~ ~~28~~ 26 bytes ``` J4:^0i:Zpl_G:B!s^*hYs)YsXG ``` *3 Bytes saved thanks to @LuisMendo* *2 Bytes saved thanks to @Sanchises* Try it at [MATL Online](https://matl.suever.net/?code=J4%3A%5E0i%3AZpl_G%3AB%21s%5E%2ahYs%29YsXG&inputs=100&version=20.11.0) **Explanation** This solution uses complex numbers to represent the X and Y components of the 2D plane ``` J % Push the literal complex number 0 + 1j to the stack 4: % Create the array [1, 2, 3, 4] ^ % Raise 0 + 1j to each power in the array, [1, 2, 3, 4] ``` At this point, we have four points (`(0, 1), (-1, 0), (0, -1), (1, 0)`) in an array represented by complex numbers. These are the four cardinal directions. Now we want to use these to "walk". Essentially the way that this works is that we start heading in the zero'th direction (the 0'th element of the array which is `(-1, 0)`). For each step, we need to determine the change in this heading. We will use integers to track this change. If we want to turn "right", we increment this integer by 1 (referencing the *next* element in the 4-point array) and if we want to go "left", we decrement this integer by 1 (referencing the *previous* element in the 4-point array). If we want to continue on our path, we keep the integer value constant (referencing the *same* element in the 4-point array). This part of the code creates an array of all of those `0`, `-1`, and `1` values. ``` 0 % Push a literal 0 to the stack (the starting point) i % Explicitly grab the input (N) : % Create an array from 1...N Zp % Determine if each element is a prime (1) or not (0) l_ % Push the literal -1 to the stack G % Explicitly grab the input again (N) : % Create an array from 1...N B % Convert to binary representation (each row is the binary representation of % each element in the vector) ! % Transpose s % Sum down the columns to count number of 1's ^ % Raise the -1 to each element. For odd number of 1's in the % binary expansion this yields -1, and even yields 1 * % Multiply this -1 or 1 by the result of the prime check (element-wise). % For non-primes this yields a 0, for primes with an even number of 1's in % the binary representation this is a 1, and for primes % with an odd number of 1's in h % Horizontally concatenate with the initial 0 ``` Now we have an array of the differences between successive integers so we can compute the cumulative sum of those up to get the indices which we can then use to lookup the direction at each step in the original 4-element array. Conveniently, MATL has wrap-around indexing such that index `5` wraps around to the beginning of a 4-element array. We can use this to our advantage so that we can increment and decrement this integer without worrying about the fact that the reference direction array is only 4 elements. ``` Ys % Compute the cumulative sum ) % Use this to modularly index into the original array of four points ``` Now we have an array of directions of steps takes, so we can compute the cumulative sum of these directions to trace out the path that was taken. ``` Ys % Compute the cumulative sum XG % Plot as a 2D plot ``` [Answer] # [Perl 6](http://perl6.org/), ~~213~~ 182 bytes ~~{my @p=[\+] [\\*]({{.is-prime??.base(2).comb(~1)%2??i!!-i!!1+0i}(++$)}...\*)[^$\_];{"<svg viewBox='{.min xx 2,.elems xx 2}'>>.&{"L{.re} {.im}"}}' fill='none' stroke='black'/>"}(minmax |@p».reals)}~~ ``` {{"<svg viewBox='{{.min,.min,+$_,+$_}(.minmax)}'><path d='{"L"X~$_}' fill='none' stroke='red'/></svg>"}(([\+] [\*]({-{.is-prime*.base(2).comb(~1)R**-1||i}(++$)i}...*)[^$_])».reals)} ``` [Try it online!](https://tio.run/##HYy9DoIwAIRfpSHE/iBFHJyAwdnJyQSRVCnaSIG0BCG1vpibL4bocJd8uS/XclVtJjmCRQniyRgn0v0V9II/ts0QQ2OoFPXyX56b/2LRjyQbsIVJ1LLuBopZdHbO4TWvEJSiqmJYNzWHQHequfMYKl7AIImC@TxxLELp0ctAeiQZMr6hQvutEpITemaaozWml0ae0SvEe0L88PkUFnmei4WllBKcntw8w583VZxVGttJsxGUKFzh6Qs "Perl 6 – Try It Online") (Really managed to pare this one down!) This function outputs in SVG format. * `{ -{ .is-prime * .base(2).comb(~1) R** -1 || i }(++$)i } ... *` is an infinite sequence of direction changes for each step, in the form of complex numbers, where `1` means "continue in the same direction," `i` means "turn left," and `-i` means "turn right." * `[^$_]` limits that sequence to the number of steps provided as the function's argument. * `[\*]` scans that sequence with (complex) multiplication, turning the list of relative direction changes into a list of absolute directions. * `[\+]` scans *that* sequence with (complex) addition, producing a list of the visited coordinates. * `».reals` converts that list of complex numbers into two-element lists of its real and imaginary parts. The SVG image is just one single `path` element. Output (converted to PNG) for N = 20000: [![path for N = 20000](https://i.stack.imgur.com/B8n94.png)](https://i.stack.imgur.com/B8n94.png) [Answer] ## C, 321 bytes ``` a,b,A,B,k,p,e,i,t,r;g(n,c,d,x,y,X,Y){x=y=Y=r=0;X=1;for(k=0;k++<=n;){r|=x==c&y==d;a=x<a?x:a;A=x>A?x:A;b=y<b?y:b;B=y>B?y:B;for(p=1,i=k;--i;p=p*i*i%k);for(e=1,i=k;i;e=-e)i&=i-1;if(p)t=X,X=-e*Y,Y=e*t;x+=X;y+=Y;}}f(n,x,y){A=a=B=b=0;g(n);printf("P1%d %d ",A-a+1,B-b+1);for(y=b;y<=B;++y)for(x=a;x<=A;++x)g(n,x,y),putchar(48+r);} ``` [Try it online!](https://tio.run/##LY/RaoNAFER/RQIJu@5dUOhDyXUS1i/ooz6uRpNFakUs7GL9drtNA/dhmIG5Z1p9b9t9t9SQoZIGmqgjRwvNfBcjtXQjT4EqquXqEVBjRsYVcu6/ZjFEPShVYGS5zj/wQHsKwI0tfGGv/mzZwF9MVIYbhKK5hnPDJcKljKp8tkzIyWFgrR1PmFKXuuMgn1H3ihx30J10Jzids@vFJBdUVEUzralGly7sFSoOCjVvWx/ZI7dcDSxKNJEzzpE8zW5cenH4yI@3JN6BjLYqp1I3Kv9/GdBwKFCyUkH@GR6WfQETDS/vr2Kavpf2YWfx9q5mydv@ad0oZLImvcizLJOcbPsv) I started working on this before the other C answer was posted, but I figured I might as well post mine as well anyway. This one is a lot longer, but it also crops the output image to the dimensions of the result automatically. Function is called as `f(n)`, and output is to stdout in netpbm format. Example output for n=1000: [![](https://i.stack.imgur.com/j494m.png)](https://i.stack.imgur.com/j494m.png) ``` a,b,A,B, // used to store x range [a,A] and y range [b,B] k,p,e,i,t, // temp variables used in g r;g(n,c,d, // takes n + coordinates, sets r to whether (c,d) is visited x,y,X,Y){ // temp variables - position (x,y) and velocity (X,Y) x=y=Y=r=0;X=1; // initialization for(k=0;k++<=n;){ // loops k over the step number r|=x==c&y==d; // set r to 1 if current coordinate is the requested one a=x<a?x:a;A=x>A?x:A;b=y<b?y:b;B=y>B?y:B; // update bounds for(p=1,i=k;--i;p=p*i*i%k); // prime test for(e=1,i=k;i;e=-e)i&=i-1; // parity test if(p)t=X,X=-e*Y,Y=e*t; // if prime, turn accordingly x+=X;y+=Y;}} // move position in direction of velocity f(n,x,y){ // main function; x and y are temp variables A=a=B=b=0;g(n); // obtain accurate bounds printf("P1 %d %d\n",A-a+1,B-b+1); // output netpbm header for(y=b;y<=B;++y)for(x=a;x<=A;++x) // loop through all coordinates g(n,x,y),putchar(48+r);} // output 1 if visited, 0 otherwise ``` The prime test is essentially the one used in [Lynn's answer to a different challenge](https://codegolf.stackexchange.com/a/57676/3808), which relies on [Wilson's theorem](https://en.wikipedia.org/wiki/Wilson%27s_theorem). The parity test uses an adaptation of [Kernighan's bit-counting method](https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan). Since the prime test is very slow, and the algorithm re-runs the entire path generation function for each pixel drawn, any input much higher than 1000 times out on TIO. [Answer] ## LOGO, ~~177~~ 171 bytes ``` to d:c if :c%2[rt 180 make"c:c-1]if:c<1[stop]d:c/2 end to p if:c>1[make"f 2 repeat:c-2[if:c%:f<1[stop]make"f:f+1]rt 90 d:c]end to g:n make"c 1 repeat:n[p fw 2 make"c:c+1]end ``` To use, do something like [this](http://logo.twentygototen.org/biBItc1a): ``` reset pu fw 100 pd g 3000 ``` Sorry, but I wasn't able to capture sample output. Explanation: ``` to d:c if :c%2[rt 180 make"c:c-1]if:c<1[stop]d:c/2 end ``` This is a recursive procedure which rotates 180° for every set bit in its parameter, which effectively computes the parity of its binary expansion. ``` to p if:c>1[make"f 2 repeat:c-2[if:c%:f<1[stop]make"f:f+1]rt 90 d:c]end ``` This is a very basic primality test. After special-casing 1, the procedure early returns if a factor is found. If however the current value is found to be prime, it turns right, and then uses the above procedure to change that into a left turn as appropriate. ``` to g:n make"c 1 repeat:n[p fw 2 make"c:c+1]end ``` This is just a simple loop to test all the numbers up to `n` for primality and to move two pixels after each one. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 41 bytes ``` B§ḂḤ’×ıµ1Ẓ?€×\ÄŻÆiZ_Ṃ$€Z‘ḞŒṬµẈḢ⁾P1,;Lṭ@FK ``` [Try it online!](https://tio.run/##AV0Aov9qZWxsef//QsKn4biC4bik4oCZw5fEscK1MeG6kj/igqzDl1zDhMW7w4ZpWl/huYIk4oKsWuKAmOG4nsWS4bmswrXhuojhuKLigb5QMSw7TOG5rUBGS////zMwMDA "Jelly – Try It Online") Full program that takes a single argument \$N\$ and outputs a 1-bit PBM to STDOUT. Takes some inspiration from [@Sanchises MATL answer](https://codegolf.stackexchange.com/a/187330/42248). Starts off going South and turns left on odd bit parity. Sample output for \$N=3000\$: [![Output for N=3000](https://i.stack.imgur.com/gz86b.jpg)](https://i.stack.imgur.com/gz86b.jpg) If ASCII Art were permissible, [here’s an alternative 29-byte variant](https://tio.run/##AUcAuP9qZWxsef//QsKn4biC4bik4oCZw5fEscK1MeG6kj/igqzDl1zDhMW7w4ZpWl/huYIk4oKsWuKAmOG4nsWS4bmsWf///zMwMA) which yields (for \$N=300\$): ``` 0000000000000000000000111110000000000 0000000000000000000000100010000000000 0000001110000000000000100010000000000 0000001010000000000000100010000000000 0000001010000000000000100010000000000 0000001010000000000000100010000000000 0000001010000000111111111010000000000 0000001010000000100000101010000000000 0000001111111110100000101010000000000 0000000000100010100000101010000000000 0000000000111111100000101010001111111 0000000000000010000000101010001000001 0000000000000011100010101010001000001 0000000000000000100010101010001000001 0000111111100000100011111111111111111 0100100000100000100010001010001000001 0110100000111111100011111111111000111 0010100000000000000010101010000000101 1111100000000000000010101110000000101 1010000000000000000010100000000000101 1010000000000000000011111111111011101 1010000000000000000000100000001010101 1110000000000000000000111111101111101 0000000000000000000000000000100010101 0000000000000000000000000000100010101 0000000000000000000000000000100010101 0000000000000000000000000000111111111 0000000000000000000000000000000010100 0000000000000000000000000000000010100 0000000000000000000000000000000010100 0000000000000000000000000000000011100 ``` [Answer] # JavaScript - ~~675~~ ~~668~~ ~~660~~ ~~632~~ ~~556~~ 534 Bytes First time here on CodeGolf, initially started with ~1500 Bytes Code. Golfed it to ~~less than half~~ ~~nearly~~ more than a third of it. Feel free to continue golfing. Bytes Counted with: [this tool](https://mothereff.in/byte-counter) Principle: Draws into fixed size canvas with N and variable stroke length as input. ### Edits: -07 Bytes - remove of missed if -08 Bytes - change switch to if/else -28 Bytes - change to tenary if/else -76 Bytes - shorter prime test (runtime / 3) -22 Bytes - use [this](https://codegolf.stackexchange.com/a/91309/74284) prime function (runtime \* 4) ### Golfed Code: ``` function f(e,r){for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){n=iP(a)?iO(a)?1:2:0;var u=i,c=f;t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2));o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(),i=u,f=c}}function iP(h){for(i=n=h;n%--i;);return(1==i)}function iO(e){for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++)"1"==r[n]&&t++;return t%2!=0} ``` ### Ungolfed code with whitespaces: ``` function f(e,r){ for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){ // prime and odd/even check n=iP(a)?iO(a)?1:2:0; var u=i,c=f; t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2)); o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(), i=u,f=c // renew old cords } } // check prime function iP(h){ for(i=n=h;n%--i;); return(1==i) } // check binary expression even/odd function iO(e){ for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++) "1"==r[n]&&t++; return t%2!=0 } ``` ### Examples: > > N = 7 - Length = 60 > > > > ``` > f(7, 60); > function f(e,r){for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){n=iP(a)?iO(a)?1:2:0;var u=i,c=f;t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2));o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(),i=u,f=c}}function iP(h){for(i=n=h;n%--i;);return(1==i)}function iO(e){for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++)"1"==r[n]&&t++;return t%2!=0} > ``` > > > ``` > <canvas id="d" width="1900" height="900"/> > ``` > > > > > > > N = 3000 - Length = 4 > > > > ``` > f(3000, 4); > function f(e,r){for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){n=iP(a)?iO(a)?1:2:0;var u=i,c=f;t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2));o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(),i=u,f=c}}function iP(h){for(i=n=h;n%--i;);return(1==i)}function iO(e){for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++)"1"==r[n]&&t++;return t%2!=0} > ``` > > > ``` > <canvas id="d" width="1900" height="900"/> > ``` > > > > > > > N = 20000 - Length = 2 > > > > ``` > f(20000, 2); > function f(e,r){for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){n=iP(a)?iO(a)?1:2:0;var u=i,c=f;t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2));o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(),i=u,f=c}}function iP(h){for(i=n=h;n%--i;);return(1==i)}function iO(e){for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++)"1"==r[n]&&t++;return t%2!=0} > ``` > > > ``` > <canvas id="d" width="1900" height="900"/> > ``` > > > > > > > N = 159000 - Length = 1 > > > > ``` > f(159000, 1); > function f(e,r){for(var t=0,n=0,i=950,f=450,o=document.getElementById("d").getContext("2d"),a=1;a<=e;a++){n=iP(a)?iO(a)?1:2:0;var u=i,c=f;t==0?(t=0==n?(c=f-r,0):1==n?(u=i-r,1):(u=i+r,3)):t==1?(t=0==n?(u=i-r,1):1==n?(c=f+r,2):(c=f-r,0)):t==2?(t=0==n?(c=f+r,2):1==n?(u=i+r,3):(u=i-r,1)):(t=0==n?(u=i+r,3):1==n?(c=f-r,0):(c=f+r,2));o.beginPath(),o.moveTo(i,f),o.lineTo(u,c),o.stroke(),i=u,f=c}}function iP(h){for(i=n=h;n%--i;);return(1==i)}function iO(e){for(var r=(e>>>0).toString(2),t=0,n=0;n<r.length;n++)"1"==r[n]&&t++;return t%2!=0} > ``` > > > ``` > <canvas id="d" width="1900" height="900"/> > ``` > > > > > > > [Answer] # [Red](http://www.red-lang.org), ~~515~~ ~~480~~ 471 bytes -1 byte thanks to Kevin Cruijssen! ``` func[n][a: 270 x: t: u: v: w: 0 y: 1 b: copy[line 0x0 0x1]repeat i n - 1[p: on j: i + 1 repeat k i / 2[if j%(k + 1)= 0[p: off]]if p[s: 0 until[if j% 2 = 1[s: s + 1](j: j / 2)< 1]a: a + pick[-90 90]s% 2 + 1]append b 'line append b as-pair x y x: x + cosine a y: y - sine a append b as-pair x y t: min x t u: max x u v: min y v w: max y w]c: 500 /(max u - t w - v)view[base white 502x500 draw collect[foreach k b[keep either pair? k[as-pair k/1 - t * c k/2 - v * c][k]]]]] ``` A significant part of the code (~160 bytes) deals with normalizing the coordinates so that the graphics fits entirely in the canvas regardless of the size of the input. Initial direction: South. Here's the result for `n = 3000` ## [3000 iterations](https://i.stack.imgur.com/75ive.png) `n = 20000` [![20000](https://i.stack.imgur.com/oVMPT.png)](https://i.stack.imgur.com/oVMPT.png) [Answer] # Processing , 140+ bytes ``` void f(int N){for(int x,y,i,l,d,k=d=y=x=0;k++<N;d+=i<l?0:Integer.bitCount(k)%2*2-1,d&=3,point(x-=~-d%2,y+=(d-2)%2))for(i=1,l=k;0<l%++i%l;);} ``` Might not fulfill clearly seen [![walk](https://i.stack.imgur.com/hsnvs.png)](https://i.stack.imgur.com/hsnvs.png) ]
[Question] [ Skittles are colored candy where there are 5 distinct flavors; grape, green apple, lemon, orange, and strawberry represented by (p)urple, (g)reen, (y)ellow, (o)range, and (r)ed respectively. I used to eat skittles by sorting all the different colors, then eating them in sequence. After getting a few weird looks in the office, I now pretend to eat them like a normal person. Your task is to emulate this: Your code (full program or function) will receive an array of skittles (10x10) as input (in any reasonable format). This array will represent a pile of unsorted skittles. Your task is to "eat" them from your least favorite to favorite color. My preferred order is grape, green apple, lemon, orange, strawberry, but you are free to choose any order so long as it is consistently enforced (please list your preference in your submission so I can judge you for it). After eating each piece of candy your code will output (in the same format you take input) the remaining pile with the eaten piece replaced by a space. You will repeat until only your favorite remains. You may choose any skittle to eat (may be random or deterministic). Trailing spaces must be kept. For example, your output sequence could look like this (using 5x5 for brevity and showing spaces as `.`) ``` start 1 2 3 4 5 n .org. .org. .org. .org. .or.. .or.. ..r.. prgrg .rgrg .rgrg .rgrg .rgrg .r.rg .r.r. gggpr gggpr ggg.r ggg.r ggg.r ggg.r ....r oyyor oyyor oyyor oyyor oyyor oyyor ....r .r.p. .r.p. .r.p. .r... .r... .r... .r... ``` This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code in bytes wins **TL;DR Rules:** * Submission may be full program or function * Input may be taken in any reasonable format (string, list, matrix, etc) by any reasonable method (STDIN, function arguments, etc.). However there must be some delineation between rows * Output must be produced in the same format as input by any reasonable method (STDOUT, function return, ect.). Intermediate output may or may not be delimited * First output shall be the first input * Trailing spaces must be preserved * Any color order may be used (list in your answer) * Any skittle of the current color may be eaten * Last output shall be only your favorite color and spaces * If possible, include a link to an online compiler to test your submission [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~16 14~~ 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` Ṅ⁶ỤṪ$¦µQL>3µ¿ ``` **[TryItOnline!](http://jelly.tryitonline.net/#code=4bmE4oG24buk4bmqJMKmwrVRTD4zwrXCvw&input=&args=IG9yZyAKcHJncmcKZ2dncHIKb3l5b3IKIHIgcCAKCg)** Most to least favourite, as for anyone serious about their O.C.D., is alphabetical! Takes input and outputs as text (i.e. the rows are delimited by new lines). 3 bytes saved by reversing the direction and using a different method: grade up rather than finding characters from the alphabet. ### How? ``` Ṅ⁶ỤṪ$¦µQL>3µ¿ - Main link: Skittle text µ µ - monadic chain separation ¿ - while Q - unique items L - length >3 - greater than 3 (until only new lines, spaces and 'g's remain) Ṅ - print z and a line feed, yield z $ - treat last two links as a monad Ụ - grade up (get indices of: new lines; spaces; gs; os; ps; rs; ys) Ṫ - tail (the last of those, so last y if there is one, else last r, ...) ⁶ - space character ¦ - apply at index (replace that index with a space) ``` [Answer] ## JavaScript (ES6), ~~74~~ ~~75~~ 74 bytes Flavors are ordered as described in the challenge: grape, green apple, lemon, orange, strawberry. Intermediate outputs are separated by newlines. ``` f=(s,n=3,r=s)=>(S=s.replace('oygp'[n],' '))!=s&&(r+=` `+S)||n--?f(S,n,r):r ``` ### Test case This test case is using the 5x5 example. Any other grid size should work as expected. ``` f=(s,n=3,r=s)=>(S=s.replace('oygp'[n],' '))!=s&&(r+=` `+S)||n--?f(S,n,r):r console.log(f( ` org prgrg gggpr oyyor r p `)) ``` [Answer] # Bash, ~~48~~, 46 bytes UPDATE: * Saved two bytes by using raw parameters to printf; **Golfed** ``` sed -nz "p;:a;`printf "s/%s/ /p;ta;" p g y o`" ``` Takes input at stdin, prints to stdout. Eats purple, green, yellow and then orange. An equivalent *sed* program would be: ``` p;:a;s/p/ /p;ta;s/g/ /p;ta;s/y/ /p;ta;s/o/ /p;ta ``` **Sample output** (delimiters are for clarity only) ``` ----- org prgrg gggpr oyyor r p ----- ----- org rgrg gggpr oyyor r p ----- ----- org rgrg ggg r oyyor r p ----- ----- org rgrg ggg r oyyor r ----- ----- or rgrg ggg r oyyor r ----- ----- or r rg ggg r oyyor r ----- ----- or r r ggg r oyyor r ----- ----- or r r gg r oyyor r ----- ----- or r r g r oyyor r ----- ----- or r r r oyyor r ----- ----- or r r r o yor r ----- ----- or r r r o or r ----- ----- r r r r o or r ----- ----- r r r r or r ----- ----- r r r r r r ----- ``` [Try it online !](https://goo.gl/YxF4OT) [Answer] # Python 2, ~~60 57~~ 56 bytes ``` def f(s):print s;q=max(s);q>'g'and f(s.replace(q,' ',1)) ``` **[repl.it](https://repl.it/EiNJ/2)** Recursive function that eats in reverse alphabetical order, leaving the greens for last. Input `s` is a string with a row delimiter with an ordinal less than that of a `'g'` (for example a new line or a comma). The function prints its input, and then recurses if that input contains anything greater than a 'g', passing the input with the first occurrence of the maximum character replaced by a space. (Almost a port of [my Jelly answer](https://codegolf.stackexchange.com/a/102342/53748).) [Answer] # Perl, ~~53~~ 46 + 2 = 48 bytes Run with `-0n` -10 bytes thanks to @Dada *Edit: Also thanks to @Dada for pointing it out, I forgot to print the input as the first output. That's been fixed.* ``` say;eval sprintf"say while s/%s/./;"x4,p,o,g,r ``` There's a little bit of trickery involved in this answer, so I'll break down what's going on. First of all, Perl doesn't like multi-line parameters being passed. The variable `$/` is the input record separator, and whenever any input encounters the character stored in it, the interpreter terminates that input and begins a new input. The default content is the newline character `\n`, which means that passing a multi-line string is not possible. To do that, we must unset `$/` from its contents. That's where the `-0` flag comes in: setting `-0` will store `null` in the variable `$/`, allowing the interpreter to read everything into the implicit variable `$_` at once. The next bit of trickery is the `eval` statement. Just what exactly are we `eval`ing? We're `eval`ing the result of the `sprintf` statement, which is broken down as follows: The first thing that `sprintf` is passed is the string `"say while s/%s/./;"` repeated 4 times, so: ``` say while s/%s/./;say while s/%s/./;say while s/%s/./;say while s/%s/./; ``` Then, `sprintf` is passed four bareword characters, `p,o,g,r`, which are interpolated into the `sprintf` statement, replacing each instance of `%s`. What we then get is the following string, which is passed to the `eval` function: ``` say while s/p/./;say while s/o/./;say while s/g/./;say while s/r/./; ``` Each `while` loop evaluates the expression `s/[color]/./`, which replaces the first instance of whatever color it is in the implicit variable `$_` with a period. If a substitution is made, it returns `1`, otherwise it returns nothing. Since `s///` has side-effects, it modifies the original variable `$_`, whose contents are then printed via `say`. Four versions of this loop are performed, replacing the purples, the oranges, the greens, and then the reds, leaving only the yellows. The reason that the yellows are left is because `y` cannot be a bareword, because it's actually a function, and having a `y` instead of any of those letters would throw an error. I could change this by putting quotes around it (+2 bytes), or using a capital Y and making the regex case-insensitive (+1 byte), but for [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), every byte counts, so I decided that I actually *like* lemon skittles the most. TL;DR: `Grape, Orange, Green Apple, Strawberry, Lemon` [Answer] # Perl, ~~30~~ ~~31~~ 33 + 2 = ~~32~~ ~~33~~ 35 bytes ``` for$x(g,o,p,r){say;s/$x/ /&&redo} ``` Run with `-n0` (2 byte penalty). Apparently, I like to eat Skittles in alphabetical order, because the program turns out shorter that way. The program doesn't really need much explanation: `-n0` reads the input implicitly (`-n` means "read input implicitly", `-0` means "don't break input on newlines"); `for$x(g..r)` runs a loop with `$x` set from each letter from `g` to `r` in turn; `say;` prints the current input, after any mutations; `s/$x/ /` replaces one copy of `$x` (specifically, the first) with a space if possible; and `&&redo` repeats the code inside the braces (without advancing the loop counter) if the replacement was successful. This program can easily be generalized to more flavours of Skittle without changing its length, and will work with a pile of any size. [Here's an Ideone link where you can test it.](http://ideone.com/EGa30Y) (Ideone doesn't allow you to specify command-line options, so I had to add a couple of lines at the start to set `-n0` and the `-M5.010` that you get for free.) [Answer] # C#, ~~134~~ 148 bytes Order: `G -> O -> Y -> P -> R` ``` I=>{var v=new string(I)+";\n";int i,j=0,c;for(;j<4;){c="goyp"[j++];for(i=0;i<I.Length;i++)if(I[i]==c){ I[i]='.';v+=new string(I)+";\n";}}return v;}; ``` Used some similar things from @Poke's answer, currently a bit longer though since I need to convert the character array to a string ;( [Answer] # Java 7, ~~139 135 130 151 138~~ 135 bytes ``` void t(char[]s){int i,j=-1;for(;++j<5;)for(i=-1;++i<109;)if(j>3|s[i]=="yogp!".charAt(j)){System.out.println(s);if(j>3)return;s[i]=32;}} ``` Eats skittles in the order: Yellow, Orange, Green, Purple, Red I guess this is better than 2 print statements >.> [Answer] # C 145 - 5 - 18 - 1 = 121 bytes ``` #define l(a)for(a=0;a<10;a++) i,j,k,b='a';F(char a[][11]){while(b++<'x')l(i)l(j)if(a[i][j]==b){a[i][j]=32;l(k)puts(a[k]);puts("");}} ``` ### ungolfed + pretty ``` #include<stdio.h> #include<windows.h> i,j,k; F(char a[][11]) { char b='a'; while(b++<'x') for(i=0;i<10;i++) for(j=0;j<10;j++) if(a[i][j]==b) { system("cls"); a[i][j]=32; for(k=0;k<10;k++) puts(a[k]); puts(""); Sleep(35); } } main() { char a[][11]={ "gggggggggg", "goooooooog", "goppppppog", "goprrrrpog", "gopryyrpog", "gopryyrpog", "goprrrrpog", "gopppppppg", "goooooooog", "gggggggggg" }; for(i=0;a[i][j];) puts(a[i++]); F(a); } ``` Here `a[][11]` means taking n-strings of length 11 where 1 char is required for termination so, technically only 10 visible chars. **order : alphabetical** this function checks for `'g'` in the given input and eliminates it 1/1 then increments the variable holding `'g'` until it finds a next match(probably letter `'o'`) and then eliminates those matched characters. The downside is that this function is just too careful.So, if your skittels were of `26` different colors code-named from letters a-z, this function will handle that input too... [Answer] # Octave, 49 bytes Eats skittles in alphabetical order, highest ascii-code first. ``` A=input("");do [~,p]=max(A(:));A(p)=32 until A<33 ``` [Answer] # ES6 (Javascript), ~~72~~,71 bytes EDITS: * Minus 1 byte, by using template literal with *of* A non-recursive version in Javascript. **Golfed** ``` s=>{r=s;for(c of`pogy`)while(s!=(s=s.replace(c,' ')))r+=` `+s;return r} ``` Input and output are multiline strings, eats pills in the "purple=>orange=>green=>yellow" order. **Test** ``` S=s=>{r=s;for(c of`pogy`)while(s!=(s=s.replace(c,' ')))r+=` `+s;return r} console.log( S(` org prgrg gggpr oyyor r p `) ); ``` [Answer] # Python 3 - ~~141~~ ~~99~~ 75 bytes ``` s=input();[exec("print(s);s=s.replace(c,' ',1);"*s.count(c))for c in'orgy'] ``` Program eats skittles in this order - `Orange Red Green Yellow Purple`. **Edit** - Thanks to [Flp.Tkc](https://codegolf.stackexchange.com/users/60919/flp-tkc) who helped to cut down 24 bytes! ``` Input - ygro goppr rppog rppog orgy Output - ygro goppr rppog rppog orgy ygr goppr rppog rppog orgy ygr g ppr rppog rppog orgy ygr g ppr rpp g rppog orgy ygr g ppr rpp g rpp g orgy ygr g ppr rpp g rpp g rgy yg g ppr rpp g rpp g rgy yg g pp rpp g rpp g rgy yg g pp pp g rpp g rgy yg g pp pp g pp g rgy yg g pp pp g pp g gy y g pp pp g pp g gy y pp pp g pp g gy y pp pp pp g gy y pp pp pp gy y pp pp pp y pp pp pp y pp pp pp ``` I believe it can be further golfed as it looks very simple. [Answer] # Vim ~~57~~ 55 bytes Saving two bytes by removing my line delimiter. Unfortunately it makes it a lot harder to read and check for correctness :(. ``` :set ws! yGP/o qqnr G9kyGGp@qq@q/y @q/p @q/g @qdG ``` Unprintables: ``` :set ws! yGP^O/o ^Oqq^Hnr G9kyGGp@qq@q/y ^O@q/p ^O@q/g ^O@qdG ``` [TryItOnline](http://v.tryitonline.net/#code=OnNldCB3cyEKeUdQDy9vCg9xcQhuciBHOWt5R0dwQHFxQHEveQoPQHEvcAoPQHEvZwoPQHFkRw&input=IG9yZyAgb3JnIApwcmdyZ3ByZ3JnCmdnZ3ByZ2dncHIKb3l5b3JveXlvcgogciBwICByIHAgCiBvcmcgIG9yZyAKcHJncmdwcmdyZwpnZ2dwcmdnZ3ByCm95eW9yb3l5b3IKIHIgcCAgciBwIA) Eats in the order oypg, leaving all of the r's for the end :) [Answer] # Mathematica, 67 bytes ``` Most[#/.(i=0;#:>"."/;i++≤0&/@Characters@"ryop")&~FixedPointList~#]& ``` Eats reds, then yellows, then oranges, then purples. [Answer] # Java 7, 125 bytes Purple, Yellow, Green, Red, Orange. I'm enjoying that I get to pick my order in this solution. :D ## Golfed ``` String s(String p){String r=p;for(String c:"pygr".split(""))for(;p.contains(c);r+="\n\n"+p)p=p.replaceFirst(c," ");return r;} ``` ## Ungolfed ``` String s(String p) { String r=p; for (String c : "pygo".split("")) { for (; p.contains(c); r += "\n\n" + p) { p = p.replaceFirst(c, " "); } } return r; } ``` [Try it here!](http://ideone.com/8GYE37) A different approach to the other Java answer by @Poke. We start by making a copy of the original string. Iterating through each color, we replace it each time it's found with a space, then append the new layout to the output string, returning after we've eaten everything but orange. ## Notes Seperation between steps is done with a double newline `\n\n`, but if the input grid can be taken with a trailing newline at the end, it can be shorted to just `\n`. [Answer] ## Haskell, 60 bytes ``` f x|(a,b:c)<-span(<maximum x)x,b>'g'=(:)<*>f$a++' ':c|1<2=[] ``` Input is a single string where the rows are separated with `,`. Return value is a list of strings with all intermediate steps. Order is alphabetically, largest first, so green remains. Usage example: ``` *Main> mapM_ putStrLn $ f " org ,prgrg,gggpr,oyyor, r p " org ,prgrg,gggpr,o yor, r p org ,prgrg,gggpr,o or, r p o g ,prgrg,gggpr,o or, r p o g ,p grg,gggpr,o or, r p o g ,p g g,gggpr,o or, r p o g ,p g g,gggp ,o or, r p o g ,p g g,gggp ,o o , r p o g ,p g g,gggp ,o o , p o g , g g,gggp ,o o , p o g , g g,ggg ,o o , p o g , g g,ggg ,o o , g , g g,ggg ,o o , g , g g,ggg , o , g , g g,ggg , , ``` Simple recursion. Save the input list in for the return value, replace the largest element greater `g` with a space and call the function again. Base case is when there's no element left to remove. [Answer] # MATL, 24 bytes ``` `tDX:t2#X>wx32w(10etun2> ``` [Try it online!](http://matl.tryitonline.net/#code=YHREWDp0MiNYPnd4MzJ3KDEwZXR1bjI-CgonLS0tLS0tLS0tLSdEICUgRGlzcGxheSBkZWxpbWl0ZXIuIE5vdCByZXF1aXJlZCBieSBjaGFsbGVuZ2Ugc3BlY3Mu&input=WydycCAgZyB5cm95JzsneSBvb3Jwb2dvZyc7J3BvcHl5eXJwcnknOydwb2d5Z29ncGdwJzsnb3lncCBvZyB5byc7J3kgcnJ5cnAgbyAnOydwcHJvcm9nIHlwJzsncm95IHJwZ3lvcic7J2dncmdwciB5cm8nOycgcnByIGd5cHB5J10) I prefer eating my skittles in reverse alphabetical order: green is my favourite colour. Explanation: ``` % Take input implicitly. ` % Start do ... while loop tD % Duplicate skittle pile (nom!), but give away for display X: % Put skittles in long row (like normal people do) t2#X> % Get least favourite skittle name and number in the row wx % Discard the skittle name 32w % Put an eaten skittle on the stack (ASCII 32) ( % Put the eaten skittle back in the row of skittles. 10e % Shape the row back into a 10x10 array tun % Check the number of unique skittles 2> % Loop while this number >2 (eaten skittles + favourite skittles) % Implicit end of do... while loop. % Display last iteration implicitly, since it's still on the stack. ``` [Answer] # QBasic, 125 bytes Creative rules abuse! ``` DATA 71,89,82,79 ?INPUT$(109) DO READ s FOR r=1TO 10 FOR c=1TO 10 IF s=SCREEN(r,c)THEN SLEEP 1:LOCATE r,c:?" " NEXT NEXT LOOP ``` This submission assumes a lot of things are okay: * Input and output are uppercase (`GORPY`) * Input is taken as 109 successive keypresses, which are not echoed to the screen until the last one is entered. At the end of each row except the last one, the user must enter a carriage return. * Instead of printing the Skittles pile multiple times, the program displays it on the screen with a 1-second pause before each step. (QBasic doesn't have output scrollback, so printing the pile multiple times would only give you the last 2 1/2 steps. Also, this method is a much better depiction of how your pile of Skittles evolves as you eat them.) * The program ends with an error. I also have a 130-byte version that uses lowercase and doesn't error. Here's a sample run in [QB64](http://qb64.net), with `109` changed to `29` for a 5x5 grid: [![Eating Skittles](https://i.stack.imgur.com/5gBwb.gif)](https://i.stack.imgur.com/5gBwb.gif) ### Explanation `DATA 71,89,82,79` stores the ASCII codes of `G`, `Y`, `R`, and `O`. `?INPUT$(109)` gets 109 keypresses from the user and prints them. We then enter an infinite `DO ... LOOP` construct. Each time through, we `READ` the ASCII code of the current Skittle into `s`. Then we loop over rows and columns from 1 to 10. `SCREEN(r,c)` gets the ASCII code of the character on the screen at row `r`, column `c`. If this is equal to the current Skittle `s`, we `SLEEP` for one second and then print a space at `r`, `c`. The main loop runs four times, removing the green, yellow, red, and orange Skittles. On the fifth iteration, `READ` errors because we're out of data. ]
[Question] [ While writing my essay for Shakespeare, I realized that I needed to shorten my quote references to more manageable lengths. I had previously been writing this: ``` (Act 1, Scene 2, Lines 345-346) ``` But I've now been told to write them like this: ``` (I.ii.345-6) ``` Clearly, I need some golfed code to golf my Shakespeare quote references down a bit. # The Task Write a program or function that, given a string input following Template 1 or 2, print or return a string following Template 3 or 4, respectively. You only have to support Acts 1 through 5 and Scenes 1 through 9. # Templates ### Template 1 ``` (Act x, Scene y, Lines a-b) ``` You may assume that `x` never exceeds 5, `y` never exceeds 9, `a` and `b` are always positive integers not exceeding your language's maximum positive standard integer value, and `a` is always exclusively less than `b`. ### Template 2 ``` (Act x, Scene y, Line a) ``` Same conditions as Template 1, excluding information about `b`. ### Template 3 ``` (x.y.a-b) ``` Where `x` is a capital roman numeral, `y` is a lowercase roman numeral, `a` and `b` are numbers, and `b` is shortened to only the digits less than the first differing digit of equal significance from `a`. ### Template 4 ``` (x.y.a) ``` Same conditions as Template 3, excluding information about `b`. # Test Cases Let `f(s)` be the function defined in the Task. `""` denotes a string value. ``` >>> f("(Act 1, Scene 2, Lines 345-346)") "(I.ii.345-6)" >>> f("(Act 3, Scene 4, Lines 34-349)") "(III.iv.34-349)" >>> f("(Act 5, Scene 9, Lines 123-234)") "(V.ix.123-234)" >>> f("(Act 3, Scene 4, Line 72)") "(III.iv.72)" >>> f("(Act 2, Scene 3, Lines 123-133)") "(II.iii.123-33)" >>> f("(Act 4, Scene 8, Lines 124-133)") "(IV.viii.124-33)" ``` For the purposes of this challenge, the following arabic to roman numeral translations must be supported: ``` 1 i I 2 ii II 3 iii III 4 iv IV 5 v V 6 vi (you do not have to support past 5) 7 vii 8 viii 9 ix ``` [Answer] # [The Shakespeare Programming Language](http://shakespearelang.sourceforge.net/) (non-competing) I really liked this question, and as there was [some](https://codegolf.stackexchange.com/questions/123378/golf-my-shakespeare-quote-references#comment302793_123378) [interest](https://codegolf.stackexchange.com/questions/123378/golf-my-shakespeare-quote-references#comment302832_123378) in a Shakespeare-language answer, here is one. ``` A Tale of Two Cites (sic). Julius Caesar, the first citizen of the Roman Republic. Brutus, a traitor -- member of the Fifth Column. Cicero, the greatest Roman orator. Cleopatra, a proud queen, whom the Romans want to make one of their own. Romeo, a man who's sometimes there. Juliet, a maiden who can follow Romeo or stand on her own. Act I: Imperium Romanum. Scene I: Cleopatra puts men in their place. [Enter Cleopatra and Julius Caesar] Julius Caesar: Thou art as lovely as the sum of an amazing delicious gentle blossoming warm angel and a charming noble reddest rose. Speak your mind. Open your mind. Open your mind. Open your mind! Open your mind! Cleopatra: You are as stuffed as the sum of a hard old green horse and the sum of a grandmother and a normal tiny bottomless furry small purple roman. [Exit Julius Caesar] [Enter Brutus] Cleopatra: You are as sorry as the difference between a rich morning and a leech. You are as smelly as the difference between yourself and a sunny rural blue bold uncle. You are as vile as the difference between Julius Caesar and yourself. [Exit Brutus] [Enter Cicero] Cleopatra: You are as half-witted as the difference between Brutus and the bluest death. Scene II: How do you solve a problem like Cleopatra? [Exeunt] [Enter Cleopatra and Julius Caesar] Julius Caesar: Listen to your heart! [Exit Cleopatra] [Enter Brutus] Julius Caesar: Is Cleopatra more pretty than a fair charming noble angel? Brutus: If so, we must proceed to Scene IV. Is Cleopatra not worse than the sweetest small aunt? Julius Caesar: If so, let us proceed to Scene III. Brutus: Speak your mind. Julius Caesar: Is Cleopatra nicer than the moon? Brutus: If so, speak your mind. Julius Caesar: Is Cleopatra better than a golden King? Brutus: If so, speak your mind. Julius Caesar: We shall proceed to Scene V. Scene III: Brutus and his friends. Julius Caesar: Is Cleopatra as fair as the blossoming smooth sky? Brutus: If so, speak your mind! Julius Caesar: Speak your mind! Julius Caesar: Is Cleopatra jollier than the sum of a yellow sweet road and a summer's day? Brutus: If so, speak your mind! Julius Caesar: Is Cleopatra friendlier than the sum of a sweet large angel and a white cow? Brutus: If so, speak your mind! Julius Caesar: Is Cleopatra as furry as a rich handsome huge mistletoe? Brutus: If so, speak your mind! Julius Caesar: We shall proceed to Scene V. Scene IV: Cicero is asked to speak. [Exit Brutus] [Enter Cicero] Julius Caesar: Is Cleopatra as beautiful as the sum of a small furry white angel and a summer's day? Cicero: If so, speak your mind! Julius Caesar: Speak YOUR mind! Scene V: A period piece -- Cleopatra's reprisal. [Exeunt] [Enter Cleopatra and Julius Caesar] Julius Caesar: You are as beautiful as the sum of a embroidered sweetest sunny delicious trustworthy Lord and a reddest charming mighty honest King. You are as healthy as the difference between yourself and a embroidered Lord. Speak your mind! Open your mind! Open your mind! Open your mind! Open your mind! Open your mind! Open your mind! Cleopatra: Are you jollier than the sum of a little rural white bottomless blue blue sky and a rural furry white green old morning? Julius Caesar: If so, we must proceed to Act II. Open your mind! Open your mind! Cleopatra: You are as damned as the difference between yourself and a half-witted dusty snotty rotten oozing death. [Exit Julius Caesar] [Enter Brutus] Cleopatra: You are as rotten as the difference between yourself and a rural rotten bottomless evil miserable famine. [Exit Brutus] [Enter Cicero] Cleopatra: You are as fatherless as the difference between Brutus and a normal pig. Let us return to Scene II. Act II: Lovers' arithmetick. Scene I: Our lovers discuss what they have in common. [Exeunt] [Enter Romeo and Juliet] Romeo: Thou art as bold as a curse. Listen to your heart! Juliet: Am I better than nothing? If so, let us proceed to Scene III. Romeo: Open your mind. Open your mind. Juliet: Listen to your heart! Open your heart! Romeo: Thou art as amazing as the product of the difference between a handsome white proud white grandfather and an aunt and the sum of a loving niece and the Heaven. Speak your mind! Open your mind. Listen to your heart. Is the quotient between yourself and the sum of the sum of a noble noble mighty blossoming embroidered good father and a gentle large large normal old joy and an old happy squirrel as yellow as the quotient between myself and the sum of the sum of a pretty beautiful yellow green bold charming kingdom and a beautiful blue normal cute large nephew and a pretty big cousin? Juliet: If not, we shall proceed to Scene II. Romeo: You are as sweet as the remainder of the quotient between yourself and the sum of the sum of a blossoming bottomless golden peaceful noble healthy nose and a happy honest sunny green healthy hero and a hard blue fellow. Juliet: YOU are as sweet as the remainder of the quotient between yourself and the sum of the sum of a blossoming bottomless golden peaceful noble healthy nose and a happy honest sunny green healthy hero and a hard blue fellow. Scene II: Tense times. Juliet: Is the quotient between yourself and the sum of a good beautiful delicious grandmother and a noble wind as amazing as the quotient between myself and the sum of a smooth furry embroidered roman and a honest sister? Romeo: If so, you are as amazing as the remainder of the quotient between yourself and the sum of a cute healthy smooth kingdom and a normal mother. Scene III: Parting is such sweet sorrow. Romeo: Open your heart! You are as noble as the sum of a honest charming smooth peaceful fine rose and the sum of a cute amazing trustworthy summer's day and an angel. Speak your mind! ``` (It's over 6000 bytes long.) There are some tricks in there but I have not tried to golf it much, because: (1) I already [contributed](https://codegolf.stackexchange.com/questions/123378/golf-my-shakespeare-quote-references/123693#123693) my share of golfing on another answer, and (2) changing all characters to "Page" and "Puck", or all phrases to "big big big big big cat", seems to spoil the fun. Instead for the part that deals with Roman numerals I have used characters who are Romans, etc. I did reuse characters and instructions to save some typing. :-) The program should be mostly straightforward but one wrinkle worth mentioning is that when I wrote this I assumed that reading an integer would work like `scanf`: (1) consume only as many characters from the input as corresponds to an integer, and (2) in case of failure, leave the variable unchanged. (I used this second property to distinguish between Template 1 and 2 in Act II, by reading up to "Line" and attempting to read an integer.) Unfortunately it turns out that there's (what I consider) a bug in the original implementation of the language where reading an integer consumes everything up to the end of the line and throws an error if it fails, so it needs [a patch to `libspl.c`](https://gist.github.com/shreevatsa/b235214061c2664af306241790f8e5f5) to make `int_input` behave more like `scanf`. And with that, it works: ``` % spl2c < good.spl > good.c % gcc -lspl -o good good.c % for f in in-*; do cat $f; echo "->"; ./good < $f; echo "\n"; done (Act 1, Scene 2, Lines 345-346) -> (I.ii.345-6) (Act 3, Scene 4, Lines 34-349) -> (III.iv.34-349) (Act 5, Scene 9, Lines 123-234) -> (V.ix.123-234) (Act 3, Scene 4, Line 72) -> (III.iv.72) (Act 2, Scene 3, Lines 123-133) -> (II.iii.123-33) (Act 4, Scene 8, Lines 124-133) -> (IV.viii.124-33) ``` Slightly higher-level pseudocode that I worked off of, to help anyone trying to understand: ``` Print `(`=40 Read 5 chars Read Int A Output A in Roman Output `.`=46 Read 8 chars Read Int S Output S in roman Output `.`=46 Read 6 chars Set N to -1 Read Int N If N ≠ -1 goto finish Read 2 chars Read Int M Output Int M Output `-`=45 Read 1 char Read Int N Reduce N wrt M finish: Output N Print `)`=41 ``` Relating the above to the final code is left as an exercise. :-) Note that ShakespearePL has arithmetic and stacks and gotos but no pointers (only labels), so implementing "subroutines" like the conversion to Roman is a bit… interesting. [Answer] ## LaTeX, ~~513~~ ~~364~~ ~~259~~ ~~226~~ ~~215~~ ~~178~~ 159 Bytes Good essays should always be written in LaTeX. ``` \documentclass{tui}\makeatletter\input{xstring}\def~#1 #2, #3 #4, #5 #6){(\@Roman#2.\@roman#4.\StrCut{#6}-\A\B\A\if\B\else-\fi\StrCompare\A\B[\P]\StrMid\B\P9)} ``` This uses the xstring package as there isn't exactly a lot of string handling built in. On the plus side the [upper limit for the built-in `\Roman` formatting](https://tex.stackexchange.com/q/372547/28808) is larger than we'll ever need (even for the sonnets) at `2^31-1`. I've included `\documentclass{ecv}` in the count, but none of the test code: ``` \begin{document} \t(Act 1, Scene 2, Lines 345-346) \t(Act 3, Scene 4, Lines 34-349) \t(Act 5, Scene 9, Lines 123-234) \t(Act 3, Scene 4, Line 72) \t(Act 2, Scene 3, Lines 123-133) \t(Act 4, Scene 8, Lines 124-133) \end{document} ``` (If you were crazy enough to actually use this, you'd have to ungolf the macro names at least. Overwriting single character macros is bad practice) Ungolfed and commented: ``` \documentclass{ecv}%We have to have a documentclass \makeatletter %treat the @ sign as a normal character (it's used in "internal" macro names) \input{xstring} %use the xstring package \def\shortref#1 #2, #3 #4, #5 #6){ %macro with 6 positional arguments searated by spaces and commas (%print the open bracket \@Roman#2 %arg 2 is the Act, print uppercase Roman .%print the full stop \roman#4 %arg 4 is the Scene, lowercase roman .%print the full stop \StrCut{#6}{-}{\A}{\B}%split arg 6 (Lines) at the hyphen, into macros \A and \B \A %print the bit before the hyphen \ifx\B\empty%if \B has nothing in it do nothing \else %otherwise - %we need to print a hyphen \fi%endif \StrCompare{\A}{\B}[\P] %returns (in macro \P) the position at which \A and \B first differ \StrMid{\B}{\P}{9}%print \B starting from position \P (9 > the number of remaining characters) )}%print the closing bracket ``` Note that in this version the comments are *required* otherwise the newline is interpreted as whitespace and expands to a space. [Answer] # JavaScript (ES6), ~~210~~ ~~183~~ ~~178~~ ~~177~~ 171 bytes *Saved 27 bytes by unrolling rest parameters (thanks to [ETHproductions](https://codegolf.stackexchange.com/users/42545/ethproductions))* *Saved 5 bytes by not matching the opening paren and by tweaking the roman numeral generation* *Saved 1 byte by adjusting the final ternary expression* *Saved 6 bytes by combining two matching groups* ``` s=>s.replace(/Act (\d)\D*(\d)\D*(\d*)(\d*-?)\3(\d*)/,(_,a,b,c,d,e)=>'IIIV'.slice(a>3&&a-2,a)+'.'+'iiiviiix'.slice('233336'[b-4],b-(b>4))+'.'+c+d+(d.length>e.length?e:c+e)) ``` ## Test Cases: ``` let f = s=>s.replace(/Act (\d)\D*(\d)\D*(\d*)(\d*-?)\3(\d*)/,(_,a,b,c,d,e)=>'IIIV'.slice(a>3&&a-2,a)+'.'+'iiiviiix'.slice('233336'[b-4],b-(b>4))+'.'+c+d+(d.length>e.length?e:c+e)) ;[ ["(Act 1, Scene 2, Lines 345-346)", "(I.ii.345-6)"], ["(Act 3, Scene 4, Lines 34-349)", "(III.iv.34-349)"], ["(Act 5, Scene 9, Lines 123-234)", "(V.ix.123-234)"], ["(Act 3, Scene 4, Line 72)", "(III.iv.72)"], ["(Act 2, Scene 3, Line 123-133)", "(II.iii.123-33)"], ["(Act 4, Scene 8, Line 124-133)", "(IV.viii.124-33)"], ["(Act 1, Scene 2, Lines 345-3499)", "(I.ii.345-3499)"] ].map(([a,b]) => console.log(`${a} => ${f(a)} (${f(a) == b ? 'Pass' : 'Fail'})`)) ``` ``` .as-console-wrapper { min-height: 100% } ``` [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), ~~87 86~~ 85 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` DµU=/œr1LCṫ@Ṫ Ṗ,Çj”-µ⁸L’$?W ⁾-,yḲḊm2Ṗ€Vµ“¬Q:’ṃ⁾IV;”X“¤|ʂ’BṚ¤œṗị@µ1,2¦Œl2¦µ;ṪÇ$“(..)”ż ``` **[Try it online!](https://tio.run/nexus/jelly#@@9yaGuorf7RyUWGPs4Pd652eLhzFdfDndN0DrdnPWqYq3to66PGHT6PGmaq2IdzPWrcp6tT@XDHpoc7unKNgKoeNa0JA6pomHNoTaAVUNHDnc1ANZ5h1kCtESDhJTWnmoDiTg93zjq05OjkhzunP9zd7XBoq6GO0aFlRyflAMlDW62Bdh5uVwGq19DT0wRqPbrn////ShqOySUKhjoKwcmpeakKRjoKPpl5qcUKxiamusYmZppKAA)** or see a [test suite](https://tio.run/nexus/jelly#@@9yaGuorf7RyUWGPs4Pd652eLhzFdfDndN0DrdnPWqYq3to66PGHT6PGmaq2IdzPWrcp6tT@XDHpoc7unKNgKoeNa0JA6pomHNoTaAVUNHDnc1ANZ5h1kCtESDhJTWnmoDiTg93zjq05OjkhzunP9zd7XBoq6GO0aFlRyflAMlDW62Bdh5uVwGq19DT0wRqPbrn/9E9h9uBpmcBMVBcQddOASge@f9/tJKGY3KJgqGOQnByal6qgpGOgk9mXmqxgrGJqa6xiZmmko4CRIkxTIkJQglQhSVChSlMhSVMhaGRsa6RsQluQxTMjRCSRjBJY6gkSLuhsTFChQlMhQVchQlERSwA) ### How? ``` DµU=/œr1LCṫ@Ṫ - Link 1, toPageShort: list of numbers [fromPage, toPage] e.g. [345,365] D - cast to decimal lists [[3,4,5],[3,6,5]] µ - monadic chain separation (call that d) U - reverse each [[5,4,3],[5,6,3]] =/ - reduce by equality [1,0,1] œr1 - strip any 1s from the right [1,0] L - length 2 C - complement (1-z) -1 Ṫ - tail d [3,6,5] ṫ@ - tail from index (swap @rguments) [6,5] Ṗ,Çj”-µ⁸L’$?W - Link 2, format page number(s): number or list of two numbers ? - if: $ - last two links as a monad: L - length ’ - decremented (0 for a number, 1 for a list of two numbers) µ - then: Ṗ - pop (list without the last item, i.e. just the from page) Ç - call the last link (1) as a monad with the list as its argument , - pair ”- - literal '-' j - join - else: ⁸ - link's left argument (the single page number) W - wrap the result in a list (for ease of post-formatting in Main) ⁾-,yḲḊm2Ṗ€Vµ ... µ1,2¦Œl2¦µ;ṪÇ$“(..)”ż - Main link: string s ⁾-, - literal ['-',','] y - map (change '-' to ',') Ḳ - split at spaces Ḋ - dequeue (get all but 1st) m2 - mod-index-2 (1st,3rd,5th) Ṗ€ - pop €ach (ditch last char) V - evaluate - list of numbers - either [act,scene,page] or - [act,scene,[from,to]] µ µ ¦ - apply to indexes: 1,2 - [1,2] ... - see monadic chain " ... ", below 2¦ - apply to index 2: Œl - lowercase µ - monadic chain separation $ - last 2 links as a monad: Ṫ - tail (page(s)) Ç - call last link (2) as a monad ; - concatenate “(..)” - literal ['(','.','.',')'] ż - zip together - implicit print “¬Q:’ṃ⁾IV;”X“¤|ʂ’BṚ¤œṗị@ - monadic chain " ... " from Main - Get Roman numeral: number n (n>0, n<10) (act or scene) “¬Q:’ - base 250 literal 520559 ⁾IV - literal ['I','V'] ṃ - base decompression -> "IIIIIIIVVVIVIIVIIII" ”X - literal 'X' ; - concatenate -> "IIIIIIIVVVIVIIVIIIIX" ¤ - nilad followed by link(s) as a nilad: “¤|ʂ’ - base 250 literal 281418 B - convert to a binary list Ṛ - reverse œṗ - split at truthy indexes i.e: I II III IV V VI VII VIII IX ị@ - index into (swap @arguments) using n ``` [Answer] # [R](https://www.r-project.org/), ~~94~~ ~~126~~ ~~112~~ 166 bytes And now it's wordier than before :(, back to trying to golf it further. Regex for reducing the page reference shamelessly ~~stolen~~ borrowed from @FryAmTheEggman. Now I really need to do some work to get back the bytes, but it works for the second case now. ``` R=as.roman;i=sub(',','',scan(,''));sprintf('(%s.%s.%s',R(i[2]),tolower(R(i[4])),`if`(!diff(c(nchar(el(strsplit(i[6],'-'))),0))-1,sub('((.+).*-)\\2','\\1',i[6]),i[6])) ``` [Try it online!](https://tio.run/nexus/r#JU5BDoIwEPxKPZju6kKkEC@Eg3dPeBQSsZbYBAvplvh8LJidTGaSycwuddVx6sdP50pb8fwESfEkse4cRIFY8uStCz1I2HO6QVIN9q5apDAO49d4WH3RItLD9g/YvWzfgwan352H2Q2WA3DwPA02xOS5JZnEaqQTYpLRtguQHjE9JNg0Kr7QNJmkNYp/xgUuOogsVyRu2jgjlMpJXK0zLPIClx8 "R – TIO Nexus") - Note that `el` doesn't work on TIO and has been replaced with `unlist` ``` R=as.roman; # Used to convert to roman numeral class i=sub(',','',scan(,'')); # Get input, splits on spaces, remove ,'s sprintf('(%s.%s.%s', # Use sprintf to format the output. R(i[2]), # Convert to roman numeral tolower(R(i[4])), # Convert to roman numeral and lowercase `if`( # !diff( # Test if the lengths of the last string c(nchar(el(strsplit(i[6],'-'))),0)# split on the hyphen are different (extra 0 to appease diff) )-1, # taking into account the trailing ) sub('((.+).*-)\\2','\\1',i[6]), # on true use regex to reduce range i[6] # else output as is ) ) ``` [Answer] # [Retina](https://github.com/m-ender/retina), ~~89~~ 88 bytes ``` T`, lL`._ 2`(\d+) $*i i{5} v i{4} iv viv ix 1T`l`L`\w+ (\b(.+)(.)*-)\2((?<-3>.)*)\b $1$4 ``` [Try it online!](https://tio.run/nexus/retina#dc2xCsIwEAbg/Z4iQ4XENoXkErUgipNLNzsGDK0dAqWLUgXps9coibp0OH6Oj/9uQY92qmxGutLmZ5CWmkvKIFk6cE89wuBDjeAGGPy4B4jKdra05p4CNTXNU0ZztuTMSEr3W447vzFTQyISNU300NyIyMipafuWyIyUrm@vBJXmqFYMPo7R1c89F4Fn6jrWdfQiupDIJaqZ82Qtg8goGORdFIiBVeTNl9Ufz/99AQ "Retina – TIO Nexus") Saved 3 bytes thanks to Neil. Strips away the unnecessary characters before replacing the first two numbers with blocks of `i` characters. Then it matches chunks of these `i`s to form the appropriate roman numerals. Then we capitalise the first roman numeral. Finally we match as many numbers as we can before the hyphen and after the hyphen such that the number of digits in the number is the same. We then remove that prefix from the second number. [Answer] # PHP>=7.1, 195 Bytes ``` preg_match_all("#\d+#",$argn,$t);[[$a,$s,$b,$e]]=$t;for(;$e&&~$c=$e[$k-=1];$p="-".substr($e,$i))$c>$b[$k]&&$i=$k;echo"(",strtoupper(($r=[_,i,ii,iii,iv,v,vi,vii,viii,ix])[$a]),".$r[$s].$b",$p,")"; ``` [Testcases](http://sandbox.onlinephpfunctions.com/code/4cbc8eb752f1e4863b87cfdefbabb5481df548af) Expanded ``` preg_match_all("#\d+#",$argn,$t); # match for all groups of digits [[$a,$s,$b,$e]]=$t; # shorter variables names for these groups for(;$e&&~$c=$e[$k-=1];$p="-".substr($e,$i)) # prepare the seceond line if exists $c>$b[$k]&&$i=$k; echo"(" # print the char ( ,strtoupper(($r=[_,i,ii,iii,iv,v,vi,vii,viii,ix])[$a]) # print the upper roman digit for Act ,".$r[$s].$b" # print the lower roman digit for Scene and the first line with trailing "." ,$p # print shorted second Line ,")"; #Print the closing ) ``` [Answer] # Perl 5, 185 + 1 = 186 bytes 1 byte penalty for the required `-n` flag. May fail for some test cases where the scene has more than 10^11 lines, but AFAIK no Shakespeare scenes are quite that long ;) ``` y/A-z //d;while($x++<9){s/,(\d+)(\d{$x})-\g1(\d{$x}\))/,$1$2-$3/};@F=split/,/;for($F[0],$F[1]){$_.='i'while(y/2-91/1-8/d);s/i{5}/v/g;s/i{4}/iv/;s/v(i)?v/$1x/;s/$/,/};$F[0]=uc$F[0];say@F ``` In readable form: ``` y/A-z //d; #Delete all characters besides numbers, parenthesis, and comma while($x++<9){s/,(\d+)(\d{$x})-\g1(\d{$x}\))/,$1$2-$3/}; #Shortens the line numbers. Super ugly, but my simpler code broke on test case 2- that fix added 26 bytes :( I'll revisit this later, perhaps... @F=split/,/; #Splits the input into an array so we can mess with the act and scene without messing with the lines for($F[0],$F[1]){ #For loop over the act and scene $_.='i'while(y/2-91/1-8/d); #Recursively turn numbers into naive Roman numerals (i.e. 9 would be iiiiiiiii) s/i{5}/v/g;s/i{4}/iv/;s/v(i)?v/$1x/;s/$/,/ #Substitution rules to convert naive Roman numerals into real Roman numerals and add a comma to the end } $F[0]=uc$F[0]; #Convert act to uppercase say@F #Output ``` [Answer] # [Ruby](https://www.ruby-lang.org/), 204+1 = 205 bytes Uses the `-p` flag. ``` d=[r=%w"i ii iii iv v vi vii viii ix",r.map(&:upcase)] i=-1 gsub(/\w+ ([\d-]+)/){(a=d.pop)?a[$1.hex]:(a,b=$1.split ?-;b ?(a="%0#{b.size}d"%a;b[0]=""while b[0]==a[i+=1];a.sub(/^0*/){}+?-+b):a)} gsub", ",?. ``` [Try it online!](https://tio.run/nexus/ruby#dc5RT4MwEADgd37F2YmhQtlKmTpIQ3zfm48MkxYa12ROAkOmC78duwb0ydzdw/W7y3Vx03TyC0g9VjxvuNsjDfqapj7BhDZpyzycUdCE76L27pKuLkWrcOFoTqjz1nbSW@56H7x8V5HCx0t88QSvwvqjxpnIb2m4V@ci8UQguWna@qBPkJFUQmbmkLtaXGTY6m81VMgVqcxXBUeo3@uDAttwkWuf0yIVoT32uro3NwY/I77EicCD/QQKAAVZOI7ec3kCGsBLqY4KogC2@qhaYPGasPgBO9bZ7PGfG95MvJ55MzONGIlY/M86PEaTRLOwSa6LlLGJ45mffjm2/AM "Ruby – TIO Nexus") [Answer] # Python 2.7 298 bytes ``` import re r=lambda n:'iiiviiix'[2*(n>3)+(n>4)+3*(n>8):n-(n>4)] o=lambda x,y,n=0:n*(len(x)==len(y))if not x or x[0]!=y[0]else o(x[1:],y[1:],n+1) q=lambda a,s,g,h:(r(int(a)).upper(),r(int(s)),g+'-'+h[o(g,h):]if h else g) f=lambda p:'(%s.%s.%s)'%q(*re.match('\D*(\d)\D*(\d)\D*(\d+).(\d*)',p).groups()) ``` [Answer] ## Perl, 99 bytes ``` /(.+)(-\1|.(?2).)\b/;@r=(s/-$1/-/,I,II,III,IV,V,VI,VII,VIII,IX);s/Act(.+)(.,).+ /$r[$1].\L$r[$2]./ ``` Run with `perl -pe`. 98 bytes (source) + 1 byte (`p` flag) = 99. [Answer] # [Python 2](https://docs.python.org/2/), ~~301~~ ~~259~~ ~~252~~ 221 bytes *A whopping -31 bytes thanks to Chas Brown.* So, uh, this is... extremely long... I think I can golf this but I've been wracking my brain for a while. ``` import re def f(s):s,r=re.match(r'.*?(\d),.*?(\d), .*? (\d*)(\d*-?)\3(\d*)',s),'0 i ii iii iv v vi vii viii ix'.split();b,c,d,e,f=s.groups();print'(%s.%s.%s)'%(r[int(b)].upper(),r[int(c)],d+e+(f if len(e)>len(f)else d+f)) ``` [Try it online!](https://tio.run/nexus/python2#fYzNTsMwEITvfYq9VN5tHIvELlBQqbhz40h7oMkaLKVpZKeIty9OqCGnyrM/nvm0Z3fojr4Hz7OaLVgM9BCkX3tWh/e@@kQv1GKD25pkmhAXiNuChpZvaKvHn5CBpLgBB25QrC@Iz0WNFY1voULXuB7pcS8rWUuWdh3Uhz@euhDNzru2FzgPahSJOfq3aOGedurUdeyR5K9T0U7WGWdowVlouEWmp2FY4iYw1JklOlsU@Fz1UEh4rbhlKCW8uJYDaLPMtbklQbME6QSZfygyqymzTMwqMUWp81Kba4fgrpzGZYr1JR5OFFpPGZOY@z/GXJjzDw "Python 2 – TIO Nexus") ## Breakdown ``` import re # re module for regex stuff def f(s): # function that accepts one argument s, r = (re.match(r'.*?(\d),.*?(\d), .*? (\d*)(\d*-?)\3(\d*)', s), # match the string and capture the important parts using regex '0 i ii iii iv v vi vii viii ix'.split() # array that stores roman numerals b, c, d, e, f = s.groups() # all the numbers from the match to variables print '(%s.%s.%s)' % ( r[int(b)].upper(), # get the respective roman numeral and make it uppercase r[int(c)], # get the respective roman numeral d + e + (f if len(e) > len(f) else d + f) # shorten the second number if it's shorter than the first number ) ``` [Answer] # q/kdb+, ~~200~~ 187 bytes **Solution:** ``` f:{R:(($:)N:(!)11)!($:)``i`ii`iii`iv`v`vi`vii`viii`ix`x;S:","vs x inter .Q.n,",-";L:"-"vs P:S 2;"(",("."sv(upper R S 0;R S 1;$[{x[y]=x z}[#:;F:L 0;T:L 1];F,"-",((*:)N(&:)F<>T)_T;P])),")"} ``` **Examples:** ``` q)f "(Act 1, Scene 2, Lines 345-346)" "(I.ii.345-6)" q)f "(Act 3, Scene 4, Lines 34-349)" "(III.iv.34-349)" q)f "(Act 5, Scene 9, Lines 123-234)" "(V.ix.123-234)" q)f "(Act 3, Scene 4, Line 72)" "(III.iv.72)" q)f "(Act 2, Scene 3, Lines 123-133)" "(II.iii.123-33)" q)f "(Act 4, Scene 8, Lines 124-133)" "(IV.viii.124-33)" ``` **Explanation:** (slightly ungolfed) ``` f:{ // create map of 0->10 to roman numerals, e.g. "5" -> "v" R:(($:)N:(!)11)!($:)``i`ii`iii`iv`v`vi`vii`viii`ix`x; // remove everything from the input string except -, then split on , S:","vs x inter .Q.n,",-"; // split the final field on '-', also save final field in variable P L:"-"vs P:S 2; // if the length of from/to lines are the same then find the first character // where they differ, and cut this many characters from the 'to' string M:$[{x[y]=x z}[#:;F:L 0;T:L 1];F,"-",((*:)N(&:)F<>T)_T;P]; // join everything together, use act/scene to index into // the roman numeral map, uppercase the act "(",("."sv(upper R S 0;R S 1;M)),")" } ``` **Notes:** Technically it can be 2 bytes shorter (no need for the `f:`) but makes it easier to show examples this way. **Edits:** * -13 bytes; replaced `string` with `$:`, `count` with `#:`, `til` with `(!)` and `first` with `(*:)`, cast the indices of R to strings so we dont have to cast act/scene into ints ]
[Question] [ ### Why a Simulator? Kids these days don't have the time nor the ambition to actually go and stack boxes on the see-saw or play around with balancing physical objects. This leaves lots of room in the software market for a Lever Simulator which will, according to my models, sell like mad! ### Programming Help Wanted I've filed the patent for such a game (pending), but need an expert programmer to write the game-logic for me. From my understanding, it is standard practice to compensate programmers based on the **size in bytes** of the final program. As such I will be awarding this lucrative contract to the lowest bidder. ### Specification A lever is a series of boxes or empty spaces that is balanced by a fulcrum. Each box has a particular weight **one** through **nine** and spaces have no weight. As you know, a box's weight on the lever is directly proportional to how far that box is from the fulcrum. A box of weight `4` that is on the third space from the fulcrum will contribute `12` effective units of force to that side of the lever. I need a program that, given an input lever, will output whether the lever will skew toward the left, the right, or be perfectly balanced. ### I/O Guidelines * You will write for me a program. * The input will contain one line of text. * The input will come from `stdin` or as one command-line string. * Boxes will represented by the characters '`1`' through '`9`'. These characters represent their respective weights. An empty space will be represented by a space ''. The fulcrum will be represented by a caret '`^`'. A sample input lever could look like: `8 2^ 941` This lever is perfectly balanced: `(4*8) + 0 + 0 + (1*2) == 0 + (2*9) + (3*4) + (4*1) == 34` * There will be no leading nor trailing spaces. There will be no trailing newline. * No need to handle malformed input, input will always have exactly one fulcrum, and only numbers and spaces. * The output will indicate whether the lever is left-heavy, right-heavy, or balanced. * Your program must have exactly 3 possible outputs that could result from a well-formed input. You can choose what these are. * The output must either be print to `stdout` or be the return code of the program. ### Test cases Here I use `L`,`R`,`B` to mean left-heavy, right-heavy, balanced: 1. Input: `11 ^9` Output: `B` 2. Input: `321^ 12` Output: `L` 3. Input: `9^ 1` Output: `R` (If anyone has some "trickier" test cases, feel free to edit them in). ### Bibliography Not-necessarily-inspired-by, but related to [Balance a set of weights on a seesaw](https://codegolf.stackexchange.com/questions/54311/balance-a-set-of-weights-on-a-seesaw) [Answer] # Javascript ES6, 62 Bytes ``` s=>Math.sign([...s].reduce((p,c,i)=>p+~~c*(i-s.indexOf`^`),0)) ``` * `-1` if left is heavier * `0` if balanced * `1` if right is heavier Ungolfed: ``` s=> Math.sign( // output sign of weight of lever [...s].reduce((p,c,i)=> // split and reduce input p+~~c*(i-s.indexOf`^`),0)) // add weights of all elements // (elements left of pivot are negatively weighted) ``` Test runs (assigning anonymous function to `f`): ``` >> f("11 ^9") << 0 >> f("321^ 12") << -1 >> f("9^ 1") << 1 ``` --- * **-11 bytes:** changed output from `R B L` to `-1 0 1` * **-3 bytes:** changed `e.split``` to `[...e]` (thanks @Vɪʜᴀɴ) * **-33 bytes:** changed algorithm to use negative weights rather than splitting at pivot * **-9 bytes:** removed pivot check (apparently, `~~'^'` evaluates to `0`...) * **-2 bytes:** made function anonymous (thanks @cᴏɴᴏʀ-obʀɪᴇɴ) [Answer] ## Python 2, 69 bytes ``` lambda s:cmp(sum(ord(c)%16*(i-s.find('^'))for i,c in enumerate(s)),0) ``` The modulus `ord(c)%16` extracts the value of a digit character while getting 0 for space. For each character, its torque contribution is computed as its weight times the signed distance to the pivot `i-s.find('^')`, and these are summed and compared to 0, producing one of `-1,0,1`. The character `^` is computed to have weight 14, but that doesn't matter because it's on the pivot. An [18-byte Pyth port](http://pyth.herokuapp.com/?code=._s.e%2A-kxz%5C%5E%25Cb16z&test_suite=1&test_suite_input=8%20%202%5E%20941%0A11%20%20%20%5E9%0A321%5E%20%2012%0A9%5E%20%20%20%20%20%20%20%20%201&debug=0) by Maltysen: ``` ._s.e*-kxz\^%Cb16z ``` For the Python code, if a full program is required, here's 79 bytes. The idea is to start the index `i` shifted by `s.find('^')`, and have it count down. ``` s=raw_input() t=0;i=s.find('^') for c in s:t-=ord(c)%16*i;i-=1 print cmp(t,0) ``` [Answer] # [Japt](https://github.com/ETHproductions/Japt), 22 bytes **Japt** is a shortened version of **Ja**vaScri**pt**. [Interpreter](https://codegolf.stackexchange.com/a/62685/42545) ``` U¬r@X+~~Y*(Z-Ub'^),0 g ``` Returns `-1` for `L`, `0` for `B`, and `1` for `R`. ### How it works ``` Uq r@X+~~Y*(Z-Ub'^),0 g // Implicit: U = input string Uq r@ ,0 // Reduce the input by this function, starting at 0: X+~~Y* // Return the previous value, plus the current value times (Z-Ub'^) // the current index minus the index of "^" in U. g // Take the sign of the resulting number. // Implicit: output last expression ``` [Answer] ## APL, ~~39~~ 30 bytes ``` {×+/(10|⍵⍳⍨∊⍕¨⍳9)×(⍳⍴⍵)-⍵⍳'^'} ``` After rereading the rules, I've changed this to output `-1` `0` `1` instead of `L` `B` `R`, saving nine bytes. Try it [here](http://tryapl.org/?a=%7B%27LBR%27%u2283%u23682+%D7+/%2810%7C%u2375%u2373%u2368%u220A%u2355%A8%u23739%29%D7%28%u2373%u2374%u2375%29-%u2375%u2373%27%5E%27%7D%A8%28%27321%5E%2012%27%29%20%28%2711%20%20%20%5E9%27%29%20%28%279%5E%20%20%20%20%20%20%20%20%201%27%29%20%28%27%27%29&run). [Answer] # Pyth, 20 bytes ``` ._s*V-Rxz\^Uzm.xsd0z ``` [Test suite](https://pyth.herokuapp.com/?code=._s%2aV-Rxz%5C%5EUzm.xsd0z&test_suite=1&test_suite_input=8++2%5E+941%0A11+++%5E9%0A321%5E++12%0A9%5E+++++++++1&debug=0) `-1` for left-biased, `0` for balanced, `1` for right-biased. How it works: ``` ._s*V-Rxz\^Uzm.xsd0z z = input() Weights: m z Map over z .x try: sd cast charater to int 0 except: 0 Lever arm: Uz range(len(input())) -Rxz\^ Subtract index of caret from each value. *V Vectorized multiplication. s Sum. ._ Take sign and print. ``` [Answer] ## Haskell, ~~116~~ ~~96~~ ~~82~~ 76 bytes ``` f x=signum$sum$zipWith(*)[-length(fst$span(<'^')x)..]$(`mod`16).fromEnum<$>x ``` Output is `0` for balanced, `-1` for left-heavy and `1` for right-heavy. Usage example: `f "321^ 12"` -> `-1` How it works: find the part before the `^`. Multiply the input string and the list of weights which starts at `- length-of-first-part`. The `^` has a weight of 0 and doesn't add to the sum. I'm using @xnor's [mod 16 trick](https://codegolf.stackexchange.com/a/64702/34531) to convert digits/spaces to integer values. If the sum is negative (positive), the lever is left-heavy (right-heavy) and balanced if the sum is 0. [Answer] # [TeaScript](https://github.com/vihanb/TeaScript), 23 [bytes](https://en.m.wikipedia.org/wiki/ISO/IEC_8859) ~~25~~ I tried writing a Pyth answer but that went horribly :\ ``` $²xd»l+~~i*(a-xi`^`),0© ``` That `²` looks so out of place but it saves 1 byte, so I'll be keeping it. [Try it online!](http://vihanserver.tk/p/TeaScript/#?code=%22$%C2%B2xd%C2%BBl%2B~~i*(a-xi%60%5E%60),0%C2%A9%22&inputs=%5B%2211%20%20%20%5E9%22%5D&opts=%7B%22int%22:false,%22ar%22:false,%22debug%22:false,%22chars%22:false,%22html%22:false%7D) [Test all cases](http://vihanserver.tk/p/TeaScript/#?code=%22_m(%23(x%3Dl,%20$C(xd(%23l%2B~~i*(a-xi%60%5E%60),0))%20))%22&inputs=%5B%228%20%202%5E%20941%22,%2211%20%20%20%5E9%22,%22321%5E%20%2012%22,%229%5E%20%20%20%20%20%20%20%20%201%22%5D&opts=%7B%22int%22:false,%22ar%22:false,%22debug%22:false,%22chars%22:false,%22html%22:false%7D) For the output scheme I've chosen: * `-1` if Left is heavier than Right (`L`) * `0` if Left is as heavy as Right (`B`) * `1` is Left is less heavy than Right (`R`) ### Ungolfed && Explanation This uses maps and reduces to get the job done. ``` $C(xd(#l+~~i*(a-xi`^`),0)) // Implicit: x = input $C( // Compare... xd(# // Reduce... l+ // Pending weight... ~~i // Current weight -> int times... (a- // Total length minus... xi`^` // Fulcrum location ,0) ) // Implicit: Output result ``` [Answer] # [pb](https://esolangs.org/wiki/pb), ~~349~~ 329 bytes ``` ^w[B!94]{>}w[B!0]{vb[T]^t[T+1]>}vb[46]<w[B!0]{<}b[1]vvb[46]^^t[X]w[X!0]{<b[T-X]}^w[B!0]{w[B=32]{b[48]}>}w[X!0]{<t[B-48]vb[B*T]^}w[B!0]{vt[B]vb[1]>^w[B!46]{>}vvb[B+T]^w[B=0]{<}b[0]^b[0]^>}vb[0]vvt[B]<w[B!0]{<}t[B+T]^>[T]w[X!0]{b[10]<}<[T]w[X!0]{b[16]>}vw[B=0]{>}t[B]b[0]w[B=0]{>}t[T-B]b[0]^<[X-T]t[B]<[X]>w[B!0]{b[0]>}<[X]^b[T+66] ``` This was a tricky one. pb was not designed to be good at this kind of thing. ~~It doesn't even have *multiplication*.~~ But hey, it works. > > **Ed. note:** Did I just say pb has no multiplication? What? pb definitely definitely has multiplication. I *designed and implemented* this language, I should know that it has multiplication built in and I don't have to do some silly looped addition. Fixing that (as well as doing some creative rearranging now that I could approach that part of the problem from [almost literally] a different angle) saves me 20 bytes. Embarrassing. > > > The hardest part was, after getting the sums of (weight\*distance) for each side, actually determining which letter to print. pb doesn't have `>` or `<` operators, just `==` and `!=`. There's no easy way to tell which value is larger. I can't even subtract and compare with 0... unless I do something really silly. * Find the sum of the two sums. * Go that far to the right, on a line that's not being used for anything. * Until reaching X=0, go left and place 'L's. * Place a 'B' at X=0. * Go left by the sum of the two sums. * Until reaching X=0, go right and place 'R's. Then, you simply go to X=(left side - right side), and there's your answer! Delete everything on that line to clean up, and then print the value that was found at (0, 0). ...But there's a slightly shorter way. Instead of using 'L', 'B' and 'R', use those values - 'B' and add 'B' back on when printing. That way, you don't ever have to place 'B' at X=0, you just leave it as the 0 it already was. The only problem is that once you do this, the program becomes very goofy in watch mode. `'L'-'B'==76-66==10=='\n'`. Everything seems to be working fine, until suddenly a huge number of newlines are printed and it's impossible to keep track of what's going on :D In pbi's regular execution mode, though, everything works fine because the newlines are deleted before anything is printed to the console. ``` ^w[B!94]{>} # Find the fulcrum w[B!0]{ # Starting at the fulcrum and going right: vb[T]^ # Store the T below each character of input t[T+1] # Increment T > } vb[46] # Put a '.' at the end of the values below the input <w[B!0]{<} # Go to the space below the fulcrum b[1] # Put a 1 (So the fulcrum will be represented as '.' later) vvb[46]^^ # Put a 46 two spaces below it t[X] # Store the current X value in T w[X!0]{< # Until reaching the beginning of the input: b[T-X] # Put T - (the current X value) below each byte } ^w[B!0]{ # For each byte of input: w[B=32]{b[48]} # Set spaces to '0' > } w[X!0]{< # For each byte of input: t[B-48] # Set T to the value of the number (fulcrum becomes '.') vb[B*T]^ # Multiply the value below by T } # This has nothing to do with the input, except that it's the right length: w[B!0]{ # For every byte of input: v # Go to the value below it t[B] # Store it in T vb[1]>^ # Put a flag below it w[B!46]{>} # Go to the next '.' value vvb[B+T] # Add T to whatever is two spaces below the '.' # This will cause the sum for the right side of # the fulcrum to be 46 too high. This is why 46 # was left below the fulcrum earlier: both sums # will be off by the same amount. ^w[B=0]{<} # Go back to the flag b[0]^b[0] # Erase the flag and the value above it ^> } vb[0] # Erase the stray '.' vvt[B]<w[B!0]{<}t[B+T] # Get the sum of the two sums ^>[T] # Go right that far w[X!0]{b[10]<} # Head back to X=0, leaving 'L'-'B' the whole way <[T] # Go left the same amount as before w[X!0]{b[16]>} # Head back to X=0, leaving 'R'-'B' the whole way vw[B=0]{>} # Find the sum from left of the fulcrum t[B]b[0] # Save it to T and erase it from the canvas w[B=0]{>} # Find the other sum t[T-B]b[0] # Subtract it from T and erase it from the canvas ^<[X-T] # On the line that was just prepared, go to X=T t[B] # Save the value of that space to T <[X]>w[B!0]{b[0]>} # Erase the entire visible part of that line <[X]^b[T+66] # Print (the value read from that line)+'B' at (0, 0) ``` [Answer] # 𝔼𝕊𝕄𝕚𝕟, 22 chars / 38 bytes ``` МŴ⟬ïĊ⇀$+˜_*(ã-ïÿ⍘^),0⸩ ``` `[Try it here (Firefox only).](http://molarmanful.github.io/ESMin/interpreter.html?eval=false&input=9%5E%20%20%20%20%20%20%20%20%201&code=%D0%9C%C5%B4%E2%9F%AC%C3%AF%C4%8A%E2%87%80%24%2B%CB%9C_*%28%C3%A3-%C3%AF%C3%BF%E2%8D%98%5E%29%2C0%E2%B8%A9)` [Answer] ## Perl 5, 72 bytes ``` @_=split//,<>;($i)=grep$_[$_]eq'^',0..@_;$j+=$_*($k++-$i)for@_;say$j<=>0 ``` [Answer] # ~~MATLAB 91, 57, 55~~ Octave, 50 bytes I did not expect to golf this further, but switching to Octave made it possible to save 5 additional bytes! Wow, this one took time... ``` @(x)(s=mod(+x,16))*[1-(i=find(s>9)):nnz(x)-i]'*inf ``` It outputs `-Inf, NaN, Inf` for `L, B, R` respectively. [**Test suite!**](https://tio.run/#TNgyo) **Explanation:** This is definitely a hard-to-read code, but I'll try to explain as well as I can. I will switch between code block explanation and text. ``` @(x) % Anonymous function that takes a string x as input +x % Convert the string into a numeric array, % where each character is represented by its ASCII-value mod(+x,16) % Takes this string modulus 16, to make spaces (ASCII 32) equal 0 (s=mod(+x,16)) % Assigns this numeric array to s, thanks to Octave's awesome % inline variable assignment possibility (s=mod(+x,16))* % Multiply s by the vector inside the brackets ``` Let's look at what's going on inside the brackets: ``` [1-(i=find(s>9)):nnz(x)-i] find(s>9) % The only value in the vector s that's larger than 9, % after the modulus is ^, (it's now 14) (i=find(s>9)) % Assign the position of `^` to the index variable i ``` This one is a bit tricky: ``` [1-(i=find(s>9)):nnz(x)-i] ``` The numbers on each side of the ladder must be multiplied by the distance from the caret. If we use negative numbers on the left side, and positive numbers on the right side we can simply sum the vector to see which side is heaviest. Suppose the input string is: `'321^ 12'`. We want the following: `3*(-3)+2*(-2)+1*(-1)+1*3+2*4`. The vector we made inside the brackets starts at `1-i`, which in this case is `-3`, since the caret is in the 4th position. It goes up to `nnz(x)-i` in increments of one. We can use `nnz(x)` instead of `numel(s)`, because `x` is a string containing no zeros. Therefore: ``` [1-(i=find(s>9)):nnz(x)-i] ans = -3 -2 -1 0 1 2 3 4 ``` Now, we could do element-wise multiplication `s.*[...]`, and take the sum of this. But, since we have two vectors, we can also mutliply `s` by the transposed of `[...]` and calculate the sum using matrix multiplication: ``` (s=mod(+x,16))*[1-(i=find(s>9)):nnz(x)-i]' ``` This gives us either a negative number, meaning the left side is heavier, a zero, meaning it's balanced, or a postive numbers, meaning the right side is heavier. Instead of using the naive approach of `sign(...)`, we multiply it by `inf`, which will give us either `-Inf` or `Inf` for left and right respectively. We get `NaN` for `0*inf`, since it's undefined. This gives us three distinct values for the three possible outcomes. [Answer] # JavaScript, 146 bytes ``` s=>{a=[0,0];d=s.split`^`;for(j=0;j<2;j++)for(i=0;i<d[j].length;i++)a[j]+=d[j][i]*(j==0?d[j].length-i:i+1);alert(a[0]==a[1]?'B':a[0]>a[1]?'L':'R')} ``` Pretty massive. [Demo](http://jsfiddle.net/x2g218db/5). [Answer] # Ruby, ~~111~~ 108 bytes ``` ->s{l,r=s.split'^';v=->x{x.chars.map.with_index{|c,i|c.to_i*(i+1)}.reduce:+};%w(B L R)[v[l.reverse]<=>v[r]]} ``` ## Explanation Sums up weighted value of each number on each side. Then it uses the ruby spaceship operator to provide a 1,0,-1 of equality/inequality of the two sides, which is the index of an array with the correct output. [Answer] ## PowerShell, ~~83~~ 73 Bytes ``` param($b)$i=-$b.indexOf('^');[char[]]$b|%{$x+=$i++*"$_"};[math]::Sign($x) ``` Thanks to [TessellatingHeckler](https://codegolf.stackexchange.com/users/571/tessellatingheckler) for the golf. Uses essentially the same algorithm as the below older code, but here we iterate through the characters in the input string one at a time rather than iterating through the index, which saves a handful of bytes. Still throws the same spectacular error message when the algorithm reaches `^` - doesn't affect STDOUT. --- ### Previous ``` param($a)1..$a.length|%{$x+=+"$($a[$_-1])"*($_-$a.indexof('^')-1)};[math]::Sign($x) ``` Uses the same awesome algorithm as Dendrobium's excellent [answer](https://codegolf.stackexchange.com/a/64692/42963), and thus uses the same output of `-1 / 0 / 1` if the input is `left-heavy / balanced / right-heavy`. Ugh. Long because of a casting ~~quirk~~ feature that PowerShell has. Most pertinent here is how `char` multiplied by `int` functions. Taking an array-index of a `string` results in a `char` object. PowerShell converts the `char` to its corresponding ASCII value (rather than literal value) before multiplication. So, something like `$a='012'[0];[int]$a*2` results in `96`. That means we need to re-cast it back as a string. However, simply doing `string` times `int` gives us a `string` repeated that many times. For example, `$a='0';$a*2` would result in `00`. This means we need to cast the `char` back as a `string` before *re*-casting as `int`, then multiplication can happen, before we add it into our accumulator `$x`. Couple that with the lengthy way to iterate through a string, and the .NET call to output the sign, and we get a pretty long piece of code. NB - This will throw a spectacular error when it reaches `^` in the string, stating that it can't convert it to an `int`. Doesn't affect STDOUT. [Answer] # CJam, 29 bytes ``` l_'^#\"^ "'0er'0f-_,,@fm.*:+g ``` [Try it online](http://cjam.aditsu.net/#code=l_'%5E%23%5C%22%5E%20%22'0er'0f-_%2C%2C%40fm.*%3A%2Bg&input=9%5E%20%20%20%20%20%20%20%20%201) Result is `-1` for left-heavy, `0` for balanced, `1` for right-heavy. This seemed a bit lengthy, but I tried a bunch of alternatives, and they all ended up between 29 and 33 bytes. One problem is that I couldn't find a way of converting the string to values that would automatically result in 0 for the spaces. So I ended up explicitly replacing the spaces with '0 characters, which obviously adds to the length of the code. Alternatives tried: * Splitting string at '^, reversing the 1st one, and then calculating the weighted value for both. * Using the `ee` operator to add the index to the list of values. * Instead of subtracting the caret position from each index, calculate the dot product without the subtraction, and then subtract caret position times string length from the result. Explanation: ``` l Get input. _'^# Copy and find caret position. \ Swap input back to top. "^ "'0er Replace caret and spaces with '0. '0f- Subtract '0 from all characters, to get integer values. _,, Build index array with same length. @ Rotate caret position to top. fm Subtract it from all indices. .* Calculate element wise product of two vectors. :+ Add up the element products to get dot product. g Signum. ``` [Answer] ## Python 3, ~~196~~ 114 bytes ``` r=0 I=list(input()) p=I.index("^") i=0 for E in I: if E.isdigit():r+=int(E)*(p-i) i+=1 print('BLR'[(r>0)-(r<0)]) ``` Regular code: ``` total = 0 inp=list(input()) ful_index=inp.index("^") i=0 for num in inp: if num.isdigit(): total += int(num) * (ful_index - i) i+=1 print('BLR'[(total>0)-(total<0)]) ``` Explanation: 1. Generates a list of numbers + the fulcrum from `stdin`. 2. For every number, adds the distance from the fulcrum times the number to the variable to the total (numbers on the left will be negative and numbers on the right will be positive). 3. Prints the correct letter depending on the result (B if equal, L if more than zero, and R if less than zero). Huge thanks to @ThomasKwa for trimming 82 bytes (more than 40%) off! [Answer] # C, 140 139 138 134 100 bytes Return: * 1 = LEFT * 2 = BALANCED * 0 = RIGHT ``` k;main(int x,char**a){char*n=a[1],*g=n;for(;*n^94;++n);for(;*g;++g)k+=(*g&15)*(n-g);return!k?2:k>0;} ``` Run: ``` ./see-saw "11 ^9" echo $? 2 ``` As we have ASCII: ``` SPACE = 0x20 0 = 0x30 ... 9 = 0x39 ``` We get: ``` 0x20 & 0x0f = 0 0x30 & 0x0f = 0 0x31 & 0x0f = 1 0x32 & 0x0f = 2 ... etc. ``` Then sum by factor distance to `^`. [Answer] # SpecBAS - 140 bytes ``` 1 INPUT b$: LET t=0,p=POS("^",b$),l$="RBL" 2 FOR i=1 TO LEN b$ 3 IF b$(i) IN ["1" TO "9"] THEN INC t,(p-i)*VAL b$(i) 4 NEXT i 5 TEXT l$(2+SGN t) ``` `t` is a running total, the values are negative when character position is more than the carat position. At the end it sees if total is negative, zero or positive and prints the corresponding character of R, B or L. I could shave a few bytes off by just outputting -1, 0 or 1 like some of the other answers. [Answer] # Java, 83 bytes ``` l->{int s=0,l=0;for(char c:l)if(l<1)s-=c-48;else s+=c-48;return s<0?-1:(s>0?1:0));} ``` ]
[Question] [ The French [spell out numbers](https://codegolf.stackexchange.com/q/35435/31516) in a peculiar way. * **1-16** are "normal" * **17-19** are spelled out **10+7. 10+8, 10+9**. * **20-69** are "normal" (OK, OK! Not really, but they are in this challenge) * **70-79** are **60+10, 60+11 ... 60+10+7, 60+10+8, 60+10+9**. * **80-99** are **4\*20, 4\*20+1, 4\*20+2 ... 4\*20+16, 4\*20+10+7, 4\*20+10+8, 4\*20+10+9** **Challenge:** Take a positive integer in the range **[1,100]**, and output it the "French way". You must output it exactly as it's shown below, with `*` and `+`, so `97` is `4*20+10+7`, not `[4 20 10 7]` or something else. Test cases: ``` 1 - 1 .. - .. 16 - 16 17 - 10+7 18 - 10+8 19 - 10+9 20 - 20 21 - 21 .. - .. 69 - 69 70 - 60+10 71 - 60+11 72 - 60+12 77 - 60+10+7 78 - 60+10+8 79 - 60+10+9 80 - 4*20 81 - 4*20+1 82 - 4*20+2 .. - .. 90 - 4*20+10 91 - 4*20+11 96 - 4*20+16 97 - 4*20+10+7 98 - 4*20+10+8 99 - 4*20+10+9 100 - 100 ``` [Answer] ## Excel, ~~153~~ 149 Bytes ``` =IF(OR(A1<17,A1>99,AND(A1>19,A1<70)),A1,IF(A1<20,"10+"&A1-10,IF(A1<80,"60","4*20")&IF(A1=80,,IF(MOD(A1,20)>16,"+10+"&MOD(A1,20)-10,"+"&MOD(A1,20))))) ``` I'm sure this could be better, I struggled to find an efficient way to account for #80. edit: Consolidated the 'Normal' cases better to save 4 bytes. #80 still sucks. Can't find a specific answer on here, not sure the rules of code-golf tbh. Can I use multiple cells in Excel, and add the byte count of each? ie. For an input in cell A1 A2: 11 Bytes ``` =MOD(A1,20) ``` A3 (result): 125 Bytes ``` =IF(OR(A1<17,A1>99,AND(A1>19,A1<70)),A1,IF(A1<20,"10+"&A1-10,IF(A1<80,"60","4*20")&IF(A1=80,,IF(A2>16,"+10+"&A2-10,"+"&A2)))) ``` For a total of 136? [Answer] # [Retina](https://github.com/m-ender/retina), ~~52~~ 48 bytes *4 bytes saved thanks to Neil* ``` ^7\B 60+1 ^9\B 81 ^8\B 4*20+ 1(?=7|8|9) 10+ \+0 ``` [Try it online!](https://tio.run/nexus/retina#@x9nHuPEZWagbcgVZwlkWQBpCyBtomVkoM1lqGFva15jUWOpyWUI5MZoG3D9/29qAAA "Retina – TIO Nexus") or [verify all inputs](https://tio.run/nexus/retina#4zI0MFDRUgSSXIpcKnoJh7ZxOSbEGXCpargn/I8zj3HiMjPQNuSKswSyLIC0BZA20TIy0OYy1LC3Na@xqLHU5DIEcmO0Dbj@/wcA) (provided by Neil) **Explanation** ``` ^7\B 60+1 ^9\B 81 ^8\B 4*20+ ``` First we handle the translation of 70, 80, and 90. In these first 3 stages, a 7 at the start with another character following it is replaced by `60+1`. Similarly, `9` is replaced by `81`, and `8` by `4*20+1`. The replacement of `9` is essentially changing it to "eighty-ten" and such, so that the `8` is then handled by the next replacement, which saves bytes over writing `4*20+1` twice. ``` 1(?=7|8|9) 10+ ``` This handles the cases of `17`, `18`, and `19`, by replacing the `1` in each with `10+`. ``` \+0 ``` Finally, there should never be a `+0` at the end, so delete it if it's there. [Answer] # [Python 2](https://docs.python.org/2/), 98 bytes ``` f=lambda x:[`x`*(x%100<70),'10+'+`x-10`][16<x<20]or['60+'+f(x-60),'4*20'+x/81*('+'+f(x-80))][x/80] ``` [Try it online!](https://tio.run/nexus/python2#LcpNCsIwEEDhtZ5iNpK/FmeKxFLiSUIgEY0UairBxdw@tuD2fa/l25Le90cCnnzkqCWfCNFdUXWC0AgTuSeMwZN17AYMa/XC7pAl93bfLnpAYfg8kpbiDyMqFfzWMLS8VmCYC9RUXk9JHSGp6Xj41Ll8YbtV@wE "Python 2 – TIO Nexus") [Answer] ## JavaScript (ES6), ~~73~~ 71 bytes ``` f=n=>n>16&n<20?'10+'+n%10:n<70|n>99?n:n%20?f(n-n%20)+'+'+f(n%20):'4*20' ``` Bonus version that prints the numbers as they are actually spelled for an extra 2 bytes: ``` f=n=>n<17|n>99?n:n<20?'10+'+n%10:n%20?f(n-n%20)+'+'+f(n%20):n-80?n:'4*20' ``` [Answer] # R, 110 bytes ``` i=scan() r=i%%10;paste0(ifelse(i>16&i<20,"10+",ifelse(i>69&i<80,"60+10+",ifelse(i>16&i<20,"4*20+",i-r/10))),r) ``` [Answer] # PHP, 99 bytes (I wanna be happy version) a straight port of [ETHproductions´ JS](https://codegolf.stackexchange.com/a/117757/55735), 4 bytes golfed. Prints the numbers as asked for by the OP. ``` function f($n){return$n<17|$n>19?$n>60&$n<100?($m=$n%20)?f($n-$m)."+".f($m):'4*20':$n:"10+".$n%10;} ``` **breakdown** ``` function f($n){return $n<17|$n>19 ?$n>69&$n<100 ?($m=$n%20) ?f($n-$m)."+".f($m) # 70..79, 81..99 :'4*20' # 80 :$n # 1..16, 20..69 :"10+".$n%10 # 17..19 ; } ``` ## I wanna be right version, ~~114~~ 98 bytes new approach inspired by [ETHproductions](https://codegolf.stackexchange.com/a/117757/55735), prints the numbers as they are actually spelled out. ``` function f($n){return$n>16&$n<100?$n-80?($m=$n%($n>60?20:10))?f($n-$m)."+".f($m):$n-$m:'4*20':$n;} ``` [try it online](http://sandbox.onlinephpfunctions.com/code/e4e481bc0233ab113ed757eac563da136ca1a9d5). **breakdown** ``` function f($n){return $n>16&$n<100 ?$n-80 ?($m=$n%($n>60?20:10)) ?f($n-$m)."+".f($m) # $n%$m>0 :$n-$m # 10,20,30,40,50,60 :'4*20' # 80 :$n # 1..16, 100 ;} ``` [Answer] # Python 2, ~~130~~ 108 bytes *22 bytes saved thanks to @mathjunkie* ``` f=lambda x:79<x<100and('4*20'+('+'+f(x-80))*(x>80))or 69<x<100and'60+'+f(x-60)or 16<x<20and'10+'+`x-10`or`x` ``` [Try it online!](https://tio.run/nexus/python2#RcpBCsIwEEDRvaeY3UwaCjNFopa2Z0mkRgKaSnAxt4@NCK7@4v0a50d4XtcAOp4uk07CHPJKeOwGRkto0UbS/szGdKRL61bA/Vd0/HscNxK30/AVaeK1F/Zb8epr3D1BylBCvt9IWMx4gFdJ@Q2Rkqkf) [Answer] ## Batch, ~~220~~ 217 bytes ``` @set/pn= @set s= @if %n% gtr 99 goto g @if %n% gtr 79 set s=+4*20&set/an-=80 @if %n% gtr 69 set s=+60&set/an-=60 @if %n% gtr 16 if %n% lss 20 set s=%s%+10&set/an-=10 :g @if %n% gtr 0 set s=%s%+%n% @echo %s:~1% ``` Takes input on STDIN. Generating and removing the leading `+` saves 1 byte over special-casing 80. Edit: Saved 3 bytes thanks to @ConorO'Brien. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 55 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` ⁹ ’,ṃ60Ṁ€ ⁹%80“4*20”, Dj⁾0+µ¹e?“×ØŒ‘ %ȷ2:“FP‘S‘ŀḟ0Ç€j”+ ``` **[Try it online!](https://tio.run/nexus/jelly#@/@ocSfXo4aZOg93NpsZPNzZ8KhpDRdQTNXC4FHDHBMtIyA1V4fLJetR4z4D7UNbD@1MtQdKHJ5@eMbRSY8aZnCpnthuZAUUcQsA8oKB@GjDwx3zDQ63Aw3KAurV/v//v6UlAA)** or see a [test suite](https://tio.run/nexus/jelly#@/@ocSfXo4aZOg93NpsZPNzZ8KhpDRdQTNXC4FHDHBMtIyA1V4fLJetR4z4D7UNbD@1MtQdKHJ5@eMbRSY8aZnCpnthuZAUUcQsA8oKB@GjDwx3zDQ63Aw3KAurV/m9oYBAE5kb@BwA) *No doubt there is a shorter way!* ### How? ``` + - Link 1, helper for 1-69&100: number s=0, number n ⁹ - link's right argument, n ’,ṃ60Ṁ€ - Link 2, helper for 70-79: number s=1, number n ’ - decrement s -> 0 , - pair -> [0,n] ṃ60 - base decompress (vectorises) using [1,2,...60] effectively -> [60,[1,n%60]] Ṁ€ - maximum for €ach effectively -> [60,n%60] ⁹%80“4*20”, - Link 3, helper for 80-99: number s=2, number n ⁹ - link's right argument, n %80 - mod 80 “4*20” - literal ['4','*','2','0'] , - pair -> [['4','*','2','0'],n] Dj⁾0+µ¹e?“×ØŒ‘ - Link 4, reformat 17-19: element v (may be char list or number) ? - if e - v exists in “×ØŒ‘ - literal [17,18,19] - then: D - convert to decimal list e.g. [1,7] ⁾0+ - literal ['0','+'] j - join [1,'0','+',7] µ - else: ¹ - identity, v %ȷ2:“FP‘S‘ŀḟ0Ç€j”+ - Main link: number n in [1,100] ȷ2 - literal 100 % - mod (convert 100 to 0) “FP‘ - literal [70,80] : - integer division (vectorises) S - sum (0 for 1-69&100; 1 for 70-79; 2 for 80-99) ‘ - increment (...1, 2 or 3) ŀ - call link at index (1, 2 or 3) as a dyad(sum, n) ḟ0 - filter out zeros (remove 0 from 4*20+0) Ç€ - call the last link (4) as a monad for each ”+ - literal '+' j - join ``` [Answer] # Pyth, ~~61~~ 56 bytes ``` L?}b}17 19++T\+eb|bk?}/QTr6T.s+?<Q80"60+""4*20+"y%Q20\+y ``` [Test it online!](http://pyth.herokuapp.com/?code=L%3F%7Db%7D17+19%2B%2BT%5C%2Beb%7Cbk%3F%7D%2FQTr6T.s%2B%3F%3CQ80%2260%2B%22%224%2a20%2B%22y%25Q20%5C%2By&test_suite=1&test_suite_input=1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A9%0A10%0A11%0A12%0A13%0A14%0A15%0A16%0A17%0A18%0A19%0A20%0A21%0A22%0A23%0A24%0A25%0A26%0A27%0A28%0A29%0A30%0A31%0A32%0A33%0A34%0A35%0A36%0A37%0A38%0A39%0A40%0A41%0A42%0A43%0A44%0A45%0A46%0A47%0A48%0A49%0A50%0A51%0A52%0A53%0A54%0A55%0A56%0A57%0A58%0A59%0A60%0A61%0A62%0A63%0A64%0A65%0A66%0A67%0A68%0A69%0A70%0A71%0A72%0A73%0A74%0A75%0A76%0A77%0A78%0A79%0A80%0A81%0A82%0A83%0A84%0A85%0A86%0A87%0A88%0A89%0A90%0A91%0A92%0A93%0A94%0A95%0A96%0A97%0A98%0A99%0A100&debug=0) Thanks to Leaky Nun for a 5 byte improvement! Explanation: ``` | Implicit: Q=eval(input()) L | Define y(b): ?}b}17 19 | If b is in the inclusive range from 17 to 19: ++T\+eb | Return "10+" + (last digit of b) |b | Else: if b!=0: return b k | Else: return an empty string (Leaves a trailing '+' for case 80) _____________________|________________ ?}/QTr6T | If 70<=Q<100: + | Concatenate the next two expressions: ?<Q80 | If Q<80: "60+" | Evaluate to "60+" "4*20+" | Else: Evaluate to "4*20+" y%Q20 | y(Q%20) .s \+ | Strip off trailing '+', if present (for case 80) y | Else: return y(Q) (Q)| Trailing Q is implicitly added ``` [Answer] ## Python3, 127 bytes ``` m,r=map,range;l=[*r(1,17),*m("10+{}".format,(7,8,9))];f=[0,*l,*r(20,61),*m("60+{}".format,l),"4*20",*m("4*20+{}".format,l),100] ``` Each array element contains its representation: ``` for i in range(1,101): print(i, f[i]) ``` The code does not actually create a function, just an array -- I don't know if that's allowed. Otherwise, I'd have to make this 139 bytes by adding `f=[...].__getitem__`. [Answer] # Java 7, ~~97~~ ~~96~~ 109 bytes ``` String c(int i){return i>16&i<20?"10+"+(i-10):i%100<70?i+"":i<80?"60+"+c(i-60):"4*20"+(i<81?"":"+"+c(i-80));} ``` +13 bytes for bug-fixing case `80`.. :( **Explanation:** ``` String c(int i){ // Method with integer parameter and String return-type return i>16&i<20? // If 17..19: "10+"+(i-10) // Return "10+" + `i`-10 :i%100<70? // Else if 1..16; 20..69; 100: i+"" // Return `i` :i<80? // Else if 70..79: "60+"+c(i-60) // Return "60+" + recursive-call with `i`-60 : // Else (80..99): "4*20"+ // Return "4*20" + (i<81? // If 80: "" // nothing : // Else (81..99) "+"+c(i-80)); // recursive-call with `i`-80 } // End of method ``` **Test code:** [Try it here.](https://tio.run/nexus/java-openjdk#LY7NCsJADITvPsWwoHRdlKxILbraJ/DkUTzU@kOgbqXdCiJ99ppaD2ECM8k3eZHVNfafEVCHLHCO7hAq9nfkEfsA1p/qGprKg3c2nrBbUKosGWUinlnSax5bIreilI1Sa3aJ@HHvy/0sloBaThfUx11iU4mov5eQ1pu2A57NuRDuH/8q@YJHxj4aehxPyHRfD7iVFYZS2MJuRJwokWzGaAwh4PCuw/UxL5swf8qHUPhIeAL7@e2on7b7Ag) ``` class M{ static String c(int i){return i>16&i<20?"10+"+(i-10):i%100<70?i+"":i<80?"60+"+c(i-60):"4*20"+(i<81?"":"+"+c(i-80));} public static void main(String[] a){ for (int i = 1; i <= 100; i++) { System.out.println(c(i)); } } } ``` ]
[Question] [ [Hex triplets](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) such as [`#ffffff`](http://www.color-hex.com/color/ffffff) (white) or [`#3764ef`](http://www.color-hex.com/color/3764ef) (blueish) are often used to denote RGB colors. They consist of `#` followed by six hexadecimal digits (0-f), or sometimes [three digits](https://en.wikipedia.org/wiki/Web_colors#Shorthand_hexadecimal_form) where the real color is obtained by doubling each digit. For example, `#fff` is `#ffffff` and `#1a8` is `#11aa88`. Sadly, that three digit shorthand was the golfiest the internet had to offer, *until now*. Write a program or function that takes in a string of 1 to 7 characters: * The first character will always be `#`. * The other characters will always be hexadecimal digits: `0123456789abcdef`. The input is a shorthand form of a hex triplet (or the full form if 7 characters are given). You need to output a full hex triplet that expands the input shorthand based on these patterns: ``` Input -> Output # -> #000000 (black) #U -> #UUUUUU #UV -> #UVUVUV #UVW -> #UUVVWW (usual 3-digit shorthand) #UVWX -> #UXVXWX #UVWXY -> #UVWXYY #UVWXYZ -> #UVWXYZ (not shorthand) ``` Each of `U`, `V`, `W`, `X`, `Y`, and `Z` may be any hexadecimal digit. The output is always 7 characters. For example: ``` Input -> Output # -> #000000 #0 -> #000000 #4 -> #444444 #f -> #ffffff #a1 -> #a1a1a1 #0f -> #0f0f0f #99 -> #999999 #1a8 -> #11aa88 #223 -> #222233 #fff -> #ffffff #1230 -> #102030 #d767 -> #d77767 #bbb5 -> #b5b5b5 #aabbc -> #aabbcc #00000 -> #000000 #3764e -> #3764ee #3764ef -> #3764ef #123456 -> #123456 #f8f8f8 -> #f8f8f8 ``` # Notes * The input will always start with `#` and so must the output. * You may assume all input letters are lowercase (`abcdef`) or uppercase (`ABCDEF`) as you prefer. * Letters in the output may be in either case as you prefer. You can even mix cases. * Alpha/transparency is not dealt with here (though there are hex versions of RGBA colors). **The shortest code in bytes wins.** [Answer] # JavaScript, ~~86~~ ~~82~~ 77 bytes ``` x=>([s,a=0,b=a,c,d,e,f]=x,f?x:e?x+e:[s,a,d||a,c?b:a,d||b,v=c||b,d||v].join``) ``` just find out that remove recursive save 4 bytes... idea from @Arnauld save 4 bytes, +1 more bytes [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 24 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page) ``` x2 j0ị$ m0 0 Ḣ;LĿṁ6$$ ``` A full program (the empty lines are actually empty lines). **[Try it online!](https://tio.run/nexus/jelly#@8/FVWHElWXwcHe3CleuAReXAdfDHYusfY7sf7iz0UxF5f///0rKBmlKAA "Jelly – TIO Nexus")** or see a [test suite](https://tio.run/nexus/jelly#@8/FVWHElWXwcHe3CleuARfXwx2LrH2O7H@4s9FMRYXL4P/RPeZH9j9qWmPtACQMDy0Dko8a5ipngek5Crp2CkBu5P//0UrKSjpKygYgwgREpIGIREOwIJhtaQkiDRMtQJSRkTFYURpYytDIGKwxxdzMHEQnJSWZgrUnJiUlg00AARDD2NzMJBXOgGk2MTUDm2YBgkqxAA)\* ### How? ``` - Link 1 (0 bytes), returns its input (e.g. "U" -> "U") - Link 2 (0 bytes), returns its input (e.g. "UV" -> "UV") x2 - Link 3, doubles up (e.g. "UVW" -> "UUVVWW") j0ị$ - Link 4, joins with final element (e.g. "UVWX" -> "UXVXWXX") m0 - Link 5, reflects its input (e.g. "UVWXY" -> "UVWXYYXWVU") - Link 6 (0 bytes), returns its input (e.g. "UVWXYZ" -> "UVWXYX") 0 - Link 7, returns zero (link 7 is also link 0 since there are 7 links) Ḣ;LĿṁ6$$ - Main link: string Ḣ - head (get the '#') $ - last two links as a monad: Ŀ - call link at index: L - length $ - last two links as a monad: ṁ6 - mould like 6 (e.g. "UVWXYYXWVU" -> "UVWXYY" - or "UV" -> "UVUVUV") ; - concatenate (prepend the '#' again) - implicit print ``` \* the test-suite program had to be altered by swapping the order of what were the `Main link` and `Link 7`, while the footer became the `Main Link`. Furthermore the `#` had to be manually replaced, since the program as-is heads it. [Answer] ## CJam, ~~45~~ ~~44~~ ~~42~~ ~~40~~ ~~36~~ 35 bytes ``` q(\0se|_,("6* 3* 2e* )f+ _W=+ "S/=~ ``` Runs various code snippets based on the length of the input. [Answer] # PHP 7.1, 88 bytes ``` #<?for(;$i<6;)echo@$argn[_22222232532233423355224462[5*$i+++strlen($argn|aa)*.85]-1]?:0; ``` ### PHP 5, 90 88 bytes ``` #<?for(;$i<6;)echo$argn[_10311001122011333002244012345[6*$i+++strlen($argn|aa)-8]+1]?:0; ``` [Answer] ## PHP, ~~95~~ ~~93~~ ~~89~~ 87 ``` <?=strtr(_1.intval([a6n,sot,c8c,lba,vf1,vf2][strlen($argn|aa)-2],33),_134256,$argn.=0); ``` Basically @JörgHülsermann's [answer](https://codegolf.stackexchange.com/a/123516/29637) but greatly golfed down so I decided to post it as a seperate answer. I'd count this answer as an collective effort of me and Jörg. ``` -4 bytes thanks to @JörgHülsermann -1 bytes thanks to @JörgHülsermann's base 33 numbers ``` [Answer] # Python 3, ~~166~~ ~~162~~ ~~160~~ 152 bytes ``` import re lambda x,d='(.)$',b=r'\1':re.sub(*[('$','0'*6),(d,b*6),('(..)$',b*3),('(\w)',b*2),('.'+'(.)'*4,r'#\1\4\2\4\3\4'),(d,b*2),('','')][len(x)-1],x) ``` I construct a list of regex replacement tuples for each pattern, and then extract the tuple at index `len(x)-1`, finally splatting (`*`) it into the arguments of `re.sub`: ``` lambda x, d='(.)$', b=r'\1': # lambda expression, save often used strings re.sub( # regex replacement of: * # expand what follows into arguments, i.e. f(*(1,2)) -> f(1,2) [ # list of replacement patterns: # 1 character: replace the end with 6 zeroes ('$', '0'*6), # 2 chars: repeat the last character 6 times (d, b*6), # 3 chars: repeat the two non-#s 3 times. ('(..)$', b*3), # 4 chars: replace every non-# with twice itself ('(\w)', b*2), # 5 chars: has to be somewhat verbose.. ('.'+'(.)'*4, r'#\1\4\2\4\3\4'), # 6 chars: repeat the last character (d, b*2), # 7 chars: complete already, replace nothing with nothing ('', '') ][len(x)-1], # select the element from the list that has the right length x) # replace in argument x ``` *saved 8 bytes by memorizing `r'\1'` (thanks, Gábor Fekete)* [Answer] # Java 10, ~~228~~ ~~227~~ ~~224~~ 182 bytes ``` s->{var x="$1$1";int l=s.length();return l>6?s:l>5?s+s.charAt(5):l<2?"#000000":s.replaceAll(l>4?"(.)(.)(.)(.)$":l==3?"([^#]{2})":"([^#])",l>4?"$1$4$2$4$3$4":l>3?x:l>2?x+"$1":x+x+x);} ``` [Try it online.](https://tio.run/##jZJNbsIwEIX3nGJksohFicgvkDSJOEC76RJRyQkGQo1BsUGpUM5OhzTqsrHHtuzxp9G8Jx/ZjU2P269HKZhS8MYqeR8BVFLzesdKDu/PK8CHriu5h9LuD4ommG9x4VSa6aqEd5CQwkNNs/uN1dCkxHItlyRYDESqHMHlXh9smtRcX2sJIotyFYsszNVEOeWB1StthzQWr15OxrNukFg5Nb8IbGUlhC2yICe2Q/@mRWKRpj4m15/jzd1rKYl/z5S8dDT2EFgeLt8KEM78vMHdy5sJPpG4mWDQpH089VyuhUAhvZ7budrCCR3pRa83wGhvx7fS/OScr9q54JMW0pZOaZMxoZ0x/xCzYSQYRnbDCHMNmjGos1wOMy5bDEOe5xsI2xm05Hq@gY3beTQfpoqiCA3MZEVRGvjZ/dlBzJ9HPjfCAm5mRxBGBt4untFz7ah9/AA) **Explanation:** ``` s->{ // Method with String as both parameter and return-type var x="$1$1"; // Create a temp String to repeat a match int l=s.length(); // Length of the String return l>6? // If the length is 7: s // Return the input-String as is :l>5? // Else-if the length is 6: s+s.charAt(5) // Return the input-String with the last character repeated :l<2? // Else-if the length is 1: "#000000"; // Simply return the literal String #000000 : // Else (the length is 2, 3, 4, or 5): s.replaceAll( // Return the input-String after a regex replace: // With as match: l>4? // If the length is 5: "(.)(.)(.)(.)$", // Use a match for pattern #(A)(B)(C)(D) :l==3? // Else-if the length is 3: "([^#]{2})" // Use a match for pattern #(AB) : // Else (the length is 2 or 4): "([^#])", // Use a match for pattern #(A) or #(A)(B)(C) // And as replacement: l>4? // If the length is 5: "$1$4$2$4$3$4" // Change #ABCD to #ADBDCD :l>3? // Else-if the length is 4: x // Change #ABC to #AABBCC :l>2? // Else-if the length is 3: x+"$1" // Change #AB to #ABABAB : // Else (the length is 2): x+x+x);} // Change #A to #AAAAAA ``` [Answer] # [APL (Dyalog)](https://www.dyalog.com/), 43 bytes Requires `⎕IO←0` which is default on many systems. ``` '#',{6⍴(≢⍵)⊃'0'⍵ ⍵(2/⍵)(∊⍵,¨⊃⌽⍵)(⍵,⌽⍵)⍵}1↓⍞ ``` [Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkGXI862tP@V6srq@uYPerdovGoc9Gj3q2aj7qa1Q3UgSwFINYw0geJaTzq6ALSOodWAGUf9eyFiAEFoGwgrjV81Db5Ue@8/0BT/yuAQRqXMhecZYBgmiCYaQhmoiGSYiRxS0sE2zDRAsExMjJGMigNSYuhkTGSdSnmZuYIXlJSkimSpYlJSclI9oIAgmtsbmaSisZFtcbE1AzJDRYgCAA "APL (Dyalog Unicode) – Try It Online") `1↓⍞` drop the first character (the hash) `{` apply the following anonymous function  `(≢⍵)⊃` use the length of the argument to pick one of the following seven values:   `'0'` a zero   `⍵` the argument   `⍵` the argument   `2/⍵` two (`2`) of each (`/`) of the argument (`⍵`)   `∊⍵,¨⊃⌽⍵` the flattened (`∊`) argument (`⍵`) followed each (`,¨`) by the first (`⊃`) of the reversed (`⌽`) argument (`⍵`)   `⍵,⌽⍵` the argument (`⍵`) prepended (`,`) to the reversed (`⌽`) argument (`⍵`)   `⍵` the argument  `6⍴` repeat elements from that until a length of six is achieved `}` end of anonymous function `'#',` prepend a hash to that [Answer] # Python 2, ~~167~~ 165 bytes *-2 bytes thanks to Trelzevir* ``` z=zip lambda s:'#'+''.join([reduce(lambda x,y:x+y,c)for c in['0'*6,s[1:2]*6,z(s[1:2],s[2:3])*3,z(*z(s[1:2],s[2:3],s[3:4]))*2,z(s[1:4],s[-1]*3),s+s[-1],s][len(s)-1]]) ``` It creates a list of strings and chooses based on the length of the string. [Answer] # Sed, 119 (118 Bytes + `-E`) ``` s/#// s/^$/0/ s/^.$/&&/ s/^..$/&&&/ s/^(.)(.)(.)$/\1\1\2\2\3\3/ s/^(.)(.)(.)(.)$/\1\4\2\4\3\4/ s/^....(.)$/&\1/ s/^/#/ ``` Straightforward text substitution. [Answer] # PHP, 87 Bytes use Base 35 Numbers ``` <?=strtr(_2.intval([i4w,qdi,j1y,apg,ruu,ruv][strlen($argn|aa)-2],35),_234156,$argn.=0); ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVVJOTEpWsuayt/tvY29bXFJUUqQRb6SXmVdSlpijEZ1pUq5TmJKpk2VYqZNYkK5TVFoKxGWx0UCVOal5GmBDahITNXWNYnWMTTV14o2MTQxNzXTAEnq2BprW//8DAA "PHP – TIO Nexus") or use Base 33 Numbers ``` <?=strtr(_1.intval([a6n,sot,c8c,lba,vf1,vf2][strlen($argn|aa)-2],33),_134256,$argn.=0); ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVVJOTEpOSU1Tsuayt/tvY29bXFJUUqQRb6iXmVdSlpijEZ1olqdTnF@ik2yRrJOTlKhTlmYIxEax0UCVOal5GmBzahITNXWNYnWMjTV14g2NTYxMzXTAEnq2BprW//8DAA "PHP – TIO Nexus") # PHP, 89 Bytes ``` <?=strtr(_1.[11111,21212,12233,42434,23455,23456][strlen($argn|aa)-2],_123456,$argn."0"); ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVVJWsuayt/tvY29bXFJUUqQRb6gXbQgCOkaGQKhjaGRkbKxjYmRibKJjZGxiagomzWKjgcpzUvM0wMbUJCZq6hrF6sQbgiV1wIJ6SgZKmtb//wMA "PHP – TIO Nexus") `intval(["8kn",gd8,"9ft",wqq,i3j,i3k][strlen($argn|aa)-2],36)` + 3 Bytes using a 36 Base ## PHP, 102 Bytes ``` <?=strtr("01".substr("11111111112121212233424342345523456",5*strlen($argn)-5,5),str_split($argn."0")); ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVVI2VLLmsrf7b2NvW1xSVFKkoWRgqKRXXJpUDGIbwoERBBoZG5sYmQCxsYmpKYgwU9Ix1QKqzUnN0wAbqalrqmOqqQMUii8uyMksgYjqKRkoaWpa//8PAA "PHP – TIO Nexus") # PHP, 180 Bytes ``` <?=[str_pad("#",7,($l=strlen($p=substr($argn,1)))?$p:0),"#$p[0]$p[0]$p[1]$p[1]$p[2]$p[2]","#$p[0]$p[3]$p[1]$p[3]$p[2]$p[3]","#$p[0]$p[1]$p[2]$p[3]$p[4]$p[4]",$argn][($l>2)*($l-2)]; ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVVJWsuayt/tvY28bXVxSFF@QmKIBFNMx19FQybEFiuSk5mmoFNgWlyYBORpgTTqGmpqa9ioFVgaaOkrKKgXRBrEwwhBOGEEIJSQVxnBJY7gKYxQVhkjiQMIEQijpgK2NjQY6yc5IUwtI6Rppxlr//w8A "PHP – TIO Nexus") [Answer] # [Retina](https://github.com/m-ender/retina), 90 bytes ``` #(..)$ #$1$1$1 #(.)(.)(.)$ #$1$1$2$2$3 #(.)(.)(.(.))$ #$1$4$2$4$3 #$ #0 +`#.{0,4}(.)$ $&$1 ``` [Try it online!](https://tio.run/nexus/retina#RUzbDcIwDPz3GhdQK1CUh5u2E7BGEyBLIGYPF1qEz7Lle/g03LaGwdrRCIzvEJ7j3j8uEPHPcxySUtAu8XRy2WBf7qrvb9ScjW8NXYAKqiDzt@NeV4HPiyAERmsl5UOk7TGnWVBKmWjOpdzp7yWIc9LnsXa7TonZpeMD "Retina – TIO Nexus") Includes test cases. Explanation: The first translation handles two digits, the second one three, the third one four, and the fourth one zero. However, neither the second and fourth translations repeat the (last) digit, as that is done at the end anyway to cover all the remaining cases. [Answer] # [Haskell](https://www.haskell.org/), 130 127 122 118 109 95 bytes (by [user1472751](https://codegolf.stackexchange.com/users/65900/user1472751)) ``` y a|l<-[last a]=[y"0",y$a++a,a++a++a,do c<-a;[c,c],(:l)=<<init a,a++l,a]!!length a f(h:r)=h:y r ``` [Try it online!](https://tio.run/##dZDbToNAEIbveYop7QWEbeTUQhF8AU8XXiIxAyyFSLEpmEjiuyM72yionUl2Jv83k91/S2xfeV0PQw/4WYfruMa2A0yiuFdNlfUrNAxk4hA1f4MsXON1nLEsYVpQ61EYVk01boiZmmGyWNS82XcloFJoZXDSozLo4TQcsGogggMe719Ae9aq5vjeMeAfR551PNdhfQOj8tSd7hpYQVVAATQDV9H3FHQlb0BTHx5vQQXDOE@MjSr2STqv6cDrlo@zs1Fdh463XasoVCAIINbGO6tmz0BWPTmzCOJxfakyUJcmhaorMAYTsnlBd0l3KaZ6QXpBMdXRIoCWyNkFcsMsRE7BbkdgRzEFFvpELAvR96fEth0i9hiOM3tWcelhlu1Ij5Zpm87MY@5tPUK554l2gtI03RBKNyJnTjFNM2lWdNnMLH3j/z/qeFuXE6OO/2HFD/ztwN1spQfZTo37IqV32UqYgDJ8AQ "Haskell – Try It Online") [Answer] # Powershell, ~~113~~ 111 bytes ``` param($s)-join($s+='0'*($s-eq'#'))[0,1+((,1*5),(2,1*2+2),(1,2,2,3,3),(4,2,4,3,4),(2..5+5),(2..6))[$s.Length-2]] ``` Explaned test script: ``` $f = { param($s) # parameter string $s+='0'*($s-eq'#') # append '0' if $s equal to '#' $i=( # get indexes from array (,1*5), # $i = 1,1,1,1,1 if $s.length-2 = 0 (2,1*2+2), # $i = 2,1,2,1,2 if $s.length-2 = 1 (1,2,2,3,3), # $i = 1,2,2,3,3 if $s.length-2 = 2 (4,2,4,3,4), # $i = 4,2,4,3,4 if $s.length-2 = 3 (2..5+5), # $i = 2,3,4,5,5 if $s.length-2 = 4 (2..6) # $i = 2,3,4,5,6 if $s.length-2 = 5 )[$s.Length-2] -join$s[0,1+$i] # join chars from $s by indexes 0, 1 and $i } @( , ("#", "#000000") , ("#0", "#000000") , ("#4", "#444444") , ("#f", "#ffffff") , ("#a1", "#a1a1a1") , ("#0f", "#0f0f0f") , ("#99", "#999999") , ("#1a8", "#11aa88") , ("#223", "#222233") , ("#fff", "#ffffff") , ("#1230", "#102030") , ("#d767", "#d77767") , ("#bbb5", "#b5b5b5") , ("#aabbc", "#aabbcc") , ("#00000", "#000000") , ("#3764e", "#3764ee") , ("#3764ef", "#3764ef") , ("#123456", "#123456") , ("#f8f8f8", "#f8f8f8") ) |% { $s, $e = $_ $r = &$f $s "$($e-eq$r): $r" } ``` Output: ``` True: #000000 True: #000000 True: #444444 True: #ffffff True: #a1a1a1 True: #0f0f0f True: #999999 True: #11aa88 True: #222233 True: #ffffff True: #102030 True: #d77767 True: #b5b5b5 True: #aabbcc True: #000000 True: #3764ee True: #3764ef True: #123456 True: #f8f8f8 ``` [Answer] # JavaScript (ES6), 96 bytes ``` s=>'#'+(c=[u,v,w,x,y,z]=s.slice(1)||'0',z?c:y?c+y:(x?u+x+v+x+w+x:w?u+u+v+v+w+w:c.repeat(v?3:6))) ``` ``` f= s=>'#'+(c=[u,v,w,x,y,z]=s.slice(1)||'0',z?c:y?c+y:(x?u+x+v+x+w+x:w?u+u+v+v+w+w:c.repeat(v?3:6))) console.log( f('#'), f('#U'), f('#UV'), f('#UVW'), f('#UVWX'), f('#UVWXY'), f('#UVWXYZ') ) ``` [Answer] ## Perl, 61 bytes ``` say+(/./g,0)[0,1,(unpack+S7,"g+g+ÜRÉ/Â¥[ [")[y/#//c]=~/./g] ``` Run with `perl -nE`. Assumes that the input is exactly as described (gives incorrect results if the input has a trailing newline). The string "g+g+ÜRÉ/Â¥[ [" encodes the 7 16-bit numbers `11111,11111,21212,12233,42434,23455,23456` as 14 latin1 characters. Here’s a hexdump for clarity: ``` 0000001d: 672b 672b dc52 c92f c2a5 9f5b a05b g+g+.R./...[.[ ``` [Answer] # Windows batch, ~~389 372 362 349~~ 231 bytes *I totally copied @Neil code...* ``` @call:c %s:~1,1% %s:~2,1% %s:~3,1% %s:~4,1% %s:~5,1% %s:~6,1% @exit/b :c @for %%r in (#%1%2%3%4%5%6.%6 #%1%2%3%4%5%5.%5 #%1%4%2%4%3%4.%4 %s%%1%2%3.%3 %s%%1%2%1%2.%2 %s%%1%1%1%1%1.%1 #000000.0)do @if not %%~xr.==. @echo %%~nr&exit/b ``` [Answer] # Pyth, 35 bytes ``` +\#@<R6[J|tQ\0K*6JKKs*R2JjeJJ+JeJ)l ``` Try it online [here](https://pyth.herokuapp.com/?code=%2B%5C%23%40%3CR6%5BJ%7CtQ%5C0K%2A6JKKs%2AR2JjeJJ%2BJeJ%29l&input=%22%23abcd%22&debug=0), or verify all test cases [here](https://pyth.herokuapp.com/?code=%2B%5C%23%40%3CR6%5BJ%7CtQ%5C0K%2A6JKKs%2AR2JjeJJ%2BJeJ%29l&test_suite=1&test_suite_input=%22%23%22%0A%22%230%22%0A%22%234%22%0A%22%23f%22%0A%22%23a1%22%0A%22%230f%22%0A%22%2399%22%0A%22%231a8%22%0A%22%23223%22%0A%22%23fff%22%0A%22%231230%22%0A%22%23d767%22%0A%22%23bbb5%22%0A%22%23aabbc%22%0A%22%2300000%22%0A%22%233764e%22%0A%22%233764ef%22%0A%22%23123456%22%0A%22%23f8f8f8%22&debug=0). ``` +\#@<R6[J|tQ\0K*6JKKs*R2JjeJJ+JeJ)lQ Implicit: Q=eval(input()) Trailing Q inferred tQ Remove first char of input | \0 The above, or "0" if empty J *Store in J (also yields stored value) K*6J *Repeat J 6 times, store in K KK *2 more copies of the above s*R2J *Duplicate each char of J in place jeJJ *Join chars of J on last char of J +JeJ *Append last char of J to J [ ) Wrap the 5 starred results in an array <R6 Trim each to length 6 @ lQ Choose result at index of length of input (Modular indexing, so length 7 selects 0th element) +\# Prepend #, implicit print ``` [Answer] # [Python 2](https://docs.python.org/2/), 99 bytes ``` def a(s):s=s[1:]or'0';l=len(s);print('#'+(l/4*s[-1]).join(i+i*(l==3)for i in(l<5)*6*s)+s+s[-1])[:7] ``` [Try it online!](https://tio.run/##TY1LDoMgAET3PYVJF4CmrSiKn3oS4wKqpDQEjLjp6amkkAiLeZkMj/W7v40unJsXkTBoUWcHO@JuMhvIQa8Gteij7ddN6h2CK8igepDUjjc8ofvHSA1lJlOohqFEwmyJTI5KPSuU1qlFmc3@07Gjk2NegC4@8pAkpAjJcBzEpm0DYNYEKooyPhNxhosyOmda04Cc8yqaGeevKPcncElrspz5ZCRVHT9q/AXIXX8 "Python 2 – Try It Online") [Answer] ## **Python 2 - 179 bytes** ``` n=raw_input() #prompts for string t=len(n) #the length of the string is stored to 't' if t==1:n+="0"*6 #if t is only one char long, it needs to be black, so n is assigned 6 zeroes if t==2:n+=n[1]*5 #if t is two chars long, it adds the last character times 5 at the end if t==3:n+=n[1:3]*2 #if t is 3 chars, it multiplies the last two digits times 3 if t==4:n="#"+n[1]*2+n[2]*2+n[3]*2 #if t is 4 chars, it multiplies each char by two if t==5:n=n[:2]+n[4]+n[2]+n[4]+n[3]+n[4] #if t is 5 chars, it makes it work if t==6:n+=n[t-1] #if t is 6 chars, it adds the last character to the end print n #it prints out n ``` Can anyone help me save some bytes? All of the if statements seem like they could be shortened into something shorter, I just don't know what. [Answer] TXR Lisp: 171 bytes Indented: ``` (do let ((s (cdr @1))) (caseql (length s) (0 "#000000") (1 `#@s@s@s@s@s@s`) (2 `#@s@s@s`) (3 `#@[mappend list s s]`) (4 `#@[s 0]@[s 3]@[s 1]@[s 3]@[s 2]@[s 3]`) (5 `#@s@[s 4]`) (6 `#@s`)))) ``` This is an anonymous function: the `do` macro generates a `(lambda ...)` form. It is idiomatic coding style, suitable for production; the only golfing is squashing whitespace: ``` (do let((s(cdr @1)))(caseql(length s)(0"#000000")(1`#@s@s@s@s@s@s`)(2`#@s@s@s`)(3`#@[mappend list s s]`)(4`#@[s 0]@[s 3]@[s 1]@[s 3]@[s 2]@[s 3]`)(5`#@s@[s 4]`)(6`#@s`)))) ``` [Answer] # [Braingolf](https://github.com/gunnerwolf/braingolf), 95 bytes ``` l1-.1e$_!&@4>[!@]|.2e$_!&@!@2!@2|.3e$_<@V2[R<!@!@v]|.4e$_<@VRM&,2>[@v!@R]|.5e$_<@!&@@|.6e$_&@|; ``` [Try it online!](https://tio.run/##SypKzMxLz89J@/8/x1BXzzBVJV5RzcHELlrRIbZGzwjCVXQwAqIaPWMg18YhzCg6yEYRKFgGVGECEQryVdMxsot2KFN0CAKKmoJFgTodavTMgGw1hxrr////KxsaGRsAAA "Braingolf – Try It Online") This is effectively Braingolf's equivalent of a switch-case on the amount of characters after the `#` in the input. ### Explanation Stuff that always runs: ``` l1-.1 Implicit input to stack l Push length of stack 1- Decrement last item in stack . Duplicate last item in stack 1 Push 1 ``` If `#X`: ``` e$_!&@4>[!@]| e If last 2 items (input length - 1 and 1) are equal.. $_ ..Pop last item silently !&@ ..Print entire stack as chars without popping 4> ..Push 4 and move it to start of stack [..] ..While loop, decrements first item in stack when it reaches ] ..If first item in stack is 0 when reaching ], exit loop ..This loop will run 5 times !@ ....Print last char without popping | endif ``` If `#XX` This one may be golfable a little, I might look at it when I get home ``` .2e$_!&@!@2!@2| .2 Duplicate last item and push 2 e If last 2 items (input length - 1 and 2) are equal.. $_ ..Pop last item silently !&@ ..Print entire stack as chars without popping !@2 ..Print last 2 items as chars without popping !@2 ..Print last 2 items as chars without popping | Endif ``` If `#XXX` ``` .3e$_<@V2[R<!@!@v]| .3 Duplicate last item and push 3 e If last 2 items (input length - 1 and 3) are equal.. $_ ..Pop last item silently <@ ..Move first item in stack to the end, then pop and print V2 ..Create new stack and push 2 to it [.......] ..While loop, see above for explanation R< ....Switch to stack1 and move first item to end of stack !@!@ ....Print last item on stack twice without popping v ....Move to stack2 for loop counting | Endif ``` You get the idea [Answer] # [Ruby](https://www.ruby-lang.org/), 127 bytes ``` c=~/#(.)?(.)?(.)?(.)?(.)?(.)?/ $6?c:'#'+($5?$1+$2+$3+$4+$5*2:$4?$1+$4+$2+$4+$3+$4:$3?$1*2+$2*2+$3*2:$2?($1+$2)*3:$1?$1*6:"0"*6) ``` [Try it online!](https://tio.run/##KypNqvyfkpqmkKaQ/D/Ztk5fWUNP0x4b1udSMbNPtlJXVtfWUDG1VzHUVjHSVjHWVjHRVjHVMrJSMQGLmYCFTSAyVirGQEEtoIARiDAGKTOy1wDr1dQytlIxBEmbWSkZKGmZaf5PzUvh4iooALoFaAuMEYpghSExw5HZESicSFRelPp/AA "Ruby – Try It Online") [Answer] # [Ruby](https://www.ruby-lang.org/), 118 bytes ``` def f c c.sub!'#','' s=c.size t=c[3] s>5?'#'+c:f(s<1?'0':s<2?c*6:s<3?c*3:s<4?c*2:s<5?c[0]+t+c[1]+t+c[2]+t:c+c[-1]) end ``` [Try it online!](https://tio.run/##Vc1NCsIwEIbh/Zyi4mLUqDSJdRFacwp/SzadJuBGimkXevk4oGC7et6PgeQ5NK@UWh@ykBHQNg7NDOe4RoRY8by/PfQV1dpBPBSWT4JMWMRSWszRxFJZWu1ZzWp2xyq2sFTnTvSCavlFMYY4NtItwT/a1HX8Kz8Jvzj@6zTK87gvk3GdrhumDw "Ruby – Try It Online") [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 24 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` ćU©0®Ð€D®S¤ý®¤«)JIgè6∍Xì ``` [Try it online](https://tio.run/##ATcAyP9vc2FiaWX//8SHVcKpMMKuw5DigqxEwq5TwqTDvcKuwqTCqylKSWfDqDbiiI1Yw6z//yNhYmNk) or [verify all test cases](https://tio.run/##yy9OTMpM/V9TVmmvpPCobZKCkn3l/yPtoYdWGhxad3jCo6Y1LofWBR9acnjvoXWHlhxarelVmX54hdmjjt6Iw2v@6/xX5lI24FI24VJO41JONARygLSlJZeyYaIFl7KRkTFQIg0oZGhkDFSWYm5mzqWclJRkClSclJwCJBOTkpKBukCAS9nY3MwkFUpBNJmYmgFNsABBAA). **Explanation:** ``` ć # Extract the head of the (implicit) input-string; # pop and push remainder and head U # Pop and store the head in variable `X` © # Store the remainder in variable `®` (without popping) 0 # Push a 0 ®Ð # Push `®` three times €D # Duplicate each character in the last copy (which becomes a character-list) ®S # Push variable `®` again, converted to a character-list ¤ # Get its last character (without popping the list itself) ý # Join the list by this character ® # Push variable `®` once again ¤ # Get its last character (without popping the string itself) « # Append it to the string ) # Wrap all values into a list J # Join the inner list from `€D` together to a list, # or in case of input `#`, join everything together to string "0" # i.e. "#" → (["","0","","","",""] → ) "0" # i.e. "#4" → ["4","0","4","4","44","4","44"] # i.e. "#a1" → ["a1","0","a1","a1","aa11","a11","a11"] # i.e. "#1a8" → ["1a8","0","1a8","1a8","11aa88","18a88","1a88"] # i.e. "#abcd" → ["abcd","0","abcd","abcd","aabbccdd","adbdcdd","abcdd"] # i.e. "#3764e" → ["3764e","0","3764e","3764e","33776644ee","3e7e6e4ee","3764ee"] # i.e. #123456 → ["123456","0","123456","123456","112233445566","16263646566","1234566"] Ig # Push the length of the input è # Index (0-based) this into the list (with automatic wraparound for length=7) 6∍ # Extend/shorten the string to length 6 Xì # And prepend variable `X` (the "#") # (after which the result is output implicitly) ``` ]
[Question] [ A "simple circular" word is a word whose chords do not intersect. The chords of a word may be seen by laying out the alphabet in a circle, and then connecting the word's consecutive letters. ## Examples of Simple Circular Words **ROLE** [![ROLE](https://i.stack.imgur.com/v0Flm.png)](https://i.stack.imgur.com/v0Flm.png) **LAKE** [![LAKE](https://i.stack.imgur.com/DDGCh.png)](https://i.stack.imgur.com/DDGCh.png) **BALMY** [![BALMY](https://i.stack.imgur.com/XbBqr.png)](https://i.stack.imgur.com/XbBqr.png) ## Failing Example A word fails to be simple circular if any of its chords intersect: [![BONES](https://i.stack.imgur.com/fFdeL.png)](https://i.stack.imgur.com/fFdeL.png) ## The Challenge Write a program or function that takes a word and returns true if it's simple circular, false otherwise. * Code golf, fewest bytes wins. * Standard rules. * You may assume there are *no repeated letters* in the word. * You may assume every word has at least 2 letters * You may assume the word is all uppercase, or all lowercase, whichever you prefer. * You may output any two consistent values for true and false. ## Test Cases ### True ROLE, LAKE, BALMY, AEBDC, ABZCYDXE, AZL, ZA ### False BONES, ACDB, ALBZ, EGDF [Answer] # [Perl 6](https://github.com/nxadm/rakudo-pkg), 46 bytes ``` {!/[(.).*]**4<?{[+^] $0 Xeq[...] ~<<$0[^2]}>/} ``` [Try it online!](https://tio.run/##DcxNC4IwAAbgv/IGEmUwJaJLy9jXqZVQF3VM6DAhMEqrwxD768vrc3herm@34eExb7APwywxC7IksY3jDT0MZlVbRCkK1xlCiMWP0ig19dqOWTKG7nt3n9bjffMgU9A8e9BLrhU0Oypwpk8lmOJSgPFKlLKYMD@rK5iQHEzzKtuFPw "Perl 6 – Try It Online") A regex solution that finds if there are four characters in the string such that the two later characters are in different sections of the circle, as defined by the first two characters. ### Explanation ``` { } # Anonymous code block returning !/ / # If the input does not match [(.).*]**4 # Any 4 characters <?{ } # Where [...] # The range from ~<<$0[^2] # The first character to the second Xeq # Contains which of $0 # The four characters [+^] # Reduce the list of booleans by xor # Effectively, if only one of the 3rd or 4th character is in that range ``` [Answer] # [K (ngn/k)](https://bitbucket.org/ngn/k), ~~26~~ 24 bytes ``` {&/|/x=&\'x:-:\|26!x-*x} ``` [Try it online!](https://tio.run/##y9bNS8/7/z/NqlpNv0a/wlYtRr3CStcqpsbITLFCV6ui9n@JVbVKdGVdkVWaQoV1Qn62tUZCWmJmjnWFdaV1kWZsLVdJtFKQv4@rkrVhLIjt4@gNZzs5@vhGwjiOrk4uznCOU5RzpEsEQqW/n2uwkrUBRNLZxQnO9nGKArH/AwA "K (ngn/k) – Try It Online") `*x` first letter of the argument `x` `x-` subtract it from each of `x` as ascii code `26!` mod 26 `|` reverse `-:\` make a pair of the list and its negation `x:` assign to `x` `&\'` cumulative minima and maxima (max is min under negation) `|/x=` boolean mask for where `x[i]` is the current minimum or maximum `&/` all (and-reduce) [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), ~~14~~ 13 bytes *Fixed a bug thanks to NickKennedy* ``` Ç.sεć-ć/ï_Ë}P ``` [Try it online!](https://tio.run/##yy9OTMpM/V9TVmmvpGBrp6BkX/n/cLte8bmtR9p1j7TrH14ff7i7NuC/zv8gfx9XLh9Hb1cuJ0cf30guR1cnF2cuR6co50iXCFcuxygfrihHIN/fzzWYC0I6Ors4cTn6OEVxubq7uAEA "05AB1E – Try It Online") ``` Ç # convert each letter to its codepoint .s # suffixes of this list ε } # for each suffix: ć- # subtract first from others: [b-a, c-a, d-a, ...] ć/ # divide others by first: [(c-a)/(b-a), (d-a)/(b-a), ...] ï # round down _ # compare with 0 Ë # all equal? P # after the loop, product (1 iff the list is all 1s) ``` [Answer] # [JavaScript (Node.js)](https://nodejs.org), 91 bytes Returns \$false\$ for simple circular, or \$true\$ for non-simple circular. ``` s=>Buffer(s).some((o,i,a,j=i)=>a.some(_=>((g=i=>x=(a[i]-o%26)%26)(j)-g(i+1))*(x-g(++j))>0)) ``` [Try it online!](https://tio.run/##hc49C8IwEAbg3V/hIrmzraiDWwJN28mqoItai4SalpTaSKPiv69fi2LA4eB43uPlSnEVJmvU6ezV@iDbnLaGMn7Jc9mAwYHRRwmgXeUKt6QKKRNv21MGUFBF2Y2CSFTq6d54gs@BEr0ClDNC7MPtsTpOiciGiG2ma6MrOah0ASRZqeOpkt1MNdmlEk1KsPN5kANZLuKI4A/H/tTG3I9nG4v7EQ8Dm/NtsAnXr6qvjOzqZK5rz/x9kC/m0cpWHYTcxjHfPri9Aw "JavaScript (Node.js) – Try It Online") ### Commented ``` s => // s = input string Buffer(s) // turn s into a Buffer .some((o, i, a, // for each ASCII code o at position i in a[] j = i) => // and starting with j = i: a.some(_ => // for each entry in a[]: ( // ( g = i => // g is a helper function taking a position i x = (a[i] - o % 26) // return (a[i] - (o mod 26)) mod 26 % 26 // and assign the result to x // NB: if a[i] is undefined, this gives NaN // and forces the forthcoming test to fail )(j) - // compute the difference between g(j) g(i + 1) // and g(i + 1) ) * ( // multiply it by the difference x - g(++j) // between g(i + 1) and g(j + 1) (and increment j) ) > 0 // if it's positive, the chords are intersecting // inside the circle (i.e. s is not simple circular) ) // end of inner some() ) // end of outer some() ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~21~~ 20 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) ``` Ask¬-₂%.sD€ß¥s€à¥+ĀP ``` Port of [*@ngn*'s K (ngn/k) answer](https://codegolf.stackexchange.com/a/198554/52210), so make sure to upvote them!! Input as a lowercase list of characters. [Try it online](https://tio.run/##yy9OTMpM/f/fsTj70BrdR01NqnrFLo@a1hyef2hpMYhecGip9pGGgP//o5WSlHSUEoE4B4hzgbhSKRYA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WGexir6TwqG2SgpL9f8fi7ENrdB81NanqFbs8alpzeP6hpcUgesGhpdpHGgL@6/yPVirKz0lV0lHKScwGUUmJObmVQDoxNSklGUQnVSVXplQApRSUkvLzUotBYskpSSAqJ6lKKRYA). **Explanation:** ``` A # Push the lowercase alphabet: "abcdefghijklmnopqrstuvwxyz" sk # Get the (0-based) index of each characters of the input-list in this alphabet # i.e. ["b","a","l","m","y"] → [1,0,11,12,24] ¬ # Push the first index (without popping) - # And subtract it from each index # i.e. [1,0,11,12,24] - 1 → [0,-1,10,11,23] ₂% # Then take modulo-26 to make the negative values positive # i.e [0,-1,10,11,23] → [0,25,10,11,23] .s # Take the suffices of this list # i.e. [0,25,10,11,23] → [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]] D # Duplicate it €ß # Take the minimum of each suffix # i.e. [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]] # → [23,11,10,10,0] ¥ # And take the deltas (forward differences) of those # i.e. [23,11,10,10,0] → [-12,-1,0,-10] s # Swap to get the suffices again €à # Take the maximum of each suffix this time # i.e. [[23],[11,23],[10,11,23],[25,10,11,23],[0,25,10,11,23]] # → [23,23,23,25,25] ¥ # And take the deltas (forward differences) of those as well # i.e. [23,23,23,25,25] → [0,0,2,0] + # Add the values at the same indices in the two lists together # i.e. [-12,-1,0,-10] + [0,0,2,0] → [-12,1,2,-10] Ā # Python-style truthify each (0→0; everything else → 1) # i.e. [-12,1,2,-10] → [1,1,1,1] P # And take the product of that to check if all are truthy # i.e. [1,1,1,1] → 1 # (after which this is output implicitly as result) ``` [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 29 bytes ``` ⬤θ⬤…θκ⬤…θμ⬤…θξ⁼⁼‹ιν‹νλ⁼‹ιπ‹πλ ``` [Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMMxJ0ejUEcBRPnm56SA2NmaqPxcNH4FkO9aWJqYU6wBpXxSi4s1MnUU8oAyYHaejkKOJkIZTL4AJl8AlgcD6///nRx9fCP/65blAAA "Charcoal – Try It Online") Takes input in consistent case and outputs a Charcoal boolean (`-` for true, nothing for false). This has a rare use of the `p` variable. Explanation: ``` θ Input string ⬤ All characters satisfy θ Input string … Truncated to κ Current index ⬤ All characters satisfy θ Input string … Truncated to μ Current index ⬤ All characters satisfy θ Input string … Truncated to ξ Current index ⬤ All characters satisfy ι Fourth character ‹ Is less than ν Second character ⁼ Equals ν Second character ‹ Is less than λ Third character ⁼ Equals ι Fourth character ‹ Is less than π First character ⁼ Equals π First character ‹ Is less than λ Third character ``` For each subsequence of four characters in the input word, the first two comparisons check whether the second character is between the third and fourth while the other comparisons check whether the first character is between the third and fourth. If the results of these comparisons is different then it means that the chord between the first two characters crosses the chord between the third and fourth characters and the whole expression therefore evaluates to false. [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes ``` O_Ṫ$:Ṫ$¬EƲƤẠ ``` [Try it online!](https://tio.run/##y0rNyan8/98//uHOVSpWIOLQGtdjm44tebhrwX/rRw1zFHTtFB41zLU@3P5w5z4Vroe7txxuf9S0JvK//8Mdi@L9VY3MQg@tjtE5tDvmWJdnMEhXkL@PK5ePo7crl5Ojj28kl6Ork4szl6NTlHOkSwRQ0N/PNZjL0dnFicvRxykKAA "Jelly – Try It Online") A Jelly translation of [Grimy’s 05AB1E answer](https://codegolf.stackexchange.com/a/198564/42248); be sure to upvote that one too! A monadic link taking a Jelly string as its argument and returning a Jelly boolean. ## Explanation ``` O | Convert to Unicode codepoints ƲƤ | Following applied to each prefix: _Ṫ$ | - Subtract tail (after popping tail) :Ṫ$ | - Integer divide by tail (after popping tail) ¬ | - Not E | - All equal Ạ | All ``` [Answer] # [J](http://jsoftware.com/), ~~40~~ ~~36~~ 33 bytes ``` 10(e.,)[:(/:~@,#.@e.])"1/~2]\3&u: ``` [Try it online!](https://tio.run/##Vcy9DoIwGEbhnat4g4mFpBYqW40JX39wsEqCi1SJg4EYFydXbr2yOpzxOe@YCjZhr8DAUUItbQRM55soy2wUPL@prFBzzVeiHsWQp7KYt8O9Wn9VzJNkfL4@mHbiIZdD13oHT0cHTf7Ug5y2BqSD6e3VgYJHIPZvdHt2F5CxGuR1gDvYhsUf "J – Try It Online") Decided to play my own game. Still golfing... But the idea is just to try all possible combinations of pairs of points, and check if their lines intersect, which, if the segements are AB and CD, happens when the letters' numerical values are arranged like: ``` _____ / \ A...C...B...D \______/ ``` [Answer] # Haskell, ~~135~~ 99 bytes *Thanks @JoKing for saving 36 bytes!* Almost certain its not the optimal way to go, so please feel free to improve it. ``` x(a:b:c:d:_)|s<- \z->min a b>z||z>max a b=s c/=s d;x _=1<0;y s=or$map(x.concat)$mapM(\a->[[a],[]])s ``` ## Explanation However, I loved doing some propositional calculus. First, `x` tests if a given sequence of four letters form a non-circular word. Let \$I\$ be the interval defined by \$a\$ and \$b\$, so \$a,b,c\$ and \$d\$ form a circular word only if: $$ p\equiv(c\in I)\iff q\equiv(d\in I)\\ (p\Rightarrow q)\wedge(q\Rightarrow p)\\ (\neg p\lor q)\wedge(\neg q\lor p)\\ \left[(\neg p\lor q)\wedge \neg q\right]\lor\left[(\neg p\lor q)\wedge p\right]\\ \left[(\neg p\wedge\neg q)\lor(q\wedge\neg q)\right]\lor\left[(\neg p\wedge p)\lor(q\wedge p)\right]\\ (\neg p\wedge\neg q)\lor(q\wedge p)\\ \neg(p\lor q)\lor(q\wedge p) $$ Negating this proposition gives us $$ (p\lor q)\wedge\neg(q\wedge p) $$ which is equivalent to \$p\veebar q\$, in haskell `p/=q`. Finally, `y` tests if any subsequence with length 4 from the original word is non-circular. Here's a spaned version: ``` import Data.List -- x cuts (a:b:c:d:rest) | s <- \z-> min a b > z || z > max a b = s c /= s d x _ = False -- y isNonCircular word = or $ map (cuts . concat) $ mapM (\a -> [[a],[]]) word ``` ``` [Answer] # [Ruby](https://www.ruby-lang.org/) `-nl`, 70 bytes An adaptation of the Perl answer, but Perl is apparently black magic with... whatever they're doing that lets them tersely get any 4 characters. ``` p$_.chars.combination(4).all?{|*m,c,d|(c=~r=/[#{m.sort*?-}]/)==(d=~r)} ``` [Try it online!](https://tio.run/##Fc09DsIwDEDh3deAIa3adGGNehCEkO1EoiKJq6RI9I@jE8r6vuGlF82ljOe75gemrFkCDRGnQaK6VBq979etDg03dlNsPsl019MadJY01X2737rKGGUPqPZSkNhCEu/A49MBoQ8zoCPLgLTwbN9HlOgyRLEuJ0C2BOhp@cr4f@bSRv8D "Ruby – Try It Online") [Answer] # [C (clang)](http://clang.llvm.org/), ~~119~~ 114 bytes ``` c,n,b,j,o;g(char*w){for(int l[92]={j=o=c=0};n=*w;c=l[*w++])for(b=l[n],o|=b|c-j++&&c+~b&&b-c;n;)l[n--]++;return!o;} ``` [Try it online!](https://tio.run/##RY7LToNAFIb3PMWIKRmYwRh3Ok4Tbt1I20S7sK0sYLhnnDFcQkyLr46QWtz9X853/nOYyXgosmFgWOAIl1iSDLI8rIxOP6WygoVoAD8@PgT0VFJJGb3viaBGRxjlR6NDKNAnLRpJBFieaXRmZomQpjH0E2laZDIiiD5OTTNAiFRJ01biRpJ@uC0E422cgOe6iQt5ly@VdL6tgK9qvJ0CqC5qQJdgEX8IFXc4g52uE6VXps8@w0JAHUx229RQBbuqbfK05eBJHSWQQvV163vX7Fsvc7Ytf72/guXZrjMCuJB9cPbu@0X9K16FvE7493@vvd14b/O@49pz9u3DnN31ajdBP/wC "C (clang) – Try It Online") ``` We use an array representing the circle points ( we start from \0 instad of 'A' because it doesn't care) We increment by 1 each point from current letter to 0. The next point is valid if next == curr or next == curr - 1 or next == 0 and curr == j( iteration / left value ) LAKE ABCDEFGHIJKLMN.. j curr next 00000000000000.. 0 0 L 0 11111111111*00.. 1 1 A 1 *1111111111100.. 2 2 K 2 3222222222*100.. 3 2 E 2 4333*222222100.. ``` Thanks to @ceilingcat for saving 5 ]
[Question] [ An aesthetically pleasing divisor tree is a tree of divisors of input `n` that, for any composite number `m`, has two children nodes that are the **pair of divisors** that are closest to the **square root** of `m`. The left node should be the smaller divisor of `m` and the right node should be the larger divisor of `m`. A prime number in the tree should have no children nodes. Your tree may be in the form of text art or an image. The rules for text art output are as follows. **Spacing rules** To space out the nodes on the tree, we have the following rules: * The nodes at a given depth from the root should all be on the same line of text in the output. ``` / \ NOT / \ / \ / 3 2 3 2 ``` * For left nodes, the incoming branch should be on the upper right if the node is a single-digit number, else, just above the last digit. Example: ``` / AND / 3 720 ``` * For right nodes, the incoming branch should be on the upper left if the node is a single-digit number, else, just above the first digit. Example: ``` \ AND \ 7 243 ``` * For outgoing left branches, the branch should begin one space to the left of the number. Example: ``` 275 / 11 ``` * For outgoing right branches, the branch should begin one space to the right of the number. Example: ``` 275 \ 25 ``` * Any two nodes on the same level of the tree should have a minimum of two spaces between them. At the same time, any two **subtrees** on the same level of the tree should have as few spaces between them as possible. ``` This tree doesn't work because the **subtrees** are too close. 504 / \ / \ / \ / \ 21 . 24 / \ . / \ / \ . / \ 3 7. 4 6 . / \ / \ .2 2 2 3 While this tree does have enough space between its branches. 504 / \ / \ / \ / \ / \ 21 ... 24 / \ ... / \ / \ ... / \ 3 7... 4 6 ... / \ / \ ...2 2 2 3 ``` * If any two subtrees are too close together on a tree, they can be separated by adding another row of branches `/\` to the tree above the parents. ``` 441 / \ Last row is not filled in yet and we have already run out of space. 21 21 / \ / \ Add another row of branches 441 / \ Almost, but the 7 and the 3 are too close together. / \ One more row should do it. 21 21 / \ / \ 3 7 3 7 Add another row of branches 441 / \ And we're done. / \ / \ 21 21 / \ / \ 3 7 3 7 ``` **Examples** As a full example, the divisor tree of 24 will look like this: ``` 24 / \ / \ 4 6 / \ / \ 2 2 2 3 ``` 4 and 6 are the pair of divisors closest to the square root of 24. 4 is on the left, because it's smaller. On the next line, the number 2 to the left of 3, because it's smaller. The divisor tree for 63 should look like: ``` 63 and NOT like this 63 / \ / \ 7 9 3 21 / \ / \ 3 3 7 3 ``` In the incorrect tree, 3 and 21 are not the pair of divisors closest to the square root of 63, and 3 and 7 are not sorted properly. The branch placement on the 21 is correct, though. For 42, you should have: ``` 42 and NOT 42 / \ / \ 6 7 21 2 / \ / \ 2 3 3 7 ``` Let's have a look at 720. Note that we need five levels of branches from `720` so that the `24` and `30` subtrees are correctly spaced. Also, note that `24` and `30` have two levels of branches because `4` and `6` have children nodes that need correct spacing and the children nodes of `30` need to be on the same level as the children nodes of `24`. ``` 720 / \ / \ / \ / \ / \ 24 30 / \ / \ / \ / \ 4 6 5 6 / \ / \ / \ 2 2 2 3 2 3 ``` **The challenge** * Your task is to build a correctly-spaced aesthetically pleasing divisor tree for input `n`, where `n` is a positive integer greater than 1. * Your output may contain leading and trailing spaces and leading and trailing newlines, but must otherwise conform to the spacing rules given above. * Your output is allowed to be: text art, an image (other formats to be added, if needed). * For images, make sure your tree's nodes are well-spaced, and that nodes at the same height in the tree are at the same height in the image. * This is code golf. Least number of bytes (or equivalent) wins. Credit to Stewie Griffin for thinking of this idea, and many thanks to Peter Taylor, Martin Ender, Mego, and Eᴀsᴛᴇʀʟʏ Iʀᴋ for their help in rewriting the specification. As usual, any suggestions or corrections are much appreciated. Good luck and good golfing! **More test cases:** ``` 2 4 / \ 2 2 20 / \ 4 5 / \ 2 2 323 / \ 17 19 362880 / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ 576 630 / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ 24 24 21 30 / \ / \ / \ / \ / \ / \ / \ / \ 4 6 4 6 3 7 5 6 / \ / \ / \ / \ / \ 2 2 2 3 2 2 2 3 2 3 1286250 / \ / \ / \ / \ / \ 1050 1225 / \ / \ / \ / \ / \ / \ 30 35 35 35 / \ / \ / \ / \ 5 6 5 7 5 7 5 7 / \ 2 3 ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~711~~ ~~651~~ ~~575~~ ~~559~~ ~~554~~ ~~547~~ ~~539~~ ~~540~~ ~~530~~ 522 bytes After four months of trying to write this answer, running into a wall, leaving it for a weeks, rinse, repeat, I have **finally** finished a proper ASCII art answer for this challenge. All that's left is the golfing, and so, golfing suggestions are very welcome. [Try it online!](https://tio.run/nexus/python2#RVJNb@IwEL3nV1iRKnliB2IDVcHxSokELQgkDqgHXB@QCCV01yzZrAj8eXZMtq0PHs/X87xn3551tXHvhZrrn4VTYx2SMNgWO1JTx1@0SSyMApLpX5uGXiPqHq6pgN2xIldSOvJMBS8dlkZRZwBMAKhcu26m1vpPXVEHaqHndA0BKXckS@WoKuq/lTNrG5DVHdOUxKOVLdqcngHKXdgN3bH2obMprfUFZ/RoTTPgNc0B73nVL0aM7LEyK/PBhI3R2Fj42o9PsBXEAqxqNDbyV1AXPOT@sNQNMutUpdsWDfWjZmBiYYHRLBUJqJO@@ILvfA5eCkbzH0NQEyTlASBeslO8UHucJcFR6IQtHiST0JU4hlD/2Y4jumQzbJ6le7JxW6THMCajPVvEMprFElj49hZizxp8Zk4vd/QTdnlCs5bQnseCe0bM0LY/ngB0DkeUZpp67RAcJZviKGQcYcCjfKnX8AvcvWkL5@VHHsDxOlTU3r4ewvQ5EY@c9AZoh5IT2e@hJ3EbJJjrJz2ZYOBRPj2hFSKK@q0ZtGZo8dPg8ogHj1jTEtqQX78r/2kOEHw7YQi3fw "Python 2 – TIO Nexus") **Golfs:** -60 bytes from renaming some often used functions and changing how the result is returned. -73 bytes from changing how the subtrees' heights are checked, how the spacing variables are calculated, and how the result is returned. -3 bytes from FlipTack's `isdigit()` replacement. -16 bytes golfing that `isdigit()` replacement even further and replacing " " with `E`. -5 bytes from minor improvements and changing from Python 3 to Python 2. -7 bytes from modifying how the result is returned. -8 bytes from a small change to how `A` is defined, ~~changing how `T` is defined, and adding `W`, using the hypothesis that any subtree with at least one longer branch than its counterpart, is necessarily longer overall than its counterpart~~, removing `Q` altogether, and editing how the result is returned. -10 bytes from using `A<10` instead of `L(S(A))<2` for `A` and `B`. -8 bytes from changing the default `H` to `[0]` since the code avoids the problem of mutable default arguments by never mutating `H`, changing how `q` is defined by using `(B>9)` instead of `1-(B<10)`, removing `p` altogether, and creating `F` as a replacement for `p+q-M`. **Bug fixes:** Hypothesis was wrong, counterexample in `11**9 = 2357947691`. +1 byte ``` G=range;L=len;E=" " def t(n,H=[0]): A=max(z*(n%z<1)for z in G(1,int(n**.5)+1));B=n/A;Z=str(n);M=L(Z) if A<2:return[Z] T=max([i for i in G(L(w))if"/"not in w[i]]for w in(t(A),t(B)));V=H[1:]or[T[k+1]-T[k]-1for k in G(L(T)-1)];x=t(A,V);y=t(B,V);P=x[0].rindex(str(A)[-1])+(A<10);q=y[0].index(str(B)[0])+(B>9);F=L(x[0])-P+q-M;h=H[0]or(F+M%2+2)/2or 1;return[E*(P+J)+(J<h and"/"+E*(2*h+M-2*J-2)+"\\"or Z)+E*(L(y[0])-q+J)for J in G(h,-1,-1)]+[(E*(2*h-F)).join(I<L(w)and w[I]or E*L(w[0])for w in(x,y))for I in G(max(L(x),L(y)))] ``` **Explanation** The whole function can be boiled down to about four steps: 1. Determine the largest divisor pair of `n`, `A` and `B`. 2. Make the subtrees of `A` and `B`, redrawing as needed. 3. Determine the number of spaces that should go between the subtrees. 4. Draw and return the new divisor tree. I will go through each step in order. **Step 1.** This is the easiest step, quite frankly. Check every number `z` between 1 and the square root for divisibility into `n` and grab the largest `z` and `n//z` that matches. Return just `str(n)` if `n` is prime (either `A==1` or `B==n`) **Step 2.** Draw the subtrees of `A` and `B` and get the number of `/\` branches between nodes in the subtrees. To do this, we get the indices of every step that has digits in them, get the first differences of the indices, and subtract 1 again. Once we have the heights, we compare them to get the largest, and redraw the subtrees with the new heights. ~~I have a sneaking suspicion that the subtree that is taller overall always has branches as long as or equal to the branches on the shorter subtree, and I can use that to golf the code, but I have no proof of this yet.~~ Counterexample in `11**9 = 2357947691`. **Step 3.** This step is what took months to write. Step 2 took a few days to write and debug, but finding the right formulas for the spacing took ages. I'll see if I can condense what I figured out into a few paragraphs. Note that some of the code in this explanation has since been golfed out of the real code. First, `p`, `q`, `h`, `P`, `Q`, `s` and `M`.`p` is the number of characters from the end of the left branch `/` to the right end of the left subtree. `q` is the number of characters from the left end of the right subtree to the end of the right branch `/`. `h` is the number of branches between the root and the subtrees. `P` and `Q` are just the inverses of `p` and `q` and are useful for placing the spaces around `/\` branches up to the root `n`. `s` is the number of spaces that add between the two subtrees. `M` is simplest; it's the length of `n`. Put graphically: ``` M --- 720 | / \ | / \ h| / \ | / \ | / \ P p s q Q ------______---____------ 24 30 / \ / \ / \ / \ 4 6 5 6 / \ / \ / \ 2 2 2 3 2 3 ``` The formula for determining `p` is this: `p = len(x[0]) - x[0].rindex(str(A)[-1]) - (A<10)`, the length, minus the zero-index of the last character in A, minus a correction for single-digit `A`s. The formula for determining `q` is this: `q = y[0].index(str(B)[0]) + (B>9)`, the index of the first character in B, plus a correction for zero-indexing, minus a correction for single-digit `B`s (combined into one correction for multiple-digit `B`s). The formula for determining `h` is this: `h = H[0] or (p+q+M%2+2-M)//2 or 1`. Either we grab from a predefined `H` which means we're redrawing the tree, we use `(from_the_left + from_the_right + parity_space + 2 - len(root)) // 2)`, or we use the minimum number of branch levels, 1. The formula for determining `s` is this: `s = 2*h+M-p-q`. We subtract `p` and `q` from the number of spaces between the root's branches at their widest `2*h + M`. **Step 4.** And finally we put it all together. First we make the root, `[" "*(P+h)+Z+" "*(Q+h)]`, then we put in the branches down to the subtrees, `[" "*(P+J)+"/"+" "*(2*h+M-2*J-2)+"\\"+" "*(Q+J)for J in G(h)][::-1]`, and finally we put in our properly spaced subtrees, `[(" "*(2*h+M-p-q)).join([(I<L(w)and w[I]or" "*L(w[0]))for w in(x,y)])for I in G(max(L(x),L(y)))]`. Et voilà! We have ourselves an aesthetically pleasing divisor tree! **Ungolfing:** ``` def tree(n, H=[0]): A = max(z for z in range(1, int(n**.5)+1) if n%z<1) B = n/A Z = str(n) M = len(Z) if A < 2: return [Z] # redraw the tree so that all of the numbers are on the same rows x = tree(A) y = tree(B) for W in [x, y]: T = [i for i in range(len(W)) if "/" not in W[i]] V = H[1:] or [T[k+1]-T[k]-1 for k in range(len(T)-1)] x = tree(A, V) y = tree(B, V) # get the height of the root from the two trees P = x[0].rindex(str(A)[-1]) + (A < 10) p = len(x[0]) - P q = y[0].index(str(B)[0]) + (B > 9) Q = len(y[0]) - q h = hs[0] or (p+q+M%2+2-M)/2 or 1 # and now to put the root down R = [] s = 2*h+M-p-q for I in range(max(len(x),len(y))): c = I<len(x) and x[I] or " "*len(x[0]) d = I<len(y) and y[I] or " "*len(y[0]) R += c + " "*s + d, for J in range(h, -1, -1): if J<h: C = "/" + " "*(2*h+M-2*J-2) + "\\" else: C = Z R += [" "*(P+J) + C + " "*(Q+J)] return R ``` [Answer] # Mathematica, ~~96~~ ~~86~~ ~~81~~ ~~79~~ 78 bytes Thanks @MartinEnder for 2 bytes. ``` TreeForm[If[PrimeQ@#,#,#0/@(#2[#,#2/#]&[Max@Nearest[Divisors@#,#^.5],#])]&@#]& ``` The output looks like this: [![enter image description here](https://i.stack.imgur.com/0f2fl.png)](https://i.stack.imgur.com/0f2fl.png) # Explanation ``` Max@Nearest[Divisors@#,#^.5] ``` Generate the list of divisors of the input. Find the element nearest to the square root of the input. (`Max` is for flattening the output) ``` #2[#,#2/#]& ``` Find the other divisor by dividing the input by the divisor found above, apply the input as the head of the result. ``` #0/@ ``` Repeat the process. ``` If[PrimeQ@#,#, ... ] ``` If the input is prime, don't do anything. ``` TreeForm ``` Format the output. # Edit: A more aesthetically pleasing version (258 bytes) ``` TreeForm[#/.{a_,_,_}:>a,VertexRenderingFunction->(#2~Text~#&),VertexCoordinateRules->Cases[#,{_,_},Infinity,Heads->True]]&@(If[PrimeQ@#,{##},{##}@@#0@@@({{#,#3-#4{1,√3}/2,#4/2},{#2/#,#3-#4{-1,√3}/2,#4/2}}&[Max@Nearest[Divisors@#,√#],##])]&[#,{0,0},1])& ``` The output looks like this: [![enter image description here](https://i.stack.imgur.com/aXjSW.png)](https://i.stack.imgur.com/aXjSW.png) [Answer] # [Charcoal](https://github.com/somebody1234/Charcoal), 302 bytes ``` ≔⟦⟦N⁰θ⁰¦⁰⟧⟧θFθ«≔§ι⁰ζ≔⌈E…·²Xζ·⁵∧¬﹪ζκκη¿η«F⟦η÷ζη⟧«≔⟦κ⊕§ι¹Iκ⁰¦⁰⟧κ⊞ικ⊞θκ»⊞υι»»≔…⁰⌈Eθ§ι¹ηF⮌竧≔ηι⊕⌈⟦⁰⌈Eυ∧⁼§κ¹ι÷Σ⟦¹§§κ⁵¦⁴‹⁹§§κ⁵¦⁰§§κ⁶¦³‹⁹§§κ⁶¦⁰±L§κ²⟧²⟧FυF²§≔κ⁺³λ⁺⁺§ηι∨⊖L§§κ⁺⁵벦¹§§κ⁺⁵λ⁺³λ»Fυ«§≔§ι⁵¦³⁻⁻§ι³§η§ι¹∨⊖L§§ι⁵¦²¦¹§≔§ι⁶¦³⁻⁺⁺§ι³L§ι²§η§ι¹‹⁹§§ι⁶¦⁰»F⊕Lη«Fθ«F⁼§κ¹ι«←⸿M§κ³→F‹⁵Lκ«↙P↙§ηι↗»§κ²↓F‹⁵LκP↘§ηι»»M⊕§ηι↓ ``` [Try it online!](https://tio.run/##jVRNj9owED2TX2HtyZayFR8FddkTKj0gAUVUPaUcUjDEIjiQ2Oxqq/x2dvxFHD52e8AxmXnz3ryMvUzifJnF6ek0KAq24TiKRnwvxVTu/tIckxA1Q3TQa3OxgC15DtZZjvCBoH9Bw4IGYsRX9BUzyALIGyS50CR@ZTu5g@cej/gylQU70nnMNxS3QzTLXoDlDWBfugSQA77C00zgSbaSaaYCW/UaFlgTVZatEU40d0PriJIQjbgYsiNbUQVIyMKEnYJoqzKWOd1RLujKF9tSZb/HhcBbYntUZM8KPZNFonL8vwf3twzsGxkipt6UQRlYPtMcFPNbB2Sd1zWkm5jTI80LCo15rrp8aJDVO3CFowsSaQz8cZBxWpz73Co@JdM36peCtypRXnIXEr/Cb0yLAj/dTWnq73Ud68HrzsfwnoNP6SYWFI8p34jEz2iDPwtinrAhymLtlCRIP9sE1V0C0AyGC3dClBK714tvIwR@5nhIKysvqC@rdVU1q8OOy2eplQotuwyc7qsP6w2EMhQwE8YBbFYv2vFok6tB@t@eLM25leqQ3sjs@YKuzWTuG9eYmKv@kdh7c8HOc@HZ5k@9JYMzor30biGzvzf29jaY5YwL3B/TtQjRw5/8wZzrSXakPka11Z@zTSJMXJfWmrvnfrfEFTXw/jB74aqwgTQmMhVsb/hcqGYKIy5Tw3/vPcKyEls/EJVcXfQTeZcaNMMtEaW6vEzdW7ekSQRPLGd5OrXa33rtbvP0eEzfAQ "Charcoal – Try It Online") Link is to verbose version of code. As the verbose version is very verbose, he's a JavaScript transliteration of the main algorithm: ``` u = []; // predefined variable, used as list of branches q = [[+s, 0, s, 0, 0]]; // list of nodes starts with the root. for (i of q) { // iterate nodes, includes new nodes z = i[0]; // get node value h = Math.max(...[...Array(Math.floor(z ** 0.5) + 1).keys()].slice(2).filter( k => z % k < 1)); // find largest factor not above square root if (h) { for (k of [h, z / h]) { k = [k, i[1] + 1, `${k}`, 0, 0]; // create child node i.push(k); // add each child to parent (indices 5 and 6) q.push(k); // and to master nodelist } u.push(i); } } h = new Array(Math.max(...q.map(i => i[1]))); // list of branch heights for (i = h.length; i --> 0; ) { // find branch height needed to space immediate children apart at this depth h[i] = 1 + Math.max(...u.map(k => k[1] == j && // filter on depth 1 + k[5][3] + (k[5][0] > 9) + k[6][2] + (k[6][0] > 9) - k[2].length >> 1)); // current overlap, halved, rounded up // calculate the new margins on all the nodes for (k of u) { k[3] = h[i] + (k[5][2].length - 1 || 1) + k[5][3]; // left k[4] = h[i] + (k[6][2].length - 1 || 1) + k[6][4]; // right } } // calculate the absolute left margin of all the nodes under the root for (i of u) { i[5][3] = i[3] - h[i[1]] - (i[5][2].length - 1 || 1); i[6][3] = i[3] + i[2].length + h[i[1]] - (i[6][0] > 9); } // print the nodes (sorry, no transliteration available) ``` [Answer] # [C (GCC)](https://gcc.gnu.org) + [Graphviz](https://graphviz.org/), 213 bytes ``` g(n,c,x,k,l){printf("a%d[label=\"%d\"]",k=c,n);for(x=(int)sqrt(n);x>1;x-=1)n%x||(printf("a%d->a%d a%d->a%d ",k,l,k,c=g(x,l=c+1)+1),c=g(n/x,c),x=0);return c;}main(n){scanf("%d",&n);puts("digraph{");g(n);puts("}");} ``` Assuming the compiled executable is `a.out`, run with `./a.out | dot -Tpng`. Takes the input `n` from `stdin` and outpus a PNG image to `stdout`. ]
[Question] [ Sometimes I need to write more documentation than just comments in code. And sometimes, those explanations need screenshots. Sometimes the conditions to get such a screenshot are so weird that I ask a developer to take a screenshot for me. Sometimes the screenshot does not fit my specifications and I have to resize it so that it looks nicely. As you can see, the circumstances for a need for the magic "Lossless Screenshot Resizer" are very unlikely. Anyway, for me it seems I need it every day. But it doesn't exist yet. I've seen you here on PCG solve [awesome graphical puzzles](https://codegolf.stackexchange.com/questions/33172/american-gothic-in-the-palette-of-mona-lisa-rearrange-the-pixels) before, so I guess this one is rather boring for you... ## Specification * The program takes a screenshot of a single window as input * The screenshot does not make use of glass effects or similar (so you don't need to deal with any background stuff that shines through) * The input file format is PNG (or any other lossless format so that you don't have to deal with compression artifacts) * The output file format is the same as the input file format * The program creates a screenshot of different size as output. Minimum requirement is shrinking in size. * The user shall specify the expected output size. If you can give hints about the minimum size your program can produce from the given input, that's helpful. * **The output screenshot must not have less information if interpreted by a human.** You shall not remove text or image content, but you shall remove areas with background only. See examples below. * If it is not possible to get the expected size, the program should indicate that and not simply crash or remove information without further notice. * If the program indicates the areas which will be removed for verification reasons, that should increase its popularity. * The program may need some other user input, e.g. to identify the starting point for optimization. ## Rules This is a popularity contest. The answer with most votes on 2015-03-08 gets accepted. ## Examples Windows XP screenshot. Original size: 1003x685 pixels. ![XP screenshot large](https://i.stack.imgur.com/D3yHi.png) Example areas (red: vertical, yellow: horizontal) that can be removed without losing any information (text or images). Note that the red bar isn't contiguous. This example doesn't indicate all possible pixels that could potentially be removed. ![XP screenshot removal indicators](https://i.stack.imgur.com/QxegK.png) Losslessly resized: 783x424 pixels. ![XP screenshot small](https://i.stack.imgur.com/3VyOc.png) Windows 10 screenshot. Original size: 999x593 pixels. ![Windows 10 screenshot large](https://i.stack.imgur.com/TpETH.png) Example areas which can be removed. ![Windows 10 screenshot removal indicated](https://i.stack.imgur.com/kIpm1.png) Losslessly resized screenshot: 689x320 pixels. Note that it is ok that the title text ("Downloads") and "This folder is empty" are not centered any more. Of course, it would be nicer if it is centered, and if your solution provides that, it should become more popular. ![Windows 10 screenshot small](https://i.stack.imgur.com/C2fcD.png) [Answer] # Python the function `delrows` deletes all but one duplicate rows and returns the transposed image, applying it twice also deletes the columns and transposes it back. Additionally `threshold` controls how many pixels can differ for two lines to be still considered the same ``` from scipy import misc from pylab import * im7 = misc.imread('win7.png') im8 = misc.imread('win8.png') def delrows(im, threshold=0): d = diff(im, axis=0) mask = where(sum((d!=0), axis=(1,2))>threshold) return transpose(im[mask], (1,0,2)) imsave('crop7.png', delrows(delrows(im7))) imsave('crop8.png', delrows(delrows(im8))) ``` ![enter image description here](https://i.stack.imgur.com/KXCns.png) ![enter image description here](https://i.stack.imgur.com/sJafp.png) Flipping the comparator in `mask` from `>` to `<=` will instead output the removed areas which are mostly blank space. ![enter image description here](https://i.stack.imgur.com/Uvwi3.png) ![enter image description here](https://i.stack.imgur.com/cH8jx.png) **golfed (because why not)** Instead of comparing each pixel it only looks at the sum, as a side effect this also converts the screenshot to greyscale and has trouble with sum-preserving permutations, like the down-arrow in the address bar of the Win8 screenshot ``` from scipy import misc from pylab import* f=lambda M:M[where(diff(sum(M,1)))].T imsave('out.png', f(f(misc.imread('in.png',1))),cmap='gray') ``` ![enter image description here](https://i.stack.imgur.com/Pwtet.png) ![enter image description here](https://i.stack.imgur.com/AX7Wn.png) [Answer] ## Java: Try lossless and fallback to content-aware *(Best lossless result so far!)* ![XP screenshot lossless without desired size](https://i.stack.imgur.com/3BZEC.png) When I first looked at this question I thought this is not a puzzle or challenge just someone desperately in need of a program and it's code ;) But it is in my nature to solve vision problems so I could not stop my self from trying this challenge! I came up with the following approach and combination of algorithms. **In pseudo-code it looks like this:** ``` function crop(image, desired) { int sizeChange = 1; while(sizeChange != 0 and image.width > desired){ Look for a repeating and connected set of lines (top to bottom) with a minimum of x lines Remove all the lines except for one sizeChange = image.width - newImage.width image = newImage; } if(image.width > desired){ while(image.width > 2 and image.width > desired){ Create a "pixel energy" map of the image Find the path from the top of the image to the bottom which "costs" the least amount of "energy" Remove the lowest cost path from the image image = newImage; } } } int desiredWidth = ? int desiredHeight = ? Image image = input; crop(image, desiredWidth); rotate(image, 90); crop(image, desiredWidth); rotate(image, -90); ``` **Used techniques:** * Intensity grayscale * Dilation * Equal column search and remove * Seam-carving * Sobel edge detection * Thresholding --- ## The Program The program can crop screenshots lossless but has an option to fallback to content-aware cropping which is not 100% lossless. The arguments of the program can be tweaked to achieve better results. Note: The program can be improved in many ways (I don't have that much spare time!) **Arguments** ``` File name = file Desired width = number > 0 Desired height = number > 0 Min slice width = number > 1 Compare threshold = number > 0 Use content aware = boolean Max content aware cycles = number >= 0 ``` **Code** ``` import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JOptionPane; /** * @author Rolf Smit * Share and adapt as you like, but don't forget to credit the author! */ public class MagicWindowCropper { public static void main(String[] args) { if(args.length != 7){ throw new IllegalArgumentException("At least 7 arguments are required: (file, desiredWidth, desiredHeight, minSliceSize, sliceThreshold, forceRemove, maxForceRemove)!"); } File file = new File(args[0]); int minSliceSize = Integer.parseInt(args[3]); //4; int desiredWidth = Integer.parseInt(args[1]); //400; int desiredHeight = Integer.parseInt(args[2]); //400; boolean forceRemove = Boolean.parseBoolean(args[5]); //true int maxForceRemove = Integer.parseInt(args[6]); //40 MagicWindowCropper.MATCH_THRESHOLD = Integer.parseInt(args[4]); //3; try { BufferedImage result = ImageIO.read(file); System.out.println("Horizontal cropping"); //Horizontal crop result = doDuplicateColumnsMagic(result, minSliceSize, desiredWidth); if (result.getWidth() != desiredWidth && forceRemove) { result = doSeamCarvingMagic(result, maxForceRemove, desiredWidth); } result = getRotatedBufferedImage(result, false); System.out.println("Vertical cropping"); //Vertical crop result = doDuplicateColumnsMagic(result, minSliceSize, desiredHeight); if (result.getWidth() != desiredHeight && forceRemove) { result = doSeamCarvingMagic(result, maxForceRemove, desiredHeight); } result = getRotatedBufferedImage(result, true); showBufferedImage("Result", result); ImageIO.write(result, "png", getNewFileName(file)); } catch (IOException e) { e.printStackTrace(); } } private static BufferedImage doSeamCarvingMagic(BufferedImage inputImage, int max, int desired) { System.out.println("Seam Carving magic:"); int maxChange = Math.min(inputImage.getWidth() - desired, max); BufferedImage last = inputImage; int total = 0, change; do { int[][] energy = getPixelEnergyImage(last); BufferedImage out = removeLowestSeam(energy, last); change = last.getWidth() - out.getWidth(); total += change; System.out.println("Carves removed: " + total); last = out; } while (change != 0 && total < maxChange); return last; } private static BufferedImage doDuplicateColumnsMagic(BufferedImage inputImage, int minSliceWidth, int desired) { System.out.println("Duplicate columns magic:"); int maxChange = inputImage.getWidth() - desired; BufferedImage last = inputImage; int total = 0, change; do { BufferedImage out = removeDuplicateColumn(last, minSliceWidth, desired); change = last.getWidth() - out.getWidth(); total += change; System.out.println("Columns removed: " + total); last = out; } while (change != 0 && total < maxChange); return last; } /* * Duplicate column methods */ private static BufferedImage removeDuplicateColumn(BufferedImage inputImage, int minSliceWidth, int desiredWidth) { if (inputImage.getWidth() <= minSliceWidth) { throw new IllegalStateException("The image width is smaller than the minSliceWidth! What on earth are you trying to do?!"); } int[] stamp = null; int sliceStart = -1, sliceEnd = -1; for (int x = 0; x < inputImage.getWidth() - minSliceWidth + 1; x++) { stamp = getHorizontalSliceStamp(inputImage, x, minSliceWidth); if (stamp != null) { sliceStart = x; sliceEnd = x + minSliceWidth - 1; break; } } if (stamp == null) { return inputImage; } BufferedImage out = deepCopyImage(inputImage); for (int x = sliceEnd + 1; x < inputImage.getWidth(); x++) { int[] row = getHorizontalSliceStamp(inputImage, x, 1); if (equalsRows(stamp, row)) { sliceEnd = x; } else { break; } } //Remove policy int canRemove = sliceEnd - (sliceStart + 1) + 1; int mayRemove = inputImage.getWidth() - desiredWidth; int dif = mayRemove - canRemove; if (dif < 0) { sliceEnd += dif; } int mustRemove = sliceEnd - (sliceStart + 1) + 1; if (mustRemove <= 0) { return out; } out = removeHorizontalRegion(out, sliceStart + 1, sliceEnd); out = removeLeft(out, out.getWidth() - mustRemove); return out; } private static BufferedImage removeHorizontalRegion(BufferedImage image, int startX, int endX) { int width = endX - startX + 1; if (endX + 1 > image.getWidth()) { endX = image.getWidth() - 1; } if (endX < startX) { throw new IllegalStateException("Invalid removal parameters! Wow this error message is genius!"); } BufferedImage out = deepCopyImage(image); for (int x = endX + 1; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { out.setRGB(x - width, y, image.getRGB(x, y)); out.setRGB(x, y, 0xFF000000); } } return out; } private static int[] getHorizontalSliceStamp(BufferedImage inputImage, int startX, int sliceWidth) { int[] initial = new int[inputImage.getHeight()]; for (int y = 0; y < inputImage.getHeight(); y++) { initial[y] = inputImage.getRGB(startX, y); } if (sliceWidth == 1) { return initial; } for (int s = 1; s < sliceWidth; s++) { int[] row = new int[inputImage.getHeight()]; for (int y = 0; y < inputImage.getHeight(); y++) { row[y] = inputImage.getRGB(startX + s, y); } if (!equalsRows(initial, row)) { return null; } } return initial; } private static int MATCH_THRESHOLD = 3; private static boolean equalsRows(int[] left, int[] right) { for (int i = 0; i < left.length; i++) { int rl = (left[i]) & 0xFF; int gl = (left[i] >> 8) & 0xFF; int bl = (left[i] >> 16) & 0xFF; int rr = (right[i]) & 0xFF; int gr = (right[i] >> 8) & 0xFF; int br = (right[i] >> 16) & 0xFF; if (Math.abs(rl - rr) > MATCH_THRESHOLD || Math.abs(gl - gr) > MATCH_THRESHOLD || Math.abs(bl - br) > MATCH_THRESHOLD) { return false; } } return true; } /* * Seam carving methods */ private static BufferedImage removeLowestSeam(int[][] input, BufferedImage image) { int lowestValue = Integer.MAX_VALUE; //Integer overflow possible when image height grows! int lowestValueX = -1; // Here be dragons for (int x = 1; x < input.length - 1; x++) { int seamX = x; int value = input[x][0]; for (int y = 1; y < input[x].length; y++) { if (seamX < 1) { int top = input[seamX][y]; int right = input[seamX + 1][y]; if (top <= right) { value += top; } else { seamX++; value += right; } } else if (seamX > input.length - 2) { int top = input[seamX][y]; int left = input[seamX - 1][y]; if (top <= left) { value += top; } else { seamX--; value += left; } } else { int left = input[seamX - 1][y]; int top = input[seamX][y]; int right = input[seamX + 1][y]; if (top <= left && top <= right) { value += top; } else if (left <= top && left <= right) { seamX--; value += left; } else { seamX++; value += right; } } } if (value < lowestValue) { lowestValue = value; lowestValueX = x; } } BufferedImage out = deepCopyImage(image); int seamX = lowestValueX; shiftRow(out, seamX, 0); for (int y = 1; y < input[seamX].length; y++) { if (seamX < 1) { int top = input[seamX][y]; int right = input[seamX + 1][y]; if (top <= right) { shiftRow(out, seamX, y); } else { seamX++; shiftRow(out, seamX, y); } } else if (seamX > input.length - 2) { int top = input[seamX][y]; int left = input[seamX - 1][y]; if (top <= left) { shiftRow(out, seamX, y); } else { seamX--; shiftRow(out, seamX, y); } } else { int left = input[seamX - 1][y]; int top = input[seamX][y]; int right = input[seamX + 1][y]; if (top <= left && top <= right) { shiftRow(out, seamX, y); } else if (left <= top && left <= right) { seamX--; shiftRow(out, seamX, y); } else { seamX++; shiftRow(out, seamX, y); } } } return removeLeft(out, out.getWidth() - 1); } private static void shiftRow(BufferedImage image, int startX, int y) { for (int x = startX; x < image.getWidth() - 1; x++) { image.setRGB(x, y, image.getRGB(x + 1, y)); } } private static int[][] getPixelEnergyImage(BufferedImage image) { // Convert Image to gray scale using the luminosity method and add extra // edges for the Sobel filter int[][] grayScale = new int[image.getWidth() + 2][image.getHeight() + 2]; for (int x = 0; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { int rgb = image.getRGB(x, y); int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = (rgb & 0xFF); int luminosity = (int) (0.21 * r + 0.72 * g + 0.07 * b); grayScale[x + 1][y + 1] = luminosity; } } // Sobel edge detection final double[] kernelHorizontalEdges = new double[] { 1, 2, 1, 0, 0, 0, -1, -2, -1 }; final double[] kernelVerticalEdges = new double[] { 1, 0, -1, 2, 0, -2, 1, 0, -1 }; int[][] energyImage = new int[image.getWidth()][image.getHeight()]; for (int x = 1; x < image.getWidth() + 1; x++) { for (int y = 1; y < image.getHeight() + 1; y++) { int k = 0; double horizontal = 0; for (int ky = -1; ky < 2; ky++) { for (int kx = -1; kx < 2; kx++) { horizontal += ((double) grayScale[x + kx][y + ky] * kernelHorizontalEdges[k]); k++; } } double vertical = 0; k = 0; for (int ky = -1; ky < 2; ky++) { for (int kx = -1; kx < 2; kx++) { vertical += ((double) grayScale[x + kx][y + ky] * kernelVerticalEdges[k]); k++; } } if (Math.sqrt(horizontal * horizontal + vertical * vertical) > 127) { energyImage[x - 1][y - 1] = 255; } else { energyImage[x - 1][y - 1] = 0; } } } //Dilate the edge detected image a few times for better seaming results //Current value is just 1... for (int i = 0; i < 1; i++) { dilateImage(energyImage); } return energyImage; } private static void dilateImage(int[][] image) { for (int x = 0; x < image.length; x++) { for (int y = 0; y < image[x].length; y++) { if (image[x][y] == 255) { if (x > 0 && image[x - 1][y] == 0) { image[x - 1][y] = 2; //Note: 2 is just a placeholder value } if (y > 0 && image[x][y - 1] == 0) { image[x][y - 1] = 2; } if (x + 1 < image.length && image[x + 1][y] == 0) { image[x + 1][y] = 2; } if (y + 1 < image[x].length && image[x][y + 1] == 0) { image[x][y + 1] = 2; } } } } for (int x = 0; x < image.length; x++) { for (int y = 0; y < image[x].length; y++) { if (image[x][y] == 2) { image[x][y] = 255; } } } } /* * Utilities */ private static void showBufferedImage(String windowTitle, BufferedImage image) { JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(image)), windowTitle, JOptionPane.PLAIN_MESSAGE, null); } private static BufferedImage deepCopyImage(BufferedImage input) { ColorModel cm = input.getColorModel(); return new BufferedImage(cm, input.copyData(null), cm.isAlphaPremultiplied(), null); } private static final BufferedImage getRotatedBufferedImage(BufferedImage img, boolean back) { double oldW = img.getWidth(), oldH = img.getHeight(); double newW = img.getHeight(), newH = img.getWidth(); BufferedImage out = new BufferedImage((int) newW, (int) newH, img.getType()); Graphics2D g = out.createGraphics(); g.translate((newW - oldW) / 2.0, (newH - oldH) / 2.0); g.rotate(Math.toRadians(back ? -90 : 90), oldW / 2.0, oldH / 2.0); g.drawRenderedImage(img, null); g.dispose(); return out; } private static BufferedImage removeLeft(BufferedImage image, int startX) { int removeWidth = image.getWidth() - startX; BufferedImage out = new BufferedImage(image.getWidth() - removeWidth, image.getHeight(), image.getType()); for (int x = 0; x < startX; x++) { for (int y = 0; y < out.getHeight(); y++) { out.setRGB(x, y, image.getRGB(x, y)); } } return out; } private static File getNewFileName(File in) { String name = in.getName(); int i = name.lastIndexOf("."); if (i != -1) { String ext = name.substring(i); String n = name.substring(0, i); return new File(in.getParentFile(), n + "-cropped" + ext); } else { return new File(in.getParentFile(), name + "-cropped"); } } } ``` --- ## Results --- ## XP screenshot lossless without desired size (Max lossless compression) **Arguments:** "image.png" 1 1 5 10 false 0 **Result:** 836 x 323 ![XP screenshot lossless without desired size](https://i.stack.imgur.com/3BZEC.png) --- ## XP screenshot to 800x600 **Arguments:** "image.png" 800 600 6 10 true 60 **Result:** 800 x 600 The lossless algorithm removes about 155 horizontal lines than the algorithm falls back to content-aware removal therefor some artifacts can be seen. ![Xp screenshot to 800x600](https://i.stack.imgur.com/blHYQ.png) --- ## Windows 10 screenshot to 700x300 **Arguments:** "image.png" 700 300 6 10 true 60 **Result:** 700 x 300 The lossless algorithm removes 270 horizontal lines than the algorithm falls back to content-aware removal which removes another 29. Vertical only the lossless algorithm is used. ![Windows 10 screenshot to 700x300](https://i.stack.imgur.com/7HXzR.png) --- ## Windows 10 screenshot content-aware to 400x200 (test) **Arguments:** "image.png" 400 200 5 10 true 600 **Result:** 400 x 200 This was a test to see how the resulting image would look after severe use of the content-aware feature. The result is heavily damaged but not unrecognizable. ![Windows 10 screenshot content-aware to 400x200 (test)](https://i.stack.imgur.com/zv7B5.png) --- [Answer] ## C#, algorithm like I would do it manually This is my first image processing program and it took a while to implement with all that `LockBits` stuff etc. But I wanted it to be fast (using `Parallel.For`) to get an almost instant feedback. Basically my algorithm is based on observations on how I remove pixels manually from a screenshot: * I am starting from the right edge, because chances are higher that unused pixels are there. * I define a threshold for edge detection in order to capture the system buttons correctly. For the Windows 10 screenshot, a threshold of 48 pixels works well. * After the edge is detected (marked in red color below), I am looking for pixels of the same color. I take the minimum number of pixels found and apply it to all rows (marked violet). * Then I start over again with edge detection (marked red), pixels of the same color (marked blue, then green, then yellow) and so forth At the moment I do it horizontally only. The vertical result can use the same algorithm and operate on a 90° rotated image, so in theory it's possible. ## Results This is a screenshot of my application with detected regions: ![Lossless Screenshot Resizer](https://i.stack.imgur.com/yzz2z.png) And this is the result for the Windows 10 screenshot and 48 pixels threshold. The output is 681 pixels wide. Unfortunately it's not perfect (see "Search Downloads" and some of the vertical column bars). ![Windows 10 result, 48 pixels threshold](https://i.stack.imgur.com/R7G5c.png) And another one with 64 pixels threshold (567 pixels wide). This looks even better. ![Windows 10 result, 64 pixels threshold](https://i.stack.imgur.com/4b8Xm.png) Overall result applying rotation to crop from all bottom as well (567x304 pixels). ![Windows 10 result, 64 pixels threshold, rotated](https://i.stack.imgur.com/CUjPk.png) For Windows XP, I needed to change the code a bit since the pixels are not exactly equal. I am applying a similarity threshold of 8 (difference in RGB value). Note some artifacts in the columns. ![Lossless Screenshot Resizer with Windows XP screenshot loaded](https://i.stack.imgur.com/fBZNx.png) ![Windows XP result](https://i.stack.imgur.com/i5JLF.png) ## Code Well, my first attempt on image processing. Doesn't look very good, does it? This only lists the core algorithm, not the UI and not the 90° rotation. ``` using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Threading.Tasks; namespace LosslessScreenshotResizer.BL { internal class PixelAreaSearcher { private readonly Bitmap _originalImage; private readonly int _edgeThreshold; readonly Color _edgeColor = Color.FromArgb(128, 255, 0, 0); readonly Color[] _iterationIndicatorColors = { Color.FromArgb(128, 0, 0, 255), Color.FromArgb(128, 0, 255, 255), Color.FromArgb(128, 0, 255, 0), Color.FromArgb(128, 255, 255, 0) }; public PixelAreaSearcher(Bitmap originalImage, int edgeThreshold) { _originalImage = originalImage; _edgeThreshold = edgeThreshold; // cache width and height. Also need to do that because of some GDI exceptions during LockBits _imageWidth = _originalImage.Width; _imageHeight = _originalImage.Height; } public Bitmap SearchHorizontal() { return Search(); } /// <summary> /// Find areas of pixels to keep and to remove. You can get that information via <see cref="PixelAreas"/>. /// The result of this operation is a bitmap of the original picture with an overlay of the areas found. /// </summary> /// <returns></returns> private unsafe Bitmap Search() { // FastBitmap is a wrapper around Bitmap with LockBits enabled for fast operation. var input = new FastBitmap(_originalImage); // transparent overlay var overlay = new FastBitmap(_originalImage.Width, _originalImage.Height); _pixelAreas = new List<PixelArea>(); // save the raw data for later so that the image can be cropped int startCoordinate = _imageWidth - 1; // start at the right edge int iteration = 0; // remember the iteration to apply different colors int minimum; do { var indicatorColor = GetIterationColor(iteration); // Detect the edge which is not removable var edgeStartCoordinates = new PixelArea(_imageHeight) {AreaType = AreaType.Keep}; Parallel.For(0, _imageHeight, y => { edgeStartCoordinates[y] = DetectEdge(input, y, overlay, _edgeColor, startCoordinate); } ); _pixelAreas.Add(edgeStartCoordinates); // Calculate how many pixels can theoretically be removed per line var removable = new PixelArea(_imageHeight) {AreaType = AreaType.Dummy}; Parallel.For(0, _imageHeight, y => { removable[y] = CountRemovablePixels(input, y, edgeStartCoordinates[y]); } ); // Calculate the practical limit // We can only remove the same amount of pixels per line, otherwise we get a non-rectangular image minimum = removable.Minimum; Debug.WriteLine("Can remove {0} pixels", minimum); // Apply the practical limit: calculate the start coordinates of removable areas var removeStartCoordinates = new PixelArea(_imageHeight) { AreaType = AreaType.Remove }; removeStartCoordinates.Width = minimum; for (int y = 0; y < _imageHeight; y++) removeStartCoordinates[y] = edgeStartCoordinates[y] - minimum; _pixelAreas.Add(removeStartCoordinates); // Paint the practical limit onto the overlay for demo purposes Parallel.For(0, _imageHeight, y => { PaintRemovableArea(y, overlay, indicatorColor, minimum, removeStartCoordinates[y]); } ); // Move the left edge before starting over startCoordinate = removeStartCoordinates.Minimum; var remaining = new PixelArea(_imageHeight) { AreaType = AreaType.Keep }; for (int y = 0; y < _imageHeight; y++) remaining[y] = startCoordinate; _pixelAreas.Add(remaining); iteration++; } while (minimum > 1); input.GetBitmap(); // TODO HACK: release Lockbits on the original image return overlay.GetBitmap(); } private Color GetIterationColor(int iteration) { return _iterationIndicatorColors[iteration%_iterationIndicatorColors.Count()]; } /// <summary> /// Find a minimum number of contiguous pixels from the right side of the image. Everything behind that is an edge. /// </summary> /// <param name="input">Input image to get pixel data from</param> /// <param name="y">The row to be analyzed</param> /// <param name="output">Output overlay image to draw the edge on</param> /// <param name="edgeColor">Color for drawing the edge</param> /// <param name="startCoordinate">Start coordinate, defining the maximum X</param> /// <returns>X coordinate where the edge starts</returns> private int DetectEdge(FastBitmap input, int y, FastBitmap output, Color edgeColor, int startCoordinate) { var repeatCount = 0; var lastColor = Color.DodgerBlue; int x; for (x = startCoordinate; x >= 0; x--) { var currentColor = input.GetPixel(x, y); if (almostEquals(lastColor,currentColor)) { repeatCount++; } else { lastColor = currentColor; repeatCount = 0; for (int i = x; i < startCoordinate; i++) { output.SetPixel(i,y,edgeColor); } } if (repeatCount > _edgeThreshold) { return x + _edgeThreshold; } } return repeatCount; } /// <summary> /// Counts the number of contiguous pixels in a row, starting on the right and going to the left /// </summary> /// <param name="input">Input image to get pixels from</param> /// <param name="y">The current row</param> /// <param name="startingCoordinate">X coordinate to start from</param> /// <returns>Number of equal pixels found</returns> private int CountRemovablePixels(FastBitmap input, int y, int startingCoordinate) { var lastColor = input.GetPixel(startingCoordinate, y); for (int x=startingCoordinate; x >= 0; x--) { var currentColor = input.GetPixel(x, y); if (!almostEquals(currentColor,lastColor)) { return startingCoordinate-x; } } return startingCoordinate; } /// <summary> /// Calculates color equality. /// Workaround for Windows XP screenshots which do not have 100% equal pixels. /// </summary> /// <returns>True if the RBG value is similar (maximum R+G+B difference is 8)</returns> private bool almostEquals(Color c1, Color c2) { int r = c1.R; int g = c1.G; int b = c1.B; int diff = (Math.Abs(r - c2.R) + Math.Abs(g - c2.G) + Math.Abs(b - c2.B)); return (diff < 8) ; } /// <summary> /// Paint pixels that can be removed, starting at the X coordinate and painting to the right /// </summary> /// <param name="y">The current row</param> /// <param name="output">Overlay output image to draw on</param> /// <param name="removableColor">Color to use for drawing</param> /// <param name="width">Number of pixels that can be removed</param> /// <param name="start">Starting coordinate to begin drawing</param> private void PaintRemovableArea(int y, FastBitmap output, Color removableColor, int width, int start) { for(int i=start;i<start+width;i++) { output.SetPixel(i, y, removableColor); } } private readonly int _imageHeight; private readonly int _imageWidth; private List<PixelArea> _pixelAreas; public List<PixelArea> PixelAreas { get { return _pixelAreas; } } } } ``` [Answer] # Haskell, using naive removal of duplicate sequential lines Unfortunately, this module only provides a function with the very generic type `Eq a => [[a]] -> [[a]]`, since I have no idea how to edit image files in Haskell, however, I'm certain it's possible to tranform a PNG image to a `[[Color]]` value and I'd imagine `instance Eq Color` to be easily definable. The function in question is `resizeL`. **Code:** ``` import Data.List nubSequential [] = [] nubSequential (a:b) = a : g a b where g x (h:t) | x == h = g x t | x /= h = h : g h t g x [] = [] resizeL = nubSequential . transpose . nubSequential . transpose ``` **Explanation:** *Note:* `a : b` means *element* `a` prefixed to *list of type of `a`*, resulting in a list. This is the fundamental construction of lists. `[]` denotes the empty list. *Note:* `a :: b` means `a` is of type `b`. For example, if `a :: k`, then `(a : []) :: [k]`, where `[x]` denotes a list containing things of type `x`. This means that `(:)` itself, without any arguments, `:: a -> [a] -> [a]`. The `->` denotes a function from something to something. The `import Data.List` simply gets some work some other people did for us and lets us use their functions without rewriting them. First, define a function `nubSequential :: Eq a => [a] -> [a]`. This function removes subsequent elements of a list that are identical. So, `nubSequential [1, 2, 2, 3] === [1, 2, 3]`. **We will now abbreviate this function as `nS`.** If `nS` is applied to an empty list, nothing can be done, and we simple return an empty list. If `nS` is applied to a list with contents, then actual processing can be done. For this, we need a second function, here in a `where`-clause, to use recursion, as our `nS` doesn't keep track of an element to compare to. We name this function `g`. It works by comparing its first argument to the head of the list it's been given, and discarding the head if they match and calling itself on the tail with the old first argument. If they don't, it appends the head onto the tail, passed through itself with the head as the new first argument. To use `g`, we give it the head of the argument of `nS` and the tail as its two arguments. `nS` is now of type `Eq a => [a] -> [a]`, taking a list and returning a list. It requires that we can check for equality between the elements as this is done in the function definition. Then, we *compose* the functions `nS` and `transpose` using the `(.)` operator. Composing functions means the following: `(f . g) x = f (g (x))`. In our example, `transpose` rotates a table 90°, `nS` removes all sequential equal elements of the list, in this case other lists (that's what a table is), `transpose` rotates it back and `nS` again removes sequential equal elements. This is essentially removing subsequent duplicate rows an columns. This is possible because if `a` is checkable for equality (`instance Eq a`), then `[a]` is, too. In short: `instance Eq a => Eq [a]` ]
[Question] [ Stackylogic is a logic-based programming language I made up that take in `0`'s and `1`'s for input and outputs a single `0` or `1` upon completion. A Stackylogic program consists of lines that can only contain the three characters `01?` as well as exactly one `<` at the end of one of the lines. Lines may not be empty and the line with the `<` must have at least one `0`, `1`, or `?` before it. Here's a sample program that (as I'll explain) computes the [NAND](https://en.wikipedia.org/wiki/NAND_gate) of two bits: ``` 1 ?< 11 ? 0 ``` Every line in a Stackylogic program is considered a [stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)), with the bottom on the left and the top on the right. Implicitly, there is an empty stack (empty line) before the first line in a program and after the last line. The `<`, which we'll call the **cursor**, marks the stack to start on when a Stackylogic program is run. Execution of a Stackylogic program proceeds as follows: 1. Pop the top character off the stack the cursor is currently pointing to. * If the character is `?`, prompt the user for a `0` or a `1` and act as if that was the character. * If the character is `0`, move the cursor one stack up (to the line above the current line). * If the character is `1`, move the cursor one stack down (to the line below the current line). 2. If the stack the cursor moves to is empty, output the last value that was popped off a stack (always a `0` or `1`), and end the program. 3. Else, if the stack the cursor moves to is not empty, go back to step 1 and repeat the process. Notice that Stackylogic programs always end because they must eventually deplete their stacks. ### NAND Example In the NAND program the cursor starts on a `?`: ``` 1 ?< 11 ? 0 ``` We'll assume the user inputs a `1` once the `?` is popped, which means the cursor will move down, making the program look like this: ``` 1 11< ? 0 ``` Now a plain `1` is at the top of the cursor stack. It is duly popped and the cursor moves again: ``` 1 1 ?< 0 ``` Now assume the user inputs `0` for the `?`, which means the cursor will move up: ``` 1 1< 0 ``` Again, a `1` is on the cursor stack so the cursor pops and moves down: ``` 1 < 0 ``` Finally the cursor stack is empty, so the last value popped, the `1`, is output and the program ends. This is accurate for a NAND gate because `1 NAND 0` is `1`. This of course works for the other three two-bit inputs if you care to check. ### OR Example This Stackylogic program simulates an [OR](https://en.wikipedia.org/wiki/OR_gate) gate: ``` ? ?< ``` It's easy to see that an initial input of `1` will push the cursor to the implicit empty stack below the last line, ending the program and outputting the `1` that was just input. For an input of `00` on the other hand, the cursor will make its way to the implicit empty stack at the top, ending the program and outputting the last `0` to be input. # Challenge Write a program or function that takes in a Stackylogic program as a string and runs it, printing or returning the resulting `0` or `1`. Upon `?`'s, you may prompt the user for a `0` or `1` input, *or* read the value from a preset string of `0`'s and `1`'s that you also take as input. (This could be another string input to your program/function or you could just assume the first or last line of the program string will be the input stream). You may assume the program and the input are always well formed. You may optionally assume input programs come with a single trailing newline (though remember there is always an implicit empty stack at the end). **The shortest code in bytes wins.** # More Sample Programs ``` ZERO 0< ONE 1< BUFFER ?< NOT 1 ?< 0 AND ?< ? NAND 1 ?< 11 ? 0 OR ? ?< NOR 1 ? 00 ?< 0 XOR(v1) ? 0 1?< ? 0 XOR(v2) ? ?< 11 ? 0 XNOR(v1) 1 ? 0?< 1 ? XNOR(v2) 1 ? 00 ?< ? MEDIAN(v1) 1 ???< 0 MEDIAN(v2) ? 1?< ?? ``` Thanks Martin for the [median](https://codegolf.stackexchange.com/questions/84851/run-stackylogic?noredirect=1#comment208063_84851) [programs](https://codegolf.stackexchange.com/questions/84851/run-stackylogic?noredirect=1#comment208091_84851). [Answer] ## [Retina](https://github.com/m-ender/retina), ~~79~~ ~~78~~ ~~73~~ ~~68~~ ~~66~~ ~~65~~ ~~63~~ ~~62~~ ~~55~~ 44 bytes Byte count assumes ISO 8859-1 encoding. ``` +`(.)([^_]*)\?<|(¶.*)0<|1<(¶.+) $2$1$4<$3 1< ``` Input is via STDIN and is expected to be the user input separated by two linefeeds from the source code. [Try it online!](http://retina.tryitonline.net/#code=JShTYC8KK2AoLikoW15fXSopXD88fCjCti4qKTA8fDE8KMK2LispCiQyJDEkNDwkMwoxPA&input=Ly8wPAovLzE8CjAvLz88CjEvLz88CjAvLzEvPzwvMAoxLy8xLz88LzAKMDAvLz88Lz8KMDEvLz88Lz8KMTAvLz88Lz8KMTEvLz88Lz8KMDAvLzEvPzwvMTEvPy8wCjAxLy8xLz88LzExLz8vMAoxMC8vMS8_PC8xMS8_LzAKMTEvLzEvPzwvMTEvPy8wCjAwMC8vPy8_MC8_PC8_MS8_CjAwMS8vPy8_MC8_PC8_MS8_CjAxMC8vPy8_MC8_PC8_MS8_CjAxMS8vPy8_MC8_PC8_MS8_CjEwMC8vPy8_MC8_PC8_MS8_CjEwMS8vPy8_MC8_PC8_MS8_CjExMC8vPy8_MC8_PC8_MS8_CjExMS8vPy8_MC8_PC8_MS8_) (The first two lines enable a test suite, where each line is a separate test case with `/` instead of linefeeds.) I'm not entirely sure what happened here. ~~This feels like a really clunky solution and~~ this is really not the kind of problem Retina was made for but it still beats all the current answers for some reason. ### Explanation The final version of this actually ended up being fairly simple. ``` +`(.)([^_]*)\?<|(¶.*)0<|1<(¶.+) $2$1$4<$3 ``` The first stage is simply a loop (due to the `+` option) which does the actual interpreting of the language. The stage is a single regex substitution, but in fact it's really three different substitutions squeezed into one stage, by making use of the fact that capturing groups from unused branches are simply considered empty during the substitution. 1. Processing `?`: ``` (.)([^_]*)\?< $2$1< ``` This simply takes the first character of the input, then matches arbitrary characters until it finds `?<`, and puts that first character in front of the `<` (deleting the `?`). 2. Processing `0`: ``` (¶.*)0< <$1 ``` This matches the line preceding a `0<` and puts it after the `<`, removing `0`. (Effectively, this just deletes the `0` and moves the `<` one line upwards.) 3. Processing `1`: ``` 1<(¶.+) $1< ``` Pretty much the same thing, except that we move `<` one line down while deleting a `1`. One important detail to notice is the use of `+` instead of `*`, that is, we require the next line not to be empty. The interesting part is figuring out why this works and why we don't need to keep track of the last value we popped to determine the final output. To do that, we need to consider how the above loop can terminate. Since every possible match changes the string (since at least one character is dropped from it), we only need to consider cases where the match fails altogether. If the character in front of `<` is `?` the only way for the match to fail is that there isn't non-linefeed character anywhere in front of it, but that can't happen because we're guaranteed that there's always enough input. If the character in front of `<` is `0`, the regex will always match, since there's always another line above the current one (which may be the empty line separating input from source code). If the character in front of `<` is `1`, the regex will fail if either we're on the last line (since the `¶` will fail to match) or if the next line is empty (since the `.+` will fail to match). Note that both of those cases correspond to terminating the program after popping a `1`. Finally, there's also the possibility that `<` isn't preceded by any of `?01`. It turns out we can only reach this situation by popping a `0` and moving up to an empty line, so that the `<` is now preceded by a linefeed. So, when the program terminates on a `1`, the `<` will still be after that `1`. But if the program terminates on a `0`, it will have moved to an empty line. We can easily turn this information into the desired output with a simple match stage: ``` 1< ``` This simply counts the matches of `1<` in the string. By the above reasoning this will be `1` if the program terminated on a `1`, and `0` if it terminated on a `0`. [Answer] ## [Convex](https://github.com/GamrCorps/Convex), ~~102~~ 95 bytes Well, a list-of-stacks-based language coded in a stack-based language turned out to be quite difficult. ~~*Mark my words: I will get this to 100 bytes or less!*~~ EDIT: Success! ``` N/S\+{s)_'<={R:M;}{R):R;+}?}%'<-M){(æ=)s_:Q;"?10 ""l+ M):M; M(:M; W:M;A~p"S/Ë~~_!S*+tM)Q:A;}h;; ``` [Try it online!](http://convex.tryitonline.net/#code=Ti9TXCt7cylfJzw9e1I6TTt9e1IpOlI7K30_fSUnPC1NKXsow6Y9KXNfOlE7Ij8xMCAiImwrIE0pOk07IE0oOk07IFc6TTtBfnAiUy_Di35-XyFTKit0TSlROkE7fWg7Ow&input=MQow&args=MQo_PAoxMQo_CjA) Program input is via command-line args. Input `0`s and `1`s normally (on TIO, this means newline-separated in the "input" box). --- **Explanation:** All of the code can be split into three pieces: ``` N/S\+ ``` This bit simply takes the input program and converts it into an array of lines, and also adds `" "` lines to the beginning of the array. Since Convex's arrays wrap, having only an empty stack at the beggining will do. ``` {s)_'<={R:M;}{R):R;+}?}%'<- ``` This part determines what line (or stack) to start execution with. It searches through each line and puts the correct stack number into the `M` variable. ``` M){(æ=)s_:Q;"?10 ""l+ M):M; M(:M; W:M;A~p"S/Ë~~_!S*+tM)Q:A;}h;; ``` This is the fun bit! It continually loops until it reaches a line with only a space (`" "`) on it (symbolizing an empty stack). If the line is not empty it does the following: 1. Pop the last character off the stack. 2. Switch statement: 1. If the character is a `?`, take input and append that character to the line. 2. If the character is a `0`, move the line pointer up one. 3. If the character is a `1`, move the line pointer down one. 4. If the character is a (space), print the most-recently popped item and end program. [Answer] # 32-bit x86 machine code, 70 bytes In hex: ``` FC89E1565F31D28A07A8DF740B3C3C7511428D5C24FCEB0A5729142484C07405B20147EBE2578B3B8A17F6C2DF7414FF0B923C3F7501AC3C30750383C30883EB04EBE389CCC3 ``` Input is a NULL-terminated multi-line string (linefeed-separated) passed via ESI. User input is assumed to be the first line. Returns '0'/'1' in AL. ## Disassembly: ``` fc cld 89 e1 mov ecx,esp 56 push esi 5f pop edi ;EDI=ESI 31 d2 xor edx,edx ;EDX=0 _loop0: 8a 07 mov al,BYTE PTR [edi] ;AL=*EDI a8 df test al,0xf5 ;AL&~0x0a==0 => separator ('\n' or '\0') 74 0b je _stck 3c 3c cmp al,'<' 75 11 jne _loop0end 42 inc edx ;For "cursor" symbol adjust stack pointer offset 8d 5c 24 fc lea ebx,[esp-0x4] ;and load EBX with the address where this pointer eb 0a jmp _loop0end ;is going to be stored in the next iteration _stck: 57 push edi ;Pointer to the separator 29 14 24 sub DWORD PTR [esp],edx ;adjusted to point to the top of the stack 84 c0 test al,al ;AL==0? 74 05 je _loop0break ;break b2 01 mov dl,0x1 ;EDX can be [0..2], resets to 1 _loop0end: 47 inc edi ;++EDI eb e2 jmp _loop0 _loop0break: 57 push edi ;*EDI==0, add lower implicit empty stack _loop1: ;The actual state machine code 8b 3b mov edi,DWORD PTR [ebx] ;EDI=*EBX 8a 17 mov dl,BYTE PTR [edi] ;DL=*EDI f6 c2 df test dl,0xf5 ;DL&~0x0a 74 14 je _loop1break ;ZF==1 => current stack is empty ff 0b dec DWORD PTR [ebx] ;--(*EBX): pop the stack 92 xchg edx,eax ;AL=DL 3c 3f cmp al,'?' 75 01 jne _skplods ;AL=='?' => substitute char from the input string ac lodsb _skplods: 3c 30 cmp al,'0' 75 03 jne _0x31 ;EBX+=AL==0?4:-4 83 c3 08 add ebx,0x8 ;But to avoid wasting 2 bytes for the jump after the 'add' _0x31: ;add 8 and fall through to subtract 4 back 83 eb 04 sub ebx,0x4 eb e3 jmp _loop1 _loop1break: 89 cc mov esp,ecx ;Clear the stack c3 ret ;Returns '0'/'1' in AL ``` [Answer] # JavaScript (ES6), 136 ~~138~~ Assuming a terminating newline in the program ``` (p,i,j=0)=>eval("for(p=`\n${p}`.split`\n`.map((x,i)=>((c=(x=[...x]).pop())=='<'?k=i:x.push(c),x));a=p[k].pop();k-=1-c-c)c=1/a?a:i[j++]") ``` *Less golfed* ``` (p, i, j=0)=>{ p=`\n${p}` .split`\n` .map( (x,i)=> ( x = [...x], c = x.pop(), c == '<' ? k=i : x.push(c), x ) ) for(; a = p[k].pop(); k -= 1-c-c) c = 1/a ? a : i[j++]; return c; } ``` **Test** ``` F=(p,i,j=0)=>eval("for(p=`\n${p}`.split`\n`.map((x,i)=>((c=(x=[...x]).pop())=='<'?k=i:x.push(c),x));a=p[k].pop();k-=1-c-c)c=1/a?a:i[j++]") function run() { var pgm=P.value+'\n' var i=I.value O.textContent = F(pgm,i) } run() ``` ``` #P { width:60%; height: 6em } #I { width:50%; } ``` ``` Program<br> <textarea id=P>1 ?&lt; 11 ? 0</textarea><br> Input<br> <input id=I value=01> <button onclick='run()'>Run</button> <br>Output <pre id=O></pre> ``` [Answer] # [05AB1E](http://github.com/Adriandmen/05AB1E), ~~58~~ ~~56~~ ~~55~~ ~~53~~ ~~51~~ ~~50~~ 46 bytes Saved 2 bytes thanks to **Emigna**! Code: ``` õ|`õ)[¤'<å#À]`¨[¬V¨Y'?QiI«ëYi1U)À`ëY_i0U)Á`ëXq ``` Uses the **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=w7V8YMO1KVvCpCc8w6Ujw4BdYMKoW8KsVsKoWSc_UWlJwqvDq1lpMVUpw4Bgw6tZX2kwVSnDgWDDq1hx&input=MQo_PAoxMQo_CjAKCjEKMA). [Answer] # Python 3, ~~147~~ ~~146~~ ~~145~~ 144 bytes *1 byte thanks to @Lynn.* ``` def f(p): i=p[:p.find("<")].count("\n");p=p.split() try: while 1:*p[i],c=p[i];c=c>"<"and input()or c;i+=c<"<"and int(c)*2-1 except:return c ``` [Answer] # Python 3, 318 ``` def s(f,z): p=b="";g=0;a=[];n=a.append;n(p) for i in f: if i=="\n":n(p);p='' else:p+=i n(p);p=b;n(p) while g<len(a): if'<'in a[g]:q=g;a[q]=a[q][:-1] g+=1 while 1: v=a[q] if v=='':print(b);break if v[-1]=='1':a[q]=v[:-1];q+=1;b=1 elif v[-1]=="0":a[q]=v[:-1];q-=1;b=0 else:a[q]=v[:-1]+z[0];z=z[1:] ``` F being the program, z being input. Yes, my variable names are insane. [Answer] # ES6, 190 bytes ``` f=(p,i)=>{ n=p.split`<`[0].split`\n`.length-1 p=p.split`\n`.map(o=>o.split``) i=i.split`` p[n].pop() while(p[n]&&p[n].length){ c=p[n].pop() v=c=='?'?i.shift():Number(c) n+=v*2-1 } return v } ``` Use like `f(program, input)` [Answer] # Java, ~~256~~ ~~255~~ ~~231~~ ~~219~~ ~~215~~ 213 bytes ``` int f(char[][]p,char[]I){int l=p.length,d=0,j=-1,c=0,k=0,i[]=new int[l];while(++j<l)if(p[j][i[j]=p[j].length-1]==60)i[k=j]--;try{for(;;k+=c>48?1:-1)c=(c=p[k][i[k]--])>49?I[d++]:c;}catch(Throwable t){}return c-48;} ``` [Demo on Ideone.](http://ideone.com/eCXC0P) Takes the program and input as arguments and returns the result as an integer. [Answer] # PHP (<7.0), ~~195~~ 192 bytes Takes the program as first argument and each value as an additional argument. Note that I tested this with split(" ",..) asn spaces rather than newlines but it should work anyway. Gives a deprecated notice if run in php >5.3. Also gives a warning if you go off the top of the program. However it still works and outputs correctly so it's fine. ``` <?php foreach(split("\n",$argv[++$t])as$l)$p[]=str_split($l);for($i=-1;end($p[++$i])!='<';);array_pop($p[$i]);for(;($v=array_pop($p[$i]))!==null;$i+=$n?:-1)($n=$v)=='?'&&$n=$argv[++$t];echo$n; ``` [Answer] # C, ~~264~~ ~~249~~ ~~244~~ 242 C doesn't do so well with manipulating strings, but this is pretty short. It works by scanning the string for the cursor (`<`), moving back 1 place, reading the command, replacing it with a `tab` character, and moving either forward or backward one line. Input is in the form of a C char array, like `char array[]="1\n?<\n11\n?\n0";result = f(array);`, although carriage returns are permitted as well. Although the input string is modified, the length is not changed. ``` t;f(char*n){char*p=strchr(n,60);for(*p--=9;;){if(*p==63)scanf("%d",&t),*p=t+48;if(*p^49){for(*p--=9;p>n&&*p^10;--p);for(--p;p>n&&*p==9;--p);if(p<n||*p==10)return 0;}else{for(*p++=9;*p&&*p^10;++p);for(p+=!!*p;*p>10;++p);if(*--p<11)return 1;}}} ``` ## Test program Run this program with each test case as a separate parameter, using a single backslash in place of newlines. Test cases will be separated by a blank line. ``` #include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, const char **argv) { while (*++argv) { char *input=malloc(strlen(*argv)+1),*p; strcpy(input,*argv); printf("testing %s\n",input); for (p=input;*p;++p) if (*p=='\\') *p=10; printf("result: %d\n\n",f(input)); free(input); } return 0; } ``` ]
[Question] [ A standard, solved, 3×3×3 [Rubik's Cube](https://en.wikipedia.org/wiki/Rubik%27s_Cube) has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite orange, the blue opposite green, and when white points upward, red is to the left of blue: [![Rubik's cube layout](https://i.stack.imgur.com/5tn68.png)](https://i.stack.imgur.com/5tn68.png) Imagine an ant sits on the center square of the white face, facing the red face. You can give him 3 commands: * Forward (`^`) - take a step in the direction he's facing to the next grid square, stepping over an edge of the cube if necessary. * Right (`>`) - rotate to the right (clockwise) by 90°, staying in the same grid square. * Left (`<`) - rotate to the left (counter-clockwise) by 90°, staying in the same grid square. Given an arbitrary list of commands, find the colors of the squares that the ant visits (not including the white starting square). > > For example, the command sequence `^^>^^<^^^` has a path that looks > like this: > > > [![example path](https://i.stack.imgur.com/6Irhz.png)](https://i.stack.imgur.com/6Irhz.png) > > > The colors of the grid squares visited in order, not counting the > starting square, are `white red red green green green yellow`, > or just `wrrgggy`. > > > Write a program or function that takes in a string of the command characters `<^>` and prints or returns a string of the characters `wyrobg` (white, yellow, red orange, blue, green) that corresponds to the ant's path over the cube. **The shortest code in bytes wins. Tiebreaker is earlier answer.** ## Notes * The cube is in midair and the ant has effective pulvilli, so he can traverse the whole of the cube. * The cube always remains in its solved state. * A square's color is only recorded upon movement into the square, not rotation. The starting white square should not be recorded. * A single optional trailing newline may be present in the input and/or output. ## Test Cases ``` input : output ``` ``` [empty string] : [empty string] ^ : w < : [empty string] > : [empty string] ><><<<>> : [empty string] >^ : w <<^> : w ^<^<^<^< : wwww ^^ : wr <^^ : wb >><<<<^^ : wo <^^^<^^^^<>^>^^>^ : wbbboooggyo ^^^^^^^^^^^^^^ : wrrryyyooowwwr <<<^<^>^<^<^<^>^^^^<^>>>>>^^<^>^^<^>^>^>^>< : wwgrwgggoooobbbbyrby ^^>^^<^^^ : wrrgggy ``` [Answer] # Perl, ~~156~~ ~~143~~ ~~134~~ ~~128~~ ~~127~~ ~~125~~ ~~120~~ ~~119~~ ~~117~~ ~~113~~ 109 bytes Includes +1 for `-p` Run with the control string on STDIN, e.g. ``` perl -p rubic.pl <<< "^^>^^<^^^" ``` `rubic.pl`: ``` @1=wryobg=~/./g;s##$n=w&$&;$y+=$x-=$y+=$x,@1[0,4,2,5,3,1]=@1while--$n%9;@{$n&&--$y%3}[3,0..2]=@1;$1[$n+9]#eg ``` ## Explanation Older version: ``` @f=gboyrw=~/./g;s##$n=w&$&;$y+=$x-=$y+=$x,@f=@f[2,4,1,3,0,5]while--$n%9;@f=@f[0,$y=1,5,2..4]if$n&&$y--<0;$f[$n+8]#eg ``` The challenge of this question is to find a coordinate system that makes it easy to track the position and direction of the ant and to still easily get the face identity. The system I chose was to put standard `(x,y)` coordinates on the face the ant is on such that the ant is always facing in the negative `y` direction with the center of the face being `(0,0)`. So: ``` rotate right: (x',y') <- (-y, x) rotate left: (x',y') <- ( y, -x) alternatve: 3 right rotations Step forward: y' <- y-1 ``` If `y` was already `-1` the ant will leave the current face and step onto the next one. In the new coordinate system there `x` keeps its value, but `y'` becomes 1. This gives an easy coordinate system within a face. I also need something for the faces themselves. There I use an array consisting of ``` The face to right of the ant g in the initial position The face to the left of of the ant b The face behind the ant o The face opposite to the ant y The face before the ant r The face the ant is on w ``` So the initial array is `(g,b,o,y,r,w)`. Moving to the next face corresponds to rotating the last 4 elements, so moving from white to red makes this `(g,b,w,o,y,r)`. Turning right is a permutation of the first 5 elements giving `(o,r,b,y,g,w)`. Turning left is a simular permutation but can also be done by turning right 3 times, so applying this permutation 3 times. And not turning at all can also be done by applying the permutation 8 times. In fact turning right can also be done by applying the permutation 5 times. Knowing this the program is rather simple: ``` @f=gboyrw=~/./g Set up the initial face orientation s## ... #eg Process each control string character {this is equivalent to s#.#...#eg because the empty regex repeats the last succesful regex) $n=w&$& Calculate n, the number of right rotations+1 modulo 9. This abuses a coincidence of the control characters: "<" & "w" = "4" -> 3 right rotations ">" & "w" = "6" -> 5 right rotations "^" & "w" = "V" = 0 but that is 9 mod 9 so leads to 8 right rtations $y+=$x-=$y+=$x, This is the same as ($x,$y)=(-$y,$x), so a right rotation of the face coordinates @f=@f[2,4,1,3,0,5] Right rotation of the face array while --$n%9 Rotate right n-1 times. After this n=0 If this was a step then n was effectively 0. So rotate right 8 times leaving n=-9 ... if $n If a step... $y-- ... decrease y ... &&$y--<0 ... but if y was already negative ... @f=@f[0,$y=1,5,2..4] ... change face and set y to 1 $f[$n+8] return the last element (current face) if this was a step, otherwise empty ``` So for that last statement rotations lead to the empty string and steps forward lead to the current face. Therefore `$_` gets replaced by the faces visited on each step. [Answer] # [Brachylog](https://github.com/JCumin/Brachylog), 287 bytes ``` :1:2222:"w":"y":["r":"b":"o":"g"]{h""|[L:I:N:A:B:[C:D:E:F]]hhM("^",(NhI,CwX,EY,B:D:A:FZ;AwX,BY,[C:D:E:F]Z),NhJ,(I1,2313O;I2,(Nh2,N$($(O;Nh1,2222O;Nbh1,3223O;3322O);3322N,2332O;3223N,2233O;2233N,3132O;2332N,3231O);IJ,AX,BY,(M"<",[C:D:E:F]$(Z,N$(O;M">",[C:D:E:F]$)Z,N$)O)),Lb:J:O:X:Y:Z:1&} ``` Expects a string containing the moves as Input, and no Output, e.g. `brachylog_main("^^>^^<^^^",_).` will write `wrrgggy` to STDOUT. ### Explanation ``` § There are 3 types of tiles we can be on: centers (noted 1), edges (2) and corners (3) § When we are on a tile, we can denote adjacent tiles in order: front, left, back, right § Similarly, we can denote the adjacent colors depending on the current one of the face § § We start on the center (1) of face white ("w"). The adjacent tiles are 4 edges (2222) § The adjacent colors of white are red, blue, orange and green ("r":"b":"o":"g") § Yellow is opposite of white ("y") § We pass those initial conditions in an array, with the sequence of moves as first § element, as input to subpredicate 1 :1:2222:"w":"y":["r":"b":"o":"g"]{...} § SUB-PREDICATE 1 h"" § If the sequence of moves is empty, terminate the recursion | § Else... § Here are the variables' names of the input (which correspond to what's described in § the first few paragraphs) [L:I:N:A:B:[C:D:E:F]] § If the move is "^"... hhM("^", § The only way we change from one face to another is if the tile we end up on is of the § same type as the tile we started from (NhI, § If this is the case CwX, § Then write the color of the face we're facing, this face will now be the § current color EY, § The third color in the list is now the opposite color B:D:A:FZ § The opposite color is now the one we face, the color behind us (the third § in the list) is the one we were on, and the other 2 don't change § If the tiles are not the same type, then we don't change color ; AwX, § Write the current color, this will remain the color BY, § Opposite color stays the same [C:D:E:F]Z), § Other colors stay in the same order since we moved forward NhJ, § The new tile type is the one we were facing (I1,2313O; § If we were on the center, then the adjacent tiles are 2313 I2, § Else if we were on an edge (Nh2,N$($(O; § then if we were facing an edge (changed face), then the new types § of tiles are a double circular permutation of the previous types Nh1,2222O; § Else if we were facing a center, then the new tiles are 2222 Nbh1,3223O; § Else (corners) if the tile to our left is the center, then 3223 3322O) § Else 3322 ; § Else if we were on a corner 3322N,2332O; § then one of those 4 possibilities applies 3223N,2233O; 2233N,3132O; 2332N,3231O) § Else if the move is NOT "^" ; IJ,AX,BY, § We stay on the same type of tile, same color, same opposite color (M"<", § if the move is "turn left" [C:D:E:F]$(Z, § Then we circular permute the adjacent colors to the left N$(O § we also circular permute the adjacent tiles to the left ;M">", § Else if the move is "turn right" [C:D:E:F]$)Z, § Then we do the same but with right circular permutations N$)O) ), Lb:J:O:X:Y:Z:1& § Recursively call sub-predicate 1 with the new input, and the next move ``` ### Equivalent SWI-Prolog code If you don't want to bother with Brachylog's compiler, you can run this solution in SWI-Prolog using the following code (this is what gets generated by Brachylog's compiler): ``` :- style_check(-singleton). :- use_module(library(clpfd)). brachylog_main(Input,Output) :- 1=1, brachylog_subpred_1([Input,1,2222,"w","y",["r","b","o","g"]],V0). brachylog_subpred_1(Input,Output) :- 1=1, brachylog_head(Input, ""). brachylog_subpred_1(Input,Output) :- 1=1, [L,I,N,A,B,[C,D,E,F]] = Input, brachylog_head([L,I,N,A,B,[C,D,E,F]], V0), brachylog_head(V0, M), ( 1=1, "^" = M, ( 1=1, brachylog_head(N, I), brachylog_write(C, X), Y = E, Z = [B,D,A,F] ; 1=1, brachylog_write(A, X), Y = B, Z = [C,D,E,F] ), brachylog_head(N, J), ( 1=1, I = 1, O = 2313 ; 1=1, I = 2, ( 1=1, brachylog_head(N, 2), brachylog_math_circular_permutation_left(N, V1), brachylog_math_circular_permutation_left(V1, O) ; 1=1, brachylog_head(N, 1), O = 2222 ; 1=1, brachylog_behead(N, V2), brachylog_head(V2, 1), O = 3223 ; 1=1, O = 3322 ) ; 1=1, N = 3322, O = 2332 ; 1=1, N = 3223, O = 2233 ; 1=1, N = 2233, O = 3132 ; 1=1, N = 2332, O = 3231 ) ; 1=1, J = I, X = A, Y = B, ( 1=1, "<" = M, brachylog_math_circular_permutation_left([C,D,E,F], Z), brachylog_math_circular_permutation_left(N, O) ; 1=1, ">" = M, brachylog_math_circular_permutation_right([C,D,E,F], Z), brachylog_math_circular_permutation_right(N, O) ) ), brachylog_behead(L, V3), brachylog_call_predicate([V3,J,O,X,Y,Z,1], V4). brachylog_behead(X,Y) :- string(X),!, sub_string(X, 1, _, 0, Y) ; number(X),!, number_codes(X,[_|T]), catch(number_codes(Y,T),_,Y=[]) ; atom(X),!, atom_codes(X,[_|T]), atom_codes(Y,T) ; X = [_|Y]. brachylog_math_circular_permutation_left(X,Y) :- string(X),!, string_codes(X,C), C = [H|T], append(T,[H],D), string_codes(Y,D) ; number(X),!, number_codes(X,C), C = [H|T], append(T,[H],D), number_codes(Y,D) ; atom(X),!, atom_codes(X,C), C = [H|T], append(T,[H],D), atom_codes(Y,D) ; X = [H|T],!, append(T,[H],Y). brachylog_math_circular_permutation_right(X,Y) :- string(X),!, string_codes(X,C), append(T,[H],C), D = [H|T], string_codes(Y,D) ; number(X),!, number_codes(X,C), append(T,[H],C), D = [H|T], number_codes(Y,D) ; atom(X),!, atom_codes(X,C), append(T,[H],C), D = [H|T], atom_codes(Y,D) ; append(T,[H],X), Y = [H|T]. brachylog_call_predicate(X,Y) :- reverse(X,R), R = [N|RArgs], number(N), reverse(RArgs, Args), ( N = 0,!, Name = brachylog_main ; atom_concat(brachylog_subpred_,N,Name) ), ( Args = [UniqueArg],!, call(Name,UniqueArg,Y) ; call(Name,Args,Y) ). brachylog_write(X,Y) :- X = [List,Format], is_list(List), string(Format),!, format(Format,List), flush_output, Y = List ; write(X), flush_output, Y = X. brachylog_head(X,Y) :- string(X),!, sub_string(X, 0, 1, _, Y) ; number(X),!, number_codes(X,[A|_]), number_codes(Y,[A]) ; atom(X),!, atom_codes(X,[A|_]), atom_codes(Y,[A]) ; X = [Y|_]. ``` [Answer] # PowerShell, 882 bytes **Usage** Save the code in a script and call it like this from the command line. Assuming working directory is the current directory. ``` .\WalkingAntcg.ps1 "^^>^^<^^^" ``` **Code** ``` $o=[char[]]"grbowy";[int]$c=4;[int]$global:x=1;[int]$global:y=1;[int]$f=1;[int]$n=5; $u={$c=$args[0];$1="341504251435240503210123".Substring($c*4,4);$2=$1*2-match".$($args[1]).";$3=$Matches[0];"$3";"012345"-replace([char[]]"$1$c"-join"|")} function t{param($o,$x,$y)if($o){switch($y){0{switch($x){0{$x=2}1{$y=1;$x=2}2{$y=2}}}1{switch($x){0{$y=0;$x=1}2{$y=2;$x=1}}}2{switch($x){0{$x=0;$y=0}1{$x=0;$y=1}2{$x=0}}}}}else{switch($y){0{switch($x){0{$y=2}1{$x=0;$y=1}2{$x=0}}}1{switch($x){0{$y=2;$x=1}2{$y=0;$x=1}}}2{switch($x){0{$x=2}1{$x=2;$y=1}2{$y=0;$x=2}}}}}$global:x=$x;$global:y=$y} ([char[]]$args[0]|%{switch($_){'^'{$global:y++;if($global:y-eq3){$global:y=0;$c="$f";$f="$n";$z=&$u $c $f;$f,$n="$($z[0][1])","$($z[1])"}$o[$c]} "<"{$z=&$u $c $f;$f,$n="$($z[0][0])","$($z[1])";t 0 $global:x $global:y} ">"{$z=&$u $c $f;$f,$n="$($z[0][2])","$($z[1])";t 1 $global:x $global:y}}})-join"" ``` **Less golfed code with explanation** ``` # Recorded order of cube colours and their indexes # Green=0,Red=1,Blue=2,Orange=3,White=4,Yellow=5 $o=[char[]]"grbowy" [int]$c=4 # Ant is currently on this colour [int]$global:x=1 # X coordinate on this face [int]$global:y=1 # Y coordinate on this face [int]$f=1 # Colour that the Ant is facing [int]$n=5 # Colour beyond that the ant is facing. # If the ant moves of this cube to the next this value becomes the one he is facing. # It is also the only colour not neighboring this current colour. # Anonymous function that will return the colour facing left and right $u = { # Cube relationships relative to position. Groups of 4 colours that are important given the order... # Green=0-3,Red=4-7,Blue=8-11,Orange=12-15,White=16-19,Yellow=20-23 # Get the colours surrounding the current colour we are on and the surrounding ones # String version: "owrygwbyrwoybwgygrbogrbo" $c=$args[0] # "341504251435240501230123" $1="341504251435240503210123".Substring($c*4,4) # double the string so that we can get the characters before and after the facing colour reliably # Assign the output to surpress a boolean. $2 is not used. Shorter than a cast $2=$1*2-match".$($args[1]).";$3=$Matches[0] # Return two values. First is the colours to the left,current and right as a string. # Second is the colour beyond the one we are facing. If we were to move forward two blocks # we would end up on this colour "$3";"012345"-replace([char[]]"$1$c"-join"|") } # function that will transpose the ants position based on right/left rotation. # Using current x and y determines what the tranposed values are and return them. function t{ param($o,$x,$y) # X = $1; Y = $2 # Left 0 Right 1 if($o){ # Right Transpose # All values are hard coded to rotate to their new positions switch($y){ 0{switch($x){0{$x=2}1{$y=1;$x=2}2{$y=2}}} # 1,1 is in the center and nothing changes 1{switch($x){0{$y=0;$x=1}2{$y=2;$x=1}}} 2{switch($x){0{$x=0;$y=0}1{$x=0;$y=1}2{$x=0}}} } }else{ # Left Transpose # All values are hard coded to rotate to their new positions switch($y){ 0{switch($x){0{$y=2}1{$x=0;$y=1}2{$x=0}}} # 1,1 is in the center and nothing changes 1{switch($x){0{$y=2;$x=1}2{$y=0;$x=1}}} 2{switch($x){0{$x=2}1{$x=2;$y=1}2{$y=0;$x=2}}} } } # Update global variables with the ones from this function $global:x=$x $global:y=$y } # Process each character passed by standard input ([char[]]$args[0]|%{ switch($_){ # Moving Forward '^'{ $global:y++ if($global:y-eq3){ # We have walked of the colour onto the next one. Update coordinates to the next colour $global:y=0 $c="$f" $f="$n" # Get the new neighboring colour indexes $z=&$u $c $f $f,$n="$($z[0][1])","$($z[1])" } # Output the colour we have just moved to. $o[$c] } # Turn Left "<"{$z=&$u $c $f;$f,$n="$($z[0][0])","$($z[1])" # Transpose the ants location by passing current location to the transposition function. t 0 $global:x $global:y } # Turn Right ">"{$z=&$u $c $f;$f,$n="$($z[0][2])","$($z[1])" # Transpose the ants location by passing current location to the transposition function. t 1 $global:x $global:y } } }) -join "" # Line above converts the output to a single string. ``` Using a lot of single letter variables used to records the ant current state (colour,position and orientation). The ant is always facing up. When a rotate instruction is read the cube is transposed in that direction. Hardcoded transposition matrices used to determine new position based on current position. Code satisfies all examples in question. [Answer] # Tcl/Tk, 422 bytes ``` rename split S array se {} [S wyywroorgbbg {}] proc R a {foreach x [lassign $a y] {lappend b $x} lappend b $y} proc < {V H} {set ::H $V set ::V [lreverse [R $H]]} proc > {V H} [string map {V H H V} [info b <]] proc ^ {V H} { lassign $V x lassign [set ::V [R $V]] y set ::H [string map "$x $y $::($x) $::($y)" $::H] puts -nonewline $y} set V [S wwrrryyyooow {}] set H [S wwgggyyybbbw {}] foreach p [S {*}$argv {}] {$p $V $H} ``` Alas, I can't get it any smaller. Non-obfuscated version: ``` array set opposites [split wyywroorgbbg {}] proc lrotate xs { foreach x [lassign $xs y] { lappend ys $x } lappend ys $y } proc < {V H} { set ::H $V set ::V [lreverse [lrotate $H]] } proc > {V H} { set ::H [lreverse [lrotate $V]] set ::V $H } proc ^ {V H} { lassign $V x lassign [set ::V [lrotate $V]] y set ::H [string map [list $x $y $::opposites($x) $::opposites($y)] $::H] puts -nonewline $y } set V [split wwrrryyyooow {}] set H [split wwgggyyybbbw {}] foreach p [split {*}$argv {}] {$p $V $H} puts {} ``` It works by maintaining a list of horizontal and vertical cell colors. ^ < and > are all commands that properly permute the lists. The current cell is the first in each list. [Answer] # Ruby, 132 ``` m=?w g="bgoyr" x=z=1 gets.bytes{|c|(m,g[2,3]=g[4],m+g[2,2]if(x+=1)%3<1 $><<m)if 93<c.upto(64){x,z,g=2-z,x,g[4]+g[2]+g[0]+g[3]+g[1]}} ``` This position system is sadly very similar to other answers out there. `x` and `z` track your position on the current face with `+x` being the direction of travel. Forward is always `x+=1`, and the bounds of each face are divisible by 3 (we don't care the number, just its modulus with 3). `m` is the current face (this saves some bytes) `g` is arranged `[left, right, behind, opposite, front]` so that we don't need to change `g[0..1]` on `^` `<` is done simply by doing `>` three times. [Answer] # Java, ~~619~~ ~~605~~ ~~534~~ ~~517~~ 485 bytes Well, here goes nothing... At least it beat powershell! -14 bytes thanks to @KevinCruijssen And over 6 years later, -71 bytes (wow!) thanks to @ceilingcat . [Try It Online!](https://tio.run/#%23TVLBbtwgEP0V14fI1NjCeFOpsNiqeu4pR8uWWK83JtlgBGyiletv3w5kFfUCT@/NMG@GeZHvsljMpF@Or7fxLJ1L/kil19uTt0o/Jz67gxNalfbJ3PViJZjgasPmE1NMNqy7HivssOX3@EWkKT5CRPqBn7HFB7zga1o6c1Y@S3GK@Gmx2ThLm4zsVPrlN8Bf1sprhtBqhc0M4lrMXJ2yUYifO7SGBCeUqLkqioZwBNLcqV4IA@dDOL4JglbdVb2wQpC2qBjcj23FAsd1R6JQtZGvgx44EGgU6D1jFzNoz6EcP9hJvvJNCRIthylIphGUy/M@FzI4dPsazZ3rIWbJxbEL7nu@OWGbonqwe9pSZhsKKJghXIVq9d9oLigElDoqVoR3eOwL@v5B2yw@HPsJLCPoOyksCyJpbf6fXHzpLCC@2clfrE4WcA@uo/euNzDeT95A703V1iyAfRHGYmBOQJEIAvUIiAaKsh3fbuZyOKsxcV56uN4XdUzeYF/uW9L1Dq1PV@ent3K5@NIA6TM9fcSlylAJXz8MzTDsh2FIEeLbdvsH) And less than a year after that, @ceilingcat saved another 17 bytes. [Try It Online!](https://tio.run/##TVLBbtswDP0Vz4fCWmRDlpMBs0wbw8479SjIgJsmtbpUFiSlReD52zPKSYddqIf3SJF84OvwPuSTPZjX59/X/WnwPvk1aDNfH4PT5iUJ2R0cyaxNSEapYGaU0XKh9oY5ZQs1UlFNPXXinj9Bmorj5LJYta@PRZh@joP74dxwyQiZHbjMEmFgFPqY7QG@b8kc8z1oqITO85YJgtIotQKwGB9i@AKMzEaWClxTdnlZu3bblXVkhJEMaYASCXyqKEcOBb4KfC0AuFVwJbCZ0MDE8jnpUBti5Waj1QaGOJlvKjJKrzBp2kD6QV@oo090ope08PakQ5bSlMi4jBKLjl2qPxh2HcfR2INrKmzGhAP8BVybl0jxVeSIdlFUYl0STfjGu2zthj@wLrI1I19Z7uooss5t/pPzf3odkVjcIZydSSacA1dZF5LKotc33qIVbdlVdQRNHl2yaBtSbAWR2iHikeL1VixXe3466X3iwxDweZ/0c/KG53E/Cqk8mR8vPhzeiukcCotkyMzhY72hjBRoTt@3fd/0fZ8SIpbl@hc) OK @ceilingcat saved another 32 bytes, marking this as community wiki so they can make further edits. [Try It Online!](https://tio.run/##VVJdj5swEPwrlIcTTnBkQ1LpMAuq@tyne7SMxHHJ4fswaHHuFFF@e7rm0kp9WY9mx@sZ2y/tR8uH8ehenl6v3Vs7TdGv1rr5@uDRuufIJzdwYrN1Puq1gVmkIpVLOn7hLBVL6rRJbTqlqG76AeJYnQZMwq6uOO388LNv8Qdie0kYmxEwGZly0Ct7SjqA@z2bg34CC7mynFdCMWr12hqAkepdKN9AsJk0ymlpAEtZc1lgta9lERhlIeMYRtqNBZDMaWFITcR2@4/KDHDiQKjlr8W2cGzUpDFbaIN8KnPW68mQaNhC/PmMj8Ml/j@GDhmMWiwgQP6byqHOyI24wzInR0Ih0AzAikuisrWZETqEplEdh@9yzb/pgrN5PZDGiDrE3nQ0Yc3PcdOpZcGjP6OLBjqRLK/GtRnpMleey2qktDQ6LJWscwIyALGCksv6QCgLVFbs1XIdz49vtosm33paPgb7FL3T898eXZuJzQ@XyR/fd8PZ70YifeKOn@sfSdjOJ3HTVE1TNk0TM0YOr38A) ``` String t(String f){int h[]={0,0,1},p[]={0,2,0},n[],i,s,r;String o="";for(int c:f.toCharArray()){r=r(p);n=h;if(c==94){for(s=i=3;i-->0;)if(h[i]==p[i]&p[i]!=0){s=i;n[1]=r<1?-1:r>4?1:n[1];i=2-r;if(i*i==1)n[0]=i;if(++i*i==1)n[2]=-i;i=0;}for(int a:n)p[++i]+=a;if(s<3)h[s]=0;o+="wgrboy".toCharArray()[r(p)];}i=r==3|r==5?2:r>0&r<3?1:0;r=h[s=r>-1&r<2?2:r>2&r<5?1:0];c-=61;if(c*c==1){h[s]=r==0?h[i]*c:0;h[i]=-r*c;}}return o;}int r(int[]p){return-1>p[0]?1:p[0]>1?3:p[1]>1?0:p[1]<-1?5:p[2]>1?2:4;} ``` ## Explanation: Unlike some of the other answers, which used used a 2-d coordinate system, I used a 3-d system to keep track of where the ant was. The direction was also kept in a 3-d fashion to facilitate switching sides and movement. Each face had one of the coordinates, x, y, or z, be set to 2 (or -2 for the opposite face) to signify which face it was. Switching faces was accomplished by checking if the ant was about to go off (position and heading have a value that is same, but not 0), make sure it would "fall off" diagonally onto the next, and change the heading to be non-diagonal. This was surprisingly easy. Turning was more difficult. Making sure it would always go the same direction required an extra if-else statement inside the check for each character, costing me many bytes. In addition, the "up" and "right" axes had to be hard-coded in for each side. ## Original ungolfed code (Unchanged from previous edits for clarity in method) ``` private static String[] sides="w,g,r,b,o,y".split(","); public static String traverse(String commands) { int[] heading = {0,0,1}; int[] pos = {0,2,0}; int[] newheading; int i; int saved; String out = ""; for(char command:commands.toCharArray()) { if(command=='^') { newheading=heading; saved=3; for(i=0;i<3;i++) { if(heading[i]==pos[i]&pos[i]!=0) { saved=determineSide(pos); if(saved==0)newheading[1]=-1; if(saved==1)newheading[0]=1; if(saved==2)newheading[2]=-1; if(saved==3)newheading[0]=-1; if(saved==4)newheading[2]=1; if(saved==5)newheading[1]=1; saved=i; break; } } i=0; for(int c:newheading) { pos[i++]+=c; } if(saved<3)heading[saved]=0; out+=sides[determineSide(pos)]; } newheading=getPlane(determineSide(pos)); if(command=='>') { saved=heading[newheading[0]]; if(saved==0) { heading[newheading[0]]=heading[newheading[1]]; heading[newheading[1]]=0; } else { heading[newheading[1]]=-saved; heading[newheading[0]]=0; } } if(command=='<') { saved=heading[newheading[0]]; if(saved==0) { heading[newheading[0]]=-heading[newheading[1]]; heading[newheading[1]]=0; } else { heading[newheading[1]]=saved; heading[newheading[0]]=0; } } } return out; } public static int determineSide(int[] pos) { return pos[0]==2?3:pos[0]==-2?1:pos[1]==2?0:pos[1]==-2?5:pos[2]==2?2:4; } public static int[] getPlane(int side) { int[] out=new int[2]; out[0]=side==0|side==1?2:side==3|side==4?1:0; out[1]=side==3|side==5?2:side==1|side==2?1:0; //side==0?{2,0}:side==1?{2,1}:side==2?{0,1}:side==3?{1,2}:side==4?{1,0}:{0,2}; return out; } ``` ]
[Question] [ # Background As most PPCG regulars will know, a [quine](/questions/tagged/quine "show questions tagged 'quine'") is a program which outputs its own source code when run; and the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between two strings is the minimum number of insertions, deletions, and edits needed to change one string into the other. In this challenge, we're combining the two concepts into a "levenquine": a program that outputs its own source code, but with one instance of one character inserted, deleted, or replaced with a different character. (In other words, the Levenshtein distance between the program and its output is 1.) # The task Write a levenquine such that its output is a levenquine, the output of that program is also a levenquine, and so on. Additionally, at some point, the sequence of repeatedly running the program, running its output, running its output's output, etc. must eventually come back to the original program. There's one additional restriction that makes things much harder: there must be two distinct programs somewhere within this cycle which have no characters in common (in other words, there's no character that exists within one program and also exists within the other program). Your program is therefore going to have to gradually transform itself into a different character set, and back again. If you're using a programming language which has unavoidable boilerplate that's required in any program that produces output (e.g. it only has one way to write a `print` statement and no other useful forms of output), you may treat that boilerplate as nonexistent for the purpose of determining which characters two programs have in common. You must, however, still count that boilerplate for the purpose of determining the Levenquine property of the code. # Clarifications * Each of the "programs" in the cycle can be either a full program or a function. They don't all have to be the same, e.g. some could be full programs and some could be functions. * Not all the programs in the cycle need to use the same form of output. For example, some could output via standard output, and some could output via standard error. * Your programs will be run with no input (or in languages which require input to do anything at all, the simplest possible input). * [Proper quine rules](http://meta.codegolf.stackexchange.com/questions/4877/what-counts-as-a-proper-quine?answertab=votes) apply; although a Levenquine is not a true quine, you may not do anything that would be illegal when writing a proper quine. In particular, the null program is never valid output from a proper Levenquine (and thus cannot be part of your cycle). * The Levenquine restriction is measured in terms of characters, rather than bytes (e.g. `ê` is one character even when the source is encoded in UTF-8). The no-characters-in-common restriction is also measured in terms of characters. The victory condition, however, counts in bytes. # Victory condition Please submit at least the following three programs from the cycle: the shortest program (measured in bytes); and two programs from the cycle that have no characters in common. It's possible that two of these are the same, and it's also possible that all three are distinct. The score is based on the length in bytes of the shortest program, with shorter being better, thus making this a kind of [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") competition. [Answer] # [Gol><>](https://github.com/Sp3000/Golfish), ~~252~~ 167 bytes ``` 1>'r&ff9++r}}r&f*bc++1z.r}r6=z?Hzznr6rHr}r:ee+6+=z9*5c*+1z . }&z+5c*&H}rebe*b+ke++rHS6PWSb`S6P$$1W5/11b6W6EE/W6EE`S6P$$W61`S6P5W6$5_61P1WW_b_ ``` [Try it online!](https://tio.run/##LYwxC8IwFIQ390wpdLBDqZAHLW/IgwrVqZCx0CFjJSVRURTiFshvj6nIDfd9cNz1/XT3zy0lPB1841wP4GPMJMwKgKH10dMQziqElyevsh6tBYIh9EKuIk@qtopNgCyNit4aKww8bP5R@5kmVrJSz@aycV0z1KXsEDnLMcQKTePYMb7Vf6Kp4PhjyTau5UI4odZ8McsupS8 "Gol><> – Try It Online") And the mutually distinct ([Verification](https://tio.run/##TY0xb4JAGIa3Dm5MmDiUNIQqBOzVcsaqrbERiIZEMJY0HawINk1RG@hSLBhcmnRgJPHv3B@jd1bT5hu@533vubs31/dgni8@GNZ7WbqAaTPP7nu50iwcq8u/qhBMj540Wy1saUR6psxVDuq/tpnn4Obc5@bzhiD4UYSJt2eCAELJj3zYDm@1MFz60NdwvHZdAQrtsMHLMx4rjMREXCjgwGmR79oubwuvLn5HOx3BIVWiStbIfiLMshSwSnIVAJrCY0OqaMFer0rRZB0UCxZpsGeZIszKEwiGwLLoiT05KVy07lDaRVu0HasqStEOD8lKvFFVHWX9fZeaDyh7dFCG5xsnlDq//T1KUKKaKj4eK8ZGIVda/RbadVGm4tx1iIWSGCVKrKIvLONfnObK9MS6WA9W8SfhTkfUg7ox0PWaiCc2xavAnE4HYo2sgxKYVzV9z4ZIuGOsTd3Tg6C2jtdnPw)) program: ``` 0<CŽB‚‚UGGŽ™™ŽB‚F~GGM–JŽ™ŽRY–[d––ŠŽRŽdŽ™ŽVGRGY–UFQFGM–<J<™B–GQFBd™Ž~F~G‡GGŽd;oRl-7-7so~|;oRl@@-Ms7QKMM3-3-3~R-4sRaaK-3sRaa|;oRl@@sR43M|;oRlQ-sR43@Q{RMlMss3{~{" ``` [Try it online!](https://tio.run/##LY29CsMwDITfpbuh4ECGZggpWJDiwYYUSqeA6Q8EMnhMcXCWQgePhryOXsyV03KD7k6f0H0cbk/7SGlfHTE0uODSAWDAlZSzcDOAxNhuXdAXjFeDkfShhMH8@jN69KCB1p1Qs8gnVVvh2mAEyo3JFHqHXjjAN8H0xRxGPbCSlXZ0r@zrmklbqpOUnJGcZoXVfX9iPI8/YnXB5eYVy75Wk5aDtJZPbtql9AU "Gol><> – Try It Online") This is mostly inspired by my answer to the [Mutually Exclusive Quines](https://codegolf.stackexchange.com/a/153965/76162) challenge, with kudos also going to [Bubbler's Gol><> answer](https://codegolf.stackexchange.com/a/164024/76162). Here is a [verification program](https://tio.run/##ZVFBT9swFL5NIrecisRhb4BIUocEszWIomyHCalHpB56qKrOSR1iaGLzbChU6v56Z6etNmnKwd/73vc9P39RH6aW7dftGfxEvhAGjIRxzXEpy@fbQANr9YojMAO1MUoP07SUC/4ol1WiDSuf@XtZs/aRJ6VsUpZmN99usvQmo9m1t@AVLPlbqOKXaOhBky95G75Ed5ijc9z1WZxj2BAa3RX5lM76l78bDyqJIEC0gKHTq8h5O/ZpxzbRsJg@ETrLKWlEG7KuiC03iy2eXYZqKmZ5/mJxFFkvi4u8iKeCXO@vQG5esQU2bWZb0SiJBvSHjkFqr1saX9u5QvmIrAnda@0GRythapDKbhQ4KoghWAURMA3VEKpkhcLwndg72s@XOlGd41TtQoZUKpO67ISuU43lASfqA5z3NEqQs0UYeZ4rIXd72ZwXoj00Wv5uLO/ankL@ZnEQeMIeV553tqrFkkPHf9mJht7f6FzqIb266hLdm908W@3H/vtyJ3DxLYS2ne5HWibupFE3QLQmPFRMa25z7MQ50P8uEEAcvd3S7wFeVNUtIbjZWNQvSkLoOsENZvn6x2i9bjHDkS2HnJOM5Ovb/qDsWwkksLlYE1tcjDbIC94vyDO3c0afx9mDf@KfTMbFL4fPz306ORmklPZ8@xWZfzzJ7u9Tv@eOvWSSHfdohwe@w@eDeUYf6GTSmxfzT38A) you can run. Unfortunately, it times out, but you can watch how one section of code builds the other section and then you can copy the last version printed and paste it into the input to continue. Eventually, you'll reach the first program you put in. ### Explanation Both sections of code are composed of two sections, the actual executing part and the data containing the other section of code. They both function practically identically: They depend on a flag (the first character of the code, either `1` or `0`). If the flag is set, they will start building the other section of code by taking the 252th character down, adding/subtracting `28` from it and appending it to the code. For example, here are the first two iterations of the code after the first program above: ``` 1>'r&ff9++r}}r&f*bc++1z.r}r6=z?Hzznr6rHr}r:ee+6+=z9*5c*+1z . }&z+5c*&H}rebe*b+ke++rHS6PWSb`S6P$$1W5/11b6W6EE/W6EE`S6P$$W61`S6P5W6$5_61P1WW_b_C 1>'r&ff9++r}}r&f*bc++1z.r}r6=z?Hzznr6rHr}r:ee+6+=z9*5c*+1z . }&z+5c*&H}rebe*b+ke++rHS6PWSb`S6P$$1W5/11b6W6EE/W6EE`S6P$$W61`S6P5W6$5_61P1WW_b_CŽ ``` Eventually when it reaches the end of the current section, it flips the second character of the code (`<` to `>` and back again) to point to the other section. Here are both sections together, about to switch from executing the first section to executing the second. ``` 1>'r&ff9++r}}r&f*bc++1z.r}r6=z?Hzznr6rHr}r:ee+6+=z9*5c*+1z . }&z+5c*&H}rebe*b+ke++rHS6PWSb`S6P$$1W5/11b6W6EE/W6EE`S6P$$W61`S6P5W6$5_61P1WW_b_CŽB‚‚UGGŽ™™ŽB‚F~GGM–JŽ™ŽRY–[d––ŠŽRŽdŽ™ŽVGRGY–UFQFGM–<J<™B–GQFBd™Ž~F~G‡GGŽd;oRl-7-7so~|;oRl@@-Ms7QKMM3-3-3~R-4sRaaK-3sRaa|;oRl@@sR43M|;oRlQ-sR43@Q{RMlMss3{~{" ``` [Try it online!](https://tio.run/##LY1Ba8IwGIZvu@dUwcNkiIOGKqE24qabKDZFKdiKK2MHZ23dxmRCeqtrpV4GO/RY8O98f6xLnLyH73m/PEnedtvNR/ReluThljc2my7GPEkEqf4aYxI3ecJpP3604viLU26JeheGmOJ@3FWNtSqUWrOWNGIsSsNKeOiHqo8/Q/GOdT2nM1RFVW/uv0qu1xHxqkaLEAWJ@BRVPDoet5Aix0XxaEUhZzaQ5LqxpGRGPE9Z@surEeRDOMJxwRjkcBKR3UwPjNlQTM673H2G4iWAQuRXNMiD//0TZJAxl4njhekcTHmlN@nBaQgFE30YSAuyFDIzZfAjZPFLcL9zt1pH60S79FvyYKDZUceZ2rauiaSu1o7c1Wqq6XJclMht6/aZHU3ywNm79taOIn2f7m/K8g8 "Gol><> – Try It Online") The flags are the opposite for each section, so the newly executing section will start deleting the other section of code until it reaches its own code. At this point, it flips the flag and the cycle repeats again. ]
[Question] [ Write a program (or function) that takes in a non-empty string of any [printable ASCII](https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) characters. Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of characters linked by: * `/` if the first character occurs before the second character in normal ASCII order. e.g. ``` B / A ``` * `\` if the first character occurs after the second character in normal ASCII order. e.g. ``` B \ A ``` * `-` if the first and second characters are the same. e.g. ``` A-A ``` So the output for `Programming Puzzles & Code Golf` would be ``` o / \ r z-z o e G l / \ / \ / \ / \ / \ P o r m-m n u l s & C d f \ / \ / \ / \ / \ / \ / \ / g a i g P e \ / ``` If there is only one character in the input string the output would just be that character. Your program should treat , `/`, `\`, and `-` just the same as all other characters. e.g. `-\//-- \ //-` should produce: ``` \ / \ - /-/ / \ - --- \ /-/ \ / \ / \ - \ ``` There should be no extraneous newlines in the output except for a single optional trailing newline. (Note that the empty line in the example just above holds the last space in the the string and is therefore not extraneous.) There may be trailing spaces on any lines in any arrangement. **The shortest code in bytes wins.** One more example - Input: ``` 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 ``` Output: ``` 9 9 8 6 6 / \ / \ / \ / \ / \ 9 6 8 7 3 3 4 2 4 8 9 8-8 / \ / \ / \ / \ / \ / \ / \ 4 5 2 5 5 2 3-3 3 7 5 2 4 9 9 9-9 7 / \ / \ / \ / \ / \ / \ / \ / \ / \ 3 1 1 3 2 0 1 7 6 3 3 5 8 8 6 \ / \ / \ / \ / \ / \ . 1 1 5 2 9 9 3 7 1 4 6 8 9 \ / \ / \ / \ / \ / \ / \ / \ / 0 0 7 9 5 2 0 0 2 6 9-9 8 5 4 7 \ / \ / \ / \ / \ / \ / \ / 4 4-4 2 8 8 4 2 3 2 7 6 \ / \ / \ / \ / 0 6 8 3 1-1 0 \ / \ / 2 0 ``` [Answer] # Pyth, 69 bytes ``` aY,JhzZVtzaY,@"-\/"K-<NJ>N~JN=+ZKaY,N=+ZK;jbCmX*\ h-e=GSeMYhG-edhGhdY ``` [Demonstration.](https://pyth.herokuapp.com/?code=aY%2CJhzZVtzaY%2C%40%22-%5C%2F%22K-%3CNJ%3EN~JN%3D%2BZKaY%2CN%3D%2BZK%3BjbCmX*%5C+h-e%3DGSeMYhG-edhGhdY&input=++-%5C%2F%2F--+%5C+%2F%2F-+&debug=0) Longer inputs still work, but they don't look very good in the fixed-width output box. I start by constructing a list, in `Y`, of [character, height] tuples. It is `[['P', 0], ['/', -1], ['r', -2], ['\\', -1], ['o', 0], ['\\', 1], ['g', 2]]` early on in the `Programming Puzzles & Code Golf` example. I then make strings of spaces of the appropriate length, insert the character at the appropriate location, transpose, join on newlines and print. [Answer] # Julia, 297 bytes ``` s->(l=length;d=sign(diff([i for i=s]));J=join([[string(s[i],d[i]>0?:'/':d[i]<0?:'\\':'-')for i=1:l(d)],s[end]]);D=reshape([d d]',2l(d));L=l(J);E=extrema(cumsum(d));b=2sumabs(E)+1;A=fill(" ",L,b);c=b-2E[2];for (i,v)=enumerate(J) A[i,c]="$v";i<l(D)&&(c-=D[i])end;for k=1:b println(join(A'[k,:]))end) ``` Ungolfed: ``` function f(s::String) # Get the direction for each slash or dash # +1 : /, -1 : \, 0 : - d = sign(diff([i for i in s])) # Interleave the string with the slashes as an array t = [string(s[i], d[i] > 0 ? '/' : d[i] < 0 ? '\\' : '-') for i = 1:length(d)] # Join the aforementioned array into a string J = join([t, s[end]]) # Interleave D with itself to duplicate each element D = reshape(transpose([d d]), 2*length(d)) # Get the length of the joined string L = length(J) # Get the maximum and minimum cumulative sum of the differences # This determines the upper and lower bounds for the curve E = extrema(cumsum(d)) # Get the total required vertical size for the output curve b = 2*sumabs(E) + 1 # Get the beginning vertical position for the curve c = b - 2*E[2] # Construct an array of spaces with dimensions corresponding # to the curve rotated 90 degrees clockwise A = fill(" ", L, b) # Fill the array with the curve from top to bottom for (i,v) = enumerate(J) A[i,c] = "$v" i < length(D) && (c -= D[i]) end # Print out the transposed matrix for k = 1:b println(join(transpose(A)[k,:])) end end ``` [Answer] # Javascript (ES6), ~~360~~ ~~331~~ ~~316~~ 302 bytes Here's my fourth attempt: ``` s=>{r=[],c=s[m=w=n=0];for(i in s)(i?(d=s[++i])>c?++n:c>d?--n:n:n)<m&&m--,n>w&&w++,c=d;for(i=0,n=w*2;i<(w-m)*2+1;r[i++]=[...' '.repeat(l=s.length*2-1)]);for(i=0;i<l;i++)i%2?(A=s[C=(i-1)/2])<(B=s[C+1])?r[--n,n--][i]='/':A>B?r[++n,n++][i]='\\':r[n][i]='-':r[n][i]=s[i/2];return r.map(x=>x.join``).join` `} ``` Not as short as some of the others, but I'm satisfied with it for now. Oh, so you want to test it? Alright, here you go: ``` z=s=>{r=[],c=s[m=w=n=0];for(i in s)(i?(d=s[++i])>c?++n:c>d?--n:n:n)<m&&m--,n>w&&w++,c=d;for(i=0,n=w*2;i<(w-m)*2+1;r[i++]=[...' '.repeat(l=s.length*2-1)]);for(i=0;i<l;i++)i%2?(A=s[C=(i-1)/2])<(B=s[C+1])?r[--n,n--][i]='/':A>B?r[++n,n++][i]='\\':r[n][i]='-':r[n][i]=s[i/2];return r.map(x=>x.join``).join('<br>')}; input=document.getElementById("input"); p=document.getElementById("a"); input.addEventListener("keydown", function(){ setTimeout(function(){p.innerHTML = "<pre>"+z(input.value)+"</pre>";},10); }) ``` ``` <form>Type or paste your text here: <input type="text" id="input"/></form> <h3>Output:</h3> <p id="a"></p> ``` Have fun! ### Updates: **Update 1:** Golfed off 29 bytes with a variety of typical techniques. **Update 2:** Golfed off 15 more bytes by building the string horizontally from the start, as opposed to building an array of the vertical strings and switching them around, which is what it did before. **Update 3:** Saved 14 more bytes. More golfiness coming soon! [Answer] # Python, 393 bytes ``` def z(n,h=[]): for j in range(len(n)):h.append(sum(cmp(ord(n[i]),ord(n[i+1]))for i in range(j))) h=[j-min(h)for j in h] for y in range(max(h)*2+2): s="" for x in range(len(n)): if h[x]*2==y:s+=n[x] else:s+=" " if x==len(n)-1:continue c=" " if h[x]<h[x+1]and h[x]*2==y-1:c="\\" if h[x]>h[x+1]and h[x]*2==y+1:c="/" if h[x]==h[x+1]and h[x]*2==y:c="-" s+=c print s ``` Run as: `z("Zigzag")` [Answer] # JavaScript (ES6), 202 Using template strings. Indentation spaces and newlines not counted, except the last newline inside backticks that is significant and counted. Usual note: test running the snippet on any EcmaScript 6 compliant browser (notably not Chrome not MSIE. I tested on Firefox, Safari 9 could go) ``` f=z=> [...z].map(c=> (d=0,x=w+c,p&&( c<p?o[d=1,g='\\ ',r+=2]||o.push(v,v) :c>p?(d=-1,g='/ ',r?r-=2:o=[v,v,...o]):x='-'+c, o=o.map((o,i)=>o+(i-r?i-r+d?b:g:x),v+=b) ),p=c) ,v=w=' ',o=[z[p=r=0]],b=w+w)&&o.join` ` Ungolfed=z=> ( v=' ',o=[z[0]],r=0,p='', [...z].map(c=>{ if (p) { if (c < p) { if (! o[r+=2]) o.push(v,v) o = o.map((o,i)=>o+(i==r ? ' '+c : i==r-1 ? '\\ ' : ' ')) } else if (c > p) { if (r == 0) o = [v,v,...o] else r -= 2 o = o.map((o,i)=>o+(i==r ? ' '+c : i==r+1 ? '/ ' : ' ')) } else { o = o.map((o,i)=>o+(i==r ? '-'+c : ' ')) } v += ' ' } p = c }), o.join`\n` ) out=x=>O.innerHTML+=x+'\n' test = [ "Programming Puzzles & Code Golf", "-\\//-- \\ //- ", "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"] test.forEach(t=>out(t+"\n"+f(t))) ``` ``` <pre id=O></pre> ``` [Answer] # CJam, 79 bytes ``` l__0=\+2ew::-:g_0\{+_}%);_$0=fm2f*_$W=)S*:E;]z{~\_)"/-\\"=2$@-E\@t@@E\@t}%(;zN* ``` [Try it online](http://cjam.aditsu.net/#code=l__0%3D%5C%2B2ew%3A%3A-%3Ag_0%5C%7B%2B_%7D%25)%3B_%240%3Dfm2f*_%24W%3D)S*%3AE%3B%5Dz%7B~%5C_)%22%2F-%5C%5C%22%3D2%24%40-E%5C%40t%40%40E%5C%40t%7D%25(%3BzN*&input=%20%20-%5C%2F%2F--%20%5C%20%2F%2F-%20) This builds the output column by column, and transposes the result at the end to get the output row by row. This was quite painful overall. Explanation: ``` l__ Get input and create a couple of copies. 0=\+ Prepend copy of first letter, since the following code works only with at least two letters. 2ew Make list with pairs of letters. ::- Calculate differences between pairs... :g ... and the sign of the differences. _0\ Prepare for calculating partial sums of signs by copying list and pushing start value 0. { Loop for calculating partial sums. +_ Add value to sum, and copy for next iteration. }% End of loop for partial sums. We got a list of all positions now. ); Pop off extra copy of last value. _$0= Get smallest value. fm Subtract smallest value to get 0-based positions for letters. 2f* Multiply them by 2, since the offsets between letters are 2. _$W= Get largest position. ) Increment by 1 to get height of result. S* Build an empty column. :E; Store it in variable E. ] We got the input string, list of relative offsets, and list of absolute positions now. Wrap these 3 lists... z ... and transpose to get triplets of [letter offset position]. { Loop over triplets. ~ Unwrap triplet. \ Swap offset to front. _) Copy and increment so that offset is in range 0-2. "/-\\" List of connection characters ordered by offset. = Pick out connection character for offset. 2$@ Get position and copy of offset to top. - Subtract to get position of connection character. E Empty column. \@ Shuffle position and character back to top. Yes, this is awkward. t Place connection character in empty line. Done with first column. @@ Shuffle letter and position to top. E Empty column. \@ Stack shuffling again to get things in the right order. t Place letter in empty line. Done with second column. }% End of main loop for triplets. (; Pop off first column, which is an extra connector. z Transpose the whole thing for output by row. N* Join with newlines. ``` [Answer] ## Perl 5, ~~230~~ 214 ``` @A=split(//,pop);$y=$m=256;map{$c=ord$_;$d=$c<=>$p;$t=$d>0?'/':$d<0?'\\':'-';$B[$x++][$y-=$d]=$t;$B[$x++][$y-=$d]=$_;$m=$y,if$m>$y;$M=$y,if$M<$y;$p=$c}@A;for$j($m..$M){for$i(1..$x){$s.=$B[$i][$j]||$"}$s.=$/}print$s ``` ### Test ``` $ perl zigzag.pl "zigge zagge hoi hoi hoi" z \ i \ g-g \ e z g-g o o o \ / \ / \ / \ / \ / \ a e h i h i h i \ / \ / \ / $ ``` [Answer] # K, 86 ``` {-1@+((d#\:" "),'1_,/("\\-/"1+e),'x)@\:!|/d:(|/b)+-:b:1_+\,/2#'e:{(x>0)-x<0}@-':6h$x;} ``` . ``` k){-1@+((d#\:" "),'1_,/("\\-/"1+e),'x)@\:!|/d:(|/b)+-:b:1_+\,/2#'e:{(x>0)-x<0}@-':6h$x;} "Programming Puzzles & Code Golf" o / \ r z-z o e G l / \ / \ / \ / \ / \ P o r m-m n u l s & C d f \ / \ / \ / \ / \ / \ / \ / g a i g P e \ / ``` Ungolfed: ``` f:{ dir:{(x>0)-x<0}-':[*a;a:"i"$x]; //directional moves (-1, 0, 1) chars:1_,/("\\-/"1+dir),'x; //array of input string combined with directional indicators depths:(|/b)+-:b:1_+\,/2#'dir; //depth for each char, normalised to start at 0 -1@+((depths#\:" "),'chars)@\:!|/depths; //Pad each character by the calculated depths, extend each string to a uniform length and transpose } ``` [Answer] ## Ruby, 158 Saved 6 bytes thanks to [histocrat](https://codegolf.stackexchange.com/questions/55593/zigzagify-a-string/55724?noredirect=1#comment137246_55724). Thanks! ``` ->s,*i{i[x=n=k=(4*m=s=~/$/).times{i<<' '*m}/2][j=0]=l=s[/./] $'.chars{|c|i[k-=d=c<=>l][j+1]=%w{- / \\}[d] i[k-=d][j+=2]=l=c n,x=[x,n,k].minmax} puts i[n..x]} ``` [Answer] ## Python with Numpy: 218 bytes It is worth it to waste 19 bytes for importing numpy. Golfed: ``` from numpy import* z=zip r=raw_input() s=sign(diff(map(ord,r[0]+r))) c=cumsum(s) p=2*(max(c)-c)+1 for L in z(*[c.rjust(i).ljust(max(p))for _ in z(z(p+s,array(list('-/\\'))[s]),z(p,r))for i,c in _][1:]):print''.join(L) ``` Ungolfed: ``` from numpy import * letters = raw_input() #letters = 'Programming Puzzles & Code Golf' s = sign(diff(map(ord, letters[0] + letters))) c = cumsum(s) lines = array(list('-/\\'))[s] letter_heights = 2 * (max(c) - c) + 1 line_heights = letter_heights + s columns = [symbol.rjust(height).ljust(max(letter_heights)) for pair in zip( # interleave two lists of (height, symbol) pairs... zip(line_heights, lines), zip(letter_heights, letters) ) for height, symbol in pair # ... and flatten. ][1:] # leave dummy '-' out for row in zip(*columns): print ''.join(row) ``` ]
[Question] [ # Task Your task is to write a function or a program in a language of your choice that analyzes a couple of statements and determines whether it can be concluded from those statements that pigs are able to fly. # Input The input is a String that can be read from STDIN, taken as a function argument or even be stored in a file. The input can be described using the following EBNF: ``` input = statement , {statement}; statement = (("Pigs are ", attribute) | ("Everything that is ", attribute, "is also ", attribute)), ". "; attribute = [not], ("able to fly" | singleAttribute); singleAttribute = letter, {letter}; letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ; ``` **Example input (see more examples below):** ``` Pigs are green. Everything that is green is also intelligent. Everything that is able to fly is also not intelligent. Pigs are sweet. ``` # Output The output can be returned by your function, be written to a file or print to STDOUT. There are 5 different cases to be handled: 1. The given statements are valid, consistent and have as a logical consequence that pigs can fly. In that case, you must output `Yes`. 2. The given statements are valid, consistent and have as a logical consequence that pigs can not fly. In that case, you must output `No`. 3. It can not be concluded from the given, valid and consistent statements whether pigs can fly or not. In that case, you must output `Maybe`. 4. The given statements are valid, but not consistent (i.e. there's a contradiction in the given statements). Since *ex falso quodlibet*, we decide to output `Yes` in that case. 5. The given statements are not valid, i.e. they are not formatted according to the given EBNF. In that case, you may do whatever you want. # Details * You may assume that the given attributes are independent from each other. So, for example, a pig may be young and old, green, red and blue at the same time without causing any inconsistency. However, a pig may not be 'green' and 'not green' at the same time, that's a contradiction and should be handled as described in (4). * For every attribute, assume that there is at least one object (not necessarily a pig) in the universe that has the given attribute, and one object that doesn't have it. # Example Inputs & Outputs **Input:** ``` Pigs are green. Everything that is green is also intelligent. Everything that is able to fly is also not intelligent. ``` **Output:** Since Pigs are green and therefore intelligent, and everything that is able to fly is not intelligent, pigs cannot fly. Output is `No`. **Input:** ``` Pigs are old. Everything that is not able to fly is also not old. ``` **Output:** If pigs were not able to fly, they were also not old. But as they are old, you must output `Yes`. **Input:** ``` Everything that is sweet is also not old. Everything that is intelligent is also blue. ``` **Output:** `Maybe`. **Input:** ``` Pigs are not able to fly. Everything that is red is also sweet. Everything that is sweet is also not red. ``` **Output:** Although the first statement implies that pigs can not fly, the following statements contradict each other and therefore the output must be `Yes`. **Input:** ``` Pigs are very smart. Pigs are able to fly. ``` **Output:** Whatever you want, as the String doesn't match the criteria mentioned above. # Winner This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest correct answer (in bytes) wins. The winner will be chosen one week after the first correct answer is posted. ![A flying Pig](https://i.stack.imgur.com/qV1jO.jpg) [Answer] # Perl, 363 353 350 347 343 297 266 264 ``` $_=<>;s/able to fly/X/g;$m=' ?(not )?\b(P|\w+)';$h{$1?N.$2:$2}{$3?N.$4:$4}=$h{$3?$4:N.$4}{$1?$2:N.$2}=1while s/$m.{8}$m\.//;map{%x=0,r($_,$_)}%h;sub r{($a,$b)=@_;$e+=$h{$a}{N.$b};$x{$b}++or$h{$a}{$b}=1,map{r($a,$_)}%{$h{$b}}}print$e|$h{P}{X}?Yes:$h{P}{NX}?No:Maybe ``` Ungolfed/Explanation: ``` # Read one line from STDIN $_=<>; # Replaces special attribute with X s/able to fly/X/g; # Prepare attribute match $m=' ?(not )?\b(P|\w+)'; # Match "Everything that is A is also B. " # "\bA........ \bB\." # Match "Pigs are B. " # "\bP........\bB\." while(s/$m.{8}$m\.//) { # Add facts for A => B and !B => !A, where A may equal "P" for "Pigs are" # Facts are stored as a hash of hashes %h; keys%h are the source attributes; # keys%{$h{$a}} are the attributes that follow from attribute $a # A "not attribute" is stored as "Nattribute", while a "attribute" is just stored as "attribute" $h{$1?N.$2:$2}{$3?N.$4:$4}=$h{$3?$4:N.$4}{$1?$2:N.$2}=1 } # For all known source attributes ... (this should really be keys%h but we dont mind the extra hashrefs) map{%x=0,r($_,$_)}%h; sub r { ($a,$b)=@_; # ... remember that we hit a negation and therefor an inconsistency ... # If we check/add $b and find an existing "N$b" that means that attribute $b is supposed to be true and not true at the same time # It is cheaper bytewise to just add up all consistency errors (remember each fact has a hard value of 1) than to exit right here $e+=$h{$a}{N.$b}; # ... remember that we processed this attribute for the current source attribute so we prevent loops ... $x{$b}++or # ... add a new fact and then follow the chains (again omitting keys). $h{$a}{$b}=1,map{r($a,$_)}%{$h{$b}} } # Did we happen on an inconsistency? Do pigs fly? Dont pigs fly? Maybe (Bitwise or is okay too) print$e|$h{P}{X}?Yes:$h{P}{NX}?No:Maybe ``` [Answer] # Haskell, 586 566 547 bytes I wrote this on the assumption that for every property *P* there must exist some *x* and *y* such that *P(x)* is true and *P(y)* is false; without this assumption, the fourth example input wouldn't have a contradiction and would answer "No". ``` #define X p s q m #define W where t=0<1;f=0>1;y="Yes" l=length;r=filter;h=head;(#)=(,) u 0=[[]];u n=[x:y|x<-[t,f],y<-u$n-1] c l=all(==h l)l#and l X[]|or[fst$c$map(!!(n-1))e|n<-[1..l$h e]]=y|z t=y|z f="No"|t="Maybe"W e=m$u$l s;z m=t#m==(c$map h$q e) X("Pigs":_:y)=p v((r$(==a).(!!k)).q)m z W((k,v),z,a)=s%y X(_:_:_:y)=p w q((r(\x->(x!!j/=a)||(x!!k==b))).m)v W((j,u),_:_:z,a)=s%y;((k,w),v,b)=u%z s%("not":w)=(i,u,not p)W(i,u,p)=s%w s%(_:"to":_:w)=(0#s,w,t) s%(w:z)=(maybe(l s,s++[w#l s])(#s)$lookup w s,z,t) main=interact$p[""#0]id id.words.r(/='.') ``` This should be compiled with the ghc command line option "-cpp". Input must be terminated by EOF (^D). You can try it online at <http://melpon.org/wandbox/>, but you cannot set command line options. Instead, you can prefix the program with the language option ``` {-# LANGUAGE CPP #-} ``` It works by collecting the set of traits, then filtering the set of trait -> truth valuations using the implications in the input. The result is then tested to ensure that every trait can be validly assigned to both True and False (failure here is the *ex falso quodlibet* case). Finally, it looks for valuations which match the pig facts, checking the value for "able to fly" in each valuation. Quite a few bytes were lost to threading state around: the set of traits seen so far, the pig-fact-selector function, and the filtering function determined by the implications. Probably the exact same idea would be much shorter in an impure language. *Edit:* Saved several bytes by proud haskeller's suggestion, then a couple extra by replacing the binding of z and "u%drop 2 z" with a binding to "\_ : \_ : z" and "u%z", saving 3. *Edit 2:* Saved some more. Used the (#)=(,) trick to save 2 bytes and learned about pattern synonyms (<https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms>), but the notation was too verbose to get a savings from eliminating the rest of the pairs in this program. Squeezed out some more savings by changing the patterns that the parser searches for. For example: if a sentence doesn't start with Pigs and we have anything left in the parser state, we parse a "Everything that is.." sentence. This saved lots of characters in the patterns for X and %. [Answer] # Python, ~~547~~ ~~536~~ ~~525~~ ~~521~~ ~~513~~ ~~509~~ ~~497~~ ~~503~~ 501 ``` m=map o='not ';R={'':{''}} S=lambda x,y:filter(len,m(str.strip,x.split(y))) N=lambda a:[o+a,a[4:]][a[:4]==o] def C(s):a,c=S(s[19:],'is also');return[(a,c),(N(c),N(a))] X=lambda A:A&set(m(N,A))and 1/0 or A for a,c in sum(m(lambda x:[('',x[9:])]if'P'==x[0]else C(x),S(raw_input(),'.')),[]):R.setdefault(a,{a}).add(c) def F(s): i,n={s},{s} while 1: for r in i:n|=R.get(r,n) if X(i)>=n:return i i|=n try:a='able to fly';n=N(a);c={n:'No','':'Maybe'}[''.join({a,n}&m(F,R)[0])] except:c='Yes' print c ``` For each `a -> b` in the input, we add the given clause and its negation `not b -> not a` to the set of clauses and then compute the set of propositions that are `->`-reachable from any proposition using a fixpoint loop. Whenever we encounter a contradiction, we throw (and later catch) a `ZeroDivisionError` and print `Yes`. Finally, we check if 'able to fly' (and/or its negation) is reachable from the 'is pig' proposition `''` and print the appropriate response. **EDIT**: ~~This is buggy, fixing it.~~ Fixed. [Answer] ## Ruby 1.9.3 (~~365 364~~ 362) ``` h='able to fly' i="(not )?(#{h}|\\w+)" o=->s{n=Regexp.new(i+" (is also|are) "+i).match s [[n[2],!n[1]],[n[5],!n[4]]]} c=e=!z=[] w=->r{z.member?(r)||(z<<(a,b=r) c|=a[0]==b[0]&&a[1]!=b[1] w[[[b[0],!b[1]],[a[0],!a[1]]]] z.map{|q|q[1]==r[0]&&w[[q[0],r[1]]]})} y=->x{z.member?([[p='Pigs',!e],[h,x]])} f=->x{x.split(?.).map{|s|w[o[s]]} c|y[!e]?'Yes':y[e]?'No':'Maybe'} ``` ### Usage The code above defines a function `f`, which takes one parameter representing the textual input and returns `Yes`, `No`, or `Maybe`. For example: ``` f['Pigs are old. Everything that is not able to fly is also not old.'] => "Yes" ``` ### Online test: <http://ideone.com/fxLemg> The ungolfed code (including unit tests) is available [here](https://github.com/clupasq/codegolf/blob/master/35623-pigs-fly/pigs_fly.rb). ]
[Question] [ Write two rectangular blocks of code, each *w* characters wide and *h* characters tall, that implement [Conway's Game of Life](http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) when arranged in a grid. (*w* and *h* may be any positive integers) For example, the two code blocks might be: (*w* = 3, *h* = 2, not actual code) ``` XX| --+ ``` and ``` | --+ ``` Treat the first block as if it is the "alive" cell in the Game of Life and the second block as if it is the "dead" cell. Now arrange multiple copies of these two blocks into a larger program that represents a Game of Life grid, such as this [glider](http://en.wikipedia.org/wiki/Glider_(Conway%27s_Life)): ``` | | | | | --+--+--+--+--+ | |XX| | | --+--+--+--+--+ | | |XX| | --+--+--+--+--+ |XX|XX|XX| | --+--+--+--+--+ | | | | | --+--+--+--+--+ | | | | | --+--+--+--+--+ ``` **Now here is the key point:** when this code is run, the output must be the Game of Life grid that is the generation after this, using the same alive and dead code blocks for the cells. So the output to the program above would be the next generation of the glider, which also serves as a runnable program: ``` | | | | | --+--+--+--+--+ | | | | | --+--+--+--+--+ |XX| |XX| | --+--+--+--+--+ | |XX|XX| | --+--+--+--+--+ | |XX| | | --+--+--+--+--+ | | | | | --+--+--+--+--+ ``` Running this would produce the next generation: ``` | | | | | --+--+--+--+--+ | | | | | --+--+--+--+--+ | | |XX| | --+--+--+--+--+ |XX| |XX| | --+--+--+--+--+ | |XX|XX| | --+--+--+--+--+ | | | | | --+--+--+--+--+ ``` And so on. The process should be indefinitely repeatable and work for any arrangement of your alive and dead code blocks in a Game of Life grid. The output grid should have the same the same dimensions as the program that it came from (5 by 6 above). Grid sizes as small as 1 by 1 should work, and they may be arbitrarily large. Naturally, an empty grid will just output itself. **Update:** Being able to simulate grids of any dimensions without having to change the "tiles" would be ideal but since this seems very difficult I will accept answers that assume the grid is a certain size (maybe around 16\*16). The Game of Life rules are as follows: 1. Any live cell with less than 2 or more than 3 live ([Moore](http://en.wikipedia.org/wiki/Moore_neighborhood)) neighbors dies. 2. Any dead cell with exactly 3 live neighbors comes alive. 3. Other cells do not change. # Scoring The challenge is to do this in the smallest code block area possible. Your score is *w* \* *h*. The lowest score wins. In case of ties the highest voted answer wins. # Details * Besides the newlines needed to make things rectangular, your two code blocks (and therefore your Game of Life grid programs) should only contain [printable ASCII characters](http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) (hex codes 20 to 7E, **no tabs, no extra newlines**). * Both code blocks must have exactly *w* \* *h* characters (besides the necessary newlines) with at least a one character difference. Padding them with spaces or comments is fine. They should not change from one generation to the next. * The output should either go to a file or to stdout. There is no input. * The boundary conditions may either be periodic (where the top edge borders the bottom and the left edge borders the right) or infinite (where all out-of-bounds cells are always dead). Choose whatever suits you best. * Reading your own source code is **not** allowed. * Any language or tool that already does this is not allowed. (Just in case one exists.) **Note:** The `-|+` characters above were only used to emphasize the cell borders. Your blocks do not need any distinguishable border. *However*, when displaying your output it would be helpful if there was some distinguishable separation between blocks, perhaps made with a character never used in the program so it is easy to remove. e.g. ``` DD+DD+DD+DD +++++++++++ AA+DD+AA+DD ``` instead of ``` DDDDDDDD AADDAADD ``` [Answer] # Perl, w\*h=233\*1=233 (per cell) Cells work in any grid size (actually even with irregular row length). Out of boundary cells are considered dead. *Dead Cell* ``` my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); ``` *Living Cell* ``` my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); ``` *Glider* ``` my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); ``` generates: ``` my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=1}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"});my$y;INIT{$y=__LINE__;$h{++$x{$y}}{$y}=0}eval($c=q{$n=0;$o++;for$i(-1..1){$n+=$i|$_&&$h{$o+$i}{$y+$_}for(-1..1)}print"my\$y;INIT{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=",$n==2?$h{$o}{$y}:$n==3||0,"}eval(\$c=q{$c});",!($o%=$x{$y})&&"\n"}); ``` *Explanation (not current)* ``` # Perl has several special blocks that are executed at certain stages. # BEGIN blocks are executed at compilation stage BEGIN { # current row index and row count in execution stage $y=__LINE__; # $x{$y} is the cell index in current row and cell count in execution stage # $h{..}{..} set cell to dead || alive $h{++$x{$y}}{$y}=1 } # dead || alive $v=1; # row index $p=__LINE__; # write cell code to $c $c=q{ # reset neighbour count $n=0; # cell index $o++; # count living neighbours for$i(-1..1){$n+=$i|$_?$h{$o+$i}{$p+$_}:0for(-1..1)} # reset cell index to 0 when end of row is reached $o%=$x{$p}; # dead || alive for next generation of this cell $v=$n==3||$n==2&&$v||0; # print the new cell print"BEGIN{\$y=__LINE__;\$h{++\$x{\$y}}{\$y}=$v}\$v=$v;\$p=__LINE__;\$c=q{$c};eval\$c;",$o?"":"\n" }; # execute cell code eval$c; ``` # Perl, w\*h=140\*2=280 (per cell) Multi-line cell is not efficient but can eliminate `__LINE__`. Dead Cell ``` BEGIN{++$v}eval($c=q<;;;;;;++$y;map{$i{$y}+=$h{$y+$_}}(-$a-1..-$a+1,-1,1,$a-1..$a+1);print'BEGIN{++$v}eval($c=q<',$c,'>);',!($y%$a)&&"\n">); BEGIN{$a||=$v,$h{++$x}=0}eval($c=q<$n=$i{++$z};print'BEGIN{$a||=$v,$h{++$x}=',$n==2?$h{$z}:$n==3||0,'}eval($c=q<',$c,'>);',!($z-$y)&&"\n">); ``` Living Cell ``` BEGIN{++$v}eval($c=q<;;;;;;++$y;map{$i{$y}+=$h{$y+$_}}(-$a-1..-$a+1,-1,1,$a-1..$a+1);print'BEGIN{++$v}eval($c=q<',$c,'>);',!($y%$a)&&"\n">); BEGIN{$a||=$v,$h{++$x}=1}eval($c=q<$n=$i{++$z};print'BEGIN{$a||=$v,$h{++$x}=',$n==2?$h{$z}:$n==3||0,'}eval($c=q<',$c,'>);',!($z-$y)&&"\n">); ``` [Answer] ## JavaScript ES6 (239 x 1 characters per cell) Dead cell: ``` f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); ``` Alive cell: ``` f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); ``` Only difference being `S[j]=0` for dead and `S[j]=1` for alive cells. Grid size is controlled with variables W (width) and H (height). Cells outside grid are dead. **Commented version** ``` f=r=>{ S=S||[], // cell states j=S.length, // current index S[j]=1, // state of this cell W=5, // width of grid H=6; // height of grid if (j+2 > W*H) // if last cell /* Loop all cells and gather code for output */ for (i in S) /* Function source with state replaced */ r +=("f="+f+";f('');").replace(/0|1/, ~~[S[i],1] // lookup table [~~S[i-W] + ~~S[+i+W] + // +i to convert from int to string ~~(i % W ? S[--i] + S[i-W] + S[W+i++] : 0) + ~~(i % W < W-1 ? S[++i] + S[i-W] + S[W+i--] : 0)-2]), r = ++i % W ? r : (console.log(r), "") }; f(''); // call current cell function to set state of the cell ``` **Glider (5 x 6 grid)** ``` f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); ``` Outputs next generation: ``` f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=1,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f('');f=e=>{S=S||[],j=S.length,S[j]=0,W=5,H=6;if(j+2>W*H)for(i in S)e+=("f="+f+";f('');").replace(/0|1/,~~[S[i],1][~~S[i-W]+~~S[+i+W]+~~(i%W?S[--i]+S[i-W]+S[W+i++]:0)+~~(i%W<W-1?S[++i]+S[i-W]+S[W+i--]:0)-2]),e=++i%W?e:(console.log(e),"")};f(''); ``` [Answer] **Python, 67x33 = 2,211** Note, that this is my pretty version, where I added a line of "#" to every other line in a life cell, and " " to every other line in a dead cell. Also, the cells are separated by "#" lines. This way, you can place an initial configuration in a text file, e.g. `GOL.py`, and look at it with a tiny font to see what is going on each step. To get to the next step, execute `python GOL.py > GOL1.py;mv GOL1.py GOL.py` and have a look again. My solution works on a grid of arbitrary size and assumes periodic boundary conditions. I haven't tested varying line widths, but there definitely is capability for that. I should also mention, that the success of this solution depends on `__del__` being called when `a` is destroyed at the end of the program. The [Python documentation](https://docs.python.org/2/reference/datamodel.html) states > > It is not guaranteed that `__del__()` methods are called for objects > that still exist when the interpreter exits. > > > So, I just hope, that this not only works with my interpreter. Live cell: ``` c=['import sys;o=sys.stdout.write;r=range;l=len;w=66',############# ################################################################### 'class B(list):',' def \_\_getitem\_\_(s,k):',######################### ################################################################### ' return list.\_\_getitem\_\_(s,k%l(s))','class A(B):',############### ################################################################### ' def e(s,k,m):',' g=(s[k-1][m]+s[k+1][m]+s[k][m-1]+s[k][m+1]',### ################################################################### '+s[k-1][m-1]+s[k-1][m+1]+s[k+1][m-1]+s[k+1][m+1])',############### ################################################################### ' if s[k][m]==0:return 1 if g==3 else 0',######################### ################################################################### ' return 1 if g==2 or g==3 else 0',' def u(s,i,y,b):',############ ################################################################### ' for j in r(l(s[i])):o(y+b[s.e(i,j)]\*(w-l(y))+"#")',############# ################################################################### ' print;print"#".join([b[s.e(i,j)]\*w for j in r(l(s[i]))])+"#"',## ################################################################### ' def \_\_del\_\_(s):',' for i in r(l(s)):',' y="";b=[" ","#"]',#### ################################################################### ' for q in ["c=["]+[repr(x)+","for x in c]+[',################### ################################################################### '"];import os;exec(os.linesep.join(c))"]:',######################## ################################################################### ' if l(y+q)>w:s.u(i,y,b);y=""',' y+=q',' s.u(i,y,b)',###### ################################################################### ' for j in r(l(s[i])):o("a[-1].append(%i);"%s.e(i,j)+" "\*51)',### ################################################################### ' print;print "#"\*l(s[i])\*(w+1)','if "a" not in locals():a=A()',# ################################################################### 'a.append(B())',];import os;exec(os.linesep.join(c))############### ################################################################### a[-1].append(1); ################################################################### ``` Dead cell: ``` c=['import sys;o=sys.stdout.write;r=range;l=len;w=66', # # 'class B(list):',' def \_\_getitem\_\_(s,k):', # # ' return list.\_\_getitem\_\_(s,k%l(s))','class A(B):', # # ' def e(s,k,m):',' g=(s[k-1][m]+s[k+1][m]+s[k][m-1]+s[k][m+1]', # # '+s[k-1][m-1]+s[k-1][m+1]+s[k+1][m-1]+s[k+1][m+1])', # # ' if s[k][m]==0:return 1 if g==3 else 0', # # ' return 1 if g==2 or g==3 else 0',' def u(s,i,y,b):', # # ' for j in r(l(s[i])):o(y+b[s.e(i,j)]\*(w-l(y))+"#")', # # ' print;print"#".join([b[s.e(i,j)]\*w for j in r(l(s[i]))])+"#"', # # ' def \_\_del\_\_(s):',' for i in r(l(s)):',' y="";b=[" ","#"]', # # ' for q in ["c=["]+[repr(x)+","for x in c]+[', # # '"];import os;exec(os.linesep.join(c))"]:', # # ' if l(y+q)>w:s.u(i,y,b);y=""',' y+=q',' s.u(i,y,b)', # # ' for j in r(l(s[i])):o("a[-1].append(%i);"%s.e(i,j)+" "\*51)', # # ' print;print "#"\*l(s[i])\*(w+1)','if "a" not in locals():a=A()',# # 'a.append(B())',];import os;exec(os.linesep.join(c)) # # a[-1].append(0); ################################################################### ``` **Python, 67x17 = 1,139** To get a golfed version, still with some way to recognise life cells from afar, the second print statement in lines 19 and 31 as well as every other line is deleted. Live cell: ``` c=['import sys;o=sys.stdout.write;r=range;l=len;w=66',############# 'class B(list):',' def \_\_getitem\_\_(s,k):',######################### ' return list.\_\_getitem\_\_(s,k%l(s))','class A(B):',############### ' def e(s,k,m):',' g=(s[k-1][m]+s[k+1][m]+s[k][m-1]+s[k][m+1]',### '+s[k-1][m-1]+s[k-1][m+1]+s[k+1][m-1]+s[k+1][m+1])',############### ' if s[k][m]==0: return 1 if g==3 else 0',######################## ' return 1 if g==2 or g==3 else 0',' def u(s,i,y,b):',############ ' for j in r(l(s[i])):o(y+b[s.e(i,j)]\*(w-l(y))+"#")',' print',### ' def \_\_del\_\_(s):',' for i in r(l(s)):',' y="";b=[" ","#"]',#### ' for q in ["c=["]+[repr(x)+","for x in c]+[',################### '"];import os;exec(os.linesep.join(c))"]:',######################## ' if l(y+q)>w:s.u(i,y,b);y=""',' y+=q',' s.u(i,y,b)',###### ' for j in r(l(s[i])):o("a[-1].append(%i);"%s.e(i,j)+" "\*51)',### ' print','if "a" not in locals():a=A()','a.append(B())',######### ];import os;exec(os.linesep.join(c))############################### a[-1].append(1); ``` Dead cell: ``` c=['import sys;o=sys.stdout.write;r=range;l=len;w=66', # 'class B(list):',' def \_\_getitem\_\_(s,k):', # ' return list.\_\_getitem\_\_(s,k%l(s))','class A(B):', # ' def e(s,k,m):',' g=(s[k-1][m]+s[k+1][m]+s[k][m-1]+s[k][m+1]', # '+s[k-1][m-1]+s[k-1][m+1]+s[k+1][m-1]+s[k+1][m+1])', # ' if s[k][m]==0: return 1 if g==3 else 0', # ' return 1 if g==2 or g==3 else 0',' def u(s,i,y,b):', # ' for j in r(l(s[i])):o(y+b[s.e(i,j)]\*(w-l(y))+"#")',' print', # ' def \_\_del\_\_(s):',' for i in r(l(s)):',' y="";b=[" ","#"]', # ' for q in ["c=["]+[repr(x)+","for x in c]+[', # '"];import os;exec(os.linesep.join(c))"]:', # ' if l(y+q)>w:s.u(i,y,b);y=""',' y+=q',' s.u(i,y,b)', # ' for j in r(l(s[i])):o("a[-1].append(%i);"%s.e(i,j)+" "\*51)', # ' print','if "a" not in locals():a=A()','a.append(B())', # ];import os;exec(os.linesep.join(c)) # a[-1].append(0); ``` If there is demand, I will gladly explain the inner workings of my solution when I find the time. ]
[Question] [ You are Ruby, a railway engineer. Your task is to lay track in any given valley such that it visits every station (`M`). The amount of track laid is not important, but it must be laid in one continuous path which starts and ends at the valley entrance/exit point (`>`) and does not, at any point cross itself. There are a few other constraints: mountains(`^`) are impassable so you must go around them, rivers(`~`) must be crossed using a bridge(`X`), and the edge of the valley (`#`) is also impassable. **The Rules of the Track** If track is not laid properly there will be derailments and nobody wants that, so here are the rules over track placement. There are four kinds of track: `-` `|` `/` `\`. Here's how each one may be combined with the others: Allowed combinations from `-` (in the centre of each example): ``` ##### ##### ##### ##### ##### ##### ##### # # # # #\ # # # # /# #\ /# # # #---# # --# # --# #-- # #-- # # - # # - # # # #/ # # # # \# # # # # #/ \# ##### ##### ##### ##### ##### ##### ##### ``` `-` may never be combined with `|`. This is too sharp a turn for the trains to make safely. Allowed combinations from `/` (in the centre of each example): ``` ##### ##### ##### ##### ##### ##### ##### # /# # -# # |# # /# # /# # -# # |# # / # # / # # / # # / # # / # # / # # / # #/ # #/ # #/ # #| # #- # #| # #- # ##### ##### ##### ##### ##### ##### ##### ``` `\` may never be combined with `/`. This is too sharp a turn for the trains to make safely. Allowed combinations from `\` (in the centre of each example): ``` ##### ##### ##### ##### ##### ##### ##### #\ # #- # #| # #\ # #\ # #- # #| # # \ # # \ # # \ # # \ # # \ # # \ # # \ # # \# # \# # \# # |# # -# # |# # -# ##### ##### ##### ##### ##### ##### ##### ``` Allowed combinations from `|` (in the centre of each example): ``` ##### ##### ##### ##### ##### ##### ##### # | # #\ # # /# # | # # | # # /# #\ # # | # # | # # | # # | # # | # # | # # | # # | # # | # # | # #/ # # \# # \# #/ # ##### ##### ##### ##### ##### ##### ##### ``` Tracks may combine with the stations, bridges and valley entrance/exit in the following ways: ``` ##### ##### ##### #\|/# #\|/# #/ # #-M-# #-X-# >- # #/|\# #/|\# #\ # ##### ##### ##### ``` Stations have turn-tables, so it's permissible to leave a station at a sharp angle (though not back the way you came - you wouldn't want to crash into the next scheduled train coming the other way!). Bridges are for crossing rivers so you must exit the bridge on the opposite side of the river that you entered it. ## Input Input will be via STDIN for programs or a function argument for functions. If your function needs a name in order for me to run it on my input then that name declaration should be included in the byte count. The input will be a **single** string with line-breaks. Each line within your input will always be the same length as the others, giving you a rectangular input. The edge of the input will always be solid and impassable (`#`) except for the point of entry. Any given input will have at least one valid answer. ## Output Your output should be returned as a **single** string with line-breaks from a function, or printed/echoed to the screen for full programs. The output should be the same as the input but with the track characters added. ## Scoring Winner will be the shortest code in bytes. ## Test cases ``` ########### # M # # ^ # > ^^ M # # ^ # #~~~~~~~~~# # M # # ^^ # # M# ########### ################# # # # M M # # ^ # # ^ M # #~~~~~~~^ # # # # ^ # # M^ # # ^ # > ^^^ M# # # # M # ################# ############### # M ~ # # ~ # > ~ M # # ~ # # ~ # # ~ # ############### ``` ## Possible solutions to test cases ``` ########### # ---M # #/ ^ \ # > ^^ M # #\ ^ | # #~X~~~~X~~# # M \ # # \ ^^ |# # -----M# ########### ################# # # # M---------M # # | ^ / # # / ^ M- # #~X~~~~~^ | # # | \ # # \^ \ # # --M^ \ # #/ ^ |# > ^^^ M# #\ / # # -------M---- # ################# ############### # M ~ # #/ \ ~ # > --X----M # #\ ~ | # # \ ~ / # # ---X--- # ############### ``` [Answer] # [Python 2](https://docs.python.org/2/), ~~3990~~ ~~3430~~ ~~4412~~ 4313 bytes This is a basically an A\* with a ugly heuristic and an ugly `getChildren` method. To run the 3 test cases consecutively takes `6.5s` on my machine. The function `f` is the solution here. It takes the map as a string and returns the solved map as a string. ``` from itertools import* import sys from Queue import* A,B,C,D,E,F,G=">|\\/-MX";H=range;I=permutations;J=set;K=abs;L=len class M: @staticmethod def T(a):return a in">|\\/-MX" @staticmethod def C(a,b,c,d,x,y,e): if not M.T(d)or not M.T(e):return 0 if e in"MX"and d in"MX"and e!=d:return 1 if d==A:return x>0 and(e==D and y==-1 or e==E and y==0 or e==C and y==1) if d==F:return e==C and K(x+y)==2 or e==D and x+y==0 or e==B and x==0 or e==E and y==0 if d==G: if b!=0!=c and K(b-x)+K(c-y)==1:return 0 return e==C and K(x+y)==2 or e==D and x+y==0 or e==B and x==0 or e==E and y==0 if e!=""and e in"MX>"and a!=""and a in"MX>":return M.C("",0,0,a,-b,-c,d)and M.C("",0,0,e,-x,-y,d) elif e!=""and e in"MX>"and a!="":return M.C("",0,0,d,b,c,a)and M.C("",0,0,e,-x,-y,d) elif e!=""and e in"MX>"and a=="":return M.C("",0,0,e,-x,-y,d) elif a!=""and a in"MX>":return M.C("",0,0,a,-b,-c,d)and M.C("",0,0,d,x,y,e) f=[[E,-1,0,E,1,0,E],[D,-1,1,E,1,0,E],[C,-1,-1,E,1,0,E],[E,-1,0,E,1,1,C],[E,-1,0,E,1,-1,D],[C,-1,-1,E,1,-1,D],[D,-1,1,E,1,1,C],[D,-1,1,D,1,-1,D],[D,-1,1,D,1,-1,E],[D,-1,1,D,1,-1,B],[B,-1,1,D,1,-1,D],[E,-1,1,D,1,-1,D],[B,-1,1,D,1,-1,E],[E,-1,1,D,1,-1,B],[C,-1,-1,C,1,1,C],[C,-1,-1,C,1,1,E],[C,-1,-1,C,1,1,B],[B,-1,-1,C,1,1,C],[E,-1,-1,C,1,1,C],[B,-1,-1,C,1,1,E],[E,-1,-1,C,1,1,B],[B,0,-1,B,0,1,B],[C,-1,-1,B,0,1,B],[D,1,-1,B,0,1,B],[B,0,-1,B,-1,1,D],[B,0,-1,B,1,1,C],[D,1,-1,B,1,1,C],[C,-1,-1,B,-1,1,D]];g=0;h=[a,b,c,d,x,y,e];j=[0,3][a==""] for k in f: l=1;m=1;n=[k[6],k[4],k[5],k[3],k[1],k[2],k[0]] for i in H(j,L(k)): if k[i]!=h[i]:l=0 if n[i]!=h[i]:m=0 if l or m:g=1 return g def __init__(s,a):s.m=[list(x)for x in a.split("\n")] def __str__(s):return"\n".join(["".join(x)for x in s.m]) def A(s):return str(s) def B(s):return L(s.m[0]) def D(s):return L(s.m) def E(s): a=[] for y in H(1,s.D()-1): for x in H(1,s.B()-1): if s.J(x,y)==F and L(s.H(x,y, F))==0:a+=[(x,y)] return a def F(s): for y in H(s.D()): for x in H(s.B()): if s.J(x,y)==A:return(x,y) def G(s): a=0 for y in H(0,s.D()-1): for x in H(0,s.B()-1): b=s.J(x,y) c=L(s.H(x,y,b)) if b==A: if c==0:a=(x,y) c=0 if c==1:return(x,y) if a!=0: return a raise ValueError() def J(s,x,y):return s.m[y][x] def K(s,x,y,b): a=[[i for i in row]for row in s.m];a[y][x]=b return"\n".join("".join(x)for x in a) def H(s,x,y,c): d=[];e=[] for a,b in J(I([-1,-1,0,1,1],2)): g=s.J(x+a,y+b) if M.T(g)and M.C("",0,0,c,a,b,g):e+=[[g,a,b]] if L(e)==1:return[e[0][0]] if L(e)==0:return[] for g,h in I(e,2): i,j,k=g;l,m,n=h;o=x + m;p=y + n if M.C(i,j,k,c,m,n,l): if l==F: if L(s.H(o,p,l))>=1:d+=[l] else:d+=[l] return d def I(s,x,y,a,b): if a==0 or b==0:return 0 a=s.J(x+a,y);b=s.J(x,y+b) return(M.T(a)or a==F)and(M.T(b)or b==F) class P: @staticmethod def A(x0,y0,x1,y1):return K(x0-x1)+4*K(y0-y1) def __init__(s,a,p,t=0,g=0): s.a=[];s.b=p;s.c=a;s.d=[a];s.e=t;s.f=g if p:s.d=p.d[:];s.d+=[a];s.e=p.e;s.f=p.f s.g=M(a);s.h=s.B() def __str__(s):return s.g.A() def B(s): a=0;b=1;c=0 try:c=s.g.G() except:a=1 d=s.g.E();e=s.g.F();g=[] if L(d)==0 and not a:g=P.A(c[0],c[1],e[0],e[1])+b elif L(d)==0 and a:return 0 elif c: h,i=c for j in combinations(d,L(d)): k=0 for x,y in j:k+=P.A(h,i,x,y);h,i=x,y g+=[k] g=min(g);g+=s.g.B()+s.g.D()+b else:return sys.maxint if g<1:return 0 return g def C(s): try:a=s.g.G() except:s.a=[];return b=s.g.J(a[0],a[1]);c=("",0,0);e=(0,0) for x,y in J(I([-1,-1,0,1,1],2)): g,h=a[0]+x,a[1]+y;i=s.g.J(g,h) if M.T(i)and M.C("",0,0,i,x,y,b):c=(i,x,y) if i=="~":e=(x,y) for x,y in J(I([-1,-1,0,1,1],2)): g,h=a[0]+x,a[1]+y;i=s.g.J(g,h) if not(i in"^#"or M.T(i)): for j in"-|\\/": if i=="~": j=G if c[0]==G:continue if c[0]==G and K(e[0])==1 and y==c[1]:continue if c[0]==G and K(e[1])==1 and x==c[0]:continue k=s.g.H(g,h,j);l=L(k) if(l==1 or l==2 and A in k)and M.C(c[0],c[1],c[2],b,x,y,j)and not s.g.I(a[0],a[1],x,y): try:s.a+=[P(s.g.K(g,h,j),s)] except:pass def f(x): d=[];a=[];b=PriorityQueue();b.put((0,P(x,0))) while not d and b.qsize(): c=b.get()[1];c.C();a+=[c.c] for e in c.a: if e.c not in a: if not e.h:d=e.d b.put((e.h,e)) return d[-1] ``` [Try it online!](https://tio.run/nexus/python2#tVhtb@M2Ev4c/wqt9wtV0zop294HqwwucZyXzRpIgeJwgFYxKImRZcuyT1JQ61DsX9/O8EWSX7YFrq2Dl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1PVAQEM5ykjDhJOoeohwBED6XwAtzdADzwq8Zlr6Cb8RiAcRYLDY8KxYL5EfqwQ16@L77Dd5b8JvjQ7VfLNW@guaLHNEyL1rmi/khLhVbXaVi2mgX2t0PZgYPLo886PvR@ylk3vbnPbsvR7NKaH7o3xmZA@TldK6XY8Q6QK4guh4w/5Zly@ocP4i/n4UPZ7Kg8/nlyNqXngdtf35u/A/7ZzzZlVDBgfopnt1t57Lf@WB//Q0) ## Test Cases ### Test 1 [![enter image description here](https://i.stack.imgur.com/XB2Wx.gif)](https://i.stack.imgur.com/XB2Wx.gif) ``` ########### # ---M # #/ ^ \ # > ^^ M # #\ ^ | # #~X~~~~X~~# # M | # # \ ^^\ # # -----M# ########### ``` --- ### Test 2 [![enter image description here](https://i.stack.imgur.com/8tQW9.gif)](https://i.stack.imgur.com/8tQW9.gif) ``` ################# # # # M---------M # # / ^ / # # | ^ M- # #~X~~~~~^ \ # # | | # # \^ | # # --M^ | # #/ ^- \ # > ^^^/ \ M# #\ / \ / # # -- M---- # ################# ``` --- ### Test 3 [![enter image description here](https://i.stack.imgur.com/yA5Rg.gif)](https://i.stack.imgur.com/yA5Rg.gif) ``` ############### # M ~ # #/ \ ~ # > --X----M # #\ ~ / # # ----X--- # # ~ # ############### ``` --- ## Source Code ### A\* State + A\* Solver Class I actually golfed these out of my solution. But they exist in my *'readable'* version. The State class is generic and meant to be implemented. The Solver class takes a start state and then follows that states heuristic `getDist`. ``` from Queue import PriorityQueue # A* State class State(object): # The type of value should be a primative def __init__(self, value, parent, start=0, goal=0): self.children = [] self.parent = parent self.value = value self.dist = 0 if parent: self.path = parent.path[:] self.path.append(value) self.start = parent.start self.goal = parent.goal else: self.path = [value] self.start = start self.goal = goal # Implement a heuristic for calculating the distance from this state to the goal def getDist(self): pass # Implement a way to create children for this state def createChildren(self): pass # A* Solver # Note: if maxmin = 1: Solver tries to minimize the distance # if maxmin = -1: Solver tries to maximize the distance class AStar_Solver: def __init__(self,startState,maxmin=1): self.path = [] self.visitedQueue = [] self.priorityQueue = PriorityQueue() self.priorityQueue.put((0,startState)) self.startState = startState self.maxmin = maxmin self.count = 0 # Create a png of the string 'qPop' def imager(self,qPop): # Imager(qPop,str(self.count).rjust(5,"0")+".png") # print str(qPop)+"\n" self.count += 1 # Solve the puzzle def solve(self): while(not self.path and self.priorityQueue.qsize()): closestChild = self.priorityQueue.get()[1] self.imager(str(closestChild)) closestChild.createChildren() self.visitedQueue.append(closestChild.value) for child in closestChild.children: if child.value not in self.visitedQueue: if not child.dist: self.imager(str(child)) self.path = child.path break self.priorityQueue.put((self.maxmin*child.dist,child)) if not self.path: print "Goal was not reachable" return self.path ``` ### State Class This is the implementation of the A\* state class. The most important method here is `getDist`, it is the heuristic for determining how close `self` is to the goal. It is basically the minimum distance to visit all the remaining destinations and get back to start. ``` from A_Star import State,AStar_Solver from Ruby_Map import Map from itertools import combinations, permutations import sys # A state class designed to work with A* class State_Pathfinder(State): # This is deprecated @staticmethod def toValue(location): return str(location[0])+","+str(location[1]) # Calculate the weighted distance between 2 points. # Not sure why the deltaY is more weighted. My theory # is that it is because the starting point is always # on a side. So vertical space is most precious? @staticmethod def distance(x0,y0,x1,y1): # return (abs(x0-x1)**2+abs(y0-y1)**2)**.5 return 1*abs(x0-x1)+4*abs(y0-y1) def __init__(self, maps, parent, value=0, start=0, goal=0): super(State_Pathfinder,self).__init__(maps,parent,start,goal) self.map = Map(maps) self.dist = self.getDist() if not value: location = self.map.getLocation() self.value = maps self.path = [self.value] def __str__(self): return self.map.getDisplay() # The heuristic function that tells us # how far we are from the goal def getDist(self): blownup = False WEIGHT = 1 location = None try: location = self.map.getLocation() except ValueError as e: blownup = True destinations = self.map.getDestinations() goal = self.map.getGoal() dist = [] if len(destinations) == 0 and not blownup: dist = State_Pathfinder.distance(location[0],location[1],goal[0],goal[1])+WEIGHT elif len(destinations) == 0 and blownup: return 0 elif location: oldX,oldY = location for path in combinations(destinations,len(destinations)): length = 0 for pair in path: x,y = pair length += State_Pathfinder.distance(oldX,oldY,x,y) oldX,oldY = x,y dist.append(length) dist = min(dist) dist += self.map.getWidth()+self.map.getHeight()+WEIGHT else: return sys.maxint if dist<1: return 0 return dist # Creates all possible (legal) child states of this state def createChildren(self): if not self.children: try: location = self.map.getLocation() except: self.children = [] return track = self.map.get(location[0],location[1]) intrack = ("",0,0) river = (0,0) for x,y in set(permutations([-1,-1,0,1,1],2)): realX,realY = location[0]+x,location[1]+y adjacent = self.map.get(realX,realY) if Map.isTrack(adjacent) and Map.isConnected("",0,0,adjacent,x,y,track): intrack = (adjacent,x,y) if adjacent=="~": river = (x,y) for x,y in set(permutations([-1,-1,0,1,1],2)): realX,realY = location[0]+x,location[1]+y adjacent = self.map.get(realX,realY) if not Map.isBlocking(adjacent) and not adjacent in "M": for outtrack in "-|\\/": if adjacent=="~": outtrack="X" if intrack[0]=="X":continue if intrack[0]=="X" and abs(river[0])==1 and y==intrack[1]:continue if intrack[0]=="X" and abs(river[1])==1 and x==intrack[0]:continue connections = self.map.getConnections(realX,realY,outtrack) hoppin = len(connections) connected = Map.isConnected(intrack[0],intrack[1],intrack[2],track,x,y,outtrack) blocked = self.map.isBlocked(location[0],location[1],x,y) if (hoppin==1 or hoppin==2 and ">" in connections) and connected and not blocked: try: maps = self.map.set(realX,realY,outtrack) value = State_Pathfinder.toValue((realX,realY)) child = State_Pathfinder(maps,self,value) self.children.append(child) except ValueError as e: print "Bad kid" print e # The solution function. Takes a map string # and returns a map string. def f(mapX): a = AStar_Solver(State_Pathfinder(mapX,0)) a.solve() print a.path[-1] if __name__ == "__main__": map1 = """########### # M # # ^ # > ^^ M # # ^ # #~~~~~~~~~# # M # # ^^ # # M# ###########""" map2 = """################# # # # M M # # ^ # # ^ M # #~~~~~~~^ # # # # ^ # # M^ # # ^ # > ^^^ M# # # # M # #################""" map3 = """############### # M ~ # # ~ # > ~ M # # ~ # # ~ # # ~ # ###############""" f(map3) f(map2) f(map1) ``` ### Map Class This class stores and processes the map. The `isConnected` method is probably the most important piece. It tests to see if 2 pieces of track are connected. ``` from itertools import permutations,combinations # A map class designed to hold string map # the specification is found here: # http://codegolf.stackexchange.com/questions/104965/ruby-on-rails-or-trackety-track class Map(object): # Is 'track' part of the railroad? @staticmethod def isTrack(track): return track in ">|\\/-MX" # Can I not build on this terrian? @staticmethod def isBlocking(terrian): return terrian in "^#" or (Map.isTrack(terrian) and not terrian=="M") # Are these 3 consecuative tracks connected in a legal fashion? @staticmethod def isConnected(inTerrian,relativeXin,relativeYin,centerTerrian,relativeXout,relativeYout,outTerrian): tin = inTerrian xin = relativeXin yin = relativeYin x = relativeXout y = relativeYout tout = outTerrian center = centerTerrian if not Map.isTrack(center) or not Map.isTrack(tout): return False if tout in "MX" and center in "MX" and tout!=center: return True if center == ">": return x>0 and (\ tout == "/" and y == -1 or \ tout == "-" and y == 0 or \ tout == "\\" and y == 1 \ ) if center == "M": return tout == "\\" and abs(x+y) == 2 or \ tout == "/" and x+y == 0 or \ tout == "|" and x == 0 or \ tout == "-" and y == 0 if center == "X": if xin!=0!=yin and abs(xin-x)+abs(yin-y) == 1: return False return tout == "\\" and abs(x+y) == 2 or \ tout == "/" and x+y == 0 or \ tout == "|" and x == 0 or \ tout == "-" and y == 0 if tout!="" and tout in "MX>" and tin!="" and tin in "MX>": return Map.isConnected("",0,0,tin,-xin,-yin,center) and Map.isConnected("",0,0,tout,-x,-y,center) elif tout!="" and tout in "MX>" and tin!="": return Map.isConnected("",0,0,center,xin,yin,tin) and Map.isConnected("",0,0,tout,-x,-y,center) elif tout!="" and tout in "MX>" and tin=="": return Map.isConnected("",0,0,tout,-x,-y,center) elif tin!="" and tin in "MX>": return Map.isConnected("",0,0,tin,-xin,-yin,center) and Map.isConnected("",0,0,center,x,y,tout) allowed = [ \ ["-",-1,0,"-",1,0,"-"], \ ["/",-1,1,"-",1,0,"-"], \ ["\\",-1,-1,"-",1,0,"-"], \ ["-",-1,0,"-",1,1,"\\"], \ ["-",-1,0,"-",1,-1,"/"], \ ["\\",-1,-1,"-",1,-1,"/"], \ ["/",-1,1,"-",1,1,"\\"], \ ["/",-1,1,"/",1,-1,"/"], \ ["/",-1,1,"/",1,-1,"-"], \ ["/",-1,1,"/",1,-1,"|"], \ ["|",-1,1,"/",1,-1,"/"], \ ["-",-1,1,"/",1,-1,"/"], \ ["|",-1,1,"/",1,-1,"-"], \ ["-",-1,1,"/",1,-1,"|"], \ ["\\",-1,-1,"\\",1,1,"\\"], \ ["\\",-1,-1,"\\",1,1,"-"], \ ["\\",-1,-1,"\\",1,1,"|"], \ ["|",-1,-1,"\\",1,1,"\\"], \ ["-",-1,-1,"\\",1,1,"\\"], \ ["|",-1,-1,"\\",1,1,"-"], \ ["-",-1,-1,"\\",1,1,"|"], \ ["|",0,-1,"|",0,1,"|"], \ ["\\",-1,-1,"|",0,1,"|"], \ ["/",1,-1,"|",0,1,"|"], \ ["|",0,-1,"|",-1,1,"/"], \ ["|",0,-1,"|",1,1,"\\"], \ ["/",1,-1,"|",1,1,"\\"], \ ["\\",-1,-1,"|",-1,1,"/"] \ ] passing = False forward = [tin,xin,yin,center,x,y,tout] start = [0,3][tin==""] for allow in allowed: maybeF = True maybeB = True backallowed = [allow[6],allow[4],allow[5],allow[3],allow[1],allow[2],allow[0]] for i in range(start,len(allow)): if allow[i]!=forward[i] and str(forward[i])not in"*": maybeF = False if backallowed[i]!=forward[i] and str(forward[i])not in"*": maybeB = False if maybeF or maybeB: passing = True return passing def __init__(self,mapString): self.indexableMap = [list(x) for x in mapString.split("\n")] def __str__(self): return "\n".join(["".join(x) for x in self.indexableMap]) # Get the string representation of this map def getDisplay(self): return self.__str__() # Get map width def getWidth(self): return len(self.indexableMap[0]) # Get map height def getHeight(self): return len(self.indexableMap) # Get unvisited destinations def getDestinations(self): destinations = [] for y in xrange(1,self.getHeight()-1): for x in xrange(1,self.getWidth()-1): sigma = 2 if self.get(x,y)=="M": sigma = len(self.getConnections(x,y,"M")) if sigma==0: destinations.append((x,y)) return destinations # Get the x,y of the goal (endpoint) def getGoal(self): for y in xrange(self.getHeight()): for x in xrange(self.getWidth()): if self.get(x,y)==">": return (x,y) # Get the x,y of the current location def getLocation(self): location = None for y in xrange(0,self.getHeight()-1): for x in xrange(0,self.getWidth()-1): track = self.get(x,y) sigma = len(self.getConnections(x,y,track)) if track == ">": if sigma==0: location = (x,y) sigma = 0 if sigma == 1: return (x,y) if location != None: return location raise ValueError('No location found in map\n'+self.getDisplay()) # Get the terrian at x,y def get(self,x,y): return self.indexableMap[y][x] # Set the terrain at x,y # (non-destructive) def set(self,x,y,value): newMap = [[i for i in row] for row in self.indexableMap] newMap[y][x] = value return "\n".join(["".join(x) for x in newMap]) # Get the track connectioning to a piece of track at x,y def getConnections(self,x,y,track): connections = [] tracks = [] for a,b in set(permutations([-1,-1,0,1,1],2)): outtrack = self.get(x+a,y+b) if Map.isTrack(outtrack) and Map.isConnected("",0,0,track,a,b,outtrack): tracks+=[[outtrack,a,b]] if len(tracks)==1:return [tracks[0][0]] if len(tracks)==0:return [] for inner,outer in permutations(tracks,2): intrack,relXin,relYin = inner other,relX,relY = outer ex = x + relX ey = y + relY if Map.isConnected(intrack,relXin,relYin,track,relX,relY,other): if other == "M": if len(self.getConnections(ex,ey,other))>=1: connections.append(other) else: connections.append(other) return connections # Is could a piece of track at x,y build in # the direct of relX,relY? def isBlocked(self,x,y,relX,relY): if relX==0 or relY==0: return False side1 = self.get(x+relX,y) side2 = self.get(x,y+relY) return (Map.isTrack(side1) or side1=="M") and (Map.isTrack(side2) or side2=="M") ``` --- ## Updates * **-560** [17-03-31] A bunch of basic regex golfing * **+982** [17-03-31] Fixed illegal track laying. Thanks *@fəˈnɛtɪk*! * **-99** [17-03-31] Utilized `;`s ]
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/38534/edit). Closed 5 years ago. [Improve this question](/posts/38534/edit) # NOTE: This question is currently in the [SANDBOX](http://meta.codegolf.stackexchange.com/a/2386/11259). Please bear this in mind before adding new answers. --- I have a large collection of fine art. My toddler is learning to use scissors and glue; lately she has started playing with my art collection. Fortunately she is really quite good with the scissors and cuts things up into perfect squares. She then uses glue to randomly tile the cut-up squares back into a new piece of art. For example, she reinterpreted my *Mona Lisa* ([which wikipedia kindly hosts for me](http://upload.wikimedia.org/wikipedia/commons/thumb/b/b9/Mona_Lisa.PNG/685px-Mona_Lisa.PNG)) as follows: ![enter image description here](https://i.stack.imgur.com/W8BqE.jpg) The following python script simulates what my toddler has done: ``` #!/usr/bin/python import sys import random from PIL import Image origname = sys.argv[1] im = Image.open(origname) width, height = im.size width = (int(width + 99) / 100) * 100 height = (int(height + 99) / 100) * 100 im = im.crop((0, 0, width, height)) im2 = Image.new("RGB", (width, height), "black") blocks = [] for x in range(width / 100): for y in range(height / 100): blocks.append(im.crop((x * 100, y * 100, (x + 1) * 100, (y + 1) * 100))) random.shuffle(blocks) for x in range(width / 100): for y in range(height / 100): im2.paste(blocks.pop().rotate(90 * random.randint(0,3)), (x * 100, y * 100)) im2.save("shuf" + origname) ``` Please excuse python skills - I'm still learning, but was happy to see how quick and easy it was to write this script. Polite code-reviews will be graciously accepted ;-) It does the following: * loads the image whose file name was given as a command-line parameter * pads that image with black pixels such that the width and height are exactly divisible by 100 * divides the image into 100x100 pixel blocks * randomly shuffles the blocks * randomly rotates the blocks (by multiples of 90 degrees) * reassembles the randomly arranged blocks back into a new image with the same size attributes as the (padded) original * saves the new image using the original filename prefixed with `shuf` --- Your task is to write a program that takes the output of this script, analyses the edges of each 100x100 block and reassembles them back to the original picture. ### Input: * an image filename. This may be passed at the commandline, via STDIN or even hard-coded, whichever is most convenient. ### Output: * either output the a singular rearranged image to a differnent file, or display the singular rearranged output to the screen. Input and output specs are intended to be lenient here, as filename-parsing is a non-goal of this [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") question. ### Other rules * The program must be able to correctly reassemble any random arrangement of the wikipedia Mona Lisa by the python script. Hard-coding of block transformations of the example image above is strictly *not* allowed. * Because all 100x100 pixel blocks are randomly rotated, the output image may also be randomly rotated by a multiple of 90 degrees. * It is understood that for some degenerate cases (e.g. chequerboard of 100x100) blocks it is impossible to correctly rearrange the image. In those cases it is acceptable to produce incorrect/undefined output. However I think in general for photo images and almost all "famous" artworks, reassembly should be possible. Works by [Mark Rothko](http://en.wikipedia.org/wiki/Mark_Rothko) are a possible exception. * Common image manipulation libraries may be used (e.g. Python's PIL), but any APIs expressly designed for this purpose are strictly banned. * [Standard “loopholes” which are no longer funny](http://meta.codegolf.stackexchange.com/questions/1061/standard-loopholes-which-are-no-longer-funny) --- Now my toddler got a hold of [*The Scream*](http://upload.wikimedia.org/wikipedia/en/thumb/f/f4/The_Scream.jpg/608px-The_Scream.jpg). This is the result that needs to be fixed: ![enter image description here](https://i.stack.imgur.com/x3X5E.jpg) ]
[Question] [ Given a string as input, output a number of whitespace characters (0x0A and 0x20) equal to the length of the string. For example, given the string `Hello, World!` your code would need to output exactly 13 whitespace characters and nothing else. These can be any mix of spaces and newlines. Your code should not output any additional trailing newlines or spaces. ## Testcases: ``` Input -> Amount of whitespace to output "Hello, World!" -> 13 "Hi" -> 2 " Don't Forget about Existing Whitespace! " -> 45 "" -> 0 " " -> 13 " " -> 1 ``` ## Scoring: This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so fewest bytes wins! [Answer] # [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php), ~~311~~ ~~150~~ ~~77~~ ~~68~~ ~~65~~ ~~46~~ ~~41~~ 38 bytes -3 bytes thanks to Kevin Cruijssen -27 bytes thanks to Ephphatha ```                             ``` [Try it online!](https://tio.run/nexus/whitespace#@8@loABECpxAyKUA5nByATmcIFKBixMswsX1/39JanEJl6GRMQA "Whitespace – TIO Nexus") A visible format ``` '\n \n \t \t \n \n \n \t\n\t \t\t\t\n\t \n\t\n \n \n\n' ``` Explanation (s = space, t = tab, n = new line) ``` nssn # label(NULL) - loop start ssststsn # push 10 in the stack -> [10] sns # duplicate the top of the stack -> [10, 10] sns # duplicate the top of the stack -> [10, 10, 10] tnts # read a single char from input, pop the stack and store at that address -> [10, 10] [10:<char that was read>] ttt # pop the stack and put the value at that adress on stack -> [10,<char>] [10:<char>] ntssn # jump to label(0) - since label(0) is not defined, the interpreter jumps to the end of the program - if the top of the stack (char) is 0 -> [10] [10:<char>] tnss # pop the top of the stack and print as ascii -> [] [10:<char>] nsnn # go back to the label(NULL) ``` [Answer] # [Japt](https://github.com/ETHproductions/japt), 1 byte ``` ç ``` [Try it online!](https://tio.run/nexus/japt#@394@f//Sh6pOTn5Ogrh@UU5KYpKAA "Japt – TIO Nexus") [Answer] # [Haskell](https://www.haskell.org/), 7 bytes ``` (>>" ") ``` [Try it online!](https://tio.run/nexus/haskell#@5@bmJmnYKtQUJSZV6KgoqBhZ6ekoKSpoOSRmpOTr6MQnl@Uk6Ko9P8/AA "Haskell – TIO Nexus") Usage: `(>>" ") "Hello, world!"`. Given two lists (and strings are lists of characters in Haskell) the `>>` operator will repeat the second list as many times as the first list has elements. Setting `" "` as second argument means we concatenate as many spaces as the input string is long. --- **Alternative** (same byte count): ``` (' '<$) ``` [Try it online!](https://tio.run/nexus/haskell#@5@bmJmnYKtQUJSZV6KgoqChrqBuo6KpoOSRmpOTr6MQnl@Uk6Ko9P8/AA "Haskell – TIO Nexus") Usage: `(' '<$) "Hello, world!"`. Given some value and a list, the `<$` operator replaces each value in the list with the given value. Thus `5 <$ "abc"` results in `[5,5,5]`, and `' ' <$ "abc"` in `" "`. The function can equivalently be written as `(<$)' '`, in case you want to find some more marine creatures in my code. [Answer] # [brainfuck](https://github.com/TryItOnline/tio-transpilers), 18 bytes ``` ++++++++++>,[<.>,] ``` [Try it online!](https://tio.run/##SypKzMxLK03O/v9fGw7sdKJt9Ox0Yv//90jNycnXUSjPL8pJUQQA "brainfuck – Try It Online") Prints one newline for each byte of input. Printing spaces instead would add 4 bytes. [Answer] # Python, 19 bytes ``` lambda s:' '*len(s) ``` [Answer] # Brainfuck, 16 bytes Prints newlines. ``` ,[>++++++++++.,] ``` [Answer] # Retina, ~~3~~ 4 bytes ``` S\`. ``` Old version, doesn't work because Retina prints a trailing line feed. ``` .   ``` (The second line contains a space). [Answer] # [sed](https://www.gnu.org/software/sed/), 7 bytes ``` s/./ /g ``` [Try it online!](https://tio.run/nexus/sed#@1@sr6evoJ/@/79Hak5Ovo5CeH5RTooiAA "sed – TIO Nexus") [Answer] # C#, ~~28~~ 24 bytes ``` s=>"".PadLeft(s.Length); ``` Old version using the `string` constructor for 28 bytes: ``` s=>new string(' ',s.Length); ``` [Answer] # JavaScript ES6, 22 bytes ``` a=>a.replace(/./g," ") ``` ``` f=a=>a.replace(/./g," "); var test = f("Hello, World!"); console.log(test, test.length); ``` [Answer] # [Retina](https://github.com/m-ender/retina), 5 bytes ``` \`. ¶ ``` [Try it online!](https://tio.run/nexus/retina#@x@ToMd1aNv//woKCi75eeolXG75RempJQqJSfmlJVyuFZnFJZl56VzhGZklqcUFicmpikCVAA "Retina – TIO Nexus") Changes everything into newlines. The `\`` suppresses the extra newline Retina would normally output. [Answer] # Mathematica, 21 bytes ``` StringReplace[_->" "] ``` [Answer] # C, 31 bytes ``` f(char*c){puts(""),*c++&&f(c);} ``` [Answer] # PHP, 28 Bytes ``` for(;a&$argn[$i++];)echo" "; ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVfJIzcnJ11EIzy/KSVFUsv6fll@kYZ2oBpaNVsnU1o611kxNzshXUgBK/gcA "PHP – TIO Nexus") # PHP, 29 Bytes ``` <?=str_pad('',strlen($argn)); ``` [Try it online!](https://tio.run/nexus/php#s7EvyCjgUkksSs@zVfJIzcnJ11EIzy/KSVFUsuayt/tvY29bXFIUX5CYoqGurgNk5qTmaYCVa2pa//8PAA "PHP – TIO Nexus") [Answer] # Excel VBA, ~~17~~ 15 Bytes Anonymous VBE immediate window funtion that takes input from cell `[A1]` and outputs spaces of length of the input to the VBE immediate window ``` ?Spc([Len(A1)]) ``` [Answer] # [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes ``` vð? ``` [Try it online!](https://tio.run/nexus/05ab1e#@192eIP9//8eqTk5@ToK4flFOSmKAA "05AB1E – TIO Nexus") ``` v # For each character... ð? # Output a space without a newline ``` ### Other 3 byte solutions (Thanks [Magic Octopus Urn](https://codegolf.stackexchange.com/users/59376/magic-octopus-urn) and [Kevin Cruijssen](https://codegolf.stackexchange.com/users/52210/kevin-cruijssen) for most of these) ``` v¶? # For each character print a newline (without adding a newline) võ, # For each character print the empty string with a newline gð× # Get the length, concatenate that many copies of space g¶× # Get the length, concatenate that many copies of newline Sð: # Split, push a space, replace each char in input with a space ðs∍ # Push ' ', swap, make the string of spaces as long as the input was võJ # For each char, push a space and ''.join(stack) v¶J # For each char, push a newline and ''.join(stack) €ðJ # For each char, push a space. Then ''.join(stack) €¶J # For each char, push a newline. Then ''.join(stack) ``` [Answer] # JavaScript (ES6), 23 bytes ``` s=>" ".repeat(s.length) ``` [Answer] # Octave, 14 bytes ``` @(a)["" 0*a+32] ``` [Answer] # [CJam](https://sourceforge.net/p/cjam), 4 bytes ``` q,S* ``` [Try it online!](https://tio.run/nexus/cjam#PcpBCoMwFEXReVbxxEFBXEbtBlpwKFq@yS8l3yZP2t3H0IGzc@GWT3/vytRDWjyCZqxmlISq154JGraksSII3hI9A2z91zcoJW/zUwqAq8UL3c2SF2JebKcbfpqp0bvxPJt6Hg "CJam – TIO Nexus") ### Explanation ``` q e# Read input , e# Length S* e# Repeat space that many times ``` [Answer] # [V](https://github.com/DJMcMayhem/V), 2 bytes ``` Ò ``` [Try it online!](https://tio.run/nexus/v#@394ksL//x6pOTn5CuX5RTkpAA "V – TIO Nexus") Note the trailing space! [Answer] # C, 45 bytes Using main. Compile with gcc, ignore warnings. ``` main(c,v)char**v;{while(*(v[1]++))puts("");} ``` Usage: ``` $./a.out "Hello, World!" ``` [Answer] # Excel, 18 bytes ``` =REPT(" ",LEN(A1)) ``` Pretty boring and one byte longer than [the VBA answer](https://codegolf.stackexchange.com/a/122722/38183). [Answer] ## [><>](https://esolangs.org/wiki/Fish), 7 bytes ``` i0(?;ao ``` The program is a loop ``` i //Push a character from the input onto the stack 0 //Add a 0 to the stack ( //Pop the top two values of the stack, and push a 1 if the second is less than the first (In this case, the input has all been read), else push a 0 ? //Pop the top of the stack. If the value is a 0, skip the next instruction ; // Terminate the program a // Add a newline to the stack o // Pop the top character of the stack and print it ``` [Answer] # [Hexagony](https://github.com/m-ender/hexagony), ~~12~~ 11 bytes -1 byte thanks to [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender) ``` ,<.;.M@.>~8 ``` [Try it online!](https://tio.run/##y0itSEzPz6v8/1/HRs9az9dBz67O4v9/BQUFl/w89RIut/yi9NQShcSk/NISLteKzOKSzLx0rvCMzJLU4oLE5FRFBQUA "Hexagony – Try It Online") Here is the expanded hex: ``` , < . ; . M @ . > ~ 8 . . . . . . . . ``` While there is input, this code runs: ``` , # Get input < # Turn right (SE) if we didn't get EOF M8 # Set the memory edge to 778 which is 10 (mod 256) ; # Print as a character (newline) > # Redirect East ~ # Multiply by -1. This makes the pointer go to the top when it runs off the edge 8 # Effectively a no-op. ``` When EOF is reached: ``` , # Get input < # Turn left (NE) 8 # Effectively a no-op @ # End program ``` [Answer] # Pyth, 3 bytes ``` *dl ``` [Try it!](https://pyth.herokuapp.com/?code=%2adl&input=%22ab%22&debug=0) Python equivalent: `len(input())*" "` ``` jmk ``` [Try this!](https://pyth.herokuapp.com/?code=jmk&input=%22abc%22&debug=0) Python equivalent: `"\n".join(map("", input()))` ``` smb ``` [Try that!](https://pyth.herokuapp.com/?code=smb&input=%22abcd%22&debug=0) Python equivalent: `"".join(map("\n",input())` ``` VQk ``` [Try!](https://pyth.herokuapp.com/?code=VQk&input=%22abcdefghijklmnopqrstuvwxyz%22&debug=0) Python equivalent: `For N in input():print("")` [Answer] # [Perl 5](https://www.perl.org/), 7 bytes *-1 byte thanks to [@Xcali](https://codegolf.stackexchange.com/users/72767/xcali)* 6 bytes of code + `-p` flag. ``` y// /c ``` [Try it online!](https://tio.run/##K0gtyjH9r6yoUABkKOgW/K/U11fQT/7/3yM1JydfR6E8vygnRREA "Perl 5 – TIO Nexus") Quite straight forward : replaces every character with a space. [Answer] # Python 2, 25 bytes ``` exec'print;'*len(input()) ``` -2 bytes thanks to Loovjo -2 bytes in the invalid code thanks to totallyhuman :p -3 bytes [Answer] # PHP, 36 bytes ``` <?=str_repeat(' ',strlen($argv[1])); ``` [Try it online!](https://tio.run/nexus/php#@29jb1tcUhRflFqQmliioc6lrgPk5qTmaagkFqWXRRvGampa////3yM1JydfRyE8vygnRREA "PHP – TIO Nexus") Outputs newlines because spaces are too mainstream [Answer] # [Jelly](https://github.com/DennisMitchell/jelly), 2 bytes ``` ⁶ṁ ``` [Try it online!](https://tio.run/##y0rNyan8//9R47aHOxv///@v5AEUyNdRCM8vyklRVAIA "Jelly – Try It Online") [Answer] # [C (tcc)](http://savannah.nongnu.org/projects/tinycc), 31 bytes I opted to output newlines since it's shorter... ``` f(char*s){for(;*s++;puts(""));} ``` [Try it online!](https://tio.run/nexus/c-tcc#@5@mkZyRWKRVrFmdll@kYa1VrK1tXVBaUqyhpKSpaV37PzcxM09Dk6uaSwEICooy80rSNJQ8UnNy8hXC84tyUhSVNOHqrcGKMOW5av9/zcvXTU5MzkgFAA "C (tcc) – TIO Nexus") ]