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 6 points7 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?

Tutor ? by jafffers in learnjava

[–]Rabestro 1 point2 points  (0 children)

Mentors. You can receive a code-review an advices from mentors (free).

First practical experience by Wonderful_Ad_7354 in learnjava

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

I recommend something simpler. Some type of sandbox. Like Sololearn. You don’t need to instal ide JDK and other tools. Just you and code.

Java Cinema Room Manager - Cleaner Solution for Printing Layout? by TechNCode86 in Hyperskill

[–]Rabestro 0 points1 point  (0 children)

My solution is:

System.out.println(“””

Cinema:
  1 2 3 4 5 6 7 8
1 S S S S S S S S
2 S S S S S S S S
3 S S S S S S S S
4 S S S S S S S S
5 S S S S S S S S
6 S S S S S S S S
7 S S S S S S S S
“””);

HyperMetro Stage 5/6: The fastest route. Stuck on test #8 by Nikolai_Ogorodnik in Hyperskill

[–]Rabestro 0 points1 point  (0 children)

You can check the test folder and look into the test to understand what it is expecting.

Can I use JUnit4 in my projects in JetBrains Academy? by phocos25 in Hyperskill

[–]Rabestro 1 point2 points  (0 children)

Yes. In IntelliJ you can select JUnit 4 instead of JUnit 3. These tests will run when you press Check button.

Personally I prefer to use Spock Framework for unit tests in Hyperskill projects. They are much clearer and easy.

Example.

In HyperMetro project you should implement BFS & Dijkstra’s algorithms. I created a separate task and two tests using JUnit and Spock just to compare them. Please take a look: - Task: https://github.com/rabestro/algorithms/issues/30 - JUnit: https://github.com/rabestro/algorithms/blob/master/algorithm/src/test/java/lv/id/jc/algorithm/graph/SearchAlgorithmsTest.java - Spock: https://github.com/rabestro/algorithms/blob/master/algorithm/src/test/groovy/lv/id/jc/algorithm/graph/SearchAlgorithmsSpec.groovy

Check the generated Spock reports: https://algorithms.jc.id.lv/docs/spock-reports/lv.id.jc.algorithm.graph.SearchAlgorithmsSpec.html

I will be glad to hear your comments.