« first day (1856 days earlier)      last day (2988 days later) » 

2:00 PM
Or is there a better way?
 
also, my solution to the puzzle didn't work
:(
 
what was it?
 
I tried using C# magic getters and setters
well, specifically the getter
 
really hopes it isn't really obvious
 
I was trying to locate and edit the argument pointer as Test was running
Dynamic memory allocation got in the way, though
 
2:02 PM
unfortunately, if you pass in a variable with a magic getter, it gets it before passing it
 
That what I would expect
The arguments are copied before the function is called
 
I know, but I was being hopeful
bah, there's no extending System.Boolean either
 
maybe a is false somehow the first time, meaning && short-circuits
idk how it becomes true
 
@Upgoat that's what I'm trying to get happen
false the first time, true the second
 
idk how that would work though
you're not accessing it again
idk you you could get it to pass by ref without using ref bool a, and idk how you could change it as it isn't a property
you may be able to use p/invoke or something?
maybe try passing values in a list/array?
 
2:21 PM
maybe a timing attack?
 
Th0at was my thought
But I couldn't locate the address of the local veriable
Sorry for the bad spelling, trying to untangle my headset cord at the same time
 
idk, maybe lazy load -> set it to true on onpropertychanged?
 
lazy load?
 
Was just looking at that
 
2:25 PM
maybe look at .net issues for bugs
 
What does C# compile to?
 
IL
 
CIL (Common Intermediate Language)
 
or that
 
With a JIT (Just-In-Time compiler)
It's no longer MSIL
Although there is ngen (the Native image GENerator)
 
2:27 PM
and LLILC (LLVM based MSIL Compiler)
but it usually uses MSBuild (Microsoft Build Engine)
Note: ngen is an AOT/ahead of time compiler
 
I also currently use mcs for compilation (Mono C-Sharp compiler)
 
oooh, I have a solution!
use a debugger
 
Immediate window?
 
just execute the first link, breakpoint, change the value
 
lol my answer was already accepted
 
2:38 PM
oh, I didn't look at the question
good job!
 
Didn't think of that
Forgot that bools are actually ints
 
Congrats ;)
 
Thanks
Maybe it was advantage to not know C#.
So I couldn't think of things like extending bool.
 
@feersum I don't really know c# either
 
haha
 
2:40 PM
but if you didn't know c# how do you know unsafe blocks?
 
Visual Studio told me I needed to put one.
 
It only works with the Microsoft C# compiler tho
 
When I tried to use pointers.
 
Mono prints false
Most likely a compiler bug
 
A bug in which compiler?
 
2:41 PM
Microsoft compiler
 
Presumably this is undefined behavior.
It's strange that it still works in Release though.
You'd think the return true would be optimized out.
I don't know how to check the assembly in for the Release mode one.
 
C# spec: The result of x & y is true if both x and y are true. Otherwise, the result is false.
Well - nope
 
The idea is to trick the compiler by putting a 2, when it expects bools to be either 0 or 1.
 
Yeah but a bool value with an int value of 2 evaluates to true
 
What do you mean?
I wouldn't expect the language spec to have such a concept as "a bool with int value 2".
 
2:47 PM
But the compiler implementation is not done right
int t = 1;
bool a = (bool) &t;
if (a) // do smt
would work
and also if we would use t = 2
 
Converting the address of t to a bool?
 
Sorry formatting error
bool a = *(bool*) &t;
 
That's because the implementation happens to test a single bool by doing cmp eax, 0.
It assumes the value will be 0 or 1.
It could have done it by test eax, 1 in which case 2 would have been treated as false.
 
wait. C# compiles to asm.
how fast is c#?
 
il code
very fast
 
2:53 PM
compared to Java?
compared to c?
(assuming no micro-optimizations)
 
C# is faster than Java but slower than C.
(at least I think)
 
@orlp congrats on getting an SO question into the HNQ... that's quite a feat :D
(I guess the 8 other answers helped, but your score is quite impressive :))
 
which question? i see none
 
29
Q: How does the + operator work in C?

sun qingyaoWhen understanding how primitive operators such as +, -, * and / are implemented in C, I found the following snippet from an interesting answer. // replaces the + operator int add(int x, int y) { while(x) { int t = (x & y) <<1; y ^= x; x = t; } return y; } S...

@randomra are you around? I could use some help testing some Retina changes ;)
 
