text:
Fully-justify & hyphenate a block of text
Given  a width  and  a block  of
text containing possible hyphen-
ation points,  format it  fully-
justified (in monospace).

Fully justified means it is aligned on the left and the right, and is achieved by increasing the spacing between words until each line fits.
Related:

Justify a text by adding spaces
Align the text to a block
And in a way this can be considered the next step in Text Processing #1: Hyphenation (which seems to have never been posted).

Input
You can take input in any format you like. You will be given:

A target width (in characters), in the range 5-100 (inclusive);
A block of text containing possibly hyphenated words. This could be a space-separated string, an array of words, or an array of arrays of word fragments (or any other data representation you desire).

A typical input might be:
Width: 25
Text:  There's no bu-si-ne-ss lik-e s-h-o-w busine-ss, n-o bus-iness I know.

Where the hyphens denote possible hyphenation points, and the spaces denote word boundaries. A possible alternative representation of the text:
[["There's"], ["no"], ["bu", "si", "ne", "ss"], ["lik", "e"], (etc.)]

Output
The input text with spaces added between words, newlines at the column width, and hyphenation points chosen to fully-justify it to the column width. For functions, an array of strings (one for each line) can be returned instead of using newline separation.
A possible output for the above input might be:
There's no  business like
show  business,  no  bus-
iness I know.

Note that all hyphens have been removed except the one in the final "bus-iness", which is kept to show that the word wraps to the next line, and was chosen to ensure the second line contains as much text as possible.
Rules

Within each line, the number of spaces between words cannot vary by more than 1, but where you insert the extra spaces is otherwise up to you:
hello hi foo     bar    <-- not permitted (1,1,5)
hello  hi foo    bar    <-- not permitted (2,1,4)
hello  hi  foo   bar    <-- OK (2,2,3)
hello  hi   foo  bar    <-- OK (2,3,2)
hello   hi  foo  bar    <-- OK (3,2,2)

No line can begin or end with spaces (except the last line, which can end with spaces).
The last line should be left justified, containing single spaces between each word. It can be followed by arbitrary whitespace / a newline if desired, but this is not required.
Words will consist of A-Z, a-z, 0-9 and simple punctuation (.,'()&)
You can assume that no word fragment will be longer than the target width, and it will always be possible to fill lines according to the rules (i.e. there will be at least 2 word fragments on each line, or 1 word fragment which fills the line perfectly)
You must choose hyphenation points which maximise the number of word characters on earlier lines (i.e. words must be consumed greedily by lines), for example:
This is an input stri-ng with hyph-en-at-ion poi-nts.

This     is     an     input    stri-      <-- not permitted
ng with hyphenation points.

This  is an  input string  with hyph-      <-- not permitted
enation points.

This is an input  string with hyphen-      <-- OK
ation points.

Shortest code in bytes wins

Examples
Width: 20
Text:  The q-uick brown fox ju-mp-s ove-r t-h-e lazy dog.

The quick  brown fox
jumps over the  lazy
dog.

Width: 32
Text: Given a width and a block of text cont-ain-ing pos-sible hyphen-ation points, for-mat it ful-ly-just-ified (in mono-space).

Given  a width  and  a block  of
text containing possible hyphen-
ation points,  format it  fully-
justified (in monospace).

Width: 80
Text:  Pro-gram-ming Puz-zles & Code Golf is a ques-tion and ans-wer site for pro-gram-ming puz-zle enth-usi-asts and code golf-ers. It's built and run by you as part of the St-ack Exch-ange net-work of Q&A sites. With your help, we're work-ing to-g-et-her to build a lib-rary of pro-gram-ming puz-zles and their sol-ut-ions.

Programming Puzzles &  Code Golf  is a question and answer  site for programming
puzzle enthusiasts  and code golfers.  It's built and run  by you as part of the
Stack Exchange network  of Q&A sites. With your help,  we're working together to
build a library of programming puzzles and their solutions.

Width: 20
Text:  Pro-gram-ming Puz-zles & Code Golf is a ques-tion and ans-wer site for pro-gram-ming puz-zle enth-usi-asts and code golf-ers. It's built and run by you as part of the St-ack Exch-ange net-work of Q&A sites. With your help, we're work-ing to-g-et-her to build a lib-rary of pro-gram-ming puz-zles and their sol-ut-ions.

Programming  Puzzles
&  Code  Golf  is  a
question and  answer
site for programming
puzzle   enthusiasts
and  code   golfers.
It's  built  and run
by  you  as  part of
the  Stack  Exchange
network    of    Q&A
sites.   With   your
help,  we're working
together to  build a
library of  program-
ming   puzzles   and
their solutions.

Width: 5
Text:  a b c d e f g h i j k l mm nn oo p-p qq rr ss t u vv ww x yy z

a b c
d e f
g h i
j k l
mm nn
oo pp
qq rr
ss  t
u  vv
ww  x
yy z

Width: 10
Text:  It's the bl-ack be-ast of Araghhhhh-hhh-h-hhh-h-h-h-hh!

It's   the
black  be-
ast     of
Araghhhhh-
hhhhhhhhh-
hhh!

Yesss, finally another (text-based) [tag:typography] challenge :-)

May we use built-ins and libraries?

@Adám yes to builtins: there's no code restrictions, and shortest code wins. Though of course, it might make for a boring answer! As for libraries, you can as long as the library is freely available and you mark your answer as "language + library". Also the library version has to pre-date this challenge.

Mathematica: Hyphenation -> True, TextJustification -> 1, Done!  ;-)

In the event that a line can end with either a hyphen or a single character, e.g. anybod-y with width 7, may we choose to output either anybody or anybod-\ny?

@JonathanAllan yes; sorry, I'll fix that

@darrylyeo no you have to output the full word in that case, since it must greedily have as many word characters as possible on each line.

JavaScript (ES6), 218 bytes
w=>s=>s.map((c,i)=>c.map((p,j)=>(k+p)[l="length"]-w-(b=!i|j>0)+(j<c[l]-1)<0?k+=b?p:" "+p:(Array(w-k[l]-b).fill(h=k.split` `).map((_,i)=>h[i%(h[l]-1)]+=" "),o.push(h.join` `+(b?"-":"")),k=p)),o=[],k="")&&o.join`
`+`
`+k

Takes arguments in currying syntax (f(width)(text)) and the text input is in the double array format described in the challenge. Strings are converted to that format via .split` `.map(a=>a.split`-`)). Also, the newlines are literal newlines inside template strings.
Un-golfed and rearranged
width=>string=> {
    out=[];
    line="";
    string.map((word,i)=> {
        word.map((part,j)=> {

            noSpaceBefore = i==0 || j>0;
            if ((line+part).length - width - noSpaceBefore + (j<word.length-1) < 0) {
                line += noSpaceBefore ? part : " "+part;
            }
            else {
                words=line.split` `;
                Array(width - line.length - noSpaceBefore).fill()
                    .map((_,i) => words[i % (words.length-1)] += " ");
                out.push(words.join(" ") + (noSpaceBefore? "-" : ""));
                line=part;
            }
        });
    });
    return out.join("\n") + "\n"+line
}

The idea here was to step through each part of the entire string and build up each line one part at a time. Once a line was complete, it increases the word spacing from left to right until all extra spaces are placed.
Test Snippet

f=
w=>s=>s.map((c,i)=>c.map((p,j)=>(k+p)[l="length"]-w-(b=!i|j>0)+(j<c[l]-1)<0?k+=b?p:" "+p:(Array(w-k[l]-b).fill(h=k.split` `).map((_,i)=>h[i%(h[l]-1)]+=" "),o.push(h.join` `+(b?"-":"")),k=p)),o=[],k="")&&o.join`
`+`
`+k

