g | x | w | all
Bytes Lang Time Link
010Uiua240728T042946ZErikDaPa
098Pascal240728T000000ZKai Burg
008Excel / Google Sheets240728T105137Zz..
002Thunno 2230616T171551ZThe Thon
009Juby221014T153231ZJordan
030Julia 1.0221024T085657Zamelies
026Julia 1.0221020T154529ZAshlin H
029Factor221020T083402Zchunes
051nroff221019T133511Z鳴神裁四点一号
021Ruby221014T152251ZJordan
003Vyxal221014T115101ZDialFros
027R180204T121713ZRobert H
055R180404T051441ZKamRa
032C#180404T021852Zlee
005Implicit180404T013621ZMD XF
016Excel VBA180109T130517Zdanielta
078Swift180109T152006Zuser3151
036FALSE180201T153951Z12Me21
001Pyt180131T030052Zmudkip20
nan180124T181241ZBrad Gil
003Stratos180116T135910ZOkx
005K oK180113T111701Zmkst
022BrainFlak180109T104022ZMr. Xcod
045Tcl180111T142539Zsergiol
1642PHP 5.6+180110T163604ZXano
012AWK180109T171642ZNoskcaj
035TSQL180109T185931ZBradC
013Q Kdb+180110T182450ZSidney
023Ruby180111T045559ZNTCG
007Mumps180110T203956Zzmerch
019PowerShell180110T194020Zbriantis
051Java 8180109T183643ZDevelopi
006Javascript180110T120607ZGeneral
089Batch180110T094846ZNeil
008Excel180110T093225ZWernisch
011Javascript180109T110321Zelementb
009dc180110T082825Zseshouma
065C++ gcc180110T063519ZKen Y-N
027C gcc180109T102627ZSteadybo
235><>180110T011029ZJo King
035R180109T214633Zrturnbul
008Jelly180109T204154Zcaird co
052Clean180109T195733ZΟurous
007APL NARS2000180109T191818ZErik the
020PowerShell180109T184932ZAdmBorkB
029Sinclair ZX81/Timex TS1000/1500 BASIC180109T111432ZShaun Be
042SNOBOL4 CSNOBOL4180109T183105ZGiuseppe
003Husk180109T163823Zბიმო
488Taxi180109T155504ZEngineer
011Attache180109T153603ZConor O&
033Operation Flashpoint scripting language180109T111608ZSteadybo
008Stacked180109T145744ZConor O&
027Wolfram Language180109T144750Zktm
004Pyth180109T123424ZDave
9110Perl 5180109T123345ZNahuel F
024jq180109T120418Zmanatwor
021Gema180109T113924Zmanatwor
025Python 3180109T113444ZMr. Xcod
004APL Dyalog180109T104319ZUriel
003Japt180109T105531ZShaggy
007Alice180109T110121ZMartin E
020Haskell180109T103939Ztotallyh
011Retina180109T105812ZMartin E
020Lua180109T104424ZJonathan
017Triangularity180109T102753ZMr. Xcod
004J180109T103455ZFrownyFr
00105AB1E180109T102836ZEmigna

Uiua, 10 bytes

=∩(⋕▽⊸≠@ )

Explanation:

=∩(⋕▽⊸≠@ )
    ▽⊸≠@   => remove spaces
   ⋕       => parse 
 ∩(      ) => do for both strings
=          => check if both match

Try this online!

Pascal, 98 B

The string capabilities and the procedure readStr require a processor supporting features of Extended Pascal as laid out in ISO standard 10206.

type T=string(80);function f(A,B:T):Boolean;var x,y:integer;begin
readStr(A+' '+B,x,y);f:=x=y end;

Nogolf’d:

