Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
The challenge involves mathematics in some central way. Also consider using more specific tags, listed in the tag wiki info.
0
votes
Find an unknown very large number
Simple non-golf binary search:
num = 110134848298567717 # sample number
guess = 1
inc = 1
halved = 0
calls_to_cmp = 0
def my_cmp(x, n):
global calls_to_cmp
calls_to_cmp += 1
return x <= …
3
votes
Reimplementing square root
return 1.f/InvSqrt(x);
InvSqrt of course courtesy of Quake.
What, you mean you wanted an accurate result?
2
votes
Reverse Polish notation
Python, 161 characters:
from operator import*;s=[];i=raw_input().split(' ')
q="*+-/";o=[mul,add,0,sub,0,div]
for c in i:
if c in q:s=[o[ord(c)-42](*s[1::-1])]+s
else:s=[float(c)]+s
print(s[0])
7
votes
17
answers
4k
views
Multiply without multiply [closed]
Write the fastest (best big-O) and smallest multiplication algorithm for positive integers, without using multiplication operators. You are only allowed addition, subtraction, logical functions (AND, …
2
votes
Angle between the hands on a clock
Python, 106 bytes
Non-golf solution:
def angle_24hr(time_str):
hour, minute = int(time_str[0:1]) % 12, int(time_str[2:3]) % 60
angle_dist = lambda a, b: ((a + (180 - b)) % 360) - 180
ret …