Message Boards Message Boards

6
|
43684 Views
|
163 Replies
|
143 Total Likes
View groups...
Share
Share this post:

[WSG20] Programming Fundamentals Week 4

This week we will be looking at the following topics:

  • Tuesday May 26: Dataset
  • Wednesday May 27: Package Development
  • Thursday May 28: Workbench
  • Friday May 29: Useful Tips and Session Wrap Up

Please post your questions on this thread and look out for daily challenges.

163 Replies
Posted 4 years ago

Hi Abrita,

thank you for your clarifications. With the expected output I was able to solve 1.18. For 1.4 and 1.13 my solutions are still not accepted. I will send you my notebook by mail.

POSTED BY: Bernd Barsuhn
Posted 4 years ago

The correct radius is 0.05.

What gets into Graphics3D should look like

{{Orange, Sphere[{x1,y1,z1}, 0.05]}, ... {Orange, Sphere[{xn, yn, zn}, 0.05]}}

where all xi, yi, zi are in the interval [0, 1]. You might remove the call to Graphics3D from your code to check it.

Correct depth of the list is also important. {{{Orange, Sphere[{x1,y1,z1},0.05]},...}} will also not be accepted.

POSTED BY: Bernd Barsuhn
Posted 4 years ago

I've encountered another strange situation. When I try my code for exercise 1.19 on the exercises page, no text is found. However, if I copy the code (including the image) to Mathematica 12.1 desktop, everything works as expected (both words highlighted).

Has anyone else seen this (or similar) behavior? Thanks.

POSTED BY: Richard Hewens
Posted 4 years ago

Hi Bernd,

Specifying a list of pairs as primitives in Graphics3D, where each pair contains a single color and a single sphere

I tried this and several other alternatives, none were accepted including Abrita's hint below (Note: the .5 should be 0.5).

Problem 1.8: Sphere[p,r] represents a sphere of radius r centered at the point p. We know r is to be .5 and p can be created out of a triplet of RandomReal numbers less than 1 (because they have to be inside the unit cube). Use Table to create a 100 of these.

POSTED BY: Updating Name

I have sent the file with all exercises solved!

Hi Muhammad, Click inside the cell and hit the shortcut keys to change to "Input" style Cmd 9 on a Mac or Alt 9 on Windows. Let us know if that does not work.

Please feel free to email wolfram-u@wolfram.com with your solutions.

Hi Bernd, Thank you for your comments on 1.8. We are working on the auto-grader to accept the alternate solutions. The solutions you suggest are perfectly acceptable.

By unit cube we are recommending that the centers of the spheres be points within 0 and 1 in all three axes. Yes - there is an issue with 1.8 accepting alternate solution. We are working on it. Please feel free to email your valid solution to wolfram-u@wolfram.com

@Yuliia Maidannyk, to achieve the Level I certification, you must successfully answer 70% of the exercise set.

POSTED BY: Jamie Peterson
Posted 4 years ago

1.15 My code produces the correct (expected) output and uses the suggested functions, but doesn't check. I've tried it with both Integer and String outputs. ???

POSTED BY: Updating Name

Hi Abrita,

how can we download the exercises notebook. On my end, it is displayed as a web-page with no options to download.

Thanks,

Slava

For 1.8, I used RandomPoint for the center of the sphere rather than a triplet of random real numbers. My code produces the expected output but is not accepted. What is your definition of the unit cube?

Posted 4 years ago

Nr. 1.18 was wrong. It has been corrected.

POSTED BY: Paul Erickson

Thank you, Abrita! I have received it yesterday!

Nr 1.7 is not more wrong! It has been corrected!

Nr. 1.18 is not more wrong! It has been corrected!

[WSG20] Programming Fundamentals Week 4

POSTED BY: Jürgen Kanz

Thank you Paul!

Yes, there was a ToLowerCase in my code, to collect the first letters from all words.

POSTED BY: Jürgen Kanz