3:26 PM
3
Q: One-zero dividend

shooqieChallenge description For every positive integer n there exists a number having the form of 111...10...000, i.e. starts with all 1's and ends with all 0's. This is very easy to prove: if we take a set of n+1 different numbers in the form of 111...111 (all 1's), then at least two of them will giv...

 
I just edited this question to make it easier to focus on the challenge itself, per Mego's comment. Thoughts?
 
Guys, can I have duplicate support on a challenge idea?
 
? you want us to support your challenge that is a duplicate?
 
So, basically, the idea is that you recursively convert an input string from the lowest representable base to base ten.
No, making sure that it not a duplicate.
 
does that add anything over just finding the lowest representable base once?
(other than wrapping it in a loop till convergence?)
because we've done that
 
3:37 PM
o
I was thinking about fastest code. >.>
 
@VoteToClose do you support bases 1-10?
1-36?
 
@NathanMerrill 1-10. :)
 
then the base is basically max(str)
 
^ Almost ninja'd
 
3:39 PM
@VoteToClose I don't see much room for optimisation there.
 
@MartinBüttner There may be interesting algorithms that arise. :P The simple step process of repetition exists, sure, but the algorithms that arise thereof are what I'm interested in.
 
Uh well as a fastest code it's certainly not a dupe, but I really don't think it's possible to find a shortcut that doesn't require looking at the intermediate bases.
 
But it may be possible.
 
Calculating max(str)+1 is O(n). I highly doubt it can get any better than that
 
@AquaTart Factoring in the conversion, as well.
 
3:45 PM
Oh I thought you just wanted to output the base
 
Oh, no, what's the point in that?
 
does anyone know if there is a consensus on what constitutes a "different programming language"? e.g. does changing all the tokens without changing any of the grammar or semantics make a different language?
 
@quintopia Related.
 
@quintopia context? in general I'd say yes.
 
I still agree with Martin that there isn't a lot of room for optimization. Base conversion is pretty straightforward especially with just bases 1-10
 
3:55 PM
0
A: Sandbox for Proposed Challenges

timmyRSRandom Build a full function or program which will return a random number from min to max, while min and max are positive integers, so the return should be too. Examples: Input | Output 1, 3 | 1, 2 or 3 1, 5 | 1, 2, .. or 5 3, 6 | 3, 4, 5 or 6 The only rule is Don't use any build in functi...

 
4:11 PM
@MartinBüttner well, one example would be Seriously. It will run programs encoded in OEM-US or in hex, depending on a flag. Do these constitute different languages?
 
oh okay
 
in general, will multiple encodings of the same semantics all parseable by the same interpreter/compiler constitute different languages?
 
it would still help to know the context to answer that
different languages for which purpose?
 
for the purpose of requiring different names?
for the purpose of knowing whether to refer to the interpreter as interpreting a language or a family of languages?
 
I think if this isn't for something as specific as a challenge that has a "same language" limitation you can call it whatever you want.
 
4:20 PM
okay
what is an example of such a challenge?
 
@NewSandboxedPosts ...hasn't this been asked before?
 
@quintopia any polyglot challenge I guess
also multi-part challenges that don't allow reuse of languages
or answer-chaining challenges that don't
 
so what is the usual thing in those cases? would hex-encoded seriously count differently from CP-437-encoded seriously?
 
Question: which is faster, !(x > y) or x <= y? I feel like it's the first, but I'm not sure.
 
@quintopia They all have custom rules so far... I don't think there's a standard/consensus on what counts as different. I vaguely remember we brought that up on meta once and the consensus was "it depends on your challenge". Some like to go with "languages are different if they are referred to by different names", but not all challenges do that.
@VoteToClose In some languages the latter is compiled to the former.
 
4:30 PM
O.o
 
@MartinBüttner did I do that?
 
sort of
(and congrats on the gold now ;))
 
how?
I just wrote like 5 sentences lol
 
@orlp it proves that concision isn't just good for golfing
 
@MartinBüttner adds to my collection of 20 :P
9x famous question though
 
4:35 PM
show-off..
 
also, can i say that this is my favorite comment yet:
a bug is something that causes even some hardened soldiers to become squeamish, while a glitch is a character that cannot leave its game. — Michael yesterday
 
I only ever got one of those on SO and took like 2 years of collecting votes ^^
 
@MartinBüttner famous question is really easy
you just gotta become #1 result on google for some common problem
consider these:
 
