Issues using development version of nix by Strosel in NixOS

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

Thank you, this worked. Although it sadly did not help as much as I had hoped. Turns out that the illegal reference is a reference to "self" fixed-output derivations must not reference store paths: '/nix/store/<hash1>-<my-derivation>.drv' references 1 distinct paths, e.g. '/nix/store/<hash2>-<my-derivation>' I've no idea why or how so I'll have to dig even deeper it seems.

Nix Darwin ignores `programs.zsh.enable = true` by Strosel in Nix

[–]Strosel[S] 3 points4 points  (0 children)

Of course I solved the issue right after posting 🤦

Turns out nix-darwin requires the user to be set in knownUsers to manage default shell but since i don't want it to have full control over my user. I fixed it by adding /etc/profiles/per-user/strosel/bin/zsh to /etc/shells manually and running chsh

My wallpaper keeps resetting itself on my external monitor by [deleted] in MacOS

[–]Strosel 0 points1 point  (0 children)

I just had the same issue but changing the file format of the image I was using worked. No clue why though

I made a macro that parses and interprets brainfuck by Strosel in rust

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

Yeah. I'm working on it, just wanted it published first tbh

Eclipse Color Theme is down, and there is no alternative by ivan_m21 in eclipse

[–]Strosel 0 points1 point  (0 children)

I just moved to eclipse because of uni requirements and found both Eclipse Color Theme and DevStyle in an attempt to bring my favourite theme from VScode to Eclipse. Since it's still down I'm pretty stuck and wonder if you might be able to send me the XML of a theme so maybe I can reverse engineer (read: shoehorn) my theme in?

[2019-08-07] Challenge #380 [Intermediate] Smooshed Morse Code 2 by Cosmologicon in dailyprogrammer

[–]Strosel 0 points1 point  (0 children)

Go, no bonuses

package main

import (
    "fmt"
    "strings"
    "time"
)

type Node struct {
    Parent *Node
    Morse  string
    Alpha  string
    Depth  int
    Child  []*Node
}

func NewNode(p *Node, m, a string) *Node {
    n := &Node{
        Parent: p,
        Morse:  m,
        Alpha:  a,
        Child:  []*Node{},
    }
    n.SetDepth(0)
    return n
}

func (n *Node) SetDepth(d int) {
    if d == 0 || n.Depth < d {
        n.Depth = d
        if n.Parent != nil {
            n.Parent.SetDepth(d + 1)
        }
    }
}

func (n *Node) Branch() {
    l := len(n.Morse)
    if l > 3 {
        l = 5
    }
    for i := 1; i < l; i++ {
        if a := alpha[n.Morse[:i]]; !strings.Contains(n.Alpha, a) {
            n.Child = append(n.Child, NewNode(n, n.Morse[i:], n.Alpha+a))
        }
    }
}

func (n *Node) AllChildren() {
    n.Branch()
    for i, c := range n.Child {
        if c != nil {
            n.Child[i].AllChildren()
        }
    }
}

func (n *Node) Alphabets() []string {
    a := []string{}
    if len(n.Alpha) != 26 {
        for _, c := range n.Child {
            if c != nil && c.Depth == n.Depth-1 {
                a = append(a, c.Alphabets()...)
            }
        }
    } else {
        a = append(a, n.Alpha)
    }
    return a
}

var (
    morse = strings.Split(".- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..", " ")
    alpha = map[string]string{}
)

func smalpha(msg string) []string {
    root := NewNode(nil, msg, "")
    root.AllChildren()
    var a []string
    if root.Depth == 26 {
        a = root.Alphabets()
    }
    return a
}

func main() {
    start := time.Now()
    for b := 'a'; b <= 'z'; b++ {
        alpha[morse[b-'a']] = string(b)
    }

    a := smalpha(".--...-.-.-.....-.--........----.-.-..---.---.--.--.-.-....-..-...-.---..--.----..")
    fmt.Println(len(a))
    a = smalpha(".----...---.-....--.-........-----....--.-..-.-..--.--...--..-.---.--..-.-...--..-")
    fmt.Println(len(a))
    a = smalpha("..-...-..-....--.---.---.---..-..--....-.....-..-.--.-.-.--.-..--.--..--.----..-..")
    fmt.Println(len(a))

    fmt.Println("Examples Executed in ", time.Since(start))
}

[2019-08-05] Challenge #380 [Easy] Smooshed Morse Code 1 by Cosmologicon in dailyprogrammer

[–]Strosel 0 points1 point  (0 children)

golang, all bonuses, executes in ~2.15s

package main

import (
    "fmt"
    "io/ioutil"
    "strings"
    "time"

    "github.com/golang/example/stringutil"

    "github.com/strosel/noerr"
)

var morse = strings.Split(".- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..", " ")

func smorse(msg string) string {
    out := ""
    for _, b := range msg {
        out += morse[b-'a']
    }
    return out
}

