How do you psuedocode this problem? How do simplify this problem before writing the code? - pseudocode

Your week is almost always the same. On the list of things to do for the day, you brush your teeth, take a shower, eat breakfast, drive your car to work, work/field work/meetings, come home, eat dinner at home, sleep. There are some days where your activities change.
On Wednesdays, you don’t eat breakfast as you need to be really early for work.
Monday, Wednesday and Friday, you have office work, while you have meetings on Tuesday, and field work on Thursday.
On Tuesdays, you take the bus instead of driving since your car is coding on that day.
On Fridays, you eat dinner out with your family and watch a movie.
Create pseudocode that shows your week detailed activities. TAKE NOTE that you can only use one loop.
I have researched about adding and removing in arrays.
Looked into nested loops but it requires just 1 loop
var week = [monday ,tuesday, wednesday, thursday, friday]
var toDo = [Brush teeth ,take shower ,eat breakfast ,drive car ,work ,come home ,eat dinner at home]
for (day in week) {
var monday += toDo;
}
return monday
Just wanted your version on how you will approach / pseudocode this problem.

Since you can only use one loop, a second array (toDo) isn't of use, since a second loop would be needed to process that. A possible approach is:
var week = [Monday, Tuesday, Wednesday, Thursday, Friday]
for day in week
{
brush teeth
take shower
if day is not Wednesday, eat breakfast
if day is Tuesday, take bus, else drive car to work
if day is Monday, Wednesday or Friday, office work
else if day is Tuesday, meetings
else (day is Thursday) field work
come home
if day is Friday, eat dinner out and watch movie, else eat dinner at home
sleep
}

Related

Set Slackbot a reminder for every weekday except Wednesday

I'm looking for something like
/remind #channel "It's time for daily stand up !" Monday Tuesday Thursday Friday at 11:45am. Click here to join: Link.
/remind #channel "It's time for daily stand up !" every Monday and Tuesday and Thursday and Friday
You have many possibilities.
Example (implicit, weekday):
/remind #channel "It's time for daily stand up!" every weekday
or (long way, day list):
/remind #channel "It's time for daily stand up!" every Monday and Tuesday and Wednesday and Thursday and Friday
and you can also add a specific time, for example:
/remind #channel "It's time for daily stand up!" at 9AM every weekday
Docs:
https://slack.com/intl/en-gb/help/articles/208423427-Set-a-reminder

How do I get slack to remind me every fortnight from next Saturday

Slack has the /remind command that allows you to set a reminder in a channel. I am trying to have slack remind me every fortnight starting from next Saturday at 8pm to jump on a call. It seems like an extension of the help documentation.
I tried:
/remind #here Fortnightly planning and retro every fortnight from saturday at 8pm
but it didn't work and the reminder states:
I will remind space-racing “planning and retro every fortnight from saturday at 8pm” at 9AM every other Saturday (next occurrence is April 22nd).
Any thoughts? thanks in advance
I was trying to do this today also. Either of these options work:
Needs to be run the week before you want it to start:
/remind me to "ABC" every other Saturday 8pm
/remind me to "ABC" Saturday 8pm every 2 weeks
Otherwise specify the start date
/remind me to "ABC" Jun 19th 8pm every 2 weeks
/remind me to "ABC" next Saturday 8pm every 2 weeks
Slackbot told me:
I will remind you to “ABC” at 8PM every other Saturday (next occurrence is June 19th).
Only achievable when setting a reminder <7 days when the first occurrence should happen. For example if you want to set the reminder at Saturday May 9th at 8pm, the earliest you can set the reminder is Saturday May 2nd 8:01pm
Then you run a command like so:
/remind #my-channel #my-group-to-notify This is my reminder message at 8pm every other Saturday
You can skip the channel or group of course. But it's nice if you run some team ceremonies and want to set reminder to specific people to attend a meeting etc.
Hint: you always set the time as per your current timezone, if other people are in different time zone the reminder will be at their time, so you don't need to worry that 8pm might be for them later/earlier. You all will see reminder in the same moment.
You can specify the starting date by the keyword starting at the end.
/remind #my-channel #my-group-to-notify This is my reminder message at 8pm every other Saturday starting April 29nd
But you need to set this. they week before you want to get notified.
For e.g Today is 7th September 2018 ( Friday) and you want to get notified on 21st September 2018 ( Friday ) i.e second Friday after today ( Friday ).
you need to use this command on next Friday. ie. on 14th September 2018 , use this command and slack will start reminding you after every other( second ) friday.
Example Command on SlackBot :
/remind me to "Send : Time Sheet" every other Friday 11am

How to get rid of reminder time issue in slack?

I am currently using slack, it’s a great team work tool. I have one issue though: when I create a remind say, /remind me “abc” at night, it sets the reminding time as 3pm. but this is not night, i would like to have 6pm, or better I can set it myself (i.e., set tonight as 6pm). How can I achieve this? - btw, i live in US west coast
You can use the time itself or a relative time:
/remind me "abc" at 6pm CST
/remind me "123" tomorrow night at 8pm CST
/remind me "youandme" 5 hours from now
You can also set your timezone data by exploring the /tz command
You can set it on the account level by following the instructions here.

Run a job every other monday

I would like to use Heroku scheduler to run every OTHER Monday. However, it only runs hourly, daily, every 10 minutes.
I read this...
How can I schedule a 'weekly' job on Heroku?
However, I'm not sure what code can be used. I think I can figure out every Monday, but not every OTHER Monday.
thanks
As you get more complicated, I'd recommend checking out scheduling gems. If you want to stick to vanilla Ruby, look at a combination of monday? and cweek, which tells you the week number in the current year. Run your job on Mondays in even-numbered weeks.
date = Date.today
date.monday? && date.cweek.even?
Note that cweek can return 53, since 365 isn't divisible by 7 and it has to handle that last, partial week. The new year's first week will be 1 (it doesn't count from 0), so you have to either skip a week or do two runs in a row when Monday falls in week 53.

How to get user hour of the week in Ruby

I want to get the current hour of the week in which day starts from Sunday.
Consider current time is
Time.now
=> 2014-10-29 12:09:23PM +0530
The result should be : 84
Explanation:
Sunday - 24 hours
Monday - 24 hours
Tuesday - 24hours
Wednesday - 12 hours
Total: 84
How can get the user hour of the week. Is there any method available in Ruby ? Or how to do it without Ruby method.
You can get the day of the week and hour of the day using Time#wday and Time#hour.
Time.now.wday
#=> 3
Time.now.hour
#=> 14
The rest is basic mathematics.
Even though I upvoted Yu Hao, I must say it's not a good approach if you want to pay attention to the concerns Jon Skeet raised. To that end, here's another approach:
(Time.now - (Date.today - Date.today.wday).to_time) / 3600
Date.today is, well, today. If you subtract the number of days since the week started, you get Sunday. Convert it to Time and it's the midnight when Sunday began. Subtraction gives you number of seconds between then and now. Divide by 3600 (and optionally round) to get number of hours. The DST details should be transparently handled by Time#-.
EDIT: Timezones... Run this before:
ENV['TZ']='EST5EDT'
(be sure to reset it back to what it used to be afterwards, in case anyone else needs to know time and didn't count on you switching timezones.) You can also use "America/New_York" instead. See tz list for details.

Resources