# Tag Info

9

Jelly, 20 bytes +Ø.÷€AĊc2ḋIɓN;æl¥ƒ-Ḋ Try it online! Port of my own APL answer. Trailing ɓ chain trick is indeed strong :P How it works +Ø.÷€AĊc2ḋIɓN;æl¥ƒ-Ḋ Dyadic link; left=range, right=divisors xxxxxxxxxxxɓyyyyyyyy x(left, y(right, left)) N;æl¥ƒ-Ḋ y: subset LCMs, negative for even-sized ones N Negate the divisors ...

8

APL (Dyalog Extended), 31 bytes -/+/(⎕+⍳2)(⊢×2!⌈⍤|⍤÷)\∊(⊢,∧)\-⎕ Try it online! Full program which takes the list of divisors, and then the (start,end) pair. Uses a modified trick to generate all nonempty subsequences. Also abuses the definition of LCM which is LCM(a,b) = a * b / GCD(a,b) and GCD is always positive, so LCM follows the sign of a * b. How it ...

6

Haskell, 131 bytes f=fromIntegral u=unwords.map show a%b|a>b=(a-b)%b|1<2=a (r#c)s="P2":u[c,r,99]:[u[round$f j%(f i**s)/f r**s*99|j<-[1..c]]|i<-[1..r]] Try it online! (r#c)s returns the lines of a PGM file. After writing it like this, I learned I could probably just return a matrix of float values but I don't think that's very ... 6 J, 51 bytes load'viewmat' 1 :'[:viewmat(|~^&u)"0~/&(1+i.)%u^~[' Try it online! A J adverb, which uses the library function viewmat to do all the heavy lifting -- we merely need to construct the matrix values. Assuming the adverb has been assigned to f, called like: 500 (0.8 f) 800 500 800 0.8 200 250 0.3 5 Python 3, 229 bytes lambda d,s,e:sum(-(-1)**len(k)*(t(e//l(*k))-t(~-s//l(*k)))*l(*k)for k in p(d)[1:]) t=lambda x:x*-~x//2 p=lambda k:k and[j+a for j in[[],k[:1]]for a in p(k[1:])]or[[]] l=lambda a,*b:b and a*l(*b)//math.gcd(a,l(*b))or a import math Try it online! -5 bytes thanks to ovs There's probably a less direct approach. I haven't properly golfed in ... 5 Vyxal s, 32 bytes$ṗḢƛ:λ₌*ġḭ;R:¹‹÷›"$ḭ:›*2ḭ¯unLe** Try it Online! 5 Jelly, 7 bytes O%32Ṅ€S A full program that accepts a string of three letters and prints their alphabetic indices followed by their sum on four lines. Try it online! How? O%32Ṅ€S - Main Link: list of characters, C O - cast to ordinals A:65 ... Z:90 / a:97 ... z:122 %32 - modulo 32 A:1 ... Z:26 / a:1 ... z:26 Ṅ€ - print each followed ... 4 05AB1E, 25 bytes æ¦ε.¿DIāÉ-s÷D>*2÷Æ®ygmP}O Try it online! æ¦ε } # map over each non-empty subset of the divisors .¿D # take the LCM of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by LCM D>*2÷... 4 Python 3, 116 114118 bytes -2 thanks to some basic pointers from hyper-neutrino +4 to correct an off-by-one error, thanks Tipping Octopus from matplotlib.pylab import* def M(R,C,s): imshow([[j%i**s/R**s for j in range(1,C+1)]for i in range(1,R+1)]);show() Fairly straightforward, my first code golf attempt so I may be missing something easily golfable. ... 4 JavaScript + HTML, 156 bytes (R,C,s)=>{for((w=x=>document.write(x))<table cellspacing=0>,i=0;i++<R;)for(w<tr>,j=0;j<C;)w(<td bgcolor=#${((++j%i**s*16/R**s|0)*273).toString(16)}>)} -7 bytes by Shaggy ; (function run() { f= (R,C,s)=>{for((w=x=>document.write(x))<table cellspacing=0>,i=0;i++<R;)for(w&...

4

Wolfram Language (Mathematica), 39 bytes sImage@Array[Mod[#2,#^s]&,{##}]/#^s& Try it online! Input [s][R, C].

4

K (oK) + iKe, 61 bytes {w::y;h::x;p::pow[;z];,(;gray;+_255*((p 1+!h)!\:/:1+!w)%p w)} Try it online! Shortened heavily and made to work with the help of JohnE and coltim at the k tree. A function which takes input as R, C, s.

4

R, 66 bytes function(R,C,s)cat('P2',C,R,99,(99*outer(1:C,(1:R)^s,%%))%/%R^s) Try it online! I kinda think that pajonk's answer is close to the shortest possible using R's built-in graphics... so here's a completely different approach, which actually turns-out to be 4 bytes shorter... Outputs the contents of a greyscale PGM file. At least on my laptop ...

4

Python 3, 90 73 bytes from pylab import*;ion() def M(R,C,s):imshow(-~r_[:C]%c_[1:R+1]**s/R**s) Heavily based on Danica's answer, I would have commented but I have 0 reputation. Shorter import statement ion() to show instead of ;show() arange (from numpy.arange) array approach for faster performance and fewer bytes remove def function indent from pylab ...

4

Factor + combinators.extras, 42 35 bytes 0 [ read1 32 mod dup . + ] thrice . Try it online! -7 bytes thanks to @MarcMush 0 Push 0, our sum, to the data stack. [ ... ] thrice Call a quotation three times. read1 Read one code point from standard input. 32 mod Modulo 32. dup . Output on its own line non-destructively. + Add it to the sum. . Print the sum.

3

Vyxal, 37 bytes $ṗḢƛ:λ₌*ġḭ;R:¹÷$‹$"$ḭ:²+½$*÷-$Lu$e*;∑ Try it Online! This is extremely messy. In case it wasn't clear, I am terrible with stack-based languages. 3 J, 72 69 bytes 1#.(_1*_1^1#.g)*(_1 0+[)(]*[:-~/(2!>:)@<.@%/)]*./@#~g=.1}.2#:@i.@^#@] Try it online! -3 thanks to nC2 trick from Bubbler's answer There's some more golf's I believe I can port from Bubbler's APL answer. Will try tomorrow. 3 Jelly, 30 29 bytes -1 thanks to caird coinheringaahing! ’1¦:×‘HIƲḢ×ʋⱮⱮœcⱮJæl/€€Ɗ}§Ṛḅ- Try it online! How? ’1¦:×‘HIƲḢ×ʋⱮⱮœcⱮJæl/€€Ɗ}§Ṛḅ- - Link: [start, stop]; divisors 1¦ - apply to index 1 (of [start, stop]): ’ - decrement -> [start-1, stop] } - using right (divisors):... 3 Vyxal, 5 bytes -*∑+c Try it Online! Inputs: attacks, growths, hits, heads Explanation - subtract: growths - attacks * multiply: that * hits ∑ sum + add: that + heads c contains: is it in attacks? 3 Python, 359 (184 without whitespace) 224 212 bytes, ~$$H_{ψ(ψ_Ι(0))[7]}(8)$$ *S,n=0,2,9 while S: i=r=d=0 for a in S[::-1]: i-=1 if d<S[-1]-a: r=r or i;d+=S[-1]-a-d>1 if[k+d for k in S[i:]]<S[r:]:break p=i+1 S.pop();n*=n if r:S=S[:p]+[d*i+k for i in range(n)for k in S[p:]] I'm new to codegolf so I'm not sure if all the whitespace ... 3 R, 84 70 bytes -14 bytes thanks to @Dominic function(R,C,s)image(outer(1:C,(R:1)^s,%%`)/R^s,c=rainbow(64),as=R/C) Try it online! Try it on rdrr.io with graphical output 3 APL (Dyalog Extended), 10 bytes Full program. Prompts via stdin and prints to stdout +⌿⎕←⍪⎕A⍳⌈⍞ Try it online! ⍞ prompt via stdin ⌈ uppercase ⎕A⍳ indices in uppercase Alphabet ⍪ make into column ⎕← send to stdout +⌿‌ sum (and implicitly print to stdout) 3 Elixir, 70 bytes &(IO.puts Enum.reduce &1,0,fn b,c->IO.puts b=b-(b>91&&96||64) c+b end) Try it online! 3 Perl 5 + -pF, 27 bytes -6 bytes thanks to @Sisyphus!$\+=$;*say$;=31&ord for@F}{ Try it online!

2

K (ngn/k), 16 bytes {|/x*c=&/c:#'$x} Try it online!$x convert the input to a list of strings c:#' count the number of characters/digits in each input, storing in c c=&/c generate boolean mask indicating which indices contain the minimal number of digits x* "mask-out" inputs that do not have the minimal number of digits (i.e., convert ...

2

Clojure, 90 bytes #(for[i[0 1]j((split-at(/(count %)2%2)(partition-all %2%))i)k(([seq reverse]i)(sort j))]k) Try it online!

2

javascript 77 bytes let i=0;while(true){console.log(i);if(i.toString().includes('00'))break;i++;}

2

Vyxal, 21 7 bytes ⌈E∑ƒ\/j Try it Online! No rational numbers here... -14 thanks to lyxal. Or, if I can take it in a very specific form: Vyxal, 4 bytes *+$" Try it Online! Input as denominator,number,numerator. 2 Perl 5 (ppencode-compatible), 64 bytes You didn't clarify that I must separate each with exactly one character, so here it is mine. print length uc xor s qq q xor print while length ne ord qw q eq Try it online! Explained # print(length) did not work for zero as$_ is not defined at then print length uc xor s qq q xor # delimiter print while ...

2

Python 3, 146 bytes lambda d,s,e:(e*e+e-s*s+s+g(d,e)-g(d,s-1))//2 g=lambda d,n,m=1:g(d[1:],n,m)-g(d[1:],n,m*d[0]//math.gcd(m,d[0]))if d else~n//m*(n//m)*m import math Try it online! Some tricks explained: ~n//m is a shorter way to write -(n//m+1), and e*e+e-s*s+s is twice the sum of integers in the interval. Python 3.9, 138 bytes lambda d,s,e:(e*e+e-s*s+...

Only top voted, non community-wiki answers of a minimum length are eligible