#AWK, 95 bytes BEGIN{RS="(.)" split("hello",h,"")}{for(j=0;++j<6;){c=RT printf c if(c!=h[j])next getline}exit}
AWK, 95 bytes
BEGIN{RS="(.)"
split("hello",h,"")}{for(j=0;++j<6;){c=RT
printf c
if(c!=h[j])next
getline}exit}
There are 2 things I learned here:
1) To split records between characters use RS="(.)" and then RT must be used instead of 1ドル
2) ORS is used by print and is defaulted to "\n"
3) I can't count to 2 and using printf is "cheaper" than assigning ORS and using print
Example usage: Place code in FILE
awk -f FILE some_data_file
or
some process | awk -f FILE
Code was tested using Dennis's yes | ... suggestion and I saw lots and lots of ys.
FYI, you can do the RS assignment as an option and pull it out of the BEGIN block via:
awk -v RS='(.)'
#AWK, 95 bytes BEGIN{RS="(.)" split("hello",h,"")}{for(j=0;++j<6;){c=RT printf c if(c!=h[j])next getline}exit}
There are 2 things I learned here:
1) To split records between characters use RS="(.)" and then RT must be used instead of 1ドル
2) ORS is used by print and is defaulted to "\n"
3) I can't count to 2 and using printf is "cheaper" than assigning ORS and using print
Example usage: Place code in FILE
awk -f FILE some_data_file
or
some process | awk -f FILE
Code was tested using Dennis's yes | ... suggestion and I saw lots and lots of ys.
FYI, you can do the RS assignment as an option and pull it out of the BEGIN block via:
awk -v RS='(.)'
AWK, 95 bytes
BEGIN{RS="(.)"
split("hello",h,"")}{for(j=0;++j<6;){c=RT
printf c
if(c!=h[j])next
getline}exit}
There are 2 things I learned here:
1) To split records between characters use RS="(.)" and then RT must be used instead of 1ドル
2) ORS is used by print and is defaulted to "\n"
3) I can't count to 2 and using printf is "cheaper" than assigning ORS and using print
Example usage: Place code in FILE
awk -f FILE some_data_file
or
some process | awk -f FILE
Code was tested using Dennis's yes | ... suggestion and I saw lots and lots of ys.
FYI, you can do the RS assignment as an option and pull it out of the BEGIN block via:
awk -v RS='(.)'
#AWK, 95 bytes BEGIN{RS="(.)" split("hello",h,"")}{for(j=0;++j<6;){c=RT printf c if(c!=h[j])next getline}exit}
There are 2 things I learned here:
1) To split records between characters use RS="(.)" and then RT must be used instead of 1ドル
2) ORS is used by print and is defaulted to "\n"
3) I can't count to 2 and using printf is "cheaper" than assigning ORS and using print
Example usage: Place code in FILE
awk -f FILE some_data_file
or
some process | awk -f FILE
Code was tested using Dennis's yes | ... suggestion and I saw lots and lots of ys.
FYI, you can do the RS assignment as an option and pull it out of the BEGIN block via:
awk -v RS='(.)'