PHP
php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/*
Author: Xan
Date: 13th April 2018
https://www.sololearn.com/learn/7130/?ref=app
VARIATION:
Aim:
For the digits 1 to 9, you can either have an empty string,
a plus sign, or a minus sign, to create expressions as
follows:
1+2-3-45+67+8+9
The aim is to find expressions like this, that evaluate
to all numbers from 1 to 100 (I go from 1 to 159, as 160 is the first number with no solution).
Notes: eval() is normally a risky command, however this code
doesn't take any input from a user, so the risk is low.
*/
// Get an operator, (or empty string),
// give a number from 1 to 3.
function get_operator($operator_number)
{
if ($operator_number == 1)
{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run