Search
Assignment expressions (Python 3.8+) The assignment expression (aka the walrus operator) := was introduced in Python 3.8 as a result of PEP 572, which can be used inline to assign a variable as pa...
Python 3.8, 44 bytes Uses a modulus of 2**16 == 4**8 == 65536. for i in range(1,98,2):print(pow(i,-1,4**8)) How it works: for i in # Iterator ra...
JavaScript (Node.js), 60 bytes n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);return l} Try it online! Explanation n=>{for(l='';n;l="0123456789ABCDEF"[n%16]+l,n>>=4);ret...
Python 3, 463 400 343 338 bytes -63 bytes thanks to trichoplax's suggestion to remove spaces -57 bytes by simple conversion to base 36 -5 bytes by removing base= (seriously, how did I miss t...
When creating a new post, at least one of the required tags listed above the Tags field must be added. The first 4 of these can be added by anyone, but "default-rules" is a moderator only tag. For...
Lean4, 113 56 bytes #eval(λx=>x^32767%4^8)<$>(λx=>1+x*2)<$>(List.range 49) Try it online! Something to notice is that you apparently don't need type signatures in functions...
Lean 4, 232 bytes def r(i):=Id.run do let M:=[999,899,499,399,99,89,49,39,9,8,4,3,0] let N:=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] let mut s:="" let mut n:=i for x in Lis...
Japt v1.4.5, 7 bytes â¬d!øUs Try it â¬d!øUs :Implicit input of integer U ⬠:Divisors, excluding itself d :Are any !ø : Contained in Us : The s...
Complete program A code golf answer can be a complete program. This means that the code can be interpreted or compiled (as appropriate) without any additional source code.
Vyxal, 4 bytes KΠ√= Try it Online! Another 4 byter, but uses the definition of A007422 that a number returns true if product(divisors) == input ** 2. Explained KΠ√=...
C (gcc), 41 bytes r;o(char*s){for(;*s;r+=*s++&1);return r;} Try it online! This is under the assumption that in a function solution, input has to be passed as parameter and output throug...
C (gcc), 37 bytes This takes an integer as input. It uses the fact that the last digit is odd if and only if the number is odd, and that integer division by 10 removes the last digit. Testing if ...
C (gcc), 53 bytes This uses the shortcut behaviour of logical or (||) to only multiply if it is a divisor; the loop end condition then makes sure it's a proper divisor. i=1;p=1;f(n){for(;i<n...
Japt, 17 bytes 0-indexed gU²o!gM fÈì äa eÉ Try it 15 bytes 1-indexed @µXì äa eÉ}f!gM Try it
JavaScript, 42 bytes s=>(g=n=>--n&&s.includes(s%n?g:n)|g(n))(s) Try it online!
JavaScript, 36 bytes n=>n==(g=d=>--d?(n%d?1:d)*g(d):1)(n) Try it online!
Given a hexomino, indicate whether it is a net of a cube. Input A 6 by 6 grid containing exactly 6 filled squares. The 6 filled squares will be in a single edge connected set (a hexomino). Th...
Some time has passed, and the leaderboard there now looks like this: It appears that the entry showing as undefined is confusing the leaderboard. I don't know what governs the placement of that...
Japt, 15 bytes Port of m90's JS solution, until I manage to come up with something shorter. ;Bg7^Mm8|#ÿ^3îU Try it
UiuaSBCS # Experimental!, 8 bytes ++↧∩=₂,, Try it here! Explanation ++↧∩=₂,, ,, Make a copy of the two arguments ∩=₂ Are they both equal to 2? ↧ Minimum ++ Add the...
When answering a code-golf challenge, what types of answer are acceptable by default? Can an answer be a complete program, a function, an anonymous function, a snippet of code? Please add one type...
Function Score is the bytes of the function A code golf answer can be a function. Only the bytes required to define the function are included in the score. Score includes imports and definitions...