program compareTwoNumbersGivenAsStrings(output);
    type
        line = string(80);
    { Returns `true` if two strings denote the same `integer`. }
    function equal(protected imageX, imageY: line): Boolean;
        var
            x, y: integer;
        begin
            readStr(imageX + ' ' + imageY, x, y);
            equal ≔ x = y
        end;
    { ═══ MAIN ═══════════════════════════════════════════════ }
    begin
        writeLn(equal('0001',     '1    '   ),  true);
        writeLn(equal('1450',     '1450 '   ),  true);
        writeLn(equal('0010001 ', ' 10001  '),  true);
        writeLn(equal('0010000',  '  10  '  ), false);
        writeLn(equal('101023',   '101024'  ), false)
    end.

Excel / Google Sheets, 8 bytes

=-A1=-A2

or

=--A1=A2

Thunno 2, 2 bytes

Nạ

Attempt This Online!

The "cast to integer" built-in (N) handles leading/trailing spaces and leading zeros. Then, we can just check equality with .

J-uby, 9 bytes

:*&Z|+:==

Attempt This Online!

Explanation

:* & Z |       # Map with to_i (Z), then
         +:==  # Compare

I think this would be 7 bytes with J-uby’s ** operator:

Z**+:==

…but it’s broken or removed in the current version.

Julia 1.0, 30 bytes

a%b=eval(Meta.parse("$a==$b"))

Try it online!

Some meta programming fun, not the shortest solution though

Julia 1.0, 26 bytes

~x=parse(Int,x);a%b=~a==~b

Try it online!

Factor, 29 bytes

[ [ " "without dec> ] same? ]

Try it online!

Factor's number parser can't handle spaces so I have to remove them first.

nroff, 51 bytes

1 and 0 for truthy and falsey. Wish type convertion were available. .nr X \\$1=\\$2 did not work for some input.

.de F
.nr X \\$1
.nr Y \\$2
.nr X \\nX=\\nY
\\nX
..

Attempt This Online!

Ruby, 21 bytes

Pretty boring.

->a,b{a.to_i==b.to_i}

Attempt This Online!

Vyxal, 3 bytes

"⌊≈

Try it Online!

Explained

"⌊≈
"   # pair both inputs into list
 ⌊  # floor
  ≈ # all items equal?

R, 28 27 bytes

!diff(as.double(scan(,'')))

Reads numbers as strings, converts them to doubles and checks if their difference is not zero.

Try it online!

−1 byte thanks to Giuseppe

R, 55 bytes

V<-strtoi(gsub(" ","",c(A,B),fixed=T),base=9)
V[1]==V[2]

This is my first attempt at codegolf; gave it my best try. Suggestions welcome!

Assumptions:

  1. The inputs are given as strings A and B

  2. The integers contained are less than 1888888888. Larger values will cause strtoi() to return NA.

C# (32 bytes)

a=>b=>int.Parse(a)==int.Parse(b)

Try it online

as already mentioned in the comments, you can do it shorter than the C# provided in the question. I wrote this thinking I was clever before reading the reply to the comments by the OP. :)

Implicit, 5 bytes

'ì'ì=

Try it online!

'ì'ì=
'      «read string, push to stack                  »;
 ì     «swap type (integer/string) of top of stack  »;
  'ì   «do it again for the second integer string   »;
    =  «compare for equality                        »;

Excel VBA, 27 16 Bytes

-9 Thanks to @Nayrb and @TaylorScott

[C1]=[A1]-[B1]=0

Where you input the values on the Cells with 'string.

Where x and y are the input Strings and z is a Boolean output.

If CInt(x)=CInt(y) Then z=1

Using CInt

Swift, 80 79 78 bytes

import Foundation;func r(g:[NSString])->Bool{return g[0].intValue==g[1].intValue}

Try it online!

FALSE, 36 bytes

