jarv / cmdchallenge

This repo is mirror of https://gitlab.com/jarv/cmdchallenge
https://about.cmdchallenge.com
MIT License
721 stars 71 forks source link

Ordering in print_common_lines #72

Closed t-lin closed 7 years ago

t-lin commented 7 years ago

Note: if you are having trouble with a challenge you can see solutions here -> https://github.com/jarv/cmdchallenge/blob/master/challenges.yaml Search for the challenge and look for the example: to see one way of doing it.

Summary

The ordering of print_common_lines should not matter. Looking at the challenges.yaml file, I believe the "order: false" should go under "expected_output:"

Steps to reproduce

Link to challenge: https://cmdchallenge.com/#/print_common_lines

This returns a correct solution for the challenge but is not accepted: IPS1=`cat access.log.1 | awk '{print $1}'`; IPS2=`cat access.log.2 | awk '{print $1}'`; for ip in $IPS1; do if [[ "$IPS2" =~ "$ip" ]]; then echo $ip; fi; done

doctorray117 commented 7 years ago

Another method that should be accepted but isn't: cat access.log.1 | awk '{ print $1 }' | egrep "$(cat access.log.2 | awk '{ print $1 }' | tr '\n' '|' | sed -e 's/.$//g')" Adding a "| sort" to the end is accepted.

jarv commented 7 years ago

There was an indent typo on challenges.yaml that is fixed in d5b8128acd99d96164516fb68a49edb7f5905698

Thanks for filing the issue!

bash(0)> IPS1=`cat access.log.1 | awk '{print $1}'`; IPS2=`cat access.log.2 | awk '{print $1}'`; for ip in $IPS1; do if [[ "$IPS2" =~ "$ip" ]]; then echo $ip; fi;
 done
108.68.174.15
28.151.137.59
2.71.250.27
17.137.186.194
# 👍 👍 👍  Correct!
# You have a new challenge!
# Print "hello world".
# Hint: There are many ways to print text on
# the command line, one way is with the 'echo'
# command.
# 
# Try it below and good luck!
# 
bash(1)> cat access.log.1 | awk '{ print $1 }' | egrep "$(cat access.log.2 | awk '{ print $1 }' | tr '\n' '|' | sed -e 's/.$//g')"
108.68.174.15
28.151.137.59
2.71.250.27
17.137.186.194
# 👍 👍 👍  Correct!
# You have a new challenge!
# Print "hello world".
# Hint: There are many ways to print text on
# the command line, one way is with the 'echo'
# command.
# 
# Try it below and good luck!
#