text:
The answer to life, the universe, and ASCII-art
Simple challenge: try to output the following text in as few bytes as you can:
       the        answer
      toli      fetheuniv
     ersea     nde     ver
    ything     the     ans
   wer tol     ife     the
  uni  ver           sean
 dev   ery         thin
gth    ean       swer
tolifetheuni    ver
seandeveryth   ing
       the     ans      wer
       tol     ifetheuniver
       sea     ndeverything

The original drawing contains 332 characters.
Rules

No input or an unused input.
Output can be in any reasonable format (string, list of strings, matrix of chars and so on).
You can use uppercase instead of lowercase for the drawing if your prefer so.
Trailing whitespaces and newlines allowed.
This is code-golf, so may the shortest program/function for each language win!

Notes

This has been identified as a possible duplicate of We're no strangers to code golf, you know the rules, and so do I. That question was about searching and replacing text. Here you have to draw a shape using a given text, and at least two of the current answers demonstrate that golfing languages can beat plain compression algorithms in this case.

This comes from the sandbox.

@Phoenix I edited the question, you can check out the clues to see that this challenge may be more about thinking and less about compressing or just making replacements.

@cairdcoinheringaahing is more about who has the best compression algorithm in their language. Aren't many kolmogorov-complexity problems so?

ahh~ you finally posted it like this :) @CarlosAlejo

Personally, I think this is on-topic and not a dupe. I don't think you need a spoiler quote, though.

@programmer5000 thank you very much for your support. I added the spoiler quote because I considered I needed it to defend my question after the warnings.

@Phoenix I don't think this is a dupe, sogl has outgolfed bubblegum. Therefore, compression is not an optimal way of doing this.

To be honest, I didn't realize my reopening vote was binding. For the reasons already mentioned by @programmer5000, I really don't think it's a dupe of We're no strangers.... It may be a dupe of another -- yet to identify -- challenge, but not this one.

AHHHHHHHHHHHHHH I FRIGGIN LOVE IT! BIGGEST FAN OF THAT SERIES. I READ THE BOOKS, NOT THE MOVIE. THE MOVIE RUINED IT FOR ME.

@MagicOctopusUrn here is the example of what happens when a geek examples.

This is an even better proof that 42 is the answer, than Arthur pulling out scrabble pieces. See how perfectly it fits???

@Nacht the best part is that at first I drew the 42 with * characters, and then replaced them with the text, which fit perfectly. I did not have to modify the original drawing to make the sentence fit. Coincidence?

We need an answer in Seed https://esolangs.org/wiki/Seed

Python 3, 224 220 219 215 211 194 bytes

Thanks to @TFeld for 1 5 bytes: if(j%27<1)*j instead of if j*(j%27<1) and simplified print statement.
Thanks to @Leaky Nun for 4 bytes:Inverting 0 and 1, did not require the padding by zeros 7*'0'
@Leaky nun saved 17 bytes with his awesome golfing skills(Thanks a lot!!!!): awesome use of modular indexing

i=j=0
k=int("OHZE5WCKDTW6JYMO1JNROAAJQVAN6F8KEO0SMKJM86XIBMCEH5FXXONZGBAVCN3689DS",36)
while k:j+=1;print(k%2*'theanswertolifetheuniverseandeverything'[i%39]or' ',end='\n'*(j%27<1));i+=k%2;k//=2

Try it online!
Explanation:
Uses base-36 compression to compress this binary number(new-line excluded)
111111100011111111000000111
111111000011111100000000011
111110000011111000111110001
111100000011111000111110001
111000100011111000111110001
110001100011111111111000011
100011100011111111100001111
000111100011111110000111111
000000000000111100011111111
000000000000111000111111111
111111100011111000111111000
111111100011111000000000000
111111100011111000000000000

We basically have two counters i and j. On encountering a 1 we print a space; Else if 0 is encountered we print next letter from the string and increase i. j increases for each 0 or 1. We also print new-lines whenever necessary i.e. when j%27<1 becomes true.

You can save 1 byte by changing if j*(j%27<1): to if(j%27<1)*j:

215 bytes: Try it online!

you need 7*'0' because your number starts with 0. Invert 0 and 1 to solve this problem.

205 bytes

201 bytes with integer arithmetic

200 bytes with modular indexing

196 bytes

194 bytes

Python 2, 235 218 213 bytes
x=bin(int('OC5POO6MZYQNBWY0RP6BKBZCOZL13MIAB6I8YZ5N7LXSZBVKX7GC57AW5631YCJ6XCLC',36))[2:].replace('1',' ')
for c in'theanswertolifetheuniverseandeverything'*4:x=x.replace('0',c,1)
while x:y,x=x[:27],x[27:];print y

Try it online!
Switched to a base 36 encoded int of the positions of letters as hinted in thew question.
Replaces each character one at a time.
       111        111111                              the        answer
      1111      111111111                            toli      fetheuniv
     11111     111     111                          ersea     nde     ver
    111111     111     111                         ything     the     ans
   111 111     111     111                        wer tol     ife     the
  111  111           1111                        uni  ver           sean
 111   111         1111             --->        dev   ery         thin
111    111       1111                          gth    ean       swer
111111111111    111                            tolifetheuni    ver
111111111111   111                             seandeveryth   ing
       111     111      111                           the     ans      wer
       111     111111111111                           tol     ifetheuniver
       111     111111111111                           sea     ndeverything

Edit: It seems officialaimm used base 36 before me.

Bubblegum, 125 bytes
0000000: 45 8f c5 01 03 31 0c 04 ff ae 62 4b 0b 99 02 c7  E....1....bK....
0000010: d8 7d 84 e7 f9 59 30 5e 41 59 4a 84 71 ef e6 3d  .}...Y0^AYJ.q..=
0000020: 4e c1 ea fd b7 42 48 91 66 d6 ae 6e da 89 d3 1c  N....BH.f..n....
0000030: ef 60 ba 97 ae 6e b6 74 2e a5 76 d9 ad ae e4 16  .`...n.t..v.....
0000040: 69 59 08 a6 a6 e8 23 d4 22 af 08 d0 20 7d 17 f0  iY....#."... }..
0000050: 8a 9b 7c 76 c2 61 7b c8 4b 01 41 23 50 24 32 87  ..|v.a{.K.A#P$2.
0000060: f5 98 9e 88 35 24 21 83 ac 50 b2 e0 a2 16 0e 42  ....5$!..P.....B
0000070: bb ba a5 bc ae 6e bd 76 b7 69 d9 f9 07           .....n.v.i...

Try it online!

How did you generate this? The closest I could get was 127

With zopfli.

I did use zopfli, but I swear I tried with and without trailing newlines, with extra spaces....couldn't get under 127

05AB1E, 83 79 74 bytes
-4 bytes thanks to Erik the Outgolfer
Outputs a list of strings to save a byte.
•2ÖH₆Ôn₅Ò\ÊÑĆ¸Ý¾*£„ÔûC∞qΘœ™‚¹µ—₃₄fm•vNÈy×vyiðë¾¼’€€Ž»to‚ì€€ªÜ€ƒ‰Ö’è}}}J27ô

Try it online!
Explanation
2ÖH₆Ôn₅Ò\ÊÑĆ¸Ý¾*£„ÔûC∞qΘœ™‚¹µ—₃₄fm is the base 255 representation of the decimal number:
73869469755353565353431353533323902433339443437469034389033390735363735903735903

Which encodes runs of 1s and 0s respectively, even indices being the 1s and uneven indeices the 0s. This evaluates to the binary number:
111111100011111111000000111
111111000011111100000000011
111110000011111000111110001
111100000011111000111110001
111000100011111000111110001
110001100011111111111000011
100011100011111111100001111
000111100011111110000111111
000000000000111100011111111
000000000000111000111111111
111111100011111000111111000
111111100011111000000000000
111111100011111000000000000

Code
•...•                                         Convert from base 255 to decimal
     v                                }       For each digit, do:
      NÈy×                                       is_even(index) repeated that many times
          v                          }           For each digit, do:
           yi                       }               If digit is truthy, then:
             ð                                         Push space
              ë                                     Else:
               ¾¼                                      Get and increment counter, starts at 0
                 ’€€Ž»to‚ì€€ªÜ€ƒ‰Ö’                    Push "theanswertolifetheuniverseandeverything"
                                   è                   Get the character at that index
                                       J      Join whole stack
                                        27ô   Split into parts of 27

Replace "ÔAo îιË3š1ĆRÕ₃FWš{ÓÛÏ.!XµM§&¶ñD°3PŸ{óNι2Ðbмh"253ö with •—."Ôq‚Ā0Ál0j¿«ªžé¨0õ₄7“Ÿ!½ÏiæÆø-δq–Å05q½Yñá+• for -4.

@EriktheOutgolfer thanks, updated my answer and now I finally know what these • are for :)

Nice answer :). Hope you continue to learn the language. If you have any questions feel free to chat me.

@MagicOctopusUrn Thanks a lot! :)

Python 2, 220 213 212 bytes
-1 byte by switching ()*4 for %39 from @officialaimm
s=""
w=l=i=0
for g in`int("352G7FS4XC8J2Q2M2HNK7IZI65Z9TVUMHOZ6MR3HY46RQBLWY4PR",36)`[:-1]:
	for j in g*int(g):l+=1;s+=[' ',"theanswertolifetheuniverseandeverything"[w%39]][i%2]+"\n"*(l%27<1);w+=i%2
	i+=1
print s

Try it online!
This is a different approach from the other Python answers. I use a hex base-36 (saved 7 bytes) encoding of a PNG-style  RLE-style encoding of the image (a string of digits indicating the number of consecutive repeated pixels).
The string of digits is:
73869469755353565353431353533323902433339443437469034389033390735363735903735903
Then I iterate through those digits and alternately print that number of ' 's or characters from the palette ('theanswer...'). When more than 9 of a character is repeated, I'd simply add a 0 and then the remainder.

+1 for different approach. You can save a byte by using "theanswertolifetheuniverseandeverything"[w%39] TIO

Thanks and noted. I was trying to work it in along with an 'or' replacement for the bracket boolean setup I have here now, but it's messing up my newlines...

I didn't know PNG used this compression algorithm - I thought that was GIF.

Nice catch. It wasn't PNG (nor GIF), but actually RLE. I'll add a link to the answer.

JavaScript (ES6), 207 205 203 bytes
Returns an array of strings with some trailing spaces.

let f =

_=>[16515968,33489856,k=58950624,k+16,k-40,31458204,7865230,1966983,462847,233471,117670784,k=134185856,k].map(n=>'heanswertolifetheuniverseandeverythingt '.replace(/./g,(_,i,s)=>s[n>>i&i<27?k++%39:39]))

console.log(f().join('\n'));

SOGL V0.12, 74 bytes
"ō⅓׀?@C⁶¬IΧΖO‘@øŗč"βΘ⅔Μv∙KΩqψ3╥W≡A;2ļm½±iq╗∆Δ⁶Πqīσ‽ε⁰5τΩ⅜δσΞoΤi┘‽N¹\Λ:‘'    n

Try it Here!
"...‘              push "the answer to life the universe and everything". because of a bug-not-really-bug, the starting quote is required
     @øŗ           remove spaces
        č          chop it into characters
         "...‘     push a string of spaces and ŗ where ŗ gets replaced with each next characters of the character array
              ' n  split into an array of line length 27

Allow me to answer my own question...
Charcoal, 140 126 112 bytes
Ａ⟦⟧βＦ⁶⁸Ｆ⁻℅§”c#*U[“⎆Ｖl¶·δ‴ü"Ｉp8ξＺ{e/⪫¦σMＭ⪫¢Ｑ⁸UＬê←⪫W?—υ⁻$⌀)”ι³⁴«¿﹪ι²§”m⌊0Ｙ℅¿№”XＪ-⁵η}Z¿8_*<o%!±Ÿ”Ｌ⊞Ｏβω ¿¬﹪Ｌ⊞Ｏυω²⁷⸿

Try it online!
You have here a link to the closest verbose version.
Explanation (see verbose version for details):

The )%*(+&(+)''%'%'('%'%&%#%'%'%%%$%-&%%%%+&&%&%)&(.&%*.%%2%'%(%)%'.)%'. string (68 bytes, 48 bytes compressed) is a representation of the RLE-encoding of the drawing. Every char code minus 34 is the number of spaces (even positions) or the number of text characters (odd positions) to print consecutively.
The algorithm just decompress the RLE-encoded string and writes the next char of the gtheanswertolifetheuniverseandeverythin string (39 bytes, 27 bytes compressed) every time a non-whitespace character is needed to be written. As I check the length of a list to get the next character and that list starts with one element, the last character of the string is written in the first position.
Every 27 characters written I insert a new line.

Acknowledgments

Many thanks to Neil and his amazing tips for allowing me to save 28 bytes and finally be able to beat Bubblegum. :-)

If you use Assign(Minus(1, c), c); then you can just use if (c) { ... } else Print(" ");.

Actually if you use for (68) and AtIndex("...", i) then you can use Modulo(i, 2) instead and you don't need c at all.

And if you use if (Not(Modulo(Length(PushOperator(u, w)), 27))) then you don't need a either.

Oh, and AtIndex does an automatic Modulo so Modulo(b, 39) can be just b.

@Neil a bunch of amazing tips indeed! Though I still don't understand the if (Not(Modulo(Length(PushOperator(u, w)), 27))) one...

I think I have it down to 112 bytes: Ａ⟦⟧βＦ⁶⁸Ｆ⁻℅§”c#*U[“⎆Ｖl¶·δ‴ü"Ｉp8ξＺ{e/⪫¦σMＭ⪫¢Ｑ⁸UＬê←⪫W?υ⁻$⌀)”ι³⁴⁺⎇﹪ι²§”m⌊0Ｙ℅¿№XＪ-⁵η}Z¿8_*<o%!±”Ｌ⊞Ｏβω ⎇﹪Ｌ⊞Ｏυω²⁷ω⸿.

u is a predefined variable which is just an empty array (saves using Ａ⟦⟧υ). Every time you push something to it its length increases by 1. This is shorter than an explicit assignment to increment.

@Neil do you have a TIO-link? Your 112-byte solution doesn't seem to work...

Sorry, I think Stack Exchange adds nonprinting characters in comments to make them wrap. Try it online!

Interestingly your "closest verbose version" isn't what I was working with, but when you remove the redundant characters it also ends up at 112 bytes.

102 bytes: Try it online!

Retina, 183 bytes

7386¶6469¶555353¶465353¶33135353¶23239024¶133394¶034374¶090343¶090333¶735363¶735903¶735903¶theanswertolifetheuniverseandeverything
.*$
$&$&$&$&
(\d)(.)
$1$* $2$*
+s`1([ 1¶]+)(.)
$2$1

