6 kyu

Simple Fun #52: Pair Of Shoes

1,031 of 2,052myjinxin2015

Description:

Task

Yesterday you found some shoes in your room. Each shoe is described by two values:

type indicates if it's a left or a right shoe;
size is the size of the shoe.

Your task is to check whether it is possible to pair the shoes you found in such a way that each pair consists of a right and a left shoe of an equal size.

Example

For:

shoes = [[0, 21], 
         [1, 23], 
         [1, 21], 
         [0, 23]]

the output should be true;

For:

shoes = [[0, 21], 
         [1, 23], 
         [1, 21], 
         [1, 23]]

the output should be false.

Input/Output

  • [input] 2D integer array shoes
    Array of shoes. Each shoe is given in the format [type, size], where type is either 0 or 1 for left and right respectively, and size is a positive integer.

    Constraints: 2 ≤ shoes.length ≤ 50, 1 ≤ shoes[i][1] ≤ 100.

  • [output] a boolean value

    true if it is possible to pair the shoes, false otherwise.

Puzzles

Stats:

CreatedJan 25, 2017
PublishedJan 25, 2017
Warriors Trained3911
Total Skips69
Total Code Submissions9199
Total Times Completed2052
JavaScript Completions1031
Python Completions748
Ruby Completions74
Crystal Completions6
C# Completions148
C Completions51
Factor Completions6
Java Completions64
Haskell Completions12
Total Stars57
% of votes with a positive feedback rating95% of 320
Total "Very Satisfied" Votes294
Total "Somewhat Satisfied" Votes21
Total "Not Satisfied" Votes5
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • GiacomoSorbi Avatar
  • suic Avatar
  • myjinxin-2015 Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • user9644768 Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • Ciprian Amza Avatar
  • Kacarott Avatar
  • tri@ Avatar
  • dfhwze Avatar
Ad