カンマで区切られた前半の文字列が、
後半の文字列で終わるなら1、そうでなければ0を表示。
正答率87%
((306.0/(306+45))*100).round
設問
You are given two strings 'A' and 'B'. Print out a 1 if string 'B' occurs at the end of string 'A'. Else a zero.
Input sample:
The first argument is a file, containing two strings, comma delimited, one per line. Ignore all empty lines in the input file.e.g.
Hello World,World Hello CodeEval,CodeEval San Francisco,San Jose
Output sample:
Print out 1 if the second string occurs at the end of the first string. Else zero. Do NOT print out empty lines between your output.
e.g.
1 1 0
やってみた
#!/usr/bin/env ruby ARGF.lines do |line| puts line.chomp.split(',').instance_eval{ |main, trail| main.match(/#{trail}$/)? 1 : 0 } end