40
7
Problem:
Your goal is to add two input numbers without using any of the following math operators: +,-,*,/.
Additionally, you can't use any built-in functions that are designed to replace those math operators.
Scoring:
Smallest code (in number of bytes) wins.
Update
Most of the programs i've seen either concatenate two arrays containing their numbers, or make
first numberof a character, appendsecond numbercharacters, then count them all.Shortest array counter: APL with 8 chars, by Tobia
Shortest array concatenation: Golfscript with 4 chars, by Doorknob
Shortest logarithmic solution: TI-89 Basic with 19 chars, by Quincunx
Integration solution: Mathematica with 45 chars, by Michael Stern
Coolest, in my opinion: bitwise operators in javascript, by dave
Do Brainf**k's
+and-count? – ASCIIThenANSI – 10 years ago2Define "number". Any integer? Non-negative integers? Do they have to be base-10? – SuperJedi224 – 9 years ago
Will it have floats? – Ismael Miguel – 12 years ago
@IsmaelMiguel - Nope. No floats. – TheDoctor – 12 years ago
7Will it have negative numbers? (Currently, all the answers assume that the numbers will be positive, so you probably shouldn't change that) – Doorknob – 12 years ago
@Doorknob the "make two lists, concatenate them, return the length of the resulting list" approach, which many are using, requires positive integers, but other solutions are possible that allow non-integer inputs, negative numbers, or both. – Michael Stern – 12 years ago
I'd like to suggest that the title be changed to
Add without addition, multiplication, subtraction, or division!or something similar (maybeAdd without +*-/) to reflect that we cannot use those operators as well. – Justin – 12 years agoa=lambda x,y:'%s%s'%(x,y)– nyuszika7h – 12 years agoRelated: Adding without using a + or - sign
– Ilmari Karonen – 12 years ago4
What about the mathematical solutions? You forgot to list those! This integrates, and this plays with logarithms
– Justin – 12 years ago3
Why did you accept one of the longer solutions? Is it because it accepts negative numbers while the shortest solutions (this and this) don't? If so, my answer supports negative numbers (it also supports floating point) and is shorter than this one. You tagged this question as [tag:code-golf], thus you are obliged to accept the shortest solution.
– Justin – 12 years agoI chose that solution because it dealt with negative numbers and it didn't use array concatenation, like the 4 char Golfscript – TheDoctor – 12 years ago
Do FMAs count as replacements for + and *? – me' – 6 years ago