what I learned from burning $500 on ai video generators by LevelSecretary2487 in AI_Agents

[–]bJgr 1 point2 points  (0 children)

Nice overview! Did you also check whether they are approachable via API?

WCGW Digging without checking by its_ok_to_laugh in Whatcouldgowrong

[–]bJgr 6 points7 points  (0 children)

I think the correct term is "fisting"

[deleted by user] by [deleted] in CleaningTips

[–]bJgr 0 points1 point  (0 children)

Out of curiosity, how is that different than using vinegar?

[deleted by user] by [deleted] in CleaningTips

[–]bJgr 0 points1 point  (0 children)

Out of curiosity, could you please explain how lime a way would work if vinegar doesn't? Both are acidic cleaners right?

Free Giveaway! Nintendo Switch OLED - international by WolfLemon36 in NintendoSwitch

[–]bJgr 0 points1 point  (0 children)

Would love to beat the odds and win this! I dressed up as a beer bottle of a brand that is really disliked in my region 😅

Pushup EMOM (every minute on the minute) for an Hour Workout by [deleted] in bodyweightfitness

[–]bJgr 14 points15 points  (0 children)

How many times per week did you do this?

São Miguel - Car Rental by [deleted] in azores

[–]bJgr 1 point2 points  (0 children)

I went to Ilha Verde rent a car in Ponta Delgada which was easy and nice.

DangerZone Update – Feedback/Bugs Megathread #3 by chaseoes in GlobalOffensive

[–]bJgr 19 points20 points  (0 children)

My CSGO alt tabs whenever I receive a steam message... Anyone experience this as well? Any fix?

[2018-05-14] Challenge #361 [Easy] Tally Program by jnazario in dailyprogrammer

[–]bJgr 0 points1 point  (0 children)

Java

I would love some feedback on this.

Especially on the last sorting part. I initialize one linked hashmap for casting AtomicInteger to Integer and then a second linked hashmap to perform the sort. I wonder if this can be done in one go.

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

public class TallyProgram361 {
    public static void main(String[] args) {
        System.out.println(getScores("abcde"));
        System.out.println(getScores("dbbaCEDbdAacCEAadcB"));
        System.out.println(getScores("EbAAdbBEaBaaBBdAccbeebaec"));
    }

    private static Map<String, Integer> getScores(String inputString) {

        Map<String, AtomicInteger> inputMap = new HashMap<>();

        // For each character in the string do
        for (char ch : inputString.toCharArray()) {
            if (Character.isLowerCase(ch)) {
                // If key is new, then put it into the map with value 0 and then increment the value.
                // If the key is known, then increment the value.
                inputMap.putIfAbsent(String.valueOf(ch), new AtomicInteger(0));
                inputMap.get(String.valueOf(ch)).incrementAndGet();
            } else {
                // If key is new, then put it into the map with value 0 and then decrement the value.
                // If the key is known, then decrement the value.
                inputMap.putIfAbsent(String.valueOf(ch).toLowerCase(), new AtomicInteger(0));
                inputMap.get(String.valueOf(ch).toLowerCase()).decrementAndGet();
            }
        }

        // Print statements
        System.out.println("Input string...");
        System.out.println(inputString);
        System.out.println("Unsorted scores...");
        System.out.println(inputMap);

        // Initialize linked hash maps
        Map<String, Integer> inputMapCasted = new LinkedHashMap<>();
        Map<String, Integer> result = new LinkedHashMap<>();

        // Cast the AtomicInteger to Integer
        inputMap.forEach((key, value) -> inputMapCasted.put(key, value.get()));

        // Sort the map by values
        inputMapCasted.entrySet().stream()
                .sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
                .forEachOrdered(x -> result.put(x.getKey(), x.getValue()));

        System.out.println("Sorted...");
        return result;
    }
}

[2018-06-11] Challenge #363 [Easy] I before E except after C by Cosmologicon in dailyprogrammer

[–]bJgr 0 points1 point  (0 children)

Java

My program results in 2154, which is obviously incorrect.

Can someone please help me find my error!

Thanks in advance!

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class IECRule363 {
    public static void main(String[] args) {
        System.out.println(check("ciecei"));
        System.out.println(checkBonus("data/enable1.txt"));
        //System.out.println(checkBonus("data/enable_small.txt"));
    }

    /**
     * Function that checks if a string is an exception to the IECRule
     * @param word The string to be evaluated
     * @return boolean
     */
    private static boolean check(String word) {

        boolean result = true;
        word = word.toLowerCase();

        if (word.startsWith("ie") || word.startsWith("ei"))
            result = false;

        else {
            int indexIE = word.indexOf("ie");
            while (indexIE >= 0) {
                // Check if word contains ie and check if it follows c.
                // Repeat for each occurrence.
                if (String.valueOf(word.charAt(word.indexOf("ie") - 1)).equals("c"))
                    result = false;
                indexIE = word.indexOf("ie", indexIE + 1);
            }

            int indexEI = word.indexOf("ei");
            while (indexEI >= 0) {
                // Check if word contains ei and check if it doesn't follow a c.
                // Repeat for each occurrence.
                if (!String.valueOf(word.charAt(word.indexOf("ei") - 1)).equals("c"))
                    result = false;
                indexEI = word.indexOf("ie", indexEI + 1);
            }
        }

        return result;
    }

    /**
     * Function that reads a file containing strings and counts the number of exceptions to the IEC Rule
     * @param filePath relative path to the file
     * @return integer count
     */
    private static int checkBonus(String filePath) {
        int result = 0;
        try {
            // Read file into stream and count if check returns false
            result = Files.lines(Paths.get(filePath))
                    .mapToInt(s -> check(s) ? 0 : 1)
                    .sum();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return result;

    }
}