30
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python, 55 51 bytes
lambda a:'%x'%(-int(a.replace('c','0c'),16)%255-39)
Attempt This Online!
Explain:
Observe that 'a', 'b', 'c' are base 16 digits.
I learnt ...
18
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
JavaScript (ES6), 59 bytes
s=>(s+"aaabbabbc").replace(q=/c|../g,s=>(q[s]^=1)?o=s:0)&&o
Try it online!
Commented
...
15
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Stax, 11 bytes
ù¢╓┘0ï<ΣEZ1
Run and debug it
Unpacked (13 bytes):
'c|^2/M{{SkmT
Explanations:
...
11
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Jelly, 15 14 bytes
ḟ”cQp`ḟs2$Ʋȯ”c
Try it online!
Thanks to @JonathanAllan for saving a byte!
A full program taking a string as its argument and printing the ...
10
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python, 55 bytes
lambda a:f'{int("cc"+(30*a).strip("ab"),16)%255%192:x}'
Attempt This Online!
This produces 15 (= base - 1) on frame and (if <...
9
votes
Just another traffic jam!
Jelly, 3 bytes
ŒgZ
A full program that accepts a pair of the two strings as the first argument and prints the resulting single lane.
Try it online!
How?
...
7
votes
Literate Programming in Base 26
Jelly, score 23
The bijective base \$26\$ program as words:
yrs seo dts i am a be in cpu sap
The Jelly code:
ÑÞ²¶O_96ḅ26ḃ⁹’
...
6
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Vyxal, 106 bitsv2, 13.25 bytes
‛ab2↔\cpṖ'ḣ∑?=;hh
Try it Online!
Bitstring:
...
6
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
J 9.4, 25 bytes
(]>.&XOR&.dfh _2]\-.)&'c'
Attempt This Online!
dfh and hfd ...
6
votes
Just another traffic jam!
Ruby, 33 bytes
f=->a,b{a[/(.)\1*/]?$&+f[b,$']:b}
Try it online!
How it works:
If the first queue is not empty, extract the first vehicle, then exchange the ...
5
votes
5
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Jelly, 20 18 17 bytes
-3 thanks to Nick Kennedy reminding me to golf the magic table.
⁾abp`”cṭŒ!F=¥Þ⁸ṪṪ
A full program that accepts the flattened, redacted ...
5
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Ruby, 41 bytes
->s{"%x"%(726-s.scan(/c|../).sum(&:hex))}
Try it online!
0xaa+0xab+0xba+0xbb+0xc is 726.
4
votes
4
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Retina 0.8.2, 29 23 bytes
$
¶aaabbbbac
D`c|..
1A`
Try it online! Link includes test cases. Explanation:
$
¶aaabbbbac
Append ...
4
votes
4
votes
4
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Uiua, 27 bytes
?"c"⍜(-@a)(◿2/+↯~2▽<2.)=8⧻.
Try it online!
Explanation:
For the cases where 'c' is in the string, this uses a little trick by ...
4
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Perl 5 (-p), 32, 29 bytes
$_=s/c//?eval s/..\K\B/^/gr:c
Try it online!
If c can't be ...
4
votes
4
votes
Just another traffic jam!
05AB1E, 5 bytes
€γõζS
Input as a pair of strings; output as a list of characters.
Try it online or verify all test cases.
Explanation:
...
4
votes
Just another traffic jam!
Uiua, 16 bytes
⊐/⊂♭⍉⬚∘⊟□[]∩⊜□∩.
Try it!
Takes lists of postive integers as input (because this saves a few bytes over strings).
...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python, 83 bytes
lambda a:min({'aa','ab','bb','ba','c'}-{a.replace('c','')[i:i+2]for i in[0,2,4,6]})
Attempt This Online!
-17 bytes thanks to Neil
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Charcoal, 19 15 bytes
⌊⁻⪪”&∨O⊕”²⪪⁻Sc²
Try it online! Link is to verbose version of code. Explanation:
...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Ruby, 64 bytes
->s{a=%w[aa ab ba bb c];a.find{[*(a-[_1]).permutation].join[s]}}
Attempt This Online!
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python 3.8, 82 bytes
lambda a:("cbbaa"*469)[(k:=sum(map(ord,(r:=a.replace('c',''))+r[::2])))::k][r==a:]
An unnamed function that accepts the flattened, ...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Google Sheets, 80 bytes
=substitute(regexreplace("aa|ab|ba|bb|c",regexreplace(A1,"(c|..)","$1|"),),"|",)
Put the input in ...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python 3, 73 bytes
b,*l=0,{'c'},{0}
for c in input():l[b]^={c};b^=c<'c'
print(str(l)[3::10])
Try it online!
71 bytes
...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
J, 31 30 29 bytes
(e.~{];,@{@;[email protected]._2<\-.)&'c'
Try it online!
-1 thanks to ovs
,@{@;~@-. All valid 2 char pairs, ...
3
votes
aaabbabbc⠀⠀⠀⠀⠀⠀
Python, 86 bytes
lambda s:[*{'aa','ab','ba','bb'}-{*map(str.__add__,*[filter('c'.__ne__,s)]*2)},'c'][0]
Attempt This Online!
No magic numbers here, just another ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
string × 2214code-golf × 2077
ascii-art × 211
decision-problem × 140
kolmogorov-complexity × 125
parsing × 116
number × 104
code-challenge × 70
natural-language × 62
random × 61
math × 58
balanced-string × 58
array × 53
restricted-source × 48
grid × 45
subsequence × 41
arithmetic × 39
alphabet × 39
sequence × 38
sorting × 38
permutations × 36
source-layout × 36
date × 33
counting × 32
palindrome × 31