New answers tagged

0

1+ (TwilightSparkle Edition), score 3, 12 bytes ...Yeah, not the best idea since I only have 8 characters (tarpits gonna tarpit) to work with but let's see how much is possible. -- the BF answer 1+ suffers from its lack of literal, so I have to use my own version instead. 1 ,,<"+ [###]# Ok I admit TwilightSparkle Edition is an improved interpreter ...


1

MAWP, unknown points %[25W|]%%0~%[{![1A1:]%1A[1A76W1M;]%69W5M;}] This submission only uses the 1 and + and ; operators. Not very efficient, but works reliably. The online link for this won't work too well for this because it's capped at 4096 possible executions. It's accurate upto around 2-3 characters. Once a MAWP 1.1 compiler is released for desktop use, ...


13

JavaScript (Node.js),  16.26 15.87 15.38 13.69  13.61 9.62 + 1.13 + 0.96 + 1.90 Saved 1.69 by optimizing the initial code, as suggested by @JoKing Source const CHAR_SET = " !\"#$%&'*+,-./0123456789:;<=>?@" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" + "abcdefghijklmnopqrstuvwxyz{}"; const MAX_WINDOW = 100; ...


3

C++, Score = 12.92 + 13.37 + 15.07 + 10.83 = 52.55 #include <iostream> #include <vector> #include <stack> #include <cstdio> #define INF 99999999 using namespace std; vector<char> a[256], code; stack<unsigned long long> st; int max_depth; void constant_gen(int depth) { if (depth == max_depth) { if (st.top() < ...


6

