Java – String Permutation – Code Review Stack Exchange

My permutation function is listed below and I would like to make it more elegant and efficient if possible.

The function should return a string that contains all permutations of the specified string (separated by commas).

private static String permutation(String prefix, String str) {
    int n = str.length();
    String toReturn = "";

    if (n == 0) {
        return prefix + ",";
    } else {
        for (int i = 0; i < n; i++) {
            toReturn +=  permutation(prefix + str.charAt(i), str.substring(0, i) + str.substring(i + 1, n));
    return toReturn;

Design pattern for Javascript modules – Software Engineering Stack Exchange

Partly for use in my own projects and partly for fun when I'm stuck at home, I try to create another "block" based editor.

So far I've used simple objects, starting with a global one window.myeditor Object, then different sub-objects to handle different things. For example I have window.myeditor.toolbar abstract functions for creating toolbars in each block. I also used it Object.create to expand my base window.myeditor.block Object to create different block types (paragraph / heading / etc.) and then create instances of these objects for each element on the page.

However, it gets a bit messy. I cannot use global variables in the objects because they are not instantiated again Object.create and so all my objects see exactly the same variables, not a big problem, but not ideal. I also create functions like _focus() in my main block object, which does some standard tasks and then calls focus() from the inside, a function that should be replaced by subordinate objects so that they can expand this functionality. I also find myself duplicating code (e.g. code to make it bold / italic) that I could probably centralize if I had a clearer way of "modularizing" logic.

Looking at how other projects work, the current favorite seems to be building on classes, most likely via modules, although I'm struggling to familiarize myself with a basic implementation, and I think I'm just screwing up the basic architecture.

For example, I currently have something in the following direction:

Editor Class / module with a global instance for the main editor (not that this is required, but I would ideally design it so that it does not depend on having a global instance for anything, so that multiple editor instances would actually be possible without being mutually exclusive bring to ). This instance contains an instance of BlockRegistry The various block types and a reference to their class are stored here. The editor also has a number of BlockContainer Instances that control a block section on the page. There is a basis Block Class for handling a single block of content to be expanded by plugin block types.

The BlockContainer Class must list all HTML sub-elements and create one SomeBlockTypeThatExtendsBlock Instance for them, with the right handler, but to do this, they need to access them BlockRegistry Instance to see if it's a supported block type and the right class.

I can imagine that I get this problem with different class instances that regularly need access to functions of other instances, but I'm not sure which method is right here, except to constantly access the global instance within modules and pass references everywhere. or just put a code in one place that may have to point to something else.

I think I just miss something obvious and I screw up the basic design.

Post Exchange – Forum Authority | Forum promotion


Hello guys, I am actively exchanging posts with forums or blogs. Depending on your niche, it may take more than 24 hours to complete. However, I strive to complete all exchanges within 48 hours.

Below are 3 headings. As soon as an exchange has been agreed, your name will be entered Exchange in progress Section. If I have finished my page but am still waiting for your, your name will be entered Waiting for an exchange Once both sides are complete, your name will appear in Exchange completed

If you would like to exchange information with my forum, you can leave a comment below stating how many posts your forum link contains.

My forum:

Completed exchange:

@zoldos – 16/16
@ Frosty the Snowman – 20/20
@tunescool – 10/10
@ kingcool52 – 15/15
@ Jolly Drawers – 7/7

Exchange in progress:


Waiting for an exchange:

Just look at the wallet help – Bitcoin Stack Exchange

I only send this to a wallet. But that was wrong. What I can do to send it to the right wallet.

Bitcoin transactions are irreversible. You cannot cancel or reclaim them. Therefore, you cannot now redirect these bitcoins into the correct wallet.

Clock-only addresses are only controlled by those who know the corresponding private key.

If you know who owns the clock-only address private key, you can ask them to make a new payment equal to the amount you sent them. You have to rely on your charity.


C # – how can you conduct a controlled exchange in an online game?

This looks like a job for the expected value!

  • Take all the epic items in your game.

  • For each player, calculate their value and likelihood of being dropped / acquired by the player.

    This second can be a little difficult to calculate depending on the game system.

    • If you are equally likely to have all the elements or have a master drop table with probabilities for each element, this is easy.

    • If there are many different ways to get an item, depending on what the player is doing, you may need to estimate it using a "typical" or "optimizing" model player or a Monte Carlo simulation.

      If it is a game that is already live or in the game test, you can use telemetry data from real players to see how often an item appears in the played state, which often differs from what it is in a subtle or dramatic way we predicted on paper.

    However, as long as you get a decent approximation of relative frequency, this technique will produce useful results, even if they're not accurate to the last decimal point. πŸ˜‰

  • For every item multiply its value by its probabilityand summarize the sum of all epic items.

  • Divide by the likelihood of getting an epic at all.

What you just calculated is that expected value of an epic item. That said, if you played for a long time and received 1000 epic items, we would expect the total to be about 1000 times this representative average.

Now do the same for the legendary items you give out when you trade in.

Subtract ten times the expected value of an epic from the expected value of a legend. The number you have left is yours expected profit for trading.

  • If it is positive, even if some individual trades could result in a loss, players would expect on average to be as much profit per trade if they were repeated across many trades.

  • If it is negative, a rational player will expect to lose in trading and will likely avoid using this system.

Now you can adjust your values ​​and probabilities until the expected profit is in a range that is right for your target experience. Just think of the aversion to losses: players feel the sting of a bad trade more than the enthusiasm of a good one. Therefore, you often have to tilt the scale a little extra in favor of the player so that he feels "fair" or profitable.

Another fold to watch out for here: if the value of the legend you lent is unrelated to the value of the sacrificed epics, players will notice and only save the low value epics used to trade and spend their high quality epics elsewhere (provided there is an alternate use, such as selling to an NPC / shop or other player). This shifts the expected value of an epic that is traded so that it is lower than the expected value of an epic as a whole, increasing the expected profit for players who go this way.

You can either include this in your calculations and compensate for both a player who trades everything and a player who chooses only the duds to trade, or you can influence your legendary selection so that you prefer legends with low value select for low value victims and vice versa, so players find trading high quality epics worthwhile to better shoot high quality legends.

Affiliate Exchange with Arcade Addicts Forum promotion

Arcade Addicts is an arcade gaming forum where you can play free arcade games in real time. Play our weekly game challenges, save your favorite games, climb the leaderboard and enter our Hall of Fame.

I have an affiliate system at the bottom of my website. The images are resized to keep them as clean as possible.

If you have a chat or gaming website and want to work with Arcade Addicts, post your link. Thanks a lot.

Transactions – Generate P2SH-P2WPKH – Bitcoin Stack Exchange

I want to replicate the same scenario bitcoin-cli getnewaddress "" "p2sh-segwit"To achieve my goal, I follow this guide

My wife is:


then my compressed public key is:


Generate my redemption script. Precede 00 (OP_0) and create a key hash (ripemd160 (sha256 (public key)).


ScriptPubKey is ripemd160 (sha256 (redeem script))


And create my address (rain test)

C43f07def7d741bed449f76068422691c9cf2e2ec1 | xxd -p -r | base58 -c


Now I want to issue some Bitcoin from this address. It has 50 bitcoins
Create my transaction details

TX_DATA=$(bitcoin-cli createrawtransaction '({"txid":"'$TXID'","vout":'$VOUT'})' '({"'$ADDR_DEST'":'$AMOUNT'})')

and then create signrawtransactionwithkey

WITNESS_SCRIPT=6672614baf71a8d9e06e11e22562e8f16fad60fa (it's sha256 and ripemd160 of public key)

bitcoin-cli signrawtransactionwithkey $TX_DATA '("'$PK'")' '({"txid":"'$TXID'","vout":'$VOUT',"redeemScript":"'$REDEEMSCRIPT'","scriptPubKey":"'$SCRIPTPUBKEY'","witnessScript":"0014'$WITNESS_SCRIPT'","amount":"'$TOTAL_UTXO_AMOUNT'"})' 

I get this error:

  "hex": "0200000001ea237a61a6250e40a1461f1599e2a7b2c80e30ce6f3951ee0679d4d237ee431800000000171600146672614baf71a8d9e06e11e22562e8f16fad60faffffffff016036f8290100000017a914309a334914af79f24a5f10c9845d01e518c801488700000000",
  "complete": false,
  "errors": (
      "txid": "1843ee37d2d47906ee51396fce300ec8b2a7e299151f46a1400e25a6617a23ea",
      "vout": 0,
      "witness": (
      "scriptSig": "1600146672614baf71a8d9e06e11e22562e8f16fad60fa",
      "sequence": 4294967295,
      "error": "Witness program hash mismatch"

I don't understand what the witness program is, and I don't know why I'm getting this error.
When i use bitcoin-cli getnewaddress "" "p2sh-segwit" and create transaction, I can see this:
asm contain the sha256 and ripemd160 of public key and the field txinwitness with signature and public key.

Thanks a lot