A General Post About the More Math-ey Levels


#1

I’ve had a thought recently that I figured I should probably express, and see what the community’s opinion is. Many of the levels in CC have a “math-ey” theme, especially from the Mountain and on (I mean, the Progamaticon IV unlocks the math library, after all). This is great. A bunch of programming needs a good relationship with math. I am, however, finding a recurring theme in all of them: I’m lost. I can beat a good number of them, depending on how much help the player is given with their code, and sometimes I can hack at answer until I get it to work, but I usually can’t come up with an elegant answer on my own.

As I’m scrolling though a thread on the What In Carnation level, I get the feeling that some of the players who got stuck were simply trying to hack it out, as opposed to understanding the underlying math at work there. Like me.

These levels are all critical, and one of the reasons I’m on CC is to up my own skills on things like this. I guess what I’m asking myself boils down to this: is there a way for people like me who are struggling with the math-ey levels to get more help on them?

I think this is a thorny issue. Many players seem to be progressing in the Glacier without any extra help, and will be duly rewarded for their efforts by having all the more experience coding vectors and the like. They shouldn’t watch the difficulty level get dropped underneath them.

One thought I had is maybe to have an ‘extra help’ mode which costs gold (the out-of-level gold, like the kind heroes and equipment are bought with), which adds more comments and the like to the code, more similar to previous levels.

It’s hard for me to admit my difficulty with the math stuff out loud. (That’s probably why I’m still writing this gargantuan post.) I would like to know if anyone else is in the same boat as me, and if anyone has any thoughts on the matter.


#2

Knowing where to find resources that are useful to you and how much research you really need is key.


Example: from problem to research to algorithm development

I had been stuck on the level Prime Pathing, and I needed an efficient way to determine if large numbers are prime. So, I googled “prime number algorithm,” and the first result was a link to “Primality Test” on Wikipedia. I scanned through the page, and there was plenty of extra info I didn’t need. However, this paragraph caught my eye:

A good way to speed up these methods (and all the others mentioned below) is to pre-compute and store a list of all primes up to a certain bound, say all primes up to 200. (Such a list can be computed with the Sieve of Eratosthenes or by an algorithm that tests each incremental m against all known primes < √m). Then, before testing n for primality with a serious method, n can first be checked for divisibility by any prime from the list. If it is divisible by any of those numbers then it is composite, and any further tests can be skipped.

I kept reading and looking up everything until I understood enough to start coding the algorithm.
I settled with an algorithm using a Sieve of Eratosthenes to make a predefined list of primes that I can use to quickly check for primality among numbers.
I even read up a little bit on Fermat’s Primality Test, but I decided not to implement that because it seemed more complicated than what I decided to go with.
(I had no clue what a Sieve of Eratosthenes or a Fermat’s Primality Test was before I started doing this level)

The next step for me was just writing the algorithm in a way that I can understand:

# Sieve of Eratosthenes
# define a function that returns a list of all prime numbers up to a given limit:
    # make an empty list that will store composite numbers (dubbed composites)
    # make an empty list that will store prime numbers (dubbed primes)
    
    # for each number in the range of limit, going up by 1 on each iteration:
        # if this number is found in the composites list:
            # skip to the next number (continue)
        
        # else:
            # this number is prime, so add it to the primes list
            
            # then, for each multiple of this prime number:
                # add that multiple to the composites list if it's not there already
    
    # return the list of primes

# define a list of prime numbers using the Sieve of Eratosthenes which will be used for a faster primality test

# Primality Test
# define a function that tests if a given number is prime
# use a globally defined list of primes to test the given number against to increase efficiency
...

I would have used sets instead of lists, but sets aren’t implemented in CodeCombat.

Then, I changed that pseudocode into Python.

Summary
For complicated problems that I can’t think of a solution for off the top of my head:

  1. Most of my time is probably spent researching and understanding the problem;
  2. Then, a moderate amount of time is spent writing the pseudocode that I can easily understand and check the logic of;
  3. And, finally, the least of my time is spent writing the actual code.

(End of example)
A different approach


Looking for helpful posts in old threads

Using your “What In Carnation” example, I searched and found this thread (I’m not a subscriber, so I don’t have access to this level). In the thread, I see two kinds of replies:

  • The replies from people trying to “hack it out” are from people that don’t completely understand what the level is really asking for. You can scan through their posts, but there’s usually nothing useful to help you.

  • The other type of replies comes from people who know what’s going on in the code, who know what the level is about. These are the posts that you should read through if you need help.

Here’s a shining example of a post from that same thread that fits the second category of replies:


Posts like these are the ones you really want to prioritize to read first.