Python 2, 13.62 + 3.18 + 3.17 + 2.90 = 22.87 def gen_prog(inp): prog = '' inp = map(ord, inp) vals = sorted(set(inp))[::-1] funcnames = ([''] + sorted(set(map(chr,range(32, 127))) - set('()|~')))[:len(vals)] val2funcname = {k:v for (k,v) in zip(sorted(vals, key=lambda c:-inp.count(c)), funcnames)} func_defined = {f: False for f in ...


2

Python 2, 14.15 + 13.40 + 13.61 13.55 + 11.85 10.01 = 53.01 51.11 def gen_prog(inp): prog = '1(|"+1+)' parts = [] prev_int = False for c in inp: if prev_int and c.isdigit(): parts[-1] += c elif c.isdigit() and c != '0': prev_int = True parts.append(c) else: ...


1

Flurry, score 1 The empty program returns the identity function λa. a = λab. a b, which is the Church numeral representation of 1. The interpreter recognizes and prints it as such: $ ./Flurry -nin -c '' 1 It takes the interpreter \$O(n)\$ time to convert from integer to decimal in order to print it, so any other answer would probably need to use character ...


9

Two sides of mazes, score 21987725 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJAAAAYXJyXzAubnB5m+wX6hsQychQxlCtnpJanFykbqWgbpNpoa6joJ6WX1RSlJgXn1+UkgoSd0vMKU4FihdnJBakAvkaRjqaOgq1ChQArhQGCIDRAFBLAwQUAAAACAAAACEAkzeCEkwAAACgAAAACQAAAGFycl8xLm5weZvsF+...


0

RGBDS macros, 11,111,111,111,111,111,111,111 REPT 23 PRINTI 1 ENDR


0

MAWP 1.0, 76543210 8[1A!:]. As suggested by Jo King. Try it! MAWP 1.0, 152587890625 5!W!W!W!W:. Try it!


11

Tridents, score 21,947,177 21,951,598 UEsDBBQAAAAIAAAAIQAL/+yrSgAAAIgAAAAJABQAYXJyXzAubnB5AQAQAIgAAAAAAAAASgAAAAAAAACb7BfqGxDJyFDGUK2eklqcXKRupaBuk2mirqOgnpZfVFKUmBefX5SSChJ3S8wpTgWKF2ckFqQC+RpGOpo6CrUKFACuFAYGBhAGAFBLAwQUAAAACAAAACEAlmPInE8AAACQAAAACQAUAGFycl8xLm5weQEAEACQAAAAAAAAAE8AAAAAAAAAm+wX6hsQychQxlCtnpJanFykbqWgbpNpoq6joJ6WX1RSlJgXn1+...


11

No dead ends near the entrance, 21,477,560 21,485,005 Try it online! Yay, 21 million. The giant horizontal segments up to row 19 are also removed, so about 20% of the entire grid is just an open space. Also, as the "real maze" starts at the leftmost column, moving the entrance to the top right gives a slight bump to the score. (Thanks to @Neil) ...


2

Slightly fewer dead ends, score 16,663,349 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJAAAAYXJyXzAubnB5m+wX6hsQychQxlCtnpJanFykbqWgbpNpoa6joJ6WX1RSlJgXn1+UkgoSd0vMKU4FihdnJBakAvkaRjqaOgq1ChQArhQGCIDRAFBLAwQUAAAACAAAACEAkzeCEkwAAACgAAAACQAAAGFycl8xLm5weZvsF+...


8

Even more dead ends, 16,555,009.5 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJABQAYXJyXzAubnB5AQAQAJAAAAAAAAAASQAAAAAAAACb7BfqGxDJyFDGUK2eklqcXKRupaBuk2mhrqOgnpZfVFKUmBefX5SSChJ3S8wpTgWKF2ckFqQC+...


2

The original dead end guest trap, 16,505,047.166666668 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJABQAYXJyXzAubnB5AQAQAJAAAAAAAAAASQAAAAAAAACb7BfqGxDJyFDGUK2eklqcXKRupaBuk2mhrqOgnpZfVFKUmBefX5SSChJ3S8wpTgWKF2ckFqQC+...


3

Zigzag path, score 12,582,074 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJAAAAYXJyXzAubnB5m+wX6hsQychQxlCtnpJanFykbqWgbpNpoa6joJ6WX1RSlJgXn1+UkgoSd0vMKU4FihdnJBakAvkaRjqaOgq1ChQArhQGCIDRAFBLAwQUAAAACAAAACEAkzeCEkwAAACgAAAACQAAAGFycl8xLm5weZvsF+...


5

Empty maze, score 51113 UEsDBBQAAAAIAAAAIQChBYC8SQAAAJAAAAAJAAAAYXJyXzAubnB5m+wX6hsQychQxlCtnpJanFykbqWgbpNpoa6joJ6WX1RSlJgXn1+UkgoSd0vMKU4FihdnJBakAvkaRjqaOgq1ChQArhQGCIDRAFBLAwQUAAAACAAAACEAkzeCEkwAAACgAAAACQAAAGFycl8xLm5weZvsF+...


1

1+, 6 bytes ](|+() The trivial approach. ] stops the comment, the rest of the program yields the "Imbalanced brackets!" error but even if you add the right parenthesis there it will be a recursive function that repeatedly pop two numbers, add them, and push the sum back and calls itself until the stack become empty. Put it in a function won't work ...


0