Hints for solutions: Again these are hinting at one way to solve these problems. If you have a different solution producing the same expected output, please email us (wolfram-u@wolfram.com) your entire exercise notebook with solutions.

  • Problem 1.4: RandomChoice will give you a random letter. Other WL functions to consider are Riffle to mix up consonants and vowels, StringJoin to join them, and Table to do the whole process 5 times
  • Problem 1.5: There might have been an issue initially but it was fixed right away. The correct solution should be accepted now.
  • Problem 1.7: A Panel with its Background set should be mapped over the letters (in upper case) of Russian Alphabet
  • Problem 1.8: Sphere[p,r] represents a sphere of radius r centered at the point p. We know r is to be 0.05 and p can be created out of a triplet of RandomReal numbers {x,y,z} less than 1 (because they have to be inside the unit cube). Use Table to create a 100 of these.
  • Problem 1.11: Yes this is from the documentation - Neat Examples.
  • Problem 1.13: WordList[] should provide the list of words. StringTake can be used on a list of strings - so it can be used on WordList[]. Counts and TakeLargest should do the rest.
  • Problem 1.18: The confusion might have been due to the wrong screenshot for the expected output. This has been updated. enter image description here

Hi Muhammad, We tried to keep the solutions as simple one-liners.You will not have to use Module or Block.

Hi Valeriu, The certificates of completions have been going out this week. Please email us if you haven't received yours.

Hi Marko, Hope you received the email by now.

this should work ok now.

In reply to Juergen on 1.13: I had this issue as well generating your number, but if you consider the number of characters as case sensitive - i.e. "A" and "a" separately... Somewhat ambiguous question, so figure this hint is fair game...

POSTED BY: Paul Erickson

Hello Bernd,

Thank you very much for your hint. I have changed the language to English and WordList[] comes now with the list of English words. The list is the same as you can get with WordList[Language -> "English"]. The difference in the counting result remains the same.

Expected output: enter image description here

My output: enter image description here

POSTED BY: Jürgen Kanz

Hello All,

Thanks for commenting on the issues. We're working on them.

  • Problem 1.11: GenomeData does seem to be running into some issues on the cloud. However the the auto-grader should accept the solution even if the cell throws error on evaluation.

  • Problem 1.18: The expected out is as follows (this was fixed on the cloud but in some cases the update is not showing up when you are working on your local copy) enter image description here

I'll add a few more hints for the problems that seem to be having issues with accepting solutions. As many of you have pointed out TMTOWTDI :) (there's more than one way to do it - more so in the Wolfram Language). We're continuing to work on the autograder to ensure all viable solutions are accepted. If you continue to face issues, feel free to download the exercise notebook, complete your solutions and send to wolfram-u@wolfram.com.

Thanks for your patience.

Posted 4 years ago

I'm also seeing an error on the webpage with the Genome data, although it works fine in Mathematica 12.1 desktop. The exercise 1.11 is taken directly from the GenomeData help page (in the "Neat Examples" section). Oddly, the example code generates an error on the exercises web page, but is accepted as a "correct" response.

POSTED BY: Richard Hewens
Posted 4 years ago

Hello Juergen,

I am also from Germany. Did you know, that you can work around the issues publishing Mathematica code or notebooks to an international community by setting the language to English in the interface tab of the Mathematica preferences dialog? This is easy to toggle without changing any language settings of the OS. You'll just have to restart the MMA frontend. After publishing, you can easily switch back to your preferred language, if you want to.

It seems that the verification of the exercise solutions has some issues. Not every valid solution is accepted. As of 1.13, I also was not able to find an accepted solution. I would suspect, that there might be no solution that would be accepted at all.

Question to all: Did anyone find an accepted solution to 1.4, 1.13 or 1.18? I finally gave up on those leaving my not accepted solutions in place.

For those still struggling with 1.8 you might want to check my hints on an accepted solution for 1.8 from my post from yesterday. I am just giving hints on what the verification wants to see, not on the task in solving the exercise.

If anyone did find a solution to 1.4, 1.13 or 1.18, I would appreciate some hints from the community. You should not post a solution, but some insight on what the verification wants to see would be helpful. I don't think this will be considered as cheating. @Wolfram: Could you confirm this or add some clarification on those exercises.

POSTED BY: Bernd Barsuhn

Same, there is some error with GenomeData[] on the webpage but on my end everything works fine as can be seen in the screenshot

POSTED BY: Yuliia Maidannyk

Well done, from my point of view. My code is less elegant but provides the same output. The funny thing in my case is that my code runs very well on Mathematica V12.1, but it produces hard errors on the test page.

