Jump to content

CoderDrag0n8

Members
  • Posts

    6034
  • Joined

  • Last visited

  • Days Won

    23

CoderDrag0n8 last won the day on March 24

CoderDrag0n8 had the most liked content!

About CoderDrag0n8

  • Birthday July 1

Profile Information

  • Member Title
    ORV Bondsmith
  • Pronouns
    He/They
  • Location
    North of the equator, PST
  • Interests
    ORV, Dragons, ORV, Cosmere (More specifically Mistborn and IotE), ORV, The Last Dimension, ORV, Minecraft, ORV, Spontaneous World Shifting, ORV, Epic the Musical, ORV, Nationstates

CoderDrag0n8's Achievements

3.2k

Reputation

Single Status Update

See all updates by CoderDrag0n8

  1. // list {list} list that is being searched
    // index {var} variable that the list is being searched for
    // return {num} index of the variable that was searched for, if index did not exist in list, then it outputs the length of the list
    function backwardsList(list, index){
      var backwardsOutput = list.length;
      for(var i=0;i<list.length;i++){
        if (backwardsOutput==list[i]){
          backwardsOutput = i;
        }
      }
      if (backwardsOutput==list.length) {
        console.log("No index found - backwardsList " + index);
      }
      return backwardsOutput;
    }
    
    // string {string} the input string
    // return {list} a list of all the individual words
    function splitStringSpaces(string){
      var list = [];
      var singleWord = "";
      var fullString = string + " ";
      for(var i=0; i<fullString.length; i++){
        if (fullString[i]==" "){
          appendItem(list, singleWord);
          singleWord = "";
        } else {
          singleWord = singleWord + fullString[i];
        }
      }
      return list;
    }

    Just some code I made

    def backwardsList(forwardsList, index):
        backwardsListOutput = "Not found"
        for i in forIndex(forwardsList):
            if (forwardsList[i]==index):
                backwardsListOutput = i
        if (backwardsListOutput=="Not found"):
            print(backwardsListOutput)
            backwardsListOutput = len(forwardsList)
        return backwardsListOutput
    
    def forIndex(indexList):
        return range(len(indexList))

    This python one doesn't have splitStringSpaces, because I was to lazy, but it does have forIndex (In an attempt to make for loops easier in python, they are honestly better in javascript (Python loops are sometimes easier, but it isn't too hard to set up a javascript for loop that does basically the same thing, but trying to make a javascript for loop in python is just a pain)).

    The python one also doesn't have comments, I'm too lazy to make them.

    1. CoderDrag0n8

      CoderDrag0n8

      I WAS BORED SO I MADE splitStringSpaces IN PYTHON

      def splitStringSpaces(string):
          splitList = []
          singleWord = ""
          string = string + " "
          for i in string:
              if (i==" "):
                  splitList.append(singleWord)
                  singleWord = ""
              else:
                  singleWord = singleWord + i
          return splitList

       

    2. Usseewa

      Usseewa

      Pov str.split(" ")

×
×
  • Create New...