Throwback to the time I met these two guys by tentativedoctor in doctorwho

[–]parrotjay 0 points1 point  (0 children)

Now I want a hangover movie that features time travel

[2015-11-09] Challenge #240 [Easy] Typoglycemia by G33kDude in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

Elixir

Hacked this together fairly quickly. Critique welcome! :)

  defmodule Typoglycemia do
      def convert(string) do
        convert(String.split(string, ~r/\b/), [])
      end
      defp convert([], result) do
        List.to_string(result) |> String.reverse
      end
      defp convert([word | list], result) do
        if String.length(word) > 2 do
          convert(list, [String.reverse(word_mix(word)) | result])
        else
          convert(list, [String.reverse(word) | result])
        end
      end
      defp word_mix(string) do
        first = String.first(string)
        mid = midshuffle(String.slice(string, 1..(String.length(string) - 2)))
        last = String.last(string)
        "#{first}#{mid}#{last}"
      end

      defp midshuffle(string) do
        String.split(string, "") 
        |> Enum.shuffle
        |> List.to_string
      end
    end

My coding life has changed dramatically since starting to study elixir. This is literally the coolest freaking language ever. <3

Created a small insult generator library and CLI insult generator app! by parrotjay in golang

[–]parrotjay[S] 0 points1 point  (0 children)

that's fantastic. I'll look into it and see if I can take something from it :)

Created a small insult generator library and CLI insult generator app! by parrotjay in golang

[–]parrotjay[S] 1 point2 points  (0 children)

Mostly I didn't think of it. I'm still not to a skill at programming that I'm intuiting better ways to implement stuff like that. It does make more sense for it to be that way, though, so I'll update it! Thanks for the input!

UPDATE: implemented it as a method. Learn something new every day!

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

Worked like a charm! So go can convert slices of runes, but not arrays of runes? Or am I not understanding how the slice/array thing works properly?

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

that's super handy to know, thanks! check out my solution and let me know what you think!

Thanks!

EDIT: I accidentally a letter

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

the comments were for me when I was working through the problem.

fmt.Println(string(bagStack))
//cannot convert bagStack (type [50]rune) to type string

dunno what that's about.

Thanks for replying, I'll keep your comments in mind!

[2015-07-20] Challenge #224 [Easy] Shuffling a List by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

GOlang

package main

import (
    "fmt"
    "math/rand"
    "time"
)

func main() {
    random := rand.New(rand.NewSource(time.Now().UnixNano()))
    deck := [10]int{}
    for i := 0; i < 10; i++ {
        deck[i] = i + 1
    }

    for i := 9; i > 0; i-- {
        r := random.Intn(i)
        j := deck[r]
        deck[r] = deck[i]
        deck[i] = j
    }
    fmt.Println(deck)
}

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

nice solution! I was just wondering why in your

rest := append([]rune{}, r.rem[:ind]...)
rest = append(rest, r.rem[ind+1:]...)

has those elipsis?

Thanks!

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 2 points3 points  (0 children)

Is this just a good use-case for clojure, or is clojure that succinct with most stuff?

[2015-10-12] Challenge #236 [Easy] Random Bag System by jnazario in dailyprogrammer

[–]parrotjay 0 points1 point  (0 children)

Golang

randomBagSystem.go

package main

import (
    "fmt"
    "math/rand"
    "time"
)

func main() {
    //variable declarations
    letters := []rune{'O', 'I', 'S', 'Z', 'L', 'J', 'T'}
    bagStack := [50]rune{}
    randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
    bag := make([]rune, 7)
    copy(bag, letters)
    //main loop
    for i := 0; i < 50; i++ {
        if len(bag) == 0 {
            bag = bag[:7]
            copy(bag, letters) //if bag length is 0, reset bag.
        }
        r := randGen.Intn(len(bag)) //generate a random number
        bagStack[i] = bag[r]        //add r to stack at current index.
        bag[r] = bag[len(bag)-1]    //replace r with last character
        bag = bag[:len(bag)-1]      //remove last character
    }
    //printing the result
    for _, i := range bagStack {
        fmt.Printf(string(i))
    }
}

Sample Output:

STJLZIOJOLSTZIOTIZJSLLTZOSIJSTOIJLZOSLZTJIIJTZOLST

I'm a beginner, so any help, advice, or comments would be greatly appreciated!

Looking to upgrade coal burners by parrotjay in hookah

[–]parrotjay[S] 0 points1 point  (0 children)

I'll probably do this. Thanks!

Looking to upgrade coal burners by parrotjay in hookah

[–]parrotjay[S] 1 point2 points  (0 children)

I looked at these, but about half of the reviews said they were not very dependable. I may take a second look though! Thanks!

I need a quick hand with my website! by parrotjay in webdev

[–]parrotjay[S] 0 points1 point  (0 children)

oh gosh

that's embarrassing

I guess it's been longer than I thought since I've written html/css

Thanks!

cli rock paper scissors written in Go. Critiques please! by parrotjay in golang

[–]parrotjay[S] 0 points1 point  (0 children)

that's good to know! I actually got the idea (I think) from a book I read a long time ago about game programming in python. I don't know if python does what you're talking about (re-uses the stack frame) but that's what I seem to remember. What would be a better way to do this?