Eternity Async Tutoring

I did this with a different array:

a = ["B","A","C","B","A"]

a.each do |n|
  if a[0] == n
    puts "Match"
  end
end

It should work with the card stuff. Issue I’m having is having the first card compare to itself. Is there a way to adjust when n would start from? Or should I do it a different way?

Oh yeah: I’ve been doing it this way for a while now. By this way I mean trying out simpler code elsewhere and then trying to fit into my cards project. Is that fine?

that’s good

You could:

use an upto loop or something else where you control the counter

slice the array to exclude the first one, then use each

use each_with_index and use next when the index is 0

Some stuff to share from some events I had today:

I’ve tried a few things to help my energy: having a consistent sleep schedule (I’ve done this successfully for some time periods, no long-term consistency), eating healthier, exercising, quitting caffeine, increasing my nutritional intake, quitting vaping, and trying out various supplements. While I think certain things have had some success I wonder how much of my health has been affected by mold.

We recently got our roof repaired and thought that those leaks, due to the damaged roof, were the cause of water damage in the house. Some were. Others were not. We’ve had a pipe leaking and doing crazy amounts of water damage. Apparently the plumbers said all the houses in my neighborhood were built with it. Its so bad that you are no longer allowed to build with the stuff since ~1980 smth.

Anywaeys just seeing how much mold we actually have was insane. My moms whole walk-in closet was covered in black mold. We had black mold go into our bathroom but my mom painted it. I don’t know why I never made the connection about how the mold affected me until I saw just the sheer volume of mold we have. I’ve changed moldy shower curtains before in the past and noticed myself feeling much better. I think because I’m so used to the mold surrounding my bathroom (and probably cause it feels so far) that I never thought it could affect me.

Luckily, after dealing with some lying by our insurance company and threatening to go to a lawyer and some other stuff they agreed to cover all the damage. Should be more-or-less mold free within a few weeks or so. I wonder if I’ll notice a difference?

For the Duolingo assignment you mentioned in Elliot's Microblogging - #253 by Elliot I went ahead and chose Japanese because I have been studying it for a while already. Just a few questions:

Would my prior knowledge be a problem for this kind of thing?

Roughly how I study Japanese daily so far is to:

  • Do writing lessons and reviews. Roughly write about 20 characters a day.
  • Grammar flashcards
  • Vocabulary flashcards (regular recall ones and type in the answers)
  • an episode of anime in Japanese

I bring those up because I wonder if those count as practice. I don’t mind adding 15 minutes of DuoLingo on top of that. From what I read the assignment wasn’t given as a requirement just a recommendation but I don’t mind doing it. Will I get benefits from doing it? I feel like the stuff duo had me do so far is similar to my reviews and stuff. Should I do a different language?

I think trying Duo is a good idea for you, but if it ends up too similar you could stop earlier than a month. Try another language for a couple days so you can compare to Duo Japanese.

1 Like

Watched two more giraffe academy video’s:

  • Methods | Ruby | Tutorial 15 - YouTube
    • A block of code that performs a specific task for us.
    • Use def tp define a method.
    • The code in a method is only executed when the method is called.
    • In the case of ruby: functions and methods are interchangeable.
    • The stuff in the parentheses in a method after the name is the parameters of the method.
    • Hmm. Parameter?
      • Google:
      • You can give parameters default values.
    • Return Statement | Ruby | Tutorial 16 - YouTube
      • Last lesson we looked at how we can give methods information through parameters. In this tutorial we will be looking at how methods can give us information back.
      • You can put “return” in your method to define what you want to have returned when calling on a function.
      • Even though the code isn’t “done” by putting return earlier on in the method ruby does not run the remaining code in a function after the return.
      • You can return multiple values.

Have twenty or so videos left. After I finish them I plan to go through the Ruby | The Odin Project you mentioned before.

yes parameters means inputs

not exactly. you can return an array that holds multiple values, but the array is itself a single value that’s returned. also ruby has some syntax shortcuts that can make it look more like returning multiple values.

1 Like

Hmm. So I just realized: do the parameters determine where the inputs go? By that I mean in:

def rank_to_number(rank)
  # J = 11, Q = 12, K = 13, A = 14. For now we'll ignore how A can sometimes be 1.
  rtn = {"A" => 14, "J"=> 11, "Q"=>12, "K"=>13,"T"=>10, "2"=>2, "3"=>3, "4"=>4, "5"=>5 , "6"=>6, "7"=>7, "8"=>8, "9"=>9}
  print rtn[rank]
end

I kept thinking that the "rank) in the parentheses referred to an array or something. To put it differently I thought what that string of words is mattered. I though “rank” had a coding reason to be named rank. The code could work just as well with “rank” being renamed as “lemon”. Right?

