Skip to content

Instantly share code, notes, and snippets.

@danielborowski
Created June 1, 2017 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielborowski/9bb9ac70e8522cb97cff1c9532e1162b to your computer and use it in GitHub Desktop.
Save danielborowski/9bb9ac70e8522cb97cff1c9532e1162b to your computer and use it in GitHub Desktop.
def QuestionsMarks(s):
qnum = 0
dig = 0
has_10 = False
for ch in s:
if ch.isdigit():
if int(ch) + dig == 10:
if qnum != 3:
return 'false'
has_10 = True
dig = int(ch)
qnum = 0
elif ch == '?':
qnum += 1
return 'true' if has_10 else 'false'
@AdamLaing
Copy link

This code fails the following assertion:

assert(QuestionsMarks("7?6??3?4") == 'true')

If that is what was intended by the question, then I think the challenge question needs to be rewritten. The way I read the question, I thought that we needed to check every sub-string between any pair of numbers in the entire string that could add up to 10.

In fact, I just realized that the test case in the challenge

"5??aaaaaaaaaaaaaaaaaaa?5?a??5" == true

would be false under my reading of the question, so your code does seem to fit what the challenge had in mind, but I will stand by my assertion that the question is unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment