Microsoft Small Basic

Program Listing:
Embed this in your website
' Maths Challenge - December 2018
' Copyright © 2018 Nonki Takahashi. The MIT License.
' Program ID SZP003-0

' Write a program that outputs all possibilities to put + or - or nothing
' between the numbers 1,2,…,9 (in this order) such that the result is 100.
' For example 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100

delim="0= + ;1= - ;2=;"
For j = 0 To Math.Power(3, 8) - 1
  _j = j
  e = 9
  For i = 8 To 1 Step -1
    r = Math.Remainder(_j, 3)
    e = Text.Append(i, Text.Append(delim[r], e))
    _j = (_j - r) / 3
  EndFor
  Eval()
  If ans = 100 Then
    TextWindow.WriteLine(e + " = " + ans)
  EndIf
EndFor

Sub Eval
  ' param e - expression
  ' return ans - answer
  sign = 1
  ans = 0
  num = ""
  For p = 1 To Text.GetLength(e)
    c = Text.GetSubText(e, p, 1)
    If c = "+" Then
      ans = ans + sign * num
      sign = 1
      num = ""
    ElseIf c = "-" Then
      ans = ans + sign * num
      sign = -1
      num = ""
    ElseIf c = " " Then
    Else
      num = Text.Append(num, c)
    EndIf
  EndFor
  ans = ans + sign * num
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.