Also if I move around “rank” in the code it will put in that input at that spot. I guess thats obvious but I was bit confused thinking that if I don’t put in a rank array or something in the rank spot it shouldn’t run.


I watched three giraffe academy videos. The last one was a simple calculator he put together with puts, gets, and if statements. Nothing covered to note. Here’s my notes from the other two:

  • If Statements | Ruby | Tutorial 17 - YouTube
    • For an if statement that is dealing with boolean values (true or false) by default an if statement will look to see if the value/variable with a value is true. You can set it up to run while false but by default it has to run when true.
    • You can check for two boolean values (and maybe more?) by simply using the word “and”. Something along the lines “if true and true”
    • “or” if one of the values is true
    • ! = not
    • I assume this follows the truth table stuff I did before.
  • If Statements (con’t) | Ruby | Tutorial 18 - YouTube
    • if statements need conditions
    • you can use comparisons in ruby to get a true or false value
    • when comparisons are resolved the return value(?) is true or false

Ok. The video did mention that but I don’t know why I didn’t take it seriously when he said it returns an array.

Yes “lemon” would work. You’re just giving names to the input(s), similar to giving a name to the function.

you can check more values using more than one and.

yes

yes. for example:

3 > 2 # returns/outputs true (the # creates a comment for the rest of the line. comments are for people to read. the computer ignores them)

the > is just a function available to the Integer class. you can do 3.>(2) so it looks like other function calls

Came across this quote while doing reviews, from Why Does He Do That?:

The good news is that remorse is often genuine; the bad news is that it rarely helps.

Something I relate to. I often feel genuine remorse for some things I’ve done and I’ve mentioned before how I think that remorse is a substitute for dealing with the stuff I did.

Watched two giraffe academy video’s:

  • Case Expressions | Ruby | Tutorial 20 - YouTube
    • case expression is a special type of if statement
    • case expressions simplifies comparing the same value to a bunch of different values
  • While Loops | Ruby | Tutorial 21 - YouTube
    • While loops are for looping through a block of code a specific number of times
    • while loops need a condition
      • so long as the condition is true, while loops will keep running the code
    • if you have var = var + 1, you can do var += 1 instead.
    • infinite loops are, in general, very bad. apparently their are high level use cases for them though. neat.

That’s for loops.

You can get out of loops with break or return. Or a video game could have a main loop that just runs forever until you quit the game.

What’s happening to US lawyers FYI

1 Like

Hmm. That sucks. I’m kinda surprised to hear that corporate law firms are being affected. I wonder how far this stuff will spill.

I wonder if part of the reason for inaction is because, regardless of how bad things maybe are (I don’t know I haven’t been keeping up), companies are just used to pressure from the government.

Watched giraffe academy’s videos 22-24. Only took notes on video 23:

  • For Loops | Ruby | Tutorial 23 - YouTube
    • A for loop allows us to loop through a specific collection like an array.
    • for x in y
      • x refers to the variable, the variable name is for your user understanding, not for making the code run
        • However it is what defines the variable that your code interact with. If you did:
          • for number in array
          • puts number
        • every time the for loop is going through the code the variable part takes on a different value

So for getting pairs I came up with this with if statements:

a = ["D","A","C","C","A"]

1.upto(4) do |n|
  if
  a[0] = a[n]
    puts "Match"
  elsif
  a[1] = a[n+1]
    puts "Match"
  elsif
  a[2] = a[n+2]
    puts "Match"
  elsif
  a[3] = a[n+3]
  puts "Match"
  elsif
  a[4] = a[n+4]
    puts "Match"
  end

end

I do realize that this wouldn’t be efficient to scale up. Also, I’m having trouble with numbers getting used twice. Any advice?

Also I think you may be losing track of some other information you already have.

Eternity Async Tutoring - #794 by Elliot

def find_pair(hand)
# return rank (as 1-character string) of highest ranked pair in hand

You’re just printing match not saying what rank the pair is.

Anyway, I think breaking it down into simpler parts is the key. When stuff is hard, confusing, too complicated, etc., looking for ways to deal with sub-parts is generally the most important thing to try.

This seems to come up quote often and I don’t disagree with it. Do you have any assignments (besides obviously what we are working on right now) that I could to practice breaking something up into simpler parts?

Yes, Thats also why I started my project of posting consistently. I noticed I forget a lot of details due to some of the long breaks I take. My goal is to try and even work a little bit daily so I don’t forget stuff so often. I could, alternatively, also work on maybe noting some of the stuff better? So I have access to it more often?