Scala, Score: ~26.14 (183 bytes, 7 ops) i=>("OR"+i split "(?<=\\d)").foldLeft(false){(b,o)=>val s=o.replace("NOT","") val c=(s!=o)^(o.last>48) (s.count(_==78)==1)^(if(s contains 65)!(b&c)else if(s contains 88)b^c else b|c)} Try it online! The operators are uppercase (whitespace doesn't matter), and ...


0

C (gcc), 3 tiebreakers I take no credit for this, as this is not an original answer, but merely an amalgamation of the following answers to this same challenge: https://codegolf.stackexchange.com/a/5701/97511, https://codegolf.stackexchange.com/a/4613/97511 #include <stdio.h> #define OP ( #define CP ) #define CO , int main OP ac CO av CP int ac; ...


0

Lua, 46 bytes print(load'return io.read"n"\x2Bio.read"n"'()) Try it online! How It Works load loads a string and returns a function, we pass a hexadecimal to it and call the function.


3

Excel, (25, 8) (22, 6) 13, 4 tie-breakers Inputs are A1, A2. =2*MEDIAN(A:A Because MEDIAN is shorter than AVERAGE and AGGREGATE.


3

Scala 2.12, 20 bytes, 0 +/- signs readInt\u002breadInt The unicode literal is just turned into a + before compilation


3

Befunge-93, 0 +- characters, 0 tiebreakers, 33 bytes "e:"%"X:"%::%p"h:"%"Y:"%::%p&& @ Try it online! Explanation Like @negative seven's Befunge answer, we generate + and . at runtime and put them onto the field to be executed. However, Befunge-93 does not include the y instruction, so we abuse the % modulo ...


0

CJam, score 8 "twasbrilligandtheslithytovesdidgyreandgimbleinthewabeallmimsyweretheborogovesandthemomerathsoutgrabebeware";"The Jabberwock"'m;'y 'tis a shame this was so simple, I was enjoying using the c to convert numbers to characters and then rearrange them at great expense. Try it online Verify online Explanation: "tw...re"...


-1

Scala, 127 126 121 bytes (score is the same) s=>1 to s.size collect((s.sliding(_:Int).distinct.find{e=>var x=s;while(x contains e)x=x.replace(e,"");x==""})unlift)head I didn't even try to make it actually erasable. Note: Requires postfix operators enabled. Try it online


0

Zig 0.6.0, 2 bytes ` (\n`) A newline will reset the tokenizer state, escaping any comments or multiline strings and erroring for single line strings. Backticks are not a valid character except in strings. Try it online!


1

Scratch (1.x, except 1.2 beta), scratchblocks syntax, 26 bytes when gf clicked say(()/() Leading new line ensures that "when gf clicked" will not be in a comment, so that what's below it will run. This errors when run in the Stage, because the Stage cannot use the say block. This errors when run in a sprite by itself, because a divide by zero is ...


0

Jelly, 3 bytes » € Try it online! Jelly has no comments, and every line in the code is parsed whether or not it is reachable. The only way to prevent some code from being executed is starting a string literal using “. This is countered by », which terminates a string (and interprets it as a dictionary-compressed string). Thus € (each) will always be ...


0

Javascript, 228 bytes, score 228 Naive solution I guess: (r,d)=>{w=0;l=r.length;for(var i=0;i!=-1&&i<l;){i=r.indexOf(d,i);w=w||((i<0)?0:t(r.substr(0,i)+r.substr((i++)+d.length,l),d))}return !r?1:w} f=a=>{n=a.length;for(p=1;p<=n;p++)for(i=0;i<=n-p;i++)if(t(a,b=a.substr(i,p)))return b} Try it online!


3

Brachylog, 23 bytes, score 23 Rather boring, as it doesn't have a non-trivial eraser. {|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh Try it online! or verify the other test cases (split in two, so TIO doesn't time out.) How it works {|~c₃↺↔At.l>0∧Akc↰}ᶠlᵒh { }ᶠ Find all outputs for the implicit input, that … | either is itself or …...


11

Python 3, score ... 48 29 20 +1,eval(bytes([57])) A completely different approach from the last 2 versions (and also result in manageable generated program). Check out the revision history for some (possibly) interesting ideas. Given an arbitrary Python program: print(1) it can be transformed, without changing the behavior: exec("print(1)") ...


0

brainfuck, 130 bytes / 1 operator = 130 +>>+<,[------------------------------------------------[<->[-]]<[>>[-]<<-]><+>,]>++++++++++++++++++++++++++++++++++++++++++++++++. Try it online! Link is for a readable, commented version. Only implements AND. Although technically all it does is print 1 unless there is a 0 in ...


0

Haskell, \$225 \div 4 = 56.25\$ b(_:'A':'0':s)=b('0':s) b(c:'A':_:s)=b(c:s) b(_:'O':'1':s)=b('1':s) b(c:'O':_:s)=b(c:s) b('N':'0':s)=b('1':s) b('N':_:s)=b('0':s) b('0':'X':'0':s)=b('0':s) b('1':'X':'1':s)=b('0':s) b(_:'X':_:s)=b('1':s) b x=x f=(b.map(!!0)) Defines a function f, which given a list of the format ["1","AND","0"] ...


Top 50 recent answers are included