<div oninput="O.innerHTML=f(+W.value)(S.value.split` `.map(a=>a.split`-`))">
Width: <input type="number" size="3" min="5" max="100" id="W">
Tests: <select id="T" style="width:20em" oninput="let x=T.value.indexOf(','),s=T.value;W.value=s.slice(0,x);S.value=s.slice(x+2)"><option></option><option>20, The q-uick brown fox ju-mp-s ove-r t-h-e lazy dog.</option><option>32, Given a width and a block of text cont-ain-ing pos-sible hyphen-ation points, for-mat it ful-ly-just-ified (in mono-space).</option><option>80, Pro-gram-ming Puz-zles & Code Golf is a ques-tion and ans-wer site for pro-gram-ming puz-zle enth-usi-asts and code golf-ers. It's built and run by you as part of the St-ack Exch-ange net-work of Q&A sites. With your help, we're work-ing to-g-et-her to build a lib-rary of pro-gram-ming puz-zles and their sol-ut-ions.</option><option>20, Pro-gram-ming Puz-zles & Code Golf is a ques-tion and ans-wer site for pro-gram-ming puz-zle enth-usi-asts and code golf-ers. It's built and run by you as part of the St-ack Exch-ange net-work of Q&A sites. With your help, we're work-ing to-g-et-her to build a lib-rary of pro-gram-ming puz-zles and their sol-ut-ions.</option><option>5, a b c d e f g h i j k l mm nn oo p-p qq rr ss t u vv ww x yy z</option><option>10, It's the bl-ack be-ast of Araghhhhh-hhh-h-hhh-h-h-h-hh</option></select>

Text:  <textarea id="S" cols="55" rows="4"></textarea>

GNU sed -r, 621 bytes
Takes input as two lines: The width as a unary number first and the string second.
I'm certain this could be golfed much more but I've already dumped way too much time into it.
x;N
G
s/\n/!@/
:
/@\n/bZ
s/-!(.*)@ /\1 !@/
s/!(.*[- ])(@.*1)$/\1!\2/
s/@(.)(.*)1$/\1@\2/
s/-!(.*-)(@.*)\n$/\1!\2\n1/
s/(\n!@) /\1/
s/-!(.* )(@.*)\n$/\1!\2\n1/
s/-!(.*-)(@.*1)$/\1!\21/
s/!(.*)-@([^ ]) /\1\2!@ /
t
s/ !@(.*)\n$/\n!@\1#/
s/!(.*-)@(.*)\n$/\1\n!@\2#/
s/!(.*)(@ | @)(.*)\n$/\1\n!@\3#/
s/-!(.*[^-])@([^ ]) (.*)\n$/\1\2\n!@\3#/
s/!(.+)@([^ ].*)\n$/\n!@\1\2#/
/#|!@.*\n$/{s/#|\n$//;G;b}
:Z
s/-?!|@.*//g
s/ \n/\n/g
s/^/%/
:B
G
/%.*\n.+\n/!bQ
:C
s/%([^\n])(.*)1$/\1%\2/
tC
s/([^\n]+)%\n/%\1\n/
:D
s/%([^ \n]* )(.*)1$/\1 %\2/
tD
s/(^|\n)([^\n]+)%(.*1)$/\1%\2\3/
tD
s/%([^\n]*)\n(.*)\n$/\1\n%\2/
tB
:Q
s/%(.*)\n1*$/\1/

Try it online!
Explanation
The program works in two phases: 1. Split, and 2. Justify. For the below, suppose our input is:

111111111111
I re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.

Setup
First we read the input, moving the first line (the width as a unary number) to the hold space (x), then appending the next line (N) and then a copy of the width from the hold space (G) to the pattern space. Since N left us with a leading \n we replace it with !@, which we'll use as cursors in Phase 1.
x;N
G
s/\n/!@/

Now the content of the hold space is 1111111111111 (and won't change henceforth) and the pattern space is (in the format of sed's "print unambiguously" l command):

!@I re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n111111111111$

Phase 1
In Phase 1, the main @ cursor advances one character at a time, and for each character a 1 is removed from the "counter" at the end of the pattern space. In other words, @foo\n111$, f@oo\n11$, fo@o\n1$, etc.
The ! cursor trails behind the @ cursor, marking places we could break if the counter reaches 0 in the middle of the line. A couple rounds would look like this:

!@I re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n111111111111$
!I@ re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n11111111111$
!I @re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n1111111111$

Here there's a pattern we recognize: a space immediately followed by the @ cursor. Since the counter is greater than 0, we advance the break marker, then keep advancing the main cursor:

I !@re-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n1111111111$
I !r@e-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n111111111$
I !re@-mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n11111111$
I !re-@mem-ber a time of cha-os, ru-ined dreams, this was-ted land.\n1111111$

Here's another pattern: -@, and we still have 7 in the counter, so we advance the break cursor again and keep advancing:

I re-!mem-@ber a time of cha-os, ru-ined dreams, this was-ted land.\n111$

Here's a different pattern: A hyphen immediately preceding the break cursor and another preceding the main cursor. We remove the first hyphen, advance the break cursor, and, since we removed a character, add 1 to the counter.

I remem-!@ber a time of cha-os, ru-ined dreams, this was-ted land.\n1111$

We keep advancing the main cursor:

I remem-!ber@ a time of cha-os, ru-ined dreams, this was-ted land.\n1$

Similar to before, but this time the main cursor precedes a space rather than following a hyphen. We remove the hyphen, but since we're also advancing the main cursor we neither increment no decrement the counter.

I remember !@a time of cha-os, ru-ined dreams, this was-ted land.\n1$
I remember !a@ time of cha-os, ru-ined dreams, this was-ted land.\n$

Finally, our counter has reached zero. Since the character after the main cursor is a space, we insert a newline and put both cursors immediately after it. Then we replenish the counter (G) and start again.

I remember a\n!@ time of cha-os, ru-ined dreams, this was-ted land.\n111111111111$

Phase 1 continues, advancing the cursors and matching various patterns, until the @ cursor reaches the end of the string.
# Phase 1
:
  # End of string; branch to :Z (end of phase 1)
  /@\n/bZ

  # Match -!.*@_
  s/-!(.*)@ /\1 !@/

  # Match [-_]@ and >0
  s/!(.*[- ])(@.*1)$/\1!\2/

  # Advance cursor
  s/@(.)(.*)1$/\1@\2/

  # Match -!.*-@ and 0; add 1
  s/-!(.*-)(@.*)\n$/\1!\2\n1/

  # Match \n!@_
  s/(\n!@) /\1/

  # Match -!.*_@ and 0; add 1
  s/-!(.* )(@.*)\n$/\1!\2\n1/

  # Match -!.*-@ and >0; add 1
  s/-!(.*-)(@.*1)$/\1!\21/

  # Match -@[^_]_
  s/!(.*)-@([^ ]) /\1\2!@ /

  # If there were any matches, branch to `:`
  t

  # Match _!@ and 0
  s/ !@(.*)\n$/\n!@\1#/

  # Match -@ and 0
  s/!(.*-)@(.*)\n$/\1\n!@\2#/

  # Match @_|_@ and 0
  s/!(.*)(@ | @)(.*)\n$/\1\n!@\3#/

  # Match -!.*[^-]@[^_]_ and 0
  s/-!(.*[^-])@([^ ]) (.*)\n$/\1\2\n!@\3#/

  # Match !.+@[^_] and 0
  s/!(.+)@([^ ].*)\n$/\n!@\1\2#/

  # Match marked line (#) or !@ and 0
  /#|!@.*\n$/{
    # Remove mark; append width and branch to `:`
    s/#|\n$//
    G
    b
  }