Try it online! Explanation: The first stage adds the RLE encoding of the cell bitmap and the text, which the second stage then duplicates to the correct length, while the third stage decodes the RLE encoding. The fourth stage then moves the text into the cells.

Jelly, 83 bytes
“¡eu⁾ṃṣƬİḂṃ½)ṣṾṘƇ@^AṀẆṫ+¢ṗɲ⁾ṭḋZ`⁺×Ṗj½Ṇ-Þḣ2żṿƤc’BCẋ"`“ÆZ⁺ƙ{Æß¥ŀŒ1gỤ3Ḍṭṁ ṃjɓ»ṁȯ€⁶s27Y

Try it online!
How it works
“XX’BCẋ"`“YY»ṁȯ€⁶s27Y
“XX’                   a large number
    B                  binary
     C                 complement
      ẋ"`              1 becomes [1] and 0 becomes []
             ṁ         reshape
         “YY»             "theanswertolifetheuniverseandeverything"
              ȯ€⁶      replace [] with " "
                 s27   split into chunks of length 27
                    Y  join with newline

Vim, 239 keystrokes
:h4<CR>3hy5bZZitheanswerto<Esc>p:%s/ \|,//g<CR>ye3P
lqqi<CR><Esc>qqw3li <Esc>lq3@wbhr<CR>16l@q@w3-@w6l@ql@w9l@qll3@whr<CR>3l9@w4l@q 2@w4l@q2@w4l@q9l2@wlr<CR>9l@w4klr<CR>4whr<CR>jj
el<C-v>3k"aD0jji <Esc>qqdiwukPi <Esc>q5@qwy04j$"ap6+<C-v>GPp3kw3i <Esc>2@q4kbXj2@qywh<C-v>4jp2je<C-v>jj4A <Esc>8j5i <Esc>b<C-v>jj2I <Esc>

Linebreaks added for "readability"

Explanation
The first line yanks life, the universe and everything from a help page, which is one byte shorter than simply typing it out. It then turns that into this:
theanswertolifetheuniverseandeverythingtheanswertolifetheuniverseandeverythingtheanswertolifetheuniverseandeverythingtheanswertolifetheuniverseandeverything

The second line breaks the string up into:
the answer
toli fetheuniv
ersea nde ver
ything the ans
wer tol ife the
uni ver sean
dev ery thin
gth ean swer
tolifetheuni ver
seandeveryth ing
the ans wer
tol ifetheuniver
sea ndeverything

And then the final line indents it to make:
       the        answer
      toli      fetheuniv
     ersea     nde     ver
    ything     the     ans
   wer tol     ife     the
  uni  ver           sean
 dev   ery         thin
gth    ean       swer
tolifetheuni    ver
seandeveryth   ing
       the     ans      wer
       tol     ifetheuniver
       sea     ndeverything

Jelly, 76 bytes
“¡¢ʋỵṆ⁻kỴ⁷ṁḤæ ƊVṛĠ¥¡¢tṢ}ȧƘ=ẒṆ_`-p1ḷṠ’ḃ⁴ĖŒṙḂ¬R“£:(ḥB⁼Ṇ#¥Ṡ1ɗĠðȮ $¿⁹½ɓ»ṁȯ€⁶s27Y

Try it online!

Add++, 1398 bytes
+32
&
&
&
&
&
&
&
+84
&
-12
&
-3
&
-69
&
&
&
&
&
&
&
&
+65
&
+13
&
+5
&
+4
&
-18
&
+13
&
-104
&
+22
&
&
&
&
&
&
+84
&
-5
&
-3
&
-3
&
-73
&
&
&
&
&
&
+70
&
-1
&
+15
&
-12
&
-3
&
+16
&
-7
&
-5
&
+13
&
-108
&
+22
&
&
&
&
&
+69
&
+13
&
+1
&
-14
&
-4
&
-65
&
&
&
&
&
+78
&
-10
&
+1
&
-69
&
&
&
&
&
+86
&
-17
&
+13
&
-104
&
+22
&
&
&
&
+89
&
-5
&
-12
&
+1
&
+5
&
-7
&
-71
&
&
&
&
&
+84
&
-12
&
-3
&
-69
&
&
&
&
&
+65
&
+13
&
+5
&
-105
&
+22
&
&
&
+87
&
-18
&
+13
&
-82
&
+84
&
-5
&
-3
&
-76
&
&
&
&
&
+73
&
-3
&
-1
&
-69
&
&
&
&
&
+84
&
-12
&
-3
&
-91
&
+22
&
&
+85
&
-7
&
-5
&
-73
&
&
+86
&
-17
&
+13
&
-82
&
&
&
&
&
&
&
&
&
&
&
+83
&
-14
&
-4
&
+13
&
-100
&
+22
&
+68
&
+1
&
+17
&
-86
&
&
&
+69
&
+13
&
+7
&
-89
&
&
&
&
&
&
&
&
&
+84
&
-12
&
+1
&
+5
&
-100
&
+93
&
+13
&
-12
&
-72
&
&
&
&
+69
&
-4
&
+13
&
-78
&
&
&
&
&
&
&
+83
&
+4
&
-18
&
+13
&
-104
&
+106
&
-5
&
-3
&
-3
&
-3
&
-1
&
+15
&
-12
&
-3
&
+16
&
-7
&
-5
&
-73
&
&
&
&
+86
&
-17
&
+13
&
-104
&
+105
&
-14
&
-4
&
+13
&
-10
&
+1
&
+17
&
-17
&
+13
&
+7
&
-5
&
-12
&
-72
&
&
&
+73
&
+5
&
-7
&
-93
&
+22
&
&
&
&
&
&
&
+84
&
-12
&
-3
&
-69
&
&
&
&
&
+65
&
+13
&
+5
&
-83
&
&
&
&
&
&
+87
&
-18
&
+13
&
-104
&
+22
&
&
&
&
&
&
&
+84
&
-5
&
-3
&
-76
&
&
&
&
&
+73
&
-3
&
-1
&
+15
&
-12
&
-3
&
+16
&
-7
&
-5
&
+13
&
-17
&
+13
&
-104
&
+22
&
&
&
&
&
&
&
+83
&
-14
&
-4
&
-65
&
&
&
&
&
+78
&
-10
&
+1
&
+17
&
-17
&
+13
&
+7
&
-5
&
-12
&
+1
&
+5
&
-7
&
P

Try it online!
It looks like hardcoding it is the shortest way (at least in Add++)

Ruby, 216 bytes
o=i=1
puts"6iffnqxq0opdbco5e3f1zk5d7eezo2j6zwly9z5yykqsc1hl5svaof".to_i(36).to_s(17).chars.map{|c|
o=!o
c.to_i(17).times.map{o ? (i+=1)&&"ngtheanswertolifetheuniverseandeverythi"[i%39]:" "}.join
}.join.scan /.{1,27}/

Try it online!
Explanation Similar to the Python solutions but I used Run Length Encoding before converting to base 36. So the data string is only 54 characters instead of 68.
But it still ended up longer over all, hopefully it can be golfed further.

A port of my Charcoal answer:
C# (.NET Core), 229 bytes
_=>{var r="";for(int i=0,j,k=0,n=0;i<68;i++)for(j=0;j++<")%*(+&(+)''%'%'('%'%&%#%'%'%%%$%-&%%%%+&&%&%)&(.&%*.%%2%'%(%)%'.)%'."[i]-34;){r+=i%2<1?' ':"theanswertolifetheuniverseandeverything"[k++%39];if(++n%27<1)r+='\n';}return r;}

Try it online!

Retina, 185 bytes

7!8&sw'6Bi6fe!Av¶5#sea5nde5v'4y%g5!5&s¶3w#1B5ife5!¶2A2v#92se&¶1dev3#y9%¶gth4e&7sw'Bife!A4v'se&dev#yth3ing¶7!5&s6w'7B5ife!Av'7sea5ndev#y%g
'
#¶
&
an
%
thin
#
er
!
the
A
uni
B
tol
\d
$*

Try it online!

JavaScript, 215 bytes
solution based on guest44851
$=>'a21xb0k9qf30155yiv016ewp3018lkhz0ohfdb077or302cl5b0mgzr0b8hz028ghs7028gi67028gi67'.split(p=0).map(x=>parseInt(x,36).toString(2).slice(1).replace(/./g,x=>" theanswertolifetheuniverseandeverything"[+x&&1+p++%39]))

C (gcc), 220 219 217 213 210 bytes
-1 byte thanks to ceilingcat
-3 bytes thanks to Jerry Jeremiah
q,i,j,t;main(c){for(;c="HDIG@GEGJ@FFFDFD@EGFDFD@DDBDFDFD@CDCDLE@BDDDJE@ADEDHE@AMED@AMDD@HDFDGD@HDFM@HDFM"[t++];)for(c%=64,j=c?q=!q,c:2;--j;)putchar(c?q?32:"theanswertolifetheuniverseandeverything"[i++%39]:10);}

Try it online!

A function is only half a program - just use a full program for 214 bytes

@JerryJeremiah Very true; nice catch! Could shave one more byte from it too.

Pyth, 121 bytes
This contained too many bytes that I couldn't get to show up in TIO, so here's a hexdump:
00000000: 7558 6848 477c 2a64 6548 622c 5658 434d  uXhHG|*deHb,VXCM
00000010: 2290 8d8d 817e 7e7b 7875 7572 6663 5753  "....~~{xuurfcWS
00000020: 504d 4946 4343 3f3c 3939 3633 302d 2d2a  PMIFCC?<99630--*
00000030: 2721 211e 1b16 160d 0909 0300 225d 545d  '!!........."]T]
00000040: 3133 6a43 2202 1232 a464 b09d 7303 4244  13jC"..2.d..s.BD
00000050: 9386 74d2 e954 b89e e722 3132 2a34 2e22  ..t..T..."12*4."
00000060: 6179 1aa6 55ad c176 932b 6088 d5c5 556c  ay..U..v.+`...Ul
00000070: e4f4 5575 12a0 e7fb 1f                   ..Uu.....

