New answers tagged

1 vote

Repeated! Factorials!

Regex 🐇 (RME / PCRE2 v10.35+), 25 bytes ^(x+),((?*x+)(?>\1|.*))*$ Attempt This Online! - PCRE2 Try it on replit.com! - ...
user avatar
  • 9,610
2 votes

Repeated! Factorials!

Nibbles, 3.5 bytes (7 nibbles) `*`%@\, ...
user avatar
3 votes

Repeated! Factorials!

Knight, 34 33 bytes ;=p=xE P;=yP;W<0=x-x y=p*x pO+p!p Try it online! -1 byte thanks to Aiden Chow
user avatar
  • 9,066
3 votes

Repeated! Factorials!

Vyxal, 4 bytes ɾṘḞΠ Try it Online!
user avatar
  • 9,066
0 votes

The inverse Collatz Conjecture

Nim, 65 bytes proc f(n:int)= echo n;if n>0:f(if (n%%2)>0:(n-1)/%2 else:n*3+1) Attempt This Online! Simple recursive solution.
user avatar
  • 1,443
1 vote

Cryptic Multiplications

Python 3, 128 bytes ...
user avatar
0 votes

The inverse Collatz Conjecture

dc, 35 bytes [3*1+]0:s[1-2/]1:s[pd2%;sxd0<l]dslx Try it online!
user avatar
  • 475
0 votes

Implement an Over function

Fig, \$2\log_{256}(96)\approx\$ 1.646 bytes RM See the README to see how to run this The perfect job for a functional language. Here is an example program with \$a ...
user avatar
  • 3,347
0 votes

Divisor reduction

Vyxal l, 5 bytes ≬KL-İ Try it Online! Flagless: Vyxal, 6 bytes ≬KL-İL Try it Online!
user avatar
  • 9,066
0 votes

Find a Fixed Point

J, 3 bytes ^:_ Try it online! When a conjunction in J is missing an operand, it becomes an adjective. This program produces an adjective which takes as an argument ...
user avatar
0 votes

Find a Fixed Point

Vyxal, 1 byte Try it Online! Builtin lol
user avatar
  • 9,066
1 vote

Implement an Over function

Knight, 22 bytes O E++P" "+=f+P" "+P+fP Try it online! Since knight doesn't have the concept of functions, this program instead takes in the &...
user avatar
  • 1,431
1 vote

Find a Fixed Point

dc, 30 bytes [pq][Smrd3Rd3Rxd3R=mLmlmx]dsmx Try it online! Takes as input the function in the form of a macro and initial value on the stack(pushed in that order). ...
user avatar
  • 475
0 votes

Implement an Over function

dc, 16 bytes 4Rdsfxsrlfxlr3Rx Try it online! Takes input as the four preceding items on the stack, and pushes the result onto the stack.
user avatar
  • 475
1 vote

Find number components with lowest distribution

05AB1E, 13 bytes ÅœIùʒ@P}ʒ¦Ë}θ Inputs in the same order as the challenge description: \$X,N,B\$. Try it online or verify all test cases. Explanation: ...
user avatar
1 vote

Find number components with lowest distribution