Yes, the gap in skill required going from Cloudrip Mountain to Kelvintaph Glacier is really big.

There’s more of an emphasis towards doing your own research during the levels of Kelvintaph Glacier.

I recommend you to learn what vectors are and what they are used for before you program with them, just to avoid any shortsighted mistakes. Personally, I didn’t even know what vectors were until I learned about them in my third semester of calculus! Vectors can be a surprisingly simple concept to grasp, but their usefulness really shines in physics and advanced calculus.

Parametric equations along with trigonometry can be useful to learn, primarily for those flower-drawing levels.

Not all programs are going to be math-y. Some problems focus more on logic. There are a few levels in Kelvintaph Glacier that are complex logic problems with minimal math, such as Gridmancer Redux.


Some math resources:

Use a search engine/Wikipedia if you need a quick reference for an algorithm, whether it is math or logic.
Use StackOverflow if you have a question about implementing something in code (be mindful that all code might not work in CodeCombat due to incomplete transpiler features).


If you want more math-y levels:

https://projecteuler.net/archives (You’ll probably want to program these outside of CodeCombat)


#3

@byobcello As usual, your posts are clear and informative. Thanks for the comprehensive reply. I think I still have a point, though, and I’m going to try to explain.

The thread you linked to was actually a lot of my inspiration for starting this topic. I had also broken down many of the posters into the two categories that you had. I believe that your answer about research and implementation works well for the second group (those who get it), but I at least find myself struggling with it.

I’m no stranger to research, but in my experience, for research to yield results, the researcher has to have a certain core understanding. I loved your example(a prime number algo), because I think that it demonstrates this pretty well.

You were able to scan a page on Wikipedia, and zone in on the information you needed. I would not have been able to do that. I would have been stuck trawling at a slow pace through many concepts I do not intuitively know, and then trying to sieve out (pun! shameless!) whatever I thought I didn’t need or couldn’t use. Sieve of Eratosthenes? Testing each incremental m against all known primes < √m? For me, at current, this is a language I don’t yet speak, though I certainly would like to. I feel like you’re talking about someone who can do as you say, namely scan available excellent resources and find what they need; I’m positing that there’s a sub-community of those who want to get there, but aren’t there yet. (And if there isn’t a whole sub-community, at least there’s me, and that’s gotta be worth something :wink:)

I think this has given me a better way of summarizing what I was trying to get at with the first post:

  1. Are there other members who are experiencing difficulty getting up to speed with the math levels, and don’t feel like they possess the skills to be self-sufficient?
  2. If so, are there any ideas about how to help, without it being to the detriment of those who don’t need it?

#4

There are links everywhere on Wikipedia; I just click on them and keep reading and re-reading to understand. It’s quite a web of knowledge.

Sure, Wikipedia definitions are usually hard to decipher, but there are plenty of other resources on the internet that probably explain Wikipedia definitions in simple terms. One alternative I use are programming blogs: they can often be an easy-to-understand resource, although quality, depth, and entertainment may vary.


To reach that level of core understanding to be self-sufficient, I guess it just takes a lot of reading, patience, and perhaps a mentor (which basically describes college for me).
In the case of math, there’s also practice, but I’d just categorize that within patience.
You can hack your way through problems using existing algorithms/solutions, but there are no shortcuts to understanding.


In general, it really depends on the problem. In my opinion, a good grasp on logic is more essential for practical programming.

In CodeCombat, because levels can be barred from access without completing the precursor level, having a basic understanding of certain math subjects may be necessary. (Although, a simple bypass to access the level is to go directly to the level’s url)


Everyone starts out lost whenever they start a new level. We get more familiar with the problem as we read the goals and guidelines. We find out what we need to learn. We start solving it.

If you ever find a level too intimidating, don’t quit. Take a break instead. Have determination. You can ask around for clarification or guidance whenever you want.


What do you mean by “without it being to the detriment of those who don’t need it?”


#5

@byobcello Great post!

If I extrapolate, I think what I’m looking for here is to see if CC has the scope to build in any kind of mentorship. I feel like the earlier levels did that well. What I meant at then end (the ‘detriment’ bit) was that I wouldn’t want the experience to be watered down for those who don’t need it, made easier than their learning curve. For all of those who are on CC’s curve, making it easier should cause them to learn slower.

Hmm… in the first post I pitched a ‘help mode’, but once you pointed out the idea of needing a mentor head-on, it makes me wonder if there might be some way to do some sort of pair programming, maybe in which the player that needs help (like me) can wager gold to get help… That sound a lot more complicated (it would need a communications interface, and probably a whole system for ranking and connecting, etc.), but I figured I’d just mention the idea in case anyone has thoughts or comments.