Try it online!
You can add a call to wc or xxd in the bash script to see the byte length or the hexdump I produced above.
Interestingly, this program demonstrates a minor bug (?) in Pyth. Any carriage return bytes (0x0d) are read as newline bytes (0x0a) when in string literals. This forces me to add 6 bytes: X ... ]T]13 to replace the incorrect ten with a thirteen.
Otherwise the idea behind this code was fairly simple: record each position where a run of whitespace occurs. Then, pair each of those indices with the number of spaces in that run. Then, reconstruct the original string by repeating the phrase four times, then inserting in the correct locations. If the number of spaces recorded was zero, instead a newline is inserted.

Java (OpenJDK 8), 258 252 251 bytes
z->{int i=0,x,j,N[]={16515968,33489856,x=58950624,x+16,x-40,31458204,7865230,1966983,462847,233471,117670784,x=134185856,x};for(int n:N)for(j=32;j-->0;n/=2)System.out.print(n%2<1?j<1?"\n":" ":"theanswertolifetheuniverseandeverything".charAt(i++%39));}

Try it online!
It's a rather naive implementation. First a mask, for the printed characters, then a roll over the text until done.

6 bytes saved thanks to Carlos Alejo!

You can save some bytes with int[]{16515968,33489856,x=58950624,x+16,x-40,31458204,7865230,1966983,462847,233471,117670784,x=134185856,x}.

JavaScript, 265 237 219 bytes
(i=0)=>'jwq80,13ntvk,26p62g,25g7w8,239k3c,zg4xc,7rpbk,1e9dc,b8mw,5mbc,4f9reg,4f9r0g,4f9r0g'.split`,`.map(b=>parseInt(b,36).toString(2).slice(1).replace(/./g,c=>'  theanswertolifetheuniverseandeverything'[+c||2+i++%39]))

Few bytes off thanks to @tsh.
JSFiddle

.substr -> .slice(1) save some bytes

"Output can be in list of string" so just skip the join

Javascript, approximate drawing. 319 bytes
s=32
t="theanswertolifetheuniverseandeverything"
j=0
o=""
b=document.createElement('canvas'),c=b.getContext('2d')
b.width=b.height=s
c.font="25px Verdana"
c.fillText('42',0,20)
m=c.getImageData(0,0,s,s)
i=0
while(i<m.data.length) {
 d=m.data[i+3]
 o+=d?t[j%t.length]:" "
 if(d)j++
 i+=4
}
o.match(/.{1,32}/g).join("\n")

^ for what it's worth, not much really, but before I delete the failed code.


text:
Octal Calculator with Primality check
Problem
Build an octal calculator that can do the following operations:

Add (+)
Subtract (-)
Multiply (*)
Divide (/)
Check is prime

Counting in octal is like this with decimal
(Octal)  (Decimal)
0        0
1        1
2        2
3        3
4        4
5        5
6        6
7        7
10       8
11       9

and so on...
So given input a b c

a being a number in octal
b being an operator (+, -, *, /) not is prime
c being a number in octal

Output the expression evaluated as abc = Output (Is prime)
Test cases:
a=3, b='+', c=3 -> 6 (false)
a=5, b='+', c=5 -> 12 (false)
a=1, b='*', c=5 -> 5 (true)
a=7, b='+', c=6 -> 15 (true)
a=31, b='-', c=11 -> 20 (false)
a=25, b='/', c=3 -> 7 (true)
Rules:

The output just needs to contain the answer and a truthy/falsey value of whether it is prime so [4,0] is fine.
The inputs will always be a case that outputs an integer (integer division)
This is code golf so shortest answer wins

When is an octal number a prime

Can we do something like [12, 0] or [4, 1] instead of 12 (false) and 4 (true)?

Yes, will ammend.

...as if being octal is a property of numbers...

Can we get lists of octal digits?

Also, does division refer to integer division?

@EriktheOutgolfer Lets say a b and the answer will always be an integer

@LeakyNun It isn't but using them in code should atleast prove a challenge. Don't you agree.

@LiefdeWen Oh so I can assume integer division. What about an octal digit list?

@EriktheOutgolfer Added

@LiefdeWen Let us continue this discussion in chat.

@totallyhuman, you have to take 3 seperate strings though.

What should the primality test output on 1? Should it even be defined behavior?

One isn't a prime, and it is defined behavior for the case 2/1

But 1 isn't composite either.

@totallyhuman I don't understand?

@totallyhuman 1 is generally understood to not be a prime number. The definition of a prime number is exactly two positive divisors, 1 and the number itself. 1 only has 1 positive divisor, so it is not prime. https://en.wikipedia.org/wiki/Prime_number#Definition_and_examples see also https://oeis.org/A000040

Please provide examples for the other operations, especially the prime test.

@Titus I've added test cases for multiply and division, as for prime test, the prime test is always done at the end.

