New answers tagged integer
1
vote
Repeated! Factorials!
Regex 🐇 (RME / PCRE2 v10.35+), 25 bytes
^(x+),((?*x+)(?>\1|.*))*$
Attempt This Online! - PCRE2
Try it on replit.com! - ...
2
votes
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
3
votes
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.
1
vote
0
votes
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 ...
0
votes
Divisor reduction
Vyxal l, 5 bytes
≬KL-İ
Try it Online!
Flagless:
Vyxal, 6 bytes
≬KL-İL
Try it Online!
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 ...
0
votes
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 &...
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). ...
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.
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:
...
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.
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.
...
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.
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 ...
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θ
...
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!
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 ...
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!
4
votes
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:
...
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 ...
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 ...
3
votes
2
votes
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.
...
1
vote
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.
2
votes
Shifted auto-sum
Knight, 12 bytes
O*/^10L=xP9x
Try it online!
Ungolfed:
OUTPUT (* (/ (^ 10 (LENGTH (= x PROMPT))) 9) x)
3
votes
2
votes
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 ...
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)
3
votes
3
votes
Shifted auto-sum
Wolfram Language (Mathematica), 27 26 bytes
#(10^IntegerLength@#-1)/9&
Try it online!
2
votes
2
votes
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:
...
5
votes
Shifted auto-sum
Bash, 19 bytes
expr ${1//?/1} * $1
An unusual example of expr being shorter than regular ...
4
votes
2
votes
3
votes
3
votes
Shifted auto-sum
Pip, 7 bytes
a*:1X#a
Try it online!
Explanation
Port of Bubbler's string-based Japt answer:
...
3
votes
2
votes
Shifted auto-sum
Burlesque, 8 bytes
Jq./]m|*
Try it online!
Takes input as a string (as from standard in) containing number.
...
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 ...
Top 50 recent answers are included
Related Tags
integer × 406code-golf × 379
number × 111
math × 87
sequence × 82
arithmetic × 56
array × 46
decision-problem × 32
string × 27
number-theory × 25
primes × 18
matrix × 17
binary × 16
ascii-art × 13
code-challenge × 12
base-conversion × 12
geometry × 9
bitwise × 9
kolmogorov-complexity × 8
sorting × 8
fibonacci × 8
division × 8
random × 7
fastest-code × 7
subsequence × 7