Post History
C (gcc), 88 bytes char a[53]={91},*p=a+1,i;f(n,d){for(;i<50;)p[i++]=1.*n/d<=i/50.?45:124;p[i]=93;puts(a);} Try it online! There's two approaches to this in C that I came up with - eith...
Answer
#1: Initial revision
# [C (gcc)], 88 bytes <!-- language-all: lang-c --> char a[53]={91},*p=a+1,i;f(n,d){for(;i<50;)p[i++]=1.*n/d<=i/50.?45:124;p[i]=93;puts(a);} [Try it online!][TIO-m3sv6mme] [C (gcc)]: https://gcc.gnu.org/ [TIO-m3sv6mme]: https://tio.run/##NY29EoMgEIR7n4KZNKAXBZHCnEwexLFg/EkoJI6ayvHZCTGm@/Z297a9PtrW@/ZpZmJqJRu9lWKHeNImEWBxoA46tg2vmaKtFEc21TZJGi3S2GVdpW2meHov1E3kBQav0aXE6b0u1DDc/aXrB@t68vtDrOZIxn5c@pUa4KByhmGXh5ZAcozimY0i61YyGusoi7aIhLOAED8oB/knWYDk/FQK1Bd3/wE "C (gcc) – Try It Online" There's two approaches to this in C that I came up with - either write into an array then print it, or print everything at once but use conditionals. I tried both but got about the same result so this version is the array one. Dumping all variables at file scope makes initialization easier and we can abuse the usual C89 tricks of "implicit int" (but this makes the function "call once", so tests will have to restore all variables between multiple calls). The actual algorithm is just floating point division then scale that from 0 to 50. `<` instead of `<=` would give incorrect rounding and that would be my on my algorithm, not the language, so I used `<=`. Also this code has some pretty severe UB abuse with the i++... :)