def solve(request, question_id, answer_id):
 question = get_object_or_404(Question, pk=question_id, is_spam=False)
 if (not request.user.is_authenticated()):
  watch_secret = request.GET.get('watch', None)
  try:
   watch = Watch.objects.get(secret=watch_secret, event_type='question reply', user=question.creator)
   distinguishable_letters = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ'
   new_secret = ''.join((random.choice(distinguishable_letters) for x in xrange(10)))
   watch.update(secret=new_secret)
   request.user = question.creator
  except Watch.DoesNotExist:
   return HttpResponseForbidden()
 answer = get_object_or_404(Answer, pk=answer_id, is_spam=False)
 if (not question.allows_solve(request.user)):
  raise PermissionDenied
 if ((question.creator != request.user) and (not request.user.has_perm('questions.change_solution'))):
  return HttpResponseForbidden()
 if (not question.solution):
  question.set_solution(answer, request.user)
  messages.add_message(request, messages.SUCCESS, _('Thank you for choosing a solution!'))
 else:
  messages.add_message(request, messages.ERROR, _('This question already has a solution.'))
 return HttpResponseRedirect(question.get_absolute_url())

def solve ( request , question_id , answer_id ) : question = get_object_or_404 ( Question , pk = question_id , is_spam = False ) if ( not request . user . is_authenticated ( ) ) : watch_secret = request . GET . get ( 'watch' , None ) try : watch = Watch . objects . get ( secret = watch_secret , event_type = 'question reply' , user = question . creator ) distinguishable_letters = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ' new_secret = '' . join ( ( random . choice ( distinguishable_letters ) for x in xrange ( 10 ) ) ) watch . update ( secret = new_secret ) request . user = question . creator except Watch . DoesNotExist : return HttpResponseForbidden ( ) answer = get_object_or_404 ( Answer , pk = answer_id , is_spam = False ) if ( not question . allows_solve ( request . user ) ) : raise PermissionDenied if ( ( question . creator != request . user ) and ( not request . user . has_perm ( 'questions.change_solution' ) ) ) : return HttpResponseForbidden ( ) if ( not question . solution ) : question . set_solution ( answer , request . user ) messages . add_message ( request , messages . SUCCESS , _ ( 'Thank you for choosing a solution!' ) ) else : messages . add_message ( request , messages . ERROR , _ ( 'This question already has a solution.' ) ) return HttpResponseRedirect ( question . get_absolute_url ( ) )
solve the equation a x = b for x .