QUICK

QUICK
WRITE A PROGRAM THAT RETURN THE SUM OF 2 INTEGERS WITHOUT USING THE "+" OPERATOR OR THIS PAJEETH WILL OUTSOURCE YOU!!

Other urls found in this thread:

en.wikipedia.org/wiki/Adder_(electronics)
twitter.com/NSFWRedditGif

def fuck(a, b): return a - ((-1) * b)

QUICK
COME UP WITH A RATIONALE FOR NOT USING THE ADDITION OPERAND TO ADD 2 INTEGERS OR A MOD WILL BAN YOU

What said.

because you shit in the streets

you mixed up "you" and "i". i guess english language courses aren't very good in india, but you probably should have learned this.

public int summery(int num1,int num2){

if(num2==0) return num1;

int sum= num1 ^ num2;
int carry= (num1^num2)

return x - (-y) ;

+= operators for ya
var sum = (a,b) => a += b

YOU ALL FAILED. RAJ NASHEED STARTS TOMORROW.

f x y = sum [x,y]

it's funny how autistic people think that they're getting fired because they're not implementing crazy shit like this.

it's because you're difficult for us to tolerate, and we figure some pajeets couldn't possibly be worse than condescending autists.

Should have been fuck(o, p)

$sum = function($a, $b) { return (int)bcadd($a, $b); };

return a-(-b);

Fuck you Pajeet

>not posting the bird

This is the one I'd have gone for if this user hadn't posted it first - because this is how hardware actually does it.

If you take off the first bit it's the non-linear operation in NORX.

int get_sum(int a, int b)
{
int c = a & b;
while (c) {
a |= b;
a ^= c;
b = c

n .+. m
| m >= 0 = foldl (const . succ) n [1..m]
| otherwise = foldl (const . pred) n [1..abs m]

This one is incorrect.

while a,
b++
a--
return b

add:
mov eax, [esp+4]
add eax, [esp+8]
ret

fuck, I actually used the + operator

return a - (-b)

public int sum(int a, int b)
{
return 0 - (0 - a) - (0 - b)
}

If I use the addition operator the generated assembly won't make use of it, but if I go out of my way to not use the addition operator the generated assembly may be less efficient than what would have been generated if I had used the addition operator.

Thus it makes no sense to not use the addition operator, unless you code it in assembly in a more efficient manner.

for a in bits (x):
for b in bits (y):
bits(z)[i++] = a & b

return z

Isn't that literally what the + operator compiles to?

QUICK
NOW PERFORM BINARY MODULUS WITHOUT USING THE MODULUS OPERATOR.

print "2"

after all, 2 is the sum of 1 + 1, two integers.

Were are my million $$$?

20 mod 11
wow that was hard

QUICK
WRITE

no, more like
and then depending on the architecture how the add is implemented in the ALU/floating point unit

>32-bit x86
>2016

...

NO CHEATING AND USING "MOD", "%", OR ANYTHING THAT DIRECTLY DOES MODULUS.

lmao

No you fucking idiot.

>PHP

So, in other words, do modulus without doing modulus?
Well fuck you too.

beautiful

Why are posts starting with "So" usually terrible?

sum [a,b]

Okay

mod(a,b){
int c = a/b
a -= a-b*c
return a
}

I think

No worries man just write it in 64 bit

mov rax, rdi
add rax, rsi
ret

>-= a-b*c
whoops meant to be = not -=

Does 64-bit use a different calling convention (i.e. args not going on the stack)? What if there are more args than registers?

function add (a, b) {
return a - -b;
};

t. ideas guy

Yes, essentially similar to fastcall

>What if there are more args than registers?
They go on the stack after you've exhausted the registers

Good job user, your my hero!

fuck :: Integer -> Integer -> Integer
fuck you asshole = add you asshole

int SumInts(int a, int b)
{
return a - -b;
}

??

yay!

static int fucko(int _a, int _b) { return _a&_b; }

I thought we were supposed to avoid division operators?

This isn't considered cheating, is it?

I realize now why in some countries they say "two AND two make four." (In the United States we never say that)

If i am not wrong.
a & (b+1)
Should do the job

Not in scope: ‘add’

use std::io;

fn main() {
let mut in_1: String = String::new();
let mut in_2: String = String::new();
io::stdin().read_line(&mut in_1).expect("read error");
io::stdin().read_line(&mut in_2).expect("read error");

let in_1: i32 = in_1.parse::().expect("parse error");
let in_2: i32 = in_2.parse::().expect("parse error");

println!("{}", in_1 - (in_2 * -1));
}

You used the + operator

No i used the binary and.

I think its wrong anyways, but i know there is a way to substitute mod with simple binary operations.

MAKE IT AS HARD AS YOU LIKE, THE HARDER THE BETTER.

No point,

divide(a,b)
{
int c = 0;
while(a>=0)
{
a-=b;
c++;
}
return c-1;
}


and then we get back to not being able to use + operator.

+ is just a function in some languages. This is trivially solved in, say, Clojure, where it's not an operator. Just + will do.

What is behind
add

instruction?

I mean what kind of logical operation are being done while this instruction is executed?

At a basic level: Hard-wired circuitry

In reality it's more complicated, x86 gets translated by your CPU's microcode to a sequence of sub-instructions that are themselves hard-wired, altough I'm not exactly sure about the details of this (I imagine nobody outside of intel is)

But yes, to build a rudimentary CPU, your ‘add’ instruction would just translate to hard-wired logic (adders and half adders).

QUICK ANONS
WRITE A FUNCTION THAT RETURNS THE SUM OF TWO INTEGERS WITHOUT USING THE "+", "-", "*" OR "/" OPERATORS

en.wikipedia.org/wiki/Adder_(electronics)

int addTwoNumbers(int TheFirstNumber, int TheSecondNumber)
{
printf("SEGMENTATION FAULT. This is a known issue with AMD chipset. Please contact your hardware vendor for updated driver.");
return -1;
}

irb(main):001:0> a = [5, 3]
=> [5, 3]
irb(main):002:0> kek = 'b' * a[0]
=> "bbbbb"
irb(main):004:0> kek "bbbbbccc"
irb(main):005:0> kek.length
=> 8

It seems I just did

>*

>without using the "*" operator

""""""""*""""""""

int Add(int x, int y)
{
if (y == 0)
return x;
else
return Add(x ^ y, (x & y)

static Func Add = (x,y) => y == 0 ? x : Add(x ^ y, (x & y)

def f(a, b): return sum([a,b])

sum([i,j])

>inb4 pythoning is not programming

congratulations
you win a brand new copy of windows 10 home edition

Thanks, Microsoft™ - Keep up the good work with .NET!

Ook. Ook! Ook. Ook? Ook. Ook! Ook? Ook. Ook! Ook? Ook! Ook! Ook. Ook? Ook. Ook. Ook? Ook. Ook? Ook! Ook. Ook? Ook! Ook.

memeadd(A, B) ->
lists:flatlength([lists:seq(1, A) | lists:seq(1, B)]).

(+.) x y = abs $ -x - y

>*Main> 2 +. 2
4

I don't get this at all, how the hell do you add two numbers without adding them?

Do you want me to write a full adder? You want me to code out the logic gates?

That's reinventing the wheel user.

int sum(int a, int b) {
return a - (-b);
}

I think we might be the only people from this thread that understood your code

Ignoring sign, an 8bit adder.

def adder_2(a, b, c)
so = (a ^ b) ^ c
co = ((a ^ b) & c) | (a & b)
return co, so
end

def add_8(num1, num2)
a0 = num1 & 0x1
b0 = num2 & 0x1

a1 = (num1 & 0x2 != 0) ? 1 : 0
b1 = (num2 & 0x2 != 0) ? 1 : 0

a2 = (num1 & 0x4 != 0) ? 1 : 0
b2 = (num2 & 0x4 != 0) ? 1 : 0

a3 = (num1 & 0x8 != 0) ? 1 : 0
b3 = (num2 & 0x8 != 0) ? 1 : 0

a4 = (num1 & 0x10 != 0) ? 1 : 0
b4 = (num2 & 0x10 != 0) ? 1 : 0

a5 = (num1 & 0x20 != 0) ? 1 : 0
b5 = (num2 & 0x20 != 0) ? 1 : 0

a6 = (num1 & 0x40 != 0) ? 1 : 0
b6 = (num2 & 0x40 != 0) ? 1 : 0

a7 = (num1 & 0x80 != 0) ? 1 : 0
b7 = (num2 & 0x80 != 0) ? 1 : 0

ca, s0 = adder_2(a0, b0, 0)
ca, s1 = adder_2(a1, b1, ca)
ca, s2 = adder_2(a2, b2, ca)
ca, s3 = adder_2(a3, b3, ca)
ca, s4 = adder_2(a4, b4, ca)
ca, s5 = adder_2(a5, b5, ca)
ca, s6 = adder_2(a6, b6, ca)
ca, s7 = adder_2(a7, b7, ca)

return s0 | (s1

>Add two numbers without adding them
But user, that's not what the challenge is. The challenge is to not use the "+" operator.

I did it without using any mathematical operators at all.

You could convert b into negative by doing b = 0 - b

Then doing a - b

This would only work for positive integers though.

int sum(int a, int b) {
for (int i=1; i

But that would be using a mathematical operator.

I mean if I went with just the original challenge in the OP, then the answer is ludicrously simple.

static Func Add = (x, y) => x - -y;

Noice quads mate

And here's some proof that it works with negative integers as well as positive ones.

nice. senpai

Didn't the op state not to use + operator? Great, my solution actually worked.

That's not actual logic, it's just a string that I put there for clarity.

where is lisp solution?

public static int add(int a, int b)
{
BigInteger x = BigInteger.valueOf(a);
BigInteger y = BigInteger.valueOf(b);

return x.add(y).intValue();
}


am i doing it right?

private int fuckYouPajeet(int a, int b){
return Integer.sum(a,b);
}


What now Pajeet?

let f a b = head $ filter (\x -> x - a - b == 0) [1..]