POSTED BY: Jürgen Kanz

I have already come up with 4 different ways to write this code for 1.11 and none of them are accepted. enter image description here

POSTED BY: Yuliia Maidannyk

Hi, I have to admit that my fun in doing the test is decreasing very fast. Today I do not have solutions for all tasks (approx. 4 are still open). For the rest, I can generate the EXPECTED OUTPUT, but even then in most cases, the solutions are not accepted.

For some tasks, I can not generate the requested solution. An example related to 1.13:

WordList[]

It gives me a list of German words, because I am located in Germany.

WordList[Language->"English"]

Gives me a list of English words with a length of 39176

WordList["KnownWords", Language -> "English"]

Gives me a list of English words with a length of 84923

So, I am producing the correct sequence of letters, but I assume that the values are not accepted because not all students can use the same prerequisites.

I could add more examples, where I am facing issues. Perhaps your checking algorithm does not only look for the correct outcome, but he is also looking for Functions in a certain order that should be applied. If this is the case, please consider "there are many roads to Rome".

Therefore, I am going to finish all tasks, because it is a challenge for me, but that is it. I do not get the impression that your test environment is mature enough.

POSTED BY: Jürgen Kanz
Posted 4 years ago

I accidentally typed * in the solution cell and it is converted to item cell and now I can't work on it. Can someone please tell me how to reset the test?

POSTED BY: Muhammad Ali
Posted 4 years ago

Since this is indeed a test I wouldn't recommend posting your solution. If your query requires an explicit mention of your solution then I would recommend contacting: wolfram-u@wolfram.com

POSTED BY: Muhammad Ali

Do all 20 exercises have to be completed correctly in order to achieve a certificate?

I have a few exercises for which my code produces correct outputs but the answer isn't accepted. For example this one: enter image description here

POSTED BY: Yuliia Maidannyk

Sorry, misunderstood the problem 1.15.

In Problem 1.15, the expected output is incorrect:

enter image description here

The correct output should be 654421

I experienced the same issue. I have solutions that generate the expected output for 1.8, 1.13, 1.14 but are not accepted. Can we e-mail our solutions to someone to have them checked manually?

Posted 4 years ago

My solution for 1.5 is not accepted even though it generates the expected output.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

1.18 is clearly wrong I even plotted it on the map with concentric disks of distances centered at Washington DC to visually confirm.

POSTED BY: Muhammad Ali
Posted 4 years ago

I had to try a lot of correct solutions, before I was able to find an accepted solution for 1.8.

One issue with 1.8 is the definition of "the unit cube". As of my knowledge a unit cube is simply a cube with unit edge length. This definition does not specify a position of "the unit cube". Wolfram Language does have a geometric region function named Cube, where "Cube[]" is defined to be a unit cube centered at the origin. But this seems not to be accepted in 1.8, which seems to assume, that "the unit cube" is centered at {0.5,0.5,0.5}.

Secondly the obvious solution for the Graphics3D primitive list would be the color primitive followed by a sequence of spheres. As the Sphere function does allow to represent a collection of spheres, by specifying a list of center points as its first argument, the simplest solution would be a single color followed by a single Sphere call with a list of 100 center points. Again, both of this seems not to be, what would be accepted as a solution in 1.8. A far less optimal solution finally worked for me. Specifying a list of pairs as primitives in Graphics3D, where each pair contains a single color and a single sphere.

I still did not find any accepted solution for 1.4, 1.13 and 1.18. Additionally the expected output shown in 1.18 does not seem to be correct. At least for my interpretation of the question. Last in the list of the expected outcome is Cheyenne (Wyoming), which should then be the closest capital to Washington DC. I am not living in the states, but as of my knowledge this is obviously not correct.

POSTED BY: Bernd Barsuhn

Also having trouble with 1.11 as exact output match, and tried length and alpha sort on 'standardnames' etc, but even though elements and order match, no check mark. I think the exact criteria for acceptance must be a bit more obscure than it should be...

1.12 was a bit picky - didn't like FontStyle ... but eventually trying various variants...

Agreed 1.4, 1.8, 1.13, 1.18 seem to be having problems, but not quite done with the others yet.

POSTED BY: Paul Erickson
Posted 4 years ago

