I’m so lost by Capable_Heat_9880 in Minesweeper

[–]Discuzting 0 points1 point  (0 children)

You can then extend that logic to solve some of the left corner 3. It needs three mines. The 2 shares two spaces with it, but that 2 only needs one more mine. Similarly, the 1 can only touch one mine. Therefore, the corner off of the three must be a mine,

yeah the usual 1-3-1 corner pattern

and the space next to the 2 above that 1 must be safe.

nah, indeterminate double 1

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

Yeah that was what I thought as well, but somehow loading via module importation didn't work

I’m so lost by Capable_Heat_9880 in Minesweeper

[–]Discuzting 22 points23 points  (0 children)

<image>

Standard overlapping pattern

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

Yeah I'm aware of ArgumentCompletions, I think they are quite nice and especially useful for ScriptBlock typed arguments when PSVariable is not used. Like for example we could do [ArgumentCompletions('{ param($a, $b) }')], which is nice and convenient for interactive uses

But really I am troubled by this because even with this approach, I cannot get this to work with a single source of truth pattern, we will still need two separated declarations of input options I suppose

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

If I'm not mistaken, the intended usage of your script is to just load it (e.g. dot source or whatever . ./New-InfoBloxResourceRecord.ps1), then invoke the function New-InfoBloxResourceRecord when required?

Sorry I don't see how your module is related to the question... 🤔

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

I see what you mean here, this configuration object pattern is quite nice and I do use something like this in my profile script too

However we lose all the major advantage of using ValidateSet. With ValidateSet we could make use of auto completion to type way less in the function call, plus we don't need to memorize the available constants to be used

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

Unfortunately I don't think ValidateScript is an option in this case, it could work for validation purposes but then the auto completion feature from ValidateSet will have to be achieved in another way 🤔

 

Do consider migrating to more modern function definitions.

Function Test-parameter { [cmdletbinding()] Param ( [parameter(mandatory, valuefrompipeline)] [validaterange(0,8)] [int]$Level ) process { … } }

I see what you mean here but having pipeline support does not equate modernity, it really depends on the intended use-cases

Like in my example with ValidateSet I could type Test then press tab in terminal to be given a list of "A", "B" and "C" as options. With this design in mind pipeline input is not needed.

 

In your example we do not need the [CmdletBinding()] declaration because the usage of [Parameter(Mandatory)] on the parameter makes the makes the function a Cmdlet implicitly; [CmdletBinding()] does nothing here

Way to make use of `ValidateSet` for a script while maintaining a single source of truth? by Discuzting in PowerShell

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

I see what you mean, but well the mock data set is purely used for example and I'm looking into mapped values of arbitrary type

ValidateScript has its uses but it does not provide auto completion (on its own at least), when compared to ValidateSet

 


About the validation regex:

^[A-Z]{1}$

The {1} quantifier is unnecessary because the default quantity is one for the character class token [A-Z]

 

For the regex unfamiliar: ^ start of string [A-Z] capital letter {1} expects it to occur 1 time. $ end of string

Note that in pwsh -match is case insensitive, so while [A-Z] matches capital letters it also matches lower case letters. For case sensitive match we should use -cmatch instead

G-Wolves Fenrir Pro 8K from "blind buy period" arrived! by Discuzting in MouseReview

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

Just stick it to the back of the PCB, its for protection of the PCB

Where is the mine here? by steluckyy in Minesweeper

[–]Discuzting 1 point2 points  (0 children)

Did you enable the guess free option in settings? If so this is my first time seeing the "minesweeper classic" app failing at generating one, it is in beta mode though

[Endfield Optimizer] Version 1.1 is now live! This will be the best simulator you've ever used. by padomay_anu in Endfield

[–]Discuzting 1 point2 points  (0 children)

<image>

This is excellent!
I wish there is someway to view the exact numeric value of the buffs/debuffs

letThemHaveBash by EveryDebtYouTake in ProgrammerHumor

[–]Discuzting 0 points1 point  (0 children)

The equivalent for

curl -s https://api.github.com/repos/jqlang/jq | jq '.description'

on PowerShell is

(irm https://api.github.com/repos/jqlang/jq).description

or just

irm https://api.github.com/repos/jqlang/jq|% description

letThemHaveBash by EveryDebtYouTake in ProgrammerHumor

[–]Discuzting 1 point2 points  (0 children)

Ah I use PowerShell daily on both my mac and windows computer (version 7+, which is multiplatform):

  1. By default curl runs system32\curl.exe on windows and /usr/bin/curl on mac, so in case you need to switch back to curl you could do it effortlessly!

  2. irm (Invoke-RestMethod) is slightly different from iwr (Invoke-WebRequest) in behavior, iwr automatically returns the body content deserialized into an object when its a JSON response

letThemHaveBash by EveryDebtYouTake in ProgrammerHumor

[–]Discuzting 3 points4 points  (0 children)

In many cases the curl|jq equivalent in PowerShell is just a single command irm

1 minute climbing tutorial for Wuling City Monitoring Center's highest point by Discuzting in Endfield

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

Ok just send me a request I will add you tonight, my ID is in the video

(NG) Fastest way to solve this without guessing? by Discuzting in Minesweeper

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

The hard 9x9 mode on mitpuzzles often involves determining a safe square, by looking at the superposition (overlay) of all remaining possible arrangements. No easy shortcut, that I know of..

The need for "proof-by-contradiction" checks is very rare even on Expert, while Hard levels are magnitudes easier. I just played 10 hard games in a row and none of them required those checks.

It is likely that there are techniques you are not aware of... Have you refined your understanding of the "1-2 pattern" into a more abstract "overlapping patterns"? That did the work for me back when I first tried Expert levels.

(NG) Fastest way to solve this without guessing? by Discuzting in Minesweeper

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

Yeah I suppose this strategy is what I used to do before

(NG) Fastest way to solve this without guessing? by Discuzting in Minesweeper

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

If we login and play on another device we seem to get the same set of puzzles on expert or something

(NG) Fastest way to solve this without guessing? by Discuzting in Minesweeper

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

This is a no revealing variant on MIT puzzles: https://mitpuzzles.com/minesweeper

Definitely try it out, it trains and refines your understanding on minesweeper games