For loop - 1 seat every 30 people

For loop - 1 seat every 30 people - Сообщения

#1 Опубликовано: 11.10.2021 16:34:23
talpacolore

talpacolore

0 сообщений из 4 понравились пользователям.

Группа: User

Hi to everyone, I'm a new user of S-math.
I'm a newbie to programming.
Today I had to make a calculation to size the number of seats in a waiting room according to the total number of people.
The number of seats must be 1 for every 30 people.
I tried to make the calculation automatic via S-math, but I was unable. I thought the for loop might help me, but I don't know how. Can someone help me?
#2 Опубликовано: 12.10.2021 04:25:23
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: Moderator

You should start from the problem itself... How would you solve it in mathematical or pseudocode form?
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Опубликовано: 12.10.2021 09:57:04
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

That's my understanding of your project.
Jean.

SocialSeats.PNG
#4 Опубликовано: 12.10.2021 13:19:00
talpacolore

talpacolore

0 сообщений из 4 понравились пользователям.

Группа: User

Hi I try to explain better what I want to calculate.
I would like to set up a for loop that allows me to do the same calculations as the if loop in the figure.
Cattura.PNG

for example

if n.pers < 10 ---> n.s = 1
if n.pers > 10 & n.pers < 30 ---> n.s = 2
if n.pers > 30 & n.pers < 60 ---> n.s = 3
if n.pers > 60 & n.pers < 90 ---> n.s = 4
and so on

I don't know how if it's possible set up this cycle, anyway thanks.
#5 Опубликовано: 12.10.2021 13:57:13
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: Moderator

Wrote

Hi I try to explain better what I want to calculate.
I would like to set up a for loop that allows me to do the same calculations as the if loop in the figure.

for example

if n.pers < 10 ---> n.s = 1
if n.pers > 10 & n.pers < 30 ---> n.s = 2
if n.pers > 30 & n.pers < 60 ---> n.s = 3
if n.pers > 60 & n.pers < 90 ---> n.s = 4
and so on

I don't know how if it's possible set up this cycle, anyway thanks.


You don't need an iteration.
Ceil() and cases() shall work for you.

Regards

2021-10-12_19-56.png
1 пользователям понравился этот пост
Davide Carpi 12.10.2021 16:15:00
#6 Опубликовано: 12.10.2021 14:29:11
talpacolore

talpacolore

0 сообщений из 4 понравились пользователям.

Группа: User

Hi
I'm probably doing something wrong because, for exemple, with 40 or 70 it doesn't work.
#7 Опубликовано: 12.10.2021 14:38:28
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: Moderator

Wrote

Hi
I'm probably doing something wrong because, for exemple, with 40 or 70 it doesn't work.


Probably, please use the file below.
Regards

seats.sm (2 КиБ) скачан 32 раз(а).
#8 Опубликовано: 12.10.2021 14:50:02
sergio

sergio

115 сообщений из 329 понравились пользователям.

Группа: User

The suggestion of Overlord is correct. You can also define a function and make different corresponding values ​​calculate (using the Vectorize function)
number_seat.sm (6 КиБ) скачан 39 раз(а).
sergio
#9 Опубликовано: 12.10.2021 15:11:23
talpacolore

talpacolore

0 сообщений из 4 понравились пользователям.

Группа: User

Thank to all. you are great!
I used an old version. Now work correctly in my pc, too.
#10 Опубликовано: 12.10.2021 15:41:15
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Page8 Social.sm (16 КиБ) скачан 29 раз(а).
#11 Опубликовано: 12.10.2021 17:42:31
overlord

overlord

552 сообщений из 1332 понравились пользователям.

Группа: Moderator

Wrote

Page8 Social.sm (16 КиБ) скачан 29 раз(а).


Not related with OP's question.
#12 Опубликовано: 12.10.2021 20:25:44
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I don't know how if it's possible set up this cycle, anyway thanks.



Social...Seats.PNG

You can elongate at will:
1. collect the last condition from RHS
2. double coma

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений