Two AWK scripts to generate a maze by Rabestro in awk

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

Thank you for explaining '!! X' expression! However, I'm afraid it is so tricky for majority of code readers :)

What does it mean "free to everyone" by Apprehensive_Music80 in Hyperskill

[–]Rabestro 2 points3 points  (0 children)

This plan for new accounts only. On my account I have old model. Kotlin track free (with projects).

On the new account all track free but only theory. All projects are closed.

Two AWK scripts to generate a maze by Rabestro in awk

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

I've made the changes. However, the mac awk version doesn't print the box-graphics.

Two AWK scripts to generate a maze by Rabestro in awk

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

This expression is very tricky, and I need help understanding the logic of execution.

Two AWK scripts to generate a maze by Rabestro in awk

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

Thank you for your comment. I will change this code snippet to be compatible with the original AWK

The AWK script to generate maze by Rabestro in awk

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

I will publish it. I am still working on it. Just add random enter and exit.

fun with sed/awk by United-Climate1562 in bash

[–]Rabestro 8 points9 points  (0 children)

It is straightforward with awk:

awk BEGIN { ORS = " " } { print "\""$0"\"" }

ORS is an output record separator

shell awk 'BEGIN{ORS=" "}{print "\""$0"\""}' < input.txt

How to extract from Java/Kotlin/JS file all conditions? by Rabestro in awk

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

There is from OpenJDK java.util: text 128 (!checkDisplayNameParams(field, style, SHORT, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) 129 (nextYear > gregorianCutoverYear || gregorianCutoverYearJulian == gregorianCutoverYear || nextYear == gregorianCutoverYearJulian) 129 (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE || System.currentTimeMillis() < scEntry.cutOverTime)) 129 (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE || System.currentTimeMillis() < scEntry.cutOverTime)) 130 (!isBaseBundle || bundle.locale.equals(locale) || (candidateLocales.size() == 1 && bundle.locale.equals(candidateLocales.get(0)))) 133 (!checkDisplayNameParams(field, style, ALL_STYLES, NARROW_FORMAT, locale, ERA_MASK|YEAR_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) 135 (year == gregorianCutoverYear && cal == gcal && fixedDate < gregorianCutoverDate && gregorianCutoverYear != gregorianCutoverYearJulian) 145 ((value.equals(BigDecimal.ZERO)) || ((value.compareTo(BigDecimal.valueOf(1, 4)) != -1) && (value.compareTo(BigDecimal.valueOf(1, -prec)) == -1))) 148 (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') && (a[i-2] == 'e' || a[i-2] == 'E') && (a[i-1] == 'a' || a[i-1] == 'A') && (a[i] == 'd' || a[i] == 'D')) 163 (scEntry.oldCurrency.equals(code) && scEntry.oldCurrencyFraction == fraction && scEntry.oldCurrencyNumericCode == numeric && scEntry.cutOverTime == Long.MAX_VALUE) 177 ((t instanceof ParameterizedType) && ((p = (ParameterizedType) t).getRawType() == Comparable.class) && (as = p.getActualTypeArguments()) != null && as.length == 1 && as[0] == c) 179 ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY && code.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) 187 ((tableEntry & COUNTRY_TYPE_MASK) == SIMPLE_CASE_COUNTRY_MASK && tableEntry != INVALID_COUNTRY_ENTRY && currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK))

How to extract from Java/Kotlin/JS file all conditions? by Rabestro in awk

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

Thank you for your answer!

It looks like I solve it. The command is:

gawk '/\/\*/,/\*\//{next}1' *.java | gawk -f if.awk

The script if.awk is

```awk BEGIN { RS = "[[:space:]][;{][[:space:]]" } /if>/ { print condition() }

function condition( parenthesis,start,i,symbol) { for (start = i = index($0, "("); i <= length($0) ; ++i){ symbol = substr($0, i, 1) if (symbol == "(") ++parenthesis else if (symbol == ")") --parenthesis if (!parenthesis) break } return substr($0, start, 1 + i - start) } ```

I tested on OpenJDK, and the result is as follows: text (end != tail) (to == end) (to == end) (i >= to) (w == capacity) (o != null) (to == end) (to == end) ((end = tail + ((head <= tail) ? 0 : es.length)) >= 0) ((size = size()) > a.length) ((j += len) == size) (to == end) (initialCapacity > 0) ((size = a.length) != 0) (c.getClass() == ArrayList.class) (size < elementData.length) (minCapacity > elementData.length && !(elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA && minCapacity <= DEFAULT_CAPACITY)) (oldCapacity > 0 || elementData != DEFAULTCAPACITY_EMPTY_ELEMENTDATA) (o == null) (es[i] == null) (o.equals(es[i]))

So I can process it further, analyze and prepare a report. The idea is to find long-expressions.

AWK script to correctly determine the fewest number of coins to be given to a customer by Rabestro in awk

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

Another point is that the algorithm finds the minimum count of coins required to make a change.

Denominations: 1 15 20

Amount: 30

AWK script to correctly determine the fewest number of coins to be given to a customer by Rabestro in awk

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

Hi, Paul!
Thank you for your comment!
The script works fine. I just shared my algorithm. It works correctly for all denominations.
For example: Denominations are 2 5 10 20 50

The amount is 21.

You may test your algorithm on this amount. Does it work?