Compare commits
5 Commits
2333762f46
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ef616df92 | |||
| 41c53e86ec | |||
| 54666fd55c | |||
| 4c74a07eb6 | |||
| f34be20aa1 |
@@ -9,8 +9,8 @@ Rules command
|
||||
Interface to ask number
|
||||
'Higher or lower' interface
|
||||
Variable number. 'Between 1 and a user selected number'
|
||||
Percentage of Variable Number to be number of guesses
|
||||
maybe 30% ?
|
||||
Percentage of Variable Number to be number of guesses
|
||||
maybe 30% ?
|
||||
Play Again? dialog
|
||||
|
||||
## Outline
|
||||
|
||||
21
bash/randTest.sh
Executable file
21
bash/randTest.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# set script restart
|
||||
script=$(readlink -f "$0")
|
||||
|
||||
# Select number
|
||||
echo "Pick a number:"
|
||||
read num
|
||||
|
||||
# Output response
|
||||
echo "The random number is $((1 + $RANDOM % $num))."
|
||||
|
||||
# Ask to run again
|
||||
|
||||
echo "Run script again (yes/no)?"
|
||||
read answer
|
||||
if [ "$answer" = yes ]
|
||||
then exec "$script"
|
||||
fi
|
||||
echo "Exiting"
|
||||
exit 0
|
||||
0
delete.test
Normal file
0
delete.test
Normal file
BIN
lua/Notes/help1.png
Normal file
BIN
lua/Notes/help1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
10
lua/randTest.lua
Normal file
10
lua/randTest.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
io.write("Pick a number: ")
|
||||
local number = io.read("*n")
|
||||
local randnum = math.random(1, number)
|
||||
print("The number is ", randnum)
|
||||
-- ask to rerun script
|
||||
print("Run again (y/n)?")
|
||||
local cmd = io.read()
|
||||
if cmd == "y" then
|
||||
dofile("randTest.lua")
|
||||
else end
|
||||
26
lua/randTestExperiment.lua
Normal file
26
lua/randTestExperiment.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Assistance from a friend
|
||||
|
||||
-- Instantiate all the things
|
||||
local run = true
|
||||
local cmd, number, randnum
|
||||
|
||||
-- Start a loop
|
||||
while run == true do
|
||||
-- Get the users initial number
|
||||
io.write("Pick a number: ")
|
||||
number = io.read("*n")
|
||||
|
||||
-- Do some mathemagic
|
||||
-- randnum = math.random(1, number)
|
||||
print("The random number is ", math.random(1, number))
|
||||
|
||||
-- Ask to rerun script
|
||||
io.read()
|
||||
print("Run again (Y/n)?")
|
||||
cmd = io.read("*l")
|
||||
|
||||
-- Exit if the user doesn't want to go again
|
||||
if string.lower(cmd) ~= "y" then
|
||||
run = false
|
||||
end
|
||||
end
|
||||
26
lua/randTestHelped.lua
Normal file
26
lua/randTestHelped.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- Assistance from a friend
|
||||
|
||||
-- Instantiate all the things
|
||||
local run = true
|
||||
local cmd, number, randnum
|
||||
|
||||
-- Start a loop
|
||||
while run == true do
|
||||
-- Get the users initial number
|
||||
io.write("Pick a number: ")
|
||||
number = io.read("*n")
|
||||
|
||||
-- Do some mathemagic
|
||||
randnum = math.random(1, number)
|
||||
print("The random number is ", randnum)
|
||||
|
||||
-- Ask to rerun script
|
||||
io.read()
|
||||
print("Run again (Y/n)?")
|
||||
cmd = io.read("*l")
|
||||
|
||||
-- Exit if the user doesn't want to go again
|
||||
if string.lower(cmd) ~= "y" then
|
||||
run = false
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user