OK let’s try something else first.
Can you make a loop which just prints out the 4 suits?
OK let’s try something else first.
Can you make a loop which just prints out the 4 suits?
Reminder to do some writing on most days and share something at least every 2 weeks.
Like this?:
0.upto(4) do |i|
puts "S"
puts "H"
puts "C"
puts "D"
end
I forget if I shared for last month: I did 23 out of 31 days in December. I’ve journaled and done around ~15 minutes of writing every day so far in January. I will share something soon.
each time it goes through the loop, it should print one suit, until all 4 are printed.
suits = ["S","H","C","D"]
0.upto(4) do |n|
puts suits[n]
end
When trying to look up stuff I keep going to this guys videos on ruby:
He has a ruby playlist:
I’m thinking of going through the videos in between my answers and sharing my notes and thoughts on the stuff. Sound fine?
Some writing:
I’ve thought about this before but I don’t know if I’ve shared it here before.
I think companies are a bit misguided when it comes to offering better benefits or pay to increase employee satisfaction. From my experience I think people would rather have a better working environment in a trade off for less pay. They would never openly say that and I don’t think anyone would admit it (hmm. admits a strong word. idk.), but I think they would be happier with less pay. I say this because after talking to friends with other jobs (and family) and looking at Starbucks own benefits policy. I do think Starbucks is quite a generous employer for the level of work I’m doing. Free college, lots of leave opportunities for issues in someones life, sick time, vacation time, abortion help (I forget details but if you can’t legally abort in your area they will help pay you for to travel somewhere for an abortion, idk if they help pay for the abortion too), etc. Starbucks is quite generous with its benefits and they keep expanding it. Yet people want more. Starbucks are unionizing because they believe they aren’t getting what they deserve. I don’t know how to comment on the economics of the issue but I think most of those workers think that because for most Starbucks it sucks working there. I think the thought process goes: working is shit, so I deserve enough pay until working no longer feels like shit.
Yeah I think thats a good way of putting it: people think with enough money, a crappy working situation can be made tolerable. I disagree. As an example: doctors. Doctors, generally, make six figures. Thats the kind of money a lot of people say they would do anything for. I’ve seen jokes online where people will see a clearly bad job that pays well and they say stuff like, “for that kind of pay you’ll see me there 4 hours early, worshipping the boss”. Yet the doctors who are making that kind of money are burning out at a high number. An article: https://www.ama-assn.org/practice-management/physician-health/measuring-and-addressing-physician-burnout . I haven’t looked through the article fully but one of the headlines read “Physician burnout rates drop below 50% for first time in 4 years”. So for the past four years, people making six figures have been burning out at a rate higher than 50%. Thats bad.
Now I do think people who really need the money can tolerate bad working conditions. However, I think for people who are in ok financial situations/perceive themselves in an ok situation (even if they are not) can’t be made to tolerate a job with better pay. They don’t necessarily need the money, so more money doesn’t make their crappy day-to-day tolerable. I think Starbucks and other companies would be better off treating their workers better and making the day to day job much better in order to keep happy employees.
yes
That works (although you looped 5 times not 4). There are nicer ways to do it. One of the most common loops in Ruby loops through an array. Can you find that in the array documentation?
I haven’t tried it myself but I’ve heard a couple positive things about The Odin Project, so FYI:
There also exist books like:
(Long ago, I used a much older version of that book. It was fine. Nothing exceptional, but totally decent.)
People admit this on programming forums like https://www.reddit.com/r/cscareerquestions/
People will ask which job to take between multiple options and be told that remote work (and some other things, such as getting away from an awful manager) is worth it for less pay. These are jobs where the lower paying option still pays well, so it’s an easier tradeoff to accept.
One of the reasons employers don’t try to offer a better working environment instead of less pay is that they don’t know how to reliably offer reasonable managers, coworkers and company policies. They’re bad at that.
My first guess is that’s because they want more cash pay because a few specific things are now way too expensive in the US, particularly rent or buying a house.
I suspect that rent and house prices (and a few other things) feel really bad to them even though they have a job, and that feels unfair and makes their life hard. Even if work was nicer, they’d still have big problems with their finances.
Working conditions in the medical system can be pretty bad yeah, but I think it may often be better for doctors than working for Amazon for much lower pay… And people do manage to have all kinds of problems even if they have plenty of money for housing, but I do think that overall the people struggling to pay rent despite working a job are significantly more sympathetic than the people making $100k+.
This?:
suits = ["S","C","D","H"]
suits.each do |a| puts a
end
yes
so with one loop for the suits, and one for the numbers, can you use both to make all the cards?
Thats true. I’ve started thinking, partially inspired by your Capitalism Means Policing Big Companies · Elliot Temple essay, that its also kind of impossible for a big company to be good all the time. Their just aren’t enough good people you can reasonably find and hire at such a massive scale.
I think thats partially true. I do think peoples money issues play a big part in it. All I can go off of is anecdotal stuff. To me it just seems like the same coworkers who have money issues but are ok with their jobs (usually at the slower Starbucks with a chill manager) don’t really hate their jobs and don’t get frustrated at Starbucks for not paying them more. They would like more pay because it would help them more and because they feel Starbucks can afford to pay them more (maybe they can. maybe they can’t idk).
Mmm. Yeah I do think overall it probably is better for doctors working in the medical industry then at Amazon or something. I do think the people struggling to pay rent are more sympathetic. My point with the doctors was just to show that their are people who make a lot of money who are quitting at record rates due to the working conditions. I think most people would say they could handle the working environment of medicine for that pay. I think thats true until someone feels like their finances feel better sorted out.
I do think more people would quit Amazon then medicine if they could afford to.
Do you see how the each
loop is better? It’s a little shorter and more importantly you don’t have to deal with managing numbers. Unless you actually need loop numbers and math for some reason, it’s better to avoid them, because they’re a source of potential bugs and extra complexity. (btw there is an each_with_index
version of each
that provides loop numbers)
I did it with 52 cards in mind. I forgot that we switched to focusing on just the 32(?) cards or so. Here:
cards = Array.new
suits = ["S","C","D","H"]
letters = ["A","T","J","Q","K"]
suits.each do |a|
2.upto(9) do |n|
cards << "#{n}#{a}"
end
letters.each do |l|
cards << "#{l}#{a}"
end
end
I think so? I do see how using numbers when I don’t need to is adding complexity. I did like how I could go through a set of values in an array instead of having to do stuff like converting from numbers to strings.
Great.
FYI, here is a way you could get all the card ranks into one array instead of using two separate loops:
ranks = ["A"] + (2..9).to_a + ["T","J","Q","K"]
So next, shuffle the deck and deal 5 cards, then print out your hand of 5 cards on one line.
For January I wrote 29 out of 31 days.
I have a journal entry for every day of January but for some of those days I journaled after the day (or even a few days later).
A common theme I noticed from looking at some random journal entires was getting up late and taking long to start my day. I would wake up what I felt like was kind of late. Feel “off” as I was getting up late (though even when I’m not getting up late, I feel off if I just “naturally” wake up) and take a while to start doing stuff even though I am more rested.
Actually is this normal? Specifically, feeling “off” when sleeping in? I don’t know how to describe it but if I sleep in even a little bit it is harder for me to follow up with certain goals and stuff. For example, I’ve been trying to eat at home more and out less. However, if I sleep in and start getting ready the temptation to just order food is much harder to control. On the other hand, if I force myself up on an alarm. While I may be tired, I find it easier to follow through with stuff.
Hmm. Maybe having a consistent sleep routine would help? Probably. Just some thoughts.
Oh yeah. Some notes I took yesterday and today from Giraffe Academy:
video 6:
video 6 was on variables:
puts "some string" + a_variable_that_contains_a_string
for example:
character_name = "Luffy" character_age = "20" puts character_name + " is " + character_age
In the video he mentions to do the above with puts I need to do it with parentheses. It seems to work without. Is that an old thing for Ruby?
video 7:
video 7 was on data types:
This fine?:
cards = Array.new
hand = Array.new
deck = Array.new
suits = ["S","C","D","H"]
letters = ["A","T","J","Q","K"]
suits.each do |a|
2.upto(9) do |n|
cards << "#{n}#{a}"
end
letters.each do |l|
cards << "#{l}#{a}"
end
end
deck = cards.shuffle
hand << deck[0..4]
deck.slice!(0..4)
print hand
Hmm. The array doesn’t look as nice. I’m also unsure if I should’ve made the hand an array.
Oh yeah. I started using RubyMine. Giraffe academy recommended to use an IDE. I googled some and saw that recommended quite a bit. I get it for free due to my college email and it seemed neat. Is that fine?
What’s the return value for this?
Yes but I don’t think one should be too reliant on it.
It’s fine to use the IDE to do something you don’t fully understand, just like you might copy/paste some code and get it working while only understanding parts of it. But you should pay some attention to what things keep coming up repeatedly and learn how they work at some point, not keep using them without understanding indefinitely. This generally isn’t a big concern for beginners but becomes a larger concern as you try to advance further.