:Z

# Cleanup
s/-?!|@.*//g
s/ \n/\n/g

At the end of Phase 1, our pattern space looks like this:

I remember a\ntime of cha-\nos, ruined\ndreams, this\nwasted land.

Or:

I remember a
time of cha-
os, ruined
dreams, this
wasted land.

Phase 2
In Phase 2 we use % as a cursor and use the counter in a similar way, beginning like this:

%I remember a\ntime of cha-\nos, ruined\ndreams, this\nwasted land.\n111111111111$

First, we count the characters on the first line by advancing the cursor and removing 1s from the counter, after which we have;

I remember a%\ntime of cha-\nos, ruined\ndreams, this\nwasted land.\n$

Since the counter is 0, we don't do anything else on this line. The second line also has the same number of characters as the counter, so let's skip to the third line:

I remember a\ntime of cha-\nos, ruined%\ndreams, this\nwasted land.\n11$

The counter is greater than 0, so we move the cursor back to the beginning of the line. Then we find the first run of spaces and add a space, decrementing the counter.

I remember a\ntime of cha-\nos, % ruined\ndreams, this\nwasted land.\n1$

The counter is greater than 0; since the cursor is already in the last (only) run of spaces on the line, we move it back to the beginning of the line and do it again:

I remember a\ntime of cha-\nos,  % ruined\ndreams, this\nwasted land.\n$

Now the counter is 0, so we move the cursor to the beginning of the next line. We repeat this for every line except the last. That's the end of phase 2 and the end of the program! The final result is:

I remember a
time of cha-
os,   ruined
dreams, this
wasted land.

# Phase 2
# Insert cursor
s/^/%/
:B
  # Append counter from hold space
  G
  # This is the last line; branch to :Q (end of phase 1)
  /%.*\n.+\n/!bQ

  :C
    # Count characters
    s/%([^\n])(.*)1$/\1%\2/
    tC

  # Move cursor to beginning of line
  s/([^\n]+)%\n/%\1\n/

  :D
    # Add one to each space on the line as long as counter is >0
    s/%([^ \n]* )(.*)1$/\1 %\2/
    tD

    # Counter is still >0; go back to beginning of line
    s/(^|\n)([^\n]+)%(.*1)$/\1%\2\3/
    tD

    # Counter is 0; move cursor to next line and branch to :B
    s/%([^\n]*)\n(.*)\n$/\1\n%\2/
    tB

:Q

# Remove cursor, any remaining 1s
s/%(.*)\n1*$/\1/

This is incredible, but when I run it using gsed (GNU sed) 4.4 I get gsed: -e expression #1, char 16: ":" lacks a label. Can you add a note on exactly how you're invoking it? (I'm using printf "%s\n%s" "$1" "$2" | gsed -r '';)

@Dave That works for me in GNU sed 4.2. Here's a gist: https://gist.github.com/jrunning/91a7584d95fe10ef6b036d1c82bd385c Note that TiO's sed page doesn't seem to respect the -r flag, which is why the TiO link above goes to the bash page.

Ah, I hadn't noticed the TiO link. That'll do for me; have a +1! There are 2 small mistakes on the last example though (the "black beast" one): it prints the second-to-last line one character short, and misses the final ! (though since I missed ! from the list of possible special characters, I won't hold that against it).

JavaScript (ES6), 147 bytes
Takes input as (width)(text).
w=>F=(s,p=S=' ')=>(g=([c,...b],o='',h=c=='-')=>c?o[w-1]?c==S&&o+`
`+F(b):o[w+~h]?o+c+`
`+F(b):c>S?g(b,h?o:o+c):g(b,o+p)||g(b,o+p+c):o)(s)||F(s,p+S)

Try it online!
Commented
w =>                              // w = requested width
  F = (                           // F is a recursive function taking:
    s,                            //   s = either the input string (first iteration) or an
                                  //       array of remaining characters (next iterations)
    p =                           //   p = current space padding
    S = ' '                       //   S = space character
  ) => (                          //
    g = (                         // g is a recursive function taking:
      [c,                         //   c   = next character
          ...b],                  //   b[] = array of remaining characters
      o = '',                     //   o   = output for the current line
      h = c == '-'                //   h   = flag set if c is a hyphen
    ) =>                          //
      c ?                         // if c is defined:
        o[w - 1] ?                //   if the line is full:
          c == S &&               //     fail if c is not a space
          o + `\n` + F(b)         //     otherwise, append o + a linefeed and process the
                                  //     next line
        :                         //   else:
          o[w + ~h] ?             //     if this is the last character and c is a hyphen:
            o + c + `\n` + F(b)   //       append o + c + a linefeed and process the next
                                  //       line
          :                       //     else, we process the next character:
            c > S ?               //       if c is not a space:
              g(b, h ? o : o + c) //         append c if it's not a hyphen
            :                     //       else:
              g(b, o + p) ||      //         append either the current space padding
              g(b, o + p + c)     //         or the current padding and one extra space
      :                           // else:
        o                         //   success: return o
  )(s)                            // initial call to g() with s
  || F(s, p + S)                  // in case of failure, try again with a larger padding

APL (Dyalog Unicode), 129 123 121 118 111 109 107 104 100 95 bytesSBCS
{⊃⌽m←⍺≥-⌿c⍪+\⊢⌿c←' -'∘.≠⍵:⊂⍵/⍨⊢⌿c⋄(⊂∊l⊣l[(⍺-≢l)⍴⍸' '=l],←⊃0⍴l←⍵/⍨n×⊣⌿c⊖⍨1⌽n),⍺∇⍵/⍨~n←⌽∨\⌽m>×⌿c}

Try it online!

Stax, 51 50 bytes
éS┴k╖♀╡¶┐'▼jÆD╨◙♠ß╒└╧rî{♀EÜ╢a┌ùLiƒ7ÉøΩS╜╪åⁿM◙┴,○9H

Run and debug it

Python 2, 343 bytes
W,T=input()
T+=' '
L,l=[],len
while T:
 p,r=0,''
 for i in range(l(T)):
  s=T[:i].replace('-','')
  if'-'==T[i]:s+='-'
  if T[i]in' -'and W-l(s)>=0:p,r=i,s
 R=r.split()
 if R:
  d,k=W-l(''.join(R)),0
  for j in range(d):
   R[k]+=' '
   k+=1
   if k==l(R)-1:k=0
  L+=[''.join(R)]
  T=T[p+1:]
print'\n'.join(L[:-1])
print' '.join(L[-1].split())

Try it online!
The  input  is a block of text
containing possibly hyphenated
words.  For  each space/hyphen
position  p  the code computes
l(p)  the  length  of the line
induced  by  slipping the text
to this space/hyphen. Then the
code choses the position p for
which  the  length l(p) is the
closest  to  the given width W
(and  l(p)<=W).  If l(p)<W the
code  adds spaces  fairly  in-
between  the  words to achieve
the length W.

Though input may be in any format you like, it should still come from STDIN or parameters. See defaults for I/O. We don't generally allow "input" to be from pre-assigned variables.

You can save a byte by doing print'\n'.join(L[:-1]) instead of for e in L[:-1]:print e

@mbomb007 ok yes I’ll do the needed changes to respect the I/O


text:
Reverse the file
I remember this was exam question long long long time ago.
There is a file say MyFile.txt, it can be any size and contains aphanumeric only
your task is to revese the words
example : "Go beyond the traditional laptop with Surface Laptop. It's backed by the best of Microsoft, including Windows and Office"
It should be "Office and Windows including Microsoft, of best the by backed It's Laptop. Surface with laptop traditional the beyond Go"
The size of the text in the file is unknown.

This is a file, the file size is unknown, you cant find the length of the string in the file.

I think you mean alphanumeric and spaces?

This is tagged code challenge but no winning criteria is given

Python 3, 77 71 47 43 bytes
print(" ".join(open("f").read().split()[::-1]))

EDIT: Saved 6 bytes thanks to NoOneIsHere.
EDIT: Saved another 24 thanks to Jonathan Allan.

Why do you need f = f.read() if you only use f once? Why not with open("MyFile.txt") as f:fprint(" ".join(f.read().split(" ")[::-1]))

@NoOneIsHere I tried that before and it didn't work, probably just a typo. Thanks!

You can remove the " " from the split() call as it defaults to splitting on spaces.

print(" ".join(open("MyFile.txt").read().split()[::-1])) saves 12 bytes. Also the question only gives "Myfile.txt" as an example, you could assume the name is just "f" and save another 9.

@NoOneIsHere I don't think Reversal exists on PPCG.

@LyricLy https://codegolf.stackexchange.com/help/badges/50/reversal

source: Stack Exchange

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

sort: votes


text:
Encrypt a string using vigenere techniques
Your task:
Create a program that encrypts a string with another string using a key, using
the vigenere cipher.
What a vigenere cipher does
Ciphertext:   string
Key:          keya
 |             |
 v             v
string
keyake
 |
 v
(18)(19)(17)(08)(13)(06)
(10)(04)(24)(00)(10)(04)
 |
 v
(28)(23)(41)(08)(23)(10)
 |
 v
cxpixk

If it still isn't clear, read here.
Rules: No built-ins, shortest code in bytes wins, input and output will/should always be either completely lowercase, or completely uppercase.
string, keya -> cxpixk
aaaaaaaaaaaaaaaaaaaaaaaa,abcdefghijklmnopqrstuvwxyz -> abcdefghijklmnopqrstuvwxyz
vigenere, cipher -> xqvlrvtm
short, longkey -> dvbxd

Similar, possible duplicate

This challenge could really benefit from a description of the cipher.

If the key is longer than the text, should we lengthen the text? You do it in your second testcase, but not in the fourth testcase

Your plaintext of a's is two letters shorter than its ciphertext.

Jelly, 9 bytes
2 bytes thanks to Dennis.
ṁ⁹,OS‘ịØA

Try it online!
How it works
ṁ⁹,OS‘ịØA            arguments: "KEYA", "STRING"

ṁ⁹         reshape   "KEYAKE"
  ,        pair      ["KEYAKE","STRING"]
   O       codepoint [[75,69,89,65,75,69],[83,84,82,73,78,71]]
    S      sum       [158,153,171,138,153,140]
     ‘     add 1     [159,154,172,139,154,141]
      ịØA  index ØA  "CXPIXK"
           where ØA is "ABCDEFGHIJKLMNOPSRQTUVWXYZ"

Uppercase letters would save two bytes.

@Dennis nice observation.

Brachylog, 18 bytes
ạᵐz{+-₁₂%₂₆;Ạ∋₍}ᵐc

Try it online!

R, 114 bytes
l=letters
i=match
s=strsplit
function(m,k)cat(l[(i(s(m,'')[[1]],l)+i(s(k,'')[[1]],l)-2)%%26+1][1:nchar(m)],sep='')

Returns a function that takes the message and the key and prints the result to stdout. Will explain later (on mobile now)
Try it online!

Pyth, 15 bytes
s.e@GsxLG,@QkbE

Try it online!

Python 3, 75 73 bytes
-2 bytes thanks to @LeakyNun
f=lambda a,b:a and chr((ord(a[0])+ord(b[0])+1)%26+64)+f(a[1:],b[1:]+b[0])

Try it online!
Takes input in uppercase

You don't need to minus 194. You just need to minus 12 for lowercase, and add 1 for uppercase, so using uppercase would be shorter.

(ord(a[0])+ord(b[0])+1)%26+64 won't work for Z. (ord(a[0])+ord(b[0]))%26+65 should (and saves two bytes).

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


text:
CSI: Minecraft Items
Minecraft 1.12 will be released tomorrow, so let's celebrate!
Write code that takes in a non-negative integer N which represents the number of items of something in Minecraft. Output it in a way more helpful to players, giving the number of chests, stacks, and items N is equivalent to. Use the format
XcYsZi

where

X is the number of chests you can completely fill with N items,
Y is the number of stacks you can fill with the items remaining after filling chests,
Z if the number of items remaining after filling chests and stacks.

Note that:

64 items fit in a stack. (We'll ignore items that stack to 16 or don't stack.)
27 stacks fit in a chest. (These are single chests, not double chests.)

So it would never make sense if Y is more than 26 or if Z is more than 63.
A caveat with the format is that if there is zero of something, that term is not printed.

So, for example, if Y were zero and X and Z nonzero, the format would look like XcZi.

Likewise if Y and Z were zero and X nonzero, the format would be Xc.

The exception here is when N is zero. Then 0i is the output rather than an empty string.

You can assume all N items are of the same type, hence all stackable.
You may not output a list or tuple of three numbers. You must give a string with the exact "csi" notation, in that order, with no spaces or commas.
For reference, here's a chest completely filled with stacks of items:

Testcases
in -> out
0 -> 0i
1 -> 1i
2 -> 2i
62 -> 62i
63 -> 63i
64 -> 1s
65 -> 1s1i
66 -> 1s2i
127 -> 1s63i
128 -> 2s
129 -> 2s1i
200 -> 3s8i
512 -> 8s
1337 -> 20s57i
1664 -> 26s
1727 -> 26s63i
1728 -> 1c
1729 -> 1c1i
1791 -> 1c63i
1792 -> 1c1s
1793 -> 1c1s1i
4096 -> 2c10s
5183 -> 2c26s63i
5184 -> 3c
5200 -> 3c16i
9999 -> 5c21s15i
385026 -> 222c22s2i
1000000000 -> 578703c19s

The shortest code in bytes wins.

Related

ok apparently this is a crime scene investigation

Related.

@Okx with all the spinoffs that wouldn't be surprising.  Now we need a challenge with drawing a chalk outline -- of a creeper perhaps

Mulling it over now, but I don't think this challenge can be done in Minecraft. No way to concatenate the output string. Maybe I could display the result as an actual pile of chests, blocks, and items :)

Jelly,  26  24 bytes
d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i

A full program taking the number and printing the result.
It does seem too long to me...
Try it online! or see the test suite.
How?
updating...
d64d1¦27Fża¥“csi”Fḟ0ȯ⁾0i - Main link: number n
 64                      - literal 64
d                        - divmod (whole divisions and remainder)
      27                 - literal 27
    1¦                   - apply to index 1 (the whole division from above)
   d                     - divmod
        F                - flatten into a single list (of three items i.e. [(n/64)/27, (n/64)%27, n%64]
            “csi”        - literal ['c','s','i']
           ¥             - last two links as a dyad:
         ż               -   zip
          a              -   logical and (any 0s in the divmod result become [0,0], others become [integer, character]
                 F       - flatten (from list of three lists to one list)
                  ḟ0     - filter discard zeros
                     ⁾0i - literal ['0','i']
                    ȯ    - logical or (non-vectorising)
                         - implicit print (smashed together representation, so [578703,'c',19,'i'] prints as 578703c19i)

Retina, 49 48 41 bytes
.+
$*i
i{64}
s
s{27}
c
(.)\1*
$.&$1
^$
0i

Try it online! Includes all test cases except the last, in case it overloaded TIO. Edit: Saved 7 bytes thanks to @MartinEnder. Explanation:
.+
$*i

Convert the input number to unary using is.
i{64}
s

64 items fill one stack.
s{27}
c

27 stacks fill one chest.
(.)\1*
$.&$1

Convert any chests, stacks or remaining items to decimal, but leaving the type as a suffix.
^$
0i

If the input was zero, make the result 0i.

Oh my is this really converting to unary then replacing?

@JonathanAllan I've added an explanation (I didn't have time earlier sorry). (Writing the explanation gave me an opportunity to save a byte too!)

You can avoid some of that $.& duplication like this: https://tio.run/##FYs9DsIwDIX3d46ASpGq2Ens5ARcAiEQYsjCQNmqnj21Lb9veD@/z79/X@M03Z5juSLMHX2TvGPFurHueGNaLneaEZZzIDwCYh8jgsAQ@wTJkAIREKupmho4RhRiUEpminVIPVbP1QqkjRzsSMixiQ1qcmQU3zc7pFoiywE

@MartinEnder Ah, I was wondering whether it would be worthwhile converting directly to i instead of 1, but I just couldn't see that simplification, thanks!

05AB1E, 24 bytes
1728‰`64‰)˜…csiøvyJ¬0Êi?

Try it online!
Explanation
1728‰                      # input divmod 1728 (64*27)
     `                     # split as separate with mod result on top of stack
      64‰                  # divmod 64
         )˜                # wrap stack in flattened list
           …csiø           # zip with the string "csi"
                vy         # for each
                  J        # join amount with storage-type
                   ¬0Êi    # if head != 0
                       ?   # print

How does it work in the 0 input case, and why does that also print a trailing newline while other inputs don't?

@JonathanAllan: If nothing has been printed, 05AB1E implicitly prints the top of the stack at the end of execution (with newline). For-loops breaks lists apart and pushes the elements to the stack, so any item not printed will be added to the stack. At the end of the loop in the 0 case 0i will be on the top of the stack (0s and 0c will be under it) and will be printed.

1728 can be Ž6Ç now; and 0Ê can be Ā.

C#, 84 86 bytes
_=>(_/1728>0?_/1728+"c":"")+((_-=_/1728*1728)/64>0?_/64+"s":"")+(_%64>0?_%64+"i":"")

Notice the inline subtraction, didn't realize it was possible but i-- made sense so why not i-=10
Edit:
_=>_>0?(_/1728>0?_/1728+"c":"")+((_%=1728)/64>0?_/64+"s":"")+(_%64>0?_%64+"i":""):"0i"

for 0 edge case and suggestion.

+1. And you can change _-=_/1728*1728 to _%=1728 to golf a few bytes.

Also, you forgot about the edge case 0, which should result in 0i and is currently outputting nothing. Adding a simply _>0?...:"0i" would fix this.

@KevinCruijssen Ahh, thank you.

+1 for >_> in the edited one

Python 3, 87 bytes
lambda n:g(n//1728,"c")+g(n//64%27,"s")+g(n%64,"i")or"0i"
g=lambda n,s:(str(n)+s)*(n>0)

Try it online!

In Python 2 this could be shortened to 82 bytes, using simple division (/  instead of //) and using backtick operator instead of str(...)

C, 85 87 105 110 111 112 bytes
#define a(x,y)x?printf("%d%c",x,y+99):0;
f(z){a(z/1728,0)a(z%1728/64,16)!z+a(z%64,6)}

Try it here.
The code even works properly on negative numbers. You may now owe server OP blocks!

Functions are acceptable as standard on PPCG

83 bytes

JavaScript (ES6), 77 76 bytes
n=>[n+1,1728,64,1].map((v,i,a)=>(v=n%a[--i]/v|0)?v+'csi'[i]:'').join``||'0i'

Test cases

let f =

n=>[n+1,1728,64,1].map((v,i,a)=>(v=n%a[--i]/v|0)?v+'csi'[i]:'').join``||'0i'

console.log(f(0)) // -> 0i
console.log(f(1)) // -> 1i
console.log(f(2)) // -> 2i
console.log(f(62)) // -> 62i
console.log(f(63)) // -> 63i
console.log(f(64)) // -> 1s
console.log(f(65)) // -> 1s1i
console.log(f(66)) // -> 1s2i
console.log(f(127)) // -> 1s63i
console.log(f(128)) // -> 2s
console.log(f(129)) // -> 2s1i
console.log(f(200)) // -> 3s8i
console.log(f(512)) // -> 8s
console.log(f(1337)) // -> 20s57i
console.log(f(1664)) // -> 26s
console.log(f(1727)) // -> 26s63i
console.log(f(1728)) // -> 1c
console.log(f(1729)) // -> 1c1i
console.log(f(1791)) // -> 1c63i
console.log(f(1792)) // -> 1c1s
console.log(f(1793)) // -> 1c1s1i
console.log(f(4096)) // -> 2c10s
console.log(f(5183)) // -> 2c26s63i
console.log(f(5184)) // -> 3c
console.log(f(5200)) // -> 3c16i
console.log(f(9999)) // -> 5c21s15i
console.log(f(385026)) // -> 222c22s2i
console.log(f(1000000000)) // -> 578703c19s

Java 8, 86 bytes
i->i>0?(i/1728>0?i/1728+"c":"")+((i%=1728)/64>0?i/64+"s":"")+((i%=64)>0?i+"i":""):"0i"

Try it here.

CJam, 31 bytes
ri64md\27md@]"csi"]z{0=},"0i"e|

Try it online!
Explanation
ri                               e# Read an int from input.
  64md                           e# Divmod by 64, gives total #stacks, #items.
      \27md                      e# Divmod total #stacks by 27, gives #chests, #stacks.
           @                     e# Bring #items back to top.
            ]                    e# Wrap in an array: [#chests, #stacks, #items]
             "csi"               e# Push "csi".
                  ]z             e# Zip with the other array.
                    {0=},        e# Filter out subarrays where the first element is 0.
                         "0i"e|  e# Logical or with "0i". An input of 0 gives an empty array
                                 e# from the rest of the program, in that case yield "0i"
                                 e# instead.

