logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    Henry Zheng
    Jul 17
    Edited: Jul 20

    Summer 2022 - Class 9 7/16

    in Python for ACSL

    CLASS OUTLINE

    1. Homework review

    2. Leetcode - Linked list cycle (https://leetcode.com/problems/linked-list-cycle/)

    a. SOLUTION


    3. ACSL Solitaire


    Homework - Finish ACSL Solitaire

    Solution:


    1 comment
    0
    1 Comment
    ElijahG
    Jul 18

    Solitare Solution: (did this in a leetcode style problem)

    cards = input()
    class Solution:
    	def solitare(cards):
    		newlist = cards.split(", ")
    		ret = ""
    		newlist.pop(0)
    		for i in range(0, len(newlist)-1):
    			if newlist[len(newlist)-1][0] == newlist[len(newlist)-2][0] or newlist[len(newlist)-1][1] == newlist[len(newlist)-2][1]:
    				newlist.pop(0)
    		for i in range(0, len(newlist)-1):
    			ret += newlist[i] + ", "
    		ret += newlist[len(newlist)-1]
    		return ret
    
    print(Solution.solitare(cards))


    Like
    1 comments
    Similar Posts
    • Summer 2022 - Class 1 6/7
    • Summer 2022 - Class 7 6/28
    • Summer 2022 - Class 10 7/19

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2022 Legion of Learners