A+B Problem
A+B problem is a challenge that reads two decimal integers, add, and output.
Usually, the input value is constrained in some way.
For languages that can't do I/O, the "input" is done by manually modifying the program before it is executed so that it stores its two numbers in the memory, the "output" is done by storing the result in the memory.
Implementations
1
111*111*111*11*1*,111*111*11*1*,*1,
Befunge
&&+.@
Brain-Flak
({}{})
brainfuck
The following is a not so decent implementation in brainfuck, by User:None1.
,------------------------------------------------>,,------------------------------------------------[-<+>]<++++++++++++++++++++++++++++++++++++++++++++++++.
Both the input and the result have to be one-digit numbers, and the two numbers in the input are separated by exactly one space (or any other character, but there must be exactly one).
Actually I have a better one that uses algorithms mentioned in brainfuck algorithms.
[-]>[-]+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+>>]<+>]]]<]>>[-]>[-]+[[-]>[-],[+[-----------[>[-]++++++[<------>-]<--<<[->>++++++++++<<]>>[-<<+>>]<+>]]]<]<[-<<<+>>>]<++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<++++++++>]<.
It only works on 8 bit cells, and the numbers in the input and the result should not exceed 255. The two numbers in the input are separated by line feeds.
Brainfuck extended
(@(+%)
BrainZ
The following programs are in hex dump
01 55 55 55 55 55 55 55 55 55 55 55 55 20 20 2A AA AA AA AA AA AA AA AA AA AA AA A1 46 41 1F FF FF FF FF FF F0 20
Both the input and the result have to be one-digit numbers, and the two numbers in the input are separated by exactly one space (or any other character, but there must be exactly one).
Actually I have a better one that uses algorithms mentioned in brainfuck algorithms.
0A 09 0A 0C 21 41 21 41 01 0C 2A AA AA 84 85 07 F0 8A AA 94 11 51 10 A4 FF E2 20 92 14 46 48 23 20 82 08 82 48 50 48 50 61 0A 09 0A 08 08 61 55 55 54 24 28 3F 84 55 54 A0 8A 88 85 27 FF 11 04 90 A2 32 41 19 04 10 44 11 0A 22 32 48 23 FF 88 85 32 84 C9 04 86 14 64 13 24 11 11 11 10 49 0A 09 27 FF 10 A5 09 92 09 0C 28 C8 26 48 22 22 22 09 0A 09 21 3F 85 1F F2 08 81 11 99 0A 08 22 11 0A 51 07 F0 A7 FC 41 20 42 82 08 8F E1 47 FC 82 20 40
It only works on 8 bit cells, and the numbers in the input and the result should not exceed 255. The two numbers in the input are separated by line feeds.
C++
#include<cstdio> int main(){ int x,y; scanf("%d%d",&x,&y); printf("%d",x+y); return 0; }
Factor
1550312130344523405322670672726144276060320428835586125982062278216873380299547785445888965317356993578998458894062824590818181343465544643203278969789760306483260898195025071606514680066312822882289150961729164240257496460164711229028838279617380759313885377180750696493806042467569915139382024410955786156745725726158898119
Both the input and the result have to be one-digit numbers, and the two numbers in the input are separated by exactly one space (or any other character, but there must be exactly one).
Actually I have a better one that uses algorithms mentioned in brainfuck algorithms.
223410076043971245540455586062108671976382093084650814048455942695029728847248299149137635554999424822108920506098868033476214459320120499009107004136078049794893673781761295204469664667935339948220791969940797178711884552892973753625015470549096824911093718441469356768533249165014176626741614824403577081277068387982322629535712447454364104489588780254372499850172986326729405696524997412110326083025627210689998917530563991619062944140202877791117569707740865348999991542007107447224733604600000527878988213435845838869570404281302989627799961769506811874060021300896611729156306973830638599329303622560576731383760330633151857809874340774202118735387543078461597660714598235881914663270305145053382281893795661261671652072174089103101132267118681988227624613185931131543618491818705958774014872388695403663087930058282062807944776002596264627880492322717384703232216135346484920131957918341425918130884150142467794506237984533771367614705105664172251120356711890741861382387138254921794223791411080320254372901167902742308408394759875459949509185990551844055573095741697932045088640395955024237597472362455681672376050549253700368981271604291990235515264750252871044914433037348488635473615344302888662605466698658948109839364491561884085899786063927241502662408998462517291640998101657371778834680047837565519172095276588293322125139653792272461457837353049108094141833488627267796682360797868482152871439304768041176143520773935566597
It only works on 8 bit cells, and the numbers in the input and the result should not exceed 255. The two numbers in the input are separated by line feeds.
Gofe
,&s,As.
Java
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(a+b); } }
Func++
intoutput(add(intinput(),intinput())
JavaScript
function add(a,b){ console.log(a+b); }
I use a function, because it seems that JavaScript has no functions for input.
Powershell
$a=read-host $b=read-host $c=[Convert]::ToInt32($a)+[Convert]::ToInt32($b) write-host $c
Python
print(sum([int(i) for i in input().split()]))
Sokolang
### #*# ##I#### #@*.O*# #..#### #.# ### --- @:13 i:13 o:1,11 --- rudwup2[dlr]dwp2u2rplwplwprlwp2r2lud
This esolang is not a push-down automata
,,+.