Same, I also have issues with 1.4, 1.8, 1.13, 1.18. Moreover, if I try to introduce unnecessary variables to store intermediate results or start scoping these variables by using Block, With or Module without changing the output, the previously correct result starts getting recognized as incorrect.

POSTED BY: Muhammad Ali

Hi, Abrita,

It seems that the set of exercises has some inconveniences in numbers: 1.4, 1.7, 1.8, 1.13, 1.18

Additionally I have to ask if the Certificate of Completion was sent to participants. I have not received anything!

Posted 4 years ago

Got it. Thanks a lot!

POSTED BY: Bernd Barsuhn
Posted 4 years ago

I received the email with the link. Thank you!

POSTED BY: David Schulz

Hi @Bernd Barsuhn, those emails are being sent this morning. Yours should have arrived by now. Let me know, please.

POSTED BY: Jamie Peterson

@David Schulz, those emails are being sent this morning. Yours should have arrived by now. Let me know, please.

POSTED BY: Jamie Peterson
Posted 4 years ago

Thank you for the clarification. I have not yet received an email with information about the exercises. It looks like people are maybe already working on the problems, and I would like to have plenty of time to complete the work. Thanks again.

POSTED BY: David Schulz
Posted 4 years ago

I still did not get a link to the exercises

POSTED BY: Bernd Barsuhn
Posted 4 years ago

Thank you

POSTED BY: Muhammad Ali

Hi @David Schulz, I am sorry for the miscommunication. There are two different levels of certification associated with this study group. The first is a certificate of program completion, and that requires the four quizzes. The other is Level I certification in programming fundamentals, and that requires the exercise set. The previous (April) study group did not offer Level I certification, so that has caused a little confusion.

POSTED BY: Jamie Peterson
Posted 4 years ago

For clarification, on May 18, during the recorded Study Group, I asked a question about earning the Level I certification in Wolfram Technology. Here is my question and the answer I received: ******************* Q: For Program completion and Wolfram Technology Certified Level I, is there a difference between quiz questions and assigned questions?

A: Only quizzes are going towards your certification. Challenges in community, poll questions and other in session items are strictly review. **************** So, my understanding was that satisfactory completion of the quizzes was the only requirement for earning the Wolfram Technology Certified Level 1. Please confirm that my satisfactory completion of the quizzes has been applied to my Wolfram Technology Level 1 certification.

Thank you!

POSTED BY: David Schulz
Posted 4 years ago

@Abrita Chakravarty Also the auto-grader is not expecting the code to be written in a certain way rather as long as it produces the correct output, anything goes, right?

POSTED BY: Muhammad Ali

Absolutely!

Posted 4 years ago

@Abrita Chakravarty Are multiple attempts allowed in auto-graded exercises?

POSTED BY: Muhammad Ali
Posted 4 years ago

Thanks Abrita. Will have look.

POSTED BY: Derek Jones

Hi Derek, This will be a good place for you to start https://www.wolframphysics.org/

Posted 4 years ago

Hello everyone. I am a novice to physics, but I am quite interested in the potentially new way of interpreting physics, offering my contribution where I can and wondering if this is the right place to start. Could someone please help?

POSTED BY: Derek Jones
Posted 4 years ago

Hi Jamie, I didn't receive the email regarding the exercises on Wednesday, could you send the link to me as well?

POSTED BY: Marko Rossi

Paul, I'd like to troubleshoot your email issue with you directly. I will send an email to you shortly.

POSTED BY: Jamie Peterson

Since I haven't been receiving the reminder email (at all), could you post it here as well? or at least post that they have been sent...

POSTED BY: Paul Erickson

Hi All, Sorry for the delay in sending out the link. Please rest assured you will have at least 2 weeks from the date of release of the exercises, to submit the solutions.

Posted 4 years ago

On Wednesday, I did not get a link to the exercises.

POSTED BY: David Schulz

What shall I do if I didn't receive the link for the exercises yesterday?

POSTED BY: Yuliia Maidannyk
Posted 4 years ago

Thank you for the update on the exercises and the timeline with regard to completion of those exercises. I enjoyed the WSG.

POSTED BY: David Schulz

Will there be a link to the notebooks that were used in the presentations?

POSTED BY: Charles Glover