Python, 53 bytes lambda x,n,b:[y:=b>=(y:=-(-x//n))and y]*~-n+[~-x%y+1] Attempt This Online! Port of my JS answer (which is a port of Jonathan Allan's Jelly answer). Errors for no possible solution.
user avatar
  • 9,066
2 votes

Find number components with lowest distribution

Jelly,  16 10  9 bytes ÷Ċ¬>¡⁵⁸sẈ A full program that accepts X N B and prints a list or errors if no solution is possible. ...
user avatar
1 vote

Find number components with lowest distribution

JavaScript (Node.js), 61 bytes (x,n,b)=>(a=[...Array(--n).fill(y=(x+n)/-~n|0),x-n*y],y>b||a) Attempt This Online! Similar to Jonathan Allan's answer.
user avatar
  • 9,066
1 vote

Find number components with lowest distribution

Vyxal R, 22 12 9 bytes /⌈~≥[¹ẇvL Try it Online! -10 bytes by porting Jonathan Allan's answer Outputs a positive integer for no ...
user avatar
  • 9,066
1 vote

Cryptic Multiplications

Charcoal, 36 bytes FXχLθFEXχLη⪫⟦ικ×ικ⟧¶⊞υEκ⌕κλI№υ§υI⁺θη Try it online! Link is to verbose version of code. Explanation: FXχLθ ...
user avatar
  • 146k
1 vote

Gödel numbering of a string

Haskell, 95 bytes e=(product.zipWith(^)[p|p<-[2..],all((>0).mod p)[2..p-1]]<$>).mapM(`lookup`zip"0s~|A()"[1,3..]) Try it online!
user avatar
  • 475
3 votes

Cryptic Multiplications

05AB1E, 20 bytes €g°Ý`âIšεDPª»DSk»}ć¢ Port of @Steffan's Vyxal answer, but with less convenient builtins. Try it online or verify (almost) all test cases (the last ...
user avatar
1 vote

Cryptic Multiplications

Ruby, 108 bytes ->a,b{[*0..9].permutation.map{|c|"#{a}*#{b}==#{a*b}".tr('0-9',c*'')}.uniq.count{|c|/^0|\*0|=0/!~c&&eval(c)}} Try it online!
user avatar
  • 18.3k
4 votes

Cryptic Multiplications

Knight, 416 219 bytes ...
user avatar
  • 9,066
4 votes

Cryptic Multiplications

Vyxal s, 17 bytes vL↵ʀΠƛ?"ƛΠJṄ:vḟ;≈ Try it Online! This would flaglessly be 19 bytes. It can be shorter flagless, though: ...
user avatar
  • 9,066
3 votes

Cryptic Multiplications

Jelly,  20 18  17 bytes Thanks to Steffan for a speed up! (‘×⁵ -> æċ⁵) and a byte that ended up saving elsewhere! Save of 2 ...
user avatar
7 votes

Cryptic Multiplications

K (ngn/k), 41 36 bytes -5 bytes inspired by Jonathan Allan's answer. {#*={.(=`k@x,*/x)_" "}'?+x,'!10*1+x} Try it online! The last 4 cases are too slow to ...
user avatar
  • 55k
3 votes

Cryptic Multiplications

JavaScript (ES6),  127  120 bytes Expects (p)(q), as strings. ...
user avatar
  • 169k
2 votes

Is this a triangle?

Vyxal, 4 bytes ∑½<A Try it Online!
user avatar
  • 9,066
1 vote

Is this a triangle?

Vyxal, 5 bytes Ṗ'ḣ∑≥ Try it Online! Returns an empty list for valid triangles, nonempty for invalid ones. Fun fact: This works for any polygon. ...
user avatar
  • 31.6k
1 vote

Is this a triangle?

TI-Basic, 7 bytes sum(Ans)>2max(Ans Takes input as a list in Ans.
user avatar
  • 2,151
0 votes

Is this a triangle?

Knight, 32 bytes O&<=a+0P+=b+0P=c+0P&<b+a c<c+a b Try it online! The obvious answer.
user avatar
  • 1,431
2 votes

Shifted auto-sum

Knight, 12 bytes O*/^10L=xP9x Try it online! Ungolfed: OUTPUT (* (/ (^ 10 (LENGTH (= x PROMPT))) 9) x)
user avatar
  • 9,066
3 votes

Shifted auto-sum

PHP, 29 bytes fn($n)=>$n*~-10**strlen($n)/9 Try it online!
user avatar
2 votes

Shifted auto-sum

perl -p, 12 bytes $_*=s/./1/gr Multiplies itself with 1, 11, ...
user avatar
  • 2,945
2 votes

Shifted auto-sum

Regex 🐇 (PCRE2 v10.35+), 36 bytes ^(?*(\1{10}|^x{9})*x(x*$))(?*\2x+)x+ Attempt This Online! Attempt This Online! - just the ...
user avatar
  • 9,610
0 votes

Shifted auto-sum

ECMAScript 2016, 73 bytes n=>Array(String(n).length).fill(n).map((a,b)=>a*10**b).reduce((a,b)=>a+b)
user avatar
  • 310
3 votes

Shifted auto-sum

Perl 5 -Minteger -pF , 12 bytes $_*=10**@F/9 Try it online!
user avatar
  • 12.7k
3 votes

Shifted auto-sum

Wolfram Language (Mathematica), 27 26 bytes #(10^IntegerLength@#-1)/9& Try it online!
user avatar
  • 1,847
2 votes

Shifted auto-sum

C++ (gcc), 42 bytes [](int&n){int i=1;for(;n/i;)i*=10;n*=i/9;} Try it online!
user avatar
  • 500
2 votes

Shifted auto-sum

Raku, 13 bytes {$_*S:g/./1/} Try it online!
user avatar
  • 5,696
3 votes

Shifted auto-sum

Desmos, 29 bytes f(k)=∑_{n=0}^{logk-.5}10^nk Try It On Desmos! Using the formula $$n\cdot\frac{10^{length(n)}-1}9$$ is surprisingly 1 byte longer: ...
user avatar
  • 5,790
5 votes

Shifted auto-sum

Bash, 19 bytes expr ${1//?/1} * $1 An unusual example of expr being shorter than regular ...
user avatar
4 votes

Shifted auto-sum

BQN, 15 bytes 10⊸×⊸+˜´⊢⊣¨•Fmt Try it at BQN online! Explanation ...
user avatar
  • 33.3k
2 votes

Shifted auto-sum

Brachylog, 5 bytes lᵐ×↙? Try it online! ...
user avatar
3 votes

Shifted auto-sum

dc, 10 ?dZAr^9/*p Try it online! Explanation ...
user avatar
3 votes

Shifted auto-sum

Pip, 7 bytes a*:1X#a Try it online! Explanation Port of Bubbler's string-based Japt answer: ...
user avatar
  • 33.3k
3 votes

Shifted auto-sum

Vyxal r, 4 bytes Lẋ₀β Try it Online! Another approach. Vyxal s, 3 bytes ...
user avatar
  • 9,066
2 votes

Shifted auto-sum

Burlesque, 8 bytes Jq./]m|* Try it online! Takes input as a string (as from standard in) containing number. ...
user avatar
2 votes

Shifted auto-sum

BQN, 27 bytes {𝕩≤𝕨÷10?(𝕨×𝕩)+𝕨𝕊𝕩×10;𝕨×𝕩}⟜1 Try it at BQN REPL Recursive function to try to circumvent the lack of simple base-conversion, string-conversion ...
user avatar

Top 50 recent answers are included