✓ Trusted by 500+ organizations since 2014

Quiz

Barcode challenge

Emil
Skribent
February 15, 2021 2 mins read

Barcode challenge

In this week’s challenge, you need to help your local post office whose package sorting system is broken. The packages have a barcode that, when scanned, are converted into a series of ones and zeroes (bits).

The destination country is written in the barcode. It is determined by the two first bits and by the last bit. Write a formula in column U that outputs the destination of the package.

Italy 11xxxxx1
France 11xxxxx0
Germany 10xxxxx1
Spain 01xxxxx0
Russia 00xxxxx0
USA 01xxxxx1

 


Drop your solution in the comments below! 🙂

Our solution (solves both medium and hard version):


=IF(AND(AND(M6;N6);T6);”Italy”;IF(AND(AND(M6;N6);XOR(N6;T6));”France”;IF(AND(AND(M6;T6);OR(T6;N6));”Germany”;
IF(AND(XOR(M6;N6);XOR(N6;T6));”Spain”;IF(AND(AND(NOT(M6);NOT(N6);NOT(T6)));”Russia”;
IF(AND(XOR(M6;N6;);AND(N6;T6));”USA”;”Country not found”))))))

Since the barcodes are represented by bits, we have chosen to solve this challenge with boolean logic. Inside each IF-function we evaluate the specific countries only with logical operators (AND, OR, XOR & NOT).

Read more about boolean logic:

https://www.i-programmer.info/babbages-bag/235-logic-logic-everything-is-logic.html

 

Built for Nordic business teams

See how Learnesy works for your team

12 years in market. Admin dashboard included. Courses in Swedish and Norwegian

500+ companies 4.9 on Google
Book a demo Try free for 7 days

Try some lessons in this course for free

Fill in your e-mail address and telephone and we will give you 7 days free access to some lessons in this course.

No card required!
Skribent

Emil har jobbat på Learnesy som produktutvecklare i flera år och ligger bakom flera av Learnesys kurser. Han har en utbildning inom datavetenskap med ett stort intresse för det analytiska och teoretiska. Utöver Finska och Svenska snackar Emil även flytande Excelfunktioner!