Tag Info

48

18 Steps (-a)*(-a) = ((-a)*(-a))+0 Axiom 2 = ((-a)*(-a))+(((a*a)+(a*(-a)))+(-((a*a)+(a*(-a))))) Axiom 3 = (((-a)*(-a))+((a*a)+(a*(-a))))+(-((a*a)+(a*(-a)))) Axiom 1 = (((a*a)+(a*(-a)))+((-a)*(-a)))+(-((a*a)+(a*(-a)))) Axiom 4 = ((a*a)+((a*(-a))+((-a)*(-a)...

38

2 circles, 13 lines, 17 points Try it on GeoGebra Let circle(A, B) intersect circle(B, A) at C and D. Let AB intersect circle(A, B) again at E. Let AB intersect circle(B, A) again at F. Let AD intersect circle(A, B) again at G. Let AD intersect CF at H. Let BG intersect DF at I. Let HI intersect circle(A, B) at J and K. Let BG intersect EJ at L. Let BJ ...

37

21 13 11 9 weights This is based on the polarization identity of bilinear forms which in the one dimensional real case reduces to the polynomial identity: $$x\cdot y = \frac{(x+y)^2 - (x-y)^2}{4}$$ So y1 just computes [x+y, x-y] using a linear transformation, and y3 is just the absolute value of y1 as a preprocessing step for the next one: Then the "hard"...

35

C++, 15 operations I have no idea why while loops are allowed as they destroy the whole challenge. Here is an answer without any: int64_t is_negpow2(int64_t n) { int64_t neg = uint64_t(n) >> 63; // n >>> 63 n = (n ^ -neg) + neg; // if (n < 0) n = -n; int64_t evenbits = n & int64_t(0xaaaaaaaaaaaaaaaaull >> neg); ...

34

2 2.2 I love arbitrary precision arithmetic. 0x4126030156610>>(n<<2) Or, if you don't like hex, 1146104239711760>>(n<<2) Test: print([(0x4126030156610>>(n<<2))%7 for n in range(1,13)]) [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]

34

22 operations itx = 1/(1+a+b) #4 nx = -1/(itx+itx) #4 c = -( 1/(itx + itx + 1/(1+nx)) + 1/(1/(a+nx) + 1/(b+nx)) ) #14 Try it online! The ops are 10 additions, 7 inverses, 2 negations, and 3 assignments. So, how did I get this? I started with the promising-looking template of the sum of two double-decker fractions, a motif that had appeared in many ...

32

2.0 (127004 >> i) ^ 60233 or (score 2.2) : (i * 3246) ^ 130159 All found with brute force :-)

31

C - 2 tokens int div3(int x) { return x * 0xAAAAAAAB <= x; } Seems to work up to 231-1. Credits to zalgo("nhahtdh") for the multiplicative inverse idea.

31

7 weights eps = 1e-6 c = 1 / (2 * eps * eps) def f(A, B): e_s = exp(eps * A + eps * B) # 2 weights, exp activation e_d = exp(eps * A - eps * B) # 2 weights, exp activation return c * e_s + (-c) * e_d + (-1 / eps) * B # 3 weights, linear activation Try it online! Uses the following approximate equality for small $\epsilon$ based on the ...

29

4 (Language is irrelevant) n-((48&(11-n))>>2) Woo! Got to 4. 11-n will ensure all of the high order bits are set if and only if n>= 12. 48&(11-n) == if n>11 then 48 else 0 (48&(11-n))>>2 == if n>11 then 12 else 0 n-((48&(11-n))>>2) is the answer

29

18 steps Different from the already posted 18-step solution. a*a = a*a + 0 A2 = a*a + ((a*(-a) + a*(-a)) + (-(a*(-a) + a*(-a)))) A3 = (a*a + (a*(-a) + a*(-a))) + (-(a*(-a) + a*(-a))) A1 = (a*a + a*((-a) + (-a))) + (-(a*(-a) + a*(-a))) A8 = a*(a + ((-a) + (-a))) + (-(a*(-...

28

29 26 Steps No lemmas! Comment if you see anything wrong. (It's very easy to make a mistake) (-a) × (-a) = ((-a) + 0) × (-a) Ax. 2 = ((-a) + (a + (-a))) × (-a) Ax. 3 = ((a + (-a)) + (-a)) × (-a) Ax. 4 ...

27

671 E a (a+a>a*a & (E b (E c (E d (A e (A f (f<a | (E g (E h (E i ((A j ((!(j=(f+f+h)*(f+f+h)+h | j=(f+f+a+i)*(f+f+a+i)+i) | j+a<e & (E k ((A l (!(l>a & (E m k=l*m)) | (E m l=e*m))) & (E l (E m (m<k & g=(e*l+(j+a))*k+m)))))) & (A k (!(E l (l=(j+k)*(j+k)+k+a & l<e & (E m ((A n (!(n>a & (E o m=n*o)) | (...

26

23 operations z = 1/(1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b)) res = z+z proof by explosion: z = 1/(1/(1/(1/(a+1)+1/(b+1))-1+1/(a+b+1+1))-(1/a+1/b)) 1/(a+1)+1/(b+1) == (a+b+2) / (ab+a+b+1) 1/(1/(a+1)+1/(b+1)) == (ab+a+b+1) / (a+b+2) 1/(1/(a+1)+1/(b+1))-1 ...

25

Python 2, 3 operations def f(n): while n>>1: while n&1:return 0 n=n/-2 return n Try it online! The operations are >>, &, /. The idea is to repeatedly divide by -2. Powers of -2 chain down to 1: -8 -> 4 -> -2 -> 1. If we hit a 1, accept. If we hit an odd number before hitting 1, reject. We also need to reject 0, which ...

24

60 55 50 48 gates The original (60 gates) was the systematic approach - multiply each digit with each, and then sum them together. Namely, see Wallace trees and Dadda trees The top half is the multiplication network - multiply each digit with each, and group output digits with the same weight. Some bits have been left inverted to save gates. The second ...

24

Not my answer 6 blocks The user Alex found a shorter solution, of length 6. I can confirm that their solution works: O(O(Br G G, 6) Br, 5) They attempted to edit this question to add this answer, so I'm assuming they want it to be displayed here. I don't like how the reputation system works around here. The message they left: The editor doesn't have ...

22

33 31 weights # Activation functions sub hard { $_[0] < -2.5 ? 0 :$_[0] > 2.5 ? 1 : 0.2 * $_[0] + 0.5 } sub linear {$_[0] } # Layer 0 sub inputA() { $a } sub inputB() {$b } # Layer 1 sub a15() { hard(5*inputA) } # Layer 2 sub a8() { hard(-5*inputA + 75*a15 - 37.5) } # Layer 3 sub aa() { linear(-5*inputA + 75*a15 - 40*a8) } # Layer 4 sub a4() ...

17

Python, 3 2 tokens Brute force solution, but it works. 0x9249249249249249249249249249249249249249249249249249249249249249>>x&1 Thanks to Howard for the 1 token reduction.

17

Dominoes - Total Score: 243 NANDs ORs used: 61 (3 NANDs each -> 183 NANDs) NOTs used: 60 (1 NANDs each -> 60 NANDs) This solution is in dominoes and required a collection of pieces of software I wrote in the course of answering Martin Büttner's two Domino related questions to produce (Golfing for Domino Day and Domino Circuits). By modifying my Domino ...

17

7 6 circles, 3 lines This is a classical pentagon construction, a proof of its correctness can be found here.

15

18 steps Not the first 18-step proof, but it’s simpler than the others. (-a)*(-a) = (-a)*(-a) + 0 [Axiom 2] = (-a)*(-a) + ((-a)*a + -((-a)*a)) [Axiom 3] = ((-a)*(-a) + (-a)*a) + -((-a)*a) [Axiom 1] = ((-a)*(-a) + ((-a) + 0)*a) + -((-a)*a) [Axiom 2] = ((-a)*(-a) + ((-a)*a + 0*a)) + -((-a)*a) [Axiom 9] = (((-...

15

7 5 vertices, 14 10 edges (Graph made with this online tool and paint.) A-F are our six nodes, and J is a helper node. The three 1-nodes enforce that opposite nodes are different, while the 2-node makes sure that A, C and E can neither be all mines, nor all empty. Edit: -2 vertices thanks to CalculatorFeline and H.PWiz!

14

43 weights The two solutions posted so far have been very clever but their approaches likely won't work for more traditional tasks in machine learning (like OCR). Hence I'd like to submit a 'generic' (no clever tricks) solution to this task that hopefully inspires other people to improve on it and get sucked into the world of machine learning: My model is ...

14

40 combinators S(S(SI(K(S(S(KS)K)(K(S(S(KS)(S(KK)S))(K(S(KK)(S(S(KS)K)))))))))(K(S(SI(K(KI)))(K(KI)))))(KK) Try it online! Generated with a little help from a slightly modified version of my answer to Combinatory Conundrum: \begin{align*} \textit{zero} &= λf. λx. x = KI \\ \textit{succ} &= λn. λf. λx. f\,(n\,f\,x) = S(S(KS)K) \\ \textit{zero-...

13

29 operations Does not work for the set { (a,b) ∈ R2 | a+b = 0 or a+b = -1 or a-b = 0 or a-b = -1 }. That's probably measure zero? sum = a+b nb = -b diff = a+nb rfc = 1/(1/(1/sum + -1/(sum+1)) + -1/(1/diff + -1/(diff+1)) + nb + nb) # rfc = 1/4c c = 1/(rfc + rfc + rfc + rfc) # sum is 2: =+ # nb is 2: =- # diff is 2: =+ # rfc is 18: =///+-/++-//+-...

12

Actually, I found a solution with 8 blocks O(O(O(G,4)R,4)GGR,4)

12

Python 3, 67 tokens import sys import time class Bunny(): def __init__(self): self.direction = [0, 1] self.coords = [-1, -1] def setCoords(self, x, y): self.coords = [x, y] def rotate(self, dir): directions = [[1, 0], [0, 1], [-1, 0], [0, -1]] if dir == 'L': self.direction = directions[(...

11

Python -> Python, 8 distinct characters def minimal_python(input_code): """Convert Python code to minimal Python code.""" # Create a list of the ordinal numbers of <input_code>'s characters. # '%' signs have to be treated specially and are represented with -1. ords = [] num_escaped_chars = 0 for char in input_code: if ...

11

4 A solution with a lookup table (it looks up i ^ (i % 12)): i ^ (0x1d4c000 >> (i & 0xfc) & 30) 4 Here's another solution with 4 operations: i - ((0xffff >> (i - 12)) & 12) It assumes that the count operand of bitshifts is implicitly taken mod 32, i.e. x >> -1 is the same as x >> 31. 5 Another approach, using a ...

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