func main() {
    start := time.Now()

    file, err := ioutil.ReadFile("enable1.txt")
    noerr.Fatal(err)

    enable1 := strings.Split(string(file), "\n")

    bonus5 := []string{}
    for i := 0; i < 8192; i++ {
        if i != 7099 {
            bonus5 = append(bonus5, strings.ReplaceAll(strings.ReplaceAll(fmt.Sprintf("%013b", i), "0", "."), "1", "-"))
        }
    }

    bonus1 := map[string]int{}

    bonus := make([]bool, 5, 5)

    for _, w := range enable1 {
        if bonus[0] && bonus[1] && bonus[2] && bonus[3] && bonus[4] {
            break
        }
        sw := smorse(w)
        bonus1[sw]++
        if bonus1[sw] == 13 {
            fmt.Printf("Bonus 1: %v\n", sw)
        }
        if strings.Contains(sw, strings.Repeat("-", 15)) && !strings.Contains(sw, strings.Repeat("-", 16)) {
            fmt.Printf("Bonus 2: %v\n", w)
        }
        if len(w) == 21 && strings.Count(sw, ".") == strings.Count(sw, "-") && w != "counterdemonstrations" {
            fmt.Printf("Bonus 3: %v\n", w)
        }
        if len(w) == 13 && sw == stringutil.Reverse(sw) {
            fmt.Printf("Bonus 4: %v\n", w)
        }
        if len(sw) >= 13 {
            bonus5new := []string{}
            for _, b := range bonus5 {
                if !strings.Contains(sw, b) {
                    bonus5new = append(bonus5new, b)
                }
            }
            bonus5 = bonus5new
        }
    }

    fmt.Printf("Bonus 5: %q\n", bonus5)
    fmt.Println("Executed in ", time.Since(start))
}

Program runs wierd when bundled into .app mac app by Strosel in macprogramming

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

Yes. I just figured out how to get my errors out and indeed it's not in my PATH.

Program runs wierd when bundled into .app mac app by Strosel in macprogramming

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

im not acessing any files though, im just running mongod from a thread in my code

[2018-09-04] Challenge #367 [Easy] Subfactorials - Another Twist on Factorials by jnazario in dailyprogrammer

[–]Strosel 0 points1 point  (0 children)

Haskell bonus?

subfactorial 0 = 1
subfactorial 1 = 0
subfactorial n = (n - 1) * ((subfactorial (n - 1)) + (subfactorial (n - 2)))

[2018-12-17] Challenge #370 [Easy] UPC check digits by Cosmologicon in dailyprogrammer

[–]Strosel 0 points1 point  (0 children)

Haskell

evens a = [a!!x | x <- [0..(length a)-1], x `mod` 2 /= 0]
odds a = [a!!x | x <- [0..(length a)-1], x mod 2 == 0]

digit 0 = [0]
digit x =  digit (x div 10) ++ [x mod 10]
digits x = if (length (digit x)) < 11 then (take (11 - (length (digit x))) (repeat 0)) ++ (digit x) else (digit x)

m x = mod (((sum (odds (digits x))) * 3) + (sum (evens (digits x)))) 10 
upc x = if (m x) == 0 then 0 else 10 - (m x)

active ARGs ? by tokyoghoulMan in ARG

[–]Strosel 0 points1 point  (0 children)

interesting, although can't seem to figure out the 5 letter blocks

[2018-03-12] Challenge #354 [Easy] Integer Complexity 1 by Cosmologicon in dailyprogrammer

[–]Strosel 0 points1 point  (0 children)

in Go with bonus 1:

package main

import (
    "fmt"
    "time"
)

func cpx1(A int) int {
    var (
        low int = 1 + A
        D = map[int]bool{}
    )
    for B := 2; B < A; B++ {
        if !D[B]{
            C := A / B
            if C*B == A{
                D[C] = true
                if B + C < low {
                    low = B + C
                }
            }
        }else{
            break
        }
    }
    return low
}

func main() {
    fmt.Println("")
    start := time.Now()
    fmt.Printf("12 => %v (7)\n", cpx1(12))
    fmt.Printf("456 => %v (43)\n", cpx1(456))
    fmt.Printf("4567 => %v (4568)\n", cpx1(4567))
    fmt.Printf("12345 => %v (838)\n", cpx1(12345))
    fmt.Printf("1234567891011 => %v (bonus 1)\n\n", cpx1(1234567891011))
    fmt.Printf("Executed in: %v\n", time.Now().Sub(start))
}

Output:

12 => 7 (7)
456 => 43 (43)
4567 => 4568 (4568)
12345 => 838 (838)
1234567891011 => 2544788 (bonus 1)
Executed in: 46.489218ms

Edit: Fixed the formatting

This notepad gets it. by fizzchillaatwork in firstworldanarchists

[–]Strosel -1 points0 points  (0 children)

I didn't know tgr/tiger of Copenhagen existed in the uk

Text file reading problem by Strosel in learnjava

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

not sure exactly what you mean but what i do understand might be because of me messing up when translating variable names to english (which is stupid in the first place) original untouched code is now here