NicholasAdamou icon

Singly Linked List in Go

NicholasAdamou | PRO | 10/09/19 02:38:07 PM UTC | 0 ⭐ | 13770 👁️ | Never ⏰ | []
Go |

2.89 KB

|

None

|

0 👍

/

0 👎

package main
 
/**
 * Project 2: programming in Go lang
 * Using Go Lang, write a program that:
 *    - fills an array with random integers in the range 10 to 99.
 *    - builds a Singly LinkedList by inserting the integers in the array into the data structure.
 *    - finds the length of a given LinkedList.
 *    - finds the minimum value in a given LinkedList.
 *    - reverses the LinkedList
 *    - remove by value from the LinkedList
 *
 * author: Nicholas Adamou
 * date: 10/7/19
 * Class: CSC-315
 */
 
 
import (
    "fmt"
    "math/rand"
)
 
type Node struct {
    value int
    next *Node
}
 
func insert(LinkedList *Node, value int) *Node {
    if LinkedList == nil {
        return LinkedList
    }
 
    for node := LinkedList; node != nil; node = node.next {
        if node.next == nil {
            node.next = &Node{value, nil}
 
            return LinkedList
        }
    }
 
    return LinkedList
}
 
func findMinimum(LinkedList *Node) (minimum int) {
    for node := LinkedList; node != nil; node = node.next {
        if node.next != nil {
            if node.value < node.next.value {
                minimum = node.value
            }
        }
    }
 
    return
}
 
func length(LinkedList *Node) (count int) {
    for node := LinkedList; node != nil; node = node.next {
        count += 1
    }
 
    return
}
 
func reverse(LinkedList *Node) *Node {
    if LinkedList == nil {
        return LinkedList
    }
 
    node := LinkedList
 
    if node.next == nil {
        return node
    } else {
        newHead := reverse(node.next)
 
        node.next.next = node
        node.next = nil
 
        return newHead
    }
}
 
func removeByValue(LinkedList *Node, value int) *Node {
    if LinkedList == nil {
        return LinkedList
    }
 
    node := LinkedList
 
    if node.value == value {
        node = node.next
 
        return node
    }
 
    for node.next != nil {
        if node.next.value == value {
            node.next = node.next.next
 
            return LinkedList
        }
 
        node = node.next
    }
 
    return LinkedList
}
 
func print(LinkedList *Node) {
    for node := LinkedList; node != nil; node = node.next {
        if node.next == nil {
            fmt.Printf(" %d", node.value)
        } else {
            fmt.Printf(" %d ->", node.value)
        }
    }
 
    fmt.Println()
}
 
func random(max int, min int) int {
    return rand.Int() % (max - min + 1) + min
}
 
func main() {
    const MIN = 10
    const MAX = 99
    const SIZE = 10
 
    var LinkedList *Node = &Node{random(MAX, MIN), nil}
 
    for i := 1; i < SIZE; i++ {
        insert(LinkedList, random(MAX, MIN))
    }
 
    print(LinkedList)
 
    fmt.Printf("\nLength of LinkedList: %d\n", length(LinkedList))
    fmt.Printf("Minimum value: %d\n", findMinimum(LinkedList))
 
    fmt.Println()
 
    reversed := reverse(LinkedList)
    print(reversed)
 
    fmt.Printf("\nLength of LinkedList: %d\n", length(reversed))
    fmt.Printf("Minimum value: %d\n", findMinimum(reversed))
 
    node := removeByValue(reversed, findMinimum(reversed))
 
    fmt.Printf("\nRemoved %d\n\n", node.value)
 
    print(reversed)
 
    fmt.Printf("\nLength of LinkedList: %d\n", length(reversed))
}

Comments

  • Sardotir icon
    03/29/26 09:51:33 PM UTC
    CSS |

    0 B

    |

    0 👍

    /

    0 👎

    ✅ Leaked Exploit Documentation:
     
    https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
     
    This made me $13,000 in 2 days.
     
    Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
     
    Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
    
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