///, 179 bytes
/|/\/\///b/l0|d/11|x/dddd|sbxxxxxxxx/1sb|cbxxxd1/1cb|bxd/1b|d/2|2222/8|222/6|22/4|21/3|81/9|61/7|41/5|bc/gc|cb/c|bs/gs|sb/s|bi/gi|b|/g/0|mc/m|ms/m|mi/0i|m|/si/s|cs/c|ci/c/mcl0sl0i

Try it online!
Input is taken in unary 1s at the end of the program right before the i.
Ex:
.../si/s|cs/c|ci/c/mcl0sl0<--input here-->i

You can also use an x in place of 8 1s as a side affect of golfing the program. There is a wrapper for easier testing below.
Testing wrapper:
Try it online!
Ungolfed:
Try it online!
It does 2 divmods, one to separate into chests, stacks, and items, then again to convert to decimal. I could have it convert input from decimal as well, but I would also have to change all of the symbol names and add additional logic to keep it from breaking, so I'm not going to do that. Besides, I think unary is a recognized standard input for ///.

Batch, 347 335 283 246 234 202 199 191 189 bytes
@set/al=%1,c=%1/1728,l-=c*1728,s=l/64,l-=s*64
@set c=%c%c
@set s=%s%s
@set i=%l%i
@if %c%==0c set c=
@if %s%==0s set s=
@if %i%==0i set i=
@if %c%%s%%i%.==. set i=0i
@echo(%c%%s%%i%

You do know you can use division and modulus in a set/a expression, don't you?

@Neil I know, I'm working as the same way right now

@Neil I'm just encountering an issue: if %c%==0 (set c=)else rem this codes gives me "(set is not expected"

Huh, that should only happen if c is empty...

@Neil turns out it was an program error. %c% was undefined xD

JFTR my solution (two slightly different variations with the same length) is down to 122 bytes.

Let us continue this discussion in chat.

JavaScript (ES6) 71 bytes
n=>[n/1728|0,(n/64|0)%27,n%64].map((a,i)=>a?a+'csi'[i]:'').join``||'0i'

Snippet:

f=
n=>[n/1728|0,(n/64|0)%27,n%64].map((a,i)=>a?a+'csi'[i]:'').join``||'0i'

console.log(f(0)) // 0i
console.log(f(1)) // 1i
console.log(f(2)) // 2i
console.log(f(62)) // 62i
console.log(f(63)) // 63i
console.log(f(64)) // 1s
console.log(f(65)) // 1s1i
console.log(f(66)) // 1s2i
console.log(f(127)) // 1s63i
console.log(f(128)) // 2s
console.log(f(129)) // 2s1i
console.log(f(200)) // 3s8i
console.log(f(512)) // 8s
console.log(f(1337)) // 20s57i
console.log(f(1664)) // 26s
console.log(f(1727)) // 26s63i
console.log(f(1728)) // 1c
console.log(f(1729)) // 1c1i
console.log(f(1791)) // 1c63i
console.log(f(1792)) // 1c1s
console.log(f(1793)) // 1c1s1i
console.log(f(4096)) // 2c10s
console.log(f(5183)) // 2c26s63i
console.log(f(5184)) // 3c
console.log(f(5200)) // 3c16i
console.log(f(9999)) // 5c21s15i
console.log(f(385026)) // 222c22s2i
console.log(f(1000000000)) // 578703c19s

Python 2, 82 bytes
I converted Gabor Fekete's comment from above into a working example:

lambda n:g(n/1728,"c")+g(n/64%27,"s")+g(n%64,"i")or"0i"
g=lambda n,s:(`n`+s)*(n>0)

Try it online!

dc, 76 bytes
?dddsf[1728/n99P]sc1728/0<c1728%ddd[64/n115P]si64/0<i[64%n105P]sy64%0<ylf0=y

Try it online!

Braingolf, 71 bytes
V"isc"R#@!%>93*!*,>,>!/!*,>,$_-,>,>,/<$_<&,!?_v@R:>|!?_v@R:>|!?_v@R:>|;

Try it online!
Not at all golfy, but it works

PHP, 84 bytes
<?=($c=($a=$argn)/1728^0)?$c.c:"",($s=$a/64%27)?$s.s:"",($i=$a%64)||$c+$s<1?$m.i:"";

Try it online!
PHP, 93 bytes
$i-=64*$s=($i-=1728*$c=($i=$argn)/1728^0)/64^0;echo$c?$c.c:"",$s?$s.s:"",$i||$c+$s<1?$i.i:"";

Try it online!

Mathematica, 155 bytes
A=AppendTo;G={};P=Print;(z=Mod[t=Mod[#,1728],64];If[(x=⌊#/1728⌋)>0,A[G,{x,c}]];If[(y=⌊t/64⌋)>0,A[G,{y,s}]];If[z>0||#==0,A[G,{z,i}]];Row@Flatten@G)&

T-SQL, 139 134 139 bytes
Input is stored in column a of pre-existing table t.
SELECT IIF(a=0,'0i',REPLACE(IIF(a<1728,'',STR(a/1728)+'c')
                           +IIF(a%1728<64,'',STR(a%1728/64)+'s')
                           +IIF(a%64=0,'',STR(a%64)+'i'),' ',''))FROM t

Line breaks for readability, not counted in byte total.
Tested on MS SQL Server 2012.
EDIT 1: Changed multiple REPLACE to IIF to save 5 bytes. Final REPLACE still necessary because STR annoyingly pads with spaces to 10 chars.
EDIT 2: Fixed to follow the rules by using the approved input type for SQL, values stored in a named table. This cost bytes for the FROM, also requires SELECT instead of PRINT. Recovered 2 bytes by dropping an unnecessary parens.

PowerShell, 113 Bytes
param($i)("$(($c=[math]::floor($i/1728)))c","")[!$c]+("$(($s=[math]::floor(($i%1728)/64)))s","")[!$s]+"$($i%64)i"

This hits a bunch of powershell's pain points very precisely.
[math]::Floor is required for this as PS does Bankers Rounding by default.
the PS Ternary also takes up a load of bytes compared to other languages, to do a simple null coallescence ($a="This";$a?$a:"That" or "This"?:"That") we need to do (($a="This"),"That")[$a-ne$null]
then we need to use all of these twice, and also add in another set of brackets in some places due to powershell's default operation order.

Python 2, 77 bytes
lambda n:''.join(`k`+c for k,c in zip([n/1728,n/64%27,n%64],'csi')if k)or'0i'

Try it online!

Jelly, 21 bytes
d64d1¦27FµTȯ3ịż“csi”$

Try it online!
Like Jonathan Allan's essentially-the-same answer before it, this does seem too long.
Even more essentially the same:
Jelly, 21 bytes
d64d1¦27Fż“csi”ẠƇȯ⁾0i

Try it online!

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


text:
Explode the Box
This is very similar to this challenge, "Implode the Box". It was a pretty nice challenge and it didn't get many answers, so I'm going to post a similar challenge (strongly) inspired by it.
ASCII Boxes look like this:
++    +---+    +------+           +---+    +---+
++    |   |    |      |           |   |    |   |
      |   |    |      |           |   |    |   |
+-+   |   |    |      |           |   |    |   |
+-+   |   |    |      |           |   |    +---+
      +---+    |      |           |   |
+--+           |      |           |   |    ++
|  |           |      |           |   |    ||
|  |           +------+           |   |    ||
+--+                              |   |    ||
                                  +---+    ||
                                           ||
                  +-----+                  ||
+------------+    |     |                  ++
|            |    |     |
|            |    |     |
+------------+    +-----+

Here are the same ASCII boxes, exploded:
                  --
        -        -  -               -        -
++    +- -+    +-    -+           +- -+    +- -+
++    |   |    |      |           |   |    |   |
     |     |  |        |         |     |  |     |
+-+  |     | |          |       |       |  |   |
+-+   |   | |            |     |         | +- -+
      +- -+  |          |     |           |  -
+--+    -     |        |       |         | ++
|  |           |      |         |       |  ||
|  |  --       +-    -+          |     |  |  |
+--+ -  -        -  -             |   |  |    |
    -    -        -- -            +- -+  |    |
   -      -         - -             -     |  |
  -        -      +-   -+                  ||
+-          -+    |     |                  ++
|            |   |       |
|            |    |     |
+-          -+    +-   -+
  -        -        - -
   -      -          -
    -    -
     -  -
      --

Here are the test cases in a more computer-friendly format.
The challenge is to take an ASCII box as input and output the exploded box. A box is exploded according to the following rules:

+ never changes, and neither do the - and | immediately neighboring them.
Starting from the corners and moving in, each - and | move outward one more space than the previous one.

The result does not have to be symmetrical, so padding spaces are not needed.

Standard loopholes apply.
You can take input in any reasonable format, including LF/CR/CRLF separated lines, array of lines, array of array of characters, etc.
The only characters in the input string will be "+", "-", "|", " ", and "\n" (or whatever your newline is, if you choose this input format), and your output string should follow the same rules.
You may optionally have a single trailing newline at the end of the last line.
The smallest ASCII box you need to handle is the top-left example. Every ASCII box will have exactly 4 "+"s, exactly at its corners.
You can assume you will always get a single valid ASCII box as input.
The box must be left-aligned.
Each line may have trailing whitespace so long as the line (without the newline character) is not longer than the longest line with all trailing whitespace removed. That is, the padding whitespace to the right cannot stretch out farther than the center of the extrusion.

The first box in the second column does not explode at the bottom part. I think this is not the desired output.

@GáborFekete Yes, my idiocy again. :I Thanks for pointing that out! :)

Must the box be left-aligned?

"padding spaces are not needed." Are they allowed?

@Neil I will say yes.

@Doorknob Yes, you may have as much whitespace to the right of a line (excluding the newline) such that the width of a line does not exceed the width of the longest line with whitespace removed. I will specify that, thanks.

Retina, 136 bytes
m`^
#
(¶#\|(.*))(?<=\1\1)(?=\1)
¶|  $2
T`#`_`^(.|¶#)*$
}T`#`p
+`^(.*?-)(-+)-
$.1$* $2¶$1$.2$* -
+`¶(.*?-)(-+)(-.*)$
¶$1$.2$* $3¶$.1$* $2

Try it online! Explanation:
m`^
#

Prefix a # to every line.
(¶#\|(.*))(?<=\1\1)(?=\1)
¶|  $2

Where there are three identical lines, i.e. in the middle of a box, expand the middle line of the three. (When there are more than tree identical lines, all except the first and last get expanded.)
T`#`_`^(.|¶#)*$

If no lines were expanded, then delete the #s again. This causes the loop to exit.
}T`#`p

If at least one line was expanded, change the #s to spaces, and continue the loop. (I use p here because it's easier to see.) At the end of the loop, the sides of the box will have been completely exploded.
+`^(.*?-)(-+)-
$.1$* $2¶$1$.2$* -

Repeatedly remove all but two of the top row of -s and put them on their own line preceding the rest of the original row. This explodes the top of the box.
+`¶(.*?-)(-+)(-.*)$
¶$1$.2$* $3¶$.1$* $2

Repeatedly remove all but two of the bottom row of -s and put them on their own line following the rest of the original row. This explodes the bottom of the box.

Charcoal, 56 49 bytes
ＳχＡ⁰δＷ¬⁼χＳＡ⁺¹δδ↓+Ｐ↗×-÷⁺¹Ｌχ²↙×|÷⁺¹δ²‖ＯＯ﹪Ｌχ²‖ＯＯ↓﹪δ²

Try it online! Link is to verbose version of code. Explanation: The input box is measured; χ contains the first line of the box, while δ contains the number of rows of the box. The top left corner of the exploded box is then drawn: first the +, then the -s, then the |s. Finally the box is reflected horizontally and vertically; for boxes of odd sizes, a 1-character overlap is taken into account.

I'd originally tried drawing the whole box in a loop but even after golfing that still weighed in at 68 bytes: ＳχＡ¹δＷ¬⁼χＳＡ⁺δ¹δＡ⁻Ｌχ¹χＡ×-÷χ²εＡ×|÷δ²φＦ²Ｆ²«↷¹Ｐ⎇κφε↷¹¶↷⁴+↶¹Ｐ⎇κεφ↷¹×¶⎇κδχ.

Jelly,  80 79  77 bytes
HĊḢ
ċÐ€⁾-|HµHĊS+=0Ḣ$©Ṭ€ḤH⁸ÇR¤¦;€⁸Ço1¤¦3Ḋ€¹®?z0ZUŒḄm0$⁸ḂḢ¤?€ŒḄm0$⁸ḂṪ¤?ị“-|+ ”Y

A full program that prints the result.
Try it online!
How?
HĊḢ - Link 1: first item halved and rounded up: list
H   - halve (vectorises)
 Ċ  - ceiling (vectorises) (i.e. round up)
  Ḣ - head

ċÐ€⁾-|HµHĊS+=0Ḣ$©Ṭ€ḤH⁸ÇR¤¦;€⁸Ço1¤¦3Ḋ€¹®?z0ZUŒḄm0$⁸ḂḢ¤?€ŒḄm0$⁸ḂṪ¤?ị“-|+ ”Y - Main link

breaking the Main link down:

ċÐ€⁾-|Hµ - get the dimensions: list of characters
   ⁾-|   - literal ['-', '|']
 Ð€      - map with:
ċ        - count - yields a list [number of '-'s, number of '|'s]
      H  - halve
       µ - start a new monadic link using that as it's argument, call it d

HĊS+=0Ḣ$©Ṭ€ - build an appropriately sized binary "diagonal":                  e.g. [3,4]
H           - halve (vectorises)                                                  [1.5,2]
 Ċ          - ceiling (vectorises) (rounds each halved dimension up)                [2,2]
  S         - sum                                                                       4
       $    - last two links as a monad:
    =0      -   equals zero? (vectorises)                                           [0,0]
      Ḣ     -   head (first element)  (i.e. "inputHasZeroDashes")                       0
        ©   - copy to register and yield
   +        - addition                                                                  4
         Ṭ€ - untruth for €ach                              [[1],[0,1],[0,0,1],[0,0,0,1]]

ḤH⁸ÇR¤¦ - make 1s become 2s for those that will represent '|' rather than '-'
Ḥ       - double (vectorises)                               [[2],[0,2],[0,0,2],[0,0,0,2]]
      ¦ - sparse application...
        - ... at indexes:
     ¤  -   nilad followed by link(s) as a nilad:
  ⁸     -     chain's left argument, d                                              [3,4]
   Ç    -     call last link (1) as a monad                                             2
    R   -     range                                                                 [1,2]
        - ...of:
 H      -   halve                                           [[1],[0,1],[0,0,2],[0,0,0,2]]

;€⁸Ço1¤¦3 - place a 3 where the `+` should be
        3 - literal 3                                                                   3
       ¦  - sparse application...
          - ... at indexes:
      ¤   -   nilad followed by link(s) as a nilad:
  ⁸       -     chain's left argument, d                                            [3,4]
   Ç      -     call last link (1) as a monad                                           2
     1    -     literal 1                                                               1
    o     -     logical or (when no '-' Ç returns 0, but we want 1)                     2
          - ...of:
;€        -   concatenate for €ach (append the 3)         [[1],[0,1,3],[0,0,2],[0,0,0,2]]

Ḋ€¹®? - a further correction for zero width edge-case
    ? - if:
   ®  -   recal from register (inputHasZeroDashes)
      - ...then:
Ḋ€    -   dequeue €ach (all rows were made one longer, so adjust)
      - ...else:
  ¹   -   identity (do nothing)                           [[1],[0,1,3],[0,0,2],[0,0,0,2]]

z0ZU - pad with zeros and reflect each
z0   - transpose with filler zero               [[1,0,0,0],[0,1,0,0],[0,3,2,0],[0,0,0,2]]
  Z  - transpose                                [[1,0,0,0],[0,1,3,0],[0,0,2,0],[0,0,0,2]]
   U - upend (reverse each)                     [[0,0,0,1],[0,3,1,0],[0,2,0,0],[2,0,0,0]]

ŒḄm0$⁸ḂḢ¤?€ - perform reflections of row elements
         ?€ - if for €ach:
        ¤   -   nilad followed by link(s) as a nilad:
     ⁸      -     chain's left argument, d                                          [3,4]
      Ḃ     -     modulo 2 (vectorises)                                             [1,0]
       Ḣ    -     head (first element)                                                  1
            - ...then:
ŒḄ          -   bounce  [[0,0,0,1,0,0,0],[0,3,1,0,1,3,0],[0,2,0,0,0,2,0],[2,0,0,0,0,0,2]]
            - else:
    $       -   last two links as a monad
  m0        -     reflect

ŒḄm0$⁸ḂṪ¤? - perform reflection of rows
         ? - if:
        ¤   -   nilad followed by link(s) as a nilad:
     ⁸      -     chain's left argument, d                                          [3,4]
      Ḃ     -     modulo 2 (vectorises)                                             [1,0]
       Ṫ    -     tail (last element)                                                   0
            - ...then:
ŒḄ          -   bounce
            - else:
    $       -   last two links as a monad
  m0        -     reflect
            -           [[0,0,0,1,0,0,0],[0,3,1,0,1,3,0],[0,2,0,0,0,2,0],[2,0,0,0,0,0,2],
            -            [2,0,0,0,0,0,2],[0,2,0,0,0,2,0],[0,3,1,0,1,3,0],[0,0,0,1,0,0,0]]

ị“-|+ ”Y - create the list of characters itself
 “-|+ ”  - literal ['-', '|', '+', ' ']
ị        - index into                           ["   -   "," +- -+ "," |   | ","|     |",
         -                                       "|     |"," |   | "," +- -+ ","   -   "]
       Y - join with newlines
         -       "   -   \n +- -+ \n |   | \n|     |\n|     |\n |   | \n +- -+ \n   -   "
         - implicit print:
           >>>   -
           >>> +- -+
           >>> |   |
           >>>|     |
           >>>|     |
           >>> |   |
           >>> +- -+
           >>>   -


text:
Can those squares form an imperfect square
Given a non-empty array of positive integers, determine if it is possible to take squares with side lengths specified by each integer, and arrange them in space such that they form a square.
The output can have anything as truthy / falsey values, and the input array may contain duplicates.
For the truthy testcase [3,2,2,2,1,1,1,1], a possible way to arrange the square is:
aaabb
aaabb
aaaef
ccddg
ccddh

where each letter represents a different square. The lengths of the squares are completely specified by the given array.
Numberphile did a video on that which inspired me to write this challenge. He called this an imperfect square. This is code-golf so shortest code wins.
Testcases
Truthy:
[1]
[2]
[3]
[3,2,2,2,1,1,1,1]
[12,11,11,7,5,5,4,3,3,2,2,1,1]

Falsy:
[2,1]
[2,2,2]
[3,4]

Please add test cases.

This one is about square nor a rectangle, but it's a similar thing.

I have edited two of your truthy testcases because they were wrong.

Thanks. I worked both of them out by hand and did some mistakes as i typed them in.

I thought this was as easy as checking all the ints in the array squared equalled a square number till I saw the [3,4] test case.

@TheLethalCoder This was the exact why I added it...

Is this about the new Numberphile video??? yes, it is...

You saw nothing

I did the same, @TheLethalCoder and now I can't see past that to figure out what the actual solution might be!


text:
ROT13 and upside-down text (flip text)
When I saw this title in the Hot Network Questions I thought it was going to be a PPCG challenge. I was a little disappointed when it was on Mathematica.
So now it is on PPCG:
Challenge
Given an input string, output the ROT13, flipped value. The input will contain characters from the following alphabet: [abcdefghijklmnopqrstuvwxyz <flipped alphabet>]1
The flipped alphabet can be anything visually similar to the flipped lowercase Latin alphabet so long as it can be accepted as input.
The space character should remain unchanged.
As an example, your flipped alphabet might be zʎxʍʌnʇsɹbdouɯlʞɾᴉɥƃɟǝpɔqɐ
Example

Input:    caesar woz ere
Rot13:    pnrfne jbm rer
Output:   ɹǝɹ ɯqɾ ǝuɟɹud

Input:    ɹǝɹ ɯqɾ ǝuɟɹud
Rot13:    pnrfne jbm rer
Output:   caesar woz ere

Scoring
Simple code-golf, the lowest number of bytes wins.

I think this is different enough to the proposed duplicate for a few reasons:

The answerer has the choice of which characters to use as output (within limits)
The process should be reversible. i.e. flipped text should be acceptable as input and return "normal" text.
There is the opportunity for graphical solutions in this question.

Please include a list of the flipped alphabet.

related

@EriktheOutgolfer, I think it's probably different enough for a few reasons. I've added my reasons to the question.

@JamesWebster Then, first of all, what are the limits? Second, what do you mean by "graphical solutions"? If the output is an image, are the solutions below supposed to take that image as input and print the original text or something?

The limit is mentioned in the question: The flipped alphabet can be anything visually similar to the flipped lowercase Latin alphabet so long as it can be accepted as input. I've clarified the output as input section, however. By graphical solution, I understand that Mathemetica would be to rotate text rather than replace characters.

There is the opportunity for graphical solutions in this question.: I don't see how unless you are performing some OCR.

Your flipped alphabet contains letters from the roman alphabet, so it's impossible to know whether d is a flipped p and should therefore rot13 to ɔ before flipping to c, rather than rot13 to q and flipping to b.

Your upside-down q is a b.

Python 3, 120 bytes
many bytes saved thanks to @JonathanAllan
lambda s,a='abcdefghijklmnopqrstuvwxyz VOďƄɹ5ʇη^MXʎ2ɐʠ>Pəɟ6ɥ!ɾʞ|W ':''.join(a[(a.find(c)+27)%54]for c in s)

Try it online!

@JonathanAllan fixed (plus space issue). in case of ambiguity (like "uodb") will choose the normal alphabet to translate from

Nice fix, although the [abc... <flipped>] does suggest one alphabet and possible mixed input, maybe you can save bytes and fix both at the same time by picking some other unicode chars?

@JonathanAllan I already tested the option to use a single string (with a[(a.index(x)+27)%54], but I didn't find decent replacements for the overlapping characters.

@JonathanAllan I can't see dennis' tio links (wifi provider blocks)

Wow, why? OK lambda s,a='abcdefghijklmnopqrstuvwxyz υοďƄɹ5ʇηʌʍXʎ2ɐʠɔǷəɟɓɥ!ɾʞ|ɯ ':''.join(a[(a.find(c)+27)%54]for c in s)

@JonathanAllan wish I knew. nice use for Ƅ Ƿ and |. I think the last one can use the integral sign, and ᴉ does not need to be replaced by !.

Let us continue this discussion in chat.

Mathematica, 234 bytes
T=ToExpression;B=Characters;L=T@CharacterRange["a","z"];K=T@B@"uodbɹsʇnʌʍxʎzɐqɔpǝɟƃɥᴉɾʞlɯ";(If[Max@ToCharacterCode@#<123,A=L;F=K,A=K;F=L];S=Association@Table[ToRules[A[[Z]]==F[[Z]]],{Z,Length@L}];Row@Reverse@T@B@#/.S)&