[0[^$9>][$32>[48-+10*]?]#%10/]$!\!=.

Numbers are received from the console, separated by a tab character. True=-1, False=0.

Pyt, 1 byte

=

Explanation

         Implicitly takes two inputs, and casts them to integers/floats if possible.
=        Checks if the two are equal

Try it online!

Perl 6, 4 bytes

*==*

Test it

The == operator converts to Numeric which ignores leading and trailing whitespace, and leading 0's get ignored just the same. (0o127 is how you write an octal)

The two * are just there to turn it into a lambda that takes two arguments.

Stratos, 3 bytes

_=_

Both of the _ take an input as a string and convert it to a number, then negate it.

Java converts the input to a number by removing 0s and spaces.

The = takes the results of this and checks for equality

Try it!

K (oK), 5 bytes

Solution:

=/.:'

Try it online!

Examples:

=/.:'("0001";"1    ")
1
=/.:'("1450";"1450 ")
1
=/.:'("0010001";" 10001  ")
1
=/.:'("0010000";"  10  ")
0
=/.:'("101023";"101024")
0

Explanation:

Convert each input to an integer, and then check for equality.

=/.:' / the solution
  .:' / value (.:) each ('), converts char list to integer
=/    / equality (=) over (/)

Brain-Flak, 22 bytes

(([{}]{})[{(){}}](){})

Try it online!

Saved 4 bytes thanks to Jo King.

Tcl, 45 bytes

proc x a\ b {expr [scan $a %d]==[scan $b %d]}

Try it online!

PHP 5.6+, 16 (42 when callable) bytes

The minimum code that meets the puzzle's requirements (16 bytes):

(int)$a==(int)$b

In callable form (42 bytes):

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

Try it online, with tests

Explanation

Declare a regular function with a single-character name f with two, otherwise undetermined parameters. It returns the result of comparing both arguments after casting each to integers, which safely removed the padding and whitespace. The code could have been made 2 bytes shorter by converting the function to a closure, but then the closure would not be assigned (which takes another 3 bytes), and therefore not callable.

AWK, 12 bytes

{$0=$1==$2}1

Try it online!

AWK, 9 bytes

$0=$1==$2

Alternate version: outputs 1 on match, otherwise outputs nothing

Try it online!

T-SQL, 35 bytes

Per our standards, data is input via pre-existing table t with varchar fields a and b.

    SELECT IIF(ABS(a)=ABS(b),1,0)FROM t

Returns 1 if they match, 0 if they don't.

A few of SQL's mathematical functions (including ABS, FLOOR and CEILING) will do an implicit conversion to numeric if given string parameters, this is shorter than an explicit CAST(a AS INT) or CONVERT(INT,b), and works in this case since we know the input values are always positive.

IIF is specific to MS SQL 2012 and above, so no guarantee about other implementations.

Q (Kdb+), 13 bytes

=/["J"$(x;y)]

Explanation

(x;y) : a list of the two inputs.

"J"$ : casting each input to a long (7j) type from string (10c), which can correctly interpret
white space and leading 0s.

=/ : checks equality over elements in a list (each subsequent pair).
As there is only one pair, returns single boolian 0b/1b.

Ruby, 23 bytes

s=->x,y{x.to_i==y.to_i}

Mumps, 7 bytes

W +X=+Y

In Mumps, all data are strings, the '+' operator evaluates the string to a numeric value. There is no implicit output function, so the 'W' (Write) function provides the output.

PowerShell, 19 bytes

$args-join'-eq'|iex

Try it online!

-join the argument array ($args) with the string representation of the comparison operator (-eq) then evaluate the expression with Invoke-Expression (iex).

Java 8, 58 51 bytes

7 bytes thanks to Kevin

b->c->new Long(b.trim()).equals(new Long(c.trim()))

Try it online!

Explanation

Trims off spaces, casting to Long removes leading zeros, and then returns boolean value if they are equal or not.

Javascript, 6 bytes

Pretty standard stuff, but using Javascript's auto type casting

!(a-b)

Or if we don't need it as a function (19 bytes)

let f=(a,b)=>!(a-b)

Try it online! https://jsfiddle.net/pgz4ctLy/2/

Batch, 89 bytes

@call:c %1
@set e=%errorlevel%
@call:c %2
@if %e%==%errorlevel% echo 1
:c
@exit/b%~1