Thanks for sharing Abrita! Enjoyed it.

Posted 4 years ago

Thank you I asked this during the session.

POSTED BY: Muhammad Ali

Yes, there will be one link to a cloud notebook with the exercises required for the Level I certification. The link will be shared with all participants in a Study Group email scheduled for Wednesday, June 3. You'll have 2 weeks to complete the exercises. Quizzes should be completed by Friday, June 5.

POSTED BY: Jamie Peterson

Is there a single location for all the coding challenges required for completion of the Level 1 cert? \

POSTED BY: Joseph Sauvageau

Thanks, Valeriu.

The response follows from this:

In[1]:= Cases[{a - b, c + d, e - 2 f}, HoldPattern[_ + Times[x_ /; x < 0, _]]]
Out[1]= {a - b, e - 2 f}

There is no Minus[] function as an arithmetic operation. Minus[x] is only the arithmetic negation of x.

Thank you. It takes some getting used to. Does

enter image description here

work as expected because there is no way to evaluate Blank[]^Blank[] even if the blanks are the same? Here is another curious example; enter image description here

Why does this not pick up e-2f?

Posted 4 years ago

Because it is the same symbol. Such as a + a. Blank[] is also just a symbol. It has no special meaning in evaluation rules.

This was discussed in Week 3 Part 3 "Evaluation Control". To use an expression with blanks in pattern matching, you should use HoldPattern. See slide 24 of the "Evaluation Control" presentation notebook.

POSTED BY: Bernd Barsuhn

Hi Paul, here is the link to Quiz 4:

Quiz 4

I am puzzled by the following:

enter image description here

Why are the two blanks interpreted as the same?

I've not received the reminder emails. I don't have the links to the fourth quiz. Nor to the (higher level) course (level 1 programmer proficiency)? Not sure if I'll be doing that, but would like to investigate. Paul

POSTED BY: Paul Erickson
Posted 4 years ago

Thanks.

POSTED BY: rjehanathan

Yup link to the exercises will go out on Tuesday. Thanks.

Posted 4 years ago

Abrita, I haven't received the link to the exercises that were mentioned in the webinar earlier today.If that's because you haven't sent it out yet that's fine. Regards, Rajeev

