New answers tagged

0

Flurry, 12 bytes ({}){({})}{} Run example $ ./flurry -inn -c "({}){({})}{}" 3 3 3 3 $ ./flurry -inn -c "({}){({})}{}" 6 6 6 6 6 6 6 This uses the "push x y times" construct y {({})} x, just that in this case both are the input number n. ({}) Pop and push n; evaluates to n {({})} A lambda that returns its argument unchanged, ...


0

MAWP, 4 20 bytes %@_1A[1A~25WWM~]~?1: Responds to numbers which have more than 1 digit. Try it!


0

Flurry, 12 bytes ({})[(){}]{} Run example $ ./flurry -nin -c "({})[(){}]{}" 0 1 $ ./flurry -nin -c "({})[(){}]{}" 1 1 $ ./flurry -nin -c "({})[(){}]{}" 2 2 $ ./flurry -nin -c "({})[(){}]{}" 10 10 For single input n, computes n (K n) 1: apply "a constant function that returns n regardless of argument" n ...


0

Scala, 101 bytes for(x<-LazyList from 9)s"$x".permutations.find{d=>d.head>48&d.toInt!=x&x%d.toInt<1}map(_=>println(x)) Try it in Scastie (For whatever reason, TIO doesn't recognize LazyLists, not even after importing it explicitly) Scala (with recursion), 104 bytes def f(x:Int){s"$x".permutations.find{d=>d....


1

Haskell (Lambdabot), 87 bytes [x|x<-[1..],any(\y->show x/=y&&head y/='0'&&rem x(read y::Int)==0)$permutations$show x] Try it online! This is probably unoptimal, as it's my first Haskell golf 😅


0

Ruby, 96 bytes ->a{a.chars.permutation.map(&:join).reject{|x|/^0+/.match(x)||x==a}.detect{|n|a.to_i%n.to_i==0}} The permutation function gives a lot of duplicates, so a large part of this is weedng those out. Try it online!


0

Ruby, 317 bytes ->a{a<31?"Cenozoic/"+(a<4?"Quaternary":(a<24?"Neogene":(a<67?"Paleogene":""))):a<253?"Mesozoic/"+(a<146?"Cretaceous":(a<202?"Jurassic":(a<253?"Triassic":""))):a<543?"Paleozoic/"+(a<300===a ?"...


0

Scala, 45 bytes (n,s)=>0 to n-1 filter(x=>s.exists(x%_<1))sum Try it in Scastie Takes as its input an Int n and a List[Int] s, creates a range from 0 to n, filters every number in that range that's divisible by an element in s, and sums it. Requires language:postfixOps.


2

Brachylog, 43 27 24 bytes []|a₀ᶠ⟨{a₁=h0}ᶜ+⌉⟩ᵐa₁ᶠ⌋ᵐ Uses 0 as the blank value. Try it online! How? Lots of prefixes and suffixes. We want to perform a two-step process that goes like this: [0, 1, 0, 0, 0, 3, 0, 0] [1, 1, 2, 3, 4, 3, 4, 5] [1, 1, 2, 3, 3, 3, 4, 5] For the first step, we look at each prefix of the list: [0] [0, 1] [0, 1, 0] ... [0, 1, 0, 0, 0,...


0

C (gcc), 77 bytes *s;f(){for(s=L"pp!'JO~S<kx`[zQ]g kf YVDp ";*s;)printf("%d",*s++-' ');} Assumes that wchar_t and int have the same size. This way we can make the string wide and we can omit the type when declaring s. A naive approach: group the digits in blocks of 1–3, each of which is an integer between 0 and 127 with no ...


2

Google Sheets, 141 140 134 132 90 Closing parens already discounted. Phew! That was more work than I bargained for. The hard part was getting something that worked for all ranges. Inputs: A1 - N Row 2 - A1, A2, ... Formulae: A3 - =A1-1 (N - 1) A4 - =SUM(ArrayFormula(SEQUENCE(A3)*LT(,COUNTIF(MMULT(SEQUENCE(A1),FILTER(2:2,2:2)),SEQUENCE(A3))))) Where A4 is ...


1

Io, 63 bytes Port of NikoNyrh's answer. method(N,A,A map(i,Range 0toBy(N-1,i)asList)flatten unique sum) Try it online! Explanation method(N,A, ) // Take two inputs, the number and the array A map(i, ) // For each item in the array A: ...


1

Pip, 12 bytes $+Y0N_%gFI,q Try it online! Explanation Uses a somewhat unusual input method: takes N from stdin and the set of divisors as command-line args. $+Y0N_%gFI,q g is list of command-line args (implicit) q Read a line of stdin , Range from 0 up to one less than that value FI Filter on this function: ...


3

Whitespace, 1841 1830 1819 bytes ...


Top 50 recent answers are included