oh wait, famous question...
I was thinking great answer for some reason (because that's the one you just got)
anyway, I haven't been able to ask a question on SO that got enough attention to attract amazing answers in the first place.
 
@MartinBüttner well, I can still show off... :P
 
4:41 PM
well...
 
@MartinBüttner for the multiples of 0's and 1's, I believe n! ones and n zeroes always suffices
 
@MartinBüttner I don't consider great answer to be too amazing either
 
@xnor well... :D
 
you're mostly limited by how popular the question is, rather than the quality of your answer
 
@orlp I guess that speaks for the one great answer badge I have :P
 
4:46 PM
@MartinBüttner Actually, phi(n)*9 ones should suffices, and that'a a reasonable value. Know a language with short built-in phi?
 
phi being Euler's totient function?
 
yup
 
EulerPhi in Mathematica
 
ok, could have been worse
 
26 bytes: ⌊10^EulerPhi@#/9⌋10^#&
 
4:50 PM
that's pretty short
 
if you have a proof that it's correct, please post it yourself :)
 
i think it do, how about i try to explain it and that might convince me as well as you?
 
haha sure
 
ok, so for simplicity, let's assume for now the input n isn't divisible by 2,3, or 5
so we want k ones to be a multiple of n
we know k ones equals (10^k-1)/9
 
@Quill cool
 
4:55 PM
since we assumed n isn't divisible by 3, the /9 doesn't affect if that value is divisible by n
so, we need k so that 10^k-1 is divisible by n
good so far?
 
k, still with you
 
so, we need 10^k = 1 (mod n)
now, how much group theory do you know?
 
meh... a lot less than I would like to know
 
would it make sense if i said we're considering the multiplicative group modulo n and looking at the order of the element 10?
 
if you give me 3 minutes to google then yes...
 
4:59 PM
haha
 
well I know what a multiplicative group mod n is... what is the order of element? is that the smallest power that gives 0 mod n?
 
that gives 1
 
oh okay
 
things never give 0 because only numbers relatively prime to n are allowed
 
what if 10 is not an element of the group? are we considering 10 % n instead?
 
5:01 PM
oh, good question
yes, that still works
for example, 10^6 = 1 modulo 7, which corresponds to 3*3*3*3*3*3
which is indeed 1 modulo 7
 
so, an important thing about this group is that it only contains elements relatively prime to n
since they need to have an inverse
 
and the number of such elements is EulerPhi(n)
 
oh okay, so the order can't be greater than that
 
5:04 PM
yes, but more strongly, the order must be a factor of it
we need more than a lower bound, since adding more 1's can mess us up
 
yeah
unless we repeat the 1s an integer number of times
 
the fact any element to the order of the size of the group is the identity is a classic fact from group theory
 
because then it's divisible by 10..00100..01 or something
 
yes, exactly, multiplying the number of 1's by a const is fine
 
alright. so what about numbers divided by 2,3,5 then?
 
5:06 PM
ok, right
 
@Quill ಠ_ಠ
 
so, for 2 and 5, we take care of those by adding zeroes
 
hmm, but is it a problem that 10 now potentially divides n?
 
i think it works out
we think of n=x*y, where x has no factors of 2 and 5
and y has all of them
we find a number of 1's that are a multiple of x
and find a power of 10 big enough to be a multiple of y
then, their product is a multiple of x*y
 
we choose our number of ones based on n, not x though, right?
 
5:09 PM
oh, right
ok, it's still fine
because phi(x*y) = phi(x) * phi(y) if x and y are relatively prime, which they are
good catch
(and we know it's OK to multiply the number of 1's by whatever amount)
 
yeah, okay
 
now the 3's need to be taken care of
 
Wow.
 
the issue was we lose a factor of 9 when we did (10^k-1)/9
 
I just forgot how to write numbers.
 
5:12 PM
You just wrote it
 
@MartinBüttner so, if we were just looking for a number of form (10^k-1) * 10^c that worked, we'd be fine
well, fine for divisibility, it's not made of ones and zeroes
to compensate for the factor of 9 we lose, we add nine ones
 
I couldn't remember if you wrote one hundred as 100 or 001. xD
I'm an idiot sometimes.
 
which makes it a multiple of 9 because the sum of the digits is now 9
and we know that multiplying the number of 1's is fine
 
"we add nine ones"... uhhh... did you mean we use 9 times as many ones?
 
oh, oops, yes
 
5:14 PM
where does that factor of 9 come from though?
 
what do you mean?
 
umm, how do I phrase that.
 
2
Q: What exactly is 'too chatty'?

ArtOfCodeI've just had a number of 'too chatty' comment flags declined, and I'd like to clarify what the mods here consider too chatty before I continue flagging. This is the text of each of the comments that I've had a flag declined on: +1, great use of eval and * '+' +1 for the "farthest in n seconds...

 
@xnor you say we have nine times as many 1s. why is that?
 
because the formula was 9*phi(n) ones followed by n zeroes
 
5:17 PM
oh I don't think my code does that
 
oh
 
completely overlooked the *9
 
need 10^(9*phi(n)) then
 
29 bytes then:
⌊10^(9EulerPhi@#)/9⌋10^#&
 
What are you guys trying to solve?
 
5:19 PM
4
A: One-zero dividend

xnorPython 2, 44 bytes f=lambda n,j=1:j/9*j*(j/9*j%n<1)or f(n,j*10) When j is a power of 10 such as 1000, the floor-division j/9 gives a number made of 1's like 111. So, j/9*j gives 1's followed by an equal number of 0's like 111000. The function recursively tests numbers of this form, trying hig...

 
@xnor fixed it
 
@HelkaHomba i've (i hope) convinced martin that it suffices to use 9*Euler_Phi(n) ones followed by n zeroes
 
you have :P
 
great!
i got to run now, might be busy for a bit, feel free to post it
 
Hey, can anybody help me with my base conversion code? :P I keep screwing up something and I don't see what it is.
Wait, nope.
Found the problem.
>.> It was me.
 
5:22 PM
@xnor nah, it's all your work basically. let's hope no one ninjas you to posting it, but I don't think I will.
 
Okay. :P Can anyone help me with this?:
public class A {
	public static void main(String[] args) {
		String baseinfo = "0123456789abcdefghijklmnopqrstuvwxyz";
		int max = 0;
		String newString;
		char[] argument, baseinfochar = baseinfo.toCharArray();
		for (;!args[0].contains("z") & args[0].length() > 1;) {
			newString = "";
			argument = args[0].toCharArray();
			for (char x : argument) {
				int y = baseinfo.indexOf(x);
				if (max <= y)
					max = y + 1;
			}
			int sum = 0, i = argument.length, multi = 1;
			for (; i > 0; multi *= max)
For some reason, it seems to be going to the wrong number.
Oh. Hold up. Maybe not.
\o/
We're good.
 
The Nineteenth Rubber Duck
 
kek
/me wanders over to CR.
 
5:38 PM
Heresy
 
@MartinBüttner Nah, that's for VBA debugging
 
@VoteToClose you didn't actually go to CR. Liar.
 
I'm fixing my code for review. >.>
 
lol okay
Post it here for golfing too. :P
 
0
A: Sandbox for Proposed Challenges

Don MuesliHighly composite numbers code-golf number number-theory arithmetic A highly composite number is a positive integer that has more divisors than any smaller positive integer has. This is OEIS sequence A002182. Its first 20 terms are 1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1...

 
5:50 PM
@EasterlyIrk Lol, I'm actually doing a on it.
 
6:05 PM
0
A: Sandbox for Proposed Challenges

VoteToCloseRepeatedly convert from minimal base to base 36 fastest-codebase-conversionrepeated-transformation Your task is to convert an input string from the lowest possible base to base 36, repeatedly, until there is no further change to be made. Rules: You may not use base conversion builtins. From ...

0
A: Sandbox for Proposed Challenges

Adam MartinFind the haystack in the needles In a twist on finding a needle in a haystack, you need to find the largest contiguous haystack containing exactly one needle. Note that you cannot connect cells on diagonals, only left/right/up/down. Input An array (or a number of user input lines, your pick) o...

 
2
Q: Translate oOo CODE

DoorknobGiven an input of a program written in oOo CODE, output the BF code that it represents. Here is a short description of how oOo CODE works: First, all non-alphabetic characters are removed (everything not in the range A-Za-z). For example, take the program PROgRam reVERsES giVeN iNPut sEqUENcE...

 
@MartinBüttner I posted your code and my proof
thanks for the mathematica-ing as always, and for checking through the proof
 
@Quill I recognize so many of those names...
 
@MartinBüttner I think phi(9*n) would also work. Any chance that can cut the parens?
 
@MartinBüttner if there's anything special about my gold answer
is that it has 100 upvotes and 0 downvotes
 
6:25 PM
@orlp Wait, really? (I can't see score on SO)
 
@AquaTart Get the userscript.
 
@mınxomaτ lazy
 
> Conditional comments can block resources from loading in parallel in Internet Explorer. Place an empty conditional comment before any external resources to eliminate the blocking behavior.
ರ_ರ
 
@AquaTart For formatting questions in CR: how much background do I need to give about the code I wish to be reviewed, and how much information do I need to give about previous enhancements, etc?
 
@AquaTart Give me your root password and I'll do it for you.
 
6:27 PM
@VoteToClose Context?
 
@mınxomaτ What even is a conditional comment anyway?!
 
I don't think you need to give much info on previous enhancements.
@El'endiaStarman <!--[if ie8] I think
Something like that
 
ahh, okay
 
They're only an IE thing
 
@El'endiaStarman <!--[if gt IE 8]><b>Your browser sucks!</b><!-->
 
6:28 PM
Yea, there you go
 
@AquaTart I don't want to post my question and it be considered low quality. D: I'm writing up a question on base conversion in Java, and I want the code to be reviewed for fastest possible that the current algorithm allows for.
 
@VoteToClose Give background but don't bother with previous enhancements
 
@AquaTart Okaydokay.
 
If you're worried show the question text to me before you post it
 
6:30 PM
Note: if IE only works up to IE9. — cameronjonesweb Jun 15 '14 at 7:22
ರ_ರ
 
@mınxomaτ Seriously? LMAO
 
@xnor say, can you find an input n where the 1^m0^m approach requires m>n?
because I think my CJam answer is currently broken
(I think I can assume m<=2n though?)
@xnor ⌊10^EulerPhi[9#]/9⌋10^#&
 
I'm writing a fastest-code challenge over at PPCG relating to base conversion to/from bases 1 to 36, and as a part of the process for writing the competition, I decided to write my own program for it. Half way through writing it, I realized that this code had other, more formal uses which I now intend to follow-up on. This is the code I wish to be reviewed:
...code...
I wish to make sure that this code, with its _current_ algorithm, is in the fastest setup possible, as well as being "proper" code (as I plan on using this for more formal stuff later).
 
You should definitely explain what the algorithm is :P
 
> What's the difference between gern and gerne? They're just variations of the same word. There's no difference in terms of meaning or style. You can use whichever you like best.
@MartinBüttner: Is this often/usually a dialectal thing, like color/colour for American/British English?
 
6:36 PM
Oh, yeah, duh.
 
@El'endiaStarman no I don't think so. people use both.
 
Okay, so it's more like whether to use " or ' in *programming languages where they are interchangeable?
 
yes, although I'd call those personal preference... I think it's not uncommon for one person to use both "gern" and "gerne" depending on situation/context/whim.
 
@MartinBüttner it never should because phi(n) is always at most n, and because for the multiple of 3 thing, we could first extract all powers of 3, find phi(r) where r is what's left, then multiply the number of ones by that power of 3
 
@MartinBüttner Well, I often use both " and ' in Python, sometimes even in the same line, so that lines up perfectly. :P
 
6:40 PM
my bad, I thought you were talking about natural languages :P
 
somehow I don't find that surprising
@xnor what if n is prime? we get 1^(n-1)0^n... is there a guarantee that 0^(n-1) would also be sufficient? otherwise we might have to increase the number of 1s which would go beyond n.
what I mean is I'm not worried that the 1^EulerPhi(9n) won't fit, but that I need so many zeroes, that I can't increase the number of 1s to match them without going beyond n
if this was still confusing: we know that the smallest valid solution is 1^m0^k with m, k <= n. if m>k we can easily make m=k by appending zeroes. however, if m<k, we can't just prepend 1s to match k... we have to prepend them in multiples of m. but in principle we could have 2m>n
 
6:55 PM
2
Q: Find the haystack in the needles

Adam MartinIn a twist on finding a needle in a haystack, you need to find the largest contiguous haystack containing exactly one needle. Note that you cannot connect cells on diagonals, only left/right/up/down. Input An array (or a number of user input lines, your pick) of 'N' (needles) and '#' (hay) char...

 

« first day (1856 days earlier)      last day (2988 days later) »