POSTED BY: rjehanathan
f[t_, n_] := -t^n {Cos@t Sin@t^2, Sin@t Cos@t^2};
ParametricPlot[
 Evaluate[f[t, #] & /@ Range[0, 1, 0.1]], {t, 24 \[Pi], 48 \[Pi]}, 
 Axes -> False, PlotStyle -> Thick]

enter image description here

Posted 4 years ago

My favorites: Manipulate and all kinds of Entity functions!

Now that many art galleries are closed around the world, here is a small app that shows random paintings from the Wolfram entities by different centuries.

In case the Manipulate is not working on this site, here is a screenshot: enter image description here

I started by writing an oneliner showing a list of random paintings, then used Select function to filter paintings by year and wrapped Manipulate around the whole thing. Lastly, I added some error handling in case of missing data or if filtering returned an empty list.

POSTED BY: Marko Rossi
Posted 4 years ago

The published notebook does not seem to render correctly in all browsers, when being viewed on this community page. You might try it using the "Make Your Own Copy" button. This always worked for me.

POSTED BY: Bernd Barsuhn
Posted 4 years ago

POSTED BY: Bernd Barsuhn

Thanks, Abrita,

This has been a BLAST!!! :-)

POSTED BY: Lori Johnson

Hello all!

My favorite Wolfram Language function is Manipulate because it is simply one of the best ways to show young people how patterns develop and change.

This code is inspired by John. H. Conway (1937-2020), Richard K. Guy (1916-2020) in their Book of Numbers (Springer-Verlag 1996, page 31, Figure 2.10).

ENJOY!

Manipulate[Multicolumn[show[n], columns, Appearance -> "Horizontal"],

 {{columns, 10}, 5, 25, 1}, {{n, 25, "Numbers to display:"}, 5, 1000, 
  1}, {show, {redDots -> "Dots", redSquares -> "Numbers"}},

 LabelStyle -> {14, FontFamily -> "Times"},
 FrameLabel -> {"", "", 
   Column[{Style["What Shapes Do The Red Figures Make?", Bold, 18],
     Style["(a.k.a. Residue Classes for Kids)", Gray]}, 
    Alignment -> Center], ""},

 Initialization :> {
   tinyCircRed = 
    Graphics[{Darker@Red, Disk[{0, 0}, .01]}, ImageSize -> 5],
   tinyCircGray = 
    Graphics[{Lighter@RGBColor[.9, .9, .9], Disk[{0, 0}, .01]}, 
     ImageSize -> 5],

   redSquares[max_] := Table[
     If[IntegerQ[Sqrt[x]] == True, 
      Style[x, Darker@Red, 16, Bold, FontFamily -> "Times"], 
      Style[x, Lighter@Gray]], {x, 1, max, 1}],

   redDots[max_] := Table[
     If[IntegerQ[Sqrt[x]] == True, tinyCircRed, tinyCircGray], {x, 0, 
      max, 1}]}]

enter image description here

POSTED BY: Lori Johnson
Posted 4 years ago

POSTED BY: Bernd Barsuhn

CHALLENGE: Find a dataset of the 5 largest observed altitudes in the Fireballs & Bolides dataset.

ballBols = ResourceData["Fireballs and Bolides"];
ballBols[TakeLargestBy["Altitude", 5]][All, "Altitude"]

enter image description here

A little context and styling:

Dataset[Take[ReverseSort@ballBols[All, {"Altitude", "NearestCity"}], 
  5], HeaderBackground -> Lighter@Red, 
 HeaderDisplayFunction -> (Style[#, Bold, 18] &)]
(*nicer with headers to show context*)

enter image description here

BONUS: Plot the nearest cities for the 10 entries with largest altitudes in the Fireballs & Bolides dataset, labeling each city.

nearCity = ballBols[TakeLargestBy["Altitude", 10]][All, "NearestCity"]

enter image description here

Plot with easy with read lables:

GeoListPlot[nearCity, GeoLabels -> Automatic, 
 PlotMarkers -> GeoMarker, GeoBackground -> "ReliefMap", 
 LabelStyle -> {Darker@Red, 14, Background -> LightYellow}]
(*large, easy to read labels*)

enter image description here

POSTED BY: Lori Johnson

End-of-study-group open challenge: To all the enthusiastic study group participants ... post a snippet of code using your favorite Wolfram Language function--may be something you learned in one of the study group sessions.

Feel free to "Like" posts by fellow study group participants and we will declare the most liked post, at our last session, on Friday.

Posted 4 years ago

Part 1: ResourceData[ResourceObject["Fireballs and Bolides"], "Dataset"][ Select[QuantityQ[#Altitude] &] /* TakeLargestBy[QuantityMagnitude[#Altitude] &, 5]]

Extra Credit: GeoListPlot[ Normal@ResourceData[ResourceObject["Fireballs and Bolides"], "Dataset"][ Select[QuantityQ[#Altitude] &] /* TakeLargestBy[QuantityMagnitude[#Altitude] &, 10], "NearestCity"], GeoLabels -> True]

POSTED BY: rjehanathan

Excellent. Thanks for sharing!

Posted 4 years ago

Hi Abrita,

During the Tuesday webinar someone asked if there is a way to tell if Dataset operators are ascending or descending. There are undocumented functions AscendingQ and DescendingQ in the Dataset package that do this. See this post for details.

Dataset`AscendingQ /@ {Total, Select, All, Key["a"]}
(* {True, True, False, False} *)
POSTED BY: Rohit Namjoshi
Posted 4 years ago
ResourceData["Fireballs and Bolides"][TakeLargestBy[#Altitude &, 5]]

ResourceData["Fireballs and Bolides"][
  TakeLargestBy[#Altitude &, 10],
  "Coordinates",
  GeoNearest[Entity["City"], #] &][
 GeoListPlot[#, GeoLabels -> True, PlotLegends -> None] &]

enter image description here

POSTED BY: Rohit Namjoshi

May 26-27 Challenge: From EIWL ...

Find a dataset of the 5 largest observed altitudes in the Fireballs & Bolides dataset.

Extra credit:

Plot the nearest cities for the 10 entries with largest altitudes in the Fireballs & Bolides dataset, labeling each city.

Sorry. That was a typo.

Did you mean Friday May 29 ?

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract