Chat mini challenge:a, b and n are unsigned 32-bit integers. Compute (a-b)%n (where % is proper non-negative modulo). You may use signed types but you must not use types with a width greater than 32 bits.
@Stefnotch when you decrement -2^31 you get an overflow which gives you 2^31-1. Normally, decrementing should reduce your modulo 3 result by 1 (or turn 0 into 2). But due to the overflow, this one decrement does not change the modulo result, which makes the final result off by 1 (per overflow, although only one overflow can happen here).
JavaScript ES5, 118 bytes
Interesting technique in my opinion.
function p(x){x=x.toString(2)[R="replace"](/1/g,"(")[R](/0/g,")");r=/\(\)/;while(x.search(r)>=0){x=x[R](r,"")}return !x}
JavaScript ES6, 108 bytes
(Just a "fun" golf of the above.)
x=>{x=x.toString(2)[R="replace"](/1/g,"(")[R](/...
Is this good reason to reject an edit that changes code? Editing would furnish an edit that would change the source code of the user, even if it is wrong.
@Stefnotch Given three 32-bit unsigned integers a b n, calculate (a-b)%n without running into any overflow issues and without casting it to a larger type
Minecraft snap. Ver. 15w46a, 2 + 0 = 2 bytes
Note that this version of this "language" was created after the question was asked.
This is using this version of byte counting.
Put inside of an always active repeating command block, it will, indeed, loop forever with no output.
Ah, but the command blocks/the language don't do a loop, just keep the system game running. And technically, it the game does have output if looking at the logs.
Since programs may be created in vanilla (un-modded) Minecraft using redstone to create logic gates (and more), someone could create such a program for a challenge on this site.
How would such an entry be scored?
Some possible scoring methods:
Blocks used (placed redstone counts as a block)
R...
Is there a regex feature that will make the parentheses implicit in ((A?)?)?? i.e. make A{0,1}{0,1}{0,1} really mean ((A{0,1}){0,1}){0,1}? (@MartinBüttner..?)
@CᴏɴᴏʀO'Bʀɪᴇɴ Also not really - you'd run into issues like making sure that command blocks count as 1 byte (smallest way I can think of requires 2, 4 for 1.9).
The Task
You are to write some ASCII Art Text as seen from this website for generating ASCII art!
Rules
Input will only be alphabetical text and spaces, and will be input as a single line. It is also case-insensitive.
You needn't fix if the output text is longer than the terminal width. As lo...
Related
Exposition
After winning the SO raffle, you could have been on top the world, and you were! The raffle had been going on for a year, now, and you were one of a hundred programmers who were selected to enter into the SO stronghold. And finally, the wait is over. Today is the day you go t...
Premise
One night, I was just contemplating on numbers. I found out about something unique about numbers like 7, 10, 12, 13, and more. They are squares of squares! Meaning, that when squared, are comprised of squares themselves. The OEIS calls them Squares which are a decimal concatenation of tw...
This is the best use of truthy/falsy output I have seen: "For parenthifiable numbers, it will print one or more blocks. For non-parenthifiable numbers, it will crash without printing anything to STDOUT. " (by Dennis)
@Stefnotch The issue is that a-b can be either positive or negative. So, naively, you have to use a signed type to store the difference. But a signed 32-bit type can only represent differences in the range [-2^31,2^32-1]. But the difference between to 32-bit integers can be larger than that (up to 2^32-1). This is why you can run into an overflow.