+ 31

[ASSIGNMENT] : Binary Check

The binary numeral system, or base-2 number system, represents numeric values using two symbols: 0 and 1. Write a program to check the given number is binary number or not? For Example, Is 11010 binary? true Is 11030 binary? false //Assigned in the Lessons Factory!

20th Mar 2018, 9:59 AM
MeanMachine
MeanMachine - avatar
25 Answers
20th Mar 2018, 7:08 PM
Shobikaj
Shobikaj - avatar
+ 27
//mine try in java ☺ String str=new Scanner(System.in).next(); for(int i=0;i<str.length();i++) if(!(str.charAt(i)=='0'||str.charAt(i)=='1')){ System.out.println("not binary number"); System.exit(0);} System.out.print("is binary number");
20th Mar 2018, 10:30 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
20th Mar 2018, 10:08 AM
MeanMachine
MeanMachine - avatar
+ 23
@Gaurav Agrawal great, 👏 why did not you write a code, ☺ thank you for participating and support 👍
20th Mar 2018, 10:36 AM
MeanMachine
MeanMachine - avatar
+ 23
@Shobikaj I would like Your Answer to be declared as The Best! 😀 Please make it Public! 😊👍 I really like your solution! 😆👍
21st Mar 2018, 8:36 AM
MeanMachine
MeanMachine - avatar
20th Mar 2018, 11:49 AM
LukArToDo
LukArToDo - avatar
+ 20
@Tasvir You did Not answer the Challenge! Read the Task ?! CHALLENGE : Binary Check!! Write a program to check the given number is Binary Number or Not? Make your code Public!
23rd Mar 2018, 12:59 PM
MeanMachine
MeanMachine - avatar
+ 18
welcome , will make code next time //I just saw and then started typing 😅 //thnx for 4 challenge
20th Mar 2018, 10:37 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
20th Mar 2018, 12:04 PM
John Wells
John Wells - avatar
20th Mar 2018, 5:10 PM
Med Arezki
Med Arezki - avatar
+ 10
b=input() print(b,not(b.replace('0','').replace('1',''))) https://code.sololearn.com/cvCE38xqCtQe/?ref=app
20th Mar 2018, 1:09 PM
Louis
Louis - avatar
+ 10
My solution: • One-liner • No if statements • No regExp • 73 bytes https://code.sololearn.com/c6qDyDIiL74c/?ref=app
20th Mar 2018, 6:01 PM
ƒred
ƒred - avatar
+ 9
Here's my attempt. Thanks for challenge : ) https://code.sololearn.com/cxqw2zcoqzr8/?ref=app
20th Mar 2018, 4:04 PM
Ipang
+ 8
heres my 5 whole methods.. 3 rd 1 is not supported here.. https://code.sololearn.com/cd1jh8sht4Io/?ref=app
20th Mar 2018, 3:56 PM
sayan chandra
sayan chandra - avatar
+ 7
python oneliner: print(not (set(input())-{'0','1'}))
20th Mar 2018, 10:07 PM
VcC
VcC - avatar
+ 6
@MeanMachine Here the simple solution of your problem I make it code in simple way. https://code.sololearn.com/cY2l4tRB5jhy/?ref=app
21st Mar 2018, 9:15 AM
Maninder $ingh
Maninder $ingh - avatar
+ 6
https://code.sololearn.com/cE36eu2jr9ct/?ref=app
22nd Mar 2018, 5:22 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 5
21st Mar 2018, 2:35 AM
Maninder $ingh
Maninder $ingh - avatar
+ 5
https://code.sololearn.com/craHAVhTHNBy/?ref=app
21st Mar 2018, 3:02 PM
VISHAL SRIVASTAVA
VISHAL SRIVASTAVA - avatar
+ 4
😊
22nd Mar 2018, 4:23 PM
Raj Chhatrala
Raj Chhatrala - avatar