Prints 1 if the two numbers are the same. Explanation: Batch's numeric processing usually uses leading zeros to indicate an octal number, however exit/b always takes a decimal number. The ~ removes any quotes that would be needed to pass leading or trailing spaces in the parameter.

Excel, 8 bytes

=A1-B1=0

Excel does the string to num conversion for us.

(To input as string, prefix values with '.)

Javascript, 11 bytes

a=>b=>+a==b

Abusing Javascript's casting rules a bit; +a coerces a into a numeric type.

-6 bytes thanks to Shaggy and Martin Ender♦

Also a cool take by LiefdeWen:

a=>b=>~~a==~~b

dc, 9 bytes

[1p]sQ?=Q

Outputs 1 if the numbers are equal, or nothing if unequal. The input numbers are separated by ',', and this gives a warning since data is code in dc. I wasn't sure if space was allowed as delimiter, so I chose one that doesn't stop the program.

Try it online!

C++ (gcc), 65 bytes

#include<cstdlib>
auto a(auto b,auto c){return atoi(b)==atoi(c);}

Try it online!

I initially tried used a lambda expression, but auto a=[] is three more characters, and less one more for no trailing semicolon. On the other hand, since atoi is not referenced until the lambda is instantiated, could I delete the #include and put that in the test harness footer instead?

C (gcc), 27 bytes

f(s,t){s=atoi(s)==atoi(t);}

With -O0 (which is the default setting).

Try it online!

C, 32 bytes

f(s,t){return atoi(s)==atoi(t);}

Try it online!

><>, 2 + 3 = 5 bytes

=n

Try it online!

Uses the -v flag to pass the values into the program. This automatically converts them to numbers, removing the spaces and leading 0s. It then outputs if the two are equal, and exits with an error as it tries to compare an empty stack.

R, 37 35 bytes

pryr::f(as.double(x)==as.double(y))

There's probably some cleverer way to coerce strings to numerics but I haven't figured it out yet.

Try it online!

Jelly, 8 bytes

t€⁶V€€ḌE

Try it online! or see the test suite

35 answers, and no Jelly submission? Takes the argument as a list (["0001", "1 "] for the first example)

How it works

t€⁶V€€ḌE - Main link. Argument: list       e.g.    ["0001", "1    "]
 €       - For €ach element...                     ["0001", "1"]
t        -   trim from both sides...
  ⁶      -   spaces
     €   - For €ach element...
   V€    -   evaluate €ach character               [[0, 0, 0, 1], [1]]
      Ḍ  - Convert from digits                     [1, 1]
       E - Are they equal?                         1

Clean, 52 bytes

import StdEnv
$n=toInt{#c\\c<-n|c>' '}
?n=(==)($n)o$

Try it online!

APL (NARS2000), 7 bytes

=⍥⍎

Well, yes, I do know NARS2000 can't compete over Dyalog here since it uses Unicode, but I thought I'd rather show off (called Composition in NARS2000, even though it's actually unrelated to function composition), something Dyalog doesn't have as a built-in and I haven't ever seen used here. In Dyalog, it has to be implemented as {(⍵⍵⍺)⍺⍺⍵⍵ ⍵}. What it does is call the right operand monadic function on both the left and right argument, and then call the left operand dyadic function on the results.

Here, the right operand is (Execute, i.e. eval) and the left operand is = (Equal To, i.e. check if its arguments are equal).

PowerShell, 20 bytes

param($a,$b)+$a-eq$b

Similar to the JavaScript answer, just longer because PowerShell doesn't have currying. Uses + to cast the first string to integer, and then the -equals automatically casts the second string to integer. Output is True/False.

Try it online!

Sinclair ZX81/Timex TS1000/1500 BASIC, ~29 tokenized BASIC bytes

New solution thanks to Neil (thanks for the tip).

 1 INPUT A$
 2 INPUT B$
 3 PRINT VAL A$=VAL B$

This solution requires user input, so enter in two strings with white spaces and/or leading zeros, or enter two strings of non-equal numeric value; 0 is false and 1 is true once line three has compared the value of each string entered.

Old solution: Sinclair ZX81/Timex TS1000/1500 BASIC, ~46 tokenized BASIC bytes

 1 LET A$=" 001 "
 2 LET B$="1"
 3 PRINT (VAL A$=VAL B$)

The actual check is done in line three, which is only ~16 tokenized BASIC bytes; so entering each test case pair using direct mode will save ~30 bytes from the listing. Note that this byte count does not include the var stack.

SNOBOL4 (CSNOBOL4), 42 bytes

	OUTPUT =EQ(EVAL(INPUT),EVAL(INPUT)) 1
END

Try it online!

Outputs 1 for truthy, nothing for falsey. Since (space) is the concatenation operator in SNOBOL, EVALing a number with leading/trailing spaces yields the number itself, and it also neatly takes care of any leading zeroes. EQ tests for numerical equality, conditionally setting OUTPUT to 1 on Success.

Husk, 3 bytes

¤=r

Try it online!

Explanation

¤    -- combine both arguments of ..
 =   -- .. equality ..
  r  -- .. with read

Taxi, 488 bytes

Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to Equal's Corner.Pickup a passenger going to Equal's Corner.Go to Equal's Corner:n 1 l 1 l 1 l.Switch to plan "b" if no one is waiting.'1' is waiting at Writer's Depot.[b]'0' is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 r 2 r 1 l.

Try it online!

Ungolfed:

Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to The Babelfishery.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: south 1st left 1st right.
Pickup a passenger going to Equal's Corner.
Pickup a passenger going to Equal's Corner.
Go to Equal's Corner: north 1st left 1st left 1st left.
Switch to plan "b" if no one is waiting.
'1' is waiting at Writer's Depot.
[b]
'0' is waiting at Writer's Depot.
Go to Writer's Depot: north 1st left 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st right 2nd right 1st left.

Taxi is (relatively) well-suited to this challenge because strings are the only input or output type allowed. The Babelfishery is what converts strings to number (and vice versa) and it handles stripping all the spaces and leading zeroes. It will also handle negative numbers if the - is immediately before the first digit. After that, Equal's Corner checks the two values against each other and Writer's Depot provides the output in string format. Output is 1 for truthy and 0 for falsey.

Attache, 11 bytes

Same@Map&:N

Try it online!

This takes an array of strings, such as V["0001", "1 "]. Simply stated, Map&:N is a function that maps N over its argument, and Same checks that the array contains only equal members. (Fun fact: this function works for more than 2 string arguments.)

Operation Flashpoint scripting language, 33 bytes

f={call format(["%1==%2"]+_this)}

Call with:

hint format["%1\n%2\n%3\n%4\n%5",
    ["0001", "1    "] call f,
    ["1450", "1450 "] call f,
    ["0010001 ", " 10001  "] call f,
    ["0010000", "  10  "] call f,
    ["101023", "101024"] call f]

Output:

Alternative version (41 bytes):

f={{t=call _x;r=t==s;s=t}forEach _this;r}

Still 5 bytes shorter than the more straightforward f={t=_this;call(t select 0)==call(t select 1)}

39 bytes:

f={{t=call _x;r=t==s;s=t}count _this;r}

count (which returns the size of an array) works instead of forEach, because you can give it a "lambda" that is used as a condition to count only the array elements that meet that condition. The "condition" used in this case is not a valid condition, but it doesn't matter here because it doesn't cause an error and the return value of the count is not needed.

Stacked, 8 bytes

[#~\#~=]

Try it online!

Explanation

[#~\#~=]   anonymous function
 #~        eval TOS
   \       swap top two
    #~     eval TOS
      =    push equality of top two

Wolfram Language, 27 bytes

ToExpression[#1<>"=="<>#2]&

Test cases:

In[1]:= ToExpression[#1 <> "==" <> #2] &["0001", "1"]
Out[1]= True

In[2]:= ToExpression[#1 <> "==" <> #2] &["1450", "1450 "]
Out[2]= True

In[3]:= ToExpression[#1 <> "==" <> #2] &["0010001", " 10001"]
Out[3]= True

In[4]:= ToExpression[#1 <> "==" <> #2] &["0010000", "  10  "]
Out[4]= False

In[5]:= ToExpression[#1 <> "==" <> #2] &["101023", "101024"]
Out[5]= False

Pyth, 4 bytes

qFsM

Try it online!

Int-parse each element of the input list with sM(Q), then Fold over equality.

Perl 5, 9 + 1 (-p) = 10 bytes

$_=$_==<>

try it online

jq, 24 characters

map(tonumber)|.[0]==.[1]

The 2 strings are passed as items of an array.

Sample run:

bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010001 ", " 10001  "]'
true

bash-4.4$ jq 'map(tonumber)|.[0]==.[1]' <<< '["0010000", "  10  "]'
false

Try it online! (All test cases)

Gema, 21 characters

*\n*=@cmpn{*;*;0;1;0}

No boolean in Gema. As the @get-switch{}/@set-switch{} functions use 0 and 1 to represent switch statuses, also used 0 and 1.

The 2 strings are passed on separate input lines.

Sample run:

bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010001\n10001  '
1

bash-4.4$ gema '*\n*=@cmpn{*;*;0;1;0}' <<< $'0010000\n  10  '
0

Python 3, 25 bytes

lambda a,b:int(a)==int(b)

Try it online!

APL (Dyalog), 4 bytes

3 bytes saved thanks to @Adám

=/⍎¨

Try it online!

Japt, 3 bytes

¥Vn

Try it

Converts the second input to an integer and compares equality with the first.

Alice, 7 bytes

X/n
o@i

Try it online!

Any non-digit separator works. Prints 1 for equality and 0 otherwise.

Explanation

X   XOR, does nothing.
/   Switch to Ordinal mode.
i   Read all input as a string.
/   Switch to Cardinal mode.
X   XOR. Implicitly finds all integers in the string and pushes them separately
    onto the stack. The XOR gives 0 if the values are identical.
n   Logical NOT. Gives 1 for equal inputs and 9 otherwise.
/   Switch to Ordinal.
o   Print the 0 or 1 as a string.
/   Switch to Cardinal.
@   Terminate the program.

Haskell, 20 bytes

-11 bytes thanks to Laikoni. -2 bytes thanks to Zgarb.

a#b=0+read a==read b

Try it online!

Retina, 11 bytes

.+
$*
D`
¶$

Try it online!

Input is linefeed separated, but the test suite uses comma separation for convenience. Prints 1 for equality and 0 for inequality.

Explanation

.+
$*

Convert each line to unary. This ignores leading zeros and spaces.

D`

Deduplicate: clear the second line if both are the same.

¶$

Check that the string now ends in a linefeed.

Lua, 20 bytes

print(...-arg[2]==0)

Try it online!

Triangularity, 17 bytes

..)..
.Ii).
@Ii=.

Try it online!

Triangularity is, for once, competitive!

How it works

Triangularity requires the code to have a triangular distribution of the dots. That is, the length of each row must be equal the number of rows multiplied by 2 and decremented, and each row must have (on each side) a number of dots equal to its position in the program (the bottom row is row 0, the one above it is row 1 and so forth). Keeping this in mind, let's analyse how the code works:

..).. || Push a 0 onto the stack.
.Ii   || Get the 0th input and cast it to an integer.
   ). || Push another 0 onto the stack.
@I    || Increment the ToS => 1. Get the first input.
  i=. || Then cast it to an integer and compare their equality.

J, 4 bytes

=&do

Compare = after & evaluating do. Can also be =&". Try it online!

05AB1E, 1 byte

Q

Try it online!

Explanation

Comparison for equality Q will automatically try to evaluate strings as ints before comparing.