Mathematica, 38 bytes
{a=#@@(#~FromDigits~8&)/@#2,PrimeQ@a}&

Anonymous function. Takes input in the form ... &[Plus, {"7", "12"}] (with both numbers as octal strings and the operator being Plus, Subtract, Times, or Divide) and returns output in the form {17, True} (with the number in decimal.) Did this based on my own, possibly incorrect, interpretation of the rules; please comment if I did something wrong.

05AB1E, 13 bytes
‚8ö`³.VDps8B‚

Try it online!
Input format:
c
a
b

Output format:
[Is prime, 'Output']

Note that strings and numbers are equivalent datatypes in 05AB1E.

Hmm...not sure if valid.

@MagicOctopusUrn I don't think it'd behave correctly (also there's ð for ' ), since the operator is designed to work on base-10 ints, while it would have incorrect results with base-8 ints. Also you aren't supposed to check if the base-8 version is prime, but the integer itself before converting to base-8 with 8B.

No it still makes the operator work on the base-8 versions of the integers (something it's not supposed to do). Basically it would treat them as base-10 integers.

Back to disliking the challenge, get it now though.

JavaScript, 82 bytes
(a,b,c,k=m=eval((v=0)+a+b+v+c))=>{while(k-->3)m%k||(v=1);return[m.toString(8),!v]}

JSFiddle
Input is in octal base, output is also in octal base.

Python 2, 89 67 bytes
A whopping -22 bytes thanks to suggestions by Rod.
n=eval(''.join(input()))
print[oct(n),all(n%i for i in range(2,n))]

Try it online!
Takes input as:
['01', '*', '05']

Prints a list like:
['05', True]

You can drop both lambdas switching to input()/print to save 2 bytes, also since you are using eval, you don't need to convert to int(,8), you can use octa literals in the string to save 10+

1 is shown prime you need to add x>1and I guess.

Jelly, 12 bytes
Dḅ8jVµb8V,ÆP

Try it online!
Uses × for * and ÷ or : for / (approved by OP in chat).
Argument 1:
[a, c]

Argument 2:
b

Output:
[Output, Is prime]

PHP, 104 bytes
for(eval("\$i=\$n=octdec($argv[1])$argv[2]octdec($argv[3])|0;");--$i>1&&$n%$i;);echo
decoct($n),_,$i==1;

Run with -nr or try it online.
Output format: Result_1 for primes; Result_ for non-primes.
Output for negative results is faulty; replace the echo part with echo$n<0?-decoct(-$n):decoct($n),_,$i==1; (+17 bytes) to fix.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Old Cordless Phone
I need to call my friends but the buttons of my cordless phone are not working properly. The only buttons I can press are [Up], [Down] and [Call]. [Up] and [Down] can be used to navigate in my recent calls and [Call] can be used to call the selected name. My phone has a list that holds N recent calls, and I know that all the friends I need to call are in this list.

Task:
You'll receive a number N and a list of names L:

N is the number of recent calls my phone can remember;
L has the names in the order I need to call.

You must output the number of button presses I need to make in an optimal arrangement of the recent call list.

Example:
-> Input:
Calling Anna, Bob and then Anna again. With a recent calls list of size 5.
5
Anna
Bob
Anna

-> Output:
Possible optimal arrangement: Anna, Foo, Bar, Foobar, Bob
5    # Key presses: [Call] Anna, [Up] + [Call] Bob, [Down] + [Call] Anna

More test cases:
Input: 5, Anna, Bob, Carl
Output: 5

Input: 5, Anna, Bob, Carl, Anna
Output: 8

Input: 5, A, B, C, D, E, A
Output: 11

Input: 6, A, B, C, D, E, A
Output: 12

Input: 4, A, B, C, B, A
Output: 10

Rules:

Your cursor will always start in the first position of the list;
You can take the input N and L from any source: keyboard, parameters, file, etc;
The names in the list can be in any reasonable format such as: strings, integers, chars;
When you reach the end of the recent calls list and presses [Down] again, your cursor wraps around. The same happens when you're at the begining of the recent calls list and presses [Up];
When you call someone, that person's name will be moved to the first position of the recent calls list and the rest will be pushed down;
When you call someone, your cursor will be moved to the first position;
A friend name cannot appear more than once in the recent calls list;
You can fill your recent calls list with dummy entries (see example);
The number of friends to call will not be greater than N.

Ruby, 97 95 94 bytes
->n,a{r=a.size;1.upto(r-1){|i|r+=[p=a[(a[0,i].rindex(a[i])||i-2)+1...i].uniq.size,n-p].min};r}

Try it online!
In an optimal arrangement, the first name will take one press (Call). Names that have not been called yet take two presses (Up Call), and names that have take varying numbers depending on how many other unique names have been called since then and whether that places them closer to the top or the bottom of the list.
I think this is a strategy similar or identical to WaffleCohn's.

Python 3, 195 185 164 bytes
-4 bytes thanks to @notjagan
-27 bytes thanks to @FelipeNardiBatista
lambda n,l:min(g([*x],l,n)for x in permutations(range(n)))
def g(x,l,n,r=0):
 for p in l:a=x.index(p);x=[x.pop(a)]+x;r-=~min(a,n-a)
 return r
from itertools import*

Try it online!
L is taken as a list of integers from [0, N)

-4 bytes.

@notjagan This is not working as x=[x[a]]+x[:a]+x[a+1:] assigns x to a new list object. i would still be the indexmethod on the old list object

@ovs -10 bytes using Felipe's suggestion and the ones I had other than x.index.

164 bytes

@FelipeNardiBatista thanks a lot

JavaScript (SpiderMonkey), 213 143 bytes
(N,L)=>L.reduce((t,v,i)=>{x=0,a=[v]
for(j=i;j-->=0&!~a.indexOf(L[j]);x++)a+=L[j]+","
return i?t+((x=L.indexOf(v)-i?x:1)<N-x?x:N-x):t},L.length)

Try it online!
Generates an optimal arrangement of the given names then counts the number of key presses.
Skipped the generation and just counted how many key presses it would take each name in the optimal arrangement

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Find the closest Fibonacci Number
We are all familiar with the famous Fibonacci sequence, that starts with 0 and 1, and each element is the sum of the previous two. Here are the first few terms (OEIS A000045):
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584

Given a positive integer, return the closest number of the Fibonacci sequence, under these rules:

The closest Fibonacci number is defined as the Fibonacci number with the smallest absolute difference with the given integer. For example, 34 is the closest Fibonacci number to 30, because |34 - 30| = 4, which is smaller than the second closest one, 21, for which |21 - 30| = 9.

If the given integer belongs to the Fibonacci sequence, the closest Fibonacci number is exactly itself. For example, the closest Fibonacci number to 13 is exactly 13.

In case of a tie, you may choose to output either one of the Fibonacci numbers that are both closest to the input or just output them both. For instance, if the input is 17, all of the following are valid: 21, 13 or 21, 13. In case you return them both, please mention the format.

Default Loopholes apply. You can take input and provide output through any standard method. Your program / function must only handle values up to 108.

Test Cases

Input -> Output

1    -> 1
3    -> 3
4    -> 3 or 5 or 3, 5
6    -> 5
7    -> 8
11   -> 13
17   -> 13 or 21 or 13, 21
63   -> 55
101  -> 89
377  -> 377
467  -> 377
500  -> 610
1399 -> 1597

Scoring
This is code-golf, so the shortest code in bytes in every language wins!

Sandbox.

FWIW, here is some Python code on SO for doing this efficiently for large inputs, along with a script that can be used for timing various algorithms.

Is 0 considered as a positive integer?

@AlixEisenhardt No. Positive integer n implies n ≥ 1.

Python 2, 43 bytes
f=lambda n,a=0,b=1:a*(2*n<a+b)or f(n,b,a+b)

Try it online!
Iterates through pairs of consecutive Fibonacci numbers (a,b) until it reaches one where the input n is less than their midpoint (a+b)/2, then returns a.
Written as a program (47 bytes):
n=input()
a=b=1
while 2*n>a+b:a,b=b,a+b
print a

Same length:
f=lambda n,a=0,b=1:b/2/n*(b-a)or f(n,b,a+b)

Neim, 5 bytes
fS

Explanation:
f       Push infinite Fibonacci list
                      93
       Select the first ^ elements
        This is the maximum amount of elements we can get before the values overflow
        which means the largest value we support is 7,540,113,804,746,346,429
   S   Closest value to the input in the list

In the newest version of Neim, this can be golfed to 3 bytes:
fS

As infinite lists have been reworked to only go up to their maximum value.
Try it online!

How is this 5 bytes when there are 2 characters there? And what is the difference between the first and second solution?

Are you counting bytes or characters? It appears the first is 15 bytes, and the second 7 bytes.

This probably has some kind of own codepage in which each character is own byte meaning the first one is 5 bytes ans the second is 3 bytes. The difference between the two is that the first one selects the first 93 elements manual while the second snipet in a newer version automatically selects the highest possible value that the languages int size can handle

@cairdcoinheringaahing I've often had issues with people not being able to see my programs. Screenshot

@Nateowami Neim uses a custom codepage

Speaking of the codepage, what's the difference between 0x1E and 0x1F ?

@Okx Oh OK, interesting, I would not have guessed.

Python, 55 52 bytes
f=lambda x,a=1,b=1:[a,b][b-x<x-a]*(b>x)or f(x,b,a+b)

Try it online!

R, 70 67 64 62 60 bytes
-2 bytes thanks to djhurio!
-2 more bytes thanks to djhurio
(boy can he golf!)
F=1:0;while(F<1e8)F=c(F[1]+F[2],F);F[order((F-scan())^2)][1]

Since we only have to handle values up to 10^8, this works.
Try it online!
Reads n from stdin. the while loop generates the fibonacci numbers in F (in decreasing order); in the event of a tie, the larger is returned. This will trigger a number of warnings because while(F<1e8) only evaluates the statement for the first element of F with a warning
Originally I used F[which.min(abs(F-n))], the naive approach, but @djhurio suggested (F-n)^2 since the ordering will be equivalent, and order instead of which.min. order returns a permutation of indices to put its input into increasing order, though, so we need [1] at the end to get only the first value.
faster version:
F=1:0;n=scan();while(n>F)F=c(sum(F),F[1]);F[order((F-n)^2)][1]

only stores the last two fibonacci numbers

Nice one. -2 bytes F=1:0;n=scan();while(n>F)F=c(F[1]+F[2],F);F[order((F-n)^2)][1]

And the fast version with the same number of bytes F=1:0;n=scan();while(n>F)F=c(sum(F),F[1]);F[order((F-n)^2)][1]

@djhurio nice! thank you very much.

I like this. -2 bytes again F=1:0;while(F<1e8)F=c(F[1]+F[2],F);F[order((F-scan())^2)][1]

Using a builtin to generate the fibnums is shorter: numbers::fibonacci(x<-scan(),T)

And rank is shorter than order.

Jelly, 9 7 bytes
-2 bytes thanks to @EriktheOutgolfer
‘RÆḞạÐṂ

Try it online!
Golfing tips welcome :).  Takes an int for input and returns an int-list.
            ' input -> 4
‘           ' increment -> 5
 R          ' range -> [1,2,3,4,5]
  ÆḞ        ' fibonacci (vectorizes) -> [1,1,2,3,5,8]
     ÐṂ     ' filter and keep the minimum by:
    ạ       ' absolute difference -> [3,3,2,1,1,4]
            ' after filter -> [3,5]

You can remove µḢ.

@EriktheOutgolfer as in: "There is a way to do it if you think about it", or as in "If you literally just backspace them it still works"?

As in "it's allowed by the rules". :P

Ah.  Thank you!  (Filler text)

JavaScript (ES6), 41 bytes

f=(n,x=0,y=1)=>y<n?f(n,y,x+y):y-n>n-x?x:y
<input type=number min=0 value=0 oninput=o.textContent=f(this.value)><pre id=o>0

Rounds up by preference.

Almost identical to the version I was working on.  At least you didn't use the same variable names or I would have been freaked out.

@Grax Huh, now you mention it, Business Cat beat me to it...

(Well, almost... I made my version work with 0, because why not?)

f=(n,x=0,y=1)=>x*(2*n<x+y)||f(n,y,x+y)
Since you don't have to work with 0, you can golf a bit more.

Mathematica, 30 bytes
Array[Fibonacci,2#]~Nearest~#&

Try it online!

x86-64 Machine Code, 24 bytes
31 C0 8D 50 01 92 01 C2 39 FA 7E F9 89 D1 29 FA 29 C7 39 D7 0F 4F C1 C3

The above bytes of code define a function in 64-bit x86 machine code that finds the closest Fibonacci number to the specified input value, n.
The function follows the System V AMD64 calling convention (standard on Gnu/Unix systems), such that the sole parameter (n) is passed in the EDI register, and the result is returned in the EAX register.
Ungolfed assembly mnemonics:
; unsigned int ClosestFibonacci(unsigned int n);
    xor    eax, eax        ; initialize EAX to 0
    lea    edx, [rax+1]    ; initialize EDX to 1

  CalcFib:
    xchg   eax, edx        ; swap EAX and EDX
    add    edx, eax        ; EDX += EAX
    cmp    edx, edi
    jle    CalcFib         ; keep looping until we find a Fibonacci number > n

    mov    ecx, edx        ; temporary copy of EDX, because we 'bout to clobber it
    sub    edx, edi
    sub    edi, eax
    cmp    edi, edx
    cmovg  eax, ecx        ; EAX = (n-EAX > EDX-n) ? EDX : EAX
    ret

Try it online!
The code basically divides up into three parts:

The first part is very simple: it just initializes our working registers. EAX is set to 0, and EDX is set to 1.

The next part is a loop that iteratively calculates the Fibonacci numbers on either side of the input value, n. This code is based on my previous implementation of Fibonacci with subtraction, but…um…isn't with subtraction. :-) In particular, it uses the same trick of calculating the Fibonacci number using two variables—here, these are the EAX and EDX registers. This approach is extremely convenient here, because it gives us adjacent Fibonacci numbers. The candidate potentially less than n is held in EAX, while the candidate potentially greater than n is held in EDX. I'm quite proud of how tight I was able to make the code inside of this loop (and even more tickled that I re-discovered it independently, and only later realized how similar it was to the subtraction answer linked above).

Once we have the candidate Fibonacci values available in EAX and EDX, it is a conceptually simple matter of figuring out which one is closer (in terms of absolute value) to n. Actually taking an absolute value would cost way too many bytes, so we just do a series of subtractions. The comment out to the right of the penultimate conditional-move instruction aptly explains the logic here. This either moves EDX into EAX, or leaves EAX alone, so that when the function RETurns, the closest Fibonacci number is returned in EAX.

In the case of a tie, the smaller of the two candidate values is returned, since we've used CMOVG instead of CMOVGE to do the selection. It is a trivial change, if you'd prefer the other behavior. Returning both values is a non-starter, though; only one integer result, please!

NASM listings are nice for codegolf answers, since they mix the machine code bytes with the original commented source somewhat compactly.  I used nasm foo.asm -l /dev/stdout | cut -b -28,$((28+12))- to trim some columns between the machine code and source in a recent answer.

In 32-bit code, you can get eax=0 and edx=1 in only 4 bytes instead of 5, with xor eax,eax / cdq / inc edx.  So you could make a 32-bit custom-calling-convention version that saved a byte.

I used to do that, @Peter, but there's a lot of confusion here over submissions being in "assembly" or "machine code". Apparently some of the experienced users maintain that there is a difference, and object to my counting the bytes of machine code for an answer that is presented using assembly mnemonics. Naturally, I think this is stupid, because "assembly" is just a mnemonic representation of the machine bytes, but I got outvoted. I've found that the separate presentation creates less friction, even though I don't personally like it as well.

The other trick is nice—thanks. I should have thought of that, I use cdq a lot in code-golf answers. A custom calling convention isn't required. I usually use the Microsoft __fastcall calling convention for 32-bit code. The nice thing about this is it's supported by GCC with an annotation, so you can still use the TIO service that everyone wants to see.

Ah yes, any old register calling convention works for you . My most recent codegolf answer needed pointers in edi/esi for lodsb/stosb, and only x86-64 SysV does that (fun fact: on purpose for that reason, because some functions pass on their args to memset / memcpy, and I guess gcc at the time liked to inline string ops).

You obviously still need the machine code to be a literal part of the answer somehow.  I like either NASM listing format, or a disassembly.  I guess putting it totally separate (just bytes) helps people that are clueless about asm/machine-code, but I think it's useful to be able to easily see the size of each instruction.  And BTW, submitting an answer in asm source is a totally valid option, just like C.  NASM is a language, and so is pre-processed CPP + GNU as (for a .S file).  With the right %rep or times, you can even break the near-1:1 machine code:source relationship.

PowerShell, 80 74 bytes
param($n)for($a,$b=1,0;$a-lt$n;$a,$b=$b,($a+$b)){}($b,$a)[($b-$n-gt$n-$a)]

(Try it online! temporarily unresponsive)
Iterative solution. Takes input $n, sets $a,$b to be 1,0, and then loops with Fibonacci until $a is larger than the input. At that point, we index into ($b,$a) based on Boolean of whether the difference between the first element and $n is greater than between $n and the second element. That's left on the pipeline, output is implicit.

JavaScript (ES6), 67 bytes
f=(n,k,y)=>(g=k=>x=k>1?g(--k)+g(--k):k)(k)>n?x+y>2*n?y:x:f(n,-~k,x)

Test cases

f=(n,k,y)=>(g=k=>x=k>1?g(--k)+g(--k):k)(k)>n?x+y>2*n?y:x:f(n,-~k,x)

console.log(f(1   )) // -> 1
console.log(f(3   )) // -> 3
console.log(f(4   )) // -> 3 or 5 or 3, 5
console.log(f(6   )) // -> 5
console.log(f(7   )) // -> 8
console.log(f(11  )) // -> 13
console.log(f(17  )) // -> 13 or 21 or 13, 21
console.log(f(63  )) // -> 55
console.log(f(101 )) // -> 89
console.log(f(377 )) // -> 377
console.log(f(467 )) // -> 377
console.log(f(500 )) // -> 610
console.log(f(1399)) // -> 1597

JavaScript (Babel Node), 41 bytes
f=(n,i=1,j=1)=>j<n?f(n,j,j+i):j-n>n-i?i:j

Based on ovs's awesome Python answer
Try it online!
Ungolfed
f=(n,i=1,j=1)=> // Function f: n is the input, i and j are the most recent two Fibonacci numbers, initially 1, 1
 j<n?           // If j is still less than n
  f(n,j,j+i)    //  Try again with the next two Fibonacci numbers
 :              // Else:
  j-n>n-i?i:j   //  If n is closer to i, return i, else return j

This was commented on my answer but it would make it stop working for 0 (not that it needs to; I just want it to): f=(n,i=1,j=1)=>n+n<i+j?i:f(n,j,j+i)

Python, 74 bytes
import math
r=5**.5
p=r/2+.5
lambda n:round(p**int(math.log(n*2*r,p)-1)/r)

Try it online!
How it works
For all k ≥ 0, since |φ−k/√5| < 1/2, Fk = φk/√5 + φ−k/√5 = round(φk/√5).  So the return value switches from Fk − 1 to Fk exactly where k = logφ(n⋅2√5) − 1, or n = φk + 1/(2√5), which is within 1/4 of Fk + 1/2 = (Fk − 1 + Fk)/2.

Damn, I knew something like this had to be possible. Well done! (+1)

05AB1E, 6 bytes
nÅFs.x

Try it online!

Python 3, 103 bytes
import math
def f(n):d=5**.5;p=.5+d/2;l=p**int(math.log(d*n,p))/d;L=[l,p*l];return round(L[2*n>sum(L)])

Try it online!
Sadly, had to use a def instead of lambda... There's probably much room for improvement here.
Original (incorrect) answer:
 Python 3, 72 bytes
lambda n:r(p**r(math.log(d*n,p))/d)
import math
d=5**.5
p=.5+d/2
r=round

Try it online!
My first PPCG submission. Instead of either calculating Fibonacci numbers recursively or having them predefined, this code uses how the n-th Fibonacci number is the nearest integer to the n-th power of the golden ratio divided by the root of 5.

Nice job! Welcome to PPCG :)

To fairly calculate the byte count of your code I think you need to assign the lambda, as shown in the other Python answers. However, this algorithm doesn't always work correctly for n in range(1, 1+10**8). Eg, n=70 returns 89, but it should return 55. Here are the n values < 120 that it gives wrong  answers for: (27, 44, 70, 71, 114, 115, 116). For testing purposes, you may like to use the nearest_fib_PM2R function I linked in my comment on the question.

@PM2Ring You're right, I made a stupid mistake... I now have a correct solution, but with a lot more bytes. As for the lambda, I believe you're wrong. I believe the answers assigning lambda only do so because they use recursion. The other Python 3 answers doesn't assign the first lambda, for example.

C (gcc), 86 85 83 76 bytes
f(n){n=n<2?:f(n-1)+f(n-2);}i,j,k;g(n){for(;k<n;j=k,k=f(i++));n=k-n<n-j?k:j;}

Try it online!

Java (OpenJDK 8), 60 57 56 bytes
c->{int s=1,r=2;for(;c>r;s=r-s)r+=s;return c-s>r-c?r:s;}

Try it online!
-1 byte thanks to @Neil

Taxi, 2321 bytes
Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Trunkers.Go to Trunkers:n 1 l 1 l.0 is waiting at Starchild Numerology.1 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 l 2 l.Pickup a passenger going to Bird's Bench.Pickup a passenger going to Cyclone.Go to Cyclone:w 1 r 4 l.[a]Pickup a passenger going to Rob's Rest.Pickup a passenger going to Magic Eight.Go to Bird's Bench:n 1 r 2 r 1 l.Go to Rob's Rest:n.Go to Trunkers:s 1 l 1 l 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:w 2 r.Pickup a passenger going to Trunkers.Pickup a passenger going to Magic Eight.Go to Zoom Zoom:n.Go to Trunkers:w 3 l.Go to Magic Eight:e 1 r.Switch to plan "b" if no one is waiting.Pickup a passenger going to Firemouth Grill.Go to Firemouth Grill:w 1 r.Go to Rob's Rest:w 1 l 1 r 1 l 1 r 1 r.Pickup a passenger going to Cyclone.Go to Bird's Bench:s.Pickup a passenger going to Addition Alley.Go to Cyclone:n 1 r 1 l 2 l.Pickup a passenger going to Addition Alley.Pickup a passenger going to Bird's Bench.Go to Addition Alley:n 2 r 1 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 1 l.Switch to plan "a".[b]Go to Trunkers:w 1 l.Pickup a passenger going to Cyclone.Go to Bird's Bench:w 1 l 1 r 1 l.Pickup a passenger going to Cyclone.Go to Rob's Rest:n.Pickup a passenger going to Cyclone.Go to Cyclone:s 1 l 1 l 2 l.Pickup a passenger going to Sunny Skies Park.Pickup a passenger going to What's The Difference.Pickup a passenger going to What's The Difference.Go to What's The Difference:n 1 l.Pickup a passenger going to Magic Eight.Go to Sunny Skies Park:e 1 r 1 l.Go to Cyclone:n 1 l.Pickup a passenger going to Sunny Skies Park.Pickup a passenger going to What's The Difference.Go to Sunny Skies Park:n 1 r.Pickup a passenger going to What's The Difference.Go to What's The Difference:n 1 r 1 l.Pickup a passenger going to Magic Eight.Go to Magic Eight:e 1 r 2 l 2 r.Switch to plan "c" if no one is waiting.Go to Sunny Skies Park:w 1 l 1 r.Pickup a passenger going to The Babelfishery.Go to Cyclone:n 1 l.Switch to plan "d".[c]Go to Cyclone:w 1 l 2 r.[d]Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 2 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Try it online!
Try it online with comments!
Un-golfed with comments:
[ Find the Fibonacci number closest to the input ]
[ Inspired by: https://codegolf.stackexchange.com/q/133365 ]

[ n = STDIN ]
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Trunkers.
Go to Trunkers: north 1st left 1st left.

[ Initialize with F0=0 and F1=1 ]
0 is waiting at Starchild Numerology.
1 is waiting at Starchild Numerology.
Go to Starchild Numerology: west 1st left 2nd left.
Pickup a passenger going to Bird's Bench.
Pickup a passenger going to Cyclone.
Go to Cyclone: west 1st right 4th left.

[ For (i = 1; n > F(i); i++) { Store F(i) at Rob's Rest and F(i-1) at Bird's Bench } ]
[a]
Pickup a passenger going to Rob's Rest.
Pickup a passenger going to Magic Eight.
Go to Bird's Bench: north 1st right 2nd right 1st left.
Go to Rob's Rest: north.
Go to Trunkers: south 1st left 1st left 1st right.
Pickup a passenger going to Cyclone.
Go to Cyclone: west 2nd right.
Pickup a passenger going to Trunkers.
Pickup a passenger going to Magic Eight.
Go to Zoom Zoom: north.
Go to Trunkers: west 3rd left.
Go to Magic Eight: east 1st right.
Switch to plan "b" if no one is waiting.

[ n >= F(i) so iterate i ]
Pickup a passenger going to Firemouth Grill.
Go to Firemouth Grill: west 1st right.
Go to Rob's Rest: west 1st left 1st right 1st left 1st right 1st right.
Pickup a passenger going to Cyclone.
Go to Bird's Bench: south.
Pickup a passenger going to Addition Alley.
Go to Cyclone: north 1st right 1st left 2nd left.
Pickup a passenger going to Addition Alley.
Pickup a passenger going to Bird's Bench.
Go to Addition Alley: north 2nd right 1st right.
Pickup a passenger going to Cyclone.
Go to Cyclone: north 1st left 1st left.
Switch to plan "a".

[b]
[ F(i) > n which means n >= F(i-1) and we need to figure out which is closer and print it]
Go to Trunkers: west 1st left.
Pickup a passenger going to Cyclone.
Go to Bird's Bench: west 1st left 1st right 1st left.
Pickup a passenger going to Cyclone.
Go to Rob's Rest: north.
Pickup a passenger going to Cyclone.
Go to Cyclone: south 1st left 1st left 2nd left.
Pickup a passenger going to Sunny Skies Park.
Pickup a passenger going to What's The Difference.
Pickup a passenger going to What's The Difference.
[ Passengers:n, n, F(i-1) ]
Go to What's The Difference: north 1st left.
Pickup a passenger going to Magic Eight.
[ Passengers:n, n-F(i-1) ]
Go to Sunny Skies Park: east 1st right 1st left.
Go to Cyclone: north 1st left.
Pickup a passenger going to Sunny Skies Park.
Pickup a passenger going to What's The Difference.
[ Passengers: n-F(i-1), F(i-1), F(i) ]
Go to Sunny Skies Park: north 1st right.
Pickup a passenger going to What's The Difference.
[ Passengers: n-F(i-1), F(i), n ]
Go to What's The Difference: north 1st right 1st left.
[ Passengers: n-F(i-1), F(i)-n ]
Pickup a passenger going to Magic Eight.
Go to Magic Eight: east 1st right 2nd left 2nd right.
Switch to plan "c" if no one is waiting.

[ If no one was waiting, then {n-F(i-1)} < {F(i)-n} so we return F(i-1) ]
Go to Sunny Skies Park: west 1st left 1st right.
Pickup a passenger going to The Babelfishery.
Go to Cyclone: north 1st left.
Switch to plan "d".

[c]
[ Otherwise {n-F(i-1)} >= {F(i)-n} so we return F(i) ]
[ Note: If we didn't switch to plan c, we still pickup F(i) but F(i-1) will be the *first* passenger and we only pickup one at The Babelfishery ]
[ Note: Because of how Magic Eight works, we will always return F(i) in the event of a tie ]
Go to Cyclone: west 1st left 2nd right.
[d]
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 2nd right 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.

Python 3, 84 bytes
lambda k:min(map(f,range(2*k)),key=lambda n:abs(n-k))
f=lambda i:i<3or f(i-1)+f(i-2)

Try it online!
It may work, but it's certainly not fast...
Outputs True instead of  1, but in Python these are equivalent.

dc, 52 bytes
si1d[dsf+lfrdli>F]dsFxli-rlir-sdd[lild-pq]sDld<Dli+p

Try it online!
Takes input at run using ?
Edited to assume top of stack as input value, -1 byte.
Input is stored in register i. Then we put 1 and 1 on the stack to start the Fibonacci sequence, and we generate the sequence until we hit a value greater than i. At this point we have two numbers in the Fibonacci sequence on the stack: one that is less than or equal to i, and one that is greater than i. We convert these into their respective differences with i and then compare the differences. Finally we reconstruct the Fibonacci number by either adding or subtracting the difference to i.
Oops, I was loading two registers in the wrong order and then swapping them, wasting a byte.

Functions are allowed.

Thanks, I repeatedly missed that in the challenge's text.

C# (.NET Core), 63 56 bytes
-1 byte thanks to @Neil
-6 bytes thanks to @Nevay
n=>{int a=0,b=1;for(;b<n;a=b-a)b+=a;return n-a>b-n?b:a;}

Try it online!

Does for(;b<n;a=b,b+=c)c=a; save a byte?

You can remove c by using b+=a,a=b-a (should save 6 bytes).

Q/KDB+, 51 bytes
{w where l=min l:abs neg[x]+w:{x,sum -2#x}/[x;0 1]}

Welcome to PPCG!

Hexagony, 37 bytes
?\=-${&"*.2}+".|'=='.@.&}1.!_|._}$_}{

Try it online!
ungolfed:
   ? \ = -
  $ { & " *
 . 2 } + " .
| ' = = ' . @
 . & } 1 . !
  _ | . _ }
   $ _ } {

Broken down:
start:
? { 2 ' * //set up 2*target number
" ' 1     //initialize curr to 1

main loop:
} = +     //next + curr + last
" -       //test = next - (2*target)
branch: <= 0 -> continue; > 0 -> return

continue:
{ } = &   //last = curr
} = &     //curr = next

return:
{ } ! @   //print last

Like some other posters, I realized that when the midpoint of last and curr is greater than the target, the smaller of the two is the closest or tied for closest.
The midpoint is at (last + curr)/2. We can shorten that because next is already last + curr, and if we instead multiply our target integer by 2, we only need to check that (next - 2*target) > 0, then return last.

Brachylog, 22 bytes
;I≜-.∧{0;1⟨t≡+⟩ⁱhℕ↙.!}

Try it online!
Really all I've done here is paste together Fatalize's classic Return the closest prime number solution and my own Am I a Fibonacci Number? solution. Fortunately, the latter already operates on the output variable; unfortunately, it also includes a necessary cut which has to be isolated for +2 bytes, so the only choice point it discards is ⁱ, leaving ≜ intact.

Japt -g, 8 bytes
ò!gM ñaU

Try it

Java 7, 244 234 Bytes
 String c(int c){for(int i=1;;i++){int r=f(i);int s=f(i-1);if(r>c && s<c){if(c-s == r-c)return ""+r+","+s;else if(s-c > r-c)return ""+r;return ""+s;}}} int f(int i){if(i<1)return 0;else if(i==1)return 1;else return f(i-2)+f(i-1);}

Why don't you use Java 8 and turn this into a lambda? You can also remove static if you want to stick with Java 7.

You have two errors in your code (r>c&&s<c should be r>=c&&s<=c, s-c should be c-s), You could remove not required whitespace, use int f(int i){return i<2?i:f(--i)+f(--i);}, use a single return statement with ternary operator in c and remove the special handling for c-s==r-c as returning either value is allowed.

@Nevay I don't see the error, I've tested it without fails

The r>c&&s<c condition is never satisfied if the input is a fibonacci number, thus times out for 1 etc.

Pyke, 6 bytes
}~F>R^

Try it online!
}      -    input*2
 ~F    -   infinite list of the fibonacci numbers
   >   -  ^[:input]
    R^ - closest_to(^, input)

Common Lisp, 69 bytes
(lambda(n)(do((x 0 y)(y 1(+ x y)))((< n y)(if(<(- n x)(- y n))x y))))

Try it online!

Perl 6, 38 bytes
{(0,1,*+*...*>$_).sort((*-$_).abs)[0]}

Test it
{   # bare block lambda with implicit parameter ｢$_｣

  ( # generate Fibonacci sequence

    0, 1,  # seed the sequence
    * + *  # WhateverCode lambda that generates the rest of the values
    ...    # keep generating until
    * > $_ # it generates one larger than the original input
           # (that larger value is included in the sequence)

  ).sort(           # sort it by
    ( * - $_ ).abs  # the absolute difference to the original input
  )[0]              # get the first value from the sorted list
}

For a potential speed-up add .tail(2) before .sort(…).
In the case of a tie, it will always return the smaller of the two values, because sort is a stable sort. (two values which would sort the same keep their order)

Pyth, 19 bytes
JU2VQ=+Js>2J)hoaNQJ

Try it here
Explanation
JU2VQ=+Js>2J)hoaNQJ
JU2                  Set J = [0, 1].
   VQ=+Js>2J)        Add the next <input> Fibonacci numbers.
              oaNQJ  Sort them by distance to <input>.
             h       Take the first.

Haskell, 48 bytes
(%)a b x|abs(b-x)>abs(a-x)=a|1>0=b%(a+b)$x
(1%2)

Try it online!

K (ngn/k), 28 bytes
{F@&x=&/x|:-x-:F:x(+':1,)/1}

Try it online!

F:x(+':1,)/1 generate the first x+1 terms of the fibonacci sequence, storing in F (adapted from @ngn's answer here)
x-:F get the difference between x and each term of the sequence, updating x (which now becomes a list)
x|:-x take the absolute value of each, updating x
&x=&/x identify indices in sequence with the smallest value
F@ index into the actual sequence

Perl 5 -p, 48 bytes
($a,$.)=($.,$a+$.)while$.<$_;$_=2*$_-$a<$.?$a:$.

Try it online!

Pyth, 27 bytes
J[Z1)WgQeJ=aJ+eJ@J_2)hoaNQJ

Test suite.
Python 3 translation:
Q=eval(input())
def a(x):
    return abs(Q-x)
J=[0,1]
while Q>=J[-1]:
    J.append(J[-1]+J[-2])
print(sorted(J,key=a)[0])

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
ASCII 2D game-map
Problem
Given input a where a is a grid of characters in any input format as long as it has only one element for each 'block' of the output.
And input b where b is a grid of numbers the same size as input a.
There are two types of road, a 1 represents a stone road marked by @ and a 2 represents a dirt road marked by #

A @ road is centered in the block and is size 6x6, if a road is adjacent, that side is extended to grid cell border
A # road is centered in the block is size 4x4, if a road is adjacent, that side is extended to grid cell border

Output a grid offset by line number of 8x8 of the ASCII character in input a and overlay a 'road' from input b e.g.
Input a=[[a,b,a],[b,a,b],[a,b,a]] b=[[1,1,1],[2,0,1],[2,0,0]]
Output:
Step 1: the grid (8x8 representation of input a)
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
bbbbbbbbaaaaaaaabbbbbbbb
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa

Step 2: Overlay with roads represented by b:
aaaaaaaabbbbbbbbaaaaaaaa
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@@@@@@@@@@@@@@@@@a
a@@@@@@abbbbbbbba@@@@@@a
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaab@@@@@@b
bb####bbaaaaaaaabbbbbbbb
aa####aabbbbbbbbaaaaaaaa
aa####aabbbbbbbbaaaaaaaa
aa####aabbbbbbbbaaaaaaaa
aa####aabbbbbbbbaaaaaaaa
aa####aabbbbbbbbaaaaaaaa
aa####aabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa
aaaaaaaabbbbbbbbaaaaaaaa

Step 3: Offset each line with linenumber:
aaaaaaaabbbbbbbbaaaaaaaa
 a@@@@@@@@@@@@@@@@@@@@@@a
  a@@@@@@@@@@@@@@@@@@@@@@a
   a@@@@@@@@@@@@@@@@@@@@@@a
    a@@@@@@@@@@@@@@@@@@@@@@a
     a@@@@@@@@@@@@@@@@@@@@@@a
      a@@@@@@@@@@@@@@@@@@@@@@a
       a@@@@@@abbbbbbbba@@@@@@a
        bb####bbaaaaaaaab@@@@@@b
         bb####bbaaaaaaaab@@@@@@b
          bb####bbaaaaaaaab@@@@@@b
           bb####bbaaaaaaaab@@@@@@b
            bb####bbaaaaaaaab@@@@@@b
             bb####bbaaaaaaaab@@@@@@b
              bb####bbaaaaaaaab@@@@@@b
               bb####bbaaaaaaaabbbbbbbb
                aa####aabbbbbbbbaaaaaaaa
                 aa####aabbbbbbbbaaaaaaaa
                  aa####aabbbbbbbbaaaaaaaa
                   aa####aabbbbbbbbaaaaaaaa
                    aa####aabbbbbbbbaaaaaaaa
                     aa####aabbbbbbbbaaaaaaaa
                      aaaaaaaabbbbbbbbaaaaaaaa
                       aaaaaaaabbbbbbbbaaaaaaaa

Rules:

Leading whitespace or newlines allowed.
Trailing whitespace and newlines allowed.
This is code-golf so shortest code wins

Here is an extra test case with all edge cases in I can think of.

why only 1 newline allowed? can there be leading newlines (with whitespace)?

In the extra test case, array a is smaller than array b.

@dzaima Why should more be allowed?

@LiefdeWen they don't do any bad and give more golfing opportunities

@Zgarb fixed it, sorry all the commas blurred together.

@dzaima Okay, will ammend.

Now the '1' and some other characters seem to be in the wrong place.

@Zgarb fixed again.

It seems to me that your question is not well defined. First off, in your test case second row of input a is ['.', ',', '.', ',', '.', ',', '.'], but output is like that row was [',', '.', ',', '.', ',', '.', ','].
Also, what prevents you to have this as output from your test case: https://gist.github.com/anonymous/dfcf3b754464f3ca4394d34e9f3bf123
Notice that the second 1 from the first row of input b is adjacent to two 2's. Why did you chose to connect it only to first 2 (in the same row)?

Can we assume the elements in array a will never contain @ or #?

@DarrenH yes that's fine.

In your second test case, rows 9 and 10, columns 35-38, your answer returns the value of a, but mine returns the value of b because there is a road to the north (of a different type, but still a road). Have I misunderstood the requirement or is this a mistake in your test case?

@guest44851 I see no problem with the question itself, however my test case was wrong but it shouldn't be like your example, it should be how DarrenH described it, it's fixed now

@DarrenH you are correct, fixed my second test case.

May we take multi-line or single-line strings as input?

@Titus any input format is acceptable as long as there are two distinct inputs.

JavaScript (ES6), 250 207 bytes
Edit Bug fix :(
A function taking inputs in currying syntax (a)(b).
a=>b=>a.map((r,i)=>k.map(y=>(h+=' ')+r.map((c,j)=>k.map(x=>(t=x<v,s=x>7-v,!v|t&(!q[j-1]|w|u)|s&(!q[j+1]|w|u)|u&(!p[j]|t|s)|w&(!(b[i+1]||[])[j]|t|s)?c:'-@#'[v]),v=q[j],w=y>7-v,u=y<v).join``).join``,p=q,q=b[i]).join`
`,h=q=[],k=[...'01234567']).join`
`

Less golfed
a=>b=>a.map((r,i)=>
  [0,1,2,3,4,5,6,7].map(y=>
    (h+=' ') + r.map((c,j)=>
      [0,1,2,3,4,5,6,7].map(x=> (
        t=x<v, s=x>7-v,
        v == 0
        || t && (!B[i][j-1] | w|u)
        || s && (!B[i][j+1] | w|u)
        || u && (!(B[i-1]||[])[j] | t|s)
        || w && (!(B[i+1]||[])[j] | t|s)
        ? c : '-@#'[v] )
      , v = B[i][j], w=y>7-v,u=y<v).join``
    ).join``
  ).join`\n`
,h = '').join`\n`

Test

F=
a=>b=>a.map((r,i)=>k.map(y=>(h+=' ')+r.map((c,j)=>k.map(x=>(t=x<v,s=x>7-v,!v|t&(!q[j-1]|w|u)|s&(!q[j+1]|w|u)|u&(!p[j]|t|s)|w&(!(b[i+1]||[])[j]|t|s)?c:'-@#'[v]),v=q[j],w=y>7-v,u=y<v).join``).join``,p=q,q=b[i]).join`
`,h=q=[],k=[...'01234567']).join`
`

A=[['a','b','a'],['b','a','b'],['a','b','a']]
B=[[1,1,1],[2,0,1],[2,0,0]]

O.textContent = F(A)(B)+'\n'
A=[['.', ',', '.', ',', '.', ',', '.'],['.', ',', '.', ',', '.', ',', '.'],['.', ',', '.', ',', '.', ',', '1']]
B=[[0,1,0,0,1,2,0],[1,1,1,2,2,2,2],[0,2,0,0,0,1,0]]

O.textContent += F(A)(B)

PHP 857 bytes
Not really what anyone could call "golfed" but since nobody else seems to have entered anything at all, I figured this was a start. It's massive, but it seems to work. Will make an effort to golf it tomorrow if I get the time.
function a($a,$b){$c=sizeof($a);$d=sizeof($a[0]);for($e=0;$e<$c;$e++){for($f=0;$f<$d;$f++){$A=$GLOBALS['h']=$a[$e][$f];$i=$GLOBALS['i']=$b[$e][$f];$B=j($i==1&&$b[$e-1][$f]>0);$C=j($i==1&&$b[$e][$f+1]>0);$D=j($i==1&&$b[$e+1][$f]>0);$E=j($i==1&&$b[$e][$f-1]>0);$F=j($i>0&&$b[$e-1][$f]>0);$G=j($i>0&&$b[$e][$f+1]>0);$H=j($i>0&&$b[$e+1][$f]>0);$I=j($i>0&&$b[$e][$f-1]>0);$J=j($i==1);$K=j($i==1||($i>1&&$b[$e-1][$f]>0));$L=j($i==1||($i>1&&$b[$e][$f+1]>0));$M=j($i==1||($i>1&&$b[$e+1][$f]>0));$N=j($i==1||($i>1&&$b[$e][$f-1]>0));$O=j($i>0);$P=$e*8;$g[$P].="$A$B$F$F$F$F$B$A";$g[$P+1].="$E$J$K$K$K$K$J$C";$l="$I$N$O$O$O$O$L$G";$g[$P+2].=$l;$g[$P+3].=$l;$g[$P+4].=$l;$g[$P+5].=$l;$g[$P+6].="$E$J$M$M$M$M$J$C";$g[$P+7].="$A$D$H$H$H$H$D$A";}}foreach($g as$h){echo str_repeat(' ', $i++)."$h\n";}}function j($k){return($k)?strtr($GLOBALS['i'],'12','@#'):$GLOBALS['h'];}

Test case
error_reporting(0);
$a=[[a,b,a],[b,a,b],[a,b,a]];
$b=[[1,1,1],[2,0,1],[2,0,0]];
a($a,$b);

Output
aaaaaaaabbbbbbbbaaaaaaaa
 a@@@@@@@@@@@@@@@@@@@@@@a
  a@@@@@@@@@@@@@@@@@@@@@@a
   a@@@@@@@@@@@@@@@@@@@@@@a
    a@@@@@@@@@@@@@@@@@@@@@@a
     a@@@@@@@@@@@@@@@@@@@@@@a
      a@@@@@@@@@@@@@@@@@@@@@@a
       a@@@@@@abbbbbbbba@@@@@@a
        bb####bbaaaaaaaab@@@@@@b
         bb####bbaaaaaaaab@@@@@@b
          bb####bbaaaaaaaab@@@@@@b
           bb####bbaaaaaaaab@@@@@@b
            bb####bbaaaaaaaab@@@@@@b
             bb####bbaaaaaaaab@@@@@@b
              bb####bbaaaaaaaab@@@@@@b
               bb####bbaaaaaaaabbbbbbbb
                aa####aabbbbbbbbaaaaaaaa
                 aa####aabbbbbbbbaaaaaaaa
                  aa####aabbbbbbbbaaaaaaaa
                   aa####aabbbbbbbbaaaaaaaa
                    aa####aabbbbbbbbaaaaaaaa
                     aa####aabbbbbbbbaaaaaaaa
                      aaaaaaaabbbbbbbbaaaaaaaa
                       aaaaaaaabbbbbbbbaaaaaaaa

Test case
error_reporting(0);
$a=[['.', ',', '.', ',', '.', ',', '.'],['.', ',', '.', ',', '.', ',', '.'],['.', ',', '.', ',', '.', ',', '1']];
$b=[[0,1,0,0,1,2,0],[1,1,1,2,2,2,2],[0,2,0,0,0,1,0]];
a($a,$b);

Output
........,,,,,,,,........,,,,,,,,........,,,,,,,,........
 ........,@@@@@@,........,,,,,,,,.@@@@@@@,,,,,,,,........
  ........,@@@@@@,........,,,,,,,,.@@@@@@@######,,........
   ........,@@@@@@,........,,,,,,,,.@@@@@@@######,,........
    ........,@@@@@@,........,,,,,,,,.@@@@@@@######,,........
     ........,@@@@@@,........,,,,,,,,.@@@@@@@######,,........
      ........,@@@@@@,........,,,,,,,,.@@@@@@@,,####,,........
       ........,@@@@@@,........,,,,,,,,.@@@@@@.,,####,,........
        ........,@@@@@@,........,,,,,,,,..####..,,####,,........
         .@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,..####..,,####,,........
          .@@@@@@@@@@@@@@@@@@@@@@@##############################..
           .@@@@@@@@@@@@@@@@@@@@@@@##############################..
            .@@@@@@@@@@@@@@@@@@@@@@@##############################..
             .@@@@@@@@@@@@@@@@@@@@@@@##############################..
              .@@@@@@@@@@@@@@@@@@@@@@@,,,,,,,,........,,####,,........
               ........,@@@@@@,........,,,,,,,,........,,####,,........
                ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                 ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                  ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                   ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                    ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                     ........,,####,,........,,,,,,,,........,@@@@@@,11111111
                      ........,,,,,,,,........,,,,,,,,........,@@@@@@,11111111
                       ........,,,,,,,,........,,,,,,,,........,,,,,,,,11111111

Test case
error_reporting(0);
$a=[[p,p,p,p,h,h,h,p,p,p,p],[p,p,p,p,h,h,h,p,p,p,p],[p,p,p,p,h,h,h,p,p,p,p],[p,p,p,p,h,h,h,p,p,p,p],[p,p,p,p,h,h,h,p,p,p,p]];
$b=[[1,1,1,0,1,0,1,0,1,1,1],[1,0,1,0,1,0,1,0,1,0,1],[1,1,1,0,1,1,1,0,1,1,1],[1,0,0,0,1,0,1,0,1,0,0],[1,0,0,0,1,0,1,0,1,0,0]];
a($a,$b);

Output
pppppppppppppppppppppppppppppppphhhhhhhhhhhhhhhhhhhhhhhhpppppppppppppppppppppppppppppppp
 p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
  p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
   p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
    p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
     p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
      p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
       p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
        p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
         p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
          p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
           p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
            p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
             p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
              p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
               p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
                p@@@@@@pppppppppp@@@@@@ppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@pppppppppp@@@@@@p
                 p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                  p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                   p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                    p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                     p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                      p@@@@@@@@@@@@@@@@@@@@@@ppppppppph@@@@@@@@@@@@@@@@@@@@@@hppppppppp@@@@@@@@@@@@@@@@@@@@@@p
                       p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                        p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                         p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                          p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                           p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                            p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                             p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                              p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                               p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                 p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                  p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                   p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                    p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                     p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                      p@@@@@@ppppppppppppppppppppppppph@@@@@@hhhhhhhhhh@@@@@@hppppppppp@@@@@@ppppppppppppppppp
                                       pppppppppppppppppppppppppppppppphhhhhhhhhhhhhhhhhhhhhhhhpppppppppppppppppppppppppppppppp

Java - 661 bytes
Hi! This is my first submission here. If I did something wrong please tell me.
static void m(char[][]b,int[][]t){String z="";int w=b[0].length;int h=b.length;char[][]r=new char[h*8][w*8];for(int j=0;j<h;j++){for(int i=0;i<w;i++){for(int x=0;x<8;x++)for(int y=0;y<8;y++){r[j*8+y][i*8+x]=b[j][i];int n=t[j][i];if(n!=0){char c;int d,e;if(n==1){c='@';e=0;d=7;}else{c='#';e=1;d=6;}if(x>e&&y>e&&x<d&&y<d)r[j*8+y][i*8+x]=c;if(x>e&&x<d){if(j>0&&y<2&&t[j-1][i]!=0)r[j*8+y][i*8+x]=c;if(j<h-1&&y>5&&t[j+1][i]!=0)r[j*8+y][i*8+x]=c;}if(y>e&&y<d){if(i>0&&x<2&&t[j][i-1]!=0)r[j*8+y][i*8+x]=c;if(i<w-1&&x>5&&t[j][i+1]!=0)r[j*8+y][i*8+x]=c;}}}}for(int l=0;l<8;l++){System.out.println(z+Arrays.toString(r[j*8+l]).replaceAll("[\\[\\]]|[, ]\\s",""));z+=" ";}}}

You can try it here :)
Unminified:
static void m(char[][] b, int[][] t) {
    String z="";
    int w=b[0].length;int h=b.length;
    char[][]r=new char[h*8][w*8];
    for(int j=0;j<h;j++){
        for(int i=0;i<w;i++){
            for(int x=0;x<8;x++)for(int y=0;y<8;y++){
                r[j*8+y][i*8+x] = b[j][i];
                int n=t[j][i];
                if(n!=0){
                    char c;int d,e;
                    if(n==1){c='@';e=0;d=7;}
                    else{c='#';e=1;d=6;}
                    if(x>e&&y>e&&x<d&&y<d)r[j*8+y][i*8+x]=c;

                    if(x>e&&x<d){
                        if(j>0&&y<2&&t[j-1][i]!=0)r[j*8+y][i*8+x]=c;
                        if(j<h-1&&y>5&&t[j+1][i]!=0)r[j*8+y][i*8+x]=c;
                    }
                    if(y>e&&y<d){
                        if(i>0&&x<2&&t[j][i-1]!=0)r[j*8+y][i*8+x]=c;
                        if(i<w-1&&x>5&&t[j][i+1]!=0)r[j*8+y][i*8+x]=c;
                    }
                }
            }
        }
        for(int l=0;l<8;l++){System.out.println(z+Arrays.toString(r[j*8+l]).replaceAll("[\\[\\]]|[, ]\\s",""));z+=" ";}
    }
}

Ah, I must have forgotten to update the static version. Thanks for pointing that out!

@100Toby1 Hi Toby, Welcome and nice answer, you can change your ands to bitwise ands &&->& for a few bytes.

also if you init c='#',d=6,e=1 then you can remove the else  else{c='#';e=1;d=6;}

616 bytes

PHP, 275 268 266 264 252 bytes
<?foreach($_GET[a]as$y=>$r)for($z=8;$z--;)for($x=-print"
".$f.=" ";$w--||$c=$r[++$x+!$w=7];)echo[$a=($s=($m=$_GET[b])[$y])[$x+1],$a|$b=2>$n=$s[$x],1,1,1,1,$b|$a=$s[$x-1],$a][$w]*[$a=$m[$y+1][$x],$a|$b,1,1,1,1,$b|$a=$m[$y-1][$x],$a][$z]*$n?" @#"[$n]:$c;

takes input from GET parameters a and b, prints to STDOUT.
Try it online.
breakdown
foreach($_GET[a]as$y=>$r)   # loop 1: through rows of first array
    for($z=8;$z--;)             # loop 2: $z from 7 to 0 (line = 8*$y+7-$z)
        for($x=-print"\n".$f.=" ";  # print newline and padding
            $w--                        # loop 4: loop $w from 7 to 0 (column = 8*$x+7-$w)
            ||$c=$r[++$x+!$w=7];)   # loop 3: loop $c through characters in row
                echo
                [                               # vertical test
                    $a=($s=($m=$_GET[b])[$y])[$x+1],    # $m=2nd array, $s=current row
                                                        # $a=block to the right has road
                    $a|$b=2>$n=$s[$x],                  # $b=current block has brick road
                    1,1,1,1,
                    $b|$a=$s[$x-1],                     # $a=block to the left has road
                    $a
                ][$w]                               # index tests
                *
                [                               # horizontal test
                    $a=$m[$y+1][$x],                    # $a=block below has road
                    $a|$b,
                    1,1,1,1,
                    $b|$a=$m[$y-1][$x],                 # $a=block above has road
                    $a
                ][$z]                               # index tests
                *$n                             # is a road in this block?
                ?" @#"[$n]:$c;                  # if block&v-test&h-test then print road
                                                # else print character from 1st array

JavaScript - 299 bytes
(a,b,g=(x,y)=>!(b[y]||0)[x],u=s=r='',L='length',R='repeat')=>{for(y=v=-1;++y<a[L];)for(i=v;++i<8;)for(x=v,s+=`
`+r,r+=' ';m=b[y][++x],W=Q=a[y][x],W+=(Z=~m&1)?Q:u,D=(A=i<m)|(B=i>7-m)?W:u,p=g(x-1,y)?W:D,q=g(x+1,y)?W:D,x<a[0][L];)s+=p+(A&&g(x,y-1)||B&&g(x,y+1)||!m?Q:'@#'[Z])[R](8-(p+q)[L])+q;return s}

Try it here


text:
Shifting Caesars Shifts
Description
A Caesar Shift is a very simple monoalphabetic cipher where each letter gets replaced by the one after it in the alphabet. Example:
Hello world! -> IFMMP XPSME!

(IBSLR, EGUFV! is the output for the actual challenge, this was an example of shifting by 1.)
As you can see, spacing and punctuation remain unattuned. However, to prevent guessing the message, all letters are capitalized. By shifting the letters back, the message was deciphered, convenient, but also really easy to decipher by other persons who are supposed not to know what the message means.
So, we'll be helping Caesar a bit by using an advanced form of his cipher: the Self-shifting Caesar Shift!
Challenge
Your task is to write a program or function, that, given a string to encipher, outputs the encrypted string corresponding to the input. The advanced Caesar Shift works like this:
1. Compute letter differences of all adjacent letters:
    1.1. Letter difference is computed like this:

         Position of 2nd letter in the alphabet
        -Position of 1st letter in the alphabet
        =======================================
                              Letter difference

    1.2. Example input: Hello
         H - e|e -  l|l  -  l|l  -  o
         7 - 5|5 - 12|12 - 12|12 - 15 Letter differences: 3; -7; 0; -3
            =3|   =-7|     =0|    =-3

2. Assign the letters continously a letter difference from the list,
   starting at the second letter and inverting the differences:
    2.1. 2nd letter: first difference, 3rd letter: second difference, etc.

    2.2. The first letter is assigned a 1.

    2.3. Example input: Hello with differences 3; -7; 0; -3

         Letter || Value
         =======||======
            H   ||   1
            E   ||  -3
            L   ||   7
            L   ||   0
            O   ||   3

3. Shift the letters by the value x they have been assigned:
    3.1. In case of a positive x, the letter is shifted x letters to the right.
    3.2. In case of a negative x, the letter is shifted |x| letters to the left.
    3.3. In case of x = 0, the letter is not shifted.

    3.4. If the shift would surpass the limits of the alphabet, it gets wrapped around
         Example: Y + Shift of 2 --> A

    3.5. Example input: See the table under 2.3.

                ||       || Shifted
         Letter || Value || Letter
         =======||=======||=========
            H   ||   1   ||    I
            E   ||  -3   ||    B     Program output:
            L   ||   7   ||    S     IBSLR
            L   ||   0   ||    L
            O   ||   3   ||    R

Spaces and other special symbols, such as punctuation are skipped in this process. It is guaranteed that your program will be given a string containing only printable ASCII characters. The output of your function/program must only be in upper case.
This is code-golf, so standard loopholes apply, and may the shortest answer in bytes win!

Isn't E -3?

What if the letter difference brings the letter out of the alphabet? Like ZEN, for example. Z shifted by 1 is... A? (as a side note, the 05AB1E answer turns Z into A)

Test cases please. Also, which characters are skipped exactly? And what does it mean for them to be skipped? Are they removed altogether, or must they remain in the output?

Is it just me or is Hello, World! actually IBSLR, EGUFV!?

@Mr.Xcoder I assumed it would wrap, as the ceaser cipher traditionally doesn't use numerals or symbols.

Why did you vote to close? I will gladly adjust my challenge if it is a minor problem.

@racer290 generally a challenge is VTCd if there is anything important unclear, and then once that is cleared up, it is reopened. Since answerers couldn't correctly answer until they heard a verdict on wrapping, they VTCd. Now that you've fixed it, it won't be closed.

So to be clear, punctuation is skipped, so HELLO, WORLD and HELLOWORLD should have the same result (minus punctuation)? As Luis Mendo has asked, could we have a few more test cases?

@Giuseppe see the upvoted answers for test cases, they've been validated by OP as correct, I'd assume, or they'd have downvotes.

Did you mean for words like RELIEF and RELIES to both encipher to the same result SRSFAG?

Next time, you can use the sandbox to get feedback on your challenges before posting them.

@AndersKaseorg The cipher is such that plaintext isn't recoverable. In order to decypher the second character you need to know what the second character was (as the offset for it is the difference between the first character and the second).

@Draco18s it's actually only the modularity which makes this cipher unrecoverable. For each letter in the cipher text, there are only two ways to arrive there (either ' directly' or through modular wrapping), so there are only 2^n plain text candidates for each length n word in the cipher text, making this scheme a joke as both an attacker and the intended target need to spend the same amount of effort to decipher the code.

@Sanchisesabout Ah, yes, you are correct. :)

More examples please! You should at least add one verbose example with non-letters or provide more detailed instructions on how to handle them. Looking at some of the answers, I noticed that this seems unclear: A) They don´t get converted. B) They are removed. C) They are neither converted nor considered for the shifting.

05AB1E, 28 27 24 bytes
láÇ¥R`XIlvyaiAyk+Aèëy}u?

Try it online!
Explanation
l                          # convert input to lower case
 á                         # keep only letters
  Ç¥                       # compute deltas of character codes
    R`                     # reverse and push separated to stack
      X                    # push 1
       Ilv                 # for each char y in lower case input
          yai              # if y is a letter
             Ayk           # get the index of y in the alphabet
                +          # add the next delta
                 Aè        # index into the alphabet with this
            ëy             # else push y
              }            # end if
            u?             # print as upper case

We both get IBSLR, EGUFV! for Hello, World!, is that correct? Did OP just mess up that example?

@MagicOctopusUrn: His example in the beginning is just showing what a shift is. It just shifts by 1 letter so it's pretty misleading.

Python 3, 100 bytes
b=0
for c in map(ord,input().upper()):
 if 64<c<91:b,c=c,(c+c-(b or~-c)-65)%26+65
 print(end=chr(c))

Try it online!
b keeps track of the last letter’s ASCII code, or is initially zero; the formula c+c-(b or~-x) means a letter with ASCII code c gets shifted by c-b if b is non-zero, and c-(c-1) == +1 if b is zero (for the very first letter).
b will never become zero again, as the string is guaranteed to consist of printable ASCII characters.
Finally, 64<c<91 checks if c is an uppercase ASCII letter, and (…-65)%26+65 wraps everything back into the A-Z range.
ovs saved a byte. Thanks!

100 bytes

05AB1E, 32 30 29 bytes
lDáÇ¥1¸ìUvyaiAX¾èAyk+sè¼ëy}Ju

Try it online!

ES6 ( Javascript ) , 138 bytes :
s=>((s,a,f)=>((r=i=>s[i]&&(a[i]=String.fromCharCode((2*s[f](i)-(s[f](i-1)||71)-38)%26+64),r(i+1)))(0),a))(s.toUpperCase(),[],"charCodeAt")

http://jsbin.com/manurenasa/edit?console

doesn´t skip non-letters, it seems?

MATL, 27 bytes
tXkt1Y2mXH)tlwdh+64-lY2w)H(

Try it online!
I think this is the shortest I can get, but there are lots of different varieties since there is a lot of re-use of 'variables' (there are 3 t (duplication), and 2 w (swap) operations, clipboard H is used, and even then there is still a duplicate 1Y2...). Sadly, I couldn't save bytes with the automatic M clipboard.
Over half of the program is dedicated to making it uppercase and ignoring non-alphabetic characters - just the cipher is no more than 13 bytes (Try it online!)

Perl, 9089
Though non-codegolf languages are rarely competitive, we can go below 100 ;)
@a=split//,<>;say uc(++$a[0]).join'',map{uc chr(2*ord($a[$_+1])-ord($a[$_])+!$_)}0..$#a-1

I've decided to ungolf this:
@a = split//,<>; Takes input from STDIN, stores character list (with newline!) in @a.
say uc(++$a[0]) output uppercase first letter shifted by 1. Turns out you can increment a letter in perl if you use a prefix ++. This is a mutator ofc.
2*ord($a[$_+1])-ord($a[$_])+!$_ We are asked to take character at x, and add the difference + (x-(x-1)). Well that's 2x - (x-1). However: I changed the first letter! So I've got to correct that error, hence +!$_, which will correct for having subtracted one too many at position 0 (only case !$_ is not undef ). We then uc chr to get an uppercase letter from the calculated ASCII value.
map{ ... } $#a-2 - $#a is the position to access the last array element. Since I'm adding one I want $#a-1, but because the newline from input needs ignoring, this is $#a-2.
This is concatenated with the first letter, and we are done :)

This seems to have some problems dealing with offsets that wrap around the alphabet and with non-alphabetic characters.  Try it online!

@Xcali the question clearly states "string containing only printable ASCII characters", so I don't care about the characters in your example, and shouldn't have to

Perl 5 -F, 73 77 74 bytes
/\w/&&($_=chr 65+(2*($n=ord uc)-65-($!||-1+ord uc))%26)&($!=$n)for@F;say@F

Try it online!

This doesn´t totally skip non-letters; it just doesn´t convert them. I think Hello, World! should result in IBSLR, EGUFV!, not IBSLR, XGUFV!.

You're right.  Fixed it with 4 more bytes to preserve the previous letter.

PHP, 106 98 bytes
pretty nasty that one ... if just base_convert wasn´t that long (or ctype_alpha) ...
but I got it under 100. satisfied.
for(;$a=ord($c=$argn[$i++]);print ctype_alpha($c)?chr(65+($p?(25-$p+2*$p=$a)%26:$p=$a)):$c)$a&=31;

Run as pipe with -nR or try it online.

JavaScript (Node.js), 86 83 87 81 bytes
s=>s.replace(/[a-z]/gi,(x,i)=>Buffer(x).map(x=>((i?x%32-l:1)+26+(l=x%32))%26+64))

Try it online!

@Nit fixed it :)


text:
your Uncle help Drunk needs
Drunk Uncle (sorry M.E. and AUS for region lock) is a fictional character from Saturday Night Live. He often confuses words for others that sound like them. For this challenge you need to convert normal speech into drunkspeak.
Algorithm
Translating to drunkspeak requires swapping the order of words in the text. Swapping is based on the drunkenness similarity of two words. Drunkenness similarity is defined as the number of letters that two words have occuring at the same indices. However, two identical words have a drunkenness similarity of -1. For example, tree and friend have a drunkenness similarity of 2, because they both have an 'r' at index 1, and an 'e' at index 3.
All you have to do is find the two words in the text with the highest drunkenness similarity, then swap them. Once you swap two terms, they do not move any more. Then you look at the remaining swappable terms and swap the two that have the highest drunkenness similarity. You keep doing this until you can't swap any more. Then you output (or return, for a function) the updated text.
Specifics

For simplicity, input is a list of words consisting of characters in [A-Za-z]
Every input contains at least one word
Letter matching is case-insensitive: A matches with a (Note: Due to this rule Dog and dog are identical, and thus have a D.S. of -1)
If multiple pairs have the highest drunkenness similarity:

Of the words, that can maximize drunkenness similarity, pick the one with the lowest index in the list
Pair that word with the lowest-index word that maximizes drunkenness similarity

Examples

Drunk Uncle needs your help (title)

S1: Drunk<=>your (DS: 1) your Uncle needs Drunk help
S2: needs<=>help (DS: 1) your Uncle help Drunk needs
Output: your Uncle help Drunk needs

I love fidget spinners (boring example)

S1: I<=>love (DS: 0) love I fidget spinners
S2: fidget<=>spinners (DS: 0) love I spinners fidget

dog eat dog ear

S1: eat<=>ear (DS: 2) dog ear dog eat
S2: dog<=>dog (DS: -1) dog ear dog eat (this step just formality)

Let me tell you a story

S1: Let<=>me (DS: 1) me Let tell you a story
S2: tell<=>you (DS: 0) me Let you tell a story
S3: a<=>story (DS: 0) me Let you tell story a

Too many money and purple people

S1: purple<=>people (DS: 4) Too many money and people purple
S2: many<=>money (DS: 2) Too money many and people purple
S3: Too<=>and (DS: 0) and money many Too people purple

Let me know if there are more examples you want me to cover.

please change 'i love fid-get spinners' to 'i hate fid-get spinners'

"natural language"

JavaScript - 286 279 bytes
f=(a,n=(a=a.split` `).length)=>{for(d=n>>1;w=-2,d--;){for(i=n;i--;)for(j=n;j--;)s=((a,f,v=0)=>{for(u=s=a!=f;(r=a[v])&&(t=f[v++]);s+=(p=a=>a.toLowerCase())(r)==p(t));return u*s-1})(a[i],a[j]),!(f[i]|f[j])&&s>=w&&(w=s,x=i,y=j);f[x]=f[y]=1,[a[x],a[y]]=[a[y],a[x]];}return a.join` `}

You can try it on JSFiddle.

Welcome (again) to PPCG :) Nice first submission!

Python 3, 285 277 270 267 Bytes, not working
i=input().split();r=range;l=len;t=y=z=-1;n=str.lower
for p in r(l(i)):
 for q in r(p):
  b=min(l(i[p]),l(i[q]));x=0
  for s in r(b):
   if n(i[p][s])==n(i[q][s]):
    x=x+1
  if n(i[p])==n(i[q]):
   x=-1
  if x>t:
   t=x;y=p;z=q
i[y],i[z]=i[z],i[y]
print(" ".join(i))
I tried to make the output match the challenge, not the test cases, as a couple of the test cases contradict the challenge.
Edit: golfed the 'lower' thingy.
Edit: changed split(" ") to split()
Edit: I realised this doesn't actually complete all the thingys, and while I might come up with a full working answer, in the meantime I might as well add that this only completes one iteration.

You need to define either g = str.lower or g = lambda s: s.lower() which you then can use like this.

@Bruce Forte Thanks! This got rid of 8 bytes. (It only went down to 270 though because I also had to fix a thing to make it so that it would swap words even if the highest similarity was 0; this added a byte).

No problem and welcome to PPCG! If you haven't seen already, these kind of posts are very helpful. Btw .split(' ') can be replaced by .split().

Wait, which test cases did you change,  and what was wrong with them?

I don't have enough rep to change a post, but the apparent contradiction was for the first example - the given answer for 'drunk uncle needs your help' was 'your uncle help drunk needs' over 'your uncle needs drunk help'. Both of these answers swapped words with the same similarity score, and they both follow your given tie-breaker by using the first of the pair to decide which to swap, in the sense that they both start with the first word. (I realise now as I write this that the contradiction is not really that, but more an ambiguity). The given way to decide- running out of chars see next-

The given way to decide between these is to choose the matching word, or as you more subtly/literally put it 'the one that maximises drunk ness similarity with that word'. This would make sense in a situation with two pairs of words, but in this example it is still ambiguous. Can I assume, that in a situation like this, you would choose the one with the lowest index (furthest from the left)?

Yes, I meant to say in the case of a tie, first pick the left-most word that can get a max DS. Then match it with the left-most word that achieves max DS.

@geokavel That's kind of handy as that's what both a) I interpreted it as before I re-read it and b) that's what I wrote the code to do. Also, I just realised that all the examples are correct, for some reason I didn't get that the S1 and S2 (and S3) were you feeding each answer back in.

Wait a minute, If you feed in an answer into the formula, it reverses the drunkness

@geokavel I also just realised that following the formula, if you put a drunkspeak answer into the formula, it won't drunkify it further - the most similar words in the sentence are the pair you just swapped, so it will swap them... reversing the drunkness.

Yeah, I dont exactly feed it back in. I just follow these rules: 1) Words that have moved can't move again. 2) Keep swapping until there's no pairs left to swap.

@geokavel I... didn'tsee that. I don't think I'm good